swarm-orchestrator 7.0.0-alpha.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 (174) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +199 -0
  3. package/agents/reviewer.agent.md +50 -0
  4. package/agents/worker.agent.md +41 -0
  5. package/config/default-agents.yaml +56 -0
  6. package/config/pm-agent.yaml +36 -0
  7. package/config/quality-gates.yaml +88 -0
  8. package/config/repair-agent.yaml +34 -0
  9. package/config/semgrep-rules/complexity-mismatch.yaml +6 -0
  10. package/config/semgrep-rules/exception-swallowing.yaml +13 -0
  11. package/config/semgrep-rules/hardcoded-answer.yaml +6 -0
  12. package/config/semgrep-rules/mock-mutation.yaml +6 -0
  13. package/config/semgrep-rules/test-modification.yaml +6 -0
  14. package/config/user-agents.yaml +23 -0
  15. package/dist/src/adapters/adapter-factory.js +29 -0
  16. package/dist/src/adapters/agent-adapter.js +32 -0
  17. package/dist/src/adapters/claude-code-adapter.js +126 -0
  18. package/dist/src/adapters/claude-code-teams.js +119 -0
  19. package/dist/src/adapters/codex-adapter.js +118 -0
  20. package/dist/src/adapters/copilot-adapter.js +224 -0
  21. package/dist/src/adapters/fatal-error-classifier.js +88 -0
  22. package/dist/src/adapters/index.js +44 -0
  23. package/dist/src/adapters/persistent-session.js +204 -0
  24. package/dist/src/adapters/process-supervisor.js +199 -0
  25. package/dist/src/agents-exporter.js +398 -0
  26. package/dist/src/analytics-log.js +161 -0
  27. package/dist/src/baseline-scanner.js +65 -0
  28. package/dist/src/bootstrap-evidence.js +88 -0
  29. package/dist/src/bootstrap-orchestrator.js +205 -0
  30. package/dist/src/bootstrap-types.js +5 -0
  31. package/dist/src/branch-merger.js +427 -0
  32. package/dist/src/cli/attest-handlers.js +44 -0
  33. package/dist/src/cli/cost-prompt.js +51 -0
  34. package/dist/src/cli/demo-handlers.js +274 -0
  35. package/dist/src/cli/flags.js +152 -0
  36. package/dist/src/cli/index.js +57 -0
  37. package/dist/src/cli/live-status.js +186 -0
  38. package/dist/src/cli/misc-handlers.js +242 -0
  39. package/dist/src/cli/plan-handlers.js +350 -0
  40. package/dist/src/cli/share-handlers.js +163 -0
  41. package/dist/src/cli/status-handlers.js +457 -0
  42. package/dist/src/cli/swarm-handlers.js +638 -0
  43. package/dist/src/cli/usage.js +72 -0
  44. package/dist/src/cli.js +217 -0
  45. package/dist/src/commit-pattern-detector.js +143 -0
  46. package/dist/src/commit-quality-analyzer.js +38 -0
  47. package/dist/src/config-loader.js +339 -0
  48. package/dist/src/context-broker.js +358 -0
  49. package/dist/src/copilot-cli-wrapper.js +258 -0
  50. package/dist/src/cost-estimator.js +241 -0
  51. package/dist/src/defaults.js +18 -0
  52. package/dist/src/demo-mode.js +180 -0
  53. package/dist/src/deployment-handler.js +78 -0
  54. package/dist/src/deployment-manager.js +228 -0
  55. package/dist/src/execution-queue.js +196 -0
  56. package/dist/src/external-tool-manager.js +184 -0
  57. package/dist/src/gate-prompt-builder.js +117 -0
  58. package/dist/src/gate-remediation.js +173 -0
  59. package/dist/src/github-issues-ingester.js +152 -0
  60. package/dist/src/github-mcp-integrator.js +164 -0
  61. package/dist/src/hook-generator.js +229 -0
  62. package/dist/src/index.js +48 -0
  63. package/dist/src/knowledge-base.js +300 -0
  64. package/dist/src/logger.js +111 -0
  65. package/dist/src/meta-analyzer.js +208 -0
  66. package/dist/src/metrics-collector.js +209 -0
  67. package/dist/src/metrics-types.js +5 -0
  68. package/dist/src/multi-repo-coordinator.js +179 -0
  69. package/dist/src/orchestrator/async-meta-analysis.js +84 -0
  70. package/dist/src/orchestrator/fatal-run-error.js +43 -0
  71. package/dist/src/orchestrator/final-gates-remediation.js +258 -0
  72. package/dist/src/orchestrator/git-state-utils.js +119 -0
  73. package/dist/src/orchestrator/pause-controller.js +55 -0
  74. package/dist/src/orchestrator/replan-runner.js +258 -0
  75. package/dist/src/orchestrator/step-executor.js +391 -0
  76. package/dist/src/orchestrator/wave-scheduler-loop.js +204 -0
  77. package/dist/src/owasp-mapper.js +153 -0
  78. package/dist/src/owasp-report-renderer.js +39 -0
  79. package/dist/src/plan-files.js +142 -0
  80. package/dist/src/plan-generator.js +1207 -0
  81. package/dist/src/pm-agent.js +296 -0
  82. package/dist/src/post-run-reporter.js +203 -0
  83. package/dist/src/pr-automation.js +103 -0
  84. package/dist/src/pr-manager.js +318 -0
  85. package/dist/src/presenter/index.js +209 -0
  86. package/dist/src/prompt-builder.js +173 -0
  87. package/dist/src/quality-gates/config-loader.js +196 -0
  88. package/dist/src/quality-gates/default-config.js +243 -0
  89. package/dist/src/quality-gates/file-utils.js +152 -0
  90. package/dist/src/quality-gates/gate-runner.js +171 -0
  91. package/dist/src/quality-gates/gates/accessibility.js +355 -0
  92. package/dist/src/quality-gates/gates/duplicate-blocks.js +144 -0
  93. package/dist/src/quality-gates/gates/hardcoded-config.js +52 -0
  94. package/dist/src/quality-gates/gates/readme-claims.js +62 -0
  95. package/dist/src/quality-gates/gates/runtime-checks.js +265 -0
  96. package/dist/src/quality-gates/gates/scaffold-defaults.js +108 -0
  97. package/dist/src/quality-gates/gates/test-coverage.js +240 -0
  98. package/dist/src/quality-gates/gates/test-file-protection.js +85 -0
  99. package/dist/src/quality-gates/gates/test-isolation.js +74 -0
  100. package/dist/src/quality-gates/index.js +17 -0
  101. package/dist/src/quality-gates/registry.js +205 -0
  102. package/dist/src/quality-gates/types.js +2 -0
  103. package/dist/src/quick-fix-mode.js +302 -0
  104. package/dist/src/recipe-loader.js +122 -0
  105. package/dist/src/repair-agent.js +396 -0
  106. package/dist/src/repo-analyzer.js +342 -0
  107. package/dist/src/report-generator.js +146 -0
  108. package/dist/src/report-renderer.js +90 -0
  109. package/dist/src/requirement-filter.js +52 -0
  110. package/dist/src/sarif-formatter.js +140 -0
  111. package/dist/src/scheduling/dependency-analyzer.js +178 -0
  112. package/dist/src/scheduling/work-stealing-queue.js +123 -0
  113. package/dist/src/secret-redactor.js +90 -0
  114. package/dist/src/session-executor.js +587 -0
  115. package/dist/src/session-manager.js +221 -0
  116. package/dist/src/share/transcript-verification.js +128 -0
  117. package/dist/src/share-parser.js +477 -0
  118. package/dist/src/spinner.js +146 -0
  119. package/dist/src/step-runner.js +365 -0
  120. package/dist/src/swarm-orchestrator.js +686 -0
  121. package/dist/src/task-classifier.js +134 -0
  122. package/dist/src/test-command-discovery.js +123 -0
  123. package/dist/src/text-similarity.js +24 -0
  124. package/dist/src/tier-maps.js +158 -0
  125. package/dist/src/types.js +5 -0
  126. package/dist/src/url-shortener.js +135 -0
  127. package/dist/src/verification/attestation.js +166 -0
  128. package/dist/src/verification/cheat-detector.js +240 -0
  129. package/dist/src/verification/command-runner.js +70 -0
  130. package/dist/src/verification/composite-score.js +157 -0
  131. package/dist/src/verification/cosign-attestation.js +137 -0
  132. package/dist/src/verification/diff-analysis.js +89 -0
  133. package/dist/src/verification/differential-gate.js +173 -0
  134. package/dist/src/verification/index.js +41 -0
  135. package/dist/src/verification/mutation-gate.js +242 -0
  136. package/dist/src/verification/property-gate.js +201 -0
  137. package/dist/src/verification/test-synthesizer.js +243 -0
  138. package/dist/src/verifier/outcome-checks.js +396 -0
  139. package/dist/src/verifier/transcript-checks.js +207 -0
  140. package/dist/src/verifier/verification-reporters.js +148 -0
  141. package/dist/src/verifier-engine.js +491 -0
  142. package/dist/src/wave-resizer.js +131 -0
  143. package/dist/src/wave-scheduler.js +44 -0
  144. package/dist/src/worktree-manager.js +368 -0
  145. package/dist/src/worktree-reserved-paths.js +97 -0
  146. package/package.json +80 -0
  147. package/plugin/agents/.gitkeep +0 -0
  148. package/plugin/agents/backend_master.agent.md +72 -0
  149. package/plugin/agents/devops_pro.agent.md +45 -0
  150. package/plugin/agents/frontend_expert.agent.md +59 -0
  151. package/plugin/agents/integrator_finalizer.agent.md +44 -0
  152. package/plugin/agents/meta_reviewer.agent.md +44 -0
  153. package/plugin/agents/security_auditor.agent.md +43 -0
  154. package/plugin/agents/tester_elite.agent.md +43 -0
  155. package/plugin/hooks/hooks.json +19 -0
  156. package/plugin/hooks/post-tool-use.json +9 -0
  157. package/plugin/hooks/pre-tool-use.json +9 -0
  158. package/plugin/plugin.json +47 -0
  159. package/plugin/skills/swarm-gates/SKILL.md +53 -0
  160. package/plugin/skills/swarm-orchestrate/SKILL.md +34 -0
  161. package/plugin/skills/swarm-verify/SKILL.md +44 -0
  162. package/templates/README.md +35 -0
  163. package/templates/cli-tool.json +31 -0
  164. package/templates/fullstack.json +52 -0
  165. package/templates/library.json +38 -0
  166. package/templates/react-app.json +45 -0
  167. package/templates/recipes/add-api-docs.json +35 -0
  168. package/templates/recipes/add-auth.json +47 -0
  169. package/templates/recipes/add-ci.json +39 -0
  170. package/templates/recipes/add-tests.json +39 -0
  171. package/templates/recipes/migrate-to-ts.json +42 -0
  172. package/templates/recipes/refactor-modularize.json +44 -0
  173. package/templates/recipes/security-audit.json +35 -0
  174. package/templates/rest-api.json +38 -0
