xtrm-tools 2.1.12 → 2.1.13
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/package.json
CHANGED
package/config/hooks.json
CHANGED
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
"script": "main-guard.mjs",
|
|
18
18
|
"timeout": 5000
|
|
19
19
|
},
|
|
20
|
+
{
|
|
21
|
+
"matcher": "Bash",
|
|
22
|
+
"script": "main-guard.mjs",
|
|
23
|
+
"timeout": 5000
|
|
24
|
+
},
|
|
20
25
|
{
|
|
21
26
|
"matcher": "Read|Edit|mcp__serena__rename_symbol|mcp__serena__replace_symbol_body|mcp__serena__insert_after_symbol|mcp__serena__insert_before_symbol",
|
|
22
27
|
"script": "serena-workflow-reminder.py"
|
|
@@ -51,17 +56,16 @@
|
|
|
51
56
|
"matcher": "Bash",
|
|
52
57
|
"script": "main-guard-post-push.mjs",
|
|
53
58
|
"timeout": 5000
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
"matcher": "Bash",
|
|
57
|
-
"script": "beads-close-memory-prompt.mjs",
|
|
58
|
-
"timeout": 5000
|
|
59
59
|
}
|
|
60
60
|
],
|
|
61
61
|
"Stop": [
|
|
62
62
|
{
|
|
63
63
|
"script": "beads-stop-gate.mjs",
|
|
64
64
|
"timeout": 5000
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"script": "beads-memory-gate.mjs",
|
|
68
|
+
"timeout": 8000
|
|
65
69
|
}
|
|
66
70
|
]
|
|
67
71
|
},
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// beads-memory-gate — Claude Code Stop hook
|
|
3
|
+
// At session end, forces the agent to evaluate whether this session's work
|
|
4
|
+
// produced insights worth persisting via `bd remember`.
|
|
5
|
+
// Runs after beads-stop-gate (all issues already closed by that point).
|
|
6
|
+
// Exit 0: allow stop | Exit 2: block stop (stderr shown to Claude)
|
|
7
|
+
//
|
|
8
|
+
// Installed by: xtrm install
|
|
9
|
+
|
|
10
|
+
import { execSync } from 'node:child_process';
|
|
11
|
+
import { readFileSync, existsSync, unlinkSync } from 'node:fs';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
|
|
14
|
+
let input;
|
|
15
|
+
try {
|
|
16
|
+
input = JSON.parse(readFileSync(0, 'utf8'));
|
|
17
|
+
} catch {
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const cwd = input.cwd ?? process.env.CLAUDE_PROJECT_DIR ?? process.cwd();
|
|
22
|
+
if (!existsSync(join(cwd, '.beads'))) process.exit(0);
|
|
23
|
+
|
|
24
|
+
// Agent signals evaluation complete by touching this marker, then stops again
|
|
25
|
+
const marker = join(cwd, '.beads', '.memory-gate-done');
|
|
26
|
+
if (existsSync(marker)) {
|
|
27
|
+
try { unlinkSync(marker); } catch { /* ignore */ }
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Only block if there are closed issues — don't fire on empty projects
|
|
32
|
+
let hasClosed = false;
|
|
33
|
+
try {
|
|
34
|
+
const out = execSync('bd list --status=closed', {
|
|
35
|
+
encoding: 'utf8',
|
|
36
|
+
cwd,
|
|
37
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
38
|
+
timeout: 8000,
|
|
39
|
+
});
|
|
40
|
+
hasClosed = /^✓/m.test(out);
|
|
41
|
+
} catch {
|
|
42
|
+
process.exit(0); // fail open
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!hasClosed) process.exit(0);
|
|
46
|
+
|
|
47
|
+
process.stderr.write(
|
|
48
|
+
'🧠 MEMORY GATE: Before ending the session, evaluate this session\'s work.\n\n' +
|
|
49
|
+
'For each issue you worked on and closed, ask:\n' +
|
|
50
|
+
' Is this a stable pattern, key decision, or solution I\'ll encounter again?\n\n' +
|
|
51
|
+
' YES → bd remember "<precise, durable insight>"\n' +
|
|
52
|
+
' NO → explicitly note "nothing worth persisting" and continue\n\n' +
|
|
53
|
+
'When done, signal completion and stop again:\n' +
|
|
54
|
+
' touch .beads/.memory-gate-done\n'
|
|
55
|
+
);
|
|
56
|
+
process.exit(2);
|
|
@@ -64,7 +64,7 @@ process.stdout.write(JSON.stringify({
|
|
|
64
64
|
`✅ Pushed '${branch}'. Next workflow steps:\n\n` +
|
|
65
65
|
' 1. gh pr create --fill\n' +
|
|
66
66
|
' 2. gh pr merge --squash\n' +
|
|
67
|
-
' 3. git checkout main && git
|
|
67
|
+
' 3. git checkout main && git reset --hard origin/main\n\n' +
|
|
68
68
|
'Before/after merge, ensure beads state is updated (e.g. bd close <id>).',
|
|
69
69
|
}));
|
|
70
70
|
process.stdout.write('\n');
|
package/hooks/main-guard.mjs
CHANGED
|
@@ -96,6 +96,8 @@ if (tool === 'Bash') {
|
|
|
96
96
|
/^git\s+worktree\b/,
|
|
97
97
|
/^git\s+checkout\s+-b\s+\S+/,
|
|
98
98
|
/^git\s+switch\s+-c\s+\S+/,
|
|
99
|
+
// Allow post-merge sync to protected branch only (not arbitrary origin refs)
|
|
100
|
+
...protectedBranches.map(b => new RegExp(`^git\\s+reset\\s+--hard\\s+origin/${b}\\b`)),
|
|
99
101
|
/^gh\s+/,
|
|
100
102
|
/^bd\s+/,
|
|
101
103
|
];
|
package/package.json
CHANGED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// beads-close-memory-prompt — Claude Code PostToolUse hook
|
|
3
|
-
// After `bd close`: clears session claim from bd kv, then injects a short
|
|
4
|
-
// reminder into Claude's context to capture knowledge and consider underused
|
|
5
|
-
// beads features.
|
|
6
|
-
// Output to stdout is shown to Claude as additional context.
|
|
7
|
-
//
|
|
8
|
-
// Installed by: xtrm install
|
|
9
|
-
|
|
10
|
-
import { readFileSync } from 'node:fs';
|
|
11
|
-
import {
|
|
12
|
-
resolveCwd, isBeadsProject, clearSessionClaim, withSafeBdContext,
|
|
13
|
-
} from './beads-gate-utils.mjs';
|
|
14
|
-
|
|
15
|
-
let input;
|
|
16
|
-
try {
|
|
17
|
-
input = JSON.parse(readFileSync(0, 'utf8'));
|
|
18
|
-
} catch {
|
|
19
|
-
process.exit(0);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (input.tool_name !== 'Bash') process.exit(0);
|
|
23
|
-
if (!/\bbd\s+close\b/.test(input.tool_input?.command ?? '')) process.exit(0);
|
|
24
|
-
|
|
25
|
-
withSafeBdContext(() => {
|
|
26
|
-
const cwd = resolveCwd(input);
|
|
27
|
-
if (!isBeadsProject(cwd)) process.exit(0);
|
|
28
|
-
|
|
29
|
-
if (input.session_id) {
|
|
30
|
-
clearSessionClaim(input.session_id, cwd);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
process.stdout.write(
|
|
34
|
-
'\n[beads] Issue(s) closed. Before moving on:\n\n' +
|
|
35
|
-
' Knowledge worth keeping?\n' +
|
|
36
|
-
' bd remember "key insight from this work"\n' +
|
|
37
|
-
' bd memories <keyword> -- search what is already stored\n\n' +
|
|
38
|
-
' Discovered related work while implementing?\n' +
|
|
39
|
-
' bd create --title="..." --deps=discovered-from:<id>\n\n' +
|
|
40
|
-
' Underused features to consider:\n' +
|
|
41
|
-
' bd dep add <a> <b> -- link blocking relationships between issues\n' +
|
|
42
|
-
' bd graph -- visualize issue dependency graph\n' +
|
|
43
|
-
' bd orphans -- issues referenced in commits but still open\n' +
|
|
44
|
-
' bd preflight -- PR readiness checklist before gh pr create\n' +
|
|
45
|
-
' bd stale -- issues not touched recently\n'
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
process.exit(0);
|
|
49
|
-
});
|