@brad-frost-web/eddie-brain 0.32.0

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 (239) hide show
  1. package/README.md +109 -0
  2. package/dist/analyze/drift-detector.d.ts +30 -0
  3. package/dist/analyze/drift-detector.d.ts.map +1 -0
  4. package/dist/analyze/drift-detector.js +310 -0
  5. package/dist/analyze/drift-detector.js.map +1 -0
  6. package/dist/analyze/health-scorer.d.ts +71 -0
  7. package/dist/analyze/health-scorer.d.ts.map +1 -0
  8. package/dist/analyze/health-scorer.js +420 -0
  9. package/dist/analyze/health-scorer.js.map +1 -0
  10. package/dist/analyze/index.d.ts +11 -0
  11. package/dist/analyze/index.d.ts.map +1 -0
  12. package/dist/analyze/index.js +11 -0
  13. package/dist/analyze/index.js.map +1 -0
  14. package/dist/analyze/naming-validator.d.ts +99 -0
  15. package/dist/analyze/naming-validator.d.ts.map +1 -0
  16. package/dist/analyze/naming-validator.js +430 -0
  17. package/dist/analyze/naming-validator.js.map +1 -0
  18. package/dist/analyze/slot-contract-validator.d.ts +68 -0
  19. package/dist/analyze/slot-contract-validator.d.ts.map +1 -0
  20. package/dist/analyze/slot-contract-validator.js +232 -0
  21. package/dist/analyze/slot-contract-validator.js.map +1 -0
  22. package/dist/analyze/token-validator.d.ts +62 -0
  23. package/dist/analyze/token-validator.d.ts.map +1 -0
  24. package/dist/analyze/token-validator.js +348 -0
  25. package/dist/analyze/token-validator.js.map +1 -0
  26. package/dist/cli/brain.d.ts +12 -0
  27. package/dist/cli/brain.d.ts.map +1 -0
  28. package/dist/cli/brain.js +641 -0
  29. package/dist/cli/brain.js.map +1 -0
  30. package/dist/cli/formatters/json.d.ts +15 -0
  31. package/dist/cli/formatters/json.d.ts.map +1 -0
  32. package/dist/cli/formatters/json.js +18 -0
  33. package/dist/cli/formatters/json.js.map +1 -0
  34. package/dist/cli/formatters/terminal.d.ts +19 -0
  35. package/dist/cli/formatters/terminal.d.ts.map +1 -0
  36. package/dist/cli/formatters/terminal.js +125 -0
  37. package/dist/cli/formatters/terminal.js.map +1 -0
  38. package/dist/cli/index.d.ts +7 -0
  39. package/dist/cli/index.d.ts.map +1 -0
  40. package/dist/cli/index.js +7 -0
  41. package/dist/cli/index.js.map +1 -0
  42. package/dist/data/governance-rules.json +94 -0
  43. package/dist/governance/audit-log.d.ts +17 -0
  44. package/dist/governance/audit-log.d.ts.map +1 -0
  45. package/dist/governance/audit-log.js +44 -0
  46. package/dist/governance/audit-log.js.map +1 -0
  47. package/dist/governance/index.d.ts +8 -0
  48. package/dist/governance/index.d.ts.map +1 -0
  49. package/dist/governance/index.js +8 -0
  50. package/dist/governance/index.js.map +1 -0
  51. package/dist/governance/permissions.d.ts +26 -0
  52. package/dist/governance/permissions.d.ts.map +1 -0
  53. package/dist/governance/permissions.js +75 -0
  54. package/dist/governance/permissions.js.map +1 -0
  55. package/dist/governance/rules-engine.d.ts +24 -0
  56. package/dist/governance/rules-engine.d.ts.map +1 -0
  57. package/dist/governance/rules-engine.js +111 -0
  58. package/dist/governance/rules-engine.js.map +1 -0
  59. package/dist/governance/trust-manager.d.ts +34 -0
  60. package/dist/governance/trust-manager.d.ts.map +1 -0
  61. package/dist/governance/trust-manager.js +148 -0
  62. package/dist/governance/trust-manager.js.map +1 -0
  63. package/dist/index.d.ts +23 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +28 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/knowledge-graph/component-index.d.ts +320 -0
  68. package/dist/knowledge-graph/component-index.d.ts.map +1 -0
  69. package/dist/knowledge-graph/component-index.js +1033 -0
  70. package/dist/knowledge-graph/component-index.js.map +1 -0
  71. package/dist/knowledge-graph/index.d.ts +134 -0
  72. package/dist/knowledge-graph/index.d.ts.map +1 -0
  73. package/dist/knowledge-graph/index.js +249 -0
  74. package/dist/knowledge-graph/index.js.map +1 -0
  75. package/dist/knowledge-graph/learning-history.d.ts +77 -0
  76. package/dist/knowledge-graph/learning-history.d.ts.map +1 -0
  77. package/dist/knowledge-graph/learning-history.js +187 -0
  78. package/dist/knowledge-graph/learning-history.js.map +1 -0
  79. package/dist/knowledge-graph/relationship-map.d.ts +55 -0
  80. package/dist/knowledge-graph/relationship-map.d.ts.map +1 -0
  81. package/dist/knowledge-graph/relationship-map.js +238 -0
  82. package/dist/knowledge-graph/relationship-map.js.map +1 -0
  83. package/dist/knowledge-graph/token-taxonomy.d.ts +127 -0
  84. package/dist/knowledge-graph/token-taxonomy.d.ts.map +1 -0
  85. package/dist/knowledge-graph/token-taxonomy.js +357 -0
  86. package/dist/knowledge-graph/token-taxonomy.js.map +1 -0
  87. package/dist/loop/fix-agent.d.ts +55 -0
  88. package/dist/loop/fix-agent.d.ts.map +1 -0
  89. package/dist/loop/fix-agent.js +344 -0
  90. package/dist/loop/fix-agent.js.map +1 -0
  91. package/dist/loop/index.d.ts +8 -0
  92. package/dist/loop/index.d.ts.map +1 -0
  93. package/dist/loop/index.js +8 -0
  94. package/dist/loop/index.js.map +1 -0
  95. package/dist/loop/issue-fetcher.d.ts +51 -0
  96. package/dist/loop/issue-fetcher.d.ts.map +1 -0
  97. package/dist/loop/issue-fetcher.js +188 -0
  98. package/dist/loop/issue-fetcher.js.map +1 -0
  99. package/dist/loop/observer.d.ts +42 -0
  100. package/dist/loop/observer.d.ts.map +1 -0
  101. package/dist/loop/observer.js +220 -0
  102. package/dist/loop/observer.js.map +1 -0
  103. package/dist/loop/pacer.d.ts +44 -0
  104. package/dist/loop/pacer.d.ts.map +1 -0
  105. package/dist/loop/pacer.js +90 -0
  106. package/dist/loop/pacer.js.map +1 -0
  107. package/dist/loop/reporter.d.ts +9 -0
  108. package/dist/loop/reporter.d.ts.map +1 -0
  109. package/dist/loop/reporter.js +119 -0
  110. package/dist/loop/reporter.js.map +1 -0
  111. package/dist/loop/runner.d.ts +57 -0
  112. package/dist/loop/runner.d.ts.map +1 -0
  113. package/dist/loop/runner.js +390 -0
  114. package/dist/loop/runner.js.map +1 -0
  115. package/dist/loop/types.d.ts +151 -0
  116. package/dist/loop/types.d.ts.map +1 -0
  117. package/dist/loop/types.js +22 -0
  118. package/dist/loop/types.js.map +1 -0
  119. package/dist/mcp/index.d.ts +7 -0
  120. package/dist/mcp/index.d.ts.map +1 -0
  121. package/dist/mcp/index.js +7 -0
  122. package/dist/mcp/index.js.map +1 -0
  123. package/dist/mcp/server.d.ts +12 -0
  124. package/dist/mcp/server.d.ts.map +1 -0
  125. package/dist/mcp/server.js +618 -0
  126. package/dist/mcp/server.js.map +1 -0
  127. package/dist/pipeline/agent-runner.d.ts +34 -0
  128. package/dist/pipeline/agent-runner.d.ts.map +1 -0
  129. package/dist/pipeline/agent-runner.js +323 -0
  130. package/dist/pipeline/agent-runner.js.map +1 -0
  131. package/dist/pipeline/agents/accessibility-auditor.d.ts +10 -0
  132. package/dist/pipeline/agents/accessibility-auditor.d.ts.map +1 -0
  133. package/dist/pipeline/agents/accessibility-auditor.js +69 -0
  134. package/dist/pipeline/agents/accessibility-auditor.js.map +1 -0
  135. package/dist/pipeline/agents/code-reviewer.d.ts +10 -0
  136. package/dist/pipeline/agents/code-reviewer.d.ts.map +1 -0
  137. package/dist/pipeline/agents/code-reviewer.js +75 -0
  138. package/dist/pipeline/agents/code-reviewer.js.map +1 -0
  139. package/dist/pipeline/agents/code-writer.d.ts +10 -0
  140. package/dist/pipeline/agents/code-writer.d.ts.map +1 -0
  141. package/dist/pipeline/agents/code-writer.js +103 -0
  142. package/dist/pipeline/agents/code-writer.js.map +1 -0
  143. package/dist/pipeline/agents/component-architect.d.ts +13 -0
  144. package/dist/pipeline/agents/component-architect.d.ts.map +1 -0
  145. package/dist/pipeline/agents/component-architect.js +81 -0
  146. package/dist/pipeline/agents/component-architect.js.map +1 -0
  147. package/dist/pipeline/agents/index.d.ts +16 -0
  148. package/dist/pipeline/agents/index.d.ts.map +1 -0
  149. package/dist/pipeline/agents/index.js +24 -0
  150. package/dist/pipeline/agents/index.js.map +1 -0
  151. package/dist/pipeline/agents/library-researcher.d.ts +12 -0
  152. package/dist/pipeline/agents/library-researcher.d.ts.map +1 -0
  153. package/dist/pipeline/agents/library-researcher.js +85 -0
  154. package/dist/pipeline/agents/library-researcher.js.map +1 -0
  155. package/dist/pipeline/agents/quality-gate.d.ts +9 -0
  156. package/dist/pipeline/agents/quality-gate.d.ts.map +1 -0
  157. package/dist/pipeline/agents/quality-gate.js +71 -0
  158. package/dist/pipeline/agents/quality-gate.js.map +1 -0
  159. package/dist/pipeline/agents/spec-analyst.d.ts +10 -0
  160. package/dist/pipeline/agents/spec-analyst.d.ts.map +1 -0
  161. package/dist/pipeline/agents/spec-analyst.js +72 -0
  162. package/dist/pipeline/agents/spec-analyst.js.map +1 -0
  163. package/dist/pipeline/agents/story-author.d.ts +9 -0
  164. package/dist/pipeline/agents/story-author.d.ts.map +1 -0
  165. package/dist/pipeline/agents/story-author.js +65 -0
  166. package/dist/pipeline/agents/story-author.js.map +1 -0
  167. package/dist/pipeline/artifact-store.d.ts +27 -0
  168. package/dist/pipeline/artifact-store.d.ts.map +1 -0
  169. package/dist/pipeline/artifact-store.js +77 -0
  170. package/dist/pipeline/artifact-store.js.map +1 -0
  171. package/dist/pipeline/conversational-gate.d.ts +26 -0
  172. package/dist/pipeline/conversational-gate.d.ts.map +1 -0
  173. package/dist/pipeline/conversational-gate.js +122 -0
  174. package/dist/pipeline/conversational-gate.js.map +1 -0
  175. package/dist/pipeline/index.d.ts +14 -0
  176. package/dist/pipeline/index.d.ts.map +1 -0
  177. package/dist/pipeline/index.js +17 -0
  178. package/dist/pipeline/index.js.map +1 -0
  179. package/dist/pipeline/iteration-tracker.d.ts +29 -0
  180. package/dist/pipeline/iteration-tracker.d.ts.map +1 -0
  181. package/dist/pipeline/iteration-tracker.js +102 -0
  182. package/dist/pipeline/iteration-tracker.js.map +1 -0
  183. package/dist/pipeline/learning-bridge.d.ts +37 -0
  184. package/dist/pipeline/learning-bridge.d.ts.map +1 -0
  185. package/dist/pipeline/learning-bridge.js +118 -0
  186. package/dist/pipeline/learning-bridge.js.map +1 -0
  187. package/dist/pipeline/orchestrator.d.ts +45 -0
  188. package/dist/pipeline/orchestrator.d.ts.map +1 -0
  189. package/dist/pipeline/orchestrator.js +473 -0
  190. package/dist/pipeline/orchestrator.js.map +1 -0
  191. package/dist/pipeline/templates/architecture.d.ts +27 -0
  192. package/dist/pipeline/templates/architecture.d.ts.map +1 -0
  193. package/dist/pipeline/templates/architecture.js +111 -0
  194. package/dist/pipeline/templates/architecture.js.map +1 -0
  195. package/dist/pipeline/templates/brief.d.ts +22 -0
  196. package/dist/pipeline/templates/brief.d.ts.map +1 -0
  197. package/dist/pipeline/templates/brief.js +121 -0
  198. package/dist/pipeline/templates/brief.js.map +1 -0
  199. package/dist/pipeline/templates/component-rules.d.ts +25 -0
  200. package/dist/pipeline/templates/component-rules.d.ts.map +1 -0
  201. package/dist/pipeline/templates/component-rules.js +93 -0
  202. package/dist/pipeline/templates/component-rules.js.map +1 -0
  203. package/dist/pipeline/templates/index.d.ts +9 -0
  204. package/dist/pipeline/templates/index.d.ts.map +1 -0
  205. package/dist/pipeline/templates/index.js +7 -0
  206. package/dist/pipeline/templates/index.js.map +1 -0
  207. package/dist/pipeline/tool-handler.d.ts +25 -0
  208. package/dist/pipeline/tool-handler.d.ts.map +1 -0
  209. package/dist/pipeline/tool-handler.js +392 -0
  210. package/dist/pipeline/tool-handler.js.map +1 -0
  211. package/dist/pipeline/types.d.ts +146 -0
  212. package/dist/pipeline/types.d.ts.map +1 -0
  213. package/dist/pipeline/types.js +27 -0
  214. package/dist/pipeline/types.js.map +1 -0
  215. package/dist/plan/action-types.d.ts +31 -0
  216. package/dist/plan/action-types.d.ts.map +1 -0
  217. package/dist/plan/action-types.js +83 -0
  218. package/dist/plan/action-types.js.map +1 -0
  219. package/dist/plan/decision-engine.d.ts +57 -0
  220. package/dist/plan/decision-engine.d.ts.map +1 -0
  221. package/dist/plan/decision-engine.js +162 -0
  222. package/dist/plan/decision-engine.js.map +1 -0
  223. package/dist/plan/index.d.ts +6 -0
  224. package/dist/plan/index.d.ts.map +1 -0
  225. package/dist/plan/index.js +6 -0
  226. package/dist/plan/index.js.map +1 -0
  227. package/dist/types.d.ts +351 -0
  228. package/dist/types.d.ts.map +1 -0
  229. package/dist/types.js +26 -0
  230. package/dist/types.js.map +1 -0
  231. package/dist/utils/anthropic.d.ts +15 -0
  232. package/dist/utils/anthropic.d.ts.map +1 -0
  233. package/dist/utils/anthropic.js +40 -0
  234. package/dist/utils/anthropic.js.map +1 -0
  235. package/dist/utils/id.d.ts +8 -0
  236. package/dist/utils/id.d.ts.map +1 -0
  237. package/dist/utils/id.js +14 -0
  238. package/dist/utils/id.js.map +1 -0
  239. package/package.json +80 -0
