@telora/factory 0.4.5

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 (301) hide show
  1. package/dist/audit.d.ts +69 -0
  2. package/dist/audit.d.ts.map +1 -0
  3. package/dist/audit.js +376 -0
  4. package/dist/audit.js.map +1 -0
  5. package/dist/builder-completion.d.ts +35 -0
  6. package/dist/builder-completion.d.ts.map +1 -0
  7. package/dist/builder-completion.js +375 -0
  8. package/dist/builder-completion.js.map +1 -0
  9. package/dist/builder-spawner.d.ts +40 -0
  10. package/dist/builder-spawner.d.ts.map +1 -0
  11. package/dist/builder-spawner.js +493 -0
  12. package/dist/builder-spawner.js.map +1 -0
  13. package/dist/completion-gate.d.ts +52 -0
  14. package/dist/completion-gate.d.ts.map +1 -0
  15. package/dist/completion-gate.js +336 -0
  16. package/dist/completion-gate.js.map +1 -0
  17. package/dist/completion-report.d.ts +36 -0
  18. package/dist/completion-report.d.ts.map +1 -0
  19. package/dist/completion-report.js +348 -0
  20. package/dist/completion-report.js.map +1 -0
  21. package/dist/completion.d.ts +58 -0
  22. package/dist/completion.d.ts.map +1 -0
  23. package/dist/completion.js +287 -0
  24. package/dist/completion.js.map +1 -0
  25. package/dist/config.d.ts +16 -0
  26. package/dist/config.d.ts.map +1 -0
  27. package/dist/config.js +57 -0
  28. package/dist/config.js.map +1 -0
  29. package/dist/context-manager.d.ts +152 -0
  30. package/dist/context-manager.d.ts.map +1 -0
  31. package/dist/context-manager.js +421 -0
  32. package/dist/context-manager.js.map +1 -0
  33. package/dist/crash-detection.d.ts +70 -0
  34. package/dist/crash-detection.d.ts.map +1 -0
  35. package/dist/crash-detection.js +123 -0
  36. package/dist/crash-detection.js.map +1 -0
  37. package/dist/crash-recovery.d.ts +83 -0
  38. package/dist/crash-recovery.d.ts.map +1 -0
  39. package/dist/crash-recovery.js +522 -0
  40. package/dist/crash-recovery.js.map +1 -0
  41. package/dist/crash-resolution.d.ts +34 -0
  42. package/dist/crash-resolution.d.ts.map +1 -0
  43. package/dist/crash-resolution.js +382 -0
  44. package/dist/crash-resolution.js.map +1 -0
  45. package/dist/escalation.d.ts +150 -0
  46. package/dist/escalation.d.ts.map +1 -0
  47. package/dist/escalation.js +352 -0
  48. package/dist/escalation.js.map +1 -0
  49. package/dist/execution-target.d.ts +31 -0
  50. package/dist/execution-target.d.ts.map +1 -0
  51. package/dist/execution-target.js +71 -0
  52. package/dist/execution-target.js.map +1 -0
  53. package/dist/execution-unit-init.d.ts +28 -0
  54. package/dist/execution-unit-init.d.ts.map +1 -0
  55. package/dist/execution-unit-init.js +115 -0
  56. package/dist/execution-unit-init.js.map +1 -0
  57. package/dist/execution.d.ts +17 -0
  58. package/dist/execution.d.ts.map +1 -0
  59. package/dist/execution.js +20 -0
  60. package/dist/execution.js.map +1 -0
  61. package/dist/factory-engine.d.ts +100 -0
  62. package/dist/factory-engine.d.ts.map +1 -0
  63. package/dist/factory-engine.js +243 -0
  64. package/dist/factory-engine.js.map +1 -0
  65. package/dist/gap-detection.d.ts +43 -0
  66. package/dist/gap-detection.d.ts.map +1 -0
  67. package/dist/gap-detection.js +149 -0
  68. package/dist/gap-detection.js.map +1 -0
  69. package/dist/gate-context.d.ts +23 -0
  70. package/dist/gate-context.d.ts.map +1 -0
  71. package/dist/gate-context.js +63 -0
  72. package/dist/gate-context.js.map +1 -0
  73. package/dist/gate-engine.d.ts +55 -0
  74. package/dist/gate-engine.d.ts.map +1 -0
  75. package/dist/gate-engine.js +191 -0
  76. package/dist/gate-engine.js.map +1 -0
  77. package/dist/gates/adversarial.d.ts +59 -0
  78. package/dist/gates/adversarial.d.ts.map +1 -0
  79. package/dist/gates/adversarial.js +426 -0
  80. package/dist/gates/adversarial.js.map +1 -0
  81. package/dist/gates/adversary-spawner.d.ts +35 -0
  82. package/dist/gates/adversary-spawner.d.ts.map +1 -0
  83. package/dist/gates/adversary-spawner.js +286 -0
  84. package/dist/gates/adversary-spawner.js.map +1 -0
  85. package/dist/gates/adversary-test-dir.d.ts +41 -0
  86. package/dist/gates/adversary-test-dir.d.ts.map +1 -0
  87. package/dist/gates/adversary-test-dir.js +150 -0
  88. package/dist/gates/adversary-test-dir.js.map +1 -0
  89. package/dist/gates/behavioral-parser.d.ts +32 -0
  90. package/dist/gates/behavioral-parser.d.ts.map +1 -0
  91. package/dist/gates/behavioral-parser.js +190 -0
  92. package/dist/gates/behavioral-parser.js.map +1 -0
  93. package/dist/gates/behavioral-runner.d.ts +36 -0
  94. package/dist/gates/behavioral-runner.d.ts.map +1 -0
  95. package/dist/gates/behavioral-runner.js +306 -0
  96. package/dist/gates/behavioral-runner.js.map +1 -0
  97. package/dist/gates/behavioral.d.ts +37 -0
  98. package/dist/gates/behavioral.d.ts.map +1 -0
  99. package/dist/gates/behavioral.js +485 -0
  100. package/dist/gates/behavioral.js.map +1 -0
  101. package/dist/gates/deterministic.d.ts +24 -0
  102. package/dist/gates/deterministic.d.ts.map +1 -0
  103. package/dist/gates/deterministic.js +186 -0
  104. package/dist/gates/deterministic.js.map +1 -0
  105. package/dist/git-factory.d.ts +59 -0
  106. package/dist/git-factory.d.ts.map +1 -0
  107. package/dist/git-factory.js +102 -0
  108. package/dist/git-factory.js.map +1 -0
  109. package/dist/guard-evaluation.d.ts +48 -0
  110. package/dist/guard-evaluation.d.ts.map +1 -0
  111. package/dist/guard-evaluation.js +416 -0
  112. package/dist/guard-evaluation.js.map +1 -0
  113. package/dist/index.d.ts +30 -0
  114. package/dist/index.d.ts.map +1 -0
  115. package/dist/index.js +39 -0
  116. package/dist/index.js.map +1 -0
  117. package/dist/instance-completion.d.ts +34 -0
  118. package/dist/instance-completion.d.ts.map +1 -0
  119. package/dist/instance-completion.js +366 -0
  120. package/dist/instance-completion.js.map +1 -0
  121. package/dist/instance-lifecycle.d.ts +15 -0
  122. package/dist/instance-lifecycle.d.ts.map +1 -0
  123. package/dist/instance-lifecycle.js +18 -0
  124. package/dist/instance-lifecycle.js.map +1 -0
  125. package/dist/instance-phase-dispatch.d.ts +75 -0
  126. package/dist/instance-phase-dispatch.d.ts.map +1 -0
  127. package/dist/instance-phase-dispatch.js +674 -0
  128. package/dist/instance-phase-dispatch.js.map +1 -0
  129. package/dist/instance-poll-loop.d.ts +43 -0
  130. package/dist/instance-poll-loop.d.ts.map +1 -0
  131. package/dist/instance-poll-loop.js +360 -0
  132. package/dist/instance-poll-loop.js.map +1 -0
  133. package/dist/instance-state-machine.d.ts +52 -0
  134. package/dist/instance-state-machine.d.ts.map +1 -0
  135. package/dist/instance-state-machine.js +235 -0
  136. package/dist/instance-state-machine.js.map +1 -0
  137. package/dist/log-manager.d.ts +28 -0
  138. package/dist/log-manager.d.ts.map +1 -0
  139. package/dist/log-manager.js +71 -0
  140. package/dist/log-manager.js.map +1 -0
  141. package/dist/pipeline-evaluator.d.ts +61 -0
  142. package/dist/pipeline-evaluator.d.ts.map +1 -0
  143. package/dist/pipeline-evaluator.js +107 -0
  144. package/dist/pipeline-evaluator.js.map +1 -0
  145. package/dist/pipeline-metrics.d.ts +52 -0
  146. package/dist/pipeline-metrics.d.ts.map +1 -0
  147. package/dist/pipeline-metrics.js +40 -0
  148. package/dist/pipeline-metrics.js.map +1 -0
  149. package/dist/pipeline-traversal.d.ts +43 -0
  150. package/dist/pipeline-traversal.d.ts.map +1 -0
  151. package/dist/pipeline-traversal.js +68 -0
  152. package/dist/pipeline-traversal.js.map +1 -0
  153. package/dist/plan-parser.d.ts +76 -0
  154. package/dist/plan-parser.d.ts.map +1 -0
  155. package/dist/plan-parser.js +223 -0
  156. package/dist/plan-parser.js.map +1 -0
  157. package/dist/planning-phase.d.ts +52 -0
  158. package/dist/planning-phase.d.ts.map +1 -0
  159. package/dist/planning-phase.js +444 -0
  160. package/dist/planning-phase.js.map +1 -0
  161. package/dist/planning-prompt.d.ts +64 -0
  162. package/dist/planning-prompt.d.ts.map +1 -0
  163. package/dist/planning-prompt.js +251 -0
  164. package/dist/planning-prompt.js.map +1 -0
  165. package/dist/planning.d.ts +16 -0
  166. package/dist/planning.d.ts.map +1 -0
  167. package/dist/planning.js +17 -0
  168. package/dist/planning.js.map +1 -0
  169. package/dist/process-runner.d.ts +41 -0
  170. package/dist/process-runner.d.ts.map +1 -0
  171. package/dist/process-runner.js +81 -0
  172. package/dist/process-runner.js.map +1 -0
  173. package/dist/product-config.d.ts +34 -0
  174. package/dist/product-config.d.ts.map +1 -0
  175. package/dist/product-config.js +43 -0
  176. package/dist/product-config.js.map +1 -0
  177. package/dist/queries/cycle-evaluations.d.ts +23 -0
  178. package/dist/queries/cycle-evaluations.d.ts.map +1 -0
  179. package/dist/queries/cycle-evaluations.js +37 -0
  180. package/dist/queries/cycle-evaluations.js.map +1 -0
  181. package/dist/queries/escalations.d.ts +30 -0
  182. package/dist/queries/escalations.d.ts.map +1 -0
  183. package/dist/queries/escalations.js +42 -0
  184. package/dist/queries/escalations.js.map +1 -0
  185. package/dist/queries/execution-units.d.ts +76 -0
  186. package/dist/queries/execution-units.d.ts.map +1 -0
  187. package/dist/queries/execution-units.js +109 -0
  188. package/dist/queries/execution-units.js.map +1 -0
  189. package/dist/queries/gate-results.d.ts +32 -0
  190. package/dist/queries/gate-results.d.ts.map +1 -0
  191. package/dist/queries/gate-results.js +44 -0
  192. package/dist/queries/gate-results.js.map +1 -0
  193. package/dist/queries/instances.d.ts +51 -0
  194. package/dist/queries/instances.d.ts.map +1 -0
  195. package/dist/queries/instances.js +77 -0
  196. package/dist/queries/instances.js.map +1 -0
  197. package/dist/queries/sessions.d.ts +50 -0
  198. package/dist/queries/sessions.d.ts.map +1 -0
  199. package/dist/queries/sessions.js +81 -0
  200. package/dist/queries/sessions.js.map +1 -0
  201. package/dist/queries/shared.d.ts +38 -0
  202. package/dist/queries/shared.d.ts.map +1 -0
  203. package/dist/queries/shared.js +119 -0
  204. package/dist/queries/shared.js.map +1 -0
  205. package/dist/queries/specs.d.ts +12 -0
  206. package/dist/queries/specs.d.ts.map +1 -0
  207. package/dist/queries/specs.js +21 -0
  208. package/dist/queries/specs.js.map +1 -0
  209. package/dist/queries/strategies.d.ts +14 -0
  210. package/dist/queries/strategies.d.ts.map +1 -0
  211. package/dist/queries/strategies.js +18 -0
  212. package/dist/queries/strategies.js.map +1 -0
  213. package/dist/queries/work-units.d.ts +42 -0
  214. package/dist/queries/work-units.d.ts.map +1 -0
  215. package/dist/queries/work-units.js +57 -0
  216. package/dist/queries/work-units.js.map +1 -0
  217. package/dist/queries/workflows.d.ts +29 -0
  218. package/dist/queries/workflows.d.ts.map +1 -0
  219. package/dist/queries/workflows.js +103 -0
  220. package/dist/queries/workflows.js.map +1 -0
  221. package/dist/remediation-units.d.ts +40 -0
  222. package/dist/remediation-units.d.ts.map +1 -0
  223. package/dist/remediation-units.js +263 -0
  224. package/dist/remediation-units.js.map +1 -0
  225. package/dist/replanning.d.ts +72 -0
  226. package/dist/replanning.d.ts.map +1 -0
  227. package/dist/replanning.js +403 -0
  228. package/dist/replanning.js.map +1 -0
  229. package/dist/resource-limits.d.ts +62 -0
  230. package/dist/resource-limits.d.ts.map +1 -0
  231. package/dist/resource-limits.js +322 -0
  232. package/dist/resource-limits.js.map +1 -0
  233. package/dist/scheduler.d.ts +98 -0
  234. package/dist/scheduler.d.ts.map +1 -0
  235. package/dist/scheduler.js +203 -0
  236. package/dist/scheduler.js.map +1 -0
  237. package/dist/session-adapter.d.ts +89 -0
  238. package/dist/session-adapter.d.ts.map +1 -0
  239. package/dist/session-adapter.js +108 -0
  240. package/dist/session-adapter.js.map +1 -0
  241. package/dist/sop-generator.d.ts +29 -0
  242. package/dist/sop-generator.d.ts.map +1 -0
  243. package/dist/sop-generator.js +235 -0
  244. package/dist/sop-generator.js.map +1 -0
  245. package/dist/spec-profiles.d.ts +41 -0
  246. package/dist/spec-profiles.d.ts.map +1 -0
  247. package/dist/spec-profiles.js +131 -0
  248. package/dist/spec-profiles.js.map +1 -0
  249. package/dist/strategy-design-graph.d.ts +23 -0
  250. package/dist/strategy-design-graph.d.ts.map +1 -0
  251. package/dist/strategy-design-graph.js +205 -0
  252. package/dist/strategy-design-graph.js.map +1 -0
  253. package/dist/strategy-design-prompt.d.ts +28 -0
  254. package/dist/strategy-design-prompt.d.ts.map +1 -0
  255. package/dist/strategy-design-prompt.js +108 -0
  256. package/dist/strategy-design-prompt.js.map +1 -0
  257. package/dist/strategy-design-schema.d.ts +767 -0
  258. package/dist/strategy-design-schema.d.ts.map +1 -0
  259. package/dist/strategy-design-schema.js +126 -0
  260. package/dist/strategy-design-schema.js.map +1 -0
  261. package/dist/strategy-design.d.ts +69 -0
  262. package/dist/strategy-design.d.ts.map +1 -0
  263. package/dist/strategy-design.js +411 -0
  264. package/dist/strategy-design.js.map +1 -0
  265. package/dist/strategy-gating.d.ts +31 -0
  266. package/dist/strategy-gating.d.ts.map +1 -0
  267. package/dist/strategy-gating.js +276 -0
  268. package/dist/strategy-gating.js.map +1 -0
  269. package/dist/team-prompt-builder.d.ts +47 -0
  270. package/dist/team-prompt-builder.d.ts.map +1 -0
  271. package/dist/team-prompt-builder.js +362 -0
  272. package/dist/team-prompt-builder.js.map +1 -0
  273. package/dist/trace-engine.d.ts +40 -0
  274. package/dist/trace-engine.d.ts.map +1 -0
  275. package/dist/trace-engine.js +344 -0
  276. package/dist/trace-engine.js.map +1 -0
  277. package/dist/types.d.ts +612 -0
  278. package/dist/types.d.ts.map +1 -0
  279. package/dist/types.js +9 -0
  280. package/dist/types.js.map +1 -0
  281. package/dist/unit-session-lifecycle.d.ts +78 -0
  282. package/dist/unit-session-lifecycle.d.ts.map +1 -0
  283. package/dist/unit-session-lifecycle.js +141 -0
  284. package/dist/unit-session-lifecycle.js.map +1 -0
  285. package/dist/unit-session.d.ts +30 -0
  286. package/dist/unit-session.d.ts.map +1 -0
  287. package/dist/unit-session.js +370 -0
  288. package/dist/unit-session.js.map +1 -0
  289. package/dist/watchdogs.d.ts +33 -0
  290. package/dist/watchdogs.d.ts.map +1 -0
  291. package/dist/watchdogs.js +170 -0
  292. package/dist/watchdogs.js.map +1 -0
  293. package/dist/work-unit-scheduler.d.ts +34 -0
  294. package/dist/work-unit-scheduler.d.ts.map +1 -0
  295. package/dist/work-unit-scheduler.js +91 -0
  296. package/dist/work-unit-scheduler.js.map +1 -0
  297. package/dist/workflow-transition.d.ts +90 -0
  298. package/dist/workflow-transition.d.ts.map +1 -0
  299. package/dist/workflow-transition.js +340 -0
  300. package/dist/workflow-transition.js.map +1 -0
  301. package/package.json +65 -0
