Skip to content

Commit 1777e47

Browse files
committed
fix: preserve hook markers in smart filtering
1 parent 955eabd commit 1777e47

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

scripts/track-code-change.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ if command -v jq &> /dev/null; then
6767
fi
6868
fi
6969

70+
# Skip non-educational file changes without consuming the session budget
71+
if [ "$TECH" = "other" ]; then
72+
echo "{}"
73+
exit 0
74+
fi
75+
7076
# --- Rate limiting ---
7177
NOW=$(date +%s)
7278

@@ -114,10 +120,10 @@ if command -v jq &> /dev/null; then
114120

115121
if [ "$IS_FIRST_EVER" = "true" ]; then
116122
# First-time encounter: micro-lesson about the technology
117-
CONTEXT="CodeSensei micro-lesson trigger: The user just encountered '$TECH' for the FIRST TIME (file: $FILE_PATH). Their belt level is '$BELT'. Provide a brief 2-sentence explanation of what $TECH is and why it matters for their project. Adapt language to their belt level. Keep it concise and non-intrusive — weave it naturally into your response, don't stop everything for a lecture."
123+
CONTEXT="🥋 CodeSensei micro-lesson trigger: The user just encountered '$TECH' for the FIRST TIME (file: $FILE_PATH). Their belt level is '$BELT'. Provide a brief 2-sentence explanation of what $TECH is and why it matters for their project. Adapt language to their belt level. Keep it concise and non-intrusive — weave it naturally into your response, don't stop everything for a lecture."
118124
else
119125
# Already-seen technology: inline insight about the specific change
120-
CONTEXT="CodeSensei inline insight: Claude just used '$TOOL_NAME' on '$FILE_PATH' ($TECH). The user's belt level is '$BELT'. Provide a brief 1-2 sentence explanation of what this change does and why, adapted to their belt level. Keep it natural and non-intrusive — weave it into your response as a quick teaching moment."
126+
CONTEXT="🥋 CodeSensei inline insight: Claude just used '$TOOL_NAME' on '$FILE_PATH' ($TECH). The user's belt level is '$BELT'. Provide a brief 1-2 sentence explanation of what this change does and why, adapted to their belt level. Keep it natural and non-intrusive — weave it into your response as a quick teaching moment."
121127
fi
122128

123129
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PostToolUse\",\"additionalContext\":\"$CONTEXT\"}}"

scripts/track-command.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ if command -v jq &> /dev/null; then
7474
# Log the command
7575
echo "{\"timestamp\":\"$TIMESTAMP\",\"command\":\"$(echo "$COMMAND" | head -c 200)\",\"concept\":\"$CONCEPT\"}" >> "$COMMANDS_LOG"
7676

77+
# Skip non-educational commands without consuming the session budget
78+
if [ -z "$CONCEPT" ]; then
79+
echo "{}"
80+
exit 0
81+
fi
82+
7783
# Track concept in session and lifetime if new and meaningful
7884
IS_FIRST_EVER="false"
7985
if [ -n "$CONCEPT" ] && [ -f "$PROFILE_FILE" ]; then
@@ -140,13 +146,10 @@ if command -v jq &> /dev/null; then
140146

141147
if [ "$IS_FIRST_EVER" = "true" ] && [ -n "$CONCEPT" ]; then
142148
# First-time encounter: micro-lesson about the concept
143-
CONTEXT="CodeSensei micro-lesson trigger: The user just encountered '$CONCEPT' for the FIRST TIME (command: $SAFE_CMD). Their belt level is '$BELT'. Provide a brief 2-sentence explanation of what $CONCEPT means and why it matters. Adapt language to their belt level. Keep it concise and non-intrusive."
149+
CONTEXT="🥋 CodeSensei micro-lesson trigger: The user just encountered '$CONCEPT' for the FIRST TIME (command: $SAFE_CMD). Their belt level is '$BELT'. Provide a brief 2-sentence explanation of what $CONCEPT means and why it matters. Adapt language to their belt level. Keep it concise and non-intrusive."
144150
elif [ -n "$CONCEPT" ]; then
145151
# Already-seen concept: brief inline insight about this specific command
146-
CONTEXT="CodeSensei inline insight: Claude just ran a '$CONCEPT' command ($SAFE_CMD). The user's belt level is '$BELT'. Provide a brief 1-sentence explanation of what this command does, adapted to their belt level. Keep it natural and non-intrusive."
147-
else
148-
# Unknown command type: still provide a brief hint
149-
CONTEXT="CodeSensei inline insight: Claude just ran a shell command ($SAFE_CMD). The user's belt level is '$BELT'. If this command is educational, briefly explain what it does in 1 sentence. If trivial, skip the explanation."
152+
CONTEXT="🥋 CodeSensei inline insight: Claude just ran a '$CONCEPT' command ($SAFE_CMD). The user's belt level is '$BELT'. Provide a brief 1-sentence explanation of what this command does, adapted to their belt level. Keep it natural and non-intrusive."
150153
fi
151154

152155
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PostToolUse\",\"additionalContext\":\"$CONTEXT\"}}"

0 commit comments

Comments
 (0)