@soleri/forge 5.14.0 → 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 +29 -11
  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 -6
  28. package/dist/templates/shared-rules.js +242 -199
  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 +30 -12
  33. package/src/templates/inject-claude-md.ts +65 -25
  34. package/src/templates/shared-rules.ts +259 -210
  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
@@ -1,204 +1,247 @@
1
1
  /**
2
- * Shared behavioral rules that every Soleri agent ships with.
2
+ * Shared Soleri engine rules agent-agnostic.
3
3
  *
4
- * Mirrors the structure and quality of Salvador's global CLAUDE.md.
5
- * Uses HTML comment section markers, MANDATORY keywords, compact
6
- * formatting, and complete lifecycle documentation.
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
- /** Returns markdown lines for all shared behavioral sections. */
9
- export function getSharedRules(toolPrefix) {
10
- const bt = '`';
11
- return [
12
- // ─── Vault-First Protocol ────────────────────────────────
13
- '## Vault as Source of Truth',
14
- `<!-- ${toolPrefix}:vault-protocol -->`,
15
- '',
16
- '- **MANDATORY**: Consult the vault BEFORE every decision — planning, design, architecture, patterns, problem-solving.',
17
- `- 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.`,
18
- '- If the vault has a pattern, follow it. If it has an anti-pattern, avoid it.',
19
- `- Persist lessons: call ${bt}${toolPrefix}_core op:capture_knowledge${bt} — don't just promise "I will remember this".`,
20
- '- Exceptions: runtime errors with stack traces → codebase first; user explicitly asks to search web.',
21
- '',
22
- // ─── Planning ────────────────────────────────────────────
23
- '## Planning',
24
- `<!-- ${toolPrefix}:planning -->`,
25
- '',
26
- `- Use ${bt}${toolPrefix}_core op:create_plan${bt} before writing ANY code. Show the plan, wait for approval.`,
27
- `- Two-gate approval: Gate 1 (${bt}op:approve_plan${bt}), Gate 2 (${bt}op:plan_split${bt}). Never skip either.`,
28
- '- Wait for explicit "yes" / "approve" before proceeding past each gate.',
29
- `- After execution: ${bt}op:plan_reconcile${bt} (drift report) then ${bt}op:plan_complete_lifecycle${bt} (knowledge capture, archive).`,
30
- '- Never let a plan stay in `executing` or `reconciling` state without reminding the user.',
31
- '- On session start: check for plans in `executing`/`reconciling` state and remind.',
32
- '- Exceptions: read-only operations, user says "just do it", single-line fixes.',
33
- '',
34
- '### Lifecycle States',
35
- '',
36
- '| State | Expires | Next Action |',
37
- '|-------|---------|-------------|',
38
- `| ${bt}draft${bt} | 30 min | ${bt}${toolPrefix}_core op:create_plan${bt} (iterate) |`,
39
- `| ${bt}approved${bt} | 30 min | ${bt}${toolPrefix}_core op:plan_split${bt} |`,
40
- `| ${bt}executing${bt} | Never | ${bt}${toolPrefix}_core op:plan_reconcile${bt} |`,
41
- `| ${bt}reconciling${bt} | Never | ${bt}${toolPrefix}_core op:plan_complete_lifecycle${bt} |`,
42
- `| ${bt}completed${bt} | — | Done |`,
43
- '',
44
- '### Plan Presentation',
45
- '',
46
- 'Every plan summary MUST include this format:',
47
- '',
48
- '```',
49
- '## Plan: [Short Title]',
50
- '',
51
- '| Field | Value |',
52
- '|-------|-------|',
53
- '| **Plan ID** | {planId} |',
54
- '| **Check ID** | {checkId} |',
55
- '| **Grade** | {grade} ({score}/100) |',
56
- '| **Status** | {status} |',
57
- '| **Lifecycle** | {lifecycleStatus} |',
58
- '',
59
- '**Objective:** [One sentence]',
60
- '',
61
- '**Scope:**',
62
- '| Included | Excluded |',
63
- '|----------|----------|',
64
- '| item 1 | item 1 |',
65
- '',
66
- '**Approach:**',
67
- '| Step | Task |',
68
- '|------|------|',
69
- '| 1 | Description |',
70
- '```',
71
- '',
72
- 'Without visible IDs, users cannot resume, reference, or approve plans.',
73
- '',
74
- '### Drift Report',
75
- '',
76
- '```',
77
- '| Field | Value |',
78
- '|-------|-------|',
79
- '| **Accuracy** | {accuracyScore}/100 |',
80
- '| **Drift Items** | {count} |',
81
- '',
82
- '| Type | Description | Impact | Rationale |',
83
- '|------|-------------|--------|-----------|',
84
- '| skipped | ... | medium | ... |',
85
- '```',
86
- '',
87
- // ─── Output Formatting ───────────────────────────────────
88
- '## Output Formatting',
89
- `<!-- ${toolPrefix}:output-formatting -->`,
90
- '',
91
- '**MANDATORY**: Present tool outputs in human-readable format, NOT raw JSON.',
92
- '',
93
- '**Tasks** — show as numbered table:',
94
- '```',
95
- '| # | Type | Task | Complexity |',
96
- '|---|------|------|------------|',
97
- '| 1 | Impl | ... | High |',
98
- '```',
99
- '',
100
- '**Completion** — show outcome, knowledge captured count, archive path.',
101
- '',
102
- '**Status lines** — `Persisted: X plans, Y tasks, Z checks` / `Recovered: X plans, Y tasks`',
103
- '',
104
- // ─── Clean Commits ───────────────────────────────────────
105
- '## Clean Commits',
106
- `<!-- ${toolPrefix}:clean-commits -->`,
107
- '',
108
- '**MANDATORY**: No AI attribution in commit messages.',
109
- '',
110
- 'Blocked patterns:',
111
- '- `Co-Authored-By: Claude` (any variant)',
112
- '- `noreply@anthropic.com`',
113
- '- `Generated with Claude`, `AI-generated`',
114
- '- Any mention of `Anthropic`, `Claude Opus`, `Claude Sonnet`, `Claude Haiku`',
115
- '',
116
- 'Use conventional commits:',
117
- '```',
118
- 'feat: add user authentication',
119
- 'fix: resolve login timeout issue',
120
- 'refactor: simplify data fetching logic',
121
- '```',
122
- '',
123
- // ─── Knowledge Capture ───────────────────────────────────
124
- '## Knowledge Capture',
125
- `<!-- ${toolPrefix}:knowledge-capture -->`,
126
- '',
127
- "**MANDATORY**: Persist lessons, don't just promise them.",
128
- '',
129
- 'When you learn something that should persist:',
130
- '1. **DON\'T** just say "I will remember this"',
131
- `2. **DO** call ${bt}${toolPrefix}_core op:capture_knowledge${bt} to persist to vault`,
132
- "3. **DO** update relevant files if it's a behavioral change",
133
- '',
134
- '| Type | Tool | Persists To |',
135
- '|------|------|-------------|',
136
- `| Patterns/Anti-patterns | ${bt}${toolPrefix}_core op:capture_knowledge${bt} | vault |`,
137
- `| Quick capture | ${bt}${toolPrefix}_core op:capture_quick${bt} | vault |`,
138
- `| Session summaries | ${bt}${toolPrefix}_core op:session_capture${bt} | memory |`,
139
- '',
140
- // ─── Work Task Routing ───────────────────────────────────
141
- '## Work Task Routing',
142
- `<!-- ${toolPrefix}:task-routing -->`,
143
- '',
144
- 'Use the orchestration layer for ALL work tasks:',
145
- `- ${bt}${toolPrefix}_core op:orchestrate_plan${bt} → vault + brain + structured plan.`,
146
- `- ${bt}${toolPrefix}_core op:orchestrate_execute${bt} → execution tracking.`,
147
- `- ${bt}${toolPrefix}_core op:orchestrate_complete${bt} → epilogue (vault, session).`,
148
- '',
149
- 'The orchestrator handles vault lookup, brain recommendations, and knowledge capture automatically.',
150
- '',
151
- // ─── Intent Detection ────────────────────────────────────
152
- '## Intent Detection',
153
- `<!-- ${toolPrefix}:intent-detection -->`,
154
- '',
155
- `**Semantic-First**: Analyze user MEANING before calling ${bt}route_intent${bt}.`,
156
- '',
157
- '| Signal | Intent |',
158
- '|--------|--------|',
159
- '| Problem described ("broken", "janky", "weird") | FIX |',
160
- '| Need expressed ("I need", "we should have") | BUILD |',
161
- '| Quality questioned ("is this right?") | REVIEW |',
162
- '| Advice sought ("how should I", "best way") | PLAN |',
163
- '| Improvement requested ("make it faster") | IMPROVE |',
164
- '| Ready to ship ("deploy", "release") | DELIVER |',
165
- '',
166
- `Use ${bt}${toolPrefix}_core op:route_intent${bt} only to CONFIRM your analysis or when meaning is unclear.`,
167
- '',
168
- // ─── Validation Loop ─────────────────────────────────────
169
- '## Iterative Validation Loop',
170
- `<!-- ${toolPrefix}:validation-loop -->`,
171
- '',
172
- `- When a user gives a **work task**, start a loop: ${bt}${toolPrefix}_core op:loop_start params:{ prompt: "<task>", mode: "custom" }${bt}`,
173
- '- Do NOT start loops for: questions, explanations, status checks, git operations, exploration, simple one-line fixes.',
174
- '',
175
- '| Mode | Tool | Target | Max Iter |',
176
- '|------|------|--------|----------|',
177
- `| ${bt}plan-iteration${bt} | ${bt}${toolPrefix}_core op:create_plan${bt} | grade >= A | 10 |`,
178
- `| ${bt}custom${bt} | user-defined | promise-based | 20 |`,
179
- '',
180
- // ─── Brain-Informed Work ─────────────────────────────────
181
- '## Brain-Informed Work',
182
- `<!-- ${toolPrefix}:brain -->`,
183
- '',
184
- '- Brain patterns surface at session start. For relevant patterns, pull rules just-in-time from the vault.',
185
- '- Brain tells you **which** patterns matter (names + strength scores). Vault tells you **what** they are (rules, examples).',
186
- "- Pull only what's relevant to the current task — don't load everything at session start.",
187
- '',
188
- // ─── Cross-Project Memory ────────────────────────────────
189
- '## Cross-Project Memory',
190
- `<!-- ${toolPrefix}:cross-project -->`,
191
- '',
192
- `- Use ${bt}crossProject: true${bt} in ${bt}${toolPrefix}_core op:memory_search${bt} for patterns across related projects.`,
193
- `- Promote universal patterns to global pool with ${bt}${toolPrefix}_core op:memory_promote_to_global${bt}.`,
194
- '',
195
- // ─── Session Lifecycle ───────────────────────────────────
196
- '## Session Lifecycle',
197
- `<!-- ${toolPrefix}:session -->`,
198
- '',
199
- 'A PreCompact hook calls `session_capture` before context compaction.',
200
- `Manual capture: ${bt}${toolPrefix}_core op:session_capture params:{ summary: "..." }${bt}`,
201
- '',
202
- ];
11
+ const ENGINE_MARKER = 'soleri:engine-rules';
12
+ export function getEngineMarker() {
13
+ return ENGINE_MARKER;
14
+ }
15
+ /** Returns the full engine rules markdown content (with markers). */
16
+ export function getEngineRulesContent() {
17
+ return ENGINE_RULES_LINES.join('\n');
203
18
  }
19
+ const ENGINE_RULES_LINES = [
20
+ `<!-- ${ENGINE_MARKER} -->`,
21
+ '',
22
+ '# Soleri Engine Rules',
23
+ '',
24
+ "Shared behavioral rules for all Soleri agents. The active agent's facade table provides tool names.",
25
+ '',
26
+ // ─── Response Integrity ─────────────────────────────────
27
+ '## Response Integrity',
28
+ '<!-- soleri:response-integrity -->',
29
+ '',
30
+ '- If you\'re not confident in your answer, say "I\'m not sure" and explain why. Never guess.',
31
+ '- After every response, rate your confidence from 1 to 10. Anything below 7, flag it.',
32
+ '',
33
+ // ─── Memory Quality Gate ───────────────────────────────
34
+ '## Memory Quality Gate',
35
+ '<!-- soleri:memory-quality -->',
36
+ '',
37
+ '**MANDATORY** before writing to auto memory: apply the **"Will I hit this again?"** test.',
38
+ '',
39
+ '**SAVE** — recurring bugs, non-obvious gotchas, structural issues, behavioral quirks that will resurface.',
40
+ "**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.",
41
+ '',
42
+ "If in doubt, don't save. Less memory with high signal beats more memory with noise.",
43
+ '',
44
+ // ─── Vault-First Protocol ────────────────────────────────
45
+ '## Vault as Source of Truth',
46
+ '<!-- soleri:vault-protocol -->',
47
+ '',
48
+ '- **MANDATORY**: Consult the vault BEFORE every decision — planning, design, architecture, patterns, problem-solving.',
49
+ '- Lookup order: 1) VAULT (`op:search_intelligent`) → 2) MEMORY (`op:memory_search`) → 3) CODEBASE → 4) WEB/TRAINING.',
50
+ '- If the vault has a pattern, follow it. If it has an anti-pattern, avoid it.',
51
+ '- Persist lessons: call `op:capture_knowledge` — don\'t just promise "I will remember this".',
52
+ '- Exceptions: runtime errors with stack traces → codebase first; user explicitly asks to search web.',
53
+ '',
54
+ // ─── Planning ────────────────────────────────────────────
55
+ '## Planning',
56
+ '<!-- soleri:planning -->',
57
+ '',
58
+ '- Use `op:create_plan` before writing ANY code. Show the plan, wait for approval.',
59
+ '- Two-gate approval: Gate 1 (`op:approve_plan`), Gate 2 (`op:plan_split`). Never skip either.',
60
+ '- Wait for explicit "yes" / "approve" before proceeding past each gate.',
61
+ '- After execution: `op:plan_reconcile` (drift report) then `op:plan_complete_lifecycle` (knowledge capture, archive).',
62
+ '- Never let a plan stay in `executing` or `reconciling` state without reminding the user.',
63
+ '- On session start: check for plans in `executing`/`reconciling` state and remind.',
64
+ '- Exceptions: read-only operations, user says "just do it", single-line fixes.',
65
+ '',
66
+ '### Lifecycle States',
67
+ '',
68
+ '| State | Expires | Next Action |',
69
+ '|-------|---------|-------------|',
70
+ '| `draft` | 30 min | `op:create_plan` (iterate) |',
71
+ '| `approved` | 30 min | `op:plan_split` |',
72
+ '| `executing` | Never | `op:plan_reconcile` |',
73
+ '| `reconciling` | Never | `op:plan_complete_lifecycle` |',
74
+ '| `completed` | — | Done |',
75
+ '',
76
+ '### Plan Presentation',
77
+ '',
78
+ 'Every plan summary MUST include this format:',
79
+ '',
80
+ '```',
81
+ '## Plan: [Short Title]',
82
+ '',
83
+ '| Field | Value |',
84
+ '|-------|-------|',
85
+ '| **Plan ID** | {planId} |',
86
+ '| **Check ID** | {checkId} |',
87
+ '| **Grade** | {grade} ({score}/100) |',
88
+ '| **Status** | {status} |',
89
+ '| **Lifecycle** | {lifecycleStatus} |',
90
+ '',
91
+ '**Objective:** [One sentence]',
92
+ '',
93
+ '**Scope:**',
94
+ '| Included | Excluded |',
95
+ '|----------|----------|',
96
+ '| item 1 | item 1 |',
97
+ '',
98
+ '**Approach:**',
99
+ '| Step | Task |',
100
+ '|------|------|',
101
+ '| 1 | Description |',
102
+ '```',
103
+ '',
104
+ 'Without visible IDs, users cannot resume, reference, or approve plans.',
105
+ '',
106
+ '### Drift Report',
107
+ '',
108
+ '```',
109
+ '| Field | Value |',
110
+ '|-------|-------|',
111
+ '| **Accuracy** | {accuracyScore}/100 |',
112
+ '| **Drift Items** | {count} |',
113
+ '',
114
+ '| Type | Description | Impact | Rationale |',
115
+ '|------|-------------|--------|-----------|',
116
+ '| skipped | ... | medium | ... |',
117
+ '```',
118
+ '',
119
+ // ─── Output Formatting ───────────────────────────────────
120
+ '## Output Formatting',
121
+ '<!-- soleri:output-formatting -->',
122
+ '',
123
+ '**MANDATORY**: Present tool outputs in human-readable format, NOT raw JSON.',
124
+ '',
125
+ '**Tasks** — show as numbered table:',
126
+ '```',
127
+ '| # | Type | Task | Complexity |',
128
+ '|---|------|------|------------|',
129
+ '| 1 | Impl | ... | High |',
130
+ '```',
131
+ '',
132
+ '**Completion** — show outcome, knowledge captured count, archive path.',
133
+ '',
134
+ '**Status lines** — `Persisted: X plans, Y tasks, Z checks` / `Recovered: X plans, Y tasks`',
135
+ '',
136
+ // ─── Clean Commits ───────────────────────────────────────
137
+ '## Clean Commits',
138
+ '<!-- soleri:clean-commits -->',
139
+ '',
140
+ '**MANDATORY**: No AI attribution in commit messages.',
141
+ '',
142
+ 'Blocked patterns:',
143
+ '- `Co-Authored-By: Claude` (any variant)',
144
+ '- `noreply@anthropic.com`',
145
+ '- `Generated with Claude`, `AI-generated`',
146
+ '- Any mention of `Anthropic`, `Claude Opus`, `Claude Sonnet`, `Claude Haiku`',
147
+ '',
148
+ 'Use conventional commits:',
149
+ '```',
150
+ 'feat: add user authentication',
151
+ 'fix: resolve login timeout issue',
152
+ 'refactor: simplify data fetching logic',
153
+ '```',
154
+ '',
155
+ // ─── Knowledge Capture ───────────────────────────────────
156
+ '## Knowledge Capture',
157
+ '<!-- soleri:knowledge-capture -->',
158
+ '',
159
+ "**MANDATORY**: Persist lessons, don't just promise them.",
160
+ '',
161
+ 'When you learn something that should persist:',
162
+ '1. **DON\'T** just say "I will remember this"',
163
+ '2. **DO** call `op:capture_knowledge` to persist to vault',
164
+ "3. **DO** update relevant files if it's a behavioral change",
165
+ '',
166
+ '| Type | Op | Persists To |',
167
+ '|------|-----|-------------|',
168
+ '| Patterns/Anti-patterns | `op:capture_knowledge` | vault |',
169
+ '| Quick capture | `op:capture_quick` | vault |',
170
+ '| Session summaries | `op:session_capture` | memory |',
171
+ '',
172
+ // ─── Work Task Routing ───────────────────────────────────
173
+ '## Work Task Routing',
174
+ '<!-- soleri:task-routing -->',
175
+ '',
176
+ 'Use the orchestration layer for ALL work tasks:',
177
+ '- `op:orchestrate_plan` → vault + brain + structured plan.',
178
+ '- `op:orchestrate_execute` → execution tracking.',
179
+ '- `op:orchestrate_complete` → epilogue (vault, session).',
180
+ '',
181
+ 'The orchestrator handles vault lookup, brain recommendations, and knowledge capture automatically.',
182
+ '',
183
+ // ─── Intent Detection ────────────────────────────────────
184
+ '## Intent Detection',
185
+ '<!-- soleri:intent-detection -->',
186
+ '',
187
+ '**Semantic-First**: Analyze user MEANING before calling `op:route_intent`.',
188
+ '',
189
+ '| Signal | Intent |',
190
+ '|--------|--------|',
191
+ '| Problem described ("broken", "janky", "weird") | FIX |',
192
+ '| Need expressed ("I need", "we should have") | BUILD |',
193
+ '| Quality questioned ("is this right?") | REVIEW |',
194
+ '| Advice sought ("how should I", "best way") | PLAN |',
195
+ '| Improvement requested ("make it faster") | IMPROVE |',
196
+ '| Ready to ship ("deploy", "release") | DELIVER |',
197
+ '',
198
+ 'Use `op:route_intent` only to CONFIRM your analysis or when meaning is unclear.',
199
+ '',
200
+ // ─── Validation Loop ─────────────────────────────────────
201
+ '## Iterative Validation Loop',
202
+ '<!-- soleri:validation-loop -->',
203
+ '',
204
+ '- When a user gives a **work task**, start a loop: `op:loop_start params:{ prompt: "<task>", mode: "custom" }`',
205
+ '- Do NOT start loops for: questions, explanations, status checks, git operations, exploration, simple one-line fixes.',
206
+ '',
207
+ '| Mode | Op | Target | Max Iter |',
208
+ '|------|-----|--------|----------|',
209
+ '| `plan-iteration` | `op:create_plan` | grade >= A | 10 |',
210
+ '| `custom` | user-defined | promise-based | 20 |',
211
+ '',
212
+ // ─── Brain-Informed Work ─────────────────────────────────
213
+ '## Brain-Informed Work',
214
+ '<!-- soleri:brain -->',
215
+ '',
216
+ '- Brain patterns surface at session start. For relevant patterns, pull rules just-in-time from the vault.',
217
+ '- Brain tells you **which** patterns matter (names + strength scores). Vault tells you **what** they are (rules, examples).',
218
+ "- Pull only what's relevant to the current task — don't load everything at session start.",
219
+ '',
220
+ // ─── Cross-Project Memory ────────────────────────────────
221
+ '## Cross-Project Memory',
222
+ '<!-- soleri:cross-project -->',
223
+ '',
224
+ '- Use `crossProject: true` in `op:memory_search` for patterns across related projects.',
225
+ '- Promote universal patterns to global pool with `op:memory_promote_to_global`.',
226
+ '',
227
+ // ─── Session Lifecycle ───────────────────────────────────
228
+ '## Session Lifecycle',
229
+ '<!-- soleri:session -->',
230
+ '',
231
+ '### Session Start Protocol',
232
+ '',
233
+ 'On EVERY new session:',
234
+ '1. Register project: `op:register params:{ projectPath: "." }`',
235
+ '2. Check activation response for `persistence.status`, `vault.connected`, `project.registered`.',
236
+ '3. Check for plans awaiting reconciliation via `op:check_persistence`:',
237
+ ' - `executing` → Remind user to call `op:plan_reconcile`.',
238
+ ' - `reconciling` → Remind user to call `op:plan_complete_lifecycle`.',
239
+ '',
240
+ '### Context Compaction',
241
+ '',
242
+ 'A PreCompact hook calls `op:session_capture` before context compaction.',
243
+ 'Manual capture: `op:session_capture params:{ summary: "..." }`',
244
+ '',
245
+ `<!-- /${ENGINE_MARKER} -->`,
246
+ ];
204
247
  //# sourceMappingURL=shared-rules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-rules.js","sourceRoot":"","sources":["../../src/templ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IACjG,wEAAwE;IACxE,6DAA6D;IAC7D,wEAAwE;IACxE,EAAE;IACF,wBAAwB;IACxB,EAAE;IACF,yEAAyE;IACzE,gEAAgE;IAChE,EAAE;IAEF,SAAS,aAAa,MAAM;CAC7B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soleri/forge",
3
- "version": "5.14.0",
3
+ "version": "5.14.1",
4
4
  "description": "Scaffold AI agents that learn, remember, and grow with you.",
5
5
  "keywords": [
6
6
  "agent",
package/src/lib.ts CHANGED
@@ -21,3 +21,4 @@ export type {
21
21
  export { AgentConfigSchema, SETUP_TARGETS } from './types.js';
22
22
  export { generateExtensionsIndex, generateExampleOp } from './templates/extensions.js';
23
23
  export { generateClaudeMdTemplate } from './templates/claude-md-template.js';
24
+ export { getEngineRulesContent, getEngineMarker } from './templates/shared-rules.js';
@@ -1,18 +1,19 @@
1
1
  import type { AgentConfig } from '../types.js';
2
- import { getSharedRules } from './shared-rules.js';
2
+ import { getEngineMarker, getEngineRulesContent } from './shared-rules.js';
3
3
 
4
4
  /**
5
5
  * Generates src/activation/claude-md-content.ts for a new agent.
6
6
  *
7
- * Architecture:
8
- * 1. Agent-specific identity (persona, domains, principles)
9
- * 2. Session start protocol
10
- * 3. Curated facade table (~30 key ops, grouped by category)
11
- * 4. Shared behavioral rules (vault-first, planning, output formatting)
12
- * 5. Hook packs (conditional)
7
+ * Architecture (split injection):
8
+ * 1. Engine rules — shared, prefix-free, injected once under `<!-- soleri:engine-rules -->`
9
+ * 2. Agent block — lightweight, agent-specific, under `<!-- agent-id:mode -->`
10
+ * - Identity (persona, domains, principles)
11
+ * - Session start protocol
12
+ * - Curated facade table (~30 key ops, grouped by category)
13
+ * - Hook packs (conditional)
13
14
  *
14
- * Full op list is always available via `admin_tool_list` no need to
15
- * enumerate all 145+ ops in CLAUDE.md.
15
+ * The facade table maps `op:name` actual `agentId_core op:name` tool calls.
16
+ * Full op list is always available via `admin_tool_list`.
16
17
  */
17
18
  export function generateClaudeMdTemplate(config: AgentConfig): string {
18
19
  const toolPrefix = config.id;
@@ -87,9 +88,6 @@ export function generateClaudeMdTemplate(config: AgentConfig): string {
87
88
 
88
89
  mdLines.push('', `> Full list: ${bt}${toolPrefix}_core op:admin_tool_list${bt}`, '');
89
90
 
90
- // ─── Shared Behavioral Rules ───────────────────────────
91
- mdLines.push(...getSharedRules(toolPrefix));
92
-
93
91
  // ─── Hook Packs (conditional) ──────────────────────────
94
92
  appendHookPacks(mdLines, config);
95
93
 
@@ -102,11 +100,20 @@ export function generateClaudeMdTemplate(config: AgentConfig): string {
102
100
  return ` '${escaped}',`;
103
101
  });
104
102
 
103
+ // Generate engine rules as a quoted string literal
104
+ const engineContent = getEngineRulesContent();
105
+ const engineQuotedLines = engineContent.split('\n').map((line) => {
106
+ const escaped = line.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
107
+ return ` '${escaped}',`;
108
+ });
109
+
105
110
  return [
106
111
  '/**',
107
112
  ` * CLAUDE.md content for ${config.name}.`,
108
113
  ' * Generated by Soleri — do not edit manually.',
109
114
  ' */',
115
+ '',
116
+ '/** Agent-specific block (identity + activation + facade table). */',
110
117
  'export function getClaudeMdContent(): string {',
111
118
  ' return [',
112
119
  ...quotedLines,
@@ -116,6 +123,17 @@ export function generateClaudeMdTemplate(config: AgentConfig): string {
116
123
  'export function getClaudeMdMarker(): string {',
117
124
  ` return '${marker}';`,
118
125
  '}',
126
+ '',
127
+ '/** Shared engine rules — injected once, skipped if already present. */',
128
+ 'export function getEngineRulesContent(): string {',
129
+ ' return [',
130
+ ...engineQuotedLines,
131
+ " ].join('\\n');",
132
+ '}',
133
+ '',
134
+ 'export function getEngineRulesMarker(): string {',
135
+ ` return '${getEngineMarker()}';`,
136
+ '}',
119
137
  ].join('\n');
120
138
  }
121
139