@soleri/forge 5.14.0 → 5.14.2
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/index.js +0 -0
- package/dist/lib.d.ts +2 -0
- package/dist/lib.js +2 -0
- package/dist/lib.js.map +1 -1
- package/dist/skills/brain-debrief.md +47 -19
- package/dist/skills/brainstorming.md +19 -9
- package/dist/skills/code-patrol.md +21 -19
- package/dist/skills/context-resume.md +14 -11
- package/dist/skills/executing-plans.md +30 -15
- package/dist/skills/fix-and-learn.md +17 -14
- package/dist/skills/health-check.md +29 -23
- package/dist/skills/knowledge-harvest.md +27 -20
- package/dist/skills/onboard-me.md +16 -15
- package/dist/skills/retrospective.md +34 -18
- package/dist/skills/second-opinion.md +16 -9
- package/dist/skills/systematic-debugging.md +40 -29
- package/dist/skills/test-driven-development.md +45 -30
- package/dist/skills/vault-capture.md +31 -15
- package/dist/skills/vault-navigator.md +24 -13
- package/dist/skills/verification-before-completion.md +38 -26
- package/dist/skills/writing-plans.md +21 -13
- package/dist/templates/claude-md-template.d.ts +9 -8
- package/dist/templates/claude-md-template.js +29 -11
- package/dist/templates/claude-md-template.js.map +1 -1
- package/dist/templates/inject-claude-md.js +65 -25
- package/dist/templates/inject-claude-md.js.map +1 -1
- package/dist/templates/shared-rules.d.ts +10 -6
- package/dist/templates/shared-rules.js +242 -199
- package/dist/templates/shared-rules.js.map +1 -1
- package/dist/templates/test-facades.js +6 -4
- package/dist/templates/test-facades.js.map +1 -1
- package/package.json +1 -1
- package/src/lib.ts +2 -0
- package/src/templates/claude-md-template.ts +30 -12
- package/src/templates/inject-claude-md.ts +65 -25
- package/src/templates/shared-rules.ts +259 -210
- package/src/templates/test-facades.ts +6 -4
- package/dist/skills/skills/brain-debrief.md +0 -214
- package/dist/skills/skills/brainstorming.md +0 -180
- package/dist/skills/skills/code-patrol.md +0 -178
- package/dist/skills/skills/context-resume.md +0 -146
- package/dist/skills/skills/executing-plans.md +0 -216
- package/dist/skills/skills/fix-and-learn.md +0 -167
- package/dist/skills/skills/health-check.md +0 -231
- package/dist/skills/skills/knowledge-harvest.md +0 -185
- package/dist/skills/skills/onboard-me.md +0 -198
- package/dist/skills/skills/retrospective.md +0 -205
- package/dist/skills/skills/second-opinion.md +0 -149
- package/dist/skills/skills/systematic-debugging.md +0 -241
- package/dist/skills/skills/test-driven-development.md +0 -281
- package/dist/skills/skills/vault-capture.md +0 -170
- package/dist/skills/skills/vault-navigator.md +0 -140
- package/dist/skills/skills/verification-before-completion.md +0 -182
- package/dist/skills/skills/writing-plans.md +0 -215
- package/dist/templates/brain.d.ts +0 -6
- package/dist/templates/brain.js +0 -478
- package/dist/templates/brain.js.map +0 -1
- package/dist/templates/core-facade.d.ts +0 -6
- package/dist/templates/core-facade.js +0 -564
- package/dist/templates/core-facade.js.map +0 -1
- package/dist/templates/facade-factory.d.ts +0 -1
- package/dist/templates/facade-factory.js +0 -63
- package/dist/templates/facade-factory.js.map +0 -1
- package/dist/templates/facade-types.d.ts +0 -1
- package/dist/templates/facade-types.js +0 -46
- package/dist/templates/facade-types.js.map +0 -1
- package/dist/templates/intelligence-loader.d.ts +0 -1
- package/dist/templates/intelligence-loader.js +0 -43
- package/dist/templates/intelligence-loader.js.map +0 -1
- package/dist/templates/intelligence-types.d.ts +0 -1
- package/dist/templates/intelligence-types.js +0 -24
- package/dist/templates/intelligence-types.js.map +0 -1
- package/dist/templates/llm-client.d.ts +0 -7
- package/dist/templates/llm-client.js +0 -300
- package/dist/templates/llm-client.js.map +0 -1
- package/dist/templates/llm-key-pool.d.ts +0 -7
- package/dist/templates/llm-key-pool.js +0 -211
- package/dist/templates/llm-key-pool.js.map +0 -1
- package/dist/templates/llm-types.d.ts +0 -5
- package/dist/templates/llm-types.js +0 -161
- package/dist/templates/llm-types.js.map +0 -1
- package/dist/templates/llm-utils.d.ts +0 -5
- package/dist/templates/llm-utils.js +0 -260
- package/dist/templates/llm-utils.js.map +0 -1
- package/dist/templates/planner.d.ts +0 -5
- package/dist/templates/planner.js +0 -150
- package/dist/templates/planner.js.map +0 -1
- package/dist/templates/test-brain.d.ts +0 -6
- package/dist/templates/test-brain.js +0 -474
- package/dist/templates/test-brain.js.map +0 -1
- package/dist/templates/test-llm.d.ts +0 -7
- package/dist/templates/test-llm.js +0 -574
- package/dist/templates/test-llm.js.map +0 -1
- package/dist/templates/test-loader.d.ts +0 -5
- package/dist/templates/test-loader.js +0 -146
- package/dist/templates/test-loader.js.map +0 -1
- package/dist/templates/test-planner.d.ts +0 -5
- package/dist/templates/test-planner.js +0 -271
- package/dist/templates/test-planner.js.map +0 -1
- package/dist/templates/test-vault.d.ts +0 -5
- package/dist/templates/test-vault.js +0 -380
- package/dist/templates/test-vault.js.map +0 -1
- package/dist/templates/vault.d.ts +0 -5
- package/dist/templates/vault.js +0 -263
- 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
|
|
29
|
-
' *
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
' * -
|
|
65
|
-
' * -
|
|
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
|
|
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
|
|
87
|
-
' * Returns true if the section was found and removed.',
|
|
108
|
+
' * Remove a marker-delimited block from a file.',
|
|
88
109
|
' */',
|
|
89
|
-
'function
|
|
90
|
-
' if (!existsSync(filePath)) return
|
|
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
|
|
116
|
+
' if (startIdx === -1) return false;',
|
|
97
117
|
' const endIdx = existing.indexOf(endMarker);',
|
|
98
|
-
' if (endIdx === -1) return
|
|
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
|
|
123
|
+
' return true;',
|
|
104
124
|
'}',
|
|
105
125
|
'',
|
|
106
126
|
'/**',
|
|
107
127
|
' * Remove agent section from the global ~/.claude/CLAUDE.md.',
|
|
108
|
-
' *
|
|
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
|
-
"
|
|
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
|
-
"
|
|
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,215 +1,264 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared
|
|
2
|
+
* Shared Soleri engine rules — agent-agnostic.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
7
10
|
*/
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return [
|
|
14
|
-
// ─── Vault-First Protocol ────────────────────────────────
|
|
15
|
-
'## Vault as Source of Truth',
|
|
16
|
-
`<!-- ${toolPrefix}:vault-protocol -->`,
|
|
17
|
-
'',
|
|
18
|
-
'- **MANDATORY**: Consult the vault BEFORE every decision — planning, design, architecture, patterns, problem-solving.',
|
|
19
|
-
`- Lookup order: 1) VAULT (${bt}${toolPrefix}_core op:search_intelligent${bt}) → 2) MEMORY (${bt}${toolPrefix}_core op:memory_search${bt}) → 3) CODEBASE → 4) WEB/TRAINING.`,
|
|
20
|
-
'- If the vault has a pattern, follow it. If it has an anti-pattern, avoid it.',
|
|
21
|
-
`- Persist lessons: call ${bt}${toolPrefix}_core op:capture_knowledge${bt} — don't just promise "I will remember this".`,
|
|
22
|
-
'- Exceptions: runtime errors with stack traces → codebase first; user explicitly asks to search web.',
|
|
23
|
-
'',
|
|
24
|
-
|
|
25
|
-
// ─── Planning ────────────────────────────────────────────
|
|
26
|
-
'## Planning',
|
|
27
|
-
`<!-- ${toolPrefix}:planning -->`,
|
|
28
|
-
'',
|
|
29
|
-
`- Use ${bt}${toolPrefix}_core op:create_plan${bt} before writing ANY code. Show the plan, wait for approval.`,
|
|
30
|
-
`- Two-gate approval: Gate 1 (${bt}op:approve_plan${bt}), Gate 2 (${bt}op:plan_split${bt}). Never skip either.`,
|
|
31
|
-
'- Wait for explicit "yes" / "approve" before proceeding past each gate.',
|
|
32
|
-
`- After execution: ${bt}op:plan_reconcile${bt} (drift report) then ${bt}op:plan_complete_lifecycle${bt} (knowledge capture, archive).`,
|
|
33
|
-
'- Never let a plan stay in `executing` or `reconciling` state without reminding the user.',
|
|
34
|
-
'- On session start: check for plans in `executing`/`reconciling` state and remind.',
|
|
35
|
-
'- Exceptions: read-only operations, user says "just do it", single-line fixes.',
|
|
36
|
-
'',
|
|
37
|
-
'### Lifecycle States',
|
|
38
|
-
'',
|
|
39
|
-
'| State | Expires | Next Action |',
|
|
40
|
-
'|-------|---------|-------------|',
|
|
41
|
-
`| ${bt}draft${bt} | 30 min | ${bt}${toolPrefix}_core op:create_plan${bt} (iterate) |`,
|
|
42
|
-
`| ${bt}approved${bt} | 30 min | ${bt}${toolPrefix}_core op:plan_split${bt} |`,
|
|
43
|
-
`| ${bt}executing${bt} | Never | ${bt}${toolPrefix}_core op:plan_reconcile${bt} |`,
|
|
44
|
-
`| ${bt}reconciling${bt} | Never | ${bt}${toolPrefix}_core op:plan_complete_lifecycle${bt} |`,
|
|
45
|
-
`| ${bt}completed${bt} | — | Done |`,
|
|
46
|
-
'',
|
|
47
|
-
'### Plan Presentation',
|
|
48
|
-
'',
|
|
49
|
-
'Every plan summary MUST include this format:',
|
|
50
|
-
'',
|
|
51
|
-
'```',
|
|
52
|
-
'## Plan: [Short Title]',
|
|
53
|
-
'',
|
|
54
|
-
'| Field | Value |',
|
|
55
|
-
'|-------|-------|',
|
|
56
|
-
'| **Plan ID** | {planId} |',
|
|
57
|
-
'| **Check ID** | {checkId} |',
|
|
58
|
-
'| **Grade** | {grade} ({score}/100) |',
|
|
59
|
-
'| **Status** | {status} |',
|
|
60
|
-
'| **Lifecycle** | {lifecycleStatus} |',
|
|
61
|
-
'',
|
|
62
|
-
'**Objective:** [One sentence]',
|
|
63
|
-
'',
|
|
64
|
-
'**Scope:**',
|
|
65
|
-
'| Included | Excluded |',
|
|
66
|
-
'|----------|----------|',
|
|
67
|
-
'| item 1 | item 1 |',
|
|
68
|
-
'',
|
|
69
|
-
'**Approach:**',
|
|
70
|
-
'| Step | Task |',
|
|
71
|
-
'|------|------|',
|
|
72
|
-
'| 1 | Description |',
|
|
73
|
-
'```',
|
|
74
|
-
'',
|
|
75
|
-
'Without visible IDs, users cannot resume, reference, or approve plans.',
|
|
76
|
-
'',
|
|
77
|
-
'### Drift Report',
|
|
78
|
-
'',
|
|
79
|
-
'```',
|
|
80
|
-
'| Field | Value |',
|
|
81
|
-
'|-------|-------|',
|
|
82
|
-
'| **Accuracy** | {accuracyScore}/100 |',
|
|
83
|
-
'| **Drift Items** | {count} |',
|
|
84
|
-
'',
|
|
85
|
-
'| Type | Description | Impact | Rationale |',
|
|
86
|
-
'|------|-------------|--------|-----------|',
|
|
87
|
-
'| skipped | ... | medium | ... |',
|
|
88
|
-
'```',
|
|
89
|
-
'',
|
|
90
|
-
|
|
91
|
-
// ─── Output Formatting ───────────────────────────────────
|
|
92
|
-
'## Output Formatting',
|
|
93
|
-
`<!-- ${toolPrefix}:output-formatting -->`,
|
|
94
|
-
'',
|
|
95
|
-
'**MANDATORY**: Present tool outputs in human-readable format, NOT raw JSON.',
|
|
96
|
-
'',
|
|
97
|
-
'**Tasks** — show as numbered table:',
|
|
98
|
-
'```',
|
|
99
|
-
'| # | Type | Task | Complexity |',
|
|
100
|
-
'|---|------|------|------------|',
|
|
101
|
-
'| 1 | Impl | ... | High |',
|
|
102
|
-
'```',
|
|
103
|
-
'',
|
|
104
|
-
'**Completion** — show outcome, knowledge captured count, archive path.',
|
|
105
|
-
'',
|
|
106
|
-
'**Status lines** — `Persisted: X plans, Y tasks, Z checks` / `Recovered: X plans, Y tasks`',
|
|
107
|
-
'',
|
|
108
|
-
|
|
109
|
-
// ─── Clean Commits ───────────────────────────────────────
|
|
110
|
-
'## Clean Commits',
|
|
111
|
-
`<!-- ${toolPrefix}:clean-commits -->`,
|
|
112
|
-
'',
|
|
113
|
-
'**MANDATORY**: No AI attribution in commit messages.',
|
|
114
|
-
'',
|
|
115
|
-
'Blocked patterns:',
|
|
116
|
-
'- `Co-Authored-By: Claude` (any variant)',
|
|
117
|
-
'- `noreply@anthropic.com`',
|
|
118
|
-
'- `Generated with Claude`, `AI-generated`',
|
|
119
|
-
'- Any mention of `Anthropic`, `Claude Opus`, `Claude Sonnet`, `Claude Haiku`',
|
|
120
|
-
'',
|
|
121
|
-
'Use conventional commits:',
|
|
122
|
-
'```',
|
|
123
|
-
'feat: add user authentication',
|
|
124
|
-
'fix: resolve login timeout issue',
|
|
125
|
-
'refactor: simplify data fetching logic',
|
|
126
|
-
'```',
|
|
127
|
-
'',
|
|
128
|
-
|
|
129
|
-
// ─── Knowledge Capture ───────────────────────────────────
|
|
130
|
-
'## Knowledge Capture',
|
|
131
|
-
`<!-- ${toolPrefix}:knowledge-capture -->`,
|
|
132
|
-
'',
|
|
133
|
-
"**MANDATORY**: Persist lessons, don't just promise them.",
|
|
134
|
-
'',
|
|
135
|
-
'When you learn something that should persist:',
|
|
136
|
-
'1. **DON\'T** just say "I will remember this"',
|
|
137
|
-
`2. **DO** call ${bt}${toolPrefix}_core op:capture_knowledge${bt} to persist to vault`,
|
|
138
|
-
"3. **DO** update relevant files if it's a behavioral change",
|
|
139
|
-
'',
|
|
140
|
-
'| Type | Tool | Persists To |',
|
|
141
|
-
'|------|------|-------------|',
|
|
142
|
-
`| Patterns/Anti-patterns | ${bt}${toolPrefix}_core op:capture_knowledge${bt} | vault |`,
|
|
143
|
-
`| Quick capture | ${bt}${toolPrefix}_core op:capture_quick${bt} | vault |`,
|
|
144
|
-
`| Session summaries | ${bt}${toolPrefix}_core op:session_capture${bt} | memory |`,
|
|
145
|
-
'',
|
|
146
|
-
|
|
147
|
-
// ─── Work Task Routing ───────────────────────────────────
|
|
148
|
-
'## Work Task Routing',
|
|
149
|
-
`<!-- ${toolPrefix}:task-routing -->`,
|
|
150
|
-
'',
|
|
151
|
-
'Use the orchestration layer for ALL work tasks:',
|
|
152
|
-
`- ${bt}${toolPrefix}_core op:orchestrate_plan${bt} → vault + brain + structured plan.`,
|
|
153
|
-
`- ${bt}${toolPrefix}_core op:orchestrate_execute${bt} → execution tracking.`,
|
|
154
|
-
`- ${bt}${toolPrefix}_core op:orchestrate_complete${bt} → epilogue (vault, session).`,
|
|
155
|
-
'',
|
|
156
|
-
'The orchestrator handles vault lookup, brain recommendations, and knowledge capture automatically.',
|
|
157
|
-
'',
|
|
158
|
-
|
|
159
|
-
// ─── Intent Detection ────────────────────────────────────
|
|
160
|
-
'## Intent Detection',
|
|
161
|
-
`<!-- ${toolPrefix}:intent-detection -->`,
|
|
162
|
-
'',
|
|
163
|
-
`**Semantic-First**: Analyze user MEANING before calling ${bt}route_intent${bt}.`,
|
|
164
|
-
'',
|
|
165
|
-
'| Signal | Intent |',
|
|
166
|
-
'|--------|--------|',
|
|
167
|
-
'| Problem described ("broken", "janky", "weird") | FIX |',
|
|
168
|
-
'| Need expressed ("I need", "we should have") | BUILD |',
|
|
169
|
-
'| Quality questioned ("is this right?") | REVIEW |',
|
|
170
|
-
'| Advice sought ("how should I", "best way") | PLAN |',
|
|
171
|
-
'| Improvement requested ("make it faster") | IMPROVE |',
|
|
172
|
-
'| Ready to ship ("deploy", "release") | DELIVER |',
|
|
173
|
-
'',
|
|
174
|
-
`Use ${bt}${toolPrefix}_core op:route_intent${bt} only to CONFIRM your analysis or when meaning is unclear.`,
|
|
175
|
-
'',
|
|
176
|
-
|
|
177
|
-
// ─── Validation Loop ─────────────────────────────────────
|
|
178
|
-
'## Iterative Validation Loop',
|
|
179
|
-
`<!-- ${toolPrefix}:validation-loop -->`,
|
|
180
|
-
'',
|
|
181
|
-
`- When a user gives a **work task**, start a loop: ${bt}${toolPrefix}_core op:loop_start params:{ prompt: "<task>", mode: "custom" }${bt}`,
|
|
182
|
-
'- Do NOT start loops for: questions, explanations, status checks, git operations, exploration, simple one-line fixes.',
|
|
183
|
-
'',
|
|
184
|
-
'| Mode | Tool | Target | Max Iter |',
|
|
185
|
-
'|------|------|--------|----------|',
|
|
186
|
-
`| ${bt}plan-iteration${bt} | ${bt}${toolPrefix}_core op:create_plan${bt} | grade >= A | 10 |`,
|
|
187
|
-
`| ${bt}custom${bt} | user-defined | promise-based | 20 |`,
|
|
188
|
-
'',
|
|
189
|
-
|
|
190
|
-
// ─── Brain-Informed Work ─────────────────────────────────
|
|
191
|
-
'## Brain-Informed Work',
|
|
192
|
-
`<!-- ${toolPrefix}:brain -->`,
|
|
193
|
-
'',
|
|
194
|
-
'- Brain patterns surface at session start. For relevant patterns, pull rules just-in-time from the vault.',
|
|
195
|
-
'- Brain tells you **which** patterns matter (names + strength scores). Vault tells you **what** they are (rules, examples).',
|
|
196
|
-
"- Pull only what's relevant to the current task — don't load everything at session start.",
|
|
197
|
-
'',
|
|
198
|
-
|
|
199
|
-
// ─── Cross-Project Memory ────────────────────────────────
|
|
200
|
-
'## Cross-Project Memory',
|
|
201
|
-
`<!-- ${toolPrefix}:cross-project -->`,
|
|
202
|
-
'',
|
|
203
|
-
`- Use ${bt}crossProject: true${bt} in ${bt}${toolPrefix}_core op:memory_search${bt} for patterns across related projects.`,
|
|
204
|
-
`- Promote universal patterns to global pool with ${bt}${toolPrefix}_core op:memory_promote_to_global${bt}.`,
|
|
205
|
-
'',
|
|
206
|
-
|
|
207
|
-
// ─── Session Lifecycle ───────────────────────────────────
|
|
208
|
-
'## Session Lifecycle',
|
|
209
|
-
`<!-- ${toolPrefix}:session -->`,
|
|
210
|
-
'',
|
|
211
|
-
'A PreCompact hook calls `session_capture` before context compaction.',
|
|
212
|
-
`Manual capture: ${bt}${toolPrefix}_core op:session_capture params:{ summary: "..." }${bt}`,
|
|
213
|
-
'',
|
|
214
|
-
];
|
|
12
|
+
const ENGINE_MARKER = 'soleri:engine-rules';
|
|
13
|
+
|
|
14
|
+
export function getEngineMarker(): string {
|
|
15
|
+
return ENGINE_MARKER;
|
|
215
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
|
+
];
|