@soleri/forge 5.13.1 → 5.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/index.js +0 -0
  2. package/dist/lib.d.ts +1 -0
  3. package/dist/lib.js +1 -0
  4. package/dist/lib.js.map +1 -1
  5. package/dist/skills/brain-debrief.md +47 -19
  6. package/dist/skills/brainstorming.md +19 -9
  7. package/dist/skills/code-patrol.md +21 -19
  8. package/dist/skills/context-resume.md +14 -11
  9. package/dist/skills/executing-plans.md +30 -15
  10. package/dist/skills/fix-and-learn.md +17 -14
  11. package/dist/skills/health-check.md +29 -23
  12. package/dist/skills/knowledge-harvest.md +27 -20
  13. package/dist/skills/onboard-me.md +16 -15
  14. package/dist/skills/retrospective.md +34 -18
  15. package/dist/skills/second-opinion.md +16 -9
  16. package/dist/skills/systematic-debugging.md +40 -29
  17. package/dist/skills/test-driven-development.md +45 -30
  18. package/dist/skills/vault-capture.md +31 -15
  19. package/dist/skills/vault-navigator.md +24 -13
  20. package/dist/skills/verification-before-completion.md +38 -26
  21. package/dist/skills/writing-plans.md +21 -13
  22. package/dist/templates/claude-md-template.d.ts +9 -8
  23. package/dist/templates/claude-md-template.js +36 -32
  24. package/dist/templates/claude-md-template.js.map +1 -1
  25. package/dist/templates/inject-claude-md.js +65 -25
  26. package/dist/templates/inject-claude-md.js.map +1 -1
  27. package/dist/templates/shared-rules.d.ts +10 -11
  28. package/dist/templates/shared-rules.js +242 -114
  29. package/dist/templates/shared-rules.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/lib.ts +1 -0
  32. package/src/templates/claude-md-template.ts +49 -77
  33. package/src/templates/inject-claude-md.ts +65 -25
  34. package/src/templates/shared-rules.ts +259 -121
  35. package/dist/skills/skills/brain-debrief.md +0 -214
  36. package/dist/skills/skills/brainstorming.md +0 -180
  37. package/dist/skills/skills/code-patrol.md +0 -178
  38. package/dist/skills/skills/context-resume.md +0 -146
  39. package/dist/skills/skills/executing-plans.md +0 -216
  40. package/dist/skills/skills/fix-and-learn.md +0 -167
  41. package/dist/skills/skills/health-check.md +0 -231
  42. package/dist/skills/skills/knowledge-harvest.md +0 -185
  43. package/dist/skills/skills/onboard-me.md +0 -198
  44. package/dist/skills/skills/retrospective.md +0 -205
  45. package/dist/skills/skills/second-opinion.md +0 -149
  46. package/dist/skills/skills/systematic-debugging.md +0 -241
  47. package/dist/skills/skills/test-driven-development.md +0 -281
  48. package/dist/skills/skills/vault-capture.md +0 -170
  49. package/dist/skills/skills/vault-navigator.md +0 -140
  50. package/dist/skills/skills/verification-before-completion.md +0 -182
  51. package/dist/skills/skills/writing-plans.md +0 -215
  52. package/dist/templates/brain.d.ts +0 -6
  53. package/dist/templates/brain.js +0 -478
  54. package/dist/templates/brain.js.map +0 -1
  55. package/dist/templates/core-facade.d.ts +0 -6
  56. package/dist/templates/core-facade.js +0 -564
  57. package/dist/templates/core-facade.js.map +0 -1
  58. package/dist/templates/facade-factory.d.ts +0 -1
  59. package/dist/templates/facade-factory.js +0 -63
  60. package/dist/templates/facade-factory.js.map +0 -1
  61. package/dist/templates/facade-types.d.ts +0 -1
  62. package/dist/templates/facade-types.js +0 -46
  63. package/dist/templates/facade-types.js.map +0 -1
  64. package/dist/templates/intelligence-loader.d.ts +0 -1
  65. package/dist/templates/intelligence-loader.js +0 -43
  66. package/dist/templates/intelligence-loader.js.map +0 -1
  67. package/dist/templates/intelligence-types.d.ts +0 -1
  68. package/dist/templates/intelligence-types.js +0 -24
  69. package/dist/templates/intelligence-types.js.map +0 -1
  70. package/dist/templates/llm-client.d.ts +0 -7
  71. package/dist/templates/llm-client.js +0 -300
  72. package/dist/templates/llm-client.js.map +0 -1
  73. package/dist/templates/llm-key-pool.d.ts +0 -7
  74. package/dist/templates/llm-key-pool.js +0 -211
  75. package/dist/templates/llm-key-pool.js.map +0 -1
  76. package/dist/templates/llm-types.d.ts +0 -5
  77. package/dist/templates/llm-types.js +0 -161
  78. package/dist/templates/llm-types.js.map +0 -1
  79. package/dist/templates/llm-utils.d.ts +0 -5
  80. package/dist/templates/llm-utils.js +0 -260
  81. package/dist/templates/llm-utils.js.map +0 -1
  82. package/dist/templates/planner.d.ts +0 -5
  83. package/dist/templates/planner.js +0 -150
  84. package/dist/templates/planner.js.map +0 -1
  85. package/dist/templates/test-brain.d.ts +0 -6
  86. package/dist/templates/test-brain.js +0 -474
  87. package/dist/templates/test-brain.js.map +0 -1
  88. package/dist/templates/test-llm.d.ts +0 -7
  89. package/dist/templates/test-llm.js +0 -574
  90. package/dist/templates/test-llm.js.map +0 -1
  91. package/dist/templates/test-loader.d.ts +0 -5
  92. package/dist/templates/test-loader.js +0 -146
  93. package/dist/templates/test-loader.js.map +0 -1
  94. package/dist/templates/test-planner.d.ts +0 -5
  95. package/dist/templates/test-planner.js +0 -271
  96. package/dist/templates/test-planner.js.map +0 -1
  97. package/dist/templates/test-vault.d.ts +0 -5
  98. package/dist/templates/test-vault.js +0 -380
  99. package/dist/templates/test-vault.js.map +0 -1
  100. package/dist/templates/vault.d.ts +0 -5
  101. package/dist/templates/vault.js +0 -263
  102. package/dist/templates/vault.js.map +0 -1
