Establishes the global AI development config repo from scratch: - Chunk 1: repo skeleton, install.sh, statusline, deploy manifest - Chunk 2: core instructions (coding/git/testing), CLAUDE.md rewrite (always-on + content index two-tier model), docs restructure, 6 ADRs, ROADMAP.md, .gitkeep placeholders - Bootstrap skills in .claude/skills/ (to be catalogued and migrated to .agents/skills/ in Chunk 3) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
73 lines
3.4 KiB
Bash
Executable File
73 lines
3.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
SCRIPT="$REPO_ROOT/providers/claude-code/statusline-command.sh"
|
|
PASS=0
|
|
FAIL=0
|
|
|
|
pass() { echo " PASS: $1"; PASS=$((PASS + 1)); }
|
|
fail() { echo " FAIL: $1"; FAIL=$((FAIL + 1)); }
|
|
|
|
# Strip ANSI escape codes so assertions work on plain text
|
|
strip_ansi() { sed 's/\x1b\[[0-9;]*m//g'; }
|
|
|
|
# Pipe JSON to the script and return stripped output
|
|
run() { echo "$1" | bash "$SCRIPT" | strip_ansi; }
|
|
|
|
# Baseline input covering all segments
|
|
FULL='{"workspace":{"current_dir":"/home/user/myproject"},"model":{"display_name":"Sonnet 4.6"},"context_window":{"used_percentage":20,"total_input_tokens":15000,"total_output_tokens":5000},"cost":{"total_cost_usd":0.25}}'
|
|
|
|
echo "--- assembly ---"
|
|
|
|
out=$(run "$FULL")
|
|
|
|
echo "$out" | grep -q "myproject" && pass "shows basename of working directory" || fail "dir missing — got: $out"
|
|
echo "$out" | grep -q " · " && pass "segments joined with ' · '" || fail "separator missing — got: $out"
|
|
echo "$out" | grep -q "Sonnet 4.6" && pass "shows model name" || fail "model name missing — got: $out"
|
|
echo "$out" | grep -q "context 20%" && pass "shows context % with 'context' label" || fail "context label wrong — got: $out"
|
|
|
|
echo ""
|
|
echo "--- token formatting ---"
|
|
|
|
# 15k + 5k = 20k → shown as "20k tokens"
|
|
echo "$out" | grep -q "20k tokens" && pass "formats total tokens as Xk when >= 1000" || fail "Xk format wrong — got: $out"
|
|
|
|
# Sub-1000 total: 500 + 300 = 800 → shown as "800 tokens"
|
|
LOW='{"workspace":{"current_dir":"/x"},"context_window":{"total_input_tokens":500,"total_output_tokens":300}}'
|
|
out_low=$(run "$LOW")
|
|
echo "$out_low" | grep -q "800 tokens" && pass "shows raw count when total tokens < 1000" || fail "sub-1000 format wrong — got: $out_low"
|
|
|
|
echo ""
|
|
echo "--- cost formatting ---"
|
|
|
|
# 0.25 → 25¢
|
|
echo "$out" | grep -q "25¢" && pass "formats sub-dollar cost as cents (¢)" || fail "cents format wrong — got: $out"
|
|
|
|
# 1.71 → $1.71
|
|
DOLLAR='{"workspace":{"current_dir":"/x"},"cost":{"total_cost_usd":1.71},"context_window":{"total_input_tokens":0,"total_output_tokens":0}}'
|
|
out_dollar=$(run "$DOLLAR")
|
|
echo "$out_dollar" | grep -qF '$1.71' && pass "formats dollar-plus cost as \$X.XX" || fail "dollar format wrong — got: $out_dollar"
|
|
|
|
echo ""
|
|
echo "--- missing fields omitted ---"
|
|
|
|
# No cost field → no ¢ or $ in output
|
|
NO_COST='{"workspace":{"current_dir":"/x"},"context_window":{"total_input_tokens":0,"total_output_tokens":0}}'
|
|
out_nocost=$(run "$NO_COST")
|
|
! echo "$out_nocost" | grep -qE '[¢$]' && pass "omits cost segment when cost absent" || fail "cost shown unexpectedly — got: $out_nocost"
|
|
|
|
# Zero tokens → no token segment
|
|
ZERO_TOK='{"workspace":{"current_dir":"/x"},"context_window":{"total_input_tokens":0,"total_output_tokens":0}}'
|
|
out_zerotok=$(run "$ZERO_TOK")
|
|
! echo "$out_zerotok" | grep -q "tokens" && pass "omits token segment when total is zero" || fail "token segment shown unexpectedly — got: $out_zerotok"
|
|
|
|
echo ""
|
|
echo "--- executable bit ---"
|
|
|
|
[[ -x "$SCRIPT" ]] && pass "statusline-command.sh is executable" || fail "statusline-command.sh is not executable"
|
|
|
|
echo ""
|
|
echo "Results: $PASS passed, $FAIL failed"
|
|
[[ $FAIL -eq 0 ]]
|