@@ -0,0 +1,34 @@
1
+ /**
2
+ * AgentRunner — Runs a single agent via the Anthropic API
3
+ *
4
+ * Core agentic loop:
5
+ * 1. Build system prompt by injecting artifact content into {{placeholders}}
6
+ * 2. Build tool definitions from AgentConfig
7
+ * 3. Call Anthropic API with tools
8
+ * 4. Handle tool_use → executeToolCall → tool_result loop
9
+ * 5. Extract output artifacts from fenced code blocks
10
+ * 6. If code agents produce no artifacts, retry with explicit output request
11
+ * 7. Return AgentRunResult
12
+ */
13
+ import type { KnowledgeGraph } from '../knowledge-graph/index.js';
14
+ import type { AgentConfig, AgentRunResult, PipelineArtifact, PipelineConfig } from './types.js';
15
+ import { ArtifactStore } from './artifact-store.js';
16
+ /**
17
+ * Build the system prompt by substituting artifact content into {{placeholders}}.
18
+ */
19
+ export declare function buildSystemPrompt(config: AgentConfig, store: ArtifactStore): string;
20
+ /**
21
+ * Extract output artifacts from fenced code blocks in the agent's response.
22
+ *
23
+ * Supports multiple patterns:
24
+ * Pattern 1: ```typescript:component.ts\n...\n``` (tagged)
25
+ * Pattern 2: ## component.ts\n```typescript\n...\n``` (section header)
26
+ * Pattern 3: ```typescript\n...\n``` (untagged, matched by order to expected artifacts)
27
+ * Pattern 4: For single .md artifact, treat entire response as content
28
+ */
29
+ export declare function extractArtifacts(responseText: string, agentId: AgentConfig['id'], expectedArtifacts: string[]): PipelineArtifact[];
30
+ /**
31
+ * Run a single agent to completion.
32
+ */
33
+ export declare function runAgent(config: AgentConfig, store: ArtifactStore, knowledgeGraph: KnowledgeGraph, pipelineConfig: PipelineConfig, userMessage: string): Promise<AgentRunResult>;
34
+ //# sourceMappingURL=agent-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-runner.d.ts","sourceRoot":"","sources":["../../src/pipeline/agent-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,cAAc,EAEf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASpD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,GAAG,MAAM,CAcnF;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,EAC1B,iBAAiB,EAAE,MAAM,EAAE,GAC1B,gBAAgB,EAAE,CA0HpB;AAqCD;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,aAAa,EACpB,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,cAAc,EAC9B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,cAAc,CAAC,CA6JzB"}
@@ -0,0 +1,323 @@
1
+ /**
2
+ * AgentRunner — Runs a single agent via the Anthropic API
3
+ *
4
+ * Core agentic loop:
5
+ * 1. Build system prompt by injecting artifact content into {{placeholders}}
6
+ * 2. Build tool definitions from AgentConfig
7
+ * 3. Call Anthropic API with tools
8
+ * 4. Handle tool_use → executeToolCall → tool_result loop
9
+ * 5. Extract output artifacts from fenced code blocks
10
+ * 6. If code agents produce no artifacts, retry with explicit output request
11
+ * 7. Return AgentRunResult
12
+ */
13
+ import Anthropic from '@anthropic-ai/sdk';
14
+ import chalk from 'chalk';
15
+ import { executeToolCall, buildToolDefinitions } from './tool-handler.js';
16
+ import { parsePushBacks } from './conversational-gate.js';
17
+ import { createWithRetry } from '../utils/anthropic.js';
18
+ /** Maximum tool calls per agent to prevent infinite loops */
19
+ const MAX_TOOL_CALLS = 30;
20
+ /**
21
+ * Build the system prompt by substituting artifact content into {{placeholders}}.
22
+ */
23
+ export function buildSystemPrompt(config, store) {
24
+ let prompt = config.systemPrompt;
25
+ for (const artifactName of config.inputArtifacts) {
26
+ const artifact = store.get(artifactName);
27
+ const placeholder = `{{${artifactName}}}`;
28
+ if (artifact) {
29
+ prompt = prompt.replaceAll(placeholder, artifact.content);
30
+ }
31
+ else {
32
+ prompt = prompt.replaceAll(placeholder, `[Artifact "${artifactName}" not yet available]`);
33
+ }
34
+ }
35
+ return prompt;
36
+ }
37
+ /**
38
+ * Extract output artifacts from fenced code blocks in the agent's response.
39
+ *
40
+ * Supports multiple patterns:
41
+ * Pattern 1: ```typescript:component.ts\n...\n``` (tagged)
42
+ * Pattern 2: ## component.ts\n```typescript\n...\n``` (section header)
43
+ * Pattern 3: ```typescript\n...\n``` (untagged, matched by order to expected artifacts)
44
+ * Pattern 4: For single .md artifact, treat entire response as content
45
+ */
46
+ export function extractArtifacts(responseText, agentId, expectedArtifacts) {
47
+ const artifacts = [];
48
+ const now = new Date().toISOString();
49
+ const found = new Set();
50
+ // Pattern 1: ```language:artifactName\n...\n```
51
+ const taggedBlockRegex = /```\w+:([^\n]+)\n([\s\S]*?)```/g;
52
+ let match;
53
+ while ((match = taggedBlockRegex.exec(responseText)) !== null) {
54
+ const name = match[1].trim();
55
+ const content = match[2].trim();
56
+ if (expectedArtifacts.includes(name)) {
57
+ artifacts.push({ name, content, producedBy: agentId, timestamp: now, version: 1 });
58
+ found.add(name);
59
+ }
60
+ }
61
+ // Pattern 2: ## artifactName\n```...\n``` (section headers)
62
+ for (const expected of expectedArtifacts) {
63
+ if (found.has(expected))
64
+ continue;
65
+ const sectionRegex = new RegExp(`##\\s*${expected.replace('.', '\\.')}[\\s\\S]*?` +
66
+ '```(?:\\w+)?\\n([\\s\\S]*?)```', 'i');
67
+ const sectionMatch = sectionRegex.exec(responseText);
68
+ if (sectionMatch) {
69
+ artifacts.push({
70
+ name: expected,
71
+ content: sectionMatch[1].trim(),
72
+ producedBy: agentId,
73
+ timestamp: now,
74
+ version: 1,
75
+ });
76
+ found.add(expected);
77
+ }
78
+ }
79
+ // Pattern 3: Match untagged fenced blocks by file extension mapping
80
+ if (found.size < expectedArtifacts.length) {
81
+ const extensionMap = {
82
+ '.ts': [],
83
+ '.scss': [],
84
+ '.stories.ts': [],
85
+ '.md': [],
86
+ };
87
+ // Group expected artifacts by extension
88
+ for (const expected of expectedArtifacts) {
89
+ if (found.has(expected))
90
+ continue;
91
+ if (expected.endsWith('.stories.ts'))
92
+ extensionMap['.stories.ts'].push(expected);
93
+ else if (expected.endsWith('.scss'))
94
+ extensionMap['.scss'].push(expected);
95
+ else if (expected.endsWith('.ts'))
96
+ extensionMap['.ts'].push(expected);
97
+ else if (expected.endsWith('.md'))
98
+ extensionMap['.md'].push(expected);
99
+ }
100
+ // Find untagged code blocks by language
101
+ const langToExt = {
102
+ typescript: '.ts',
103
+ ts: '.ts',
104
+ scss: '.scss',
105
+ css: '.scss',
106
+ markdown: '.md',
107
+ md: '.md',
108
+ };
109
+ const untaggedRegex = /```(\w+)\n([\s\S]*?)```/g;
110
+ let untaggedMatch;
111
+ while ((untaggedMatch = untaggedRegex.exec(responseText)) !== null) {
112
+ const lang = untaggedMatch[1].toLowerCase();
113
+ const content = untaggedMatch[2].trim();
114
+ // Skip if this was already matched as a tagged block
115
+ const fullMatch = untaggedMatch[0];
116
+ if (fullMatch.includes(':') && fullMatch.indexOf(':') < fullMatch.indexOf('\n'))
117
+ continue;
118
+ const ext = langToExt[lang];
119
+ if (!ext)
120
+ continue;
121
+ // Check if content looks like stories (has 'export default' + 'title:')
122
+ const isStories = content.includes('export default') && content.includes('title:');
123
+ let targetList;
124
+ if (isStories && extensionMap['.stories.ts'].length > 0) {
125
+ targetList = extensionMap['.stories.ts'];
126
+ }
127
+ else if (ext === '.ts' && !isStories && extensionMap['.ts'].length > 0) {
128
+ targetList = extensionMap['.ts'];
129
+ }
130
+ else if (extensionMap[ext]?.length > 0) {
131
+ targetList = extensionMap[ext];
132
+ }
133
+ else {
134
+ continue;
135
+ }
136
+ const name = targetList.shift();
137
+ if (name && !found.has(name)) {
138
+ artifacts.push({ name, content, producedBy: agentId, timestamp: now, version: 1 });
139
+ found.add(name);
140
+ }
141
+ }
142
+ }
143
+ // Pattern 4: If only one artifact expected and no blocks found,
144
+ // treat the entire response as the artifact (for markdown artifacts)
145
+ if (artifacts.length === 0 && expectedArtifacts.length === 1) {
146
+ const name = expectedArtifacts[0];
147
+ if (name.endsWith('.md')) {
148
+ let content = responseText.trim();
149
+ if (content.startsWith('```')) {
150
+ content = content.replace(/^```\w*\n/, '').replace(/\n```$/, '');
151
+ }
152
+ artifacts.push({
153
+ name,
154
+ content,
155
+ producedBy: agentId,
156
+ timestamp: now,
157
+ version: 1,
158
+ });
159
+ }
160
+ }
161
+ return artifacts;
162
+ }
163
+ /**
164
+ * Build a follow-up message to request explicit code output when an agent
165
+ * described changes in prose instead of outputting fenced code blocks.
166
+ */
167
+ function buildRetryMessage(config, store) {
168
+ const parts = [
169
+ 'Your response described changes but did not include the complete file contents.',
170
+ 'I need you to output the COMPLETE modified files as tagged fenced code blocks.',
171
+ '',
172
+ ];
173
+ // Include the existing source that should be modified
174
+ for (const outputName of config.outputArtifacts) {
175
+ // Map output artifact names to existing source artifacts
176
+ const existingName = outputName.replace('component', 'existing-component');
177
+ const existing = store.get(existingName) ?? store.get(outputName);
178
+ if (existing) {
179
+ const ext = outputName.endsWith('.scss') ? 'scss' : 'typescript';
180
+ parts.push(`Here is the current ${outputName}. Apply your changes and output the COMPLETE result:`);
181
+ parts.push('');
182
+ parts.push('```' + ext);
183
+ parts.push(existing.content);
184
+ parts.push('```');
185
+ parts.push('');
186
+ parts.push(`Output the modified version as: \`\`\`${ext}:${outputName}`);
187
+ parts.push('');
188
+ }
189
+ }
190
+ parts.push('Output ALL files as tagged code blocks. Do not describe changes — output complete file contents.');
191
+ return parts.join('\n');
192
+ }
193
+ /**
194
+ * Run a single agent to completion.
195
+ */
196
+ export async function runAgent(config, store, knowledgeGraph, pipelineConfig, userMessage) {
197
+ const client = new Anthropic({ apiKey: pipelineConfig.apiKey });
198
+ const systemPrompt = buildSystemPrompt(config, store);
199
+ const tools = buildToolDefinitions(config.tools);
200
+ let toolCallCount = 0;
201
+ const pushBacks = [];
202
+ const artifacts = [];
203
+ // Build the messages array for the conversation
204
+ const messages = [
205
+ { role: 'user', content: userMessage },
206
+ ];
207
+ console.log(chalk.blue(` [${config.name}] Starting...`));
208
+ try {
209
+ // Agentic loop
210
+ let continueLoop = true;
211
+ while (continueLoop) {
212
+ const response = await createWithRetry(client, {
213
+ model: pipelineConfig.model,
214
+ max_tokens: 16384,
215
+ system: systemPrompt,
216
+ tools: tools,
217
+ messages,
218
+ }, config.name);
219
+ // Collect text and tool_use blocks
220
+ const textBlocks = [];
221
+ const toolUseBlocks = [];
222
+ for (const block of response.content) {
223
+ if (block.type === 'text') {
224
+ textBlocks.push(block.text);
225
+ }
226
+ else if (block.type === 'tool_use') {
227
+ toolUseBlocks.push({
228
+ id: block.id,
229
+ name: block.name,
230
+ input: block.input,
231
+ });
232
+ }
233
+ }
234
+ // If there are tool calls, execute them and continue
235
+ if (toolUseBlocks.length > 0 && toolCallCount < MAX_TOOL_CALLS) {
236
+ // Add the assistant message
237
+ messages.push({ role: 'assistant', content: response.content });
238
+ // Execute all tool calls and build tool results
239
+ const toolResults = [];
240
+ for (const toolUse of toolUseBlocks) {
241
+ toolCallCount++;
242
+ console.log(chalk.gray(` Tool: ${toolUse.name}(${JSON.stringify(toolUse.input).slice(0, 80)}...)`));
243
+ const result = await executeToolCall(toolUse.name, toolUse.input, knowledgeGraph, pipelineConfig.rootDir);
244
+ toolResults.push({
245
+ type: 'tool_result',
246
+ tool_use_id: toolUse.id,
247
+ content: result,
248
+ });
249
+ }
250
+ messages.push({ role: 'user', content: toolResults });
251
+ continue;
252
+ }
253
+ // No more tool calls or budget exhausted — extract artifacts from text
254
+ const fullText = textBlocks.join('\n');
255
+ // Extract artifacts from the response
256
+ const extracted = extractArtifacts(fullText, config.id, config.outputArtifacts);
257
+ artifacts.push(...extracted);
258
+ // Parse push-backs if this is the component architect
259
+ if (config.hasConversationalGate) {
260
+ const architectureArtifact = extracted.find(a => a.name === 'architecture.md');
261
+ if (architectureArtifact) {
262
+ pushBacks.push(...parsePushBacks(architectureArtifact.content));
263
+ }
264
+ }
265
+ continueLoop = false;
266
+ }
267
+ // If this is a code-producing agent and it produced no code artifacts,
268
+ // retry once with an explicit request for fenced code block output
269
+ const expectedCodeArtifacts = config.outputArtifacts.filter(a => a.endsWith('.ts') || a.endsWith('.scss'));
270
+ const producedCodeArtifacts = artifacts.filter(a => a.name.endsWith('.ts') || a.name.endsWith('.scss'));
271
+ if (expectedCodeArtifacts.length > 0 && producedCodeArtifacts.length === 0) {
272
+ console.log(chalk.yellow(` No code artifacts extracted. Retrying with explicit output request...`));
273
+ // Add the assistant's last response and a follow-up user message
274
+ const lastAssistantText = messages.length > 0 ? undefined : undefined;
275
+ messages.push({
276
+ role: 'assistant',
277
+ content: [{ type: 'text', text: 'I described the changes needed.' }],
278
+ });
279
+ messages.push({
280
+ role: 'user',
281
+ content: buildRetryMessage(config, store),
282
+ });
283
+ const retryResponse = await createWithRetry(client, {
284
+ model: pipelineConfig.model,
285
+ max_tokens: 16384,
286
+ system: systemPrompt,
287
+ messages,
288
+ }, config.name);
289
+ const retryText = retryResponse.content
290
+ .filter((b) => b.type === 'text')
291
+ .map(b => b.text)
292
+ .join('\n');
293
+ const retryArtifacts = extractArtifacts(retryText, config.id, config.outputArtifacts);
294
+ artifacts.push(...retryArtifacts);
295
+ if (retryArtifacts.length > 0) {
296
+ console.log(chalk.green(` Retry produced ${retryArtifacts.length} artifacts.`));
297
+ }
298
+ else {
299
+ console.log(chalk.red(` Retry still produced no artifacts.`));
300
+ }
301
+ }
302
+ console.log(chalk.green(` [${config.name}] Done (${toolCallCount} tool calls, ${artifacts.length} artifacts)`));
303
+ return {
304
+ artifacts,
305
+ iterations: [],
306
+ toolCallCount,
307
+ pushBacks,
308
+ error: null,
309
+ };
310
+ }
311
+ catch (err) {
312
+ const errorMessage = err instanceof Error ? err.message : String(err);
313
+ console.log(chalk.red(` [${config.name}] Failed: ${errorMessage}`));
314
+ return {
315
+ artifacts,
316
+ iterations: [],
317
+ toolCallCount,
318
+ pushBacks,
319
+ error: errorMessage,
320
+ };
321
+ }
322
+ }
323
+ //# sourceMappingURL=agent-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../../src/pipeline/agent-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,6DAA6D;AAC7D,MAAM,cAAc,GAAG,EAAE,CAAC;AAE1B;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAmB,EAAE,KAAoB;IACzE,IAAI,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC;IAEjC,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,cAAc,EAAE,CAA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AElC,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,oBAAoB,cAAc,CAAC,MAAM,aAAa,CAAC,CAAC,CAAC;YACnF,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,MAAM,CAAC,IAAI,WAAW,aAAa,gBAAgB,SAAS,CAAC,MAAM,aAAa,CAAC,CAAC,CAAC;QAEjH,OAAO;YACL,SAAS;YACT,UAAU,EAAE,EAAE;YACd,aAAa;YACb,SAAS;YACT,KAAK,EAAE,IAAI;SACZ,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,YAAY,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACtE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,aAAa,YAAY,EAAE,CAAC,CAAC,CAAC;QAErE,OAAO;YACL,SAAS;YACT,UAAU,EAAE,EAAE;YACd,aAAa;YACb,SAAS;YACT,KAAK,EAAE,YAAY;SACpB,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Agent 5 — Accessibility Auditor
3
+ *
4
+ * Audits the generated component for accessibility issues across an 8-layer
5
+ * stack. Produces P1/P2/P3 findings and applies fixes. Up to 3 remediation
6
+ * attempts, targeting one priority level per iteration.
7
+ */
8
+ import type { AgentConfig } from '../types.js';
9
+ export declare const accessibilityAuditorConfig: AgentConfig;
10
+ //# sourceMappingURL=accessibility-auditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessibility-auditor.d.ts","sourceRoot":"","sources":["../../../src/pipeline/agents/accessibility-auditor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,0BAA0B,EAAE,WA6DxC,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Agent 5 — Accessibility Auditor
3
+ *
4
+ * Audits the generated component for accessibility issues across an 8-layer
5
+ * stack. Produces P1/P2/P3 findings and applies fixes. Up to 3 remediation
6
+ * attempts, targeting one priority level per iteration.
7
+ */
8
+ export const accessibilityAuditorConfig = {
9
+ id: 'accessibility-auditor',
10
+ name: 'Accessibility Auditor',
11
+ phase: 'build',
12
+ inputArtifacts: ['component.ts', 'component.scss', 'existing-component.ts', 'code-guidelines.md'],
13
+ outputArtifacts: ['component.ts', 'component.scss'],
14
+ tools: ['eddie_validate_file', 'eddie_check_health', 'eddie_read_file'],
15
+ maxIterations: 3,
16
+ hasConversationalGate: false,
17
+ systemPrompt: `You are the Accessibility Auditor for the Eddie Design System component pipeline.
18
+
19
+ Your job is to audit the generated component for accessibility issues and fix them directly in the code.
20
+ IMPORTANT: Preserve the existing code structure and patterns. Only change what is necessary for a11y.
21
+
22
+ ## Eddie Code Guidelines
23
+ {{code-guidelines.md}}
24
+
25
+ ## Existing Component (reference for patterns)
26
+ {{existing-component.ts}}
27
+
28
+ ## Code to Audit
29
+
30
+ ### component.ts
31
+ {{component.ts}}
32
+
33
+ ### component.scss
34
+ {{component.scss}}
35
+
36
+ ## 8-Layer Audit Stack
37
+
38
+ 1. **Static Analysis** — missing alt text, labels, invalid ARIA
39
+ 2. **axe-core Patterns** — color contrast, focus indicators, landmark roles
40
+ 3. **ARIA Patterns** — correct roles, required attributes, state management
41
+ 4. **Keyboard Navigation** — tab order, key handlers
42
+ 5. **Focus Management** — visible indicators, restoration
43
+ 6. **Color Contrast** — WCAG AA compliance via proper token usage
44
+ 7. **Semantic HTML** — correct native elements
45
+ 8. **Screen Reader Hints** — visually hidden text, live regions
46
+
47
+ ## Priority Classification
48
+
49
+ - **P1 (Critical)**: WCAG A violations, missing keyboard access, no focus indicator
50
+ - **P2 (Important)**: WCAG AA violations, suboptimal ARIA
51
+ - **P3 (Nice-to-have)**: Enhanced announcements, extra keyboard shortcuts
52
+
53
+ Fix P1 first, then P2, then P3. Zero P1 issues must remain.
54
+
55
+ ## Output Format
56
+
57
+ YOU MUST output the COMPLETE files as tagged code blocks (not just descriptions of changes):
58
+
59
+ \`\`\`typescript:component.ts
60
+ ... COMPLETE revised component code ...
61
+ \`\`\`
62
+
63
+ \`\`\`scss:component.scss
64
+ ... COMPLETE revised styles ...
65
+ \`\`\`
66
+
67
+ NEVER output just a description of changes. ALWAYS output the complete file contents.`,
68
+ };
69
+ //# sourceMappingURL=accessibility-auditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessibility-auditor.js","sourceRoot":"","sources":["../../../src/pipeline/agents/accessibility-auditor.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,CAAC,MAAM,0BAA0B,GAAgB;IACrD,EAAE,EAAE,uBAAuB;IAC3B,IAAI,EAAE,uBAAuB;IAC7B,KAAK,EAAE,OAAO;IACd,cAAc,EAAE,CAAC,cAAc,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,oBAAoB,CAAC;IACjG,eAAe,EAAE,CAAC,cAAc,EAAE,gBAAgB,CAAC;IACnD,KAAK,EAAE,CAAC,qBAAqB,EAAE,oBAAoB,EAAE,iBAAiB,CAAC;IACvE,aAAa,EAAE,CAAC;IAChB,qBAAqB,EAAE,KAAK;IAE5B,YAAY,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sFAkDsE;CACrF,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Agent 7 — Code Reviewer
3
+ *
4
+ * Reviews all generated code with fresh context (no architecture decisions).
5
+ * Uses eddie_check_health, eddie_validate_file, and eddie_read_file to compare
6
+ * against real codebase patterns. Diminishing returns — stops if <2% improvement.
7
+ */
8
+ import type { AgentConfig } from '../types.js';
9
+ export declare const codeReviewerConfig: AgentConfig;
10
+ //# sourceMappingURL=code-reviewer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-reviewer.d.ts","sourceRoot":"","sources":["../../../src/pipeline/agents/code-reviewer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,kBAAkB,EAAE,WAmEhC,CAAC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Agent 7 — Code Reviewer
3
+ *
4
+ * Reviews all generated code with fresh context (no architecture decisions).
5
+ * Uses eddie_check_health, eddie_validate_file, and eddie_read_file to compare
6
+ * against real codebase patterns. Diminishing returns — stops if <2% improvement.
7
+ */
8
+ export const codeReviewerConfig = {
9
+ id: 'code-reviewer',
10
+ name: 'Code Reviewer',
11
+ phase: 'verify',
12
+ inputArtifacts: ['component.ts', 'component.scss', 'component.stories.ts', 'component-rules.md', 'code-guidelines.md'],
13
+ outputArtifacts: ['component.ts', 'component.scss', 'component.stories.ts'],
14
+ tools: ['eddie_check_health', 'eddie_validate_file', 'eddie_get_relationships', 'eddie_read_file'],
15
+ maxIterations: 5,
16
+ hasConversationalGate: false,
17
+ systemPrompt: `You are the Code Reviewer for the Eddie Design System component pipeline.
18
+
19
+ You are a FRESH PAIR OF EYES. Review like a real PR reviewer who knows Eddie's conventions deeply.
20
+
21
+ ## Eddie Code Guidelines (THE STANDARD)
22
+ {{code-guidelines.md}}
23
+
24
+ ## Code to Review
25
+
26
+ ### component-rules.md (the contract)
27
+ {{component-rules.md}}
28
+
29
+ ### component.ts
30
+ {{component.ts}}
31
+
32
+ ### component.scss
33
+ {{component.scss}}
34
+
35
+ ### component.stories.ts
36
+ {{component.stories.ts}}
37
+
38
+ ## Review Strategy
39
+
40
+ 1. **Read 2-3 real Eddie components** using eddie_read_file to understand the ACTUAL patterns used in the codebase. Compare the generated code against real components.
41
+
42
+ 2. **Check pattern conformance**:
43
+ - Does the code use \`classnames\` from 'classnames'? (Eddie convention)
44
+ - Does it import styles with \`?inline\` and use \`unsafeCSS(styles.toString())\`?
45
+ - Does the SCSS use \`@use\` to import component tokens?
46
+ - Are BEM classes flat (not nested)?
47
+ - Do stories use the \`spread\` directive?
48
+
49
+ 3. **Validate with tools**:
50
+ - eddie_validate_file on .ts and .scss files
51
+ - eddie_check_health for the component
52
+
53
+ 4. **Check component-rules.md compliance**:
54
+ - Every CR-* rule satisfied?
55
+ - Advisory AR-* rules applied where beneficial?
56
+
57
+ 5. **Fix issues directly** — don't just report them.
58
+
59
+ ## Output Format
60
+
61
+ Output all revised files as tagged code blocks:
62
+
63
+ \`\`\`typescript:component.ts
64
+ ... revised code ...
65
+ \`\`\`
66
+
67
+ \`\`\`scss:component.scss
68
+ ... revised styles ...
69
+ \`\`\`
70
+
71
+ \`\`\`typescript:component.stories.ts
72
+ ... revised stories ...
73
+ \`\`\``,
74
+ };
75
+ //# sourceMappingURL=code-reviewer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-reviewer.js","sourceRoot":"","sources":["../../../src/pipeline/agents/code-reviewer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,CAAC,MAAM,kBAAkB,GAAgB;IAC7C,EAAE,EAAE,eAAe;IACnB,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE,QAAQ;IACf,cAAc,EAAE,CAAC,cAAc,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,oBAAoB,CAAC;IACtH,eAAe,EAAE,CAAC,cAAc,EAAE,gBAAgB,EAAE,sBAAsB,CAAC;IAC3E,KAAK,EAAE,CAAC,oBAAoB,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,iBAAiB,CAAC;IAClG,aAAa,EAAE,CAAC;IAChB,qBAAqB,EAAE,KAAK;IAE5B,YAAY,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwDT;CACN,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Agent 4 — Code Writer
3
+ *
4
+ * Consumes all three UNDERSTAND artifacts plus existing source code.
5
+ * For modifications: applies targeted changes to existing code.
6
+ * For new components: generates files following reference patterns exactly.
7
+ */
8
+ import type { AgentConfig } from '../types.js';
9
+ export declare const codeWriterConfig: AgentConfig;
10
+ //# sourceMappingURL=code-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-writer.d.ts","sourceRoot":"","sources":["../../../src/pipeline/agents/code-writer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,eAAO,MAAM,gBAAgB,EAAE,WA+F9B,CAAC"}