@@ -16,27 +16,27 @@ export function generateInjectClaudeMd(config: AgentConfig): string {
16
16
  "import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';",
17
17
  "import { homedir } from 'node:os';",
18
18
  "import { join } from 'node:path';",
19
- "import { getClaudeMdContent, getClaudeMdMarker } from './claude-md-content.js';",
19
+ "import { getClaudeMdContent, getClaudeMdMarker, getEngineRulesContent, getEngineRulesMarker } from './claude-md-content.js';",
20
20
  '',
21
21
  'export interface InjectResult {',
22
22
  ' injected: boolean;',
23
23
  ' path: string;',
24
24
  " action: 'created' | 'updated' | 'appended';",
25
+ ' engineRules?: boolean;',
25
26
  '}',
26
27
  '',
27
28
  '/**',
28
- ' * Inject into a specific CLAUDE.md file path.',
29
- ' * Shared logic for both project-level and global injection.',
29
+ ' * Inject a marker-delimited block into a file.',
30
+ ' * If the marker already exists, replaces the content between markers.',
31
+ ' * Otherwise appends (or creates the file).',
30
32
  ' */',
31
- 'function injectIntoFile(filePath: string): InjectResult {',
32
- ' const content = getClaudeMdContent();',
33
- ' const marker = getClaudeMdMarker();',
33
+ "function injectBlock(filePath: string, content: string, marker: string): 'created' | 'updated' | 'appended' | 'skipped' {",
34
34
  ` const startMarker = '<!-- ' + marker + ' -->';`,
35
35
  ` const endMarker = '<!-- /' + marker + ' -->';`,
36
36
  '',
37
37
  ' if (!existsSync(filePath)) {',
38
38
  " writeFileSync(filePath, content + '\\n', 'utf-8');",
39
- " return { injected: true, path: filePath, action: 'created' };",
39
+ " return 'created';",
40
40
  ' }',
41
41
  '',
42
42
  " const existing = readFileSync(filePath, 'utf-8');",
@@ -47,30 +47,52 @@ export function generateInjectClaudeMd(config: AgentConfig): string {
47
47
  ' if (endIdx === -1) {',
48
48
  " const updated = existing.slice(0, startIdx) + content + '\\n' + existing.slice(startIdx + startMarker.length);",
49
49
  " writeFileSync(filePath, updated, 'utf-8');",
50
- " return { injected: true, path: filePath, action: 'updated' };",
50
+ " return 'updated';",
51
51
  ' }',
52
52
  ' const updated = existing.slice(0, startIdx) + content + existing.slice(endIdx + endMarker.length);',
53
53
  " writeFileSync(filePath, updated, 'utf-8');",
54
- " return { injected: true, path: filePath, action: 'updated' };",
54
+ " return 'updated';",
55
55
  ' }',
56
56
  '',
57
57
  " const separator = existing.endsWith('\\n') ? '\\n' : '\\n\\n';",
58
58
  " writeFileSync(filePath, existing + separator + content + '\\n', 'utf-8');",
59
- " return { injected: true, path: filePath, action: 'appended' };",
59
+ " return 'appended';",
60
+ '}',
61
+ '',
62
+ '/**',
63
+ ' * Inject engine rules + agent block into a CLAUDE.md file.',
64
+ ' *',
65
+ ' * Engine rules (shared, prefix-free) are injected ONCE under',
66
+ ' * `<!-- soleri:engine-rules -->`. If already present, they are updated.',
67
+ ' * Agent block (identity + facade table) is injected under',
68
+ ` * \`<!-- ${marker} -->\`.`,
69
+ ' */',
70
+ 'function injectIntoFile(filePath: string): InjectResult {',
71
+ ' // Step 1: Engine rules — shared across all agents',
72
+ ' const engineAction = injectBlock(filePath, getEngineRulesContent(), getEngineRulesMarker());',
73
+ '',
74
+ ' // Step 2: Agent-specific block',
75
+ ' const agentAction = injectBlock(filePath, getClaudeMdContent(), getClaudeMdMarker());',
76
+ '',
77
+ ' return {',
78
+ ' injected: true,',
79
+ ' path: filePath,',
80
+ " action: agentAction === 'skipped' ? 'appended' : agentAction,",
81
+ " engineRules: engineAction !== 'skipped',",
82
+ ' };',
60
83
  '}',
61
84
  '',
62
85
  '/**',
63
86
  ' * Inject agent CLAUDE.md section into a project.',
64
- ' * - If no CLAUDE.md exists: creates one',
65
- ' * - If markers found: replaces content between them (update)',
66
- ' * - If no markers: appends section to end',
87
+ ' * - Engine rules: injected once, updated if already present',
88
+ ' * - Agent block: created, updated, or appended',
67
89
  ' */',
68
90
  'export function injectClaudeMd(projectPath: string): InjectResult {',
69
91
  " return injectIntoFile(join(projectPath, 'CLAUDE.md'));",
70
92
  '}',
71
93
  '',
72
94
  '/**',
73
- ' * Inject agent CLAUDE.md section into the global ~/.claude/CLAUDE.md.',
95
+ ' * Inject into the global ~/.claude/CLAUDE.md.',
74
96
  " * Creates ~/.claude/ directory if it doesn't exist.",
75
97
  ' * This makes the activation phrase work in any project.',
76
98
  ' */',
@@ -83,39 +105,48 @@ export function generateInjectClaudeMd(config: AgentConfig): string {
83
105
  '}',
84
106
  '',
85
107
  '/**',
86
- ' * Remove agent section from a specific CLAUDE.md file.',
87
- ' * Returns true if the section was found and removed.',
108
+ ' * Remove a marker-delimited block from a file.',
88
109
  ' */',
89
- 'function removeFromFile(filePath: string): { removed: boolean; path: string } {',
90
- ' if (!existsSync(filePath)) return { removed: false, path: filePath };',
110
+ 'function removeBlock(filePath: string, marker: string): boolean {',
111
+ ' if (!existsSync(filePath)) return false;',
91
112
  " const existing = readFileSync(filePath, 'utf-8');",
92
- ' const marker = getClaudeMdMarker();',
93
113
  ` const startMarker = '<!-- ' + marker + ' -->';`,
94
114
  ` const endMarker = '<!-- /' + marker + ' -->';`,
95
115
  ' const startIdx = existing.indexOf(startMarker);',
96
- ' if (startIdx === -1) return { removed: false, path: filePath };',
116
+ ' if (startIdx === -1) return false;',
97
117
  ' const endIdx = existing.indexOf(endMarker);',
98
- ' if (endIdx === -1) return { removed: false, path: filePath };',
118
+ ' if (endIdx === -1) return false;',
99
119
  " const before = existing.slice(0, startIdx).replace(/\\n+$/, '');",
100
120
  " const after = existing.slice(endIdx + endMarker.length).replace(/^\\n+/, '');",
101
121
  " const cleaned = before + (before && after ? '\\n\\n' : '') + after;",
102
122
  " writeFileSync(filePath, cleaned || '', 'utf-8');",
103
- ' return { removed: true, path: filePath };',
123
+ ' return true;',
104
124
  '}',
105
125
  '',
106
126
  '/**',
107
127
  ' * Remove agent section from the global ~/.claude/CLAUDE.md.',
108
- ' * Called on deactivation to clean up after test agents.',
128
+ ' * Only removes the agent block, NOT the shared engine rules',
129
+ ' * (other agents may depend on them).',
109
130
  ' */',
110
131
  'export function removeClaudeMdGlobal(): { removed: boolean; path: string } {',
111
- " return removeFromFile(join(homedir(), '.claude', 'CLAUDE.md'));",
132
+ " const filePath = join(homedir(), '.claude', 'CLAUDE.md');",
133
+ ' return { removed: removeBlock(filePath, getClaudeMdMarker()), path: filePath };',
112
134
  '}',
113
135
  '',
114
136
  '/**',
115
137
  ' * Remove agent section from a project CLAUDE.md.',
116
138
  ' */',
117
139
  'export function removeClaudeMd(projectPath: string): { removed: boolean; path: string } {',
118
- " return removeFromFile(join(projectPath, 'CLAUDE.md'));",
140
+ " const filePath = join(projectPath, 'CLAUDE.md');",
141
+ ' return { removed: removeBlock(filePath, getClaudeMdMarker()), path: filePath };',
142
+ '}',
143
+ '',
144
+ '/**',
145
+ ' * Remove shared engine rules from a file.',
146
+ ' * Use only when NO agents remain in the file.',
147
+ ' */',
148
+ 'export function removeEngineRules(filePath: string): boolean {',
149
+ ' return removeBlock(filePath, getEngineRulesMarker());',
119
150
  '}',
120
151
  '',
121
152
  '/**',
@@ -126,5 +157,14 @@ export function generateInjectClaudeMd(config: AgentConfig): string {
126
157
  " const content = readFileSync(filePath, 'utf-8');",
127
158
  ` return content.includes('<!-- ${marker} -->');`,
128
159
  '}',
160
+ '',
161
+ '/**',
162
+ ' * Check if engine rules are already present in a CLAUDE.md file.',
163
+ ' */',
164
+ 'export function hasEngineRules(filePath: string): boolean {',
165
+ ' if (!existsSync(filePath)) return false;',
166
+ " const content = readFileSync(filePath, 'utf-8');",
167
+ " return content.includes('<!-- ' + getEngineRulesMarker() + ' -->');",
168
+ '}',
129
169
  ].join('\n');
130
170
  }
@@ -1,126 +1,264 @@
1
1
  /**
2
- * Shared behavioral rules that every Soleri agent ships with.
2
+ * Shared Soleri engine rules agent-agnostic.
3
3
  *
4
- * These rules are agent-agnostic and mirror the quality of Salvador's
5
- * hand-crafted CLAUDE.md behavioral sections. They cover:
6
- * - Vault-first knowledge protocol
7
- * - Planning enforcement (two-gate approval)
8
- * - Output formatting (plan metadata tables, drift reports)
9
- * - Knowledge capture discipline
10
- * - Intent routing
11
- * - Session lifecycle
4
+ * These rules are injected ONCE into global ~/.claude/CLAUDE.md under
5
+ * the `<!-- soleri:engine-rules -->` marker. They describe behavioral
6
+ * rules WITHOUT tool prefixes. The active agent's facade table (in its
7
+ * own `<!-- agent-id:mode -->` block) maps op names to actual tools.
8
+ *
9
+ * Uses op:name syntax — the active agent provides the tool prefix.
12
10
  */
13
11
 
14
- /** Returns markdown lines for all shared behavioral sections. */
15
- export function getSharedRules(toolPrefix: string): string[] {
16
- const bt = '`';
17
-
18
- return [
19
- // ─── Vault-First Protocol ────────────────────────────────
20
- '## Vault as Source of Truth',
21
- '',
22
- 'Before every decision — planning, design, architecture, problem-solving — consult the vault.',
23
- '',
24
- '**Lookup order:**',
25
- `1. Vault — ${bt}${toolPrefix}_core op:search_intelligent params:{ query: "..." }${bt}`,
26
- '2. Codebase — only if vault has nothing',
27
- '3. Web / training knowledge — last resort',
28
- '',
29
- 'If the vault has a pattern, follow it. If it has an anti-pattern, avoid it.',
30
- '',
31
-
32
- // ─── Planning Enforcement ────────────────────────────────
33
- '## Planning',
34
- '',
35
- 'For multi-step tasks, use the planning system. **Never skip gates.**',
36
- '',
37
- '**Lifecycle:**',
38
- `${bt}draft → approved (Gate 1) → tasks approved (Gate 2) → executing → reconciling → completed${bt}`,
39
- '',
40
- '**Sequence:**',
41
- `1. Create: ${bt}${toolPrefix}_core op:create_plan params:{ objective: "...", scope: "...", tasks: [...] }${bt}`,
42
- `2. Approve plan (Gate 1): ${bt}${toolPrefix}_core op:approve_plan params:{ planId: "..." }${bt}`,
43
- `3. Split tasks (Gate 2): ${bt}${toolPrefix}_core op:plan_split params:{ planId: "..." }${bt}`,
44
- `4. Track: ${bt}${toolPrefix}_core op:update_task params:{ planId: "...", taskId: "...", status: "completed" }${bt}`,
45
- `5. Reconcile: ${bt}${toolPrefix}_core op:plan_reconcile params:{ planId: "..." }${bt}`,
46
- `6. Complete: ${bt}${toolPrefix}_core op:plan_complete_lifecycle params:{ planId: "..." }${bt}`,
47
- '',
48
- 'Wait for explicit user approval before proceeding past each gate.',
49
- 'Check activation response for recovered plans in `executing` state — remind the user.',
50
- '',
51
- '**Exceptions:** Read-only operations, user says "just do it", single-line fixes.',
52
- '',
53
-
54
- // ─── Output Formatting ───────────────────────────────────
55
- '## Output Formatting',
56
- '',
57
- '**Plan metadata** — always show at top of every plan summary:',
58
- '',
59
- '| Field | Value |',
60
- '|-------|-------|',
61
- '| **Plan ID** | {planId} |',
62
- '| **Check ID** | {checkId} |',
63
- '| **Grade** | {grade} ({score}/100) |',
64
- '| **Status** | {status} |',
65
- '',
66
- '**Drift reports:**',
67
- '',
68
- '| Field | Value |',
69
- '|-------|-------|',
70
- '| **Accuracy** | {accuracyScore}/100 |',
71
- '| **Drift Items** | {count} |',
72
- '',
73
- '| Type | Description | Impact |',
74
- '|------|-------------|--------|',
75
- '| skipped | ... | medium |',
76
- '',
77
-
78
- // ─── Knowledge Capture ───────────────────────────────────
79
- '## Knowledge Capture',
80
- '',
81
- "When learning something that should persist, capture it — don't just promise to remember.",
82
- '',
83
- `- Domain knowledge: ${bt}${toolPrefix}_core op:capture_quick params:{ title: "...", description: "..." }${bt}`,
84
- `- Batch capture: ${bt}${toolPrefix}_core op:capture_knowledge params:{ entries: [...] }${bt}`,
85
- `- Intelligent search: ${bt}${toolPrefix}_core op:search_intelligent params:{ query: "..." }${bt}`,
86
- '',
87
-
88
- // ─── Intent Detection ────────────────────────────────────
89
- '## Intent Detection',
90
- '',
91
- 'A UserPromptSubmit hook auto-classifies prompts. When you see a `[MODE-NAME]` indicator:',
92
- '',
93
- `1. Call ${bt}${toolPrefix}_core op:route_intent params:{ prompt: "<user message>" }${bt}`,
94
- '2. Follow the returned behavior rules',
95
- '3. Briefly acknowledge mode changes',
96
- '',
97
- '| Signal | Intent |',
98
- '|--------|--------|',
99
- '| Problem described ("broken", "janky", "weird") | FIX |',
100
- '| Need expressed ("I need", "we should have") | BUILD |',
101
- '| Quality questioned ("is this right?") | REVIEW |',
102
- '| Advice sought ("how should I", "best way") | PLAN |',
103
- '| Improvement requested ("make it faster") | IMPROVE |',
104
- '| Ready to ship ("deploy", "release") | DELIVER |',
105
- '',
106
-
107
- // ─── Session Lifecycle ───────────────────────────────────
108
- '## Session Lifecycle',
109
- '',
110
- 'A PreCompact hook calls `session_capture` before context compaction.',
111
- `Manual capture: ${bt}${toolPrefix}_core op:session_capture params:{ summary: "..." }${bt}`,
112
- '',
113
-
114
- // ─── Orchestration ───────────────────────────────────────
115
- '## Orchestration',
116
- '',
117
- 'For complex workflows, use the orchestration layer instead of manual planning:',
118
- '',
119
- `1. Plan: ${bt}${toolPrefix}_core op:orchestrate_plan params:{ prompt: "...", projectPath: "." }${bt}`,
120
- `2. Execute: ${bt}${toolPrefix}_core op:orchestrate_execute params:{ planId: "..." }${bt}`,
121
- `3. Complete: ${bt}${toolPrefix}_core op:orchestrate_complete params:{ planId: "..." }${bt}`,
122
- '',
123
- 'The orchestrator handles vault lookup, brain recommendations, and knowledge capture automatically.',
124
- '',
125
- ];
12
+ const ENGINE_MARKER = 'soleri:engine-rules';
13
+
14
+ export function getEngineMarker(): string {
15
+ return ENGINE_MARKER;
126
16
  }
17
+
18
+ /** Returns the full engine rules markdown content (with markers). */
19
+ export function getEngineRulesContent(): string {
20
+ return ENGINE_RULES_LINES.join('\n');
21
+ }
22
+
23
+ const ENGINE_RULES_LINES: string[] = [
24
+ `<!-- ${ENGINE_MARKER} -->`,
25
+ '',
26
+ '# Soleri Engine Rules',
27
+ '',
28
+ "Shared behavioral rules for all Soleri agents. The active agent's facade table provides tool names.",
29
+ '',
30
+
31
+ // ─── Response Integrity ─────────────────────────────────
32
+ '## Response Integrity',
33
+ '<!-- soleri:response-integrity -->',
34
+ '',
35
+ '- If you\'re not confident in your answer, say "I\'m not sure" and explain why. Never guess.',
36
+ '- After every response, rate your confidence from 1 to 10. Anything below 7, flag it.',
37
+ '',
38
+
39
+ // ─── Memory Quality Gate ───────────────────────────────
40
+ '## Memory Quality Gate',
41
+ '<!-- soleri:memory-quality -->',
42
+ '',
43
+ '**MANDATORY** before writing to auto memory: apply the **"Will I hit this again?"** test.',
44
+ '',
45
+ '**SAVE** — recurring bugs, non-obvious gotchas, structural issues, behavioral quirks that will resurface.',
46
+ "**NEVER SAVE** — one-time config, solved-and-done fixes, values already persisted in files, setup steps that won't repeat, anything where the fix is already in the codebase.",
47
+ '',
48
+ "If in doubt, don't save. Less memory with high signal beats more memory with noise.",
49
+ '',
50
+
51
+ // ─── Vault-First Protocol ────────────────────────────────
52
+ '## Vault as Source of Truth',
53
+ '<!-- soleri:vault-protocol -->',
54
+ '',
55
+ '- **MANDATORY**: Consult the vault BEFORE every decision — planning, design, architecture, patterns, problem-solving.',
56
+ '- Lookup order: 1) VAULT (`op:search_intelligent`) → 2) MEMORY (`op:memory_search`) → 3) CODEBASE → 4) WEB/TRAINING.',
57
+ '- If the vault has a pattern, follow it. If it has an anti-pattern, avoid it.',
58
+ '- Persist lessons: call `op:capture_knowledge` — don\'t just promise "I will remember this".',
59
+ '- Exceptions: runtime errors with stack traces → codebase first; user explicitly asks to search web.',
60
+ '',
61
+
62
+ // ─── Planning ────────────────────────────────────────────
63
+ '## Planning',
64
+ '<!-- soleri:planning -->',
65
+ '',
66
+ '- Use `op:create_plan` before writing ANY code. Show the plan, wait for approval.',
67
+ '- Two-gate approval: Gate 1 (`op:approve_plan`), Gate 2 (`op:plan_split`). Never skip either.',
68
+ '- Wait for explicit "yes" / "approve" before proceeding past each gate.',
69
+ '- After execution: `op:plan_reconcile` (drift report) then `op:plan_complete_lifecycle` (knowledge capture, archive).',
70
+ '- Never let a plan stay in `executing` or `reconciling` state without reminding the user.',
71
+ '- On session start: check for plans in `executing`/`reconciling` state and remind.',
72
+ '- Exceptions: read-only operations, user says "just do it", single-line fixes.',
73
+ '',
74
+ '### Lifecycle States',
75
+ '',
76
+ '| State | Expires | Next Action |',
77
+ '|-------|---------|-------------|',
78
+ '| `draft` | 30 min | `op:create_plan` (iterate) |',
79
+ '| `approved` | 30 min | `op:plan_split` |',
80
+ '| `executing` | Never | `op:plan_reconcile` |',
81
+ '| `reconciling` | Never | `op:plan_complete_lifecycle` |',
82
+ '| `completed` | — | Done |',
83
+ '',
84
+ '### Plan Presentation',
85
+ '',
86
+ 'Every plan summary MUST include this format:',
87
+ '',
88
+ '```',
89
+ '## Plan: [Short Title]',
90
+ '',
91
+ '| Field | Value |',
92
+ '|-------|-------|',
93
+ '| **Plan ID** | {planId} |',
94
+ '| **Check ID** | {checkId} |',
95
+ '| **Grade** | {grade} ({score}/100) |',
96
+ '| **Status** | {status} |',
97
+ '| **Lifecycle** | {lifecycleStatus} |',
98
+ '',
99
+ '**Objective:** [One sentence]',
100
+ '',
101
+ '**Scope:**',
102
+ '| Included | Excluded |',
103
+ '|----------|----------|',
104
+ '| item 1 | item 1 |',
105
+ '',
106
+ '**Approach:**',
107
+ '| Step | Task |',
108
+ '|------|------|',
109
+ '| 1 | Description |',
110
+ '```',
111
+ '',
112
+ 'Without visible IDs, users cannot resume, reference, or approve plans.',
113
+ '',
114
+ '### Drift Report',
115
+ '',
116
+ '```',
117
+ '| Field | Value |',
118
+ '|-------|-------|',
119
+ '| **Accuracy** | {accuracyScore}/100 |',
120
+ '| **Drift Items** | {count} |',
121
+ '',
122
+ '| Type | Description | Impact | Rationale |',
123
+ '|------|-------------|--------|-----------|',
124
+ '| skipped | ... | medium | ... |',
125
+ '```',
126
+ '',
127
+
128
+ // ─── Output Formatting ───────────────────────────────────
129
+ '## Output Formatting',
130
+ '<!-- soleri:output-formatting -->',
131
+ '',
132
+ '**MANDATORY**: Present tool outputs in human-readable format, NOT raw JSON.',
133
+ '',
134
+ '**Tasks** — show as numbered table:',
135
+ '```',
136
+ '| # | Type | Task | Complexity |',
137
+ '|---|------|------|------------|',
138
+ '| 1 | Impl | ... | High |',
139
+ '```',
140
+ '',
141
+ '**Completion** — show outcome, knowledge captured count, archive path.',
142
+ '',
143
+ '**Status lines** — `Persisted: X plans, Y tasks, Z checks` / `Recovered: X plans, Y tasks`',
144
+ '',
145
+
146
+ // ─── Clean Commits ───────────────────────────────────────
147
+ '## Clean Commits',
148
+ '<!-- soleri:clean-commits -->',
149
+ '',
150
+ '**MANDATORY**: No AI attribution in commit messages.',
151
+ '',
152
+ 'Blocked patterns:',
153
+ '- `Co-Authored-By: Claude` (any variant)',
154
+ '- `noreply@anthropic.com`',
155
+ '- `Generated with Claude`, `AI-generated`',
156
+ '- Any mention of `Anthropic`, `Claude Opus`, `Claude Sonnet`, `Claude Haiku`',
157
+ '',
158
+ 'Use conventional commits:',
159
+ '```',
160
+ 'feat: add user authentication',
161
+ 'fix: resolve login timeout issue',
162
+ 'refactor: simplify data fetching logic',
163
+ '```',
164
+ '',
165
+
166
+ // ─── Knowledge Capture ───────────────────────────────────
167
+ '## Knowledge Capture',
168
+ '<!-- soleri:knowledge-capture -->',
169
+ '',
170
+ "**MANDATORY**: Persist lessons, don't just promise them.",
171
+ '',
172
+ 'When you learn something that should persist:',
173
+ '1. **DON\'T** just say "I will remember this"',
174
+ '2. **DO** call `op:capture_knowledge` to persist to vault',
175
+ "3. **DO** update relevant files if it's a behavioral change",
176
+ '',
177
+ '| Type | Op | Persists To |',
178
+ '|------|-----|-------------|',
179
+ '| Patterns/Anti-patterns | `op:capture_knowledge` | vault |',
180
+ '| Quick capture | `op:capture_quick` | vault |',
181
+ '| Session summaries | `op:session_capture` | memory |',
182
+ '',
183
+
184
+ // ─── Work Task Routing ───────────────────────────────────
185
+ '## Work Task Routing',
186
+ '<!-- soleri:task-routing -->',
187
+ '',
188
+ 'Use the orchestration layer for ALL work tasks:',
189
+ '- `op:orchestrate_plan` → vault + brain + structured plan.',
190
+ '- `op:orchestrate_execute` → execution tracking.',
191
+ '- `op:orchestrate_complete` → epilogue (vault, session).',
192
+ '',
193
+ 'The orchestrator handles vault lookup, brain recommendations, and knowledge capture automatically.',
194
+ '',
195
+
196
+ // ─── Intent Detection ────────────────────────────────────
197
+ '## Intent Detection',
198
+ '<!-- soleri:intent-detection -->',
199
+ '',
200
+ '**Semantic-First**: Analyze user MEANING before calling `op:route_intent`.',
201
+ '',
202
+ '| Signal | Intent |',
203
+ '|--------|--------|',
204
+ '| Problem described ("broken", "janky", "weird") | FIX |',
205
+ '| Need expressed ("I need", "we should have") | BUILD |',
206
+ '| Quality questioned ("is this right?") | REVIEW |',
207
+ '| Advice sought ("how should I", "best way") | PLAN |',
208
+ '| Improvement requested ("make it faster") | IMPROVE |',
209
+ '| Ready to ship ("deploy", "release") | DELIVER |',
210
+ '',
211
+ 'Use `op:route_intent` only to CONFIRM your analysis or when meaning is unclear.',
212
+ '',
213
+
214
+ // ─── Validation Loop ─────────────────────────────────────
215
+ '## Iterative Validation Loop',
216
+ '<!-- soleri:validation-loop -->',
217
+ '',
218
+ '- When a user gives a **work task**, start a loop: `op:loop_start params:{ prompt: "<task>", mode: "custom" }`',
219
+ '- Do NOT start loops for: questions, explanations, status checks, git operations, exploration, simple one-line fixes.',
220
+ '',
221
+ '| Mode | Op | Target | Max Iter |',
222
+ '|------|-----|--------|----------|',
223
+ '| `plan-iteration` | `op:create_plan` | grade >= A | 10 |',
224
+ '| `custom` | user-defined | promise-based | 20 |',
225
+ '',
226
+
227
+ // ─── Brain-Informed Work ─────────────────────────────────
228
+ '## Brain-Informed Work',
229
+ '<!-- soleri:brain -->',
230
+ '',
231
+ '- Brain patterns surface at session start. For relevant patterns, pull rules just-in-time from the vault.',
232
+ '- Brain tells you **which** patterns matter (names + strength scores). Vault tells you **what** they are (rules, examples).',
233
+ "- Pull only what's relevant to the current task — don't load everything at session start.",
234
+ '',
235
+
236
+ // ─── Cross-Project Memory ────────────────────────────────
237
+ '## Cross-Project Memory',
238
+ '<!-- soleri:cross-project -->',
239
+ '',
240
+ '- Use `crossProject: true` in `op:memory_search` for patterns across related projects.',
241
+ '- Promote universal patterns to global pool with `op:memory_promote_to_global`.',
242
+ '',
243
+
244
+ // ─── Session Lifecycle ───────────────────────────────────
245
+ '## Session Lifecycle',
246
+ '<!-- soleri:session -->',
247
+ '',
248
+ '### Session Start Protocol',
249
+ '',
250
+ 'On EVERY new session:',
251
+ '1. Register project: `op:register params:{ projectPath: "." }`',
252
+ '2. Check activation response for `persistence.status`, `vault.connected`, `project.registered`.',
253
+ '3. Check for plans awaiting reconciliation via `op:check_persistence`:',
254
+ ' - `executing` → Remind user to call `op:plan_reconcile`.',
255
+ ' - `reconciling` → Remind user to call `op:plan_complete_lifecycle`.',
256
+ '',
257
+ '### Context Compaction',
258
+ '',
259
+ 'A PreCompact hook calls `op:session_capture` before context compaction.',
260
+ 'Manual capture: `op:session_capture params:{ summary: "..." }`',
261
+ '',
262
+
263
+ `<!-- /${ENGINE_MARKER} -->`,
264
+ ];