musubi-sdd 5.1.0 → 5.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +106 -48
- package/README.md +110 -32
- package/bin/musubi-analyze.js +74 -67
- package/bin/musubi-browser.js +27 -26
- package/bin/musubi-change.js +48 -47
- package/bin/musubi-checkpoint.js +10 -7
- package/bin/musubi-convert.js +25 -25
- package/bin/musubi-costs.js +27 -10
- package/bin/musubi-gui.js +52 -46
- package/bin/musubi-init.js +1952 -10
- package/bin/musubi-orchestrate.js +327 -239
- package/bin/musubi-remember.js +69 -56
- package/bin/musubi-resolve.js +53 -45
- package/bin/musubi-trace.js +51 -22
- package/bin/musubi-validate.js +39 -30
- package/bin/musubi-workflow.js +33 -34
- package/bin/musubi.js +39 -2
- package/package.json +1 -1
- package/src/agents/agent-loop.js +94 -95
- package/src/agents/agentic/code-generator.js +119 -109
- package/src/agents/agentic/code-reviewer.js +105 -108
- package/src/agents/agentic/index.js +4 -4
- package/src/agents/browser/action-executor.js +13 -13
- package/src/agents/browser/ai-comparator.js +11 -10
- package/src/agents/browser/context-manager.js +6 -6
- package/src/agents/browser/index.js +5 -5
- package/src/agents/browser/nl-parser.js +31 -46
- package/src/agents/browser/screenshot.js +2 -2
- package/src/agents/browser/test-generator.js +6 -4
- package/src/agents/function-tool.js +71 -65
- package/src/agents/index.js +7 -7
- package/src/agents/schema-generator.js +98 -94
- package/src/analyzers/ast-extractor.js +158 -146
- package/src/analyzers/codegraph-auto-update.js +858 -0
- package/src/analyzers/complexity-analyzer.js +536 -0
- package/src/analyzers/context-optimizer.js +241 -126
- package/src/analyzers/impact-analyzer.js +1 -1
- package/src/analyzers/large-project-analyzer.js +766 -0
- package/src/analyzers/repository-map.js +77 -81
- package/src/analyzers/security-analyzer.js +19 -11
- package/src/analyzers/stuck-detector.js +19 -17
- package/src/converters/index.js +78 -57
- package/src/converters/ir/types.js +12 -12
- package/src/converters/parsers/musubi-parser.js +134 -126
- package/src/converters/parsers/openapi-parser.js +70 -53
- package/src/converters/parsers/speckit-parser.js +239 -175
- package/src/converters/writers/musubi-writer.js +123 -118
- package/src/converters/writers/speckit-writer.js +124 -113
- package/src/generators/rust-migration-generator.js +512 -0
- package/src/gui/public/index.html +1365 -1211
- package/src/gui/server.js +41 -40
- package/src/gui/services/file-watcher.js +23 -8
- package/src/gui/services/project-scanner.js +26 -20
- package/src/gui/services/replanning-service.js +27 -23
- package/src/gui/services/traceability-service.js +8 -8
- package/src/gui/services/workflow-service.js +14 -7
- package/src/index.js +151 -0
- package/src/integrations/cicd.js +90 -104
- package/src/integrations/codegraph-mcp.js +643 -0
- package/src/integrations/documentation.js +142 -103
- package/src/integrations/examples.js +95 -80
- package/src/integrations/github-client.js +17 -17
- package/src/integrations/index.js +5 -5
- package/src/integrations/mcp/index.js +21 -21
- package/src/integrations/mcp/mcp-context-provider.js +76 -78
- package/src/integrations/mcp/mcp-discovery.js +74 -72
- package/src/integrations/mcp/mcp-tool-registry.js +99 -94
- package/src/integrations/mcp-connector.js +70 -66
- package/src/integrations/platforms.js +50 -49
- package/src/integrations/tool-discovery.js +37 -31
- package/src/llm-providers/anthropic-provider.js +11 -11
- package/src/llm-providers/base-provider.js +16 -18
- package/src/llm-providers/copilot-provider.js +22 -19
- package/src/llm-providers/index.js +26 -25
- package/src/llm-providers/ollama-provider.js +11 -11
- package/src/llm-providers/openai-provider.js +12 -12
- package/src/managers/agent-memory.js +36 -24
- package/src/managers/checkpoint-manager.js +4 -8
- package/src/managers/delta-spec.js +19 -19
- package/src/managers/index.js +13 -4
- package/src/managers/memory-condenser.js +35 -45
- package/src/managers/repo-skill-manager.js +57 -31
- package/src/managers/skill-loader.js +25 -22
- package/src/managers/skill-tools.js +36 -72
- package/src/managers/workflow.js +30 -22
- package/src/monitoring/cost-tracker.js +48 -46
- package/src/monitoring/incident-manager.js +116 -106
- package/src/monitoring/index.js +144 -134
- package/src/monitoring/observability.js +75 -62
- package/src/monitoring/quality-dashboard.js +45 -41
- package/src/monitoring/release-manager.js +63 -53
- package/src/orchestration/agent-skill-binding.js +39 -47
- package/src/orchestration/error-handler.js +65 -107
- package/src/orchestration/guardrails/base-guardrail.js +26 -24
- package/src/orchestration/guardrails/guardrail-rules.js +50 -64
- package/src/orchestration/guardrails/index.js +5 -5
- package/src/orchestration/guardrails/input-guardrail.js +58 -45
- package/src/orchestration/guardrails/output-guardrail.js +104 -81
- package/src/orchestration/guardrails/safety-check.js +79 -79
- package/src/orchestration/index.js +38 -55
- package/src/orchestration/mcp-tool-adapters.js +96 -99
- package/src/orchestration/orchestration-engine.js +21 -21
- package/src/orchestration/pattern-registry.js +60 -45
- package/src/orchestration/patterns/auto.js +34 -47
- package/src/orchestration/patterns/group-chat.js +59 -65
- package/src/orchestration/patterns/handoff.js +67 -65
- package/src/orchestration/patterns/human-in-loop.js +51 -72
- package/src/orchestration/patterns/nested.js +25 -40
- package/src/orchestration/patterns/sequential.js +35 -34
- package/src/orchestration/patterns/swarm.js +63 -56
- package/src/orchestration/patterns/triage.js +150 -109
- package/src/orchestration/reasoning/index.js +9 -9
- package/src/orchestration/reasoning/planning-engine.js +143 -140
- package/src/orchestration/reasoning/reasoning-engine.js +206 -144
- package/src/orchestration/reasoning/self-correction.js +121 -128
- package/src/orchestration/replanning/adaptive-goal-modifier.js +107 -112
- package/src/orchestration/replanning/alternative-generator.js +37 -42
- package/src/orchestration/replanning/config.js +63 -59
- package/src/orchestration/replanning/goal-progress-tracker.js +98 -100
- package/src/orchestration/replanning/index.js +24 -20
- package/src/orchestration/replanning/plan-evaluator.js +49 -50
- package/src/orchestration/replanning/plan-monitor.js +32 -28
- package/src/orchestration/replanning/proactive-path-optimizer.js +175 -178
- package/src/orchestration/replanning/replan-history.js +33 -26
- package/src/orchestration/replanning/replanning-engine.js +106 -108
- package/src/orchestration/skill-executor.js +107 -109
- package/src/orchestration/skill-registry.js +85 -89
- package/src/orchestration/workflow-examples.js +228 -231
- package/src/orchestration/workflow-executor.js +65 -68
- package/src/orchestration/workflow-orchestrator.js +72 -73
- package/src/phase4-integration.js +47 -40
- package/src/phase5-integration.js +89 -30
- package/src/reporters/coverage-report.js +82 -30
- package/src/reporters/hierarchical-reporter.js +498 -0
- package/src/reporters/traceability-matrix-report.js +29 -20
- package/src/resolvers/issue-resolver.js +43 -31
- package/src/steering/advanced-validation.js +133 -124
- package/src/steering/auto-updater.js +60 -73
- package/src/steering/index.js +6 -6
- package/src/steering/quality-metrics.js +41 -35
- package/src/steering/steering-auto-update.js +83 -86
- package/src/steering/steering-validator.js +98 -106
- package/src/steering/template-constraints.js +53 -54
- package/src/templates/agents/claude-code/CLAUDE.md +32 -32
- package/src/templates/agents/claude-code/skills/agent-assistant/SKILL.md +13 -5
- package/src/templates/agents/claude-code/skills/ai-ml-engineer/mlops-guide.md +23 -23
- package/src/templates/agents/claude-code/skills/ai-ml-engineer/model-card-template.md +60 -41
- package/src/templates/agents/claude-code/skills/api-designer/api-patterns.md +27 -19
- package/src/templates/agents/claude-code/skills/api-designer/openapi-template.md +11 -7
- package/src/templates/agents/claude-code/skills/bug-hunter/SKILL.md +4 -3
- package/src/templates/agents/claude-code/skills/bug-hunter/root-cause-analysis.md +37 -15
- package/src/templates/agents/claude-code/skills/change-impact-analyzer/dependency-graph-patterns.md +36 -42
- package/src/templates/agents/claude-code/skills/change-impact-analyzer/impact-analysis-template.md +69 -60
- package/src/templates/agents/claude-code/skills/cloud-architect/aws-patterns.md +31 -38
- package/src/templates/agents/claude-code/skills/cloud-architect/azure-patterns.md +28 -23
- package/src/templates/agents/claude-code/skills/code-reviewer/SKILL.md +61 -0
- package/src/templates/agents/claude-code/skills/code-reviewer/best-practices.md +27 -0
- package/src/templates/agents/claude-code/skills/code-reviewer/review-checklist.md +29 -10
- package/src/templates/agents/claude-code/skills/code-reviewer/review-standards.md +29 -24
- package/src/templates/agents/claude-code/skills/constitution-enforcer/SKILL.md +8 -6
- package/src/templates/agents/claude-code/skills/constitution-enforcer/constitutional-articles.md +62 -26
- package/src/templates/agents/claude-code/skills/constitution-enforcer/phase-minus-one-gates.md +35 -16
- package/src/templates/agents/claude-code/skills/database-administrator/backup-recovery.md +27 -17
- package/src/templates/agents/claude-code/skills/database-administrator/tuning-guide.md +25 -20
- package/src/templates/agents/claude-code/skills/database-schema-designer/schema-patterns.md +39 -22
- package/src/templates/agents/claude-code/skills/devops-engineer/ci-cd-templates.md +25 -22
- package/src/templates/agents/claude-code/skills/issue-resolver/SKILL.md +24 -21
- package/src/templates/agents/claude-code/skills/orchestrator/SKILL.md +148 -63
- package/src/templates/agents/claude-code/skills/orchestrator/patterns.md +35 -16
- package/src/templates/agents/claude-code/skills/orchestrator/selection-matrix.md +69 -64
- package/src/templates/agents/claude-code/skills/performance-engineer/optimization-playbook.md +47 -47
- package/src/templates/agents/claude-code/skills/performance-optimizer/SKILL.md +69 -0
- package/src/templates/agents/claude-code/skills/performance-optimizer/benchmark-template.md +63 -45
- package/src/templates/agents/claude-code/skills/performance-optimizer/optimization-patterns.md +33 -35
- package/src/templates/agents/claude-code/skills/project-manager/SKILL.md +7 -6
- package/src/templates/agents/claude-code/skills/project-manager/agile-ceremonies.md +47 -28
- package/src/templates/agents/claude-code/skills/project-manager/project-templates.md +94 -78
- package/src/templates/agents/claude-code/skills/quality-assurance/SKILL.md +20 -17
- package/src/templates/agents/claude-code/skills/quality-assurance/qa-plan-template.md +63 -49
- package/src/templates/agents/claude-code/skills/release-coordinator/SKILL.md +5 -5
- package/src/templates/agents/claude-code/skills/release-coordinator/feature-flag-guide.md +30 -26
- package/src/templates/agents/claude-code/skills/release-coordinator/release-plan-template.md +67 -35
- package/src/templates/agents/claude-code/skills/requirements-analyst/ears-format.md +54 -42
- package/src/templates/agents/claude-code/skills/requirements-analyst/validation-rules.md +36 -33
- package/src/templates/agents/claude-code/skills/security-auditor/SKILL.md +77 -19
- package/src/templates/agents/claude-code/skills/security-auditor/audit-checklists.md +24 -24
- package/src/templates/agents/claude-code/skills/security-auditor/owasp-top-10.md +61 -20
- package/src/templates/agents/claude-code/skills/security-auditor/vulnerability-patterns.md +43 -11
- package/src/templates/agents/claude-code/skills/site-reliability-engineer/SKILL.md +1 -0
- package/src/templates/agents/claude-code/skills/site-reliability-engineer/incident-response-template.md +55 -25
- package/src/templates/agents/claude-code/skills/site-reliability-engineer/observability-patterns.md +78 -68
- package/src/templates/agents/claude-code/skills/site-reliability-engineer/slo-sli-guide.md +73 -53
- package/src/templates/agents/claude-code/skills/software-developer/solid-principles.md +83 -37
- package/src/templates/agents/claude-code/skills/software-developer/test-first-workflow.md +38 -31
- package/src/templates/agents/claude-code/skills/steering/SKILL.md +1 -0
- package/src/templates/agents/claude-code/skills/steering/auto-update-rules.md +31 -0
- package/src/templates/agents/claude-code/skills/system-architect/adr-template.md +25 -7
- package/src/templates/agents/claude-code/skills/system-architect/c4-model-guide.md +74 -61
- package/src/templates/agents/claude-code/skills/technical-writer/doc-templates/documentation-templates.md +70 -52
- package/src/templates/agents/claude-code/skills/test-engineer/SKILL.md +2 -0
- package/src/templates/agents/claude-code/skills/test-engineer/ears-test-mapping.md +75 -71
- package/src/templates/agents/claude-code/skills/test-engineer/test-types.md +85 -63
- package/src/templates/agents/claude-code/skills/traceability-auditor/coverage-matrix-template.md +39 -36
- package/src/templates/agents/claude-code/skills/traceability-auditor/gap-detection-rules.md +22 -17
- package/src/templates/agents/claude-code/skills/ui-ux-designer/SKILL.md +1 -0
- package/src/templates/agents/claude-code/skills/ui-ux-designer/accessibility-guidelines.md +49 -75
- package/src/templates/agents/claude-code/skills/ui-ux-designer/design-system-components.md +71 -59
- package/src/templates/agents/codex/AGENTS.md +74 -42
- package/src/templates/agents/cursor/AGENTS.md +74 -42
- package/src/templates/agents/gemini-cli/GEMINI.md +74 -42
- package/src/templates/agents/github-copilot/AGENTS.md +83 -51
- package/src/templates/agents/qwen-code/QWEN.md +74 -42
- package/src/templates/agents/windsurf/AGENTS.md +74 -42
- package/src/templates/architectures/README.md +41 -0
- package/src/templates/architectures/clean-architecture/README.md +113 -0
- package/src/templates/architectures/event-driven/README.md +162 -0
- package/src/templates/architectures/hexagonal/README.md +130 -0
- package/src/templates/index.js +6 -1
- package/src/templates/locale-manager.js +16 -16
- package/src/templates/shared/delta-spec-template.md +20 -13
- package/src/templates/shared/github-actions/musubi-issue-resolver.yml +5 -5
- package/src/templates/shared/github-actions/musubi-security-check.yml +3 -3
- package/src/templates/shared/github-actions/musubi-validate.yml +4 -4
- package/src/templates/shared/steering/structure.md +95 -0
- package/src/templates/skills/browser-agent.md +21 -16
- package/src/templates/skills/web-gui.md +8 -0
- package/src/templates/template-constraints.js +50 -53
- package/src/validators/advanced-validation.js +30 -36
- package/src/validators/constitutional-validator.js +77 -73
- package/src/validators/critic-system.js +49 -59
- package/src/validators/delta-format.js +59 -55
- package/src/validators/traceability-validator.js +7 -11
|
@@ -22,7 +22,7 @@ class AlternativeGenerator {
|
|
|
22
22
|
maxAlternatives: 3,
|
|
23
23
|
minConfidence: 0.5,
|
|
24
24
|
includeRetryOption: true,
|
|
25
|
-
respectDependencies: true
|
|
25
|
+
respectDependencies: true,
|
|
26
26
|
};
|
|
27
27
|
this.contextAnalyzer = new ContextAnalyzer();
|
|
28
28
|
this.confidenceScorer = new ConfidenceScorer(options.scorerConfig);
|
|
@@ -35,7 +35,7 @@ class AlternativeGenerator {
|
|
|
35
35
|
* @param {Object} [options={}] - Generation options
|
|
36
36
|
* @returns {Promise<Alternative[]>} Ranked alternatives
|
|
37
37
|
*/
|
|
38
|
-
async generateAlternatives(failedTask, context,
|
|
38
|
+
async generateAlternatives(failedTask, context, _options = {}) {
|
|
39
39
|
// Analyze context to understand the situation
|
|
40
40
|
const analysis = await this.analyzeContext(failedTask, context);
|
|
41
41
|
|
|
@@ -60,9 +60,7 @@ class AlternativeGenerator {
|
|
|
60
60
|
const scoredAlternatives = await this.scoreAlternatives(alternatives, context);
|
|
61
61
|
|
|
62
62
|
// Filter by minimum confidence
|
|
63
|
-
const filtered = scoredAlternatives.filter(
|
|
64
|
-
alt => alt.confidence >= this.config.minConfidence
|
|
65
|
-
);
|
|
63
|
+
const filtered = scoredAlternatives.filter(alt => alt.confidence >= this.config.minConfidence);
|
|
66
64
|
|
|
67
65
|
// Limit to max alternatives
|
|
68
66
|
const limited = filtered.slice(0, this.config.maxAlternatives);
|
|
@@ -86,7 +84,7 @@ class AlternativeGenerator {
|
|
|
86
84
|
* @param {Object} context - Execution context
|
|
87
85
|
* @returns {string} Goal description
|
|
88
86
|
*/
|
|
89
|
-
extractGoal(task,
|
|
87
|
+
extractGoal(task, _context) {
|
|
90
88
|
// Try to get goal from task metadata
|
|
91
89
|
if (task.goal) return task.goal;
|
|
92
90
|
if (task.description) return task.description;
|
|
@@ -112,7 +110,7 @@ class AlternativeGenerator {
|
|
|
112
110
|
* @private
|
|
113
111
|
*/
|
|
114
112
|
buildPrompt(failedTask, context, analysis, goal) {
|
|
115
|
-
const errorInfo = failedTask.error
|
|
113
|
+
const errorInfo = failedTask.error
|
|
116
114
|
? `Error: ${failedTask.error.message || failedTask.error}`
|
|
117
115
|
: 'Unknown error';
|
|
118
116
|
|
|
@@ -168,16 +166,16 @@ Provide your confidence (0.0-1.0) for each alternative based on likelihood of su
|
|
|
168
166
|
properties: {
|
|
169
167
|
name: { type: 'string' },
|
|
170
168
|
skill: { type: 'string' },
|
|
171
|
-
parameters: { type: 'object' }
|
|
172
|
-
}
|
|
169
|
+
parameters: { type: 'object' },
|
|
170
|
+
},
|
|
173
171
|
},
|
|
174
172
|
confidence: { type: 'number', minimum: 0, maximum: 1 },
|
|
175
173
|
reasoning: { type: 'string' },
|
|
176
|
-
risks: { type: 'array', items: { type: 'string' } }
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
174
|
+
risks: { type: 'array', items: { type: 'string' } },
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
},
|
|
181
179
|
};
|
|
182
180
|
}
|
|
183
181
|
|
|
@@ -189,7 +187,7 @@ Provide your confidence (0.0-1.0) for each alternative based on likelihood of su
|
|
|
189
187
|
* @returns {Alternative[]} Processed alternatives
|
|
190
188
|
* @private
|
|
191
189
|
*/
|
|
192
|
-
processLLMResponse(response, failedTask,
|
|
190
|
+
processLLMResponse(response, failedTask, _context) {
|
|
193
191
|
if (!response || !response.alternatives) {
|
|
194
192
|
return [];
|
|
195
193
|
}
|
|
@@ -202,14 +200,14 @@ Provide your confidence (0.0-1.0) for each alternative based on likelihood of su
|
|
|
202
200
|
name: alt.task?.name || failedTask.name,
|
|
203
201
|
skill: alt.task?.skill || failedTask.skill,
|
|
204
202
|
parameters: alt.task?.parameters || failedTask.parameters,
|
|
205
|
-
originalTaskId: failedTask.id
|
|
203
|
+
originalTaskId: failedTask.id,
|
|
206
204
|
},
|
|
207
205
|
confidence: alt.confidence || 0.5,
|
|
208
206
|
llmConfidence: alt.confidence || 0.5,
|
|
209
207
|
reasoning: alt.reasoning || '',
|
|
210
208
|
risks: alt.risks || [],
|
|
211
209
|
source: 'llm',
|
|
212
|
-
analysisContext: response.analysis
|
|
210
|
+
analysisContext: response.analysis,
|
|
213
211
|
}));
|
|
214
212
|
}
|
|
215
213
|
|
|
@@ -226,13 +224,13 @@ Provide your confidence (0.0-1.0) for each alternative based on likelihood of su
|
|
|
226
224
|
task: {
|
|
227
225
|
...failedTask,
|
|
228
226
|
id: `${failedTask.id || 'task'}-retry`,
|
|
229
|
-
retryOf: failedTask.id
|
|
227
|
+
retryOf: failedTask.id,
|
|
230
228
|
},
|
|
231
229
|
confidence: 0.3, // Low initial confidence for retries
|
|
232
230
|
llmConfidence: 0.3,
|
|
233
231
|
reasoning: 'Retry the failed task - may succeed on transient errors',
|
|
234
232
|
risks: ['May fail with same error', 'Time cost if error persists'],
|
|
235
|
-
source: 'system'
|
|
233
|
+
source: 'system',
|
|
236
234
|
};
|
|
237
235
|
}
|
|
238
236
|
|
|
@@ -245,12 +243,12 @@ Provide your confidence (0.0-1.0) for each alternative based on likelihood of su
|
|
|
245
243
|
*/
|
|
246
244
|
async scoreAlternatives(alternatives, context) {
|
|
247
245
|
const scored = await Promise.all(
|
|
248
|
-
alternatives.map(async
|
|
246
|
+
alternatives.map(async alt => {
|
|
249
247
|
const score = await this.confidenceScorer.score(alt, context);
|
|
250
248
|
return {
|
|
251
249
|
...alt,
|
|
252
250
|
confidence: score.overall,
|
|
253
|
-
confidenceBreakdown: score
|
|
251
|
+
confidenceBreakdown: score,
|
|
254
252
|
};
|
|
255
253
|
})
|
|
256
254
|
);
|
|
@@ -286,8 +284,8 @@ class ContextAnalyzer {
|
|
|
286
284
|
failureContext: {
|
|
287
285
|
error: failedTask.error,
|
|
288
286
|
attemptCount: failedTask.attempts || 1,
|
|
289
|
-
lastAttemptTime: failedTask.lastAttemptTime || Date.now()
|
|
290
|
-
}
|
|
287
|
+
lastAttemptTime: failedTask.lastAttemptTime || Date.now(),
|
|
288
|
+
},
|
|
291
289
|
};
|
|
292
290
|
}
|
|
293
291
|
|
|
@@ -300,10 +298,7 @@ class ContextAnalyzer {
|
|
|
300
298
|
extractAvailableSkills(context) {
|
|
301
299
|
if (context.skills) return Object.keys(context.skills);
|
|
302
300
|
if (context.registry) return context.registry.getSkillNames();
|
|
303
|
-
return [
|
|
304
|
-
'analyze', 'generate', 'validate', 'implement',
|
|
305
|
-
'test', 'review', 'document', 'deploy'
|
|
306
|
-
];
|
|
301
|
+
return ['analyze', 'generate', 'validate', 'implement', 'test', 'review', 'document', 'deploy'];
|
|
307
302
|
}
|
|
308
303
|
|
|
309
304
|
/**
|
|
@@ -316,11 +311,11 @@ class ContextAnalyzer {
|
|
|
316
311
|
extractDependencies(task, context) {
|
|
317
312
|
const taskDeps = task.dependencies || [];
|
|
318
313
|
const completedIds = (context.completed || []).map(t => t.id);
|
|
319
|
-
|
|
314
|
+
|
|
320
315
|
return {
|
|
321
316
|
required: taskDeps,
|
|
322
317
|
satisfied: taskDeps.filter(d => completedIds.includes(d)),
|
|
323
|
-
unsatisfied: taskDeps.filter(d => !completedIds.includes(d))
|
|
318
|
+
unsatisfied: taskDeps.filter(d => !completedIds.includes(d)),
|
|
324
319
|
};
|
|
325
320
|
}
|
|
326
321
|
|
|
@@ -333,10 +328,10 @@ class ContextAnalyzer {
|
|
|
333
328
|
extractResources(context) {
|
|
334
329
|
return {
|
|
335
330
|
concurrency: context.maxConcurrency || 5,
|
|
336
|
-
timeRemaining: context.timeout
|
|
331
|
+
timeRemaining: context.timeout
|
|
337
332
|
? context.timeout - (Date.now() - (context.startTime || Date.now()))
|
|
338
333
|
: null,
|
|
339
|
-
memoryAvailable: true
|
|
334
|
+
memoryAvailable: true,
|
|
340
335
|
};
|
|
341
336
|
}
|
|
342
337
|
}
|
|
@@ -354,7 +349,7 @@ class ConfidenceScorer {
|
|
|
354
349
|
llm: config.llmWeight || 0.4,
|
|
355
350
|
history: config.historyWeight || 0.3,
|
|
356
351
|
resource: config.resourceWeight || 0.2,
|
|
357
|
-
complexity: config.complexityWeight || 0.1
|
|
352
|
+
complexity: config.complexityWeight || 0.1,
|
|
358
353
|
};
|
|
359
354
|
this.history = new Map();
|
|
360
355
|
}
|
|
@@ -379,7 +374,7 @@ class ConfidenceScorer {
|
|
|
379
374
|
const complexityScore = this.getComplexityScore(alternative);
|
|
380
375
|
|
|
381
376
|
// Weighted combination
|
|
382
|
-
const overall =
|
|
377
|
+
const overall =
|
|
383
378
|
llmScore * this.weights.llm +
|
|
384
379
|
historyScore * this.weights.history +
|
|
385
380
|
resourceScore * this.weights.resource +
|
|
@@ -391,8 +386,8 @@ class ConfidenceScorer {
|
|
|
391
386
|
llm: Math.round(llmScore * 100) / 100,
|
|
392
387
|
history: Math.round(historyScore * 100) / 100,
|
|
393
388
|
resource: Math.round(resourceScore * 100) / 100,
|
|
394
|
-
complexity: Math.round(complexityScore * 100) / 100
|
|
395
|
-
}
|
|
389
|
+
complexity: Math.round(complexityScore * 100) / 100,
|
|
390
|
+
},
|
|
396
391
|
};
|
|
397
392
|
}
|
|
398
393
|
|
|
@@ -417,7 +412,7 @@ class ConfidenceScorer {
|
|
|
417
412
|
*/
|
|
418
413
|
getResourceScore(alternative, context) {
|
|
419
414
|
let score = 1.0;
|
|
420
|
-
|
|
415
|
+
|
|
421
416
|
// Check time constraints
|
|
422
417
|
if (context.resources?.timeRemaining != null) {
|
|
423
418
|
const estimatedTime = alternative.estimatedTime || 30000;
|
|
@@ -445,12 +440,12 @@ class ConfidenceScorer {
|
|
|
445
440
|
*/
|
|
446
441
|
getComplexityScore(alternative) {
|
|
447
442
|
let complexity = 0;
|
|
448
|
-
|
|
443
|
+
|
|
449
444
|
// More risks = lower score
|
|
450
445
|
if (alternative.risks) {
|
|
451
446
|
complexity += alternative.risks.length * 0.1;
|
|
452
447
|
}
|
|
453
|
-
|
|
448
|
+
|
|
454
449
|
// More parameters = slightly lower score
|
|
455
450
|
const params = alternative.task.parameters || {};
|
|
456
451
|
complexity += Object.keys(params).length * 0.02;
|
|
@@ -501,8 +496,8 @@ class ConfidenceScorer {
|
|
|
501
496
|
* @property {Object} components - Component scores
|
|
502
497
|
*/
|
|
503
498
|
|
|
504
|
-
module.exports = {
|
|
505
|
-
AlternativeGenerator,
|
|
506
|
-
ContextAnalyzer,
|
|
507
|
-
ConfidenceScorer
|
|
499
|
+
module.exports = {
|
|
500
|
+
AlternativeGenerator,
|
|
501
|
+
ContextAnalyzer,
|
|
502
|
+
ConfidenceScorer,
|
|
508
503
|
};
|
|
@@ -13,24 +13,24 @@
|
|
|
13
13
|
const ReplanTrigger = {
|
|
14
14
|
/** Task execution failed */
|
|
15
15
|
TASK_FAILED: 'task-failed',
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
/** Task execution timed out */
|
|
18
18
|
TIMEOUT: 'timeout',
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
/** Context or requirements changed */
|
|
21
21
|
CONTEXT_CHANGED: 'context-changed',
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
/** A more efficient path was discovered */
|
|
24
24
|
BETTER_PATH_FOUND: 'better-path-found',
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
/** Human operator requested replanning */
|
|
27
27
|
HUMAN_REQUEST: 'human-request',
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
/** Goal determined to be unreachable with current approach */
|
|
30
30
|
GOAL_UNREACHABLE: 'goal-unreachable',
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
/** Resource constraints changed */
|
|
33
|
-
RESOURCE_CHANGED: 'resource-changed'
|
|
33
|
+
RESOURCE_CHANGED: 'resource-changed',
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -40,30 +40,30 @@ const ReplanTrigger = {
|
|
|
40
40
|
const ReplanDecision = {
|
|
41
41
|
/** Continue with current plan */
|
|
42
42
|
CONTINUE: 'continue',
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
/** Retry the failed task */
|
|
45
45
|
RETRY: 'retry',
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
/** Skip the failed task */
|
|
48
48
|
SKIP: 'skip',
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
/** Replace task with alternative */
|
|
51
51
|
REPLACE: 'replace',
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
/** Insert new tasks into plan */
|
|
54
54
|
INSERT: 'insert',
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
/** Remove tasks from plan */
|
|
57
57
|
REMOVE: 'remove',
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
/** Reorder remaining tasks */
|
|
60
60
|
REORDER: 'reorder',
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
/** Abort execution */
|
|
63
63
|
ABORT: 'abort',
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
/** Request human intervention */
|
|
66
|
-
HUMAN_REVIEW: 'human-review'
|
|
66
|
+
HUMAN_REVIEW: 'human-review',
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
/**
|
|
@@ -85,30 +85,30 @@ const defaultReplanningConfig = {
|
|
|
85
85
|
* @type {string}
|
|
86
86
|
*/
|
|
87
87
|
provider: 'auto',
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
/**
|
|
90
90
|
* Model override (optional)
|
|
91
91
|
* @type {string|null}
|
|
92
92
|
*/
|
|
93
93
|
model: null,
|
|
94
|
-
|
|
94
|
+
|
|
95
95
|
/**
|
|
96
96
|
* Maximum tokens for LLM response
|
|
97
97
|
* @type {number}
|
|
98
98
|
*/
|
|
99
99
|
maxTokens: 2048,
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
/**
|
|
102
102
|
* Temperature for LLM generation
|
|
103
103
|
* @type {number}
|
|
104
104
|
*/
|
|
105
105
|
temperature: 0.7,
|
|
106
|
-
|
|
106
|
+
|
|
107
107
|
/**
|
|
108
108
|
* Timeout for LLM requests in milliseconds
|
|
109
109
|
* @type {number}
|
|
110
110
|
*/
|
|
111
|
-
timeout: 60000
|
|
111
|
+
timeout: 60000,
|
|
112
112
|
},
|
|
113
113
|
|
|
114
114
|
/**
|
|
@@ -123,26 +123,26 @@ const defaultReplanningConfig = {
|
|
|
123
123
|
ReplanTrigger.TASK_FAILED,
|
|
124
124
|
ReplanTrigger.TIMEOUT,
|
|
125
125
|
ReplanTrigger.CONTEXT_CHANGED,
|
|
126
|
-
ReplanTrigger.HUMAN_REQUEST
|
|
126
|
+
ReplanTrigger.HUMAN_REQUEST,
|
|
127
127
|
],
|
|
128
|
-
|
|
128
|
+
|
|
129
129
|
/**
|
|
130
130
|
* Number of consecutive failures before triggering replanning
|
|
131
131
|
* @type {number}
|
|
132
132
|
*/
|
|
133
133
|
failureThreshold: 2,
|
|
134
|
-
|
|
134
|
+
|
|
135
135
|
/**
|
|
136
136
|
* Task timeout in milliseconds
|
|
137
137
|
* @type {number}
|
|
138
138
|
*/
|
|
139
139
|
taskTimeout: 300000, // 5 minutes
|
|
140
|
-
|
|
140
|
+
|
|
141
141
|
/**
|
|
142
142
|
* Enable proactive better-path detection
|
|
143
143
|
* @type {boolean}
|
|
144
144
|
*/
|
|
145
|
-
enableBetterPathDetection: false
|
|
145
|
+
enableBetterPathDetection: false,
|
|
146
146
|
},
|
|
147
147
|
|
|
148
148
|
/**
|
|
@@ -154,30 +154,30 @@ const defaultReplanningConfig = {
|
|
|
154
154
|
* @type {number}
|
|
155
155
|
*/
|
|
156
156
|
maxAlternatives: 3,
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
/**
|
|
159
159
|
* Minimum confidence score to accept an alternative (0.0 - 1.0)
|
|
160
160
|
* @type {number}
|
|
161
161
|
*/
|
|
162
162
|
minConfidence: 0.5,
|
|
163
|
-
|
|
163
|
+
|
|
164
164
|
/**
|
|
165
165
|
* Confidence threshold requiring human approval
|
|
166
166
|
* @type {number}
|
|
167
167
|
*/
|
|
168
168
|
humanApprovalThreshold: 0.7,
|
|
169
|
-
|
|
169
|
+
|
|
170
170
|
/**
|
|
171
171
|
* Include original task as fallback option
|
|
172
172
|
* @type {boolean}
|
|
173
173
|
*/
|
|
174
174
|
includeRetryOption: true,
|
|
175
|
-
|
|
175
|
+
|
|
176
176
|
/**
|
|
177
177
|
* Consider task dependencies when generating alternatives
|
|
178
178
|
* @type {boolean}
|
|
179
179
|
*/
|
|
180
|
-
respectDependencies: true
|
|
180
|
+
respectDependencies: true,
|
|
181
181
|
},
|
|
182
182
|
|
|
183
183
|
/**
|
|
@@ -189,24 +189,24 @@ const defaultReplanningConfig = {
|
|
|
189
189
|
* @type {number}
|
|
190
190
|
*/
|
|
191
191
|
llmWeight: 0.4,
|
|
192
|
-
|
|
192
|
+
|
|
193
193
|
/**
|
|
194
194
|
* Weight for historical success rate
|
|
195
195
|
* @type {number}
|
|
196
196
|
*/
|
|
197
197
|
historyWeight: 0.3,
|
|
198
|
-
|
|
198
|
+
|
|
199
199
|
/**
|
|
200
200
|
* Weight for resource availability
|
|
201
201
|
* @type {number}
|
|
202
202
|
*/
|
|
203
203
|
resourceWeight: 0.2,
|
|
204
|
-
|
|
204
|
+
|
|
205
205
|
/**
|
|
206
206
|
* Weight for complexity score
|
|
207
207
|
* @type {number}
|
|
208
208
|
*/
|
|
209
|
-
complexityWeight: 0.1
|
|
209
|
+
complexityWeight: 0.1,
|
|
210
210
|
},
|
|
211
211
|
|
|
212
212
|
/**
|
|
@@ -218,30 +218,30 @@ const defaultReplanningConfig = {
|
|
|
218
218
|
* @type {boolean}
|
|
219
219
|
*/
|
|
220
220
|
enabled: true,
|
|
221
|
-
|
|
221
|
+
|
|
222
222
|
/**
|
|
223
223
|
* Maximum events to keep in memory
|
|
224
224
|
* @type {number}
|
|
225
225
|
*/
|
|
226
226
|
maxEvents: 1000,
|
|
227
|
-
|
|
227
|
+
|
|
228
228
|
/**
|
|
229
229
|
* Persist history to file system
|
|
230
230
|
* @type {boolean}
|
|
231
231
|
*/
|
|
232
232
|
persist: false,
|
|
233
|
-
|
|
233
|
+
|
|
234
234
|
/**
|
|
235
235
|
* History file path (relative to project root)
|
|
236
236
|
* @type {string}
|
|
237
237
|
*/
|
|
238
238
|
filePath: 'storage/replanning-history.json',
|
|
239
|
-
|
|
239
|
+
|
|
240
240
|
/**
|
|
241
241
|
* Export format for reports
|
|
242
242
|
* @type {string}
|
|
243
243
|
*/
|
|
244
|
-
exportFormat: 'markdown'
|
|
244
|
+
exportFormat: 'markdown',
|
|
245
245
|
},
|
|
246
246
|
|
|
247
247
|
/**
|
|
@@ -253,24 +253,24 @@ const defaultReplanningConfig = {
|
|
|
253
253
|
* @type {boolean}
|
|
254
254
|
*/
|
|
255
255
|
enabled: true,
|
|
256
|
-
|
|
256
|
+
|
|
257
257
|
/**
|
|
258
258
|
* Timeout for human response in milliseconds
|
|
259
259
|
* @type {number}
|
|
260
260
|
*/
|
|
261
261
|
timeout: 300000, // 5 minutes
|
|
262
|
-
|
|
262
|
+
|
|
263
263
|
/**
|
|
264
264
|
* Default action on timeout
|
|
265
265
|
* @type {string}
|
|
266
266
|
*/
|
|
267
267
|
defaultOnTimeout: 'abort',
|
|
268
|
-
|
|
268
|
+
|
|
269
269
|
/**
|
|
270
270
|
* Always require approval for these trigger types
|
|
271
271
|
* @type {string[]}
|
|
272
272
|
*/
|
|
273
|
-
alwaysApprove: [ReplanTrigger.GOAL_UNREACHABLE]
|
|
273
|
+
alwaysApprove: [ReplanTrigger.GOAL_UNREACHABLE],
|
|
274
274
|
},
|
|
275
275
|
|
|
276
276
|
/**
|
|
@@ -282,19 +282,19 @@ const defaultReplanningConfig = {
|
|
|
282
282
|
* @type {string[]}
|
|
283
283
|
*/
|
|
284
284
|
enabledPatterns: ['swarm', 'sequential', 'workflow'],
|
|
285
|
-
|
|
285
|
+
|
|
286
286
|
/**
|
|
287
287
|
* Emit events for replanning actions
|
|
288
288
|
* @type {boolean}
|
|
289
289
|
*/
|
|
290
290
|
emitEvents: true,
|
|
291
|
-
|
|
291
|
+
|
|
292
292
|
/**
|
|
293
293
|
* Event prefix for replanning events
|
|
294
294
|
* @type {string}
|
|
295
295
|
*/
|
|
296
|
-
eventPrefix: 'replan'
|
|
297
|
-
}
|
|
296
|
+
eventPrefix: 'replan',
|
|
297
|
+
},
|
|
298
298
|
};
|
|
299
299
|
|
|
300
300
|
/**
|
|
@@ -315,7 +315,7 @@ function mergeConfig(userConfig = {}) {
|
|
|
315
315
|
*/
|
|
316
316
|
function deepMerge(target, source) {
|
|
317
317
|
const result = { ...target };
|
|
318
|
-
|
|
318
|
+
|
|
319
319
|
for (const key of Object.keys(source)) {
|
|
320
320
|
if (source[key] instanceof Object && key in target && target[key] instanceof Object) {
|
|
321
321
|
result[key] = deepMerge(target[key], source[key]);
|
|
@@ -323,7 +323,7 @@ function deepMerge(target, source) {
|
|
|
323
323
|
result[key] = source[key];
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
|
|
326
|
+
|
|
327
327
|
return result;
|
|
328
328
|
}
|
|
329
329
|
|
|
@@ -339,18 +339,22 @@ function validateConfig(config) {
|
|
|
339
339
|
if (config.alternatives?.minConfidence < 0 || config.alternatives?.minConfidence > 1) {
|
|
340
340
|
errors.push('alternatives.minConfidence must be between 0 and 1');
|
|
341
341
|
}
|
|
342
|
-
|
|
343
|
-
if (
|
|
342
|
+
|
|
343
|
+
if (
|
|
344
|
+
config.alternatives?.humanApprovalThreshold < 0 ||
|
|
345
|
+
config.alternatives?.humanApprovalThreshold > 1
|
|
346
|
+
) {
|
|
344
347
|
errors.push('alternatives.humanApprovalThreshold must be between 0 and 1');
|
|
345
348
|
}
|
|
346
349
|
|
|
347
350
|
// Validate evaluation weights sum to 1
|
|
348
351
|
const evaluation = config.evaluation || {};
|
|
349
|
-
const weightSum =
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
352
|
+
const weightSum =
|
|
353
|
+
(evaluation.llmWeight || 0) +
|
|
354
|
+
(evaluation.historyWeight || 0) +
|
|
355
|
+
(evaluation.resourceWeight || 0) +
|
|
356
|
+
(evaluation.complexityWeight || 0);
|
|
357
|
+
|
|
354
358
|
if (Math.abs(weightSum - 1.0) > 0.01) {
|
|
355
359
|
errors.push(`Evaluation weights must sum to 1.0, got ${weightSum}`);
|
|
356
360
|
}
|
|
@@ -365,7 +369,7 @@ function validateConfig(config) {
|
|
|
365
369
|
|
|
366
370
|
return {
|
|
367
371
|
valid: errors.length === 0,
|
|
368
|
-
errors
|
|
372
|
+
errors,
|
|
369
373
|
};
|
|
370
374
|
}
|
|
371
375
|
|
|
@@ -374,5 +378,5 @@ module.exports = {
|
|
|
374
378
|
ReplanDecision,
|
|
375
379
|
defaultReplanningConfig,
|
|
376
380
|
mergeConfig,
|
|
377
|
-
validateConfig
|
|
381
|
+
validateConfig,
|
|
378
382
|
};
|