@soleri/forge 5.1.1 → 5.1.3
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/patching.js +3 -3
- package/dist/patching.js.map +1 -1
- package/dist/templates/activate.js +15 -7
- package/dist/templates/activate.js.map +1 -1
- package/dist/templates/claude-md-template.js +11 -11
- package/dist/templates/claude-md-template.js.map +1 -1
- package/dist/templates/inject-claude-md.js +36 -0
- package/dist/templates/inject-claude-md.js.map +1 -1
- package/dist/templates/setup-script.js +2 -2
- package/dist/templates/setup-script.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/knowledge-installer.test.ts +7 -7
- package/src/patching.ts +3 -3
- package/src/templates/activate.ts +15 -7
- package/src/templates/claude-md-template.ts +38 -38
- package/src/templates/inject-claude-md.ts +36 -0
- package/src/templates/setup-script.ts +2 -2
package/dist/patching.js
CHANGED
|
@@ -85,11 +85,11 @@ function patchIndexTsV4(source, newDomains, hasBrain) {
|
|
|
85
85
|
* Fallback anchor: line containing `## Intent Detection` (older agents without memory/brain rows)
|
|
86
86
|
*/
|
|
87
87
|
export function patchClaudeMdContent(source, agentId, newDomains) {
|
|
88
|
-
const
|
|
88
|
+
const toolPrefix = agentId; // keep hyphens — matches MCP tool registration
|
|
89
89
|
const bt = '`';
|
|
90
90
|
// Filter out domains whose rows already exist (idempotent)
|
|
91
91
|
const domainsToAdd = newDomains.filter((d) => {
|
|
92
|
-
const toolName = `${
|
|
92
|
+
const toolName = `${toolPrefix}_${d.replace(/-/g, '_')}`;
|
|
93
93
|
return !source.includes(`${toolName}`);
|
|
94
94
|
});
|
|
95
95
|
if (domainsToAdd.length === 0)
|
|
@@ -110,7 +110,7 @@ export function patchClaudeMdContent(source, agentId, newDomains) {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
const newRows = domainsToAdd.flatMap((d) => {
|
|
113
|
-
const toolName = `${
|
|
113
|
+
const toolName = `${toolPrefix}_${d.replace(/-/g, '_')}`;
|
|
114
114
|
return [
|
|
115
115
|
` '| ${d} patterns | ${bt}${toolName}${bt} | ${bt}get_patterns${bt} |',`,
|
|
116
116
|
` '| Search ${d} | ${bt}${toolName}${bt} | ${bt}search${bt} |',`,
|
package/dist/patching.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patching.js","sourceRoot":"","sources":["../src/patching.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAc,EACd,UAAoB,EACpB,SAAmB;IAEnB,sEAAsE;IACtE,MAAM,SAAS,GAAG,6DAA6D,CAAC;IAChF,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAExC,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,oBAAoB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,YAAY,GAAG,UAAU,CAAC,MAAM,CACpC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAC5F,CAAC;QACF,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,MAAM,CAAC;QAE7C,MAAM,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChE,MAAM,cAAc,GAAG,oBAAoB,CAAC,IAAI,EAAE,CAAC;QACnD,MAAM,cAAc,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,cAAc,KAAK,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC;QAExF,OAAO,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;YACzC,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C;AACd,CAAC"}
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
* Uses array-joined pattern because generated code contains template literals.
|
|
7
7
|
*/
|
|
8
8
|
export function generateActivate(config) {
|
|
9
|
-
const
|
|
9
|
+
const toolPrefix = config.id; // keep hyphens — matches MCP tool registration
|
|
10
10
|
const _marker = `${config.id}:mode`;
|
|
11
11
|
// Build tool recommendations from config domains
|
|
12
12
|
const toolRecLines = [];
|
|
13
13
|
for (const d of config.domains) {
|
|
14
|
-
const toolName = `${
|
|
14
|
+
const toolName = `${toolPrefix}_${d.replace(/-/g, '_')}`;
|
|
15
15
|
toolRecLines.push(` { intent: 'search ${d}', facade: '${toolName}', op: 'search' },`);
|
|
16
16
|
toolRecLines.push(` { intent: '${d} patterns', facade: '${toolName}', op: 'get_patterns' },`);
|
|
17
17
|
toolRecLines.push(` { intent: 'capture ${d}', facade: '${toolName}', op: 'capture' },`);
|
|
@@ -27,7 +27,7 @@ export function generateActivate(config) {
|
|
|
27
27
|
"import { join } from 'node:path';",
|
|
28
28
|
"import { homedir } from 'node:os';",
|
|
29
29
|
"import { PERSONA } from '../identity/persona.js';",
|
|
30
|
-
"import { hasAgentMarker } from './inject-claude-md.js';",
|
|
30
|
+
"import { hasAgentMarker, removeClaudeMdGlobal } from './inject-claude-md.js';",
|
|
31
31
|
"import type { Vault, Planner, Plan } from '@soleri/core';",
|
|
32
32
|
'',
|
|
33
33
|
'export interface ActivationResult {',
|
|
@@ -54,6 +54,9 @@ export function generateActivate(config) {
|
|
|
54
54
|
'export interface DeactivationResult {',
|
|
55
55
|
' deactivated: boolean;',
|
|
56
56
|
' message: string;',
|
|
57
|
+
' cleanup?: {',
|
|
58
|
+
' globalClaudeMd: boolean;',
|
|
59
|
+
' };',
|
|
57
60
|
'}',
|
|
58
61
|
'',
|
|
59
62
|
'/**',
|
|
@@ -107,9 +110,9 @@ export function generateActivate(config) {
|
|
|
107
110
|
guidelineLines,
|
|
108
111
|
' ],',
|
|
109
112
|
' tool_recommendations: [',
|
|
110
|
-
` { intent: 'health check', facade: '${
|
|
111
|
-
` { intent: 'search all', facade: '${
|
|
112
|
-
` { intent: 'vault stats', facade: '${
|
|
113
|
+
` { intent: 'health check', facade: '${toolPrefix}_core', op: 'health' },`,
|
|
114
|
+
` { intent: 'search all', facade: '${toolPrefix}_core', op: 'search' },`,
|
|
115
|
+
` { intent: 'vault stats', facade: '${toolPrefix}_core', op: 'vault_stats' },`,
|
|
113
116
|
...toolRecLines,
|
|
114
117
|
' ],',
|
|
115
118
|
` session_instruction: 'You are now ' + PERSONA.name + ', a ' + PERSONA.role + '. Stay in character for the ENTIRE session. ' +`,
|
|
@@ -126,12 +129,17 @@ export function generateActivate(config) {
|
|
|
126
129
|
'}',
|
|
127
130
|
'',
|
|
128
131
|
'/**',
|
|
129
|
-
` * Deactivate ${config.name} — drops persona
|
|
132
|
+
` * Deactivate ${config.name} — drops persona and cleans up CLAUDE.md sections.`,
|
|
130
133
|
' */',
|
|
131
134
|
'export function deactivateAgent(): DeactivationResult {',
|
|
135
|
+
' // Remove agent sections from global CLAUDE.md on deactivation',
|
|
136
|
+
' const globalResult = removeClaudeMdGlobal();',
|
|
132
137
|
' return {',
|
|
133
138
|
' deactivated: true,',
|
|
134
139
|
` message: 'Goodbye! ' + PERSONA.name + ' persona deactivated. Reverting to default behavior.',`,
|
|
140
|
+
' cleanup: {',
|
|
141
|
+
' globalClaudeMd: globalResult.removed,',
|
|
142
|
+
' },',
|
|
135
143
|
' };',
|
|
136
144
|
'}',
|
|
137
145
|
].join('\n');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activate.js","sourceRoot":"","sources":["../../src/templates/activate.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAmB;IAClD,MAAM,
|
|
1
|
+
{"version":3,"file":"activate.js","sourceRoot":"","sources":["../../src/templates/activate.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,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K;QACL,iBAAiB,MAAM,CAAC,IAAI,oDAAoD;QAChF,KAAK;QACL,yDAAyD;QACzD,kEAAkE;QAClE,gDAAgD;QAChD,YAAY;QACZ,wBAAwB;QACxB,mGAAmG;QACnG,gBAAgB;QAChB,6CAA6C;QAC7C,QAAQ;QACR,MAAM;QACN,GAAG;KACJ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* backtick/template-literal escaping nightmares entirely.
|
|
9
9
|
*/
|
|
10
10
|
export function generateClaudeMdTemplate(config) {
|
|
11
|
-
const
|
|
11
|
+
const toolPrefix = config.id; // keep hyphens — matches MCP tool registration
|
|
12
12
|
const marker = `${config.id}:mode`;
|
|
13
13
|
const bt = '`'; // backtick — keeps template clean
|
|
14
14
|
// Build the raw markdown lines (plain text, no escaping needed)
|
|
@@ -19,34 +19,34 @@ export function generateClaudeMdTemplate(config) {
|
|
|
19
19
|
'',
|
|
20
20
|
`## ${config.name} Integration`,
|
|
21
21
|
'',
|
|
22
|
-
`**Activate:** "Hello, ${config.name}!" \u2192 ${bt}${
|
|
23
|
-
`**Deactivate:** "Goodbye, ${config.name}!" \u2192 ${bt}${
|
|
22
|
+
`**Activate:** "Hello, ${config.name}!" \u2192 ${bt}${toolPrefix}_core op:activate params:{ projectPath: "." }${bt}`,
|
|
23
|
+
`**Deactivate:** "Goodbye, ${config.name}!" \u2192 ${bt}${toolPrefix}_core op:activate params:{ deactivate: true }${bt}`,
|
|
24
24
|
'',
|
|
25
25
|
'On activation, adopt the returned persona. Stay in character until deactivated.',
|
|
26
26
|
'',
|
|
27
27
|
'## Session Start',
|
|
28
28
|
'',
|
|
29
|
-
`On every new session: ${bt}${
|
|
29
|
+
`On every new session: ${bt}${toolPrefix}_core op:register params:{ projectPath: "." }${bt}`,
|
|
30
30
|
'',
|
|
31
31
|
'## Facades',
|
|
32
32
|
'',
|
|
33
33
|
'| Need | Facade | Op |',
|
|
34
34
|
'|------|--------|----|',
|
|
35
|
-
`| Health check | ${bt}${
|
|
36
|
-
`| Search all | ${bt}${
|
|
37
|
-
`| Vault stats | ${bt}${
|
|
38
|
-
`| Identity | ${bt}${
|
|
35
|
+
`| Health check | ${bt}${toolPrefix}_core${bt} | ${bt}health${bt} |`,
|
|
36
|
+
`| Search all | ${bt}${toolPrefix}_core${bt} | ${bt}search${bt} |`,
|
|
37
|
+
`| Vault stats | ${bt}${toolPrefix}_core${bt} | ${bt}vault_stats${bt} |`,
|
|
38
|
+
`| Identity | ${bt}${toolPrefix}_core${bt} | ${bt}identity${bt} |`,
|
|
39
39
|
];
|
|
40
40
|
// Domain-specific facade rows
|
|
41
41
|
for (const d of config.domains) {
|
|
42
|
-
const toolName = `${
|
|
42
|
+
const toolName = `${toolPrefix}_${d.replace(/-/g, '_')}`;
|
|
43
43
|
mdLines.push(`| ${d} patterns | ${bt}${toolName}${bt} | ${bt}get_patterns${bt} |`);
|
|
44
44
|
mdLines.push(`| Search ${d} | ${bt}${toolName}${bt} | ${bt}search${bt} |`);
|
|
45
45
|
mdLines.push(`| Capture ${d} | ${bt}${toolName}${bt} | ${bt}capture${bt} |`);
|
|
46
46
|
}
|
|
47
47
|
// Memory + Session + Export + Brain + Planning rows
|
|
48
|
-
mdLines.push(`| Memory search | ${bt}${
|
|
49
|
-
mdLines.push('', '## Auto-Routing', '', 'A UserPromptSubmit hook auto-classifies every prompt via keyword matching.', `When you see a ${bt}[MODE-NAME]${bt} indicator in the system context:`, '', `1. Call ${bt}${
|
|
48
|
+
mdLines.push(`| Memory search | ${bt}${toolPrefix}_core${bt} | ${bt}memory_search${bt} |`, `| Memory capture | ${bt}${toolPrefix}_core${bt} | ${bt}memory_capture${bt} |`, `| Memory list | ${bt}${toolPrefix}_core${bt} | ${bt}memory_list${bt} |`, `| Session capture | ${bt}${toolPrefix}_core${bt} | ${bt}session_capture${bt} |`, `| Export knowledge | ${bt}${toolPrefix}_core${bt} | ${bt}export${bt} |`, `| Record feedback | ${bt}${toolPrefix}_core${bt} | ${bt}record_feedback${bt} |`, `| Rebuild vocabulary | ${bt}${toolPrefix}_core${bt} | ${bt}rebuild_vocabulary${bt} |`, `| Brain stats | ${bt}${toolPrefix}_core${bt} | ${bt}brain_stats${bt} |`, `| LLM status | ${bt}${toolPrefix}_core${bt} | ${bt}llm_status${bt} |`, `| Create plan | ${bt}${toolPrefix}_core${bt} | ${bt}create_plan${bt} |`, `| Get plan | ${bt}${toolPrefix}_core${bt} | ${bt}get_plan${bt} |`, `| Approve plan | ${bt}${toolPrefix}_core${bt} | ${bt}approve_plan${bt} |`, `| Update task | ${bt}${toolPrefix}_core${bt} | ${bt}update_task${bt} |`, `| Complete plan | ${bt}${toolPrefix}_core${bt} | ${bt}complete_plan${bt} |`, `| Route intent | ${bt}${toolPrefix}_core${bt} | ${bt}route_intent${bt} |`, `| Morph mode | ${bt}${toolPrefix}_core${bt} | ${bt}morph${bt} |`, `| Get behavior rules | ${bt}${toolPrefix}_core${bt} | ${bt}get_behavior_rules${bt} |`, `| Get identity | ${bt}${toolPrefix}_core${bt} | ${bt}get_identity${bt} |`, `| Update identity | ${bt}${toolPrefix}_core${bt} | ${bt}update_identity${bt} |`, `| Add guideline | ${bt}${toolPrefix}_core${bt} | ${bt}add_guideline${bt} |`, `| Remove guideline | ${bt}${toolPrefix}_core${bt} | ${bt}remove_guideline${bt} |`, `| Rollback identity | ${bt}${toolPrefix}_core${bt} | ${bt}rollback_identity${bt} |`);
|
|
49
|
+
mdLines.push('', '## Auto-Routing', '', 'A UserPromptSubmit hook auto-classifies every prompt via keyword matching.', `When you see a ${bt}[MODE-NAME]${bt} indicator in the system context:`, '', `1. Call ${bt}${toolPrefix}_core op:route_intent params:{ prompt: "<user message>" }${bt} to get full behavior rules`, '2. Follow the returned behavior rules for the detected mode', '3. Briefly acknowledge mode changes in your response (e.g., "Switching to FIX-MODE")', '', 'Available modes: FIX-MODE, BUILD-MODE, IMPROVE-MODE, DELIVER-MODE, REVIEW-MODE, PLAN-MODE, DESIGN-MODE, VALIDATE-MODE, EXPLORE-MODE, GENERAL-MODE.', 'GENERAL-MODE means the hook detected a work task but could not classify a specific mode — route_intent will refine it.', '', '## Intent Detection', '', '| Signal | Intent |', '|--------|--------|', '| Problem described ("broken", "janky", "weird") | FIX |', '| Need expressed ("I need", "we should have") | BUILD |', '| Quality questioned ("is this right?") | REVIEW |', '| Advice sought ("how should I", "best way") | PLAN |', '| Improvement requested ("make it faster") | IMPROVE |', '', '## Knowledge Protocol', '', 'When seeking guidance: vault before codebase before web.', '', `1. Search vault \u2014 ${bt}${toolPrefix}_core op:search${bt}`, '2. Codebase \u2014 only if vault has nothing', '3. Web \u2014 last resort', '', '## Knowledge Capture', '', 'When learning something that should persist, use the domain capture ops.', '', '## Session Capture', '', 'A PreCompact hook is configured to call `session_capture` before context compaction.', 'This automatically preserves session summaries as memories for future sessions.', `To manually capture: ${bt}${toolPrefix}_core op:session_capture params:{ summary: "..." }${bt}`, '', '## Planning', '', 'For multi-step tasks, use the planning system:', `1. Create: ${bt}${toolPrefix}_core op:create_plan params:{ objective: "...", scope: "...", tasks: [...] }${bt}`, `2. Approve: ${bt}${toolPrefix}_core op:approve_plan params:{ planId: "...", startExecution: true }${bt}`, `3. Track: ${bt}${toolPrefix}_core op:update_task params:{ planId: "...", taskId: "...", status: "completed" }${bt}`, `4. Complete: ${bt}${toolPrefix}_core op:complete_plan params:{ planId: "..." }${bt}`, '', 'Check activation response for recovered plans in `executing` state — remind the user.', '', `<!-- /${marker} -->`);
|
|
50
50
|
// Escape each markdown line for use in a single-quoted TS string literal
|
|
51
51
|
const quotedLines = mdLines.map((line) => {
|
|
52
52
|
const escaped = line.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-md-template.js","sourceRoot":"","sources":["../../src/templates/claude-md-template.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,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WAAW;QACd,kBAAkB;QAClB,GAAG;QACH,EAAE;QACF,+CAA+C;QAC/C,aAAa,MAAM,IAAI;QACvB,GAAG;KACJ,CAAC;IAEF,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -80,6 +80,42 @@ export function generateInjectClaudeMd(config) {
|
|
|
80
80
|
'}',
|
|
81
81
|
'',
|
|
82
82
|
'/**',
|
|
83
|
+
' * Remove agent section from a specific CLAUDE.md file.',
|
|
84
|
+
' * Returns true if the section was found and removed.',
|
|
85
|
+
' */',
|
|
86
|
+
'function removeFromFile(filePath: string): { removed: boolean; path: string } {',
|
|
87
|
+
' if (!existsSync(filePath)) return { removed: false, path: filePath };',
|
|
88
|
+
" const existing = readFileSync(filePath, 'utf-8');",
|
|
89
|
+
' const marker = getClaudeMdMarker();',
|
|
90
|
+
` const startMarker = '<!-- ' + marker + ' -->';`,
|
|
91
|
+
` const endMarker = '<!-- /' + marker + ' -->';`,
|
|
92
|
+
' const startIdx = existing.indexOf(startMarker);',
|
|
93
|
+
' if (startIdx === -1) return { removed: false, path: filePath };',
|
|
94
|
+
' const endIdx = existing.indexOf(endMarker);',
|
|
95
|
+
' if (endIdx === -1) return { removed: false, path: filePath };',
|
|
96
|
+
" const before = existing.slice(0, startIdx).replace(/\\n+$/, '');",
|
|
97
|
+
" const after = existing.slice(endIdx + endMarker.length).replace(/^\\n+/, '');",
|
|
98
|
+
" const cleaned = before + (before && after ? '\\n\\n' : '') + after;",
|
|
99
|
+
" writeFileSync(filePath, cleaned || '', 'utf-8');",
|
|
100
|
+
' return { removed: true, path: filePath };',
|
|
101
|
+
'}',
|
|
102
|
+
'',
|
|
103
|
+
'/**',
|
|
104
|
+
' * Remove agent section from the global ~/.claude/CLAUDE.md.',
|
|
105
|
+
' * Called on deactivation to clean up after test agents.',
|
|
106
|
+
' */',
|
|
107
|
+
'export function removeClaudeMdGlobal(): { removed: boolean; path: string } {',
|
|
108
|
+
" return removeFromFile(join(homedir(), '.claude', 'CLAUDE.md'));",
|
|
109
|
+
'}',
|
|
110
|
+
'',
|
|
111
|
+
'/**',
|
|
112
|
+
' * Remove agent section from a project CLAUDE.md.',
|
|
113
|
+
' */',
|
|
114
|
+
'export function removeClaudeMd(projectPath: string): { removed: boolean; path: string } {',
|
|
115
|
+
" return removeFromFile(join(projectPath, 'CLAUDE.md'));",
|
|
116
|
+
'}',
|
|
117
|
+
'',
|
|
118
|
+
'/**',
|
|
83
119
|
' * Check if the agent marker exists in a CLAUDE.md file.',
|
|
84
120
|
' */',
|
|
85
121
|
'export function hasAgentMarker(filePath: string): boolean {',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-claude-md.js","sourceRoot":"","sources":["../../src/templates/inject-claude-md.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAmB;IACxD,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,OAAO,CAAC;IAEnC,OAAO;QACL,+EAA+E;QAC/E,oCAAoC;QACpC,mCAAmC;QACnC,iFAAiF;QACjF,EAAE;QACF,iCAAiC;QACjC,sBAAsB;QACtB,iBAAiB;QACjB,+CAA+C;QAC/C,GAAG;QACH,EAAE;QACF,KAAK;QACL,gDAAgD;QAChD,8DAA8D;QAC9D,KAAK;QACL,2DAA2D;QAC3D,yCAAyC;QACzC,uCAAuC;QACvC,kDAAkD;QAClD,iDAAiD;QACjD,EAAE;QACF,gCAAgC;QAChC,wDAAwD;QACxD,mEAAmE;QACnE,KAAK;QACL,EAAE;QACF,qDAAqD;QACrD,EAAE;QACF,yCAAyC;QACzC,qDAAqD;QACrD,iDAAiD;QACjD,0BAA0B;QAC1B,sHAAsH;QACtH,kDAAkD;QAClD,qEAAqE;QACrE,OAAO;QACP,wGAAwG;QACxG,gDAAgD;QAChD,mEAAmE;QACnE,KAAK;QACL,EAAE;QACF,kEAAkE;QAClE,6EAA6E;QAC7E,kEAAkE;QAClE,GAAG;QACH,EAAE;QACF,KAAK;QACL,mDAAmD;QACnD,0CAA0C;QAC1C,+DAA+D;QAC/D,4CAA4C;QAC5C,KAAK;QACL,qEAAqE;QACrE,0DAA0D;QAC1D,GAAG;QACH,EAAE;QACF,KAAK;QACL,wEAAwE;QACxE,sDAAsD;QACtD,0DAA0D;QAC1D,KAAK;QACL,wDAAwD;QACxD,iDAAiD;QACjD,iCAAiC;QACjC,gDAAgD;QAChD,KAAK;QACL,wDAAwD;QACxD,GAAG;QACH,EAAE;QACF,KAAK;QACL,0DAA0D;QAC1D,KAAK;QACL,6DAA6D;QAC7D,4CAA4C;QAC5C,oDAAoD;QACpD,mCAAmC,MAAM,SAAS;QAClD,GAAG;KACJ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"inject-claude-md.js","sourceRoot":"","sources":["../../src/templates/inject-claude-md.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAmB;IACxD,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,OAAO,CAAC;IAEnC,OAAO;QACL,+EAA+E;QAC/E,oCAAoC;QACpC,mCAAmC;QACnC,iFAAiF;QACjF,EAAE;QACF,iCAAiC;QACjC,sBAAsB;QACtB,iBAAiB;QACjB,+CAA+C;QAC/C,GAAG;QACH,EAAE;QACF,KAAK;QACL,gDAAgD;QAChD,8DAA8D;QAC9D,KAAK;QACL,2DAA2D;QAC3D,yCAAyC;QACzC,uCAAuC;QACvC,kDAAkD;QAClD,iDAAiD;QACjD,EAAE;QACF,gCAAgC;QAChC,wDAAwD;QACxD,mEAAmE;QACnE,KAAK;QACL,EAAE;QACF,qDAAqD;QACrD,EAAE;QACF,yCAAyC;QACzC,qDAAqD;QACrD,iDAAiD;QACjD,0BAA0B;QAC1B,sHAAsH;QACtH,kDAAkD;QAClD,qEAAqE;QACrE,OAAO;QACP,wGAAwG;QACxG,gDAAgD;QAChD,mEAAmE;QACnE,KAAK;QACL,EAAE;QACF,kEAAkE;QAClE,6EAA6E;QAC7E,kEAAkE;QAClE,GAAG;QACH,EAAE;QACF,KAAK;QACL,mDAAmD;QACnD,0CAA0C;QAC1C,+DAA+D;QAC/D,4CAA4C;QAC5C,KAAK;QACL,qEAAqE;QACrE,0DAA0D;QAC1D,GAAG;QACH,EAAE;QACF,KAAK;QACL,wEAAwE;QACxE,sDAAsD;QACtD,0DAA0D;QAC1D,KAAK;QACL,wDAAwD;QACxD,iDAAiD;QACjD,iCAAiC;QACjC,gDAAgD;QAChD,KAAK;QACL,wDAAwD;QACxD,GAAG;QACH,EAAE;QACF,KAAK;QACL,yDAAyD;QACzD,uDAAuD;QACvD,KAAK;QACL,iFAAiF;QACjF,yEAAyE;QACzE,qDAAqD;QACrD,uCAAuC;QACvC,kDAAkD;QAClD,iDAAiD;QACjD,mDAAmD;QACnD,mEAAmE;QACnE,+CAA+C;QAC/C,iEAAiE;QACjE,oEAAoE;QACpE,iFAAiF;QACjF,uEAAuE;QACvE,oDAAoD;QACpD,6CAA6C;QAC7C,GAAG;QACH,EAAE;QACF,KAAK;QACL,8DAA8D;QAC9D,0DAA0D;QAC1D,KAAK;QACL,8EAA8E;QAC9E,mEAAmE;QACnE,GAAG;QACH,EAAE;QACF,KAAK;QACL,mDAAmD;QACnD,KAAK;QACL,2FAA2F;QAC3F,0DAA0D;QAC1D,GAAG;QACH,EAAE;QACF,KAAK;QACL,0DAA0D;QAC1D,KAAK;QACL,6DAA6D;QAC7D,4CAA4C;QAC5C,oDAAoD;QACpD,mCAAmC,MAAM,SAAS;QAClD,GAAG;KACJ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -72,7 +72,7 @@ if [ ! -f "$SETTINGS_FILE" ]; then
|
|
|
72
72
|
"PreCompact": [
|
|
73
73
|
{
|
|
74
74
|
"type": "prompt",
|
|
75
|
-
"prompt": "Before context is compacted, capture a session summary by calling ${config.id
|
|
75
|
+
"prompt": "Before context is compacted, capture a session summary by calling ${config.id}_core op:session_capture with a brief summary of what was accomplished, the topics covered, files modified, and tools used."
|
|
76
76
|
}
|
|
77
77
|
]
|
|
78
78
|
}
|
|
@@ -91,7 +91,7 @@ else
|
|
|
91
91
|
if (!settings.hooks.PreCompact) settings.hooks.PreCompact = [];
|
|
92
92
|
settings.hooks.PreCompact.push({
|
|
93
93
|
type: 'prompt',
|
|
94
|
-
prompt: 'Before context is compacted, capture a session summary by calling ${config.id
|
|
94
|
+
prompt: 'Before context is compacted, capture a session summary by calling ${config.id}_core op:session_capture with a brief summary of what was accomplished, the topics covered, files modified, and tools used.'
|
|
95
95
|
});
|
|
96
96
|
fs.writeFileSync('$SETTINGS_FILE', JSON.stringify(settings, null, 2) + '\\n');
|
|
97
97
|
"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-script.js","sourceRoot":"","sources":["../../src/templates/setup-script.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAmB;IACrD,OAAO;;;;cAIK,MAAM,CAAC,EAAE;;YAEX,MAAM,CAAC,IAAI;;;;;;;;;;;;;;;;;;;mBAmBJ,MAAM,CAAC,IAAI;;;;;;;;;;;;;;;gCAeE,MAAM,CAAC,IAAI;;;;;;;;oBAQvB,MAAM,CAAC,IAAI;;;wBAGP,MAAM,CAAC,IAAI;;;;;;;;;;;;;;;;;;uFAkBoD,MAAM,CAAC,EAAE
|
|
1
|
+
{"version":3,"file":"setup-script.js","sourceRoot":"","sources":["../../src/templates/setup-script.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAmB;IACrD,OAAO;;;;cAIK,MAAM,CAAC,EAAE;;YAEX,MAAM,CAAC,IAAI;;;;;;;;;;;;;;;;;;;mBAmBJ,MAAM,CAAC,IAAI;;;;;;;;;;;;;;;gCAeE,MAAM,CAAC,IAAI;;;;;;;;oBAQvB,MAAM,CAAC,IAAI;;;wBAGP,MAAM,CAAC,IAAI;;;;;;;;;;;;;;;;;;uFAkBoD,MAAM,CAAC,EAAE;;;;;;;;;;;;;;;;;;;qFAmBX,MAAM,CAAC,EAAE;;;;;;;;;;;;;4BAalE,MAAM,CAAC,IAAI;;QAE/B,MAAM,CAAC,IAAI;CAClB,CAAC;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -86,11 +86,11 @@ main();
|
|
|
86
86
|
const content = `export function getClaudeMdContent(): string {
|
|
87
87
|
return [
|
|
88
88
|
'# Test Agent',
|
|
89
|
-
'| existing-domain patterns | \`
|
|
90
|
-
'| Search existing-domain | \`
|
|
91
|
-
'| Capture existing-domain | \`
|
|
92
|
-
'| Memory search | \`
|
|
93
|
-
'| Memory capture | \`
|
|
89
|
+
'| existing-domain patterns | \`test-agent_existing_domain\` | \`get_patterns\` |',
|
|
90
|
+
'| Search existing-domain | \`test-agent_existing_domain\` | \`search\` |',
|
|
91
|
+
'| Capture existing-domain | \`test-agent_existing_domain\` | \`capture\` |',
|
|
92
|
+
'| Memory search | \`test-agent_core\` | \`memory_search\` |',
|
|
93
|
+
'| Memory capture | \`test-agent_core\` | \`memory_capture\` |',
|
|
94
94
|
].join('\\n');
|
|
95
95
|
}
|
|
96
96
|
`;
|
|
@@ -478,7 +478,7 @@ import { Vault } from './vault/vault.js';
|
|
|
478
478
|
const result = patchClaudeMdContent(sampleSource, 'my-agent', ['web-components']);
|
|
479
479
|
expect(result).not.toBeNull();
|
|
480
480
|
|
|
481
|
-
expect(result).toContain('
|
|
481
|
+
expect(result).toContain('my-agent_web_components');
|
|
482
482
|
});
|
|
483
483
|
|
|
484
484
|
it('should handle multiple new domains', () => {
|
|
@@ -564,7 +564,7 @@ import { Vault } from './vault/vault.js';
|
|
|
564
564
|
'utf-8',
|
|
565
565
|
);
|
|
566
566
|
expect(patched).toContain('new-domain patterns');
|
|
567
|
-
expect(patched).toContain('
|
|
567
|
+
expect(patched).toContain('test-agent_new_domain');
|
|
568
568
|
});
|
|
569
569
|
|
|
570
570
|
it('should not patch source files when only updating existing domains', async () => {
|
package/src/patching.ts
CHANGED
|
@@ -109,12 +109,12 @@ export function patchClaudeMdContent(
|
|
|
109
109
|
agentId: string,
|
|
110
110
|
newDomains: string[],
|
|
111
111
|
): string | null {
|
|
112
|
-
const
|
|
112
|
+
const toolPrefix = agentId; // keep hyphens — matches MCP tool registration
|
|
113
113
|
const bt = '`';
|
|
114
114
|
|
|
115
115
|
// Filter out domains whose rows already exist (idempotent)
|
|
116
116
|
const domainsToAdd = newDomains.filter((d) => {
|
|
117
|
-
const toolName = `${
|
|
117
|
+
const toolName = `${toolPrefix}_${d.replace(/-/g, '_')}`;
|
|
118
118
|
return !source.includes(`${toolName}`);
|
|
119
119
|
});
|
|
120
120
|
|
|
@@ -136,7 +136,7 @@ export function patchClaudeMdContent(
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
const newRows = domainsToAdd.flatMap((d) => {
|
|
139
|
-
const toolName = `${
|
|
139
|
+
const toolName = `${toolPrefix}_${d.replace(/-/g, '_')}`;
|
|
140
140
|
return [
|
|
141
141
|
` '| ${d} patterns | ${bt}${toolName}${bt} | ${bt}get_patterns${bt} |',`,
|
|
142
142
|
` '| Search ${d} | ${bt}${toolName}${bt} | ${bt}search${bt} |',`,
|
|
@@ -8,13 +8,13 @@ import type { AgentConfig } from '../types.js';
|
|
|
8
8
|
* Uses array-joined pattern because generated code contains template literals.
|
|
9
9
|
*/
|
|
10
10
|
export function generateActivate(config: AgentConfig): string {
|
|
11
|
-
const
|
|
11
|
+
const toolPrefix = config.id; // keep hyphens — matches MCP tool registration
|
|
12
12
|
const _marker = `${config.id}:mode`;
|
|
13
13
|
|
|
14
14
|
// Build tool recommendations from config domains
|
|
15
15
|
const toolRecLines: string[] = [];
|
|
16
16
|
for (const d of config.domains) {
|
|
17
|
-
const toolName = `${
|
|
17
|
+
const toolName = `${toolPrefix}_${d.replace(/-/g, '_')}`;
|
|
18
18
|
toolRecLines.push(` { intent: 'search ${d}', facade: '${toolName}', op: 'search' },`);
|
|
19
19
|
toolRecLines.push(
|
|
20
20
|
` { intent: '${d} patterns', facade: '${toolName}', op: 'get_patterns' },`,
|
|
@@ -34,7 +34,7 @@ export function generateActivate(config: AgentConfig): string {
|
|
|
34
34
|
"import { join } from 'node:path';",
|
|
35
35
|
"import { homedir } from 'node:os';",
|
|
36
36
|
"import { PERSONA } from '../identity/persona.js';",
|
|
37
|
-
"import { hasAgentMarker } from './inject-claude-md.js';",
|
|
37
|
+
"import { hasAgentMarker, removeClaudeMdGlobal } from './inject-claude-md.js';",
|
|
38
38
|
"import type { Vault, Planner, Plan } from '@soleri/core';",
|
|
39
39
|
'',
|
|
40
40
|
'export interface ActivationResult {',
|
|
@@ -61,6 +61,9 @@ export function generateActivate(config: AgentConfig): string {
|
|
|
61
61
|
'export interface DeactivationResult {',
|
|
62
62
|
' deactivated: boolean;',
|
|
63
63
|
' message: string;',
|
|
64
|
+
' cleanup?: {',
|
|
65
|
+
' globalClaudeMd: boolean;',
|
|
66
|
+
' };',
|
|
64
67
|
'}',
|
|
65
68
|
'',
|
|
66
69
|
'/**',
|
|
@@ -114,9 +117,9 @@ export function generateActivate(config: AgentConfig): string {
|
|
|
114
117
|
guidelineLines,
|
|
115
118
|
' ],',
|
|
116
119
|
' tool_recommendations: [',
|
|
117
|
-
` { intent: 'health check', facade: '${
|
|
118
|
-
` { intent: 'search all', facade: '${
|
|
119
|
-
` { intent: 'vault stats', facade: '${
|
|
120
|
+
` { intent: 'health check', facade: '${toolPrefix}_core', op: 'health' },`,
|
|
121
|
+
` { intent: 'search all', facade: '${toolPrefix}_core', op: 'search' },`,
|
|
122
|
+
` { intent: 'vault stats', facade: '${toolPrefix}_core', op: 'vault_stats' },`,
|
|
120
123
|
...toolRecLines,
|
|
121
124
|
' ],',
|
|
122
125
|
` session_instruction: 'You are now ' + PERSONA.name + ', a ' + PERSONA.role + '. Stay in character for the ENTIRE session. ' +`,
|
|
@@ -133,12 +136,17 @@ export function generateActivate(config: AgentConfig): string {
|
|
|
133
136
|
'}',
|
|
134
137
|
'',
|
|
135
138
|
'/**',
|
|
136
|
-
` * Deactivate ${config.name} — drops persona
|
|
139
|
+
` * Deactivate ${config.name} — drops persona and cleans up CLAUDE.md sections.`,
|
|
137
140
|
' */',
|
|
138
141
|
'export function deactivateAgent(): DeactivationResult {',
|
|
142
|
+
' // Remove agent sections from global CLAUDE.md on deactivation',
|
|
143
|
+
' const globalResult = removeClaudeMdGlobal();',
|
|
139
144
|
' return {',
|
|
140
145
|
' deactivated: true,',
|
|
141
146
|
` message: 'Goodbye! ' + PERSONA.name + ' persona deactivated. Reverting to default behavior.',`,
|
|
147
|
+
' cleanup: {',
|
|
148
|
+
' globalClaudeMd: globalResult.removed,',
|
|
149
|
+
' },',
|
|
142
150
|
' };',
|
|
143
151
|
'}',
|
|
144
152
|
].join('\n');
|
|
@@ -10,7 +10,7 @@ import type { AgentConfig } from '../types.js';
|
|
|
10
10
|
* backtick/template-literal escaping nightmares entirely.
|
|
11
11
|
*/
|
|
12
12
|
export function generateClaudeMdTemplate(config: AgentConfig): string {
|
|
13
|
-
const
|
|
13
|
+
const toolPrefix = config.id; // keep hyphens — matches MCP tool registration
|
|
14
14
|
const marker = `${config.id}:mode`;
|
|
15
15
|
const bt = '`'; // backtick — keeps template clean
|
|
16
16
|
|
|
@@ -22,28 +22,28 @@ export function generateClaudeMdTemplate(config: AgentConfig): string {
|
|
|
22
22
|
'',
|
|
23
23
|
`## ${config.name} Integration`,
|
|
24
24
|
'',
|
|
25
|
-
`**Activate:** "Hello, ${config.name}!" \u2192 ${bt}${
|
|
26
|
-
`**Deactivate:** "Goodbye, ${config.name}!" \u2192 ${bt}${
|
|
25
|
+
`**Activate:** "Hello, ${config.name}!" \u2192 ${bt}${toolPrefix}_core op:activate params:{ projectPath: "." }${bt}`,
|
|
26
|
+
`**Deactivate:** "Goodbye, ${config.name}!" \u2192 ${bt}${toolPrefix}_core op:activate params:{ deactivate: true }${bt}`,
|
|
27
27
|
'',
|
|
28
28
|
'On activation, adopt the returned persona. Stay in character until deactivated.',
|
|
29
29
|
'',
|
|
30
30
|
'## Session Start',
|
|
31
31
|
'',
|
|
32
|
-
`On every new session: ${bt}${
|
|
32
|
+
`On every new session: ${bt}${toolPrefix}_core op:register params:{ projectPath: "." }${bt}`,
|
|
33
33
|
'',
|
|
34
34
|
'## Facades',
|
|
35
35
|
'',
|
|
36
36
|
'| Need | Facade | Op |',
|
|
37
37
|
'|------|--------|----|',
|
|
38
|
-
`| Health check | ${bt}${
|
|
39
|
-
`| Search all | ${bt}${
|
|
40
|
-
`| Vault stats | ${bt}${
|
|
41
|
-
`| Identity | ${bt}${
|
|
38
|
+
`| Health check | ${bt}${toolPrefix}_core${bt} | ${bt}health${bt} |`,
|
|
39
|
+
`| Search all | ${bt}${toolPrefix}_core${bt} | ${bt}search${bt} |`,
|
|
40
|
+
`| Vault stats | ${bt}${toolPrefix}_core${bt} | ${bt}vault_stats${bt} |`,
|
|
41
|
+
`| Identity | ${bt}${toolPrefix}_core${bt} | ${bt}identity${bt} |`,
|
|
42
42
|
];
|
|
43
43
|
|
|
44
44
|
// Domain-specific facade rows
|
|
45
45
|
for (const d of config.domains) {
|
|
46
|
-
const toolName = `${
|
|
46
|
+
const toolName = `${toolPrefix}_${d.replace(/-/g, '_')}`;
|
|
47
47
|
mdLines.push(`| ${d} patterns | ${bt}${toolName}${bt} | ${bt}get_patterns${bt} |`);
|
|
48
48
|
mdLines.push(`| Search ${d} | ${bt}${toolName}${bt} | ${bt}search${bt} |`);
|
|
49
49
|
mdLines.push(`| Capture ${d} | ${bt}${toolName}${bt} | ${bt}capture${bt} |`);
|
|
@@ -51,28 +51,28 @@ export function generateClaudeMdTemplate(config: AgentConfig): string {
|
|
|
51
51
|
|
|
52
52
|
// Memory + Session + Export + Brain + Planning rows
|
|
53
53
|
mdLines.push(
|
|
54
|
-
`| Memory search | ${bt}${
|
|
55
|
-
`| Memory capture | ${bt}${
|
|
56
|
-
`| Memory list | ${bt}${
|
|
57
|
-
`| Session capture | ${bt}${
|
|
58
|
-
`| Export knowledge | ${bt}${
|
|
59
|
-
`| Record feedback | ${bt}${
|
|
60
|
-
`| Rebuild vocabulary | ${bt}${
|
|
61
|
-
`| Brain stats | ${bt}${
|
|
62
|
-
`| LLM status | ${bt}${
|
|
63
|
-
`| Create plan | ${bt}${
|
|
64
|
-
`| Get plan | ${bt}${
|
|
65
|
-
`| Approve plan | ${bt}${
|
|
66
|
-
`| Update task | ${bt}${
|
|
67
|
-
`| Complete plan | ${bt}${
|
|
68
|
-
`| Route intent | ${bt}${
|
|
69
|
-
`| Morph mode | ${bt}${
|
|
70
|
-
`| Get behavior rules | ${bt}${
|
|
71
|
-
`| Get identity | ${bt}${
|
|
72
|
-
`| Update identity | ${bt}${
|
|
73
|
-
`| Add guideline | ${bt}${
|
|
74
|
-
`| Remove guideline | ${bt}${
|
|
75
|
-
`| Rollback identity | ${bt}${
|
|
54
|
+
`| Memory search | ${bt}${toolPrefix}_core${bt} | ${bt}memory_search${bt} |`,
|
|
55
|
+
`| Memory capture | ${bt}${toolPrefix}_core${bt} | ${bt}memory_capture${bt} |`,
|
|
56
|
+
`| Memory list | ${bt}${toolPrefix}_core${bt} | ${bt}memory_list${bt} |`,
|
|
57
|
+
`| Session capture | ${bt}${toolPrefix}_core${bt} | ${bt}session_capture${bt} |`,
|
|
58
|
+
`| Export knowledge | ${bt}${toolPrefix}_core${bt} | ${bt}export${bt} |`,
|
|
59
|
+
`| Record feedback | ${bt}${toolPrefix}_core${bt} | ${bt}record_feedback${bt} |`,
|
|
60
|
+
`| Rebuild vocabulary | ${bt}${toolPrefix}_core${bt} | ${bt}rebuild_vocabulary${bt} |`,
|
|
61
|
+
`| Brain stats | ${bt}${toolPrefix}_core${bt} | ${bt}brain_stats${bt} |`,
|
|
62
|
+
`| LLM status | ${bt}${toolPrefix}_core${bt} | ${bt}llm_status${bt} |`,
|
|
63
|
+
`| Create plan | ${bt}${toolPrefix}_core${bt} | ${bt}create_plan${bt} |`,
|
|
64
|
+
`| Get plan | ${bt}${toolPrefix}_core${bt} | ${bt}get_plan${bt} |`,
|
|
65
|
+
`| Approve plan | ${bt}${toolPrefix}_core${bt} | ${bt}approve_plan${bt} |`,
|
|
66
|
+
`| Update task | ${bt}${toolPrefix}_core${bt} | ${bt}update_task${bt} |`,
|
|
67
|
+
`| Complete plan | ${bt}${toolPrefix}_core${bt} | ${bt}complete_plan${bt} |`,
|
|
68
|
+
`| Route intent | ${bt}${toolPrefix}_core${bt} | ${bt}route_intent${bt} |`,
|
|
69
|
+
`| Morph mode | ${bt}${toolPrefix}_core${bt} | ${bt}morph${bt} |`,
|
|
70
|
+
`| Get behavior rules | ${bt}${toolPrefix}_core${bt} | ${bt}get_behavior_rules${bt} |`,
|
|
71
|
+
`| Get identity | ${bt}${toolPrefix}_core${bt} | ${bt}get_identity${bt} |`,
|
|
72
|
+
`| Update identity | ${bt}${toolPrefix}_core${bt} | ${bt}update_identity${bt} |`,
|
|
73
|
+
`| Add guideline | ${bt}${toolPrefix}_core${bt} | ${bt}add_guideline${bt} |`,
|
|
74
|
+
`| Remove guideline | ${bt}${toolPrefix}_core${bt} | ${bt}remove_guideline${bt} |`,
|
|
75
|
+
`| Rollback identity | ${bt}${toolPrefix}_core${bt} | ${bt}rollback_identity${bt} |`,
|
|
76
76
|
);
|
|
77
77
|
|
|
78
78
|
mdLines.push(
|
|
@@ -82,7 +82,7 @@ export function generateClaudeMdTemplate(config: AgentConfig): string {
|
|
|
82
82
|
'A UserPromptSubmit hook auto-classifies every prompt via keyword matching.',
|
|
83
83
|
`When you see a ${bt}[MODE-NAME]${bt} indicator in the system context:`,
|
|
84
84
|
'',
|
|
85
|
-
`1. Call ${bt}${
|
|
85
|
+
`1. Call ${bt}${toolPrefix}_core op:route_intent params:{ prompt: "<user message>" }${bt} to get full behavior rules`,
|
|
86
86
|
'2. Follow the returned behavior rules for the detected mode',
|
|
87
87
|
'3. Briefly acknowledge mode changes in your response (e.g., "Switching to FIX-MODE")',
|
|
88
88
|
'',
|
|
@@ -103,7 +103,7 @@ export function generateClaudeMdTemplate(config: AgentConfig): string {
|
|
|
103
103
|
'',
|
|
104
104
|
'When seeking guidance: vault before codebase before web.',
|
|
105
105
|
'',
|
|
106
|
-
`1. Search vault \u2014 ${bt}${
|
|
106
|
+
`1. Search vault \u2014 ${bt}${toolPrefix}_core op:search${bt}`,
|
|
107
107
|
'2. Codebase \u2014 only if vault has nothing',
|
|
108
108
|
'3. Web \u2014 last resort',
|
|
109
109
|
'',
|
|
@@ -115,15 +115,15 @@ export function generateClaudeMdTemplate(config: AgentConfig): string {
|
|
|
115
115
|
'',
|
|
116
116
|
'A PreCompact hook is configured to call `session_capture` before context compaction.',
|
|
117
117
|
'This automatically preserves session summaries as memories for future sessions.',
|
|
118
|
-
`To manually capture: ${bt}${
|
|
118
|
+
`To manually capture: ${bt}${toolPrefix}_core op:session_capture params:{ summary: "..." }${bt}`,
|
|
119
119
|
'',
|
|
120
120
|
'## Planning',
|
|
121
121
|
'',
|
|
122
122
|
'For multi-step tasks, use the planning system:',
|
|
123
|
-
`1. Create: ${bt}${
|
|
124
|
-
`2. Approve: ${bt}${
|
|
125
|
-
`3. Track: ${bt}${
|
|
126
|
-
`4. Complete: ${bt}${
|
|
123
|
+
`1. Create: ${bt}${toolPrefix}_core op:create_plan params:{ objective: "...", scope: "...", tasks: [...] }${bt}`,
|
|
124
|
+
`2. Approve: ${bt}${toolPrefix}_core op:approve_plan params:{ planId: "...", startExecution: true }${bt}`,
|
|
125
|
+
`3. Track: ${bt}${toolPrefix}_core op:update_task params:{ planId: "...", taskId: "...", status: "completed" }${bt}`,
|
|
126
|
+
`4. Complete: ${bt}${toolPrefix}_core op:complete_plan params:{ planId: "..." }${bt}`,
|
|
127
127
|
'',
|
|
128
128
|
'Check activation response for recovered plans in `executing` state — remind the user.',
|
|
129
129
|
'',
|
|
@@ -83,6 +83,42 @@ export function generateInjectClaudeMd(config: AgentConfig): string {
|
|
|
83
83
|
'}',
|
|
84
84
|
'',
|
|
85
85
|
'/**',
|
|
86
|
+
' * Remove agent section from a specific CLAUDE.md file.',
|
|
87
|
+
' * Returns true if the section was found and removed.',
|
|
88
|
+
' */',
|
|
89
|
+
'function removeFromFile(filePath: string): { removed: boolean; path: string } {',
|
|
90
|
+
' if (!existsSync(filePath)) return { removed: false, path: filePath };',
|
|
91
|
+
" const existing = readFileSync(filePath, 'utf-8');",
|
|
92
|
+
' const marker = getClaudeMdMarker();',
|
|
93
|
+
` const startMarker = '<!-- ' + marker + ' -->';`,
|
|
94
|
+
` const endMarker = '<!-- /' + marker + ' -->';`,
|
|
95
|
+
' const startIdx = existing.indexOf(startMarker);',
|
|
96
|
+
' if (startIdx === -1) return { removed: false, path: filePath };',
|
|
97
|
+
' const endIdx = existing.indexOf(endMarker);',
|
|
98
|
+
' if (endIdx === -1) return { removed: false, path: filePath };',
|
|
99
|
+
" const before = existing.slice(0, startIdx).replace(/\\n+$/, '');",
|
|
100
|
+
" const after = existing.slice(endIdx + endMarker.length).replace(/^\\n+/, '');",
|
|
101
|
+
" const cleaned = before + (before && after ? '\\n\\n' : '') + after;",
|
|
102
|
+
" writeFileSync(filePath, cleaned || '', 'utf-8');",
|
|
103
|
+
' return { removed: true, path: filePath };',
|
|
104
|
+
'}',
|
|
105
|
+
'',
|
|
106
|
+
'/**',
|
|
107
|
+
' * Remove agent section from the global ~/.claude/CLAUDE.md.',
|
|
108
|
+
' * Called on deactivation to clean up after test agents.',
|
|
109
|
+
' */',
|
|
110
|
+
'export function removeClaudeMdGlobal(): { removed: boolean; path: string } {',
|
|
111
|
+
" return removeFromFile(join(homedir(), '.claude', 'CLAUDE.md'));",
|
|
112
|
+
'}',
|
|
113
|
+
'',
|
|
114
|
+
'/**',
|
|
115
|
+
' * Remove agent section from a project CLAUDE.md.',
|
|
116
|
+
' */',
|
|
117
|
+
'export function removeClaudeMd(projectPath: string): { removed: boolean; path: string } {',
|
|
118
|
+
" return removeFromFile(join(projectPath, 'CLAUDE.md'));",
|
|
119
|
+
'}',
|
|
120
|
+
'',
|
|
121
|
+
'/**',
|
|
86
122
|
' * Check if the agent marker exists in a CLAUDE.md file.',
|
|
87
123
|
' */',
|
|
88
124
|
'export function hasAgentMarker(filePath: string): boolean {',
|
|
@@ -74,7 +74,7 @@ if [ ! -f "$SETTINGS_FILE" ]; then
|
|
|
74
74
|
"PreCompact": [
|
|
75
75
|
{
|
|
76
76
|
"type": "prompt",
|
|
77
|
-
"prompt": "Before context is compacted, capture a session summary by calling ${config.id
|
|
77
|
+
"prompt": "Before context is compacted, capture a session summary by calling ${config.id}_core op:session_capture with a brief summary of what was accomplished, the topics covered, files modified, and tools used."
|
|
78
78
|
}
|
|
79
79
|
]
|
|
80
80
|
}
|
|
@@ -93,7 +93,7 @@ else
|
|
|
93
93
|
if (!settings.hooks.PreCompact) settings.hooks.PreCompact = [];
|
|
94
94
|
settings.hooks.PreCompact.push({
|
|
95
95
|
type: 'prompt',
|
|
96
|
-
prompt: 'Before context is compacted, capture a session summary by calling ${config.id
|
|
96
|
+
prompt: 'Before context is compacted, capture a session summary by calling ${config.id}_core op:session_capture with a brief summary of what was accomplished, the topics covered, files modified, and tools used.'
|
|
97
97
|
});
|
|
98
98
|
fs.writeFileSync('$SETTINGS_FILE', JSON.stringify(settings, null, 2) + '\\n');
|
|
99
99
|
"
|