claude-code-handoff 1.5.0 → 1.6.0
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.
- package/README.md +132 -27
- package/cli.js +2 -2
- package/hooks/context-monitor.sh +52 -8
- package/install.sh +8 -8
- package/package.json +1 -1
- package/update.sh +1 -1
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ Either way, you lose. Auto-compact gives you a degraded Claude that forgets. Man
|
|
|
36
36
|
|
|
37
37
|
## The Solution
|
|
38
38
|
|
|
39
|
-
Instead of relying on lossy compression or starting from zero, **claude-code-handoff** gives Claude **structured persistent memory** —
|
|
39
|
+
Instead of relying on lossy compression or starting from zero, **claude-code-handoff** gives Claude **structured persistent memory** — 6 slash commands that capture exactly what matters and restore it cleanly:
|
|
40
40
|
|
|
41
41
|
| Command | Description |
|
|
42
42
|
|---------|-------------|
|
|
@@ -49,7 +49,7 @@ Instead of relying on lossy compression or starting from zero, **claude-code-han
|
|
|
49
49
|
|
|
50
50
|
The workflow becomes: work until context is full → `/handoff` → `/clear` → `/resume` → continue with full context. No degradation, no amnesia. Just clean handoffs.
|
|
51
51
|
|
|
52
|
-
**
|
|
52
|
+
**Auto-handoff** (since v1.4) monitors your context usage and **automatically triggers a handoff** when the transcript reaches a configurable threshold (default: **90%**) — so you never forget to save. Since v1.5, the threshold is configured as a **percentage of context** instead of fixed bytes, making it intuitive and portable across different setups.
|
|
53
53
|
|
|
54
54
|
Session state is stored in `.claude/handoffs/` (gitignored) — each developer keeps their own context, no conflicts.
|
|
55
55
|
|
|
@@ -62,7 +62,7 @@ cd your-project
|
|
|
62
62
|
npx claude-code-handoff
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
That's it. Open Claude Code and your
|
|
65
|
+
That's it. Open Claude Code and your 6 commands are ready. Auto-handoff is enabled by default at 90%.
|
|
66
66
|
|
|
67
67
|
---
|
|
68
68
|
|
|
@@ -157,38 +157,91 @@ graph TD
|
|
|
157
157
|
|
|
158
158
|
## Auto-Handoff (Context Monitor)
|
|
159
159
|
|
|
160
|
-
The biggest risk with handoffs is **forgetting to save**. Auto-handoff eliminates this by monitoring your transcript size and forcing
|
|
160
|
+
The biggest risk with handoffs is **forgetting to save**. You're deep in a task, context fills up, and everything is lost. Auto-handoff eliminates this by monitoring your transcript size and **forcing Claude to save the handoff** before it's too late.
|
|
161
161
|
|
|
162
162
|
### How It Works
|
|
163
163
|
|
|
164
|
+
A [Claude Code hook](https://docs.anthropic.com/en/docs/claude-code/hooks) runs after every Claude response (Stop event). It reads the **actual token count** from Claude's API usage data in the JSONL transcript and compares it against the 200K token context window. When the threshold is exceeded, it **blocks** Claude's next action and forces an immediate handoff save.
|
|
165
|
+
|
|
164
166
|
```mermaid
|
|
165
167
|
flowchart TD
|
|
166
168
|
A[Claude responds] --> B[Stop hook fires]
|
|
167
|
-
B --> C
|
|
169
|
+
B --> C["Transcript size > threshold?"]
|
|
168
170
|
C -->|No| D[Continue normally]
|
|
169
|
-
C -->|Yes| E{Already triggered?}
|
|
171
|
+
C -->|Yes| E{Already triggered this session?}
|
|
170
172
|
E -->|Yes| D
|
|
171
|
-
E -->|No| F[Create flag file]
|
|
172
|
-
F --> G["Block: force handoff save"]
|
|
173
|
-
G --> H[Claude
|
|
173
|
+
E -->|No| F[Create flag file in /tmp]
|
|
174
|
+
F --> G["Block Claude: force handoff save"]
|
|
175
|
+
G --> H[Claude writes _active.md]
|
|
174
176
|
H --> I["User: /clear → /resume"]
|
|
175
177
|
```
|
|
176
178
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
### Threshold Configuration
|
|
180
|
+
|
|
181
|
+
The threshold is configured as a **percentage of the 200K token context window**. The hook reads the **actual token count** from Claude's API usage data in the transcript — no guesswork, no byte-to-token estimation.
|
|
182
|
+
|
|
183
|
+
| Preset | Value | Triggers at | Best for |
|
|
184
|
+
|--------|-------|-------------|----------|
|
|
185
|
+
| **90% (default)** | `THRESHOLD_PERCENT=90` | 180K tokens | Maximizing context usage |
|
|
186
|
+
| **80%** | `THRESHOLD_PERCENT=80` | 160K tokens | Balance between space and safety |
|
|
187
|
+
| **75%** | `THRESHOLD_PERCENT=75` | 150K tokens | Short sessions, early handoff |
|
|
188
|
+
|
|
189
|
+
The calculation uses real data:
|
|
190
|
+
```
|
|
191
|
+
MAX_CONTEXT_TOKENS = 200000 (Claude Code's context window)
|
|
192
|
+
THRESHOLD = MAX_CONTEXT_TOKENS × THRESHOLD_PERCENT / 100
|
|
193
|
+
|
|
194
|
+
# The hook reads input_tokens from the last assistant message in the JSONL
|
|
195
|
+
# This is the ACTUAL context size — not an estimate
|
|
196
|
+
```
|
|
181
197
|
|
|
182
|
-
###
|
|
198
|
+
### Three Ways to Configure
|
|
183
199
|
|
|
200
|
+
**1. Environment variable** (per-session override):
|
|
184
201
|
```bash
|
|
185
|
-
#
|
|
186
|
-
export CLAUDE_CONTEXT_THRESHOLD=80
|
|
202
|
+
# Trigger at 80% instead of the default
|
|
203
|
+
export CLAUDE_CONTEXT_THRESHOLD=80
|
|
204
|
+
```
|
|
187
205
|
|
|
188
|
-
|
|
189
|
-
|
|
206
|
+
**2. Interactive wizard** (`/auto-handoff` command):
|
|
207
|
+
```
|
|
208
|
+
you: /auto-handoff
|
|
209
|
+
claude: Auto-handoff is ENABLED (threshold: 90%). What would you like to do?
|
|
210
|
+
1. Disable
|
|
211
|
+
2. Adjust threshold
|
|
212
|
+
|
|
213
|
+
you: [selects "Adjust threshold"]
|
|
214
|
+
claude: Which threshold do you want?
|
|
215
|
+
1. 90% (Recommended) — Default, maximizes context usage
|
|
216
|
+
2. 80% — Balance between space and safety
|
|
217
|
+
3. 75% — Short sessions, saves handoff earlier
|
|
218
|
+
4. Other — Type a custom value
|
|
190
219
|
```
|
|
191
220
|
|
|
221
|
+
**3. Edit the script directly**:
|
|
222
|
+
```bash
|
|
223
|
+
# In .claude/hooks/context-monitor.sh, change the default:
|
|
224
|
+
THRESHOLD_PERCENT=${CLAUDE_CONTEXT_THRESHOLD:-90} # change 90 to your value
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Safety Mechanisms
|
|
228
|
+
|
|
229
|
+
- **One-shot trigger**: A flag file in `/tmp` (per session ID) prevents infinite loops — the hook triggers exactly once per session, even if Claude's handoff response pushes the transcript further
|
|
230
|
+
- **Session cleanup**: A `SessionStart` hook automatically cleans up stale flag files older than 24 hours
|
|
231
|
+
- **Disable switch**: Create `.claude/hooks/.auto-handoff-disabled` to completely disable the monitor (or use `/auto-handoff` to toggle)
|
|
232
|
+
- **Non-destructive**: The hook only blocks and instructs — it never modifies files directly. Claude performs the actual handoff save
|
|
233
|
+
|
|
234
|
+
### What Happens When It Triggers
|
|
235
|
+
|
|
236
|
+
When the threshold is hit, Claude receives a block message like:
|
|
237
|
+
|
|
238
|
+
> ⚠️ AUTO-HANDOFF: Context reached 90% of the limit. You MUST save the handoff NOW.
|
|
239
|
+
|
|
240
|
+
Claude will then:
|
|
241
|
+
1. Analyze the full conversation
|
|
242
|
+
2. Write the handoff to `.claude/handoffs/_active.md`
|
|
243
|
+
3. Tell you: "Handoff saved automatically. Use `/clear` then `/resume` to continue."
|
|
244
|
+
|
|
192
245
|
---
|
|
193
246
|
|
|
194
247
|
## Install
|
|
@@ -226,7 +279,7 @@ your-project/
|
|
|
226
279
|
│ ├── save-handoff.md ← /save-handoff (wizard)
|
|
227
280
|
│ ├── switch-context.md ← /switch-context (workstream switch)
|
|
228
281
|
│ ├── delete-handoff.md ← /delete-handoff (remove handoffs)
|
|
229
|
-
│ └── auto-handoff.md
|
|
282
|
+
│ └── auto-handoff.md ← /auto-handoff (on/off + threshold)
|
|
230
283
|
├── rules/
|
|
231
284
|
│ ├── session-continuity.md ← Auto-loaded behavioral rules
|
|
232
285
|
│ └── auto-handoff.md ← Auto-handoff trigger rules
|
|
@@ -298,6 +351,45 @@ claude: Where should this session's handoff be saved?
|
|
|
298
351
|
3. Replace active
|
|
299
352
|
```
|
|
300
353
|
|
|
354
|
+
### Auto-handoff in action
|
|
355
|
+
|
|
356
|
+
```
|
|
357
|
+
you: [working normally on a long session...]
|
|
358
|
+
claude: [responds to your request]
|
|
359
|
+
|
|
360
|
+
── context reaches 90% ──
|
|
361
|
+
|
|
362
|
+
claude: ⚠️ AUTO-HANDOFF: Context reached 90% of the limit.
|
|
363
|
+
Handoff saved automatically.
|
|
364
|
+
Use /clear then /resume to continue.
|
|
365
|
+
|
|
366
|
+
you: /clear
|
|
367
|
+
|
|
368
|
+
── new session ──
|
|
369
|
+
|
|
370
|
+
you: /resume
|
|
371
|
+
claude: ## Resuming session
|
|
372
|
+
[full context restored, continues exactly where you left off]
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Adjusting auto-handoff threshold
|
|
376
|
+
|
|
377
|
+
```
|
|
378
|
+
you: /auto-handoff
|
|
379
|
+
claude: Auto-handoff is ENABLED (threshold: 90%). What would you like to do?
|
|
380
|
+
1. Disable
|
|
381
|
+
2. Adjust threshold
|
|
382
|
+
|
|
383
|
+
you: [selects "Adjust threshold"]
|
|
384
|
+
claude: Which threshold do you want?
|
|
385
|
+
1. 90% (Recommended)
|
|
386
|
+
2. 80%
|
|
387
|
+
3. 75%
|
|
388
|
+
|
|
389
|
+
you: [types "95" via Other]
|
|
390
|
+
claude: ✅ Threshold updated to 95%.
|
|
391
|
+
```
|
|
392
|
+
|
|
301
393
|
---
|
|
302
394
|
|
|
303
395
|
## What Gets Captured
|
|
@@ -399,7 +491,8 @@ The installer adds a `session-continuity.md` rules file that Claude auto-loads o
|
|
|
399
491
|
|
|
400
492
|
- **On session start**: Claude knows `_active.md` exists but doesn't read it unless asked
|
|
401
493
|
- **During work**: Claude proactively reminds you to save after significant milestones
|
|
402
|
-
- **Command awareness**: Claude understands all
|
|
494
|
+
- **Command awareness**: Claude understands all 6 commands natively
|
|
495
|
+
- **Auto-handoff awareness**: When the context monitor triggers, Claude knows exactly what to do — save the handoff immediately without asking
|
|
403
496
|
|
|
404
497
|
---
|
|
405
498
|
|
|
@@ -421,9 +514,10 @@ curl -fsSL https://raw.githubusercontent.com/eximIA-Ventures/claude-code-handoff
|
|
|
421
514
|
|
|
422
515
|
This will:
|
|
423
516
|
- Overwrite command files with the latest versions
|
|
424
|
-
- Update
|
|
425
|
-
-
|
|
426
|
-
-
|
|
517
|
+
- Update rules and hooks to latest
|
|
518
|
+
- Ensure hooks are configured in `settings.json`
|
|
519
|
+
- Remove legacy files if present (`auto-handoff-toggle.md`, Portuguese commands)
|
|
520
|
+
- **Not touch** your `.claude/handoffs/` data or custom threshold settings
|
|
427
521
|
|
|
428
522
|
---
|
|
429
523
|
|
|
@@ -435,16 +529,18 @@ curl -fsSL https://raw.githubusercontent.com/eximIA-Ventures/claude-code-handoff
|
|
|
435
529
|
```
|
|
436
530
|
|
|
437
531
|
The uninstaller:
|
|
438
|
-
- Removes all
|
|
439
|
-
- Removes
|
|
532
|
+
- Removes all 6 command files (including legacy `auto-handoff-toggle.md`)
|
|
533
|
+
- Removes rules and hooks
|
|
534
|
+
- Cleans hooks from `settings.json` (requires `jq`)
|
|
440
535
|
- Preserves handoff data if sessions exist (won't delete your session history)
|
|
441
536
|
- Cleans `.gitignore` entries
|
|
442
537
|
- Leaves `CLAUDE.md` unchanged (remove the section manually if desired)
|
|
443
538
|
|
|
444
539
|
Or remove manually:
|
|
445
540
|
```bash
|
|
446
|
-
rm .claude/commands/{handoff,resume,save-handoff,switch-context,delete-handoff}.md
|
|
447
|
-
rm .claude/rules/session-continuity.md
|
|
541
|
+
rm .claude/commands/{handoff,resume,save-handoff,switch-context,delete-handoff,auto-handoff}.md
|
|
542
|
+
rm .claude/rules/{session-continuity,auto-handoff}.md
|
|
543
|
+
rm .claude/hooks/{context-monitor,session-cleanup}.sh
|
|
448
544
|
rm -rf .claude/handoffs/ # ⚠️ deletes all session history
|
|
449
545
|
```
|
|
450
546
|
|
|
@@ -478,6 +574,15 @@ A: The commands automatically summarize older sessions into a "Prior Sessions Su
|
|
|
478
574
|
**Q: Can I edit the handoff files manually?**
|
|
479
575
|
A: Absolutely. They're plain markdown. You can add notes, reorder next steps, or clean up history.
|
|
480
576
|
|
|
577
|
+
**Q: How does the auto-handoff threshold work?**
|
|
578
|
+
A: The threshold is a percentage of Claude Code's 200K token context window. At 90% (default), the hook triggers at 180K tokens. The hook reads the **actual token count** from Claude's API usage data — not file size estimates. You can set any value from 1-100 via env var (`CLAUDE_CONTEXT_THRESHOLD=80`) or the `/auto-handoff` command.
|
|
579
|
+
|
|
580
|
+
**Q: Can I disable auto-handoff?**
|
|
581
|
+
A: Yes. Run `/auto-handoff` and select "Disable", or manually create the file `.claude/hooks/.auto-handoff-disabled`. Delete the file to re-enable.
|
|
582
|
+
|
|
583
|
+
**Q: What if auto-handoff triggers too early/late?**
|
|
584
|
+
A: Adjust the threshold. If it triggers too early, increase to 95%. If you're running out of context before it triggers, lower to 80% or 75%. Use `/auto-handoff` to change it interactively.
|
|
585
|
+
|
|
481
586
|
---
|
|
482
587
|
|
|
483
588
|
## Contributing
|
package/cli.js
CHANGED
|
@@ -67,8 +67,8 @@ fs.chmodSync(path.join(CLAUDE_DIR, 'hooks', 'session-cleanup.sh'), 0o755);
|
|
|
67
67
|
console.log(` ${YELLOW}[5/10]${NC} Configuring hooks in settings.json...`);
|
|
68
68
|
const settingsPath = path.join(CLAUDE_DIR, 'settings.json');
|
|
69
69
|
const hooksConfig = {
|
|
70
|
-
Stop: [{ hooks: [{ type: 'command', command: '$CLAUDE_PROJECT_DIR/.claude/hooks/context-monitor.sh', timeout: 10 }] }],
|
|
71
|
-
SessionStart: [{ hooks: [{ type: 'command', command: '$CLAUDE_PROJECT_DIR/.claude/hooks/session-cleanup.sh', timeout: 5 }] }]
|
|
70
|
+
Stop: [{ hooks: [{ type: 'command', command: '"$CLAUDE_PROJECT_DIR/.claude/hooks/context-monitor.sh"', timeout: 10 }] }],
|
|
71
|
+
SessionStart: [{ hooks: [{ type: 'command', command: '"$CLAUDE_PROJECT_DIR/.claude/hooks/session-cleanup.sh"', timeout: 5 }] }]
|
|
72
72
|
};
|
|
73
73
|
if (fs.existsSync(settingsPath)) {
|
|
74
74
|
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
|
package/hooks/context-monitor.sh
CHANGED
|
@@ -9,11 +9,11 @@ if [ -f "$SCRIPT_DIR/.auto-handoff-disabled" ]; then
|
|
|
9
9
|
exit 0
|
|
10
10
|
fi
|
|
11
11
|
|
|
12
|
-
# Contexto máximo
|
|
13
|
-
|
|
12
|
+
# Contexto máximo do Claude Code (tokens)
|
|
13
|
+
MAX_CONTEXT_TOKENS=200000
|
|
14
14
|
# Threshold configurável (% do contexto). 90% padrão — maximiza uso do contexto
|
|
15
15
|
THRESHOLD_PERCENT=${CLAUDE_CONTEXT_THRESHOLD:-90}
|
|
16
|
-
|
|
16
|
+
THRESHOLD_TOKENS=$((MAX_CONTEXT_TOKENS * THRESHOLD_PERCENT / 100))
|
|
17
17
|
|
|
18
18
|
INPUT=$(cat)
|
|
19
19
|
TRANSCRIPT_PATH=$(echo "$INPUT" | jq -r '.transcript_path // empty')
|
|
@@ -28,11 +28,52 @@ if [ -z "$SESSION_ID" ]; then
|
|
|
28
28
|
exit 0
|
|
29
29
|
fi
|
|
30
30
|
|
|
31
|
-
#
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
# Extrai o input_tokens da última mensagem do assistente no JSONL.
|
|
32
|
+
# Isso reflete o tamanho REAL do contexto que o Claude está usando.
|
|
33
|
+
# Campos: input_tokens + cache_read_input_tokens + cache_creation_input_tokens = total input
|
|
34
|
+
CURRENT_TOKENS=0
|
|
35
|
+
if command -v python3 &>/dev/null; then
|
|
36
|
+
CURRENT_TOKENS=$(python3 -c "
|
|
37
|
+
import json, sys
|
|
38
|
+
last = 0
|
|
39
|
+
with open('$TRANSCRIPT_PATH') as f:
|
|
40
|
+
for line in f:
|
|
41
|
+
try:
|
|
42
|
+
e = json.loads(line)
|
|
43
|
+
if e.get('type') == 'assistant':
|
|
44
|
+
u = e.get('message', {}).get('usage', {})
|
|
45
|
+
t = u.get('input_tokens', 0) + u.get('cache_read_input_tokens', 0) + u.get('cache_creation_input_tokens', 0)
|
|
46
|
+
if t > 0:
|
|
47
|
+
last = t
|
|
48
|
+
except:
|
|
49
|
+
pass
|
|
50
|
+
print(last)
|
|
51
|
+
" 2>/dev/null)
|
|
52
|
+
elif command -v node &>/dev/null; then
|
|
53
|
+
CURRENT_TOKENS=$(node -e "
|
|
54
|
+
const fs = require('fs');
|
|
55
|
+
const lines = fs.readFileSync('$TRANSCRIPT_PATH', 'utf-8').trim().split('\n');
|
|
56
|
+
let last = 0;
|
|
57
|
+
for (const line of lines) {
|
|
58
|
+
try {
|
|
59
|
+
const e = JSON.parse(line);
|
|
60
|
+
if (e.type === 'assistant' && e.message?.usage) {
|
|
61
|
+
const u = e.message.usage;
|
|
62
|
+
const t = (u.input_tokens || 0) + (u.cache_read_input_tokens || 0) + (u.cache_creation_input_tokens || 0);
|
|
63
|
+
if (t > 0) last = t;
|
|
64
|
+
}
|
|
65
|
+
} catch {}
|
|
66
|
+
}
|
|
67
|
+
console.log(last);
|
|
68
|
+
" 2>/dev/null)
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
CURRENT_TOKENS=$(echo "$CURRENT_TOKENS" | tr -d ' \n')
|
|
72
|
+
if [ -z "$CURRENT_TOKENS" ] || [ "$CURRENT_TOKENS" -eq 0 ] 2>/dev/null; then
|
|
73
|
+
exit 0
|
|
74
|
+
fi
|
|
34
75
|
|
|
35
|
-
if [ "$
|
|
76
|
+
if [ "$CURRENT_TOKENS" -lt "$THRESHOLD_TOKENS" ]; then
|
|
36
77
|
exit 0
|
|
37
78
|
fi
|
|
38
79
|
|
|
@@ -43,10 +84,13 @@ if [ -f "$FLAG" ]; then
|
|
|
43
84
|
fi
|
|
44
85
|
touch "$FLAG"
|
|
45
86
|
|
|
87
|
+
# Calcula % atual
|
|
88
|
+
CURRENT_PERCENT=$((CURRENT_TOKENS * 100 / MAX_CONTEXT_TOKENS))
|
|
89
|
+
|
|
46
90
|
# Bloqueia e força handoff
|
|
47
91
|
cat <<HOOKEOF
|
|
48
92
|
{
|
|
49
93
|
"decision": "block",
|
|
50
|
-
"reason": "⚠️ AUTO-HANDOFF: O contexto atingiu ${
|
|
94
|
+
"reason": "⚠️ AUTO-HANDOFF: O contexto atingiu ${CURRENT_PERCENT}% do limite (${CURRENT_TOKENS}/${MAX_CONTEXT_TOKENS} tokens). Você DEVE salvar o handoff AGORA.\n\nSiga estes passos IMEDIATAMENTE:\n1. Analise a conversa inteira e extraia: o que foi feito, próximos passos, arquivos-chave, decisões\n2. Escreva o handoff em .claude/handoffs/_active.md seguindo o template padrão\n3. Diga ao usuário: 'Handoff salvo automaticamente. Use /clear e depois /resume para continuar.'\n\nNÃO continue com outro trabalho até o handoff estar salvo."
|
|
51
95
|
}
|
|
52
96
|
HOOKEOF
|
package/install.sh
CHANGED
|
@@ -82,8 +82,8 @@ if [ -f "$SETTINGS_FILE" ]; then
|
|
|
82
82
|
if command -v jq &>/dev/null; then
|
|
83
83
|
HOOKS_JSON='{
|
|
84
84
|
"hooks": {
|
|
85
|
-
"Stop": [{"hooks": [{"type": "command", "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/context-monitor.sh", "timeout": 10}]}],
|
|
86
|
-
"SessionStart": [{"hooks": [{"type": "command", "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/session-cleanup.sh", "timeout": 5}]}]
|
|
85
|
+
"Stop": [{"hooks": [{"type": "command", "command": "\"$CLAUDE_PROJECT_DIR/.claude/hooks/context-monitor.sh\"", "timeout": 10}]}],
|
|
86
|
+
"SessionStart": [{"hooks": [{"type": "command", "command": "\"$CLAUDE_PROJECT_DIR/.claude/hooks/session-cleanup.sh\"", "timeout": 5}]}]
|
|
87
87
|
}
|
|
88
88
|
}'
|
|
89
89
|
jq --argjson hooks "$(echo "$HOOKS_JSON" | jq '.hooks')" '. + {hooks: $hooks}' "$SETTINGS_FILE" > "${SETTINGS_FILE}.tmp" && mv "${SETTINGS_FILE}.tmp" "$SETTINGS_FILE"
|
|
@@ -102,7 +102,7 @@ if [ -f "$SETTINGS_FILE" ]; then
|
|
|
102
102
|
"hooks": [
|
|
103
103
|
{
|
|
104
104
|
"type": "command",
|
|
105
|
-
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/context-monitor.sh",
|
|
105
|
+
"command": "\"$CLAUDE_PROJECT_DIR/.claude/hooks/context-monitor.sh\"",
|
|
106
106
|
"timeout": 10
|
|
107
107
|
}
|
|
108
108
|
]
|
|
@@ -113,7 +113,7 @@ if [ -f "$SETTINGS_FILE" ]; then
|
|
|
113
113
|
"hooks": [
|
|
114
114
|
{
|
|
115
115
|
"type": "command",
|
|
116
|
-
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/session-cleanup.sh",
|
|
116
|
+
"command": "\"$CLAUDE_PROJECT_DIR/.claude/hooks/session-cleanup.sh\"",
|
|
117
117
|
"timeout": 5
|
|
118
118
|
}
|
|
119
119
|
]
|
|
@@ -136,7 +136,7 @@ SETTINGSEOF
|
|
|
136
136
|
"hooks": [
|
|
137
137
|
{
|
|
138
138
|
"type": "command",
|
|
139
|
-
"command": "\$CLAUDE_PROJECT_DIR/.claude/hooks/context-monitor.sh",
|
|
139
|
+
"command": "\"\$CLAUDE_PROJECT_DIR/.claude/hooks/context-monitor.sh\"",
|
|
140
140
|
"timeout": 10
|
|
141
141
|
}
|
|
142
142
|
]
|
|
@@ -147,7 +147,7 @@ SETTINGSEOF
|
|
|
147
147
|
"hooks": [
|
|
148
148
|
{
|
|
149
149
|
"type": "command",
|
|
150
|
-
"command": "\$CLAUDE_PROJECT_DIR/.claude/hooks/session-cleanup.sh",
|
|
150
|
+
"command": "\"\$CLAUDE_PROJECT_DIR/.claude/hooks/session-cleanup.sh\"",
|
|
151
151
|
"timeout": 5
|
|
152
152
|
}
|
|
153
153
|
]
|
|
@@ -169,7 +169,7 @@ else
|
|
|
169
169
|
"hooks": [
|
|
170
170
|
{
|
|
171
171
|
"type": "command",
|
|
172
|
-
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/context-monitor.sh",
|
|
172
|
+
"command": "\"$CLAUDE_PROJECT_DIR/.claude/hooks/context-monitor.sh\"",
|
|
173
173
|
"timeout": 10
|
|
174
174
|
}
|
|
175
175
|
]
|
|
@@ -180,7 +180,7 @@ else
|
|
|
180
180
|
"hooks": [
|
|
181
181
|
{
|
|
182
182
|
"type": "command",
|
|
183
|
-
"command": "$CLAUDE_PROJECT_DIR/.claude/hooks/session-cleanup.sh",
|
|
183
|
+
"command": "\"$CLAUDE_PROJECT_DIR/.claude/hooks/session-cleanup.sh\"",
|
|
184
184
|
"timeout": 5
|
|
185
185
|
}
|
|
186
186
|
]
|
package/package.json
CHANGED
package/update.sh
CHANGED
|
@@ -72,7 +72,7 @@ SETTINGS_FILE="$CLAUDE_DIR/settings.json"
|
|
|
72
72
|
if [ -f "$SETTINGS_FILE" ]; then
|
|
73
73
|
if ! grep -q "context-monitor" "$SETTINGS_FILE" 2>/dev/null; then
|
|
74
74
|
if command -v jq &>/dev/null; then
|
|
75
|
-
HOOKS_JSON='{"Stop":[{"hooks":[{"type":"command","command":"$CLAUDE_PROJECT_DIR/.claude/hooks/context-monitor.sh","timeout":10}]}],"SessionStart":[{"hooks":[{"type":"command","command":"$CLAUDE_PROJECT_DIR/.claude/hooks/session-cleanup.sh","timeout":5}]}]}'
|
|
75
|
+
HOOKS_JSON='{"Stop":[{"hooks":[{"type":"command","command":"\"$CLAUDE_PROJECT_DIR/.claude/hooks/context-monitor.sh\"","timeout":10}]}],"SessionStart":[{"hooks":[{"type":"command","command":"\"$CLAUDE_PROJECT_DIR/.claude/hooks/session-cleanup.sh\"","timeout":5}]}]}'
|
|
76
76
|
jq --argjson hooks "$HOOKS_JSON" '. + {hooks: $hooks}' "$SETTINGS_FILE" > "${SETTINGS_FILE}.tmp" && mv "${SETTINGS_FILE}.tmp" "$SETTINGS_FILE"
|
|
77
77
|
echo -e " Hooks added to settings.json"
|
|
78
78
|
else
|