@@ -0,0 +1,251 @@
1
+ /**
2
+ * Planning prompt builders and environment setup.
3
+ *
4
+ * Contains functions that construct the prompts sent to Claude Code for
5
+ * planning sessions, configure the spawning environment, and generate
6
+ * branch names. Split from planning.ts for maintainability.
7
+ */
8
+ import { resolveExecutionProfile } from './spec-profiles.js';
9
+ // ============================================================================
10
+ // Environment builder
11
+ // ============================================================================
12
+ /**
13
+ * Build a clean environment for the planning Claude Code session.
14
+ *
15
+ * Strips inherited CLAUDE_CODE_* and CLAUDECODE env vars to prevent
16
+ * child Claude Code processes from detecting a parent session and hanging.
17
+ * Injects TELORA_TRACKER_ID for the spawned session.
18
+ */
19
+ export function buildPlanningEnv(config) {
20
+ const env = { ...process.env };
21
+ // Strip all Claude Code session markers
22
+ for (const key of Object.keys(env)) {
23
+ if (key === 'CLAUDECODE' || key.startsWith('CLAUDE_CODE_')) {
24
+ delete env[key];
25
+ }
26
+ }
27
+ // Inject tracker ID for the spawned session
28
+ env.TELORA_TRACKER_ID = config.trackerId;
29
+ return env;
30
+ }
31
+ // ============================================================================
32
+ // Branch name generation
33
+ // ============================================================================
34
+ /**
35
+ * Sanitize a blueprint name for use in a git branch name.
36
+ *
37
+ * Replaces non-alphanumeric characters with hyphens, collapses runs of
38
+ * hyphens, and trims leading/trailing hyphens.
39
+ */
40
+ function sanitizeBranchSegment(name) {
41
+ return name
42
+ .toLowerCase()
43
+ .replace(/[^a-z0-9-]/g, '-')
44
+ .replace(/-+/g, '-')
45
+ .replace(/^-|-$/g, '');
46
+ }
47
+ /**
48
+ * Generate a factory branch name from the blueprint name and instance ID.
49
+ *
50
+ * Format: factory/{sanitized-blueprint-name}-{first-8-chars-of-instance-id}
51
+ */
52
+ export function generateBranchName(blueprintName, instanceId) {
53
+ const sanitized = sanitizeBranchSegment(blueprintName);
54
+ const shortId = instanceId.replace(/-/g, '').slice(0, 8);
55
+ return `factory/${sanitized}-${shortId}`;
56
+ }
57
+ // ============================================================================
58
+ // Prompt builder
59
+ // ============================================================================
60
+ /**
61
+ * Build the prompt that instructs Claude Code to generate a work plan.
62
+ *
63
+ * The prompt includes the full factory specification, resource limits from the
64
+ * blueprint, and asks for a structured JSON response matching the WorkPlan schema.
65
+ */
66
+ export function buildPlanningPrompt(specification, blueprint, auditReport, specType, reviewGaps) {
67
+ const parts = [
68
+ 'You are a planning agent for a software factory system.',
69
+ 'Your task is to analyze the following specification and produce a structured work plan.',
70
+ '',
71
+ '## Blueprint',
72
+ `Name: ${blueprint.name}`,
73
+ ];
74
+ if (blueprint.operationalNotes) {
75
+ parts.push('', '## Operational Notes', blueprint.operationalNotes);
76
+ }
77
+ // Inject spec type planning guidance from execution profile
78
+ const profile = resolveExecutionProfile(specType ?? null);
79
+ if (profile.planningGuidance) {
80
+ parts.push('', '## Spec Type', profile.planningGuidance);
81
+ }
82
+ // Inject resource limits so the AI plans within constraints
83
+ const limits = [];
84
+ if (blueprint.maxWorkUnits !== null) {
85
+ limits.push(`- Maximum work units: ${blueprint.maxWorkUnits}`);
86
+ }
87
+ if (blueprint.maxIterationsPerWorkUnit !== null) {
88
+ limits.push(`- Maximum iterations per work unit: ${blueprint.maxIterationsPerWorkUnit}`);
89
+ }
90
+ if (blueprint.maxTokenBudget !== null) {
91
+ limits.push(`- Token budget for entire instance: ${blueprint.maxTokenBudget}`);
92
+ }
93
+ if (blueprint.maxWallClockHours !== null) {
94
+ limits.push(`- Wall-clock time limit: ${blueprint.maxWallClockHours} hours`);
95
+ }
96
+ if (limits.length > 0) {
97
+ parts.push('', '## Resource Limits', ...limits);
98
+ }
99
+ parts.push('', '## Specification', specification);
100
+ // Inject audit results when available (from pre-planning codebase audit)
101
+ if (auditReport) {
102
+ parts.push('', '## Codebase Audit Results', '', 'The following audit was performed against the existing codebase. Use this to avoid duplicating existing work.', '', auditReport, '', 'IMPORTANT:', '- Do NOT create work units for features that are already fully implemented', '- For partial implementations, scope work units to complete only the missing parts', '- If the audit identifies conflicts, include work units to resolve them', '- If the audit shows gaps, these are your primary work units');
103
+ }
104
+ // Inject review gap constraints when re-planning after a review cycle
105
+ if (reviewGaps && reviewGaps.length > 0) {
106
+ const critical = reviewGaps.filter((g) => g.severity === 'critical');
107
+ const important = reviewGaps.filter((g) => g.severity === 'important');
108
+ const gapLines = [
109
+ '## Review Gaps -- Constrained Scope',
110
+ '',
111
+ 'The review phase identified specific gaps. Your work plan MUST be LIMITED to fixing these gaps only.',
112
+ 'Do NOT create work units for features already implemented, add new scope, or work on anything',
113
+ 'not directly related to the gaps listed below.',
114
+ '',
115
+ ];
116
+ if (critical.length > 0) {
117
+ gapLines.push('### Critical gaps (must fix)');
118
+ for (const g of critical) {
119
+ gapLines.push(`- **${g.area}**: ${g.description}`);
120
+ gapLines.push(` Fix: ${g.suggestedFix}`);
121
+ }
122
+ gapLines.push('');
123
+ }
124
+ if (important.length > 0) {
125
+ gapLines.push('### Important gaps (should fix)');
126
+ for (const g of important) {
127
+ gapLines.push(`- **${g.area}**: ${g.description}`);
128
+ gapLines.push(` Fix: ${g.suggestedFix}`);
129
+ }
130
+ gapLines.push('');
131
+ }
132
+ parts.push('', ...gapLines);
133
+ }
134
+ parts.push('', '## Instructions', 'Analyze the specification and break it down into discrete, implementable work units.', '', '### Work Unit Scope', 'Each work unit should represent a distinct functional capability the specification requires.', 'Think of each work unit as a meaningful deliverable -- not as fine-grained as individual tasks or functions,', 'but not as broad as the entire specification.', '', 'Each work unit is something to BUILD -- a functional capability the spec requires.', 'Writing and running tests is a normal part of implementing a feature, not a separate work unit.', 'Do NOT create work units whose sole purpose is to run tests, confirm builds succeed, or verify', 'commands execute. A work unit called "Implement authentication" that includes writing tests is correct.', 'A work unit called "Verify npm test passes" is not a feature -- it is solving for the gate.', '', 'Split into separate work units when:', '- Features are independently useful', '- Components belong to different subsystems (e.g. backend API vs frontend UI)', '- Changes have no shared state or tightly coupled logic', '', 'Combine into a single work unit when:', '- Changes are tightly coupled and must be deployed together', '- Splitting would leave either side in a broken state', '- The scope is small enough to implement as one coherent change', '', 'If the Operational Notes section above provides specific granularity guidance, follow that instead.', '', 'Order work units by dependency -- units that other units depend on should come first.', 'Use the `blockedBy` field to express dependency relationships between work units using tempId references.', '', '### What Belongs in Work Unit Descriptions', 'Work unit descriptions must describe WHAT to build -- the functional capability --', 'not internal naming conventions or implementation details.', '', 'Do NOT include in work unit titles or descriptions:', '- Specific internal method names, private function names, or internal constant names', ' the team should use (e.g. "rename pressDigit to inputDigit", "use PLUS/MINUS constants")', '- Instructions to rename or restructure code to match spec vocabulary when the', ' existing implementation is functionally equivalent', '- Internal naming prescriptions that do not affect the externally observable behavior', '', 'DO include:', '- What the feature does for a user or caller', '- What the external API or interface must expose (exported functions, endpoints, etc.)', '- What behavior or contract must hold', '', 'If the specification or audit report mentions internal naming differences, ignore them.', 'Only create work units for functional gaps or broken external contracts.', '', '## Output Format', 'Return ONLY a JSON object (no markdown fencing, no commentary) with this exact structure:', '```', '{', ' "workUnits": [', ' {', ' "tempId": "wu-0",', ' "title": "Short descriptive title",', ' "description": "Detailed description of what this work unit implements",', ' "sortOrder": 0,', ' "blockedBy": []', ' },', ' {', ' "tempId": "wu-1",', ' "title": "Another work unit",', ' "description": "This depends on wu-0",', ' "sortOrder": 1,', ' "blockedBy": ["wu-0"]', ' }', ' ]', '}', '```', '', 'Rules:', '- Each tempId must be unique (e.g. "wu-0", "wu-1", "wu-2", ...)', '- sortOrder must start at 0 and increment by 1', '- blockedBy must only reference tempIds of other work units in the plan', '- Every work unit must have a non-empty title and description', '- Return at least one work unit');
135
+ if (blueprint.maxWorkUnits !== null) {
136
+ parts.push(`- You MUST produce no more than ${blueprint.maxWorkUnits} work units`);
137
+ }
138
+ parts.push('- Return ONLY the JSON object, nothing else');
139
+ return parts.join('\n');
140
+ }
141
+ /**
142
+ * Build a scoped planning prompt for a single strategy within a larger
143
+ * multi-strategy factory instance.
144
+ *
145
+ * Differs from buildPlanningPrompt() in that it:
146
+ * 1. Frames the role as planning within a bounded strategy scope
147
+ * 2. Includes the strategy's tech context and relevant files
148
+ * 3. Includes interface contracts (what this strategy must produce/consume)
149
+ * 4. Includes dependency context from already-planned upstream strategies
150
+ */
151
+ export function buildScopedPlanningPrompt(strategy, specification, blueprint, auditReport, dependencyContexts, specType) {
152
+ const parts = [
153
+ 'You are a planning agent for a specific strategy within a multi-strategy software factory system.',
154
+ `Your task is to plan work units ONLY within the scope of the "${strategy.name}" strategy.`,
155
+ '',
156
+ '## Strategy Scope',
157
+ `**Name:** ${strategy.name}`,
158
+ ];
159
+ if (strategy.description) {
160
+ parts.push(`**Description:** ${strategy.description}`);
161
+ }
162
+ if (strategy.techContext) {
163
+ parts.push('', '**Technical Context:**', strategy.techContext);
164
+ }
165
+ // Inject spec type planning guidance from execution profile
166
+ const profile = resolveExecutionProfile(specType ?? null);
167
+ if (profile.planningGuidance) {
168
+ parts.push('', '## Spec Type', profile.planningGuidance);
169
+ }
170
+ // Interface contracts
171
+ if (strategy.interfaceContract) {
172
+ const contract = strategy.interfaceContract;
173
+ if (contract.produces.length > 0) {
174
+ parts.push('', '### This Strategy Must Produce');
175
+ for (const item of contract.produces) {
176
+ parts.push(`- [${item.kind}] \`${item.identifier}\`${item.description ? ` -- ${item.description}` : ''}`);
177
+ }
178
+ }
179
+ if (contract.consumes.length > 0) {
180
+ parts.push('', '### This Strategy Consumes (from dependencies)');
181
+ for (const item of contract.consumes) {
182
+ parts.push(`- [${item.kind}] \`${item.identifier}\`${item.description ? ` -- ${item.description}` : ''}`);
183
+ }
184
+ }
185
+ }
186
+ // Dependency context from upstream strategies
187
+ if (dependencyContexts && dependencyContexts.length > 0) {
188
+ parts.push('', '## Upstream Dependencies (already planned)');
189
+ for (const dep of dependencyContexts) {
190
+ parts.push(`### ${dep.strategyName}`);
191
+ if (dep.description) {
192
+ parts.push(dep.description);
193
+ }
194
+ if (dep.produces.length > 0) {
195
+ parts.push('Produces:');
196
+ for (const item of dep.produces) {
197
+ parts.push(`- [${item.kind}] \`${item.identifier}\`${item.description ? ` -- ${item.description}` : ''}`);
198
+ }
199
+ }
200
+ if (dep.workUnitTitles.length > 0) {
201
+ parts.push(`Work units (${dep.workUnitTitles.length}): ${dep.workUnitTitles.join(', ')}`);
202
+ }
203
+ parts.push('');
204
+ }
205
+ }
206
+ parts.push('', '## Blueprint', `Name: ${blueprint.name}`);
207
+ if (blueprint.operationalNotes) {
208
+ parts.push('', '## Operational Notes', blueprint.operationalNotes);
209
+ }
210
+ // Resource limits
211
+ const limits = [];
212
+ if (blueprint.maxWorkUnits !== null) {
213
+ limits.push(`- Maximum work units (entire instance): ${blueprint.maxWorkUnits}`);
214
+ }
215
+ if (blueprint.maxIterationsPerWorkUnit !== null) {
216
+ limits.push(`- Maximum iterations per work unit: ${blueprint.maxIterationsPerWorkUnit}`);
217
+ }
218
+ if (limits.length > 0) {
219
+ parts.push('', '## Resource Limits', ...limits);
220
+ }
221
+ parts.push('', '## Full Specification (for reference)', specification);
222
+ if (auditReport) {
223
+ parts.push('', '## Scoped Codebase Audit Results', '', 'The following audit was performed against the codebase scoped to this strategy.', '', auditReport, '', 'IMPORTANT:', '- Do NOT create work units for features that are already fully implemented', '- For partial implementations, scope work units to complete only the missing parts', '- If the audit identifies conflicts, include work units to resolve them');
224
+ }
225
+ parts.push('', '## Instructions', `Plan work units ONLY for the "${strategy.name}" strategy scope described above.`, 'Do NOT plan work that belongs to other strategies or falls outside this scope.', '', '### Work Unit Scope', 'Each work unit should represent a distinct functional capability the specification requires.', '', 'Each work unit is something to BUILD -- a functional capability the spec requires.', 'Writing and running tests is a normal part of implementing a feature, not a separate work unit.', 'Do NOT create work units whose sole purpose is to run tests, confirm builds succeed, or verify', 'commands execute.', '', 'Split into separate work units when:', '- Features are independently useful', '- Components belong to different subsystems within this strategy', '', 'Combine into a single work unit when:', '- Changes are tightly coupled and must be deployed together', '- The scope is small enough to implement as one coherent change', '', 'If the Operational Notes section above provides specific granularity guidance, follow that instead.', '', 'Order work units by dependency -- units that other units depend on should come first.', 'Use the `blockedBy` field to express dependency relationships between work units using tempId references.', '', '### What Belongs in Work Unit Descriptions', 'Work unit descriptions must describe WHAT to build -- the functional capability --', 'not internal naming conventions or implementation details.', '', 'Do NOT include in work unit titles or descriptions:', '- Specific internal method names, private function names, or internal constant names', ' the team should use (e.g. "rename pressDigit to inputDigit", "use PLUS/MINUS constants")', '- Instructions to rename or restructure code to match spec vocabulary when the', ' existing implementation is functionally equivalent', '- Internal naming prescriptions that do not affect the externally observable behavior', '', 'DO include:', '- What the feature does for a user or caller', '- What the external API or interface must expose (exported functions, endpoints, etc.)', '- What behavior or contract must hold', '', 'If the specification or audit report mentions internal naming differences, ignore them.', 'Only create work units for functional gaps or broken external contracts.', '', '## Output Format', 'Return ONLY a JSON object (no markdown fencing, no commentary) with this exact structure:', '```', '{', ' "workUnits": [', ' {', ' "tempId": "wu-0",', ' "title": "Short descriptive title",', ' "description": "Detailed description of what this work unit implements",', ' "sortOrder": 0,', ' "blockedBy": []', ' }', ' ]', '}', '```', '', 'Rules:', '- Each tempId must be unique (e.g. "wu-0", "wu-1", "wu-2", ...)', '- sortOrder must start at 0 and increment by 1', '- blockedBy must only reference tempIds of other work units in THIS plan', '- Every work unit must have a non-empty title and description', '- Return at least one work unit', '- Return ONLY the JSON object, nothing else');
226
+ return parts.join('\n');
227
+ }
228
+ // ============================================================================
229
+ // Retry feedback prompt builder
230
+ // ============================================================================
231
+ /**
232
+ * Build a retry prompt that includes the original prompt and the validation error.
233
+ *
234
+ * This gives the AI context about what went wrong so it can correct its output
235
+ * on the next attempt.
236
+ */
237
+ export function buildRetryPrompt(originalPrompt, validationError) {
238
+ return [
239
+ originalPrompt,
240
+ '',
241
+ '## RETRY -- Previous Attempt Failed',
242
+ '',
243
+ `Your previous work plan was rejected with the following error:`,
244
+ '',
245
+ validationError,
246
+ '',
247
+ 'Please fix the issue and produce a corrected work plan.',
248
+ 'Return ONLY the JSON object, nothing else.',
249
+ ].join('\n');
250
+ }
251
+ //# sourceMappingURL=planning-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planning-prompt.js","sourceRoot":"","sources":["../src/planning-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAI7D,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAqB;IACpD,MAAM,GAAG,GAAuC,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAEnE,wCAAwC;IACxC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,IAAI,GAAG,KAAK,YAAY,IAAI,GAAG,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;YAC3D,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,4CAA4C;IAC5C,GAAG,CAAC,iBAAiB,GAAG,MAAM,CAAC,SAAS,CAAC;IAEzC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAE/E;;;;;GAKG;AACH,SAAS,qBAAqB,CAAC,IAAY;IACzC,OAAO,IAAI;SACR,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC3B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAA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,IAAI,CAAC,CAAC;AACf,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Factory planning phase -- barrel re-export.
3
+ *
4
+ * The implementation has been split into focused modules:
5
+ * - planning-prompt.ts -- prompt builders, env setup, branch naming
6
+ * - planning-phase.ts -- plan generation/validation, runPlanningPhase orchestrator
7
+ * - plan-parser.ts -- JSON extraction, Zod schema, dependency validation, ID mapping
8
+ *
9
+ * This file preserves the original import path for consumers.
10
+ */
11
+ export { buildPlanningEnv, generateBranchName, buildPlanningPrompt, buildScopedPlanningPrompt, buildRetryPrompt, } from './planning-prompt.js';
12
+ export type { DependencyContext } from './planning-prompt.js';
13
+ export { generateAndValidateWorkPlan, runPlanningPhase, } from './planning-phase.js';
14
+ export type { PlanGenerationResult } from './planning-phase.js';
15
+ export { extractWorkPlanJson, mapTempIdsToUuids, WorkPlanSchema, validateDependencies, } from './plan-parser.js';
16
+ //# sourceMappingURL=planning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planning.d.ts","sourceRoot":"","sources":["../src/planning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAGhE,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,GACrB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Factory planning phase -- barrel re-export.
3
+ *
4
+ * The implementation has been split into focused modules:
5
+ * - planning-prompt.ts -- prompt builders, env setup, branch naming
6
+ * - planning-phase.ts -- plan generation/validation, runPlanningPhase orchestrator
7
+ * - plan-parser.ts -- JSON extraction, Zod schema, dependency validation, ID mapping
8
+ *
9
+ * This file preserves the original import path for consumers.
10
+ */
11
+ // Prompt builders & env
12
+ export { buildPlanningEnv, generateBranchName, buildPlanningPrompt, buildScopedPlanningPrompt, buildRetryPrompt, } from './planning-prompt.js';
13
+ // Plan generation & orchestration
14
+ export { generateAndValidateWorkPlan, runPlanningPhase, } from './planning-phase.js';
15
+ // Plan parsing & validation
16
+ export { extractWorkPlanJson, mapTempIdsToUuids, WorkPlanSchema, validateDependencies, } from './plan-parser.js';
17
+ //# sourceMappingURL=planning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planning.js","sourceRoot":"","sources":["../src/planning.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,wBAAwB;AACxB,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAG9B,kCAAkC;AAClC,OAAO,EACL,2BAA2B,EAC3B,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAG7B,4BAA4B;AAC5B,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,GACrB,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Async Claude Code process runner.
3
+ *
4
+ * Replaces execFileSync for all Claude Code invocations so the Node.js
5
+ * event loop remains unblocked during long-running AI sessions.
6
+ * Unblocked event loop keeps daemon heartbeats alive and allows graceful
7
+ * SIGTERM shutdown while Claude Code is running.
8
+ */
9
+ export interface SpawnAsyncOptions {
10
+ /** Text to write to stdin. */
11
+ input: string;
12
+ /** Encoding for stdout output. */
13
+ encoding: 'utf-8';
14
+ /** Timeout in ms. Undefined or 0 = no limit. */
15
+ timeout?: number;
16
+ /** Working directory for the child process. */
17
+ cwd: string;
18
+ /** Environment variables. */
19
+ env: Record<string, string | undefined>;
20
+ }
21
+ /** Error thrown by spawnAsync on non-zero exit or timeout. */
22
+ export interface SpawnAsyncError extends Error {
23
+ killed?: boolean;
24
+ signal?: string | null;
25
+ status?: number | null;
26
+ stderr?: string;
27
+ stdout?: string;
28
+ }
29
+ /**
30
+ * Async equivalent of execFileSync for one-shot Claude Code invocations.
31
+ *
32
+ * Spawns a child process, writes `input` to stdin, and collects stdout.
33
+ * Resolves with the stdout string when the process exits with code 0.
34
+ * Rejects with a SpawnAsyncError on non-zero exit, timeout, or spawn failure.
35
+ *
36
+ * The error object shape matches what execFileSync throws so existing
37
+ * catch blocks (checking killed, signal, status, stderr) continue to work
38
+ * without modification.
39
+ */
40
+ export declare function spawnAsync(cmd: string, args: string[], options: SpawnAsyncOptions): Promise<string>;
41
+ //# sourceMappingURL=process-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-runner.d.ts","sourceRoot":"","sources":["../src/process-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,MAAM,WAAW,iBAAiB;IAChC,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,GAAG,EAAE,MAAM,CAAC;IACZ,6BAA6B;IAC7B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CACzC;AAED,8DAA8D;AAC9D,MAAM,WAAW,eAAgB,SAAQ,KAAK;IAC5C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,MAAM,CAAC,CAmEjB"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Async Claude Code process runner.
3
+ *
4
+ * Replaces execFileSync for all Claude Code invocations so the Node.js
5
+ * event loop remains unblocked during long-running AI sessions.
6
+ * Unblocked event loop keeps daemon heartbeats alive and allows graceful
7
+ * SIGTERM shutdown while Claude Code is running.
8
+ */
9
+ import { spawn } from 'node:child_process';
10
+ // ============================================================================
11
+ // Implementation
12
+ // ============================================================================
13
+ /**
14
+ * Async equivalent of execFileSync for one-shot Claude Code invocations.
15
+ *
16
+ * Spawns a child process, writes `input` to stdin, and collects stdout.
17
+ * Resolves with the stdout string when the process exits with code 0.
18
+ * Rejects with a SpawnAsyncError on non-zero exit, timeout, or spawn failure.
19
+ *
20
+ * The error object shape matches what execFileSync throws so existing
21
+ * catch blocks (checking killed, signal, status, stderr) continue to work
22
+ * without modification.
23
+ */
24
+ export function spawnAsync(cmd, args, options) {
25
+ return new Promise((resolve, reject) => {
26
+ const child = spawn(cmd, args, {
27
+ cwd: options.cwd,
28
+ env: options.env,
29
+ stdio: ['pipe', 'pipe', 'pipe'],
30
+ });
31
+ const stdoutChunks = [];
32
+ const stderrChunks = [];
33
+ let timedOut = false;
34
+ let timer;
35
+ if (options.timeout && options.timeout > 0) {
36
+ timer = setTimeout(() => {
37
+ timedOut = true;
38
+ child.kill('SIGTERM');
39
+ }, options.timeout);
40
+ }
41
+ child.stdout.on('data', (chunk) => stdoutChunks.push(chunk));
42
+ child.stderr.on('data', (chunk) => stderrChunks.push(chunk));
43
+ // Swallow EPIPE errors — child may exit before reading all stdin
44
+ child.stdin.on('error', () => { });
45
+ child.stdin.write(options.input, 'utf-8', () => {
46
+ child.stdin.end();
47
+ });
48
+ child.on('close', (code, signal) => {
49
+ if (timer)
50
+ clearTimeout(timer);
51
+ const stdout = Buffer.concat(stdoutChunks).toString('utf-8');
52
+ const stderr = Buffer.concat(stderrChunks).toString('utf-8');
53
+ if (timedOut) {
54
+ const err = new Error(`Process timed out`);
55
+ err.killed = true;
56
+ err.signal = 'SIGTERM';
57
+ err.stderr = stderr;
58
+ err.stdout = stdout;
59
+ reject(err);
60
+ return;
61
+ }
62
+ if (code !== 0) {
63
+ const err = new Error(`Command failed: ${cmd} (exit code ${code ?? 'null'})`);
64
+ err.killed = signal !== null;
65
+ err.signal = signal ?? undefined;
66
+ err.status = code ?? undefined;
67
+ err.stderr = stderr;
68
+ err.stdout = stdout;
69
+ reject(err);
70
+ return;
71
+ }
72
+ resolve(stdout);
73
+ });
74
+ child.on('error', (err) => {
75
+ if (timer)
76
+ clearTimeout(timer);
77
+ reject(err);
78
+ });
79
+ });
80
+ }
81
+ //# sourceMappingURL=process-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-runner.js","sourceRoot":"","sources":["../src/process-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AA4B3C,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CACxB,GAAW,EACX,IAAc,EACd,OAA0B;IAE1B,OAAO,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC7C,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE;YAC7B,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,GAAG,EAAE,OAAO,CAAC,GAAwB;YACrC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC;QAEH,MAAM,YAAY,GAAa,EAAE,CAAC;QAClC,MAAM,YAAY,GAAa,EAAE,CAAC;QAClC,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,IAAI,KAAgD,CAAC;QAErD,IAAI,OAAO,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AM,GAAG,IAAI,CAAC;gBAClB,GAAG,CAAC,MAAM,GAAG,SAAS,CAAC;gBACvB,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;gBACpB,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;gBACpB,MAAM,CAAC,GAAG,CAAC,CAAC;gBACZ,OAAO;YACT,CAAC;YAED,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,MAAM,GAAG,GAAG,IAAI,KAAK,CACnB,mBAAmB,GAAG,eAAe,IAAI,IAAI,MAAM,GAAG,CACpC,CAAC;gBACrB,GAAG,CAAC,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;gBAC7B,GAAG,CAAC,MAAM,GAAG,MAAM,IAAI,SAAS,CAAC;gBACjC,GAAG,CAAC,MAAM,GAAG,IAAI,IAAI,SAAS,CAAC;gBAC/B,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;gBACpB,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC;gBACpB,MAAM,CAAC,GAAG,CAAC,CAAC;gBACZ,OAAO;YACT,CAAC;YAED,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAoB,EAAE,EAAE;YACzC,IAAI,KAAK;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;YAC/B,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Multi-product configuration helpers for the factory engine.
3
+ *
4
+ * Separated from config.ts to avoid importing @telora/daemon-core at
5
+ * module level -- the experimental test module mocking in tsx breaks
6
+ * external package resolution when config.ts is transitively loaded.
7
+ */
8
+ import type { FactoryConfig } from './types.js';
9
+ /** Product entry shape (matches ProductEntry from @telora/daemon-core). */
10
+ interface ProductEntry {
11
+ id: string;
12
+ repoPath: string;
13
+ }
14
+ /**
15
+ * Derive a short human-readable label for a product entry.
16
+ * Uses the basename of the product's repoPath (e.g., "/home/user/repos/telora" -> "telora").
17
+ * Falls back to an 8-char ID slice if repoPath is empty.
18
+ */
19
+ export declare function productLabel(product: ProductEntry): string;
20
+ /**
21
+ * Create a product-scoped FactoryConfig by overriding repoPath,
22
+ * factoryWorktreeDir, and logDir to target a specific product's repository.
23
+ *
24
+ * This ensures factory worktrees are created inside the correct product repo
25
+ * rather than always using the first product's paths.
26
+ */
27
+ export declare function configForFactoryProduct(config: FactoryConfig, product: ProductEntry): FactoryConfig;
28
+ /**
29
+ * Look up a ProductEntry by productId from the config's products array.
30
+ * Returns undefined if not found.
31
+ */
32
+ export declare function findFactoryProduct(config: FactoryConfig, productId: string): ProductEntry | undefined;
33
+ export {};
34
+ //# sourceMappingURL=product-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-config.d.ts","sourceRoot":"","sources":["../src/product-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,2EAA2E;AAC3E,UAAU,YAAY;IAAG,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE;AAEvD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAG1D;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,GAAG,aAAa,CAQnG;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAErG"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Multi-product configuration helpers for the factory engine.
3
+ *
4
+ * Separated from config.ts to avoid importing @telora/daemon-core at
5
+ * module level -- the experimental test module mocking in tsx breaks
6
+ * external package resolution when config.ts is transitively loaded.
7
+ */
8
+ import { basename } from 'node:path';
9
+ import { resolve } from 'node:path';
10
+ /**
11
+ * Derive a short human-readable label for a product entry.
12
+ * Uses the basename of the product's repoPath (e.g., "/home/user/repos/telora" -> "telora").
13
+ * Falls back to an 8-char ID slice if repoPath is empty.
14
+ */
15
+ export function productLabel(product) {
16
+ if (product.repoPath)
17
+ return basename(product.repoPath);
18
+ return product.id.slice(0, 8);
19
+ }
20
+ /**
21
+ * Create a product-scoped FactoryConfig by overriding repoPath,
22
+ * factoryWorktreeDir, and logDir to target a specific product's repository.
23
+ *
24
+ * This ensures factory worktrees are created inside the correct product repo
25
+ * rather than always using the first product's paths.
26
+ */
27
+ export function configForFactoryProduct(config, product) {
28
+ return {
29
+ ...config,
30
+ productId: product.id,
31
+ repoPath: product.repoPath,
32
+ factoryWorktreeDir: resolve(product.repoPath, '.telora', 'factory-worktrees'),
33
+ logDir: resolve(product.repoPath, '.telora', 'factory-logs'),
34
+ };
35
+ }
36
+ /**
37
+ * Look up a ProductEntry by productId from the config's products array.
38
+ * Returns undefined if not found.
39
+ */
40
+ export function findFactoryProduct(config, productId) {
41
+ return config.products.find(p => p.id === productId);
42
+ }
43
+ //# sourceMappingURL=product-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-config.js","sourceRoot":"","sources":["../src/product-config.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,OAAqB;IAChD,IAAI,OAAO,CAAC,QAAQ;QAAE,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACxD,OAAO,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAqB,EAAE,OAAqB;IAClF,OAAO;QACL,GAAG,MAAM;QACT,SAAS,EAAE,OAAO,CAAC,EAAE;QACrB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,kBAAkB,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,mBAAmB,CAAC;QAC7E,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,EAAE,cAAc,CAAC;KAC7D,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAqB,EAAE,SAAiB;IACzE,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Factory cycle evaluation queries.
3
+ *
4
+ * Provides read and insert operations for factory_cycle_evaluations table.
5
+ */
6
+ import type { CompletionGateResult, FactoryCycleEvaluation } from '../types.js';
7
+ /**
8
+ * Retrieve all cycle evaluations for a factory instance, ordered by cycle_number ASC.
9
+ *
10
+ * @param instanceId - The factory instance ID
11
+ * @returns Array of cycle evaluation records
12
+ */
13
+ export declare function getCycleEvaluations(instanceId: string): Promise<FactoryCycleEvaluation[]>;
14
+ /**
15
+ * Persist a completion gate evaluation result to factory_cycle_evaluations.
16
+ *
17
+ * @param instanceId - The factory instance ID
18
+ * @param cycleNumber - Which iteration cycle this evaluation belongs to
19
+ * @param result - The CompletionGateResult to persist
20
+ * @returns The created cycle evaluation record
21
+ */
22
+ export declare function createCycleEvaluation(instanceId: string, cycleNumber: number, result: CompletionGateResult): Promise<FactoryCycleEvaluation>;
23
+ //# sourceMappingURL=cycle-evaluations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cycle-evaluations.d.ts","sourceRoot":"","sources":["../../src/queries/cycle-evaluations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEhF;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,sBAAsB,EAAE,CAAC,CAMnC;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,sBAAsB,CAAC,CAcjC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Factory cycle evaluation queries.
3
+ *
4
+ * Provides read and insert operations for factory_cycle_evaluations table.
5
+ */
6
+ import { callApi } from './shared.js';
7
+ /**
8
+ * Retrieve all cycle evaluations for a factory instance, ordered by cycle_number ASC.
9
+ *
10
+ * @param instanceId - The factory instance ID
11
+ * @returns Array of cycle evaluation records
12
+ */
13
+ export async function getCycleEvaluations(instanceId) {
14
+ const result = await callApi('factory_get_cycle_evaluations', { instanceId });
15
+ return result.cycleEvaluations || [];
16
+ }
17
+ /**
18
+ * Persist a completion gate evaluation result to factory_cycle_evaluations.
19
+ *
20
+ * @param instanceId - The factory instance ID
21
+ * @param cycleNumber - Which iteration cycle this evaluation belongs to
22
+ * @param result - The CompletionGateResult to persist
23
+ * @returns The created cycle evaluation record
24
+ */
25
+ export async function createCycleEvaluation(instanceId, cycleNumber, result) {
26
+ const response = await callApi('factory_create_cycle_evaluation', {
27
+ instanceId,
28
+ cycleNumber,
29
+ passed: result.passed,
30
+ confidence: result.confidence,
31
+ summary: result.summary,
32
+ gaps: result.gaps,
33
+ suggestions: result.suggestions,
34
+ });
35
+ return response.cycleEvaluation;
36
+ }
37
+ //# sourceMappingURL=cycle-evaluations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cycle-evaluations.js","sourceRoot":"","sources":["../../src/queries/cycle-evaluations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,UAAkB;IAElB,MAAM,MAAM,GAAG,MAAM,OAAO,CAC1B,+BAA+B,EAC/B,EAAE,UAAU,EAAE,CACf,CAAC;IACF,OAAO,MAAM,CAAC,gBAAgB,IAAI,EAAE,CAAC;AACvC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,UAAkB,EAClB,WAAmB,EACnB,MAA4B;IAE5B,MAAM,QAAQ,GAAG,MAAM,OAAO,CAC5B,iCAAiC,EACjC;QACE,UAAU;QACV,WAAW;QACX,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CACF,CAAC;IACF,OAAO,QAAQ,CAAC,eAAe,CAAC;AAClC,CAAC"}