Explorar el Código

feat(templates): Add settings.json with context-aware statusline

Statusline shows project, git branch, model, and a 24-segment context
usage bar. Token count is summed from the transcript's .message.usage
(input + cache_creation + cache_read + output) via jq; context window
auto-detects 1M vs 200k from the model display name.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AwW2Sen58WCSMTvWzfW7sv
0xDarkMatter hace 1 mes
padre
commit
b86eec63ee
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6 0
      templates/settings.json

+ 6 - 0
templates/settings.json

@@ -0,0 +1,6 @@
+{
+  "statusLine": {
+    "type": "command",
+    "command": "input=$(cat); project=$(echo \"$input\" | jq -r '.workspace.project_dir' | sed 's|.*[/\\]||'); model=$(echo \"$input\" | jq -r '.model.display_name'); cwd=$(echo \"$input\" | jq -r '.workspace.current_dir'); transcript=$(echo \"$input\" | jq -r '.transcript_path'); cd \"$cwd\" 2>/dev/null; branch=$(git -c core.fileMode=false rev-parse --abbrev-ref HEAD 2>/dev/null || echo 'no-git'); last=$(grep '\"usage\":' \"$transcript\" 2>/dev/null | tail -1); tokens=$(echo \"$last\" | jq '(.message.usage.input_tokens//0)+(.message.usage.cache_creation_input_tokens//0)+(.message.usage.cache_read_input_tokens//0)+(.message.usage.output_tokens//0)' 2>/dev/null); if [ -z \"$tokens\" ] || [ \"$tokens\" = \"null\" ]; then tokens=0; fi; case \"$model\" in *1M*|*\"1m\"*) context_window=1000000;; *) context_window=200000;; esac; if [ \"$tokens\" -ge 1000 ]; then token_display=$(awk \"BEGIN {printf \\\"%.1fk\\\", $tokens/1000}\"); else token_display=\"$tokens\"; fi; percentage=$(awk \"BEGIN {printf \\\"%.0f\\\", ($tokens/$context_window)*100}\"); filled=$(awk \"BEGIN {printf \\\"%.0f\\\", ($percentage/100)*24}\"); progress_bar=''; for i in $(seq 1 24); do if [ \"$i\" -le \"$filled\" ]; then progress_bar=\"${progress_bar}█\"; else progress_bar=\"${progress_bar}░\"; fi; done; printf '📂 \u001b[1m%s\u001b[0m  🌿 \u001b[32m%s\u001b[0m  🧠 \u001b[36m%s\u001b[0m  \u001b[32m%s\u001b[0m \u001b[90m%s (%s%%)\u001b[0m' \"$project\" \"$branch\" \"$model\" \"$progress_bar\" \"$token_display\" \"$percentage\""
+  }
+}