claude-flow-novice 2.15.2 → 2.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/hooks/cfn-BACKUP_USAGE.md +243 -243
- package/.claude/hooks/cfn-invoke-security-validation.sh +69 -69
- package/.claude/hooks/cfn-post-edit-cfn-retrospective.sh +78 -78
- package/.claude/hooks/cfn-post-edit.config.json +44 -44
- package/.claude/skills/agent-lifecycle/SKILL.md +60 -0
- package/.claude/skills/agent-lifecycle/execute-lifecycle-hook.sh +573 -0
- package/.claude/skills/agent-lifecycle/simple-audit.sh +31 -0
- package/.claude/skills/cfn-hybrid-routing/check-dependencies.sh +51 -51
- package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +252 -252
- package/.claude/skills/cfn-redis-coordination/agent-recovery.sh +74 -74
- package/.claude/skills/cfn-redis-coordination/get-context.sh +112 -112
- package/.claude/skills/cfn-transparency-middleware/middleware-config.sh +28 -28
- package/.claude/skills/cfn-transparency-middleware/performance-benchmark.sh +78 -78
- package/.claude/skills/cfn-transparency-middleware/test-integration.sh +161 -161
- package/.claude/skills/cfn-transparency-middleware/test-transparency-skill.sh +367 -367
- package/.claude/skills/cfn-transparency-middleware/tests/input-validation.sh +92 -92
- package/.claude/skills/cfn-transparency-middleware/wrap-agent.sh +131 -131
- package/claude-assets/hooks/cfn-BACKUP_USAGE.md +243 -243
- package/claude-assets/hooks/cfn-invoke-security-validation.sh +69 -69
- package/claude-assets/hooks/cfn-post-edit-cfn-retrospective.sh +78 -78
- package/claude-assets/hooks/cfn-post-edit.config.json +44 -44
- package/claude-assets/hooks/cfn-post-execution/memory-cleanup.sh +19 -19
- package/claude-assets/hooks/cfn-pre-execution/memory-check.sh +19 -19
- package/claude-assets/skills/agent-lifecycle/execute-lifecycle-hook.sh +572 -572
- package/claude-assets/skills/agent-lifecycle/simple-audit.sh +30 -30
- package/claude-assets/skills/cfn-automatic-memory-persistence/persist-agent-output.sh +48 -48
- package/claude-assets/skills/cfn-automatic-memory-persistence/query-agent-history.sh +34 -34
- package/claude-assets/skills/cfn-deliverable-validation/confidence-calculator.sh +261 -261
- package/claude-assets/skills/cfn-expert-update/update-expert.sh +345 -345
- package/claude-assets/skills/cfn-hybrid-routing/check-dependencies.sh +51 -51
- package/claude-assets/skills/cfn-intervention-detector/detect-intervention.sh +110 -110
- package/claude-assets/skills/cfn-intervention-orchestrator/execute-intervention.sh +58 -58
- package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +252 -252
- package/claude-assets/skills/cfn-loop2-output-processing/process-validator-output.sh +275 -275
- package/claude-assets/skills/cfn-memory-management/check-memory.sh +159 -159
- package/claude-assets/skills/cfn-memory-management/cleanup-memory.sh +196 -196
- package/claude-assets/skills/cfn-node-heap-sizer/task-mode-heap-limiter.sh +325 -325
- package/claude-assets/skills/cfn-playbook-auto-update/auto-update-playbook.sh +85 -85
- package/claude-assets/skills/cfn-redis-coordination/agent-recovery.sh +74 -74
- package/claude-assets/skills/cfn-redis-coordination/get-context.sh +112 -112
- package/claude-assets/skills/cfn-scope-simplifier/simplify-scope.sh +67 -67
- package/claude-assets/skills/cfn-specialist-injection/recommend-specialist.sh +56 -56
- package/claude-assets/skills/cfn-standardized-error-handling/capture-agent-error.sh +86 -86
- package/claude-assets/skills/cfn-standardized-error-handling/test-error-handling.sh +165 -165
- package/claude-assets/skills/cfn-task-config-init/initialize-config.sh +264 -264
- package/claude-assets/skills/cfn-task-decomposition/task-decomposer.sh +278 -278
- package/claude-assets/skills/cfn-transparency-middleware/middleware-config.sh +28 -28
- package/claude-assets/skills/cfn-transparency-middleware/performance-benchmark.sh +78 -78
- package/claude-assets/skills/cfn-transparency-middleware/test-integration.sh +161 -161
- package/claude-assets/skills/cfn-transparency-middleware/test-transparency-skill.sh +367 -367
- package/claude-assets/skills/cfn-transparency-middleware/tests/input-validation.sh +92 -92
- package/claude-assets/skills/cfn-transparency-middleware/wrap-agent.sh +131 -131
- package/claude-assets/skills/docker-build/SKILL.md +96 -203
- package/claude-assets/skills/docker-build/build.sh +73 -73
- package/claude-assets/skills/integration/agent-handoff.sh +494 -0
- package/claude-assets/skills/integration/file-operations.sh +414 -0
- package/claude-assets/skills/workflow-codification/APPROVAL_WORKFLOW.md +806 -0
- package/claude-assets/skills/workflow-codification/COST_TRACKING.md +637 -0
- package/claude-assets/skills/workflow-codification/EDGE_CASE_TRACKING.md +404 -0
- package/claude-assets/skills/workflow-codification/README_PHASE4.md +457 -0
- package/claude-assets/skills/workflow-codification/SKILL.md +110 -0
- package/claude-assets/skills/workflow-codification/analyze-patterns.sh +899 -0
- package/claude-assets/skills/workflow-codification/approval-workflow.sh +514 -0
- package/claude-assets/skills/workflow-codification/generate-skill-update.sh +525 -0
- package/claude-assets/skills/workflow-codification/review-skill.sh +643 -0
- package/claude-assets/skills/workflow-codification/templates/email-notification.txt +114 -0
- package/claude-assets/skills/workflow-codification/templates/slack-notification.md +85 -0
- package/claude-assets/skills/workflow-codification/test-integration.sh +281 -0
- package/claude-assets/skills/workflow-codification/track-cost-savings.sh +445 -0
- package/claude-assets/skills/workflow-codification/track-edge-case.sh +323 -0
- package/dist/cli/config-manager.js +91 -109
- package/dist/cli/config-manager.js.map +1 -1
- package/dist/integration/DatabaseHandoff.js +507 -0
- package/dist/integration/DatabaseHandoff.js.map +1 -0
- package/dist/integration/StandardAdapter.js +291 -0
- package/dist/integration/StandardAdapter.js.map +1 -0
- package/dist/lib/agent-output-parser.js +518 -0
- package/dist/lib/agent-output-parser.js.map +1 -0
- package/dist/lib/agent-output-validator.js +950 -0
- package/dist/lib/agent-output-validator.js.map +1 -0
- package/dist/lib/artifact-registry.js +443 -0
- package/dist/lib/artifact-registry.js.map +1 -0
- package/dist/lib/config-validator.js +687 -0
- package/dist/lib/config-validator.js.map +1 -0
- package/dist/types/agent-output.js +44 -0
- package/dist/types/agent-output.js.map +1 -0
- package/dist/types/config.js +28 -0
- package/dist/types/config.js.map +1 -0
- package/package.json +2 -1
- package/scripts/artifact-cleanup.sh +392 -0
- package/scripts/deploy-production.sh +355 -355
- package/scripts/docker-playwright-fix.sh +311 -311
- package/scripts/docker-rebuild-all-agents.sh +127 -127
- package/scripts/memory-leak-prevention.sh +305 -305
- package/scripts/migrate-artifacts.sh +563 -0
- package/scripts/migrate-yaml-to-json.sh +465 -0
- package/scripts/run-marketing-tests.sh +42 -42
- package/scripts/update_paths.sh +46 -46
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Output Parser
|
|
3
|
+
* Legacy stdout parser for backward compatibility
|
|
4
|
+
*
|
|
5
|
+
* @version 1.0.0
|
|
6
|
+
* @description Converts unstructured text output to structured JSON
|
|
7
|
+
*/ // ============================================================================
|
|
8
|
+
// Parser Class
|
|
9
|
+
// ============================================================================
|
|
10
|
+
/**
|
|
11
|
+
* AgentOutputParser: Legacy text output parser
|
|
12
|
+
* Provides best-effort parsing of unstructured stdout
|
|
13
|
+
*/ export class AgentOutputParser {
|
|
14
|
+
/**
|
|
15
|
+
* Parse stdout text to structured agent output
|
|
16
|
+
*/ parse(text) {
|
|
17
|
+
const errors = [];
|
|
18
|
+
let confidence = 0.5; // Default confidence for legacy parsing
|
|
19
|
+
try {
|
|
20
|
+
// Attempt to parse as JSON first
|
|
21
|
+
const jsonOutput = this.tryParseJSON(text);
|
|
22
|
+
if (jsonOutput) {
|
|
23
|
+
return {
|
|
24
|
+
success: true,
|
|
25
|
+
output: jsonOutput,
|
|
26
|
+
errors: [],
|
|
27
|
+
confidence: 0.95
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
// Detect output type from text patterns
|
|
31
|
+
const outputType = this.detectOutputType(text);
|
|
32
|
+
// Parse based on detected type
|
|
33
|
+
switch(outputType){
|
|
34
|
+
case 'loop3':
|
|
35
|
+
return this.parseLoop3Text(text);
|
|
36
|
+
case 'loop2':
|
|
37
|
+
return this.parseLoop2Text(text);
|
|
38
|
+
case 'product_owner':
|
|
39
|
+
return this.parseProductOwnerText(text);
|
|
40
|
+
default:
|
|
41
|
+
return {
|
|
42
|
+
success: false,
|
|
43
|
+
errors: [
|
|
44
|
+
'Unable to detect agent output type from text'
|
|
45
|
+
],
|
|
46
|
+
confidence: 0.0
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
} catch (error) {
|
|
50
|
+
return {
|
|
51
|
+
success: false,
|
|
52
|
+
errors: [
|
|
53
|
+
`Parse error: ${error instanceof Error ? error.message : String(error)}`
|
|
54
|
+
],
|
|
55
|
+
confidence: 0.0
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Attempt to parse text as JSON
|
|
61
|
+
*/ tryParseJSON(text) {
|
|
62
|
+
try {
|
|
63
|
+
// Try parsing the entire text
|
|
64
|
+
const obj = JSON.parse(text);
|
|
65
|
+
if (this.isValidAgentOutput(obj)) {
|
|
66
|
+
return obj;
|
|
67
|
+
}
|
|
68
|
+
// Try extracting JSON from markdown code blocks
|
|
69
|
+
const jsonMatch = text.match(/```json\s*\n([\s\S]*?)\n```/);
|
|
70
|
+
if (jsonMatch) {
|
|
71
|
+
const obj = JSON.parse(jsonMatch[1]);
|
|
72
|
+
if (this.isValidAgentOutput(obj)) {
|
|
73
|
+
return obj;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
} catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Basic validation for agent output structure
|
|
83
|
+
*/ isValidAgentOutput(obj) {
|
|
84
|
+
if (typeof obj !== 'object' || obj === null) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
const record = obj;
|
|
88
|
+
return typeof record.success === 'boolean' && typeof record.confidence === 'number' && typeof record.output_type === 'string' && (record.output_type === 'loop3' || record.output_type === 'loop2' || record.output_type === 'product_owner');
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Detect output type from text patterns
|
|
92
|
+
*/ detectOutputType(text) {
|
|
93
|
+
const lower = text.toLowerCase();
|
|
94
|
+
// Check for Product Owner decision keywords
|
|
95
|
+
if (/\b(PROCEED|ITERATE|ABORT)\b/.test(text) && /\b(decision|rationale)\b/i.test(lower)) {
|
|
96
|
+
return 'product_owner';
|
|
97
|
+
}
|
|
98
|
+
// Check for Loop 2 validation keywords
|
|
99
|
+
if (/\b(approved|rejected|consensus|validation)\b/i.test(lower) && /\b(issues?|recommendations?)\b/i.test(lower)) {
|
|
100
|
+
return 'loop2';
|
|
101
|
+
}
|
|
102
|
+
// Check for Loop 3 implementation keywords
|
|
103
|
+
if (/\b(deliverables?|implementation|created|modified)\b/i.test(lower) || /\b(files? (created|modified))\b/i.test(lower)) {
|
|
104
|
+
return 'loop3';
|
|
105
|
+
}
|
|
106
|
+
return 'unknown';
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Parse Loop 3 implementer text output
|
|
110
|
+
*/ parseLoop3Text(text) {
|
|
111
|
+
const output = {
|
|
112
|
+
output_type: 'loop3',
|
|
113
|
+
success: true,
|
|
114
|
+
confidence: this.extractConfidence(text),
|
|
115
|
+
iteration: this.extractIteration(text),
|
|
116
|
+
deliverables: this.extractDeliverables(text),
|
|
117
|
+
errors: this.extractErrors(text),
|
|
118
|
+
metadata: {
|
|
119
|
+
agent_type: this.extractAgentType(text) || 'unknown',
|
|
120
|
+
timestamp: new Date().toISOString()
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
// Extract optional fields
|
|
124
|
+
const summary = this.extractSummary(text);
|
|
125
|
+
if (summary) {
|
|
126
|
+
output.summary = summary;
|
|
127
|
+
}
|
|
128
|
+
const metrics = this.extractMetrics(text);
|
|
129
|
+
if (Object.keys(metrics).length > 0) {
|
|
130
|
+
output.metrics = metrics;
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
success: true,
|
|
134
|
+
output,
|
|
135
|
+
errors: [],
|
|
136
|
+
confidence: 0.7
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Parse Loop 2 validator text output
|
|
141
|
+
*/ parseLoop2Text(text) {
|
|
142
|
+
const output = {
|
|
143
|
+
output_type: 'loop2',
|
|
144
|
+
success: true,
|
|
145
|
+
confidence: this.extractConfidence(text),
|
|
146
|
+
iteration: this.extractIteration(text),
|
|
147
|
+
validation_type: this.extractValidationType(text),
|
|
148
|
+
issues: this.extractIssues(text),
|
|
149
|
+
recommendations: this.extractRecommendations(text),
|
|
150
|
+
approved: this.extractApproval(text),
|
|
151
|
+
errors: this.extractErrors(text),
|
|
152
|
+
metadata: {
|
|
153
|
+
agent_type: this.extractAgentType(text) || 'reviewer',
|
|
154
|
+
timestamp: new Date().toISOString()
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const summary = this.extractSummary(text);
|
|
158
|
+
if (summary) {
|
|
159
|
+
output.summary = summary;
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
success: true,
|
|
163
|
+
output,
|
|
164
|
+
errors: [],
|
|
165
|
+
confidence: 0.7
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Parse Product Owner text output
|
|
170
|
+
*/ parseProductOwnerText(text) {
|
|
171
|
+
const decision = this.extractDecision(text);
|
|
172
|
+
if (!decision) {
|
|
173
|
+
return {
|
|
174
|
+
success: false,
|
|
175
|
+
errors: [
|
|
176
|
+
'Unable to extract Product Owner decision'
|
|
177
|
+
],
|
|
178
|
+
confidence: 0.0
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
const output = {
|
|
182
|
+
output_type: 'product_owner',
|
|
183
|
+
success: true,
|
|
184
|
+
confidence: this.extractConfidence(text),
|
|
185
|
+
iteration: this.extractIteration(text),
|
|
186
|
+
decision,
|
|
187
|
+
rationale: this.extractRationale(text),
|
|
188
|
+
deliverables_validated: this.extractDeliverablesValidated(text),
|
|
189
|
+
next_action: this.extractNextAction(text),
|
|
190
|
+
errors: this.extractErrors(text),
|
|
191
|
+
metadata: {
|
|
192
|
+
agent_type: 'product-owner',
|
|
193
|
+
timestamp: new Date().toISOString()
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
const consensusScore = this.extractConsensusScore(text);
|
|
197
|
+
if (consensusScore !== null) {
|
|
198
|
+
output.consensus_score = consensusScore;
|
|
199
|
+
}
|
|
200
|
+
const gateScore = this.extractGateScore(text);
|
|
201
|
+
if (gateScore !== null) {
|
|
202
|
+
output.gate_score = gateScore;
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
success: true,
|
|
206
|
+
output,
|
|
207
|
+
errors: [],
|
|
208
|
+
confidence: 0.75
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
// ============================================================================
|
|
212
|
+
// Extraction Helper Methods
|
|
213
|
+
// ============================================================================
|
|
214
|
+
/**
|
|
215
|
+
* Extract confidence score from text
|
|
216
|
+
*/ extractConfidence(text) {
|
|
217
|
+
// Look for explicit confidence score (fixed regex to match only valid decimals)
|
|
218
|
+
const match = text.match(/confidence[:\s]+([0-9]+(?:\.[0-9]+)?)/i) || text.match(/confidence score[:\s]+([0-9]+(?:\.[0-9]+)?)/i);
|
|
219
|
+
if (match) {
|
|
220
|
+
const value = parseFloat(match[1]);
|
|
221
|
+
// Handle both 0.0-1.0 and 0-100 formats
|
|
222
|
+
if (value >= 0 && value <= 1) {
|
|
223
|
+
return value;
|
|
224
|
+
}
|
|
225
|
+
if (value > 1 && value <= 100) {
|
|
226
|
+
return value / 100;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
// Default confidence for parsed text
|
|
230
|
+
return 0.7;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Extract iteration number from text
|
|
234
|
+
*/ extractIteration(text) {
|
|
235
|
+
const match = text.match(/iteration[:\s]+(\d+)/i) || text.match(/iteration (\d+)/i);
|
|
236
|
+
if (match) {
|
|
237
|
+
return parseInt(match[1], 10);
|
|
238
|
+
}
|
|
239
|
+
return 1; // Default to iteration 1
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Extract agent type from text
|
|
243
|
+
*/ extractAgentType(text) {
|
|
244
|
+
const match = text.match(/agent[_\s]?type[:\s]+([a-z-]+)/i) || text.match(/agent[:\s]+([a-z-]+)/i);
|
|
245
|
+
return match ? match[1] : null;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Extract summary from text
|
|
249
|
+
*/ extractSummary(text) {
|
|
250
|
+
const match = text.match(/summary[:\s]+(.+?)(?:\n\n|\n[A-Z]|$)/is) || text.match(/## Summary\s*\n(.+?)(?:\n\n|\n#|$)/is);
|
|
251
|
+
return match ? match[1].trim() : null;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Extract deliverables from text
|
|
255
|
+
*/ extractDeliverables(text) {
|
|
256
|
+
const deliverables = [];
|
|
257
|
+
// Look for file listings
|
|
258
|
+
const filePatterns = [
|
|
259
|
+
/(?:created|modified|deleted)[:\s]+([^\n]+)/gi,
|
|
260
|
+
/[-*]\s+(?:created|modified|deleted)[:\s]+([^\n]+)/gi,
|
|
261
|
+
/[-*]\s+`([^`]+)`\s+-\s+(created|modified|deleted)/gi
|
|
262
|
+
];
|
|
263
|
+
for (const pattern of filePatterns){
|
|
264
|
+
let match;
|
|
265
|
+
while((match = pattern.exec(text)) !== null){
|
|
266
|
+
const path = match[1].trim().replace(/`/g, '');
|
|
267
|
+
const status = this.extractDeliverableStatus(match[0]);
|
|
268
|
+
deliverables.push({
|
|
269
|
+
path,
|
|
270
|
+
type: this.guessDeliverableType(path),
|
|
271
|
+
status: status || 'created'
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return deliverables;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Extract deliverable status from text
|
|
279
|
+
*/ extractDeliverableStatus(text) {
|
|
280
|
+
const lower = text.toLowerCase();
|
|
281
|
+
if (lower.includes('created')) return 'created';
|
|
282
|
+
if (lower.includes('modified')) return 'modified';
|
|
283
|
+
if (lower.includes('deleted')) return 'deleted';
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Guess deliverable type from file path
|
|
288
|
+
*/ guessDeliverableType(path) {
|
|
289
|
+
const lower = path.toLowerCase();
|
|
290
|
+
if (lower.match(/\.test\.|\.spec\.|test\/|tests\//)) return 'test';
|
|
291
|
+
if (lower.match(/\.md$|readme|docs?\//)) return 'documentation';
|
|
292
|
+
if (lower.match(/\.json$|\.ya?ml$|\.toml$|\.ini$/)) return 'config';
|
|
293
|
+
if (lower.match(/schema|\.graphql$/)) return 'schema';
|
|
294
|
+
if (lower.match(/\.sh$|\.bash$|scripts?\//)) return 'script';
|
|
295
|
+
if (lower.match(/\.ts$|\.js$|\.py$|src\//)) return 'implementation';
|
|
296
|
+
return 'other';
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Extract metrics from text
|
|
300
|
+
*/ extractMetrics(text) {
|
|
301
|
+
const metrics = {};
|
|
302
|
+
const patterns = [
|
|
303
|
+
{
|
|
304
|
+
key: 'files_created',
|
|
305
|
+
pattern: /(\d+)\s+files?\s+created/i
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
key: 'files_modified',
|
|
309
|
+
pattern: /(\d+)\s+files?\s+modified/i
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
key: 'lines_of_code',
|
|
313
|
+
pattern: /(\d+)\s+lines?\s+of\s+code/i
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
key: 'test_coverage',
|
|
317
|
+
pattern: /(?:coverage|test coverage)[:\s]+([0-9]+(?:\.[0-9]+)?)%?/i
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
key: 'tests_passed',
|
|
321
|
+
pattern: /(\d+)\s+tests?\s+passed/i
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
key: 'tests_failed',
|
|
325
|
+
pattern: /(\d+)\s+tests?\s+failed/i
|
|
326
|
+
}
|
|
327
|
+
];
|
|
328
|
+
for (const { key, pattern } of patterns){
|
|
329
|
+
const match = text.match(pattern);
|
|
330
|
+
if (match) {
|
|
331
|
+
let value = parseFloat(match[1]);
|
|
332
|
+
// Convert percentage to 0.0-1.0 for test_coverage
|
|
333
|
+
if (key === 'test_coverage' && value > 1) {
|
|
334
|
+
value = value / 100;
|
|
335
|
+
}
|
|
336
|
+
metrics[key] = value;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return metrics;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Extract validation type from text
|
|
343
|
+
*/ extractValidationType(text) {
|
|
344
|
+
const lower = text.toLowerCase();
|
|
345
|
+
if (lower.includes('security')) return 'security';
|
|
346
|
+
if (lower.includes('test')) return 'test';
|
|
347
|
+
if (lower.includes('architecture')) return 'architecture';
|
|
348
|
+
if (lower.includes('performance')) return 'performance';
|
|
349
|
+
if (lower.includes('compliance')) return 'compliance';
|
|
350
|
+
return 'review'; // Default
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Extract issues from text
|
|
354
|
+
*/ extractIssues(text) {
|
|
355
|
+
const issues = [];
|
|
356
|
+
// Look for issue listings
|
|
357
|
+
const issuePatterns = [
|
|
358
|
+
/[-*]\s+\[([^\]]+)\]\s+([^\n]+)/g,
|
|
359
|
+
/[-*]\s+(critical|high|medium|low|info)[:\s]+([^\n]+)/gi
|
|
360
|
+
];
|
|
361
|
+
for (const pattern of issuePatterns){
|
|
362
|
+
let match;
|
|
363
|
+
while((match = pattern.exec(text)) !== null){
|
|
364
|
+
const severity = this.parseSeverity(match[1]);
|
|
365
|
+
const message = match[2].trim();
|
|
366
|
+
issues.push({
|
|
367
|
+
severity,
|
|
368
|
+
category: 'other',
|
|
369
|
+
message
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return issues;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Parse severity from text
|
|
377
|
+
*/ parseSeverity(text) {
|
|
378
|
+
const lower = text.toLowerCase();
|
|
379
|
+
if (lower.includes('critical')) return 'critical';
|
|
380
|
+
if (lower.includes('high')) return 'high';
|
|
381
|
+
if (lower.includes('medium')) return 'medium';
|
|
382
|
+
if (lower.includes('low')) return 'low';
|
|
383
|
+
return 'info';
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Extract recommendations from text
|
|
387
|
+
*/ extractRecommendations(text) {
|
|
388
|
+
const recommendations = [];
|
|
389
|
+
// Look for recommendation listings
|
|
390
|
+
const patterns = [
|
|
391
|
+
/recommendation[s]?[:\s]+([^\n]+)/gi,
|
|
392
|
+
/[-*]\s+(?:recommend|suggestion)[:\s]+([^\n]+)/gi
|
|
393
|
+
];
|
|
394
|
+
for (const pattern of patterns){
|
|
395
|
+
let match;
|
|
396
|
+
while((match = pattern.exec(text)) !== null){
|
|
397
|
+
recommendations.push(match[1].trim());
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return recommendations;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Extract approval status from text
|
|
404
|
+
*/ extractApproval(text) {
|
|
405
|
+
const lower = text.toLowerCase();
|
|
406
|
+
// Explicit approval/rejection
|
|
407
|
+
if (/\bapproved\b/i.test(text)) return true;
|
|
408
|
+
if (/\brejected\b/i.test(text)) return false;
|
|
409
|
+
// Implicit approval from consensus (fixed regex to match only valid decimals)
|
|
410
|
+
if (/consensus[:\s]+([0-9]+(?:\.[0-9]+)?)/i.test(text)) {
|
|
411
|
+
const match = text.match(/consensus[:\s]+([0-9]+(?:\.[0-9]+)?)/i);
|
|
412
|
+
if (match) {
|
|
413
|
+
const score = parseFloat(match[1]);
|
|
414
|
+
return score >= 0.9; // Default threshold
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return false; // Default to not approved
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Extract Product Owner decision
|
|
421
|
+
*/ extractDecision(text) {
|
|
422
|
+
const match = text.match(/\b(PROCEED|ITERATE|ABORT)\b/);
|
|
423
|
+
return match ? match[1] : null;
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Extract rationale from text
|
|
427
|
+
*/ extractRationale(text) {
|
|
428
|
+
const match = text.match(/rationale[:\s]+(.+?)(?:\n\n|\n[A-Z]|$)/is) || text.match(/reason[:\s]+(.+?)(?:\n\n|\n[A-Z]|$)/is);
|
|
429
|
+
return match ? match[1].trim() : 'No rationale provided in legacy output';
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Extract deliverables validated status
|
|
433
|
+
*/ extractDeliverablesValidated(text) {
|
|
434
|
+
const lower = text.toLowerCase();
|
|
435
|
+
return lower.includes('deliverables validated') || lower.includes('all deliverables') || lower.includes('deliverables complete');
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Extract next action from text
|
|
439
|
+
*/ extractNextAction(text) {
|
|
440
|
+
const match = text.match(/next[_\s]action[:\s]+([^\n]+)/i) || text.match(/action[:\s]+([^\n]+)/i);
|
|
441
|
+
if (match) {
|
|
442
|
+
return match[1].trim();
|
|
443
|
+
}
|
|
444
|
+
// Infer from decision
|
|
445
|
+
const decision = this.extractDecision(text);
|
|
446
|
+
if (decision === 'PROCEED') return 'mark_task_complete';
|
|
447
|
+
if (decision === 'ITERATE') return 'start_next_iteration';
|
|
448
|
+
if (decision === 'ABORT') return 'abort_task';
|
|
449
|
+
return 'unknown';
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Extract consensus score from text
|
|
453
|
+
*/ extractConsensusScore(text) {
|
|
454
|
+
const match = text.match(/consensus[_\s]score[:\s]+([0-9]+(?:\.[0-9]+)?)/i) || text.match(/consensus[:\s]+([0-9]+(?:\.[0-9]+)?)/i);
|
|
455
|
+
if (match) {
|
|
456
|
+
const value = parseFloat(match[1]);
|
|
457
|
+
return value >= 0 && value <= 1 ? value : value / 100;
|
|
458
|
+
}
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Extract gate score from text
|
|
463
|
+
*/ extractGateScore(text) {
|
|
464
|
+
const match = text.match(/gate[_\s]score[:\s]+([0-9]+(?:\.[0-9]+)?)/i) || text.match(/gate[:\s]+([0-9]+(?:\.[0-9]+)?)/i);
|
|
465
|
+
if (match) {
|
|
466
|
+
const value = parseFloat(match[1]);
|
|
467
|
+
return value >= 0 && value <= 1 ? value : value / 100;
|
|
468
|
+
}
|
|
469
|
+
return null;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Extract errors from text
|
|
473
|
+
*/ extractErrors(text) {
|
|
474
|
+
const errors = [];
|
|
475
|
+
// Look for error listings
|
|
476
|
+
const errorPatterns = [
|
|
477
|
+
/error[:\s]+\[([^\]]+)\]\s+([^\n]+)/gi,
|
|
478
|
+
/\[ERROR\]\s+([^\n]+)/gi
|
|
479
|
+
];
|
|
480
|
+
for (const pattern of errorPatterns){
|
|
481
|
+
let match;
|
|
482
|
+
while((match = pattern.exec(text)) !== null){
|
|
483
|
+
const code = match[1] || 'UNKNOWN_ERROR';
|
|
484
|
+
const message = match[2] || match[1];
|
|
485
|
+
errors.push({
|
|
486
|
+
code: code.trim(),
|
|
487
|
+
message: message.trim()
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
return errors;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
// ============================================================================
|
|
495
|
+
// Singleton Instance and Convenience Functions
|
|
496
|
+
// ============================================================================
|
|
497
|
+
let parserInstance = null;
|
|
498
|
+
/**
|
|
499
|
+
* Get or create parser instance
|
|
500
|
+
*/ export function getParser() {
|
|
501
|
+
if (!parserInstance) {
|
|
502
|
+
parserInstance = new AgentOutputParser();
|
|
503
|
+
}
|
|
504
|
+
return parserInstance;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Parse text output to structured agent output
|
|
508
|
+
*/ export function parseAgentOutput(text) {
|
|
509
|
+
return getParser().parse(text);
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Reset parser instance (useful for testing)
|
|
513
|
+
*/ export function resetParser() {
|
|
514
|
+
parserInstance = null;
|
|
515
|
+
}
|
|
516
|
+
export default AgentOutputParser;
|
|
517
|
+
|
|
518
|
+
//# sourceMappingURL=agent-output-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/lib/agent-output-parser.ts"],"sourcesContent":["/**\r\n * Agent Output Parser\r\n * Legacy stdout parser for backward compatibility\r\n *\r\n * @version 1.0.0\r\n * @description Converts unstructured text output to structured JSON\r\n */\r\n\r\nimport type {\r\n AgentOutput,\r\n Loop3Output,\r\n Loop2Output,\r\n ProductOwnerOutput,\r\n ParseResult,\r\n Deliverable,\r\n Issue,\r\n AgentError,\r\n} from '../types/agent-output';\r\n\r\n// ============================================================================\r\n// Parser Class\r\n// ============================================================================\r\n\r\n/**\r\n * AgentOutputParser: Legacy text output parser\r\n * Provides best-effort parsing of unstructured stdout\r\n */\r\nexport class AgentOutputParser {\r\n /**\r\n * Parse stdout text to structured agent output\r\n */\r\n public parse(text: string): ParseResult {\r\n const errors: string[] = [];\r\n let confidence = 0.5; // Default confidence for legacy parsing\r\n\r\n try {\r\n // Attempt to parse as JSON first\r\n const jsonOutput = this.tryParseJSON(text);\r\n if (jsonOutput) {\r\n return {\r\n success: true,\r\n output: jsonOutput,\r\n errors: [],\r\n confidence: 0.95,\r\n };\r\n }\r\n\r\n // Detect output type from text patterns\r\n const outputType = this.detectOutputType(text);\r\n\r\n // Parse based on detected type\r\n switch (outputType) {\r\n case 'loop3':\r\n return this.parseLoop3Text(text);\r\n case 'loop2':\r\n return this.parseLoop2Text(text);\r\n case 'product_owner':\r\n return this.parseProductOwnerText(text);\r\n default:\r\n return {\r\n success: false,\r\n errors: ['Unable to detect agent output type from text'],\r\n confidence: 0.0,\r\n };\r\n }\r\n } catch (error) {\r\n return {\r\n success: false,\r\n errors: [\r\n `Parse error: ${error instanceof Error ? error.message : String(error)}`,\r\n ],\r\n confidence: 0.0,\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * Attempt to parse text as JSON\r\n */\r\n private tryParseJSON(text: string): AgentOutput | null {\r\n try {\r\n // Try parsing the entire text\r\n const obj = JSON.parse(text);\r\n if (this.isValidAgentOutput(obj)) {\r\n return obj as AgentOutput;\r\n }\r\n\r\n // Try extracting JSON from markdown code blocks\r\n const jsonMatch = text.match(/```json\\s*\\n([\\s\\S]*?)\\n```/);\r\n if (jsonMatch) {\r\n const obj = JSON.parse(jsonMatch[1]);\r\n if (this.isValidAgentOutput(obj)) {\r\n return obj as AgentOutput;\r\n }\r\n }\r\n\r\n return null;\r\n } catch {\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * Basic validation for agent output structure\r\n */\r\n private isValidAgentOutput(obj: unknown): boolean {\r\n if (typeof obj !== 'object' || obj === null) {\r\n return false;\r\n }\r\n\r\n const record = obj as Record<string, unknown>;\r\n return (\r\n typeof record.success === 'boolean' &&\r\n typeof record.confidence === 'number' &&\r\n typeof record.output_type === 'string' &&\r\n (record.output_type === 'loop3' ||\r\n record.output_type === 'loop2' ||\r\n record.output_type === 'product_owner')\r\n );\r\n }\r\n\r\n /**\r\n * Detect output type from text patterns\r\n */\r\n private detectOutputType(text: string): string {\r\n const lower = text.toLowerCase();\r\n\r\n // Check for Product Owner decision keywords\r\n if (\r\n /\\b(PROCEED|ITERATE|ABORT)\\b/.test(text) &&\r\n /\\b(decision|rationale)\\b/i.test(lower)\r\n ) {\r\n return 'product_owner';\r\n }\r\n\r\n // Check for Loop 2 validation keywords\r\n if (\r\n /\\b(approved|rejected|consensus|validation)\\b/i.test(lower) &&\r\n /\\b(issues?|recommendations?)\\b/i.test(lower)\r\n ) {\r\n return 'loop2';\r\n }\r\n\r\n // Check for Loop 3 implementation keywords\r\n if (\r\n /\\b(deliverables?|implementation|created|modified)\\b/i.test(lower) ||\r\n /\\b(files? (created|modified))\\b/i.test(lower)\r\n ) {\r\n return 'loop3';\r\n }\r\n\r\n return 'unknown';\r\n }\r\n\r\n /**\r\n * Parse Loop 3 implementer text output\r\n */\r\n private parseLoop3Text(text: string): ParseResult {\r\n const output: Loop3Output = {\r\n output_type: 'loop3',\r\n success: true,\r\n confidence: this.extractConfidence(text),\r\n iteration: this.extractIteration(text),\r\n deliverables: this.extractDeliverables(text),\r\n errors: this.extractErrors(text),\r\n metadata: {\r\n agent_type: this.extractAgentType(text) || 'unknown',\r\n timestamp: new Date().toISOString(),\r\n },\r\n };\r\n\r\n // Extract optional fields\r\n const summary = this.extractSummary(text);\r\n if (summary) {\r\n output.summary = summary;\r\n }\r\n\r\n const metrics = this.extractMetrics(text);\r\n if (Object.keys(metrics).length > 0) {\r\n output.metrics = metrics;\r\n }\r\n\r\n return {\r\n success: true,\r\n output,\r\n errors: [],\r\n confidence: 0.7,\r\n };\r\n }\r\n\r\n /**\r\n * Parse Loop 2 validator text output\r\n */\r\n private parseLoop2Text(text: string): ParseResult {\r\n const output: Loop2Output = {\r\n output_type: 'loop2',\r\n success: true,\r\n confidence: this.extractConfidence(text),\r\n iteration: this.extractIteration(text),\r\n validation_type: this.extractValidationType(text),\r\n issues: this.extractIssues(text),\r\n recommendations: this.extractRecommendations(text),\r\n approved: this.extractApproval(text),\r\n errors: this.extractErrors(text),\r\n metadata: {\r\n agent_type: this.extractAgentType(text) || 'reviewer',\r\n timestamp: new Date().toISOString(),\r\n },\r\n };\r\n\r\n const summary = this.extractSummary(text);\r\n if (summary) {\r\n output.summary = summary;\r\n }\r\n\r\n return {\r\n success: true,\r\n output,\r\n errors: [],\r\n confidence: 0.7,\r\n };\r\n }\r\n\r\n /**\r\n * Parse Product Owner text output\r\n */\r\n private parseProductOwnerText(text: string): ParseResult {\r\n const decision = this.extractDecision(text);\r\n if (!decision) {\r\n return {\r\n success: false,\r\n errors: ['Unable to extract Product Owner decision'],\r\n confidence: 0.0,\r\n };\r\n }\r\n\r\n const output: ProductOwnerOutput = {\r\n output_type: 'product_owner',\r\n success: true,\r\n confidence: this.extractConfidence(text),\r\n iteration: this.extractIteration(text),\r\n decision,\r\n rationale: this.extractRationale(text),\r\n deliverables_validated: this.extractDeliverablesValidated(text),\r\n next_action: this.extractNextAction(text),\r\n errors: this.extractErrors(text),\r\n metadata: {\r\n agent_type: 'product-owner',\r\n timestamp: new Date().toISOString(),\r\n },\r\n };\r\n\r\n const consensusScore = this.extractConsensusScore(text);\r\n if (consensusScore !== null) {\r\n output.consensus_score = consensusScore;\r\n }\r\n\r\n const gateScore = this.extractGateScore(text);\r\n if (gateScore !== null) {\r\n output.gate_score = gateScore;\r\n }\r\n\r\n return {\r\n success: true,\r\n output,\r\n errors: [],\r\n confidence: 0.75,\r\n };\r\n }\r\n\r\n // ============================================================================\r\n // Extraction Helper Methods\r\n // ============================================================================\r\n\r\n /**\r\n * Extract confidence score from text\r\n */\r\n private extractConfidence(text: string): number {\r\n // Look for explicit confidence score (fixed regex to match only valid decimals)\r\n const match =\r\n text.match(/confidence[:\\s]+([0-9]+(?:\\.[0-9]+)?)/i) ||\r\n text.match(/confidence score[:\\s]+([0-9]+(?:\\.[0-9]+)?)/i);\r\n\r\n if (match) {\r\n const value = parseFloat(match[1]);\r\n // Handle both 0.0-1.0 and 0-100 formats\r\n if (value >= 0 && value <= 1) {\r\n return value;\r\n }\r\n if (value > 1 && value <= 100) {\r\n return value / 100;\r\n }\r\n }\r\n\r\n // Default confidence for parsed text\r\n return 0.7;\r\n }\r\n\r\n /**\r\n * Extract iteration number from text\r\n */\r\n private extractIteration(text: string): number {\r\n const match =\r\n text.match(/iteration[:\\s]+(\\d+)/i) ||\r\n text.match(/iteration (\\d+)/i);\r\n\r\n if (match) {\r\n return parseInt(match[1], 10);\r\n }\r\n\r\n return 1; // Default to iteration 1\r\n }\r\n\r\n /**\r\n * Extract agent type from text\r\n */\r\n private extractAgentType(text: string): string | null {\r\n const match =\r\n text.match(/agent[_\\s]?type[:\\s]+([a-z-]+)/i) ||\r\n text.match(/agent[:\\s]+([a-z-]+)/i);\r\n\r\n return match ? match[1] : null;\r\n }\r\n\r\n /**\r\n * Extract summary from text\r\n */\r\n private extractSummary(text: string): string | null {\r\n const match =\r\n text.match(/summary[:\\s]+(.+?)(?:\\n\\n|\\n[A-Z]|$)/is) ||\r\n text.match(/## Summary\\s*\\n(.+?)(?:\\n\\n|\\n#|$)/is);\r\n\r\n return match ? match[1].trim() : null;\r\n }\r\n\r\n /**\r\n * Extract deliverables from text\r\n */\r\n private extractDeliverables(text: string): Deliverable[] {\r\n const deliverables: Deliverable[] = [];\r\n\r\n // Look for file listings\r\n const filePatterns = [\r\n /(?:created|modified|deleted)[:\\s]+([^\\n]+)/gi,\r\n /[-*]\\s+(?:created|modified|deleted)[:\\s]+([^\\n]+)/gi,\r\n /[-*]\\s+`([^`]+)`\\s+-\\s+(created|modified|deleted)/gi,\r\n ];\r\n\r\n for (const pattern of filePatterns) {\r\n let match;\r\n while ((match = pattern.exec(text)) !== null) {\r\n const path = match[1].trim().replace(/`/g, '');\r\n const status = this.extractDeliverableStatus(match[0]);\r\n\r\n deliverables.push({\r\n path,\r\n type: this.guessDeliverableType(path),\r\n status: status || 'created',\r\n });\r\n }\r\n }\r\n\r\n return deliverables;\r\n }\r\n\r\n /**\r\n * Extract deliverable status from text\r\n */\r\n private extractDeliverableStatus(\r\n text: string\r\n ): 'created' | 'modified' | 'deleted' | null {\r\n const lower = text.toLowerCase();\r\n if (lower.includes('created')) return 'created';\r\n if (lower.includes('modified')) return 'modified';\r\n if (lower.includes('deleted')) return 'deleted';\r\n return null;\r\n }\r\n\r\n /**\r\n * Guess deliverable type from file path\r\n */\r\n private guessDeliverableType(path: string): Deliverable['type'] {\r\n const lower = path.toLowerCase();\r\n\r\n if (lower.match(/\\.test\\.|\\.spec\\.|test\\/|tests\\//)) return 'test';\r\n if (lower.match(/\\.md$|readme|docs?\\//)) return 'documentation';\r\n if (lower.match(/\\.json$|\\.ya?ml$|\\.toml$|\\.ini$/)) return 'config';\r\n if (lower.match(/schema|\\.graphql$/)) return 'schema';\r\n if (lower.match(/\\.sh$|\\.bash$|scripts?\\//)) return 'script';\r\n if (lower.match(/\\.ts$|\\.js$|\\.py$|src\\//)) return 'implementation';\r\n\r\n return 'other';\r\n }\r\n\r\n /**\r\n * Extract metrics from text\r\n */\r\n private extractMetrics(text: string): Record<string, number> {\r\n const metrics: Record<string, number> = {};\r\n\r\n const patterns = [\r\n { key: 'files_created', pattern: /(\\d+)\\s+files?\\s+created/i },\r\n { key: 'files_modified', pattern: /(\\d+)\\s+files?\\s+modified/i },\r\n { key: 'lines_of_code', pattern: /(\\d+)\\s+lines?\\s+of\\s+code/i },\r\n {\r\n key: 'test_coverage',\r\n pattern: /(?:coverage|test coverage)[:\\s]+([0-9]+(?:\\.[0-9]+)?)%?/i,\r\n },\r\n { key: 'tests_passed', pattern: /(\\d+)\\s+tests?\\s+passed/i },\r\n { key: 'tests_failed', pattern: /(\\d+)\\s+tests?\\s+failed/i },\r\n ];\r\n\r\n for (const { key, pattern } of patterns) {\r\n const match = text.match(pattern);\r\n if (match) {\r\n let value = parseFloat(match[1]);\r\n // Convert percentage to 0.0-1.0 for test_coverage\r\n if (key === 'test_coverage' && value > 1) {\r\n value = value / 100;\r\n }\r\n metrics[key] = value;\r\n }\r\n }\r\n\r\n return metrics;\r\n }\r\n\r\n /**\r\n * Extract validation type from text\r\n */\r\n private extractValidationType(text: string): Loop2Output['validation_type'] {\r\n const lower = text.toLowerCase();\r\n\r\n if (lower.includes('security')) return 'security';\r\n if (lower.includes('test')) return 'test';\r\n if (lower.includes('architecture')) return 'architecture';\r\n if (lower.includes('performance')) return 'performance';\r\n if (lower.includes('compliance')) return 'compliance';\r\n\r\n return 'review'; // Default\r\n }\r\n\r\n /**\r\n * Extract issues from text\r\n */\r\n private extractIssues(text: string): Issue[] {\r\n const issues: Issue[] = [];\r\n\r\n // Look for issue listings\r\n const issuePatterns = [\r\n /[-*]\\s+\\[([^\\]]+)\\]\\s+([^\\n]+)/g,\r\n /[-*]\\s+(critical|high|medium|low|info)[:\\s]+([^\\n]+)/gi,\r\n ];\r\n\r\n for (const pattern of issuePatterns) {\r\n let match;\r\n while ((match = pattern.exec(text)) !== null) {\r\n const severity = this.parseSeverity(match[1]);\r\n const message = match[2].trim();\r\n\r\n issues.push({\r\n severity,\r\n category: 'other',\r\n message,\r\n });\r\n }\r\n }\r\n\r\n return issues;\r\n }\r\n\r\n /**\r\n * Parse severity from text\r\n */\r\n private parseSeverity(text: string): Issue['severity'] {\r\n const lower = text.toLowerCase();\r\n\r\n if (lower.includes('critical')) return 'critical';\r\n if (lower.includes('high')) return 'high';\r\n if (lower.includes('medium')) return 'medium';\r\n if (lower.includes('low')) return 'low';\r\n\r\n return 'info';\r\n }\r\n\r\n /**\r\n * Extract recommendations from text\r\n */\r\n private extractRecommendations(text: string): string[] {\r\n const recommendations: string[] = [];\r\n\r\n // Look for recommendation listings\r\n const patterns = [\r\n /recommendation[s]?[:\\s]+([^\\n]+)/gi,\r\n /[-*]\\s+(?:recommend|suggestion)[:\\s]+([^\\n]+)/gi,\r\n ];\r\n\r\n for (const pattern of patterns) {\r\n let match;\r\n while ((match = pattern.exec(text)) !== null) {\r\n recommendations.push(match[1].trim());\r\n }\r\n }\r\n\r\n return recommendations;\r\n }\r\n\r\n /**\r\n * Extract approval status from text\r\n */\r\n private extractApproval(text: string): boolean {\r\n const lower = text.toLowerCase();\r\n\r\n // Explicit approval/rejection\r\n if (/\\bapproved\\b/i.test(text)) return true;\r\n if (/\\brejected\\b/i.test(text)) return false;\r\n\r\n // Implicit approval from consensus (fixed regex to match only valid decimals)\r\n if (/consensus[:\\s]+([0-9]+(?:\\.[0-9]+)?)/i.test(text)) {\r\n const match = text.match(/consensus[:\\s]+([0-9]+(?:\\.[0-9]+)?)/i);\r\n if (match) {\r\n const score = parseFloat(match[1]);\r\n return score >= 0.9; // Default threshold\r\n }\r\n }\r\n\r\n return false; // Default to not approved\r\n }\r\n\r\n /**\r\n * Extract Product Owner decision\r\n */\r\n private extractDecision(\r\n text: string\r\n ): ProductOwnerOutput['decision'] | null {\r\n const match = text.match(/\\b(PROCEED|ITERATE|ABORT)\\b/);\r\n return match ? (match[1] as ProductOwnerOutput['decision']) : null;\r\n }\r\n\r\n /**\r\n * Extract rationale from text\r\n */\r\n private extractRationale(text: string): string {\r\n const match =\r\n text.match(/rationale[:\\s]+(.+?)(?:\\n\\n|\\n[A-Z]|$)/is) ||\r\n text.match(/reason[:\\s]+(.+?)(?:\\n\\n|\\n[A-Z]|$)/is);\r\n\r\n return match\r\n ? match[1].trim()\r\n : 'No rationale provided in legacy output';\r\n }\r\n\r\n /**\r\n * Extract deliverables validated status\r\n */\r\n private extractDeliverablesValidated(text: string): boolean {\r\n const lower = text.toLowerCase();\r\n return (\r\n lower.includes('deliverables validated') ||\r\n lower.includes('all deliverables') ||\r\n lower.includes('deliverables complete')\r\n );\r\n }\r\n\r\n /**\r\n * Extract next action from text\r\n */\r\n private extractNextAction(text: string): string {\r\n const match =\r\n text.match(/next[_\\s]action[:\\s]+([^\\n]+)/i) ||\r\n text.match(/action[:\\s]+([^\\n]+)/i);\r\n\r\n if (match) {\r\n return match[1].trim();\r\n }\r\n\r\n // Infer from decision\r\n const decision = this.extractDecision(text);\r\n if (decision === 'PROCEED') return 'mark_task_complete';\r\n if (decision === 'ITERATE') return 'start_next_iteration';\r\n if (decision === 'ABORT') return 'abort_task';\r\n\r\n return 'unknown';\r\n }\r\n\r\n /**\r\n * Extract consensus score from text\r\n */\r\n private extractConsensusScore(text: string): number | null {\r\n const match =\r\n text.match(/consensus[_\\s]score[:\\s]+([0-9]+(?:\\.[0-9]+)?)/i) ||\r\n text.match(/consensus[:\\s]+([0-9]+(?:\\.[0-9]+)?)/i);\r\n\r\n if (match) {\r\n const value = parseFloat(match[1]);\r\n return value >= 0 && value <= 1 ? value : value / 100;\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Extract gate score from text\r\n */\r\n private extractGateScore(text: string): number | null {\r\n const match =\r\n text.match(/gate[_\\s]score[:\\s]+([0-9]+(?:\\.[0-9]+)?)/i) ||\r\n text.match(/gate[:\\s]+([0-9]+(?:\\.[0-9]+)?)/i);\r\n\r\n if (match) {\r\n const value = parseFloat(match[1]);\r\n return value >= 0 && value <= 1 ? value : value / 100;\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Extract errors from text\r\n */\r\n private extractErrors(text: string): AgentError[] {\r\n const errors: AgentError[] = [];\r\n\r\n // Look for error listings\r\n const errorPatterns = [\r\n /error[:\\s]+\\[([^\\]]+)\\]\\s+([^\\n]+)/gi,\r\n /\\[ERROR\\]\\s+([^\\n]+)/gi,\r\n ];\r\n\r\n for (const pattern of errorPatterns) {\r\n let match;\r\n while ((match = pattern.exec(text)) !== null) {\r\n const code = match[1] || 'UNKNOWN_ERROR';\r\n const message = match[2] || match[1];\r\n\r\n errors.push({\r\n code: code.trim(),\r\n message: message.trim(),\r\n });\r\n }\r\n }\r\n\r\n return errors;\r\n }\r\n}\r\n\r\n// ============================================================================\r\n// Singleton Instance and Convenience Functions\r\n// ============================================================================\r\n\r\nlet parserInstance: AgentOutputParser | null = null;\r\n\r\n/**\r\n * Get or create parser instance\r\n */\r\nexport function getParser(): AgentOutputParser {\r\n if (!parserInstance) {\r\n parserInstance = new AgentOutputParser();\r\n }\r\n return parserInstance;\r\n}\r\n\r\n/**\r\n * Parse text output to structured agent output\r\n */\r\nexport function parseAgentOutput(text: string): ParseResult {\r\n return getParser().parse(text);\r\n}\r\n\r\n/**\r\n * Reset parser instance (useful for testing)\r\n */\r\nexport function resetParser(): void {\r\n parserInstance = null;\r\n}\r\n\r\nexport default AgentOutputParser;\r\n"],"names":["AgentOutputParser","parse","text","errors","confidence","jsonOutput","tryParseJSON","success","output","outputType","detectOutputType","parseLoop3Text","parseLoop2Text","parseProductOwnerText","error","Error","message","String","obj","JSON","isValidAgentOutput","jsonMatch","match","record","output_type","lower","toLowerCase","test","extractConfidence","iteration","extractIteration","deliverables","extractDeliverables","extractErrors","metadata","agent_type","extractAgentType","timestamp","Date","toISOString","summary","extractSummary","metrics","extractMetrics","Object","keys","length","validation_type","extractValidationType","issues","extractIssues","recommendations","extractRecommendations","approved","extractApproval","decision","extractDecision","rationale","extractRationale","deliverables_validated","extractDeliverablesValidated","next_action","extractNextAction","consensusScore","extractConsensusScore","consensus_score","gateScore","extractGateScore","gate_score","value","parseFloat","parseInt","trim","filePatterns","pattern","exec","path","replace","status","extractDeliverableStatus","push","type","guessDeliverableType","includes","patterns","key","issuePatterns","severity","parseSeverity","category","score","errorPatterns","code","parserInstance","getParser","parseAgentOutput","resetParser"],"mappings":"AAAA;;;;;;CAMC,GAaD,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E;;;CAGC,GACD,OAAO,MAAMA;IACX;;GAEC,GACD,AAAOC,MAAMC,IAAY,EAAe;QACtC,MAAMC,SAAmB,EAAE;QAC3B,IAAIC,aAAa,KAAK,wCAAwC;QAE9D,IAAI;YACF,iCAAiC;YACjC,MAAMC,aAAa,IAAI,CAACC,YAAY,CAACJ;YACrC,IAAIG,YAAY;gBACd,OAAO;oBACLE,SAAS;oBACTC,QAAQH;oBACRF,QAAQ,EAAE;oBACVC,YAAY;gBACd;YACF;YAEA,wCAAwC;YACxC,MAAMK,aAAa,IAAI,CAACC,gBAAgB,CAACR;YAEzC,+BAA+B;YAC/B,OAAQO;gBACN,KAAK;oBACH,OAAO,IAAI,CAACE,cAAc,CAACT;gBAC7B,KAAK;oBACH,OAAO,IAAI,CAACU,cAAc,CAACV;gBAC7B,KAAK;oBACH,OAAO,IAAI,CAACW,qBAAqB,CAACX;gBACpC;oBACE,OAAO;wBACLK,SAAS;wBACTJ,QAAQ;4BAAC;yBAA+C;wBACxDC,YAAY;oBACd;YACJ;QACF,EAAE,OAAOU,OAAO;YACd,O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