@thebassclef/lite 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/cli.cjs +240 -23
  2. package/dist/cli.js +242 -25
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/lite/.claude/hooks/artifact-ingestion-gate.sh +357 -0
  7. package/dist/lite/.claude/hooks/assert-verify-steering.sh +77 -0
  8. package/dist/lite/.claude/hooks/bassclef-source-config-validate.sh +215 -0
  9. package/dist/lite/.claude/hooks/bassclef-sync.sh +716 -0
  10. package/dist/lite/.claude/hooks/compound-noun-scrub.sh +292 -0
  11. package/dist/lite/.claude/hooks/kiss-expansion-inject.sh +69 -0
  12. package/dist/lite/.claude/hooks/longrun-prep-compounding-sequence-check.sh +492 -0
  13. package/dist/lite/.claude/hooks/plain-english-steering.sh +156 -0
  14. package/dist/lite/.claude/hooks/post-skill-friction-check.sh +177 -0
  15. package/dist/lite/.claude/hooks/post-skill-telemetry.sh +62 -0
  16. package/dist/lite/.claude/hooks/pre-build-gate.sh +511 -0
  17. package/dist/lite/.claude/hooks/pre-commit-gate.sh +451 -0
  18. package/dist/lite/.claude/hooks/session-end.sh +433 -0
  19. package/dist/lite/.claude/hooks/session-reflection.sh +303 -0
  20. package/dist/lite/.claude/hooks/skill-body-grade-gate.sh +219 -0
  21. package/dist/lite/.claude/hooks/skill-body-intent-drift.sh +107 -0
  22. package/dist/lite/.claude/hooks/state-validate.sh +271 -0
  23. package/dist/lite/.claude/hooks/substrate-clarity-gate.sh +1110 -0
  24. package/dist/lite/.claude/hooks/temperance-gate.sh +147 -0
  25. package/dist/lite/.claude/hooks/testing-tier-enforce.sh +233 -0
  26. package/dist/lite/.claude/hooks/turn-prose-grade-measure.sh +219 -0
  27. package/dist/lite/.claude/hooks/turn-prose-kiss-check.sh +463 -0
  28. package/dist/lite/.claude/hooks/vocabulary-migration-check.sh +171 -0
  29. package/dist/lite/.claude/hooks/whereami-utc-gate.sh +142 -0
  30. package/dist/lite/CLAUDE.md +2 -2
  31. package/dist/lite/whereami.md +1 -1
  32. package/package.json +1 -1
