@memnexus-ai/mx-agent-cli 0.1.44 → 0.1.46
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/dist/__tests__/claude-sync.test.js +91 -13
- package/dist/__tests__/claude-sync.test.js.map +1 -1
- package/dist/commands/init.d.ts +9 -3
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +35 -21
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +2 -1
- package/dist/commands/start.js.map +1 -1
- package/dist/lib/claude.d.ts +2 -3
- package/dist/lib/claude.d.ts.map +1 -1
- package/dist/lib/claude.js +166 -16
- package/dist/lib/claude.js.map +1 -1
- package/dist/lib/templates.d.ts +21 -1
- package/dist/lib/templates.d.ts.map +1 -1
- package/dist/lib/templates.js +423 -30
- package/dist/lib/templates.js.map +1 -1
- package/dist/lib/worktree.d.ts +1 -1
- package/dist/lib/worktree.js +2 -2
- package/dist/lib/worktree.js.map +1 -1
- package/package.json +1 -1
package/dist/lib/templates.js
CHANGED
|
@@ -9,26 +9,36 @@
|
|
|
9
9
|
* Grants bash access and restricts to the worktree directory.
|
|
10
10
|
*/
|
|
11
11
|
export const SETTINGS_JSON_TEMPLATE = JSON.stringify({
|
|
12
|
+
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS: '1',
|
|
12
13
|
hooks: {
|
|
13
14
|
PreToolUse: [
|
|
14
15
|
{
|
|
15
16
|
matcher: 'Bash',
|
|
16
|
-
hooks: [
|
|
17
|
+
hooks: [
|
|
18
|
+
{ type: 'command', command: '.claude/hooks/worktree-guard.sh' },
|
|
19
|
+
{ type: 'command', command: '.claude/hooks/mx-guard-hook.sh' },
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
PreCompact: [
|
|
24
|
+
{
|
|
25
|
+
matcher: '',
|
|
26
|
+
hooks: [{ type: 'command', command: '.claude/hooks/auto-checkpoint.sh' }],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
SessionStart: [
|
|
30
|
+
{
|
|
31
|
+
matcher: 'compact',
|
|
32
|
+
hooks: [{ type: 'command', command: '.claude/hooks/reload-checkpoint.sh' }],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
matcher: '',
|
|
36
|
+
hooks: [{ type: 'command', command: '.claude/hooks/set-terminal-appearance.sh' }],
|
|
17
37
|
},
|
|
18
38
|
],
|
|
19
39
|
},
|
|
20
40
|
permissions: {
|
|
21
41
|
allow: [
|
|
22
|
-
'Bash',
|
|
23
|
-
'Read',
|
|
24
|
-
'Edit',
|
|
25
|
-
'Write',
|
|
26
|
-
'Glob',
|
|
27
|
-
'Grep',
|
|
28
|
-
'WebFetch',
|
|
29
|
-
'WebSearch',
|
|
30
|
-
'Task',
|
|
31
|
-
'NotebookEdit',
|
|
32
42
|
'mcp__MX__search_memories',
|
|
33
43
|
'mcp__MX__create_memory',
|
|
34
44
|
'mcp__MX__retrieve_episodic_memory',
|
|
@@ -40,6 +50,16 @@ export const SETTINGS_JSON_TEMPLATE = JSON.stringify({
|
|
|
40
50
|
'mcp__MX__graphrag_query',
|
|
41
51
|
'mcp__MX__get_memory_usage',
|
|
42
52
|
'mcp__MX__list_conversations',
|
|
53
|
+
'Bash',
|
|
54
|
+
'Read',
|
|
55
|
+
'Edit',
|
|
56
|
+
'Write',
|
|
57
|
+
'Glob',
|
|
58
|
+
'Grep',
|
|
59
|
+
'WebFetch',
|
|
60
|
+
'WebSearch',
|
|
61
|
+
'Task',
|
|
62
|
+
'NotebookEdit',
|
|
43
63
|
],
|
|
44
64
|
deny: [
|
|
45
65
|
'Bash(rm -rf /*)',
|
|
@@ -52,6 +72,12 @@ export const SETTINGS_JSON_TEMPLATE = JSON.stringify({
|
|
|
52
72
|
'Bash(git reset --hard *)',
|
|
53
73
|
'Bash(git clean -fd *)',
|
|
54
74
|
'Bash(git clean -fdx *)',
|
|
75
|
+
'Bash(kubectl delete namespace *)',
|
|
76
|
+
'Bash(kubectl delete node *)',
|
|
77
|
+
'Bash(helm uninstall *)',
|
|
78
|
+
'Bash(az group delete *)',
|
|
79
|
+
'Bash(az aks delete *)',
|
|
80
|
+
'Bash(az deployment group delete *)',
|
|
55
81
|
'Bash(git checkout main)',
|
|
56
82
|
'Bash(git checkout main *)',
|
|
57
83
|
'Bash(git checkout -)',
|
|
@@ -75,30 +101,97 @@ export const SETTINGS_JSON_TEMPLATE = JSON.stringify({
|
|
|
75
101
|
'Bash(docker kill *)',
|
|
76
102
|
'Bash(docker rm *)',
|
|
77
103
|
'Bash(docker rmi *)',
|
|
104
|
+
'Bash(kubectl delete pod *)',
|
|
105
|
+
'Bash(kubectl delete deployment *)',
|
|
106
|
+
'Bash(kubectl delete service *)',
|
|
107
|
+
'Bash(kubectl drain *)',
|
|
108
|
+
'Bash(kubectl taint *)',
|
|
109
|
+
'Bash(helm upgrade *)',
|
|
110
|
+
'Bash(helm rollback *)',
|
|
111
|
+
'Bash(az aks upgrade *)',
|
|
112
|
+
'Bash(az aks scale *)',
|
|
113
|
+
'Bash(az deployment group create *)',
|
|
114
|
+
'Bash(az vm delete *)',
|
|
115
|
+
'Bash(az storage account delete *)',
|
|
78
116
|
],
|
|
79
117
|
},
|
|
80
118
|
}, null, 2);
|
|
119
|
+
/**
|
|
120
|
+
* mx-guard-hook.sh — PreToolUse hook that runs mx-guard check before
|
|
121
|
+
* allowing git push commands.
|
|
122
|
+
*/
|
|
123
|
+
export const MX_GUARD_HOOK_SH_TEMPLATE = `#!/bin/bash
|
|
124
|
+
# mx-guard pre-push enforcement hook
|
|
125
|
+
# Runs mx-guard check before allowing git push commands.
|
|
126
|
+
# Deployed by mx-agent create via syncClaudeConfig().
|
|
127
|
+
#
|
|
128
|
+
# Exit codes:
|
|
129
|
+
# 0 = allow (not a push command, or mx-guard passes)
|
|
130
|
+
# 2 = block (mx-guard found errors)
|
|
131
|
+
|
|
132
|
+
# Read hook input from stdin
|
|
133
|
+
INPUT=$(cat)
|
|
134
|
+
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
|
|
135
|
+
|
|
136
|
+
# Only intercept git push commands
|
|
137
|
+
if [[ ! "$COMMAND" =~ ^git\\ push ]]; then
|
|
138
|
+
exit 0
|
|
139
|
+
fi
|
|
140
|
+
|
|
141
|
+
# Check if mx-guard is available
|
|
142
|
+
if ! command -v mx-guard &>/dev/null; then
|
|
143
|
+
echo "⚠ mx-guard not installed — skipping pre-push validation"
|
|
144
|
+
echo " Install: pnpm install -g @memnexus-ai/mx-guard"
|
|
145
|
+
exit 0
|
|
146
|
+
fi
|
|
147
|
+
|
|
148
|
+
# Run mx-guard check (change-aware — only checks files on current branch)
|
|
149
|
+
echo "Running mx-guard check before push..."
|
|
150
|
+
echo ""
|
|
151
|
+
|
|
152
|
+
mx-guard check
|
|
153
|
+
GUARD_EXIT=$?
|
|
154
|
+
|
|
155
|
+
if [ $GUARD_EXIT -ne 0 ]; then
|
|
156
|
+
echo ""
|
|
157
|
+
echo "mx-guard: push blocked. Fix the errors above before pushing."
|
|
158
|
+
echo " To check specific rules: mx-guard check --rule <category>"
|
|
159
|
+
echo " To see all rules: mx-guard rules"
|
|
160
|
+
exit 2
|
|
161
|
+
fi
|
|
162
|
+
|
|
163
|
+
exit 0
|
|
164
|
+
`;
|
|
81
165
|
/**
|
|
82
166
|
* Stub worktree-guard.sh hook.
|
|
83
167
|
* Blocks branch switching to main and force-pushes.
|
|
84
168
|
*/
|
|
85
169
|
export const WORKTREE_GUARD_SH_TEMPLATE = `#!/bin/bash
|
|
86
|
-
#
|
|
87
|
-
#
|
|
88
|
-
#
|
|
170
|
+
# Worktree isolation guard - runs before every Bash command
|
|
171
|
+
# Exit 0 = allow, Exit 2 = block (non-zero exit blocks the command)
|
|
172
|
+
#
|
|
173
|
+
# This hook enforces worktree isolation by:
|
|
174
|
+
# 1. Blocking cd commands that leave the worktree directory
|
|
175
|
+
# 2. Blocking dangerous git operations (belt-and-suspenders with settings.json)
|
|
89
176
|
#
|
|
90
|
-
#
|
|
177
|
+
# Requires environment variables set by \`worktree start\`:
|
|
178
|
+
# - CLAUDE_WORKTREE_PATH: Absolute path to worktree (e.g., /workspace/.worktrees/foo)
|
|
179
|
+
# - CLAUDE_WORKTREE_NAME: Worktree name (e.g., foo)
|
|
91
180
|
|
|
92
181
|
set -euo pipefail
|
|
93
182
|
|
|
94
|
-
# Read tool input from stdin (JSON format)
|
|
183
|
+
# Read the tool input from stdin (JSON format)
|
|
95
184
|
INPUT=$(cat)
|
|
185
|
+
|
|
186
|
+
# Extract the command - handle both direct command and tool_input formats
|
|
96
187
|
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // .command // empty' 2>/dev/null)
|
|
97
188
|
|
|
98
189
|
if [[ -z "$COMMAND" ]]; then
|
|
190
|
+
# Can't parse command, allow it (fail open)
|
|
99
191
|
exit 0
|
|
100
192
|
fi
|
|
101
193
|
|
|
194
|
+
# Get worktree path from environment
|
|
102
195
|
WORKTREE_PATH="\${CLAUDE_WORKTREE_PATH:-}"
|
|
103
196
|
|
|
104
197
|
# If no worktree restriction set, allow everything
|
|
@@ -106,52 +199,352 @@ if [[ -z "$WORKTREE_PATH" ]]; then
|
|
|
106
199
|
exit 0
|
|
107
200
|
fi
|
|
108
201
|
|
|
202
|
+
# Normalize worktree path (remove trailing slash)
|
|
109
203
|
WORKTREE_PATH="\${WORKTREE_PATH%/}"
|
|
110
204
|
|
|
111
|
-
#
|
|
112
|
-
|
|
113
|
-
|
|
205
|
+
# Get current working directory
|
|
206
|
+
CURRENT_DIR=$(pwd)
|
|
207
|
+
|
|
208
|
+
# ============================================================
|
|
209
|
+
# Rule 1: Block cd to paths outside worktree
|
|
210
|
+
# ============================================================
|
|
211
|
+
if echo "$COMMAND" | grep -qE '^\\s*cd\\s+' || echo "$COMMAND" | grep -qE '&&\\s*cd\\s+' || echo "$COMMAND" | grep -qE ';\\s*cd\\s+'; then
|
|
212
|
+
# Extract cd target(s) from command
|
|
213
|
+
# This handles: cd /path, cd path, command && cd path, etc.
|
|
214
|
+
|
|
215
|
+
# Get all cd targets
|
|
216
|
+
CD_TARGETS=$(echo "$COMMAND" | grep -oE 'cd\\s+[^;&|]+' | sed 's/cd\\s*//' | tr -d '"'"'" || true)
|
|
217
|
+
|
|
114
218
|
for TARGET in $CD_TARGETS; do
|
|
219
|
+
# Skip empty targets
|
|
115
220
|
[[ -z "$TARGET" ]] && continue
|
|
221
|
+
|
|
222
|
+
# Resolve the path
|
|
116
223
|
if [[ "$TARGET" == /* ]]; then
|
|
224
|
+
# Absolute path
|
|
117
225
|
RESOLVED="$TARGET"
|
|
226
|
+
elif [[ "$TARGET" == "~"* ]]; then
|
|
227
|
+
# Home directory path
|
|
228
|
+
RESOLVED="\${TARGET/#\\~/$HOME}"
|
|
118
229
|
else
|
|
119
|
-
|
|
230
|
+
# Relative path - resolve from current directory
|
|
231
|
+
RESOLVED=$(cd "$CURRENT_DIR" 2>/dev/null && cd "$TARGET" 2>/dev/null && pwd) || RESOLVED=""
|
|
120
232
|
fi
|
|
233
|
+
|
|
234
|
+
# Normalize resolved path
|
|
121
235
|
RESOLVED="\${RESOLVED%/}"
|
|
122
|
-
|
|
123
|
-
|
|
236
|
+
|
|
237
|
+
# Allow /tmp and /var/tmp
|
|
238
|
+
if [[ "$RESOLVED" == /tmp* ]] || [[ "$RESOLVED" == /var/tmp* ]]; then
|
|
239
|
+
continue
|
|
240
|
+
fi
|
|
241
|
+
|
|
242
|
+
# Allow paths within worktree
|
|
243
|
+
if [[ "$RESOLVED" == "$WORKTREE_PATH"* ]]; then
|
|
244
|
+
continue
|
|
245
|
+
fi
|
|
246
|
+
|
|
247
|
+
# Allow the scratchpad directory
|
|
248
|
+
if [[ "$RESOLVED" == *"/scratchpad"* ]]; then
|
|
249
|
+
continue
|
|
250
|
+
fi
|
|
251
|
+
|
|
252
|
+
# Allow the user's home directory (for inspecting global tools, configs, etc.)
|
|
253
|
+
if [[ -n "$HOME" ]] && [[ "$RESOLVED" == "$HOME"* ]]; then
|
|
254
|
+
continue
|
|
255
|
+
fi
|
|
256
|
+
|
|
257
|
+
# Block: path is outside worktree
|
|
124
258
|
if [[ -n "$RESOLVED" ]]; then
|
|
125
|
-
echo "
|
|
259
|
+
echo ""
|
|
260
|
+
echo "BLOCKED: Cannot navigate outside worktree"
|
|
261
|
+
echo " Target: $TARGET"
|
|
262
|
+
echo " Resolved: $RESOLVED"
|
|
263
|
+
echo " Allowed: $WORKTREE_PATH (and /tmp)"
|
|
264
|
+
echo ""
|
|
265
|
+
echo "You are working in worktree: \${CLAUDE_WORKTREE_NAME:-unknown}"
|
|
266
|
+
echo "Stay within your assigned worktree directory."
|
|
267
|
+
echo ""
|
|
126
268
|
exit 2
|
|
127
269
|
fi
|
|
128
270
|
done
|
|
129
271
|
fi
|
|
130
272
|
|
|
131
|
-
#
|
|
273
|
+
# ============================================================
|
|
274
|
+
# Rule 2: Block git operations that could tangle state
|
|
275
|
+
# (Belt-and-suspenders with settings.json deny rules)
|
|
276
|
+
# ============================================================
|
|
277
|
+
|
|
278
|
+
# Block checkout to main
|
|
132
279
|
if echo "$COMMAND" | grep -qE 'git\\s+(checkout|switch)\\s+main(\\s|$)'; then
|
|
133
|
-
echo "
|
|
280
|
+
echo ""
|
|
281
|
+
echo "BLOCKED: Cannot switch to main branch"
|
|
282
|
+
echo " Command: $COMMAND"
|
|
283
|
+
echo " Worktree: \${CLAUDE_WORKTREE_NAME:-unknown}"
|
|
284
|
+
echo ""
|
|
285
|
+
echo "To work on main, use a different worktree or the root workspace."
|
|
286
|
+
echo ""
|
|
134
287
|
exit 2
|
|
135
288
|
fi
|
|
136
289
|
|
|
137
|
-
# Block new branch creation
|
|
290
|
+
# Block checkout -b (new branch creation)
|
|
138
291
|
if echo "$COMMAND" | grep -qE 'git\\s+(checkout\\s+-b|switch\\s+(-c|--create))'; then
|
|
139
|
-
echo "
|
|
292
|
+
echo ""
|
|
293
|
+
echo "BLOCKED: Cannot create new branches"
|
|
294
|
+
echo " Command: $COMMAND"
|
|
295
|
+
echo " Worktree: \${CLAUDE_WORKTREE_NAME:-unknown}"
|
|
296
|
+
echo ""
|
|
297
|
+
echo "Work on your assigned branch. Create PRs to merge changes."
|
|
298
|
+
echo ""
|
|
140
299
|
exit 2
|
|
141
300
|
fi
|
|
142
301
|
|
|
143
302
|
# Block merge
|
|
144
303
|
if echo "$COMMAND" | grep -qE 'git\\s+merge\\s'; then
|
|
145
|
-
echo "
|
|
304
|
+
echo ""
|
|
305
|
+
echo "BLOCKED: Cannot merge branches directly"
|
|
306
|
+
echo " Command: $COMMAND"
|
|
307
|
+
echo " Worktree: \${CLAUDE_WORKTREE_NAME:-unknown}"
|
|
308
|
+
echo ""
|
|
309
|
+
echo "Use pull requests to merge changes."
|
|
310
|
+
echo ""
|
|
146
311
|
exit 2
|
|
147
312
|
fi
|
|
148
313
|
|
|
149
314
|
# Block push to main
|
|
150
|
-
if echo "$COMMAND" | grep -qE 'git\\s+push\\s
|
|
151
|
-
echo "
|
|
315
|
+
if echo "$COMMAND" | grep -qE 'git\\s+push\\s+.*\\s*origin\\s+main'; then
|
|
316
|
+
echo ""
|
|
317
|
+
echo "BLOCKED: Cannot push to main"
|
|
318
|
+
echo " Command: $COMMAND"
|
|
319
|
+
echo ""
|
|
320
|
+
echo "Push to your worktree branch and create a PR."
|
|
321
|
+
echo ""
|
|
152
322
|
exit 2
|
|
153
323
|
fi
|
|
154
324
|
|
|
325
|
+
# ============================================================
|
|
326
|
+
# All checks passed - allow the command
|
|
327
|
+
# ============================================================
|
|
328
|
+
exit 0
|
|
329
|
+
`;
|
|
330
|
+
/**
|
|
331
|
+
* auto-checkpoint.sh — PreCompact hook that saves a checkpoint memory
|
|
332
|
+
* before context compaction so agents can resume after losing context.
|
|
333
|
+
*/
|
|
334
|
+
export const AUTO_CHECKPOINT_SH_TEMPLATE = `#!/bin/bash
|
|
335
|
+
# auto-checkpoint.sh — Claude Code PreCompact hook
|
|
336
|
+
# Saves a checkpoint memory before context compaction so agents can resume
|
|
337
|
+
# after losing context. Uses the /mx-checkpoint template format.
|
|
338
|
+
#
|
|
339
|
+
# Fires on: PreCompact (auto or manual compaction)
|
|
340
|
+
# Input: JSON on stdin with transcript_path, session_id, trigger
|
|
341
|
+
# Output: none (side-effect only — saves memory via mx CLI)
|
|
342
|
+
# Exit: always 0 (never blocks compaction)
|
|
343
|
+
|
|
344
|
+
# Fail-open: any error → allow compaction without saving
|
|
345
|
+
trap 'exit 0' ERR
|
|
346
|
+
|
|
347
|
+
# ── 1. Parse hook input ──────────────────────────────────────────────────
|
|
348
|
+
INPUT=$(cat)
|
|
349
|
+
|
|
350
|
+
TRANSCRIPT_PATH=$(echo "$INPUT" | jq -r '.transcript_path // empty' 2>/dev/null)
|
|
351
|
+
SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // empty' 2>/dev/null)
|
|
352
|
+
TRIGGER=$(echo "$INPUT" | jq -r '.trigger // .source // "auto"' 2>/dev/null)
|
|
353
|
+
|
|
354
|
+
# Skip if no transcript available or jq missing
|
|
355
|
+
if [[ -z "$TRANSCRIPT_PATH" || ! -f "$TRANSCRIPT_PATH" ]]; then
|
|
356
|
+
exit 0
|
|
357
|
+
fi
|
|
358
|
+
|
|
359
|
+
command -v jq >/dev/null 2>&1 || exit 0
|
|
360
|
+
command -v mx >/dev/null 2>&1 || exit 0
|
|
361
|
+
|
|
362
|
+
# ── 2. Extract context from transcript ───────────────────────────────────
|
|
363
|
+
|
|
364
|
+
# Recent user/assistant text (last ~200 lines of transcript, text content only)
|
|
365
|
+
RECENT_TEXT=$(tail -200 "$TRANSCRIPT_PATH" | \\
|
|
366
|
+
jq -r '
|
|
367
|
+
select(.type == "user" or .type == "assistant") |
|
|
368
|
+
.message.content[]? |
|
|
369
|
+
select(.type == "text") |
|
|
370
|
+
.text // empty
|
|
371
|
+
' 2>/dev/null | tail -c 8000)
|
|
372
|
+
|
|
373
|
+
# Files touched (from tool_use entries: Read, Edit, Write, Glob)
|
|
374
|
+
FILES_TOUCHED=$(tail -500 "$TRANSCRIPT_PATH" | \\
|
|
375
|
+
jq -r '
|
|
376
|
+
select(.type == "assistant") |
|
|
377
|
+
.message.content[]? |
|
|
378
|
+
select(.type == "tool_use") |
|
|
379
|
+
.input.file_path // empty
|
|
380
|
+
' 2>/dev/null | grep -v '^\$' | sort -u | head -30)
|
|
381
|
+
|
|
382
|
+
# Git branch and PR references
|
|
383
|
+
GIT_BRANCH="\${CLAUDE_WORKTREE_BRANCH:-}"
|
|
384
|
+
if [[ -z "$GIT_BRANCH" ]]; then
|
|
385
|
+
GIT_BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
|
|
386
|
+
fi
|
|
387
|
+
|
|
388
|
+
# GitHub issue/PR references from recent text
|
|
389
|
+
GH_REFS=$(echo "$RECENT_TEXT" | grep -oE '#[0-9]+|PR #[0-9]+|issue #[0-9]+' 2>/dev/null | sort -u | head -10 | tr '\\n' ', ' | sed 's/,\$//')
|
|
390
|
+
|
|
391
|
+
# Worktree info
|
|
392
|
+
WORKTREE_NAME="\${CLAUDE_WORKTREE_NAME:-unknown}"
|
|
393
|
+
WORKTREE_PATH="\${CLAUDE_WORKTREE_PATH:-$(pwd)}"
|
|
394
|
+
|
|
395
|
+
# ── 3. Format checkpoint memory ─────────────────────────────────────────
|
|
396
|
+
|
|
397
|
+
# Build files list (indented)
|
|
398
|
+
FILES_LIST=""
|
|
399
|
+
if [[ -n "$FILES_TOUCHED" ]]; then
|
|
400
|
+
FILES_LIST=$(echo "$FILES_TOUCHED" | sed 's/^/- /')
|
|
401
|
+
fi
|
|
402
|
+
|
|
403
|
+
CONTENT="[Auto-Checkpoint] Context compaction (\${TRIGGER}) — \${WORKTREE_NAME}
|
|
404
|
+
|
|
405
|
+
Branch: \${GIT_BRANCH}
|
|
406
|
+
Session: \${SESSION_ID}
|
|
407
|
+
GitHub refs: \${GH_REFS:-none detected}
|
|
408
|
+
|
|
409
|
+
Goal: [Auto-captured checkpoint before context compaction]
|
|
410
|
+
|
|
411
|
+
Current status: Context window reached capacity. This checkpoint captures the working state just before compaction so the next session can resume.
|
|
412
|
+
|
|
413
|
+
Key files:
|
|
414
|
+
\${FILES_LIST:-No file paths detected in recent transcript.}
|
|
415
|
+
|
|
416
|
+
Key terms: \${WORKTREE_NAME}, \${GIT_BRANCH}, auto-checkpoint, context-compaction
|
|
417
|
+
|
|
418
|
+
Next steps: Resume work from this checkpoint. Review the recent context below to understand what was in progress.
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
Recent context (last messages before compaction):
|
|
422
|
+
|
|
423
|
+
\${RECENT_TEXT:-No recent text extracted from transcript.}"
|
|
424
|
+
|
|
425
|
+
# ── 4. Save checkpoint memory ───────────────────────────────────────────
|
|
426
|
+
|
|
427
|
+
# Use a named memory so it's easy to find and gets overwritten each compaction
|
|
428
|
+
mx memories create \\
|
|
429
|
+
--name "auto-checkpoint-\${WORKTREE_NAME}" \\
|
|
430
|
+
--conversation-id "NEW" \\
|
|
431
|
+
--content "$CONTENT" \\
|
|
432
|
+
--topics "checkpoint,context-compaction" \\
|
|
433
|
+
>/dev/null 2>&1 || true
|
|
434
|
+
|
|
435
|
+
# Always allow compaction to proceed
|
|
436
|
+
exit 0
|
|
437
|
+
`;
|
|
438
|
+
/**
|
|
439
|
+
* reload-checkpoint.sh — SessionStart hook (compact) that re-injects
|
|
440
|
+
* the auto-checkpoint memory after context compaction.
|
|
441
|
+
*/
|
|
442
|
+
export const RELOAD_CHECKPOINT_SH_TEMPLATE = `#!/bin/bash
|
|
443
|
+
# reload-checkpoint.sh — Claude Code SessionStart hook (matcher: compact)
|
|
444
|
+
# Re-injects the auto-checkpoint memory after context compaction.
|
|
445
|
+
#
|
|
446
|
+
# Fires on: SessionStart with source=compact (after compaction)
|
|
447
|
+
# Input: JSON on stdin with session_id, source
|
|
448
|
+
# Output: stdout text is injected into Claude's context
|
|
449
|
+
# Exit: always 0
|
|
450
|
+
|
|
451
|
+
# Fail-open: any error → start session without checkpoint injection
|
|
452
|
+
trap 'exit 0' ERR
|
|
453
|
+
|
|
454
|
+
# ── 1. Determine worktree name ──────────────────────────────────────────
|
|
455
|
+
|
|
456
|
+
WORKTREE_NAME="\${CLAUDE_WORKTREE_NAME:-}"
|
|
457
|
+
|
|
458
|
+
# If no worktree env var, try to detect from cwd
|
|
459
|
+
if [[ -z "$WORKTREE_NAME" ]]; then
|
|
460
|
+
INPUT=$(cat)
|
|
461
|
+
CWD=$(echo "$INPUT" | jq -r '.cwd // empty' 2>/dev/null)
|
|
462
|
+
if [[ "$CWD" == */.worktrees/* ]]; then
|
|
463
|
+
WORKTREE_NAME=$(echo "$CWD" | sed 's|.*/.worktrees/||' | cut -d'/' -f1)
|
|
464
|
+
fi
|
|
465
|
+
fi
|
|
466
|
+
|
|
467
|
+
# Can't identify worktree → nothing to reload
|
|
468
|
+
if [[ -z "$WORKTREE_NAME" ]]; then
|
|
469
|
+
exit 0
|
|
470
|
+
fi
|
|
471
|
+
|
|
472
|
+
command -v mx >/dev/null 2>&1 || exit 0
|
|
473
|
+
|
|
474
|
+
# ── 2. Retrieve checkpoint memory ───────────────────────────────────────
|
|
475
|
+
|
|
476
|
+
CHECKPOINT=$(mx memories get --name "auto-checkpoint-\${WORKTREE_NAME}" 2>/dev/null)
|
|
477
|
+
|
|
478
|
+
if [[ -z "$CHECKPOINT" || "$CHECKPOINT" == *"not found"* || "$CHECKPOINT" == *"404"* ]]; then
|
|
479
|
+
exit 0
|
|
480
|
+
fi
|
|
481
|
+
|
|
482
|
+
# Extract just the content field from the JSON response
|
|
483
|
+
CONTENT=$(echo "$CHECKPOINT" | jq -r '.content // empty' 2>/dev/null)
|
|
484
|
+
|
|
485
|
+
if [[ -z "$CONTENT" ]]; then
|
|
486
|
+
exit 0
|
|
487
|
+
fi
|
|
488
|
+
|
|
489
|
+
# ── 3. Output checkpoint for context injection ──────────────────────────
|
|
490
|
+
# Text written to stdout by SessionStart hooks is added to Claude's context.
|
|
491
|
+
|
|
492
|
+
cat <<CHECKPOINT_EOF
|
|
493
|
+
## Auto-Checkpoint Recovery
|
|
494
|
+
|
|
495
|
+
The following checkpoint was automatically saved before the last context compaction.
|
|
496
|
+
Use it to resume your work. The checkpoint captures what you were working on,
|
|
497
|
+
which files were involved, and the recent conversation context.
|
|
498
|
+
|
|
499
|
+
---
|
|
500
|
+
|
|
501
|
+
\${CONTENT}
|
|
502
|
+
|
|
503
|
+
---
|
|
504
|
+
|
|
505
|
+
**Action:** Review this checkpoint and continue where you left off.
|
|
506
|
+
If you need more context, search memories with: mx memories search --query "<topic>" --recent 24h
|
|
507
|
+
CHECKPOINT_EOF
|
|
508
|
+
|
|
509
|
+
exit 0
|
|
510
|
+
`;
|
|
511
|
+
/**
|
|
512
|
+
* set-terminal-appearance.sh — SessionStart hook that sets VS Code terminal
|
|
513
|
+
* tab title and color via OSC escape sequences written to /dev/tty.
|
|
514
|
+
*/
|
|
515
|
+
export const SET_TERMINAL_APPEARANCE_SH_TEMPLATE = `#!/bin/bash
|
|
516
|
+
# set-terminal-appearance.sh — Claude Code SessionStart hook
|
|
517
|
+
# Sets the VS Code terminal tab title and color for the agent team.
|
|
518
|
+
#
|
|
519
|
+
# Fires on: SessionStart (all — no matcher filter)
|
|
520
|
+
# Input: JSON on stdin (ignored)
|
|
521
|
+
# Output: none (side-effect: writes OSC sequences to /dev/tty)
|
|
522
|
+
# Exit: always 0
|
|
523
|
+
#
|
|
524
|
+
# Reads CLAUDE_TEAM_NAME and CLAUDE_TEAM_COLOR from environment
|
|
525
|
+
# (set by mx-agent start via launchClaudeSession).
|
|
526
|
+
# Writes escape sequences to /dev/tty to bypass Claude's stdin/stdout,
|
|
527
|
+
# ensuring the tab title/color persist after Claude's TUI initializes.
|
|
528
|
+
|
|
529
|
+
TEAM_NAME="\${CLAUDE_TEAM_NAME:-}"
|
|
530
|
+
TEAM_COLOR="\${CLAUDE_TEAM_COLOR:-}"
|
|
531
|
+
|
|
532
|
+
# Nothing to set — not launched via mx-agent
|
|
533
|
+
if [[ -z "$TEAM_NAME" ]]; then
|
|
534
|
+
exit 0
|
|
535
|
+
fi
|
|
536
|
+
|
|
537
|
+
# Drain stdin (hook contract requires reading input)
|
|
538
|
+
cat > /dev/null 2>&1 || true
|
|
539
|
+
|
|
540
|
+
# OSC 0: Set terminal tab title
|
|
541
|
+
printf '\\033]0;%s\\007' "$TEAM_NAME" > /dev/tty 2>/dev/null || true
|
|
542
|
+
|
|
543
|
+
# OSC 633;P;tabColor: Set VS Code tab color (VS Code 1.94+ shell integration)
|
|
544
|
+
if [[ -n "$TEAM_COLOR" ]]; then
|
|
545
|
+
printf '\\033]633;P;tabColor=%s\\007' "$TEAM_COLOR" > /dev/tty 2>/dev/null || true
|
|
546
|
+
fi
|
|
547
|
+
|
|
155
548
|
exit 0
|
|
156
549
|
`;
|
|
157
550
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/lib/templates.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC,SAAS,CAClD;IACE,KAAK,EAAE;QACL,UAAU,EAAE;YACV;gBACE,OAAO,EAAE,MAAM;gBACf,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/lib/templates.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC,SAAS,CAClD;IACE,oCAAoC,EAAE,GAAG;IACzC,KAAK,EAAE;QACL,UAAU,EAAE;YACV;gBACE,OAAO,EAAE,MAAM;gBACf,KAAK,EAAE;oBACL,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,iCAAiC,EAAE;oBAC/D,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,gCAAgC,EAAE;iBAC/D;aACF;SACF;QACD,U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AED,MAAM,UAAU,6BAA6B,CAAC,WAAmB;IAC/D,OAAO;;;;;;;;;;;;QAYD,WAAW;;;;CAIlB,CAAC;AACF,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,OAAO;;;;;;;;;;;;;;;;;;;;;;CAsBR,CAAC;AACF,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,4BAA4B;IAC1C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAohBR,CAAC;AACF,CAAC"}
|
package/dist/lib/worktree.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Git worktree operations for the agent CLI.
|
|
3
|
-
*
|
|
3
|
+
* Git worktree creation and slot management for agent isolation.
|
|
4
4
|
*/
|
|
5
5
|
export declare function findProjectRoot(): string;
|
|
6
6
|
type SlotMap = Record<string, number>;
|
package/dist/lib/worktree.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Git worktree operations for the agent CLI.
|
|
3
|
-
*
|
|
3
|
+
* Git worktree creation and slot management for agent isolation.
|
|
4
4
|
*/
|
|
5
5
|
import { execSync, spawnSync } from 'child_process';
|
|
6
6
|
import { existsSync, readFileSync, readdirSync, writeFileSync, mkdirSync, statSync, symlinkSync } from 'fs';
|
|
@@ -51,7 +51,7 @@ export function findProjectRoot() {
|
|
|
51
51
|
return firstMainGit;
|
|
52
52
|
throw new Error('Could not find project root (no .git directory found)');
|
|
53
53
|
}
|
|
54
|
-
// ── Slot management
|
|
54
|
+
// ── Slot management ──────────────────────────────────────────────────
|
|
55
55
|
const SLOTS_FILENAME = '.slots.json';
|
|
56
56
|
function getSlotsPath(projectRoot, worktreeDir = '.worktrees') {
|
|
57
57
|
return join(projectRoot, worktreeDir, SLOTS_FILENAME);
|
package/dist/lib/worktree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worktree.js","sourceRoot":"","sources":["../../src/lib/worktree.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAC5G,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAErC,yEAAyE;AAEzE;;;;;;;;GAQG;AACH;;;;GAIG;AACH,SAAS,cAAc,CAAC,GAAW;IACjC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAClC,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;IACzC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,IAAI,SAAS,GAAG,OAAO,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