claude-recall 0.20.8 → 0.20.10
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/.claude/hooks/search_enforcer.py +0 -0
- package/.claude/settings.json +92 -1
- package/.claude/skills/auto-corrections/SKILL.md +3 -1
- package/.claude/skills/auto-corrections/manifest.json +5 -3
- package/.claude/skills/auto-failure-lessons/SKILL.md +12 -1
- package/.claude/skills/auto-failure-lessons/manifest.json +14 -3
- package/.claude/skills/auto-preferences/SKILL.md +7 -5
- package/.claude/skills/auto-preferences/manifest.json +9 -7
- package/README.md +4 -1
- package/dist/cli/claude-recall-cli.js +23 -1
- package/dist/cli/commands/hook-commands.js +10 -0
- package/dist/hooks/subagent-hooks.js +102 -0
- package/package.json +1 -1
|
File without changes
|
package/.claude/settings.json
CHANGED
|
@@ -1 +1,92 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"SessionStart": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "compact",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "node /home/ebiarao/.nvm/versions/node/v20.19.3/lib/node_modules/claude-recall/dist/cli/claude-recall-cli.js hook run post-compact-reload",
|
|
10
|
+
"timeout": 10
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"PostToolUse": [
|
|
16
|
+
{
|
|
17
|
+
"hooks": [
|
|
18
|
+
{
|
|
19
|
+
"type": "command",
|
|
20
|
+
"command": "node /home/ebiarao/.nvm/versions/node/v20.19.3/lib/node_modules/claude-recall/dist/cli/claude-recall-cli.js hook run tool-outcome-watcher",
|
|
21
|
+
"timeout": 3
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"PostToolUseFailure": [
|
|
27
|
+
{
|
|
28
|
+
"hooks": [
|
|
29
|
+
{
|
|
30
|
+
"type": "command",
|
|
31
|
+
"command": "node /home/ebiarao/.nvm/versions/node/v20.19.3/lib/node_modules/claude-recall/dist/cli/claude-recall-cli.js hook run tool-failure",
|
|
32
|
+
"timeout": 3
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"PreToolUse": [
|
|
38
|
+
{
|
|
39
|
+
"matcher": ".*",
|
|
40
|
+
"hooks": [
|
|
41
|
+
{
|
|
42
|
+
"type": "command",
|
|
43
|
+
"command": "python3 /home/ebiarao/repos-wsl/personal-projects/claude-recall/.claude/hooks/search_enforcer.py"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"UserPromptSubmit": [
|
|
49
|
+
{
|
|
50
|
+
"hooks": [
|
|
51
|
+
{
|
|
52
|
+
"type": "command",
|
|
53
|
+
"command": "node /home/ebiarao/.nvm/versions/node/v20.19.3/lib/node_modules/claude-recall/dist/cli/claude-recall-cli.js hook run correction-detector"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"Stop": [
|
|
59
|
+
{
|
|
60
|
+
"hooks": [
|
|
61
|
+
{
|
|
62
|
+
"type": "command",
|
|
63
|
+
"command": "node /home/ebiarao/.nvm/versions/node/v20.19.3/lib/node_modules/claude-recall/dist/cli/claude-recall-cli.js hook run memory-stop",
|
|
64
|
+
"timeout": 30
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "command",
|
|
68
|
+
"command": "node /home/ebiarao/.nvm/versions/node/v20.19.3/lib/node_modules/claude-recall/dist/cli/claude-recall-cli.js hook run memory-sync",
|
|
69
|
+
"timeout": 10
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"PreCompact": [
|
|
75
|
+
{
|
|
76
|
+
"hooks": [
|
|
77
|
+
{
|
|
78
|
+
"type": "command",
|
|
79
|
+
"command": "node /home/ebiarao/.nvm/versions/node/v20.19.3/lib/node_modules/claude-recall/dist/cli/claude-recall-cli.js hook run precompact-preserve",
|
|
80
|
+
"timeout": 60
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"type": "command",
|
|
84
|
+
"command": "node /home/ebiarao/.nvm/versions/node/v20.19.3/lib/node_modules/claude-recall/dist/cli/claude-recall-cli.js hook run memory-sync",
|
|
85
|
+
"timeout": 10
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
"hooksVersion": "11.0.0"
|
|
92
|
+
}
|
|
@@ -8,7 +8,7 @@ source: claude-recall
|
|
|
8
8
|
|
|
9
9
|
# Corrections
|
|
10
10
|
|
|
11
|
-
Auto-generated from
|
|
11
|
+
Auto-generated from 18 memories. Last updated: 2026-04-06.
|
|
12
12
|
|
|
13
13
|
## Rules
|
|
14
14
|
|
|
@@ -26,7 +26,9 @@ Auto-generated from 16 memories. Last updated: 2026-04-06.
|
|
|
26
26
|
- CORRECTION: Memory with complex metadata
|
|
27
27
|
- CORRECTION: Memory with complex metadata
|
|
28
28
|
- CORRECTION: Memory with complex metadata
|
|
29
|
+
- CORRECTION: Memory with complex metadata
|
|
29
30
|
- CORRECTION: License copyright should include user's name instead of 'Claude Recall Contributors'
|
|
31
|
+
- CORRECTION: Use true agentic design where agents decide when to run, not cron jobs
|
|
30
32
|
- CORRECTION: License copyright should list your name instead of 'Claude Recall Contributors'
|
|
31
33
|
|
|
32
34
|
---
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"topicId": "corrections",
|
|
3
|
-
"sourceHash": "
|
|
4
|
-
"memoryCount":
|
|
5
|
-
"generatedAt": "2026-04-
|
|
3
|
+
"sourceHash": "f96988b031c72141d7607ba19dc871b09a774b4cebd97a35cb4155ac8b1f4055",
|
|
4
|
+
"memoryCount": 18,
|
|
5
|
+
"generatedAt": "2026-04-06T18:15:28.374Z",
|
|
6
6
|
"memoryKeys": [
|
|
7
|
+
"memory_1775499328353_2ade6746o",
|
|
7
8
|
"memory_1775496241485_1yyc5ht88",
|
|
8
9
|
"memory_1775494279035_j6uj5lzxo",
|
|
9
10
|
"memory_1775492069326_vksvzmt3f",
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
"memory_1775157082825_8uvrul28i",
|
|
20
21
|
"memory_1775156381094_dr1nihes8",
|
|
21
22
|
"hook_correction_1774180798682_9b5a2hadq",
|
|
23
|
+
"hook_correction_1775498361284_9amjuw4le",
|
|
22
24
|
"hook_correction_1774180805192_4ft4zhfsa"
|
|
23
25
|
]
|
|
24
26
|
}
|
|
@@ -8,11 +8,15 @@ source: claude-recall
|
|
|
8
8
|
|
|
9
9
|
# Failure Lessons
|
|
10
10
|
|
|
11
|
-
Auto-generated from
|
|
11
|
+
Auto-generated from 27 memories. Last updated: 2026-04-06.
|
|
12
12
|
|
|
13
13
|
## Rules
|
|
14
14
|
|
|
15
|
+
- Check command syntax, file paths, and prerequisites before running
|
|
15
16
|
- SQLite query syntax error: LIKE clause requires single quotes around string literal, not double quotes
|
|
17
|
+
- Avoid: Command failed: kill $(pgrep -f "node.*webui/server.js") 2>/dev/null; kill $(pgrep -f "node.*mock-eiap/server.js"... → Instead: Check command syntax, file paths, and prerequisites before running
|
|
18
|
+
- Avoid: Command failed: pgrep -af "webui/server" ; curl -s http://localhost:3000/api/service-health 2>&1 → Instead: Check command syntax, file paths, and prerequisites before running
|
|
19
|
+
- Avoid: Command failed: kill $(pgrep -f "node.*webui/server.js") 2>/dev/null; sleep 1; node webui/server.js > /tmp/webui.... → Instead: Check command syntax, file paths, and prerequisites before running
|
|
16
20
|
- Avoid: Command failed: claude-recall outcomes 2>&1 → Instead: Check command syntax, file paths, and prerequisites before running
|
|
17
21
|
- Avoid: Command failed: npm whoami 2>&1 && npm config get registry 2>&1 → Instead: Check command syntax, file paths, and prerequisites before running
|
|
18
22
|
- Claude-recall MCP Server failed to start with npx claude-recall@latest mcp start
|
|
@@ -21,6 +25,13 @@ Auto-generated from 16 memories. Last updated: 2026-04-02.
|
|
|
21
25
|
- Avoid: Command failed: npx jest tests/unit/failure-detectors.test.ts 2>&1 → Instead: Check command syntax, file paths, and prerequisites before running
|
|
22
26
|
- SQLite query error: LIKE clause needs proper string literal syntax with single quotes in better-sqlite3
|
|
23
27
|
- Node.js syntax error: multiline strings in -e flag not properly escaped; newlines break the command parsing
|
|
28
|
+
- {"what_failed":"Bash command failed: node webui/server.js > /tmp/webui.log 2>&1 & sleep 3 && curl -s http://localhost:3000/api/service...","why_failed":"Exit code 7\n[1]+ Exit 1 node webui/server.js > /tmp/webui.log 2>&1","what_should_do":"Check inputs and prerequisites before retrying","context":"Bash error: Exit code 7\n[1]+ Exit 1 node webui/server.js > /tmp/webui.log 2>&1","preventative_checks":["Verify tool inputs are correct","Check preconditions"]}
|
|
29
|
+
- {"what_failed":"Bash command failed: sleep 2 && curl -s http://localhost:3000/api/service-health 2>&1","why_failed":"Exit code 7","what_should_do":"Check inputs and prerequisites before retrying","context":"Bash error: Exit code 7","preventative_checks":["Verify tool inputs are correct","Check preconditions"]}
|
|
30
|
+
- {"what_failed":"Bash command failed: kill $(pgrep -f \"node.*webui/server.js\") 2>/dev/null; sleep 1; cd /home/ebiarao/repos-wsl/persona...","why_failed":"Exit code 144","what_should_do":"Check inputs and prerequisites before retrying","context":"Bash error: Exit code 144","preventative_checks":["Verify tool inputs are correct","Check preconditions"]}
|
|
31
|
+
- {"what_failed":"Bash command failed: ls artifacts/urgent-trigger-ORACLE.json 2>&1","why_failed":"Exit code 2\nls: cannot access 'artifacts/urgent-trigger-ORACLE.json': No such file or directory","what_should_do":"Check inputs and prerequisites before retrying","context":"Bash error: Exit code 2\nls: cannot access 'artifacts/urgent-trigger-ORACLE.json': No such file or directory","preventative_checks":["Verify tool inputs are correct","Check preconditions"]}
|
|
32
|
+
- {"what_failed":"Bash command failed: node agents/shared/tools/post-comms.js '{\"agent\":\"TEST\",\"type\":\"handoff\",\"priority\":\"bad\",\"messag...","why_failed":"Exit code 1\n[post-comms] Error: priority must be \"normal\" or \"urgent\"","what_should_do":"Check inputs and prerequisites before retrying","context":"Bash error: Exit code 1\n[post-comms] Error: priority must be \"normal\" or \"urgent\"","preventative_checks":["Verify tool inputs are correct","Check preconditions"]}
|
|
33
|
+
- {"what_failed":"Read failed","why_failed":"File content (10265 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whol...","what_should_do":"Check inputs and prerequisites before retrying","context":"Error: File content (10265 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whol...","preventative_checks":["Verify tool inputs are correct","Check preconditions"]}
|
|
34
|
+
- {"what_failed":"Read failed","why_failed":"File content (11505 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whol...","what_should_do":"Check inputs and prerequisites before retrying","context":"Error: File content (11505 tokens) exceeds maximum allowed tokens (10000). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whol...","preventative_checks":["Verify tool inputs are correct","Check preconditions"]}
|
|
24
35
|
- Avoid: Test command reported failures: npx jest tests/unit/failure-detectors.test.ts 2>&1 → Instead: Read test output carefully — exit code 0 does not mean all tests passed
|
|
25
36
|
- Node.js -e flag cannot parse multiline strings with unescaped newlines in single quotes
|
|
26
37
|
- claude-recall reconnection failed after reinstall
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"topicId": "failure-lessons",
|
|
3
|
-
"sourceHash": "
|
|
4
|
-
"memoryCount":
|
|
5
|
-
"generatedAt": "2026-04-
|
|
3
|
+
"sourceHash": "543a967cdc5416d35aa4d95b097e319a3d4c184780ea4ee2975551d2c1187e59",
|
|
4
|
+
"memoryCount": 27,
|
|
5
|
+
"generatedAt": "2026-04-06T18:15:28.298Z",
|
|
6
6
|
"memoryKeys": [
|
|
7
|
+
"promoted_1775498319002_awwrsovw6",
|
|
7
8
|
"hook_failure_1772637584921_0tj4rrxnt",
|
|
9
|
+
"hook_failure_non-zero-exit_1775498318987_pqbmsatub",
|
|
10
|
+
"hook_failure_non-zero-exit_1775498318976_mzbyvdceo",
|
|
11
|
+
"hook_failure_non-zero-exit_1775498318963_thiuiiqef",
|
|
8
12
|
"hook_failure_non-zero-exit_1774020949485_6ubuoswae",
|
|
9
13
|
"hook_failure_non-zero-exit_1773409269877_ful451241",
|
|
10
14
|
"hook_failure_1773409616313_gmsfcbuzh",
|
|
@@ -13,6 +17,13 @@
|
|
|
13
17
|
"hook_failure_non-zero-exit_1772640279977_g3gwlfoqi",
|
|
14
18
|
"hook_failure_1772637570984_yxs8zmurp",
|
|
15
19
|
"hook_failure_1772637485532_djep8eysa",
|
|
20
|
+
"hook_failure_1775499266183_drme5d0j6",
|
|
21
|
+
"hook_failure_1775499258759_4unleb4yv",
|
|
22
|
+
"hook_failure_1775499252924_czqqpfsp3",
|
|
23
|
+
"hook_failure_1775499173022_pkye9oqx8",
|
|
24
|
+
"hook_failure_1775499039635_67oste4m3",
|
|
25
|
+
"hook_failure_1775498545106_8348kw22h",
|
|
26
|
+
"hook_failure_1775498542480_wc23ux8gt",
|
|
16
27
|
"hook_failure_silent-test-failure_1772640279996_m8f3ks8fw",
|
|
17
28
|
"hook_failure_1772637495154_i21dho3dv",
|
|
18
29
|
"hook_failure_1773410663873_oegccxk83",
|
|
@@ -8,10 +8,15 @@ source: claude-recall
|
|
|
8
8
|
|
|
9
9
|
# Preferences
|
|
10
10
|
|
|
11
|
-
Auto-generated from
|
|
11
|
+
Auto-generated from 81 memories. Last updated: 2026-04-06.
|
|
12
12
|
|
|
13
13
|
## Rules
|
|
14
14
|
|
|
15
|
+
- Session test preference 1775499328559
|
|
16
|
+
- Test preference 1775499328384-2
|
|
17
|
+
- Test preference 1775499328384-1
|
|
18
|
+
- Test preference 1775499328384-0
|
|
19
|
+
- Test memory content
|
|
15
20
|
- Session test preference 1775496241643
|
|
16
21
|
- Test preference 1775496241514-2
|
|
17
22
|
- Test preference 1775496241514-1
|
|
@@ -32,9 +37,6 @@ Auto-generated from 79 memories. Last updated: 2026-04-06.
|
|
|
32
37
|
- Test preference 1775491767395-1
|
|
33
38
|
- Test preference 1775491767395-0
|
|
34
39
|
- Test memory content
|
|
35
|
-
- When planning implementation work, always divide into phases/stages. Each phase must have its own verification tests with concrete commands and expected outputs. Only proceed to the next phase when the current phase's tests pass. Never combine untested changes into a single deployment. This prevents hours of debugging cascading failures.
|
|
36
|
-
- Solving issues and testing that they are solved takes priority over committing and pushing. Don't suggest committing until the fix is verified end-to-end.
|
|
37
|
-
- When the user says "jam" it means "just answer me" — give a direct, concise answer without extra exploration, tool calls, or elaboration. Skip the research and just respond.
|
|
38
40
|
- After each refactoring, document the changes made. Don't batch documentation to the end — write it as you go.
|
|
39
41
|
- Any major refactoring requires exhaustive search to make sure nothing is missed. Always grep/search comprehensively before and after changes to verify no stale references, broken imports, or missed files remain.
|
|
40
42
|
- Session test preference 1775169786712
|
|
@@ -68,7 +70,6 @@ Auto-generated from 79 memories. Last updated: 2026-04-06.
|
|
|
68
70
|
- Test preference 1775169244686-0
|
|
69
71
|
- Test memory content
|
|
70
72
|
- Markdown documentation files should be named with the convention YYYYMMDD_<filename>.md (e.g., 20260402_nemoclaw_integration.md). Use underscores, not hyphens, in the date-prefixed filenames.
|
|
71
|
-
- Never commit to git unless the user explicitly approves. Always show the commit message and wait for a clear "yes", "go ahead", "commit", or similar confirmation before running git commit.
|
|
72
73
|
- Session test preference 1775160781884
|
|
73
74
|
- Test preference 1775160781820-2
|
|
74
75
|
- Test preference 1775160781820-1
|
|
@@ -90,6 +91,7 @@ Auto-generated from 79 memories. Last updated: 2026-04-06.
|
|
|
90
91
|
- Test preference 1775156381110-0
|
|
91
92
|
- Test memory content
|
|
92
93
|
- axios npm package was compromised in a supply chain attack (axios@1.14.1 pulled in malicious plain-crypto-js@4.2.1). Claude Recall is NOT affected — does not use axios. Verified 2026-04-01. If axios is ever added as a dependency, pin the version and audit lockfiles.
|
|
94
|
+
- For agentic design, agents should decide when to run rather than using cron jobs for scheduling
|
|
93
95
|
- Upgrade all projects whenever a new version is pushed
|
|
94
96
|
|
|
95
97
|
---
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"topicId": "preferences",
|
|
3
|
-
"sourceHash": "
|
|
4
|
-
"memoryCount":
|
|
5
|
-
"generatedAt": "2026-04-
|
|
3
|
+
"sourceHash": "dce1646010683da840451f75aec6672ca62e50210bc5d2c89fe733ab9f9a60bd",
|
|
4
|
+
"memoryCount": 81,
|
|
5
|
+
"generatedAt": "2026-04-06T18:15:28.596Z",
|
|
6
6
|
"memoryKeys": [
|
|
7
|
+
"memory_1775499328561_9m7ao3h8s",
|
|
8
|
+
"memory_1775499328480_e2zx9g5ly",
|
|
9
|
+
"memory_1775499328425_plvaaxd69",
|
|
10
|
+
"memory_1775499328386_dqcav3itu",
|
|
11
|
+
"memory_1775499328258_cilhe1owj",
|
|
7
12
|
"memory_1775496241645_xtz7cwan4",
|
|
8
13
|
"memory_1775496241576_j7sxxuge3",
|
|
9
14
|
"memory_1775496241542_rg3hj24ud",
|
|
@@ -24,9 +29,6 @@
|
|
|
24
29
|
"memory_1775491767421_vgntf4jt8",
|
|
25
30
|
"memory_1775491767397_f181w5lqd",
|
|
26
31
|
"memory_1775491767290_s7ntmkwpg",
|
|
27
|
-
"memory_1775491073130_p8b493ay9",
|
|
28
|
-
"memory_1775236195716_i3pb5nls7",
|
|
29
|
-
"memory_1775210227089_j433ldlva",
|
|
30
32
|
"memory_1775208934902_2kovciriy",
|
|
31
33
|
"memory_1775208477621_fqa3w21j1",
|
|
32
34
|
"memory_1775169786717_1zmwoe6ai",
|
|
@@ -60,7 +62,6 @@
|
|
|
60
62
|
"memory_1775169244688_03q4mmcky",
|
|
61
63
|
"memory_1775169244628_7kuhf5met",
|
|
62
64
|
"memory_1775168901303_o8o0i4952",
|
|
63
|
-
"memory_1775162828137_l6uw5swdn",
|
|
64
65
|
"memory_1775160781885_fkbnc0s85",
|
|
65
66
|
"memory_1775160781857_gj5y299dr",
|
|
66
67
|
"memory_1775160781842_0xmv146n5",
|
|
@@ -82,6 +83,7 @@
|
|
|
82
83
|
"memory_1775156381111_1x4fxfu9n",
|
|
83
84
|
"memory_1775156381012_3tw7we7cz",
|
|
84
85
|
"memory_1775154208266_arwo2fctx",
|
|
86
|
+
"hook_preference_1775498374200_6d21qj14y",
|
|
85
87
|
"hook_preference_1774106575282_45sk4ep52"
|
|
86
88
|
]
|
|
87
89
|
}
|
package/README.md
CHANGED
|
@@ -65,13 +65,16 @@ Both agents use the same database (`~/.claude-recall/claude-recall.db`). Memorie
|
|
|
65
65
|
### Upgrading
|
|
66
66
|
|
|
67
67
|
```bash
|
|
68
|
-
# Claude Code
|
|
68
|
+
# Claude Code — update binary + re-install hooks in each project
|
|
69
69
|
npm install -g claude-recall
|
|
70
|
+
claude-recall setup --install # run from each project directory
|
|
70
71
|
|
|
71
72
|
# Pi
|
|
72
73
|
pi update claude-recall
|
|
73
74
|
```
|
|
74
75
|
|
|
76
|
+
The MCP server picks up the new version automatically. `setup --install` is needed to update hooks in `.claude/settings.json` (new hook events may have been added).
|
|
77
|
+
|
|
75
78
|
---
|
|
76
79
|
|
|
77
80
|
## What to Expect
|
|
@@ -693,8 +693,30 @@ async function main() {
|
|
|
693
693
|
// This avoids registry lookups on every hook invocation.
|
|
694
694
|
const cliScript = path.join(packageDir, 'dist', 'cli', 'claude-recall-cli.js');
|
|
695
695
|
const hookCmd = `node ${cliScript} hook run`;
|
|
696
|
-
settings.hooksVersion = '
|
|
696
|
+
settings.hooksVersion = '12.0.0'; // v12 = add SubagentStart/Stop for sub-agent recall integration
|
|
697
697
|
settings.hooks = {
|
|
698
|
+
SubagentStart: [
|
|
699
|
+
{
|
|
700
|
+
hooks: [
|
|
701
|
+
{
|
|
702
|
+
type: "command",
|
|
703
|
+
command: `${hookCmd} subagent-start`,
|
|
704
|
+
timeout: 5
|
|
705
|
+
}
|
|
706
|
+
]
|
|
707
|
+
}
|
|
708
|
+
],
|
|
709
|
+
SubagentStop: [
|
|
710
|
+
{
|
|
711
|
+
hooks: [
|
|
712
|
+
{
|
|
713
|
+
type: "command",
|
|
714
|
+
command: `${hookCmd} subagent-stop`,
|
|
715
|
+
timeout: 10
|
|
716
|
+
}
|
|
717
|
+
]
|
|
718
|
+
}
|
|
719
|
+
],
|
|
698
720
|
SessionStart: [
|
|
699
721
|
{
|
|
700
722
|
matcher: "compact",
|
|
@@ -90,6 +90,16 @@ class HookCommands {
|
|
|
90
90
|
await handlePostCompactReload(input);
|
|
91
91
|
break;
|
|
92
92
|
}
|
|
93
|
+
case 'subagent-start': {
|
|
94
|
+
const { handleSubagentStart } = await Promise.resolve().then(() => __importStar(require('../../hooks/subagent-hooks')));
|
|
95
|
+
await handleSubagentStart(input);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case 'subagent-stop': {
|
|
99
|
+
const { handleSubagentStop } = await Promise.resolve().then(() => __importStar(require('../../hooks/subagent-hooks')));
|
|
100
|
+
await handleSubagentStop(input);
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
93
103
|
case 'bash-failure-watcher': {
|
|
94
104
|
// Backward compat alias — routes to tool-outcome-watcher
|
|
95
105
|
const { handleBashFailureWatcher } = await Promise.resolve().then(() => __importStar(require('../../hooks/tool-outcome-watcher')));
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Sub-agent hooks — fires on SubagentStart and SubagentStop events.
|
|
4
|
+
*
|
|
5
|
+
* SubagentStart: injects active recall rules into the sub-agent's context
|
|
6
|
+
* via additionalContext (CC adds this as a message the sub-agent sees).
|
|
7
|
+
*
|
|
8
|
+
* SubagentStop: captures the sub-agent's outcome as an outcome event.
|
|
9
|
+
*
|
|
10
|
+
* SubagentStart input: { hook_event_name, agent_id, agent_type, session_id, cwd }
|
|
11
|
+
* SubagentStop input: { hook_event_name, agent_id, agent_type, agent_transcript_path,
|
|
12
|
+
* last_assistant_message, stop_hook_active, session_id, cwd }
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.handleSubagentStart = handleSubagentStart;
|
|
16
|
+
exports.handleSubagentStop = handleSubagentStop;
|
|
17
|
+
const shared_1 = require("./shared");
|
|
18
|
+
const memory_1 = require("../services/memory");
|
|
19
|
+
const config_1 = require("../services/config");
|
|
20
|
+
const outcome_storage_1 = require("../services/outcome-storage");
|
|
21
|
+
function extractVal(value) {
|
|
22
|
+
if (typeof value === 'string')
|
|
23
|
+
return value;
|
|
24
|
+
if (typeof value === 'object' && value !== null) {
|
|
25
|
+
return value.content || value.value || JSON.stringify(value);
|
|
26
|
+
}
|
|
27
|
+
return String(value ?? '');
|
|
28
|
+
}
|
|
29
|
+
function formatRulesCompact(rules) {
|
|
30
|
+
const sections = [];
|
|
31
|
+
if (rules.preferences.length > 0) {
|
|
32
|
+
sections.push('Preferences:\n' + rules.preferences.map(m => `- ${extractVal(m.value)}`).join('\n'));
|
|
33
|
+
}
|
|
34
|
+
if (rules.corrections.length > 0) {
|
|
35
|
+
sections.push('Corrections:\n' + rules.corrections.map(m => `- ${extractVal(m.value)}`).join('\n'));
|
|
36
|
+
}
|
|
37
|
+
if (rules.failures.length > 0) {
|
|
38
|
+
sections.push('Failures:\n' + rules.failures.map(m => `- ${extractVal(m.value)}`).join('\n'));
|
|
39
|
+
}
|
|
40
|
+
if (rules.devops.length > 0) {
|
|
41
|
+
sections.push('DevOps:\n' + rules.devops.map(m => `- ${extractVal(m.value)}`).join('\n'));
|
|
42
|
+
}
|
|
43
|
+
return sections.join('\n\n');
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* SubagentStart — inject recall rules into the sub-agent's context.
|
|
47
|
+
* stdout JSON with additionalContext is injected as a message the sub-agent sees.
|
|
48
|
+
*/
|
|
49
|
+
async function handleSubagentStart(input) {
|
|
50
|
+
try {
|
|
51
|
+
const agentType = input?.agent_type ?? 'unknown';
|
|
52
|
+
const projectId = config_1.ConfigService.getInstance().getProjectId();
|
|
53
|
+
const rules = memory_1.MemoryService.getInstance().loadActiveRules(projectId);
|
|
54
|
+
const totalRules = rules.preferences.length + rules.corrections.length +
|
|
55
|
+
rules.failures.length + rules.devops.length;
|
|
56
|
+
if (totalRules === 0)
|
|
57
|
+
return;
|
|
58
|
+
const body = formatRulesCompact(rules);
|
|
59
|
+
const context = `[Claude Recall] Apply these rules from the user's memory:\n\n${body}\n\n` +
|
|
60
|
+
'Cite each rule at the point where it influences your action: (applied from memory: <rule>)';
|
|
61
|
+
// Structured output — CC reads additionalContext and injects it
|
|
62
|
+
console.log(JSON.stringify({
|
|
63
|
+
hookEventName: 'SubagentStart',
|
|
64
|
+
additionalContext: context,
|
|
65
|
+
}));
|
|
66
|
+
// User notification via stderr (stdout is structured hook output)
|
|
67
|
+
console.error(`🤖 Recall: ${totalRules} rules loaded for sub-agent (${agentType})`);
|
|
68
|
+
(0, shared_1.hookLog)('subagent', `SubagentStart: injected ${totalRules} rules for ${agentType} (${input?.agent_id ?? '?'})`);
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
(0, shared_1.hookLog)('subagent', `SubagentStart error: ${(0, shared_1.safeErrorMessage)(err)}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* SubagentStop — capture the sub-agent's outcome.
|
|
76
|
+
*/
|
|
77
|
+
async function handleSubagentStop(input) {
|
|
78
|
+
try {
|
|
79
|
+
const agentType = input?.agent_type ?? 'unknown';
|
|
80
|
+
const agentId = input?.agent_id ?? 'unknown';
|
|
81
|
+
const lastMessage = input?.last_assistant_message ?? '';
|
|
82
|
+
// Record outcome event
|
|
83
|
+
try {
|
|
84
|
+
const outcomeStorage = outcome_storage_1.OutcomeStorage.getInstance();
|
|
85
|
+
outcomeStorage.createOutcomeEvent({
|
|
86
|
+
event_type: 'subagent_result',
|
|
87
|
+
actor: 'tool',
|
|
88
|
+
action_summary: `Sub-agent (${agentType}) completed`,
|
|
89
|
+
next_state_summary: lastMessage.substring(0, 300) || 'No final message',
|
|
90
|
+
tags: ['agent', 'subagent', agentType],
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// Non-critical
|
|
95
|
+
}
|
|
96
|
+
console.error(`🤖 Recall: sub-agent (${agentType}) outcome captured`);
|
|
97
|
+
(0, shared_1.hookLog)('subagent', `SubagentStop: captured outcome for ${agentType} (${agentId})`);
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
(0, shared_1.hookLog)('subagent', `SubagentStop error: ${(0, shared_1.safeErrorMessage)(err)}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
package/package.json
CHANGED