@@ -0,0 +1,177 @@
1
+ #!/bin/bash
2
+ # tier: lite
3
+ # Post-Skill Friction Check — fires on PostToolUse for Skill tool.
4
+ # After "major composer" skills complete, classify the output:
5
+ # - Unambiguous friction → emit /promote suggestion + log to friction-log
6
+ # - Borderline friction → log to friction-log (operator curates)
7
+ # - No friction → silent
8
+ #
9
+ # The friction log is docs/session-friction-log.md (lazy-created).
10
+ # Operator returning from unattended scenario reads the log and triages.
11
+ #
12
+ # Closes the "rough edges noticed but not filed" gap that surfaces when
13
+ # operator runs unattended scenario tests; agent self-monitors during
14
+ # multi-skill chains.
15
+ #
16
+ # Override: SKIP_FRICTION_CHECK=1 to bypass (logged via trace-helper).
17
+ # Per-skill opt-out: skill SKILL.md frontmatter `disable_friction_check: true`
18
+ #
19
+ # Refs bassclef#400.
20
+
21
+ set +e # never crash the tool call; fall through silently on any error
22
+
23
+ INPUT=$(cat)
24
+ TOOL_NAME=$(jq <<< "$INPUT" -r '.tool_name // ""' 2>/dev/null)
25
+ TOOL_INPUT=$(jq <<< "$INPUT" -r '.tool_input // {}' 2>/dev/null)
26
+ TOOL_OUTPUT=$(jq <<< "$INPUT" -r '.tool_output // ""' 2>/dev/null)
27
+
28
+ # Only fire on Skill tool
29
+ if [ "$TOOL_NAME" != "Skill" ]; then
30
+ exit 0
31
+ fi
32
+
33
+ # Override hatch — log and skip
34
+ if [ "${SKIP_FRICTION_CHECK:-0}" = "1" ]; then
35
+ SCRIPT_DIR="$(cd "$(dirname "$0")" 2>/dev/null && pwd)"
36
+ if [ -n "$SCRIPT_DIR" ] && [ -f "$SCRIPT_DIR/trace-helper.sh" ]; then
37
+ source "$SCRIPT_DIR/trace-helper.sh" 2>/dev/null || true
38
+ trace_log "post-skill-friction-check" "OVERRIDE $TOOL_NAME" 2>/dev/null || true
39
+ fi
40
+ exit 0
41
+ fi
42
+
43
+ # Extract skill name from tool input
44
+ SKILL_NAME=$(jq <<< "$TOOL_INPUT" -r '.skill // ""' 2>/dev/null)
45
+
46
+ # Major composer skills — these chain other skills or do heavy work.
47
+ # Friction surfaces best at their boundaries.
48
+ MAJOR_SKILLS_PATTERN="^(preview|preview-build|build|shape|longrun|decompose|spec|architect-review|frontend-design|prototype-variants|prototype-gallery|interpret-input|objectory-decompose|ux-migration|ia-model|interaction-design|use-case|user-stories|jtbd-tasks|task-scenarios)$"
49
+
50
+ if ! echo "$SKILL_NAME" | grep -qE "$MAJOR_SKILLS_PATTERN"; then
51
+ exit 0
52
+ fi
53
+
54
+ # Check per-skill opt-out (frontmatter disable_friction_check: true)
55
+ PROJECT_DIR="${CLAUDE_PROJECT_DIR:-$(pwd)}"
56
+ SKILL_FILE="$PROJECT_DIR/.claude/skills/$SKILL_NAME/SKILL.md"
57
+ if [ -f "$SKILL_FILE" ] && head -20 "$SKILL_FILE" | grep -qE "^disable_friction_check:[[:space:]]*true"; then
58
+ exit 0
59
+ fi
60
+
61
+ # === Friction classification ===
62
+ #
63
+ # Unambiguous: skill returned error OR clear stub markers
64
+ # Borderline: placeholder text, partial output, drift signals
65
+ # None: clean output
66
+
67
+ CLASS=""
68
+ SIGNAL=""
69
+
70
+ # Unambiguous friction signals
71
+ if echo "$TOOL_OUTPUT" | grep -qiE 'deferred to Phase [A-Z]|stub return|TODO: implement|not yet implemented|operator decides .{0,30} manually|placeholder.{0,20}fill in'; then
72
+ CLASS="unambiguous"
73
+ SIGNAL=$(echo "$TOOL_OUTPUT" | grep -oiE '(deferred to Phase [A-Z]|stub return|TODO: implement|not yet implemented|operator decides .{0,30} manually|placeholder.{0,20}fill in)' | head -1)
74
+ elif echo "$TOOL_OUTPUT" | grep -qiE '^Error:|exit code [1-9]|skill failed|unable to complete'; then
75
+ CLASS="unambiguous"
76
+ SIGNAL=$(echo "$TOOL_OUTPUT" | grep -iE '^Error:|exit code [1-9]|skill failed|unable to complete' | head -1)
77
+ fi
78
+
79
+ # Borderline friction signals (only check if not already classified)
80
+ if [ -z "$CLASS" ]; then
81
+ if echo "$TOOL_OUTPUT" | grep -qiE 'lorem ipsum|fill in here|XXX|FIXME|partial.{0,20}output|incomplete'; then
82
+ CLASS="borderline"
83
+ SIGNAL=$(echo "$TOOL_OUTPUT" | grep -oiE 'lorem ipsum|fill in here|XXX|FIXME|partial.{0,20}output|incomplete' | head -1)
84
+ fi
85
+ fi
86
+
87
+ # No friction → silent exit
88
+ if [ -z "$CLASS" ]; then
89
+ exit 0
90
+ fi
91
+
92
+ # === Append to friction log ===
93
+
94
+ LOG_FILE="$PROJECT_DIR/docs/session-friction-log.md"
95
+ TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
96
+ DATE_HEADER=$(date -u +"%Y-%m-%d")
97
+
98
+ # Lazy-create log file if missing
99
+ if [ ! -f "$LOG_FILE" ]; then
100
+ mkdir -p "$(dirname "$LOG_FILE")" 2>/dev/null
101
+ cat > "$LOG_FILE" <<'HEADER'
102
+ # Session Friction Log
103
+
104
+ Tracks rough edges, stub returns, and other friction encountered
105
+ during chained skill dispatches. Generated by
106
+ `.claude/hooks/post-skill-friction-check.sh` (bassclef#400).
107
+
108
+ **Format**: `<timestamp> [<class>] /<skill> — <signal> — <action taken>`
109
+
110
+ **Classes**:
111
+ - `unambiguous` — clear friction (error, stub return, deferred phase); auto-files /promote OR logs here
112
+ - `borderline` — partial output, placeholder text; operator triages on return
113
+
114
+ **Operator workflow on return**:
115
+ 1. Read recent entries
116
+ 2. For each `borderline` worth filing → run `/promote substrate-defect`
117
+ 3. Move resolved entries to `## Resolved` section below
118
+
119
+ ---
120
+
121
+ ## Active
122
+
123
+ HEADER
124
+ fi
125
+
126
+ # Truncate signal to one line
127
+ SIGNAL_TRUNCATED=$(echo "$SIGNAL" | head -c 200 | tr '\n' ' ' | sed 's/[[:space:]]\+/ /g; s/[[:space:]]$//')
128
+
129
+ # Append entry
130
+ ENTRY="- ${TIMESTAMP} [${CLASS}] /${SKILL_NAME} — ${SIGNAL_TRUNCATED}"
131
+
132
+ # Check if today's date header already exists; append under it
133
+ if grep -qF "## Active" "$LOG_FILE"; then
134
+ # Append to Active section. Use awk to insert after "## Active" line.
135
+ awk -v entry="$ENTRY" '
136
+ /^## Active$/ { print; print ""; print entry; next }
137
+ { print }
138
+ ' "$LOG_FILE" > "$LOG_FILE.tmp" && mv "$LOG_FILE.tmp" "$LOG_FILE"
139
+ fi
140
+
141
+ # === Emit to operator + agent context ===
142
+ #
143
+ # stderr is captured by Claude Code and surfaced to the agent on next turn.
144
+
145
+ cat >&2 <<EOF
146
+
147
+ 🔍 POST-SKILL FRICTION CHECK
148
+ ─────────────────────────────────────
149
+ Skill: /$SKILL_NAME
150
+ Class: $CLASS
151
+ Signal: $SIGNAL_TRUNCATED
152
+
153
+ Logged to: docs/session-friction-log.md
154
+
155
+ EOF
156
+
157
+ if [ "$CLASS" = "unambiguous" ]; then
158
+ cat >&2 <<EOF
159
+ RECOMMENDED: file /promote substrate-defect now (don't defer).
160
+ The signal is clear-cut; auto-prompting operator-on-return adds latency.
161
+
162
+ To file: /promote substrate-defect $SKILL_NAME — $SIGNAL_TRUNCATED
163
+
164
+ To skip (rare): SKIP_FRICTION_CHECK=1 next invocation.
165
+ ─────────────────────────────────────
166
+ EOF
167
+ else
168
+ cat >&2 <<EOF
169
+ ACTION: continue — operator will triage on return.
170
+ If you (agent) judge this warrants /promote inline, fire it.
171
+ Otherwise log entry above is sufficient.
172
+ ─────────────────────────────────────
173
+ EOF
174
+ fi
175
+
176
+ # Always exit 0 — friction-check is informational, not blocking
177
+ exit 0
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env bash
2
+ # .claude/hooks/post-skill-telemetry.sh
3
+ # tier: lite
4
+ # install-class: dual
5
+ # PostToolUse: Skill
6
+ #
7
+ # Emits a `skill_invoke` telemetry event after any Skill tool call.
8
+ # Silent-fail per @luminary michael-nygard R1 — never crashes the session.
9
+ # Reads Claude Code PostToolUse JSON on stdin; extracts skill name from
10
+ # tool_input.
11
+ #
12
+ # Wired in .claude/settings.json under hooks.PostToolUse[matcher=Skill].
13
+
14
+ set -u
15
+
16
+ CWD="${CLAUDE_PROJECT_DIR:-$PWD}"
17
+
18
+ # Silent-fail wrap — any error path exits 0 cleanly
19
+ {
20
+ if [ ! -f "$CWD/lib/telemetry.sh" ]; then
21
+ exit 0
22
+ fi
23
+
24
+ # Read Claude Code stdin JSON
25
+ input=$(cat 2>/dev/null || echo "")
26
+ if [ -z "$input" ]; then
27
+ exit 0
28
+ fi
29
+
30
+ # Extract skill name — tool_input.name is the standard field for Skill tool
31
+ if command -v jq >/dev/null 2>&1; then
32
+ skill_name=$(echo "$input" | jq -r '.tool_input.skill // .tool_input.name // empty' 2>/dev/null)
33
+ else
34
+ # Bash-only fallback — grep for skill or name field
35
+ skill_name=$(echo "$input" | grep -oE '"skill"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"\([^"]*\)"$/\1/')
36
+ [ -z "$skill_name" ] && skill_name=$(echo "$input" | grep -oE '"name"[[:space:]]*:[[:space:]]*"[^"]*"' | head -1 | sed 's/.*"\([^"]*\)"$/\1/')
37
+ fi
38
+
39
+ # Skill names must start with a letter; normalize to /skill-name shape
40
+ if [ -z "$skill_name" ]; then
41
+ exit 0
42
+ fi
43
+ # Strip leading slash if present
44
+ skill_name="${skill_name#/}"
45
+ # Only ship if the name matches the schema pattern
46
+ if ! echo "$skill_name" | grep -qE '^[a-z][a-z0-9-]*$'; then
47
+ exit 0
48
+ fi
49
+ skill_name="/$skill_name"
50
+
51
+ # shellcheck source=/dev/null
52
+ source "$CWD/lib/telemetry.sh" 2>/dev/null || exit 0
53
+
54
+ if telemetry_is_enabled; then
55
+ sid=$(telemetry_session_id)
56
+ uid=$(uuidgen 2>/dev/null | tr '[:upper:]' '[:lower:]' || echo "00000000-0000-4000-8000-000000000002")
57
+ ts=$(date -u +%Y-%m-%dT%H:%M:%SZ)
58
+ telemetry_emit "{\"event_type\":\"skill_invoke\",\"event_id\":\"$uid\",\"session_id\":\"$sid\",\"timestamp\":\"$ts\",\"tier\":\"lite\",\"payload\":{\"skill_name\":\"$skill_name\"}}"
59
+ fi
60
+ } 2>/dev/null || true
61
+
62
+ exit 0