claude-code-handoff 1.8.0 → 1.8.1
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/cli.js +35 -4
- package/install.sh +29 -2
- package/package.json +1 -1
- package/update.sh +23 -1
package/cli.js
CHANGED
|
@@ -58,12 +58,43 @@ copyFile('rules/auto-handoff.md', path.join(CLAUDE_DIR, 'rules', 'auto-handoff.m
|
|
|
58
58
|
|
|
59
59
|
// 4. Install hooks
|
|
60
60
|
console.log(` ${YELLOW}[4/10]${NC} Installing hooks...`);
|
|
61
|
-
|
|
61
|
+
|
|
62
|
+
// Detect reinstall: save user's custom settings before overwriting
|
|
63
|
+
const monitorPath = path.join(CLAUDE_DIR, 'hooks', 'context-monitor.sh');
|
|
64
|
+
let isReinstall = false;
|
|
65
|
+
let savedThreshold = '';
|
|
66
|
+
let savedMaxContext = '';
|
|
67
|
+
if (fs.existsSync(monitorPath)) {
|
|
68
|
+
isReinstall = true;
|
|
69
|
+
const oldContent = fs.readFileSync(monitorPath, 'utf-8');
|
|
70
|
+
const thresholdMatch = oldContent.match(/CLAUDE_CONTEXT_THRESHOLD:-(\d+)/);
|
|
71
|
+
const maxContextMatch = oldContent.match(/CLAUDE_MAX_CONTEXT:-(\d+)/);
|
|
72
|
+
if (thresholdMatch) savedThreshold = thresholdMatch[1];
|
|
73
|
+
if (maxContextMatch) savedMaxContext = maxContextMatch[1];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
copyFile('hooks/context-monitor.sh', monitorPath);
|
|
62
77
|
copyFile('hooks/session-cleanup.sh', path.join(CLAUDE_DIR, 'hooks', 'session-cleanup.sh'));
|
|
63
|
-
fs.chmodSync(
|
|
78
|
+
fs.chmodSync(monitorPath, 0o755);
|
|
64
79
|
fs.chmodSync(path.join(CLAUDE_DIR, 'hooks', 'session-cleanup.sh'), 0o755);
|
|
65
|
-
|
|
66
|
-
|
|
80
|
+
|
|
81
|
+
if (isReinstall) {
|
|
82
|
+
// Restore user's custom settings
|
|
83
|
+
let content = fs.readFileSync(monitorPath, 'utf-8');
|
|
84
|
+
if (savedThreshold && savedThreshold !== '90') {
|
|
85
|
+
content = content.replace('CLAUDE_CONTEXT_THRESHOLD:-90', `CLAUDE_CONTEXT_THRESHOLD:-${savedThreshold}`);
|
|
86
|
+
console.log(` Preserved threshold: ${CYAN}${savedThreshold}%${NC}`);
|
|
87
|
+
}
|
|
88
|
+
if (savedMaxContext && savedMaxContext !== '200000') {
|
|
89
|
+
content = content.replace('CLAUDE_MAX_CONTEXT:-200000', `CLAUDE_MAX_CONTEXT:-${savedMaxContext}`);
|
|
90
|
+
console.log(` Preserved max context: ${CYAN}${savedMaxContext} tokens${NC}`);
|
|
91
|
+
}
|
|
92
|
+
fs.writeFileSync(monitorPath, content);
|
|
93
|
+
// Don't touch .auto-handoff-disabled — preserve user's on/off choice
|
|
94
|
+
} else {
|
|
95
|
+
// Fresh install: auto-handoff disabled by default (beta feature)
|
|
96
|
+
fs.writeFileSync(path.join(CLAUDE_DIR, 'hooks', '.auto-handoff-disabled'), '');
|
|
97
|
+
}
|
|
67
98
|
|
|
68
99
|
// 5. Configure hooks in settings.json
|
|
69
100
|
console.log(` ${YELLOW}[5/10]${NC} Configuring hooks in settings.json...`);
|
package/install.sh
CHANGED
|
@@ -67,12 +67,39 @@ download_file "rules/auto-handoff.md" "$CLAUDE_DIR/rules/auto-handoff.md"
|
|
|
67
67
|
|
|
68
68
|
# 4. Install hooks (auto-handoff context monitor)
|
|
69
69
|
echo -e " ${YELLOW}[4/10]${NC} Installing hooks..."
|
|
70
|
+
|
|
71
|
+
# Detect reinstall: save user's custom settings before overwriting
|
|
72
|
+
IS_REINSTALL=false
|
|
73
|
+
SAVED_THRESHOLD=""
|
|
74
|
+
SAVED_MAX_CONTEXT=""
|
|
75
|
+
if [ -f "$CLAUDE_DIR/hooks/context-monitor.sh" ]; then
|
|
76
|
+
IS_REINSTALL=true
|
|
77
|
+
SAVED_THRESHOLD=$(grep -oP 'CLAUDE_CONTEXT_THRESHOLD:-\K[0-9]+' "$CLAUDE_DIR/hooks/context-monitor.sh" 2>/dev/null || echo "")
|
|
78
|
+
SAVED_MAX_CONTEXT=$(grep -oP 'CLAUDE_MAX_CONTEXT:-\K[0-9]+' "$CLAUDE_DIR/hooks/context-monitor.sh" 2>/dev/null || echo "")
|
|
79
|
+
fi
|
|
80
|
+
|
|
70
81
|
download_file "hooks/context-monitor.sh" "$CLAUDE_DIR/hooks/context-monitor.sh"
|
|
71
82
|
download_file "hooks/session-cleanup.sh" "$CLAUDE_DIR/hooks/session-cleanup.sh"
|
|
72
83
|
chmod +x "$CLAUDE_DIR/hooks/context-monitor.sh"
|
|
73
84
|
chmod +x "$CLAUDE_DIR/hooks/session-cleanup.sh"
|
|
74
|
-
|
|
75
|
-
|
|
85
|
+
|
|
86
|
+
if [ "$IS_REINSTALL" = true ]; then
|
|
87
|
+
# Restore user's custom settings
|
|
88
|
+
if [ -n "$SAVED_THRESHOLD" ] && [ "$SAVED_THRESHOLD" != "90" ]; then
|
|
89
|
+
sed -i.bak "s/CLAUDE_CONTEXT_THRESHOLD:-90/CLAUDE_CONTEXT_THRESHOLD:-${SAVED_THRESHOLD}/" "$CLAUDE_DIR/hooks/context-monitor.sh"
|
|
90
|
+
rm -f "$CLAUDE_DIR/hooks/context-monitor.sh.bak"
|
|
91
|
+
echo -e " Preserved threshold: ${CYAN}${SAVED_THRESHOLD}%${NC}"
|
|
92
|
+
fi
|
|
93
|
+
if [ -n "$SAVED_MAX_CONTEXT" ] && [ "$SAVED_MAX_CONTEXT" != "200000" ]; then
|
|
94
|
+
sed -i.bak "s/CLAUDE_MAX_CONTEXT:-200000/CLAUDE_MAX_CONTEXT:-${SAVED_MAX_CONTEXT}/" "$CLAUDE_DIR/hooks/context-monitor.sh"
|
|
95
|
+
rm -f "$CLAUDE_DIR/hooks/context-monitor.sh.bak"
|
|
96
|
+
echo -e " Preserved max context: ${CYAN}${SAVED_MAX_CONTEXT} tokens${NC}"
|
|
97
|
+
fi
|
|
98
|
+
# Don't touch .auto-handoff-disabled — preserve user's on/off choice
|
|
99
|
+
else
|
|
100
|
+
# Fresh install: auto-handoff disabled by default (beta feature)
|
|
101
|
+
touch "$CLAUDE_DIR/hooks/.auto-handoff-disabled"
|
|
102
|
+
fi
|
|
76
103
|
|
|
77
104
|
# 5. Configure hooks in settings.json
|
|
78
105
|
echo -e " ${YELLOW}[5/10]${NC} Configuring hooks in settings.json..."
|
package/package.json
CHANGED
package/update.sh
CHANGED
|
@@ -58,14 +58,35 @@ echo -e " ${YELLOW}[2/5]${NC} Updating rules..."
|
|
|
58
58
|
download_file "rules/session-continuity.md" "$CLAUDE_DIR/rules/session-continuity.md"
|
|
59
59
|
download_file "rules/auto-handoff.md" "$CLAUDE_DIR/rules/auto-handoff.md"
|
|
60
60
|
|
|
61
|
-
# 3. Update hooks
|
|
61
|
+
# 3. Update hooks (preserving user configuration)
|
|
62
62
|
echo -e " ${YELLOW}[3/5]${NC} Updating hooks..."
|
|
63
63
|
mkdir -p "$CLAUDE_DIR/hooks"
|
|
64
|
+
|
|
65
|
+
# Save user's custom settings before overwriting
|
|
66
|
+
SAVED_THRESHOLD=""
|
|
67
|
+
SAVED_MAX_CONTEXT=""
|
|
68
|
+
if [ -f "$CLAUDE_DIR/hooks/context-monitor.sh" ]; then
|
|
69
|
+
SAVED_THRESHOLD=$(grep -oP 'CLAUDE_CONTEXT_THRESHOLD:-\K[0-9]+' "$CLAUDE_DIR/hooks/context-monitor.sh" 2>/dev/null || echo "")
|
|
70
|
+
SAVED_MAX_CONTEXT=$(grep -oP 'CLAUDE_MAX_CONTEXT:-\K[0-9]+' "$CLAUDE_DIR/hooks/context-monitor.sh" 2>/dev/null || echo "")
|
|
71
|
+
fi
|
|
72
|
+
|
|
64
73
|
download_file "hooks/context-monitor.sh" "$CLAUDE_DIR/hooks/context-monitor.sh"
|
|
65
74
|
download_file "hooks/session-cleanup.sh" "$CLAUDE_DIR/hooks/session-cleanup.sh"
|
|
66
75
|
chmod +x "$CLAUDE_DIR/hooks/context-monitor.sh"
|
|
67
76
|
chmod +x "$CLAUDE_DIR/hooks/session-cleanup.sh"
|
|
68
77
|
|
|
78
|
+
# Restore user's custom settings
|
|
79
|
+
if [ -n "$SAVED_THRESHOLD" ] && [ "$SAVED_THRESHOLD" != "90" ]; then
|
|
80
|
+
sed -i.bak "s/CLAUDE_CONTEXT_THRESHOLD:-90/CLAUDE_CONTEXT_THRESHOLD:-${SAVED_THRESHOLD}/" "$CLAUDE_DIR/hooks/context-monitor.sh"
|
|
81
|
+
rm -f "$CLAUDE_DIR/hooks/context-monitor.sh.bak"
|
|
82
|
+
echo -e " Preserved threshold: ${CYAN}${SAVED_THRESHOLD}%${NC}"
|
|
83
|
+
fi
|
|
84
|
+
if [ -n "$SAVED_MAX_CONTEXT" ] && [ "$SAVED_MAX_CONTEXT" != "200000" ]; then
|
|
85
|
+
sed -i.bak "s/CLAUDE_MAX_CONTEXT:-200000/CLAUDE_MAX_CONTEXT:-${SAVED_MAX_CONTEXT}/" "$CLAUDE_DIR/hooks/context-monitor.sh"
|
|
86
|
+
rm -f "$CLAUDE_DIR/hooks/context-monitor.sh.bak"
|
|
87
|
+
echo -e " Preserved max context: ${CYAN}${SAVED_MAX_CONTEXT} tokens${NC}"
|
|
88
|
+
fi
|
|
89
|
+
|
|
69
90
|
# 4. Ensure hooks are configured in settings.json
|
|
70
91
|
echo -e " ${YELLOW}[4/5]${NC} Checking settings.json hooks..."
|
|
71
92
|
SETTINGS_FILE="$CLAUDE_DIR/settings.json"
|
|
@@ -102,4 +123,5 @@ if [ "$CLEANED" -gt 0 ]; then
|
|
|
102
123
|
fi
|
|
103
124
|
echo ""
|
|
104
125
|
echo -e " Handoff data in .claude/handoffs/ was ${CYAN}not touched${NC}."
|
|
126
|
+
echo -e " Auto-handoff settings (threshold, plan, on/off) were ${CYAN}preserved${NC}."
|
|
105
127
|
echo ""
|