@@ -0,0 +1,365 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.StepRunner = void 0;
40
+ const fs = __importStar(require("fs"));
41
+ const path = __importStar(require("path"));
42
+ const github_mcp_integrator_1 = require("./github-mcp-integrator");
43
+ const session_executor_1 = __importDefault(require("./session-executor"));
44
+ const test_command_discovery_1 = require("./test-command-discovery");
45
+ const logger_1 = require("./logger");
46
+ const logger = (0, logger_1.getLogger)('step-runner');
47
+ class StepRunner {
48
+ proofDir;
49
+ sessionExecutor;
50
+ workingDir;
51
+ constructor(proofDir, workingDir) {
52
+ this.workingDir = workingDir || process.cwd();
53
+ this.proofDir = proofDir || path.join(this.workingDir, 'proof');
54
+ this.sessionExecutor = new session_executor_1.default(this.workingDir);
55
+ }
56
+ /**
57
+ * Initialize execution context for a plan
58
+ */
59
+ initializeExecution(plan, planFilename, options) {
60
+ const executionId = this.generateExecutionId();
61
+ const context = {
62
+ plan,
63
+ planFilename,
64
+ executionId,
65
+ startTime: new Date().toISOString(),
66
+ currentStep: 0,
67
+ stepResults: plan.steps.map(step => ({
68
+ stepNumber: step.stepNumber,
69
+ agentName: step.agentName,
70
+ status: 'pending'
71
+ })),
72
+ priorContext: []
73
+ };
74
+ if (options) {
75
+ context.options = options;
76
+ }
77
+ return context;
78
+ }
79
+ /**
80
+ * Generate the session starter prompt for a Copilot CLI session
81
+ * This is what the user should paste into their Copilot CLI session
82
+ */
83
+ generateSessionPrompt(step, agent, context) {
84
+ const lines = [];
85
+ lines.push('='.repeat(70));
86
+ lines.push(`COPILOT CLI SESSION - Step ${step.stepNumber}`);
87
+ lines.push('='.repeat(70));
88
+ lines.push('');
89
+ lines.push('You are operating as a GitHub Copilot CLI custom agent within a supervised,');
90
+ lines.push('sequential workflow.');
91
+ lines.push('');
92
+ lines.push('Context');
93
+ lines.push('-------');
94
+ lines.push(`- This repository is: ${context.plan.goal}`);
95
+ lines.push(`- Execution ID: ${context.executionId}`);
96
+ lines.push(`- Step: ${step.stepNumber} of ${context.plan.steps.length}`);
97
+ lines.push('- Your work must be fully auditable through session transcripts, git history,');
98
+ lines.push(' and test output.');
99
+ lines.push('');
100
+ lines.push('Your assigned role');
101
+ lines.push('------------------');
102
+ lines.push(`- Agent name: ${agent.name}`);
103
+ lines.push(`- Domain scope: ${agent.purpose}`);
104
+ lines.push('- You must stay strictly within this domain.');
105
+ lines.push('- If a task exceeds this scope, say so and stop.');
106
+ lines.push('');
107
+ lines.push('Your specific task for this step');
108
+ lines.push('---------------------------------');
109
+ lines.push(step.task);
110
+ lines.push('');
111
+ lines.push('Scope (what you ARE responsible for)');
112
+ lines.push('-------------------------------------');
113
+ agent.scope.forEach(item => {
114
+ lines.push(`- ${item}`);
115
+ });
116
+ lines.push('');
117
+ lines.push('Boundaries (what you should NOT do)');
118
+ lines.push('-----------------------------------');
119
+ agent.boundaries.forEach(item => {
120
+ lines.push(`- ${item}`);
121
+ });
122
+ lines.push('');
123
+ lines.push('Done definition (when you can say "done")');
124
+ lines.push('------------------------------------------');
125
+ agent.done_definition.forEach(item => {
126
+ lines.push(`- ${item}`);
127
+ });
128
+ lines.push('');
129
+ lines.push('Hard rules');
130
+ lines.push('----------');
131
+ lines.push('1. Do not invent features, flags, APIs, or tool behavior.');
132
+ lines.push('2. If you are uncertain about anything, explicitly say you are uncertain');
133
+ lines.push(' and list how to verify it.');
134
+ lines.push('3. Do not claim tests passed unless you actually ran them and can show');
135
+ lines.push(' the command output.');
136
+ lines.push('4. Do not say "done" unless all required artifacts listed below exist.');
137
+ lines.push('5. Prefer small, reviewable changes over large refactors.');
138
+ lines.push('');
139
+ const testDiscovery = (0, test_command_discovery_1.discoverTestCommand)(this.workingDir);
140
+ if (testDiscovery.warning && !(0, logger_1.isPrettyMode)()) {
141
+ logger.warn(`test command discovery: ${testDiscovery.warning}`);
142
+ }
143
+ lines.push((0, test_command_discovery_1.renderVerifyCommandSection)(testDiscovery));
144
+ lines.push('Refusal rules (when to stop and ask)');
145
+ lines.push('-------------------------------------');
146
+ agent.refusal_rules.forEach(rule => {
147
+ lines.push(`- ${rule}`);
148
+ });
149
+ lines.push('');
150
+ if (step.dependencies.length > 0) {
151
+ lines.push('Dependencies (steps you can rely on)');
152
+ lines.push('------------------------------------');
153
+ lines.push(`This step depends on: Steps ${step.dependencies.join(', ')}`);
154
+ lines.push('');
155
+ if (context.priorContext.length > 0) {
156
+ lines.push('Context from prior steps:');
157
+ context.priorContext.forEach(ctx => {
158
+ lines.push(` ${ctx}`);
159
+ });
160
+ lines.push('');
161
+ }
162
+ }
163
+ lines.push('Required artifacts for this step');
164
+ lines.push('--------------------------------');
165
+ lines.push(`You must produce all of the following before ending the session:`);
166
+ lines.push('');
167
+ lines.push('1. Implementation changes (code, config, etc.)');
168
+ lines.push('2. A verification section that includes:');
169
+ lines.push(' - What commands you ran');
170
+ lines.push(' - What tests were executed');
171
+ lines.push(' - The results of those tests');
172
+ lines.push(' - Any gaps or risks that remain');
173
+ lines.push('');
174
+ lines.push('Expected outputs:');
175
+ step.expectedOutputs.forEach(output => {
176
+ lines.push(` - ${output}`);
177
+ });
178
+ lines.push('');
179
+ // add GitHub integration instructions
180
+ if (context.options?.mcp) {
181
+ lines.push('');
182
+ lines.push(github_mcp_integrator_1.GitHubMcpIntegrator.generateMcpPromptSection());
183
+ lines.push('');
184
+ }
185
+ if (context.options?.delegate) {
186
+ lines.push('');
187
+ lines.push(github_mcp_integrator_1.GitHubMcpIntegrator.generateDelegatePromptSection());
188
+ lines.push('');
189
+ }
190
+ const transcriptPath = agent.output_contract.transcript.replace('{N}', step.stepNumber.toString());
191
+ lines.push(`3. Proof transcript saved to: ${transcriptPath}`);
192
+ lines.push('');
193
+ lines.push('Session closure');
194
+ lines.push('---------------');
195
+ lines.push('- When the step is complete, run /share to capture the session transcript.');
196
+ lines.push('- The /share output is the authoritative record of this step.');
197
+ lines.push('- Save the transcript to the proof file listed above.');
198
+ lines.push('- Do not summarize results outside of the proof transcript.');
199
+ lines.push('');
200
+ lines.push('If any requirement cannot be met, stop and explain why before proceeding.');
201
+ lines.push('');
202
+ lines.push('='.repeat(70));
203
+ lines.push('BEGIN WORK');
204
+ lines.push('='.repeat(70));
205
+ return lines.join('\n');
206
+ }
207
+ /**
208
+ * Execute a step programmatically (automated execution)
209
+ * Returns session result with transcript path
210
+ */
211
+ async executeStepAutomated(step, agent, context, options) {
212
+ logger.info(`\nExecuting Step ${step.stepNumber} (${agent.name}) programmatically...`);
213
+ const sessionOptions = {
214
+ model: options?.model || undefined,
215
+ allowAllTools: true,
216
+ silent: false
217
+ };
218
+ // execute with retry
219
+ const maxRetries = options?.retries || 3;
220
+ const result = await this.sessionExecutor.executeWithRetry(this.sessionExecutor['buildStepPrompt'](step, agent, context), sessionOptions, maxRetries);
221
+ if (result.success && result.transcriptPath) {
222
+ logger.info(`✓ Step ${step.stepNumber} completed`);
223
+ logger.info(` Transcript: ${result.transcriptPath}`);
224
+ }
225
+ else {
226
+ logger.error(`✗ Step ${step.stepNumber} failed after ${maxRetries} attempts`);
227
+ if (result.error) {
228
+ logger.error(` Error: ${result.error}`);
229
+ }
230
+ }
231
+ return result;
232
+ }
233
+ /**
234
+ * Display instructions for executing a step
235
+ */
236
+ displayStepInstructions(step, agent, context) {
237
+ const prompt = this.generateSessionPrompt(step, agent, context);
238
+ logger.info('\n' + '='.repeat(70));
239
+ logger.info(`Step ${step.stepNumber}: ${step.task}`);
240
+ logger.info(`Agent: ${agent.name}`);
241
+ logger.info('='.repeat(70));
242
+ logger.info('');
243
+ logger.info('INSTRUCTIONS:');
244
+ logger.info('-------------');
245
+ logger.info('1. Open a new GitHub Copilot CLI session in this repository');
246
+ logger.info('2. Copy the prompt below and paste it into the session');
247
+ logger.info('3. Work with Copilot to complete the task');
248
+ logger.info('4. When done, run /share and save the transcript');
249
+ logger.info('');
250
+ logger.info('SESSION PROMPT (copy everything below):');
251
+ logger.info('');
252
+ logger.info(prompt);
253
+ logger.info('');
254
+ }
255
+ /**
256
+ * Mark a step as completed and update context
257
+ */
258
+ completeStep(context, stepNumber, transcriptPath, outputs) {
259
+ const resultIndex = context.stepResults.findIndex(r => r.stepNumber === stepNumber);
260
+ if (resultIndex === -1) {
261
+ throw new Error(`Step ${stepNumber} not found in execution context`);
262
+ }
263
+ const result = context.stepResults[resultIndex];
264
+ if (!result) {
265
+ throw new Error(`Step result ${stepNumber} is undefined`);
266
+ }
267
+ result.status = 'completed';
268
+ result.endTime = new Date().toISOString();
269
+ result.transcriptPath = transcriptPath;
270
+ result.outputs = outputs;
271
+ // Add to prior context for next steps
272
+ const contextSummary = `Step ${stepNumber} (${result.agentName}): ${outputs.join(', ')}`;
273
+ context.priorContext.push(contextSummary);
274
+ context.currentStep = stepNumber;
275
+ }
276
+ /**
277
+ * Mark a step as failed
278
+ */
279
+ failStep(context, stepNumber, errors) {
280
+ const resultIndex = context.stepResults.findIndex(r => r.stepNumber === stepNumber);
281
+ if (resultIndex === -1) {
282
+ throw new Error(`Step ${stepNumber} not found in execution context`);
283
+ }
284
+ const result = context.stepResults[resultIndex];
285
+ if (!result) {
286
+ throw new Error(`Step result ${stepNumber} is undefined`);
287
+ }
288
+ result.status = 'failed';
289
+ result.endTime = new Date().toISOString();
290
+ result.errors = errors;
291
+ context.currentStep = stepNumber;
292
+ }
293
+ /**
294
+ * Save execution context to file
295
+ */
296
+ saveExecutionContext(context) {
297
+ this.ensureProofDirectory();
298
+ const filename = `execution-${context.executionId}.json`;
299
+ const filepath = path.join(this.proofDir, filename);
300
+ fs.writeFileSync(filepath, JSON.stringify(context, null, 2), 'utf8');
301
+ return filepath;
302
+ }
303
+ /**
304
+ * Load execution context from file
305
+ */
306
+ loadExecutionContext(executionId) {
307
+ const filename = `execution-${executionId}.json`;
308
+ const filepath = path.join(this.proofDir, filename);
309
+ if (!fs.existsSync(filepath)) {
310
+ throw new Error(`Execution context not found: ${filepath}`);
311
+ }
312
+ const content = fs.readFileSync(filepath, 'utf8');
313
+ return JSON.parse(content);
314
+ }
315
+ generateExecutionId() {
316
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
317
+ return `exec-${timestamp}`;
318
+ }
319
+ ensureProofDirectory() {
320
+ if (!fs.existsSync(this.proofDir)) {
321
+ fs.mkdirSync(this.proofDir, { recursive: true });
322
+ }
323
+ }
324
+ /**
325
+ * Generate execution summary
326
+ */
327
+ generateSummary(context) {
328
+ const lines = [];
329
+ lines.push('='.repeat(70));
330
+ lines.push('EXECUTION SUMMARY');
331
+ lines.push('='.repeat(70));
332
+ lines.push('');
333
+ lines.push(`Goal: ${context.plan.goal}`);
334
+ lines.push(`Execution ID: ${context.executionId}`);
335
+ lines.push(`Started: ${context.startTime}`);
336
+ if (context.endTime) {
337
+ lines.push(`Ended: ${context.endTime}`);
338
+ }
339
+ lines.push('');
340
+ lines.push('Step Results:');
341
+ lines.push('-------------');
342
+ context.stepResults.forEach(result => {
343
+ const step = context.plan.steps.find(s => s.stepNumber === result.stepNumber);
344
+ const statusIcon = result.status === 'completed' ? '✓' :
345
+ result.status === 'failed' ? '✗' :
346
+ result.status === 'running' ? '⋯' : '○';
347
+ lines.push(`${statusIcon} Step ${result.stepNumber}: ${step?.task || 'Unknown'}`);
348
+ lines.push(` Agent: ${result.agentName}`);
349
+ lines.push(` Status: ${result.status}`);
350
+ if (result.transcriptPath) {
351
+ lines.push(` Transcript: ${result.transcriptPath}`);
352
+ }
353
+ if (result.outputs && result.outputs.length > 0) {
354
+ lines.push(` Outputs: ${result.outputs.join(', ')}`);
355
+ }
356
+ if (result.errors && result.errors.length > 0) {
357
+ lines.push(` Errors: ${result.errors.join(', ')}`);
358
+ }
359
+ lines.push('');
360
+ });
361
+ return lines.join('\n');
362
+ }
363
+ }
364
+ exports.StepRunner = StepRunner;
365
+ exports.default = StepRunner;