musubi-sdd 5.0.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 +164 -145
- package/src/analyzers/codegraph-auto-update.js +858 -0
- package/src/analyzers/complexity-analyzer.js +536 -0
- package/src/analyzers/context-optimizer.js +247 -125
- package/src/analyzers/impact-analyzer.js +1 -1
- package/src/analyzers/large-project-analyzer.js +766 -0
- package/src/analyzers/repository-map.js +83 -80
- 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 +53 -44
- package/src/monitoring/incident-manager.js +123 -103
- package/src/monitoring/index.js +144 -134
- package/src/monitoring/observability.js +82 -59
- package/src/monitoring/quality-dashboard.js +51 -39
- package/src/monitoring/release-manager.js +70 -50
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* HumanInLoopPattern - Validation gates with human interaction
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Enables human validation at key points in the workflow.
|
|
5
5
|
* Supports approval gates, feedback collection, and decision points.
|
|
6
6
|
*/
|
|
@@ -12,10 +12,10 @@ const { PatternType, ExecutionContext, ExecutionStatus } = require('../orchestra
|
|
|
12
12
|
* Gate type
|
|
13
13
|
*/
|
|
14
14
|
const GateType = {
|
|
15
|
-
APPROVAL: 'approval',
|
|
16
|
-
REVIEW: 'review',
|
|
17
|
-
DECISION: 'decision',
|
|
18
|
-
CONFIRMATION: 'confirmation'
|
|
15
|
+
APPROVAL: 'approval', // Yes/No approval
|
|
16
|
+
REVIEW: 'review', // Review with feedback
|
|
17
|
+
DECISION: 'decision', // Multiple choice decision
|
|
18
|
+
CONFIRMATION: 'confirmation', // Simple confirmation
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -26,7 +26,7 @@ const GateResult = {
|
|
|
26
26
|
REJECTED: 'rejected',
|
|
27
27
|
NEEDS_CHANGES: 'needs-changes',
|
|
28
28
|
TIMEOUT: 'timeout',
|
|
29
|
-
SKIPPED: 'skipped'
|
|
29
|
+
SKIPPED: 'skipped',
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
/**
|
|
@@ -40,15 +40,10 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
40
40
|
description: 'Enable human validation gates at key workflow points',
|
|
41
41
|
version: '1.0.0',
|
|
42
42
|
tags: ['validation', 'human', 'approval', 'gate'],
|
|
43
|
-
useCases: [
|
|
44
|
-
'Quality gates',
|
|
45
|
-
'Approval workflows',
|
|
46
|
-
'Decision points',
|
|
47
|
-
'Review processes'
|
|
48
|
-
],
|
|
43
|
+
useCases: ['Quality gates', 'Approval workflows', 'Decision points', 'Review processes'],
|
|
49
44
|
complexity: 'medium',
|
|
50
45
|
supportsParallel: false,
|
|
51
|
-
requiresHuman: true
|
|
46
|
+
requiresHuman: true,
|
|
52
47
|
});
|
|
53
48
|
|
|
54
49
|
this.options = {
|
|
@@ -56,7 +51,7 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
56
51
|
autoApproveOnTimeout: options.autoApproveOnTimeout || false,
|
|
57
52
|
collectFeedback: options.collectFeedback || true,
|
|
58
53
|
notifyOnGate: options.notifyOnGate || true,
|
|
59
|
-
...options
|
|
54
|
+
...options,
|
|
60
55
|
};
|
|
61
56
|
}
|
|
62
57
|
|
|
@@ -79,15 +74,15 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
79
74
|
// Validate each step
|
|
80
75
|
for (let i = 0; i < input.workflow.length; i++) {
|
|
81
76
|
const step = input.workflow[i];
|
|
82
|
-
|
|
77
|
+
|
|
83
78
|
if (!step.skill && !step.gate) {
|
|
84
79
|
errors.push(`Workflow step ${i + 1} requires either skill or gate`);
|
|
85
80
|
}
|
|
86
|
-
|
|
81
|
+
|
|
87
82
|
if (step.skill && !engine.getSkill(step.skill)) {
|
|
88
83
|
errors.push(`Unknown skill in workflow: ${step.skill}`);
|
|
89
84
|
}
|
|
90
|
-
|
|
85
|
+
|
|
91
86
|
if (step.gate && !Object.values(GateType).includes(step.gate)) {
|
|
92
87
|
errors.push(`Invalid gate type: ${step.gate}`);
|
|
93
88
|
}
|
|
@@ -96,7 +91,7 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
96
91
|
|
|
97
92
|
return {
|
|
98
93
|
valid: errors.length === 0,
|
|
99
|
-
errors
|
|
94
|
+
errors,
|
|
100
95
|
};
|
|
101
96
|
}
|
|
102
97
|
|
|
@@ -120,7 +115,7 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
120
115
|
engine.emit('humanInLoopStarted', {
|
|
121
116
|
context,
|
|
122
117
|
workflow: workflow.map(s => s.skill || s.gate),
|
|
123
|
-
totalSteps: workflow.length
|
|
118
|
+
totalSteps: workflow.length,
|
|
124
119
|
});
|
|
125
120
|
|
|
126
121
|
for (let i = 0; i < workflow.length && !aborted; i++) {
|
|
@@ -131,7 +126,7 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
131
126
|
context,
|
|
132
127
|
step,
|
|
133
128
|
stepNumber,
|
|
134
|
-
totalSteps: workflow.length
|
|
129
|
+
totalSteps: workflow.length,
|
|
135
130
|
});
|
|
136
131
|
|
|
137
132
|
try {
|
|
@@ -148,13 +143,7 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
148
143
|
);
|
|
149
144
|
} else if (step.gate) {
|
|
150
145
|
// Execute gate
|
|
151
|
-
stepResult = await this._executeGateStep(
|
|
152
|
-
step,
|
|
153
|
-
currentInput,
|
|
154
|
-
context,
|
|
155
|
-
engine,
|
|
156
|
-
stepNumber
|
|
157
|
-
);
|
|
146
|
+
stepResult = await this._executeGateStep(step, currentInput, context, engine, stepNumber);
|
|
158
147
|
}
|
|
159
148
|
|
|
160
149
|
results.push({
|
|
@@ -162,7 +151,7 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
162
151
|
type: step.skill ? 'skill' : 'gate',
|
|
163
152
|
name: step.skill || step.gate,
|
|
164
153
|
status: stepResult.status,
|
|
165
|
-
result: stepResult
|
|
154
|
+
result: stepResult,
|
|
166
155
|
});
|
|
167
156
|
|
|
168
157
|
// Check if gate rejected
|
|
@@ -172,7 +161,7 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
172
161
|
context,
|
|
173
162
|
step,
|
|
174
163
|
stepNumber,
|
|
175
|
-
reason: 'Gate rejected'
|
|
164
|
+
reason: 'Gate rejected',
|
|
176
165
|
});
|
|
177
166
|
} else if (step.gate && stepResult.result === GateResult.NEEDS_CHANGES) {
|
|
178
167
|
// Could implement retry logic here
|
|
@@ -184,7 +173,7 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
184
173
|
currentInput = {
|
|
185
174
|
...currentInput,
|
|
186
175
|
feedback: stepResult.feedback,
|
|
187
|
-
needsChanges: true
|
|
176
|
+
needsChanges: true,
|
|
188
177
|
};
|
|
189
178
|
continue;
|
|
190
179
|
}
|
|
@@ -200,23 +189,22 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
200
189
|
context,
|
|
201
190
|
step,
|
|
202
191
|
stepNumber,
|
|
203
|
-
result: stepResult
|
|
192
|
+
result: stepResult,
|
|
204
193
|
});
|
|
205
|
-
|
|
206
194
|
} catch (error) {
|
|
207
195
|
results.push({
|
|
208
196
|
step: stepNumber,
|
|
209
197
|
type: step.skill ? 'skill' : 'gate',
|
|
210
198
|
name: step.skill || step.gate,
|
|
211
199
|
status: ExecutionStatus.FAILED,
|
|
212
|
-
error: error.message
|
|
200
|
+
error: error.message,
|
|
213
201
|
});
|
|
214
202
|
|
|
215
203
|
engine.emit('humanInLoopStepFailed', {
|
|
216
204
|
context,
|
|
217
205
|
step,
|
|
218
206
|
stepNumber,
|
|
219
|
-
error
|
|
207
|
+
error,
|
|
220
208
|
});
|
|
221
209
|
|
|
222
210
|
if (!step.continueOnError) {
|
|
@@ -231,14 +219,14 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
231
219
|
context,
|
|
232
220
|
results,
|
|
233
221
|
summary,
|
|
234
|
-
aborted
|
|
222
|
+
aborted,
|
|
235
223
|
});
|
|
236
224
|
|
|
237
225
|
return {
|
|
238
226
|
results,
|
|
239
227
|
summary,
|
|
240
228
|
aborted,
|
|
241
|
-
finalOutput: currentInput
|
|
229
|
+
finalOutput: currentInput,
|
|
242
230
|
};
|
|
243
231
|
}
|
|
244
232
|
|
|
@@ -255,8 +243,8 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
255
243
|
metadata: {
|
|
256
244
|
pattern: PatternType.HUMAN_IN_LOOP,
|
|
257
245
|
stepNumber,
|
|
258
|
-
stepType: 'skill'
|
|
259
|
-
}
|
|
246
|
+
stepType: 'skill',
|
|
247
|
+
},
|
|
260
248
|
});
|
|
261
249
|
|
|
262
250
|
parentContext.children.push(stepContext);
|
|
@@ -267,7 +255,7 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
267
255
|
|
|
268
256
|
return {
|
|
269
257
|
status: ExecutionStatus.COMPLETED,
|
|
270
|
-
output
|
|
258
|
+
output,
|
|
271
259
|
};
|
|
272
260
|
}
|
|
273
261
|
|
|
@@ -285,8 +273,8 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
285
273
|
pattern: PatternType.HUMAN_IN_LOOP,
|
|
286
274
|
stepNumber,
|
|
287
275
|
stepType: 'gate',
|
|
288
|
-
gateType: step.gate
|
|
289
|
-
}
|
|
276
|
+
gateType: step.gate,
|
|
277
|
+
},
|
|
290
278
|
});
|
|
291
279
|
|
|
292
280
|
parentContext.children.push(stepContext);
|
|
@@ -299,7 +287,7 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
299
287
|
context: parentContext,
|
|
300
288
|
gate: step,
|
|
301
289
|
stepNumber,
|
|
302
|
-
input
|
|
290
|
+
input,
|
|
303
291
|
});
|
|
304
292
|
}
|
|
305
293
|
|
|
@@ -318,20 +306,16 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
318
306
|
response = this.options.autoApproveOnTimeout
|
|
319
307
|
? { approved: true, feedback: 'Auto-approved on timeout' }
|
|
320
308
|
: { approved: false, feedback: 'Timeout waiting for human response' };
|
|
321
|
-
|
|
309
|
+
|
|
322
310
|
stepContext.complete({
|
|
323
|
-
result: this.options.autoApproveOnTimeout
|
|
324
|
-
|
|
325
|
-
: GateResult.TIMEOUT,
|
|
326
|
-
feedback: response.feedback
|
|
311
|
+
result: this.options.autoApproveOnTimeout ? GateResult.APPROVED : GateResult.TIMEOUT,
|
|
312
|
+
feedback: response.feedback,
|
|
327
313
|
});
|
|
328
314
|
|
|
329
315
|
return {
|
|
330
316
|
status: ExecutionStatus.COMPLETED,
|
|
331
|
-
result: this.options.autoApproveOnTimeout
|
|
332
|
-
|
|
333
|
-
: GateResult.TIMEOUT,
|
|
334
|
-
feedback: response.feedback
|
|
317
|
+
result: this.options.autoApproveOnTimeout ? GateResult.APPROVED : GateResult.TIMEOUT,
|
|
318
|
+
feedback: response.feedback,
|
|
335
319
|
};
|
|
336
320
|
}
|
|
337
321
|
throw error;
|
|
@@ -339,18 +323,18 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
339
323
|
|
|
340
324
|
// Process response
|
|
341
325
|
const gateResult = this._processGateResponse(step.gate, response);
|
|
342
|
-
|
|
326
|
+
|
|
343
327
|
stepContext.complete({
|
|
344
328
|
result: gateResult,
|
|
345
329
|
feedback: response.feedback,
|
|
346
|
-
response
|
|
330
|
+
response,
|
|
347
331
|
});
|
|
348
332
|
|
|
349
333
|
return {
|
|
350
334
|
status: ExecutionStatus.COMPLETED,
|
|
351
335
|
result: gateResult,
|
|
352
336
|
feedback: response.feedback,
|
|
353
|
-
output: response.output
|
|
337
|
+
output: response.output,
|
|
354
338
|
};
|
|
355
339
|
}
|
|
356
340
|
|
|
@@ -383,17 +367,17 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
383
367
|
_buildGateQuestion(step, input) {
|
|
384
368
|
const context = step.context || '';
|
|
385
369
|
const prompt = step.prompt || this._getDefaultPrompt(step.gate);
|
|
386
|
-
|
|
370
|
+
|
|
387
371
|
let question = prompt;
|
|
388
372
|
if (context) {
|
|
389
373
|
question = `${context}\n\n${prompt}`;
|
|
390
374
|
}
|
|
391
|
-
|
|
375
|
+
|
|
392
376
|
// Include relevant input data
|
|
393
377
|
if (step.showInput && input) {
|
|
394
378
|
question += `\n\nContext:\n${JSON.stringify(input, null, 2)}`;
|
|
395
379
|
}
|
|
396
|
-
|
|
380
|
+
|
|
397
381
|
return question;
|
|
398
382
|
}
|
|
399
383
|
|
|
@@ -424,18 +408,18 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
424
408
|
if (response.approved === true) {
|
|
425
409
|
return GateResult.APPROVED;
|
|
426
410
|
}
|
|
427
|
-
|
|
411
|
+
|
|
428
412
|
if (response.approved === false) {
|
|
429
413
|
if (response.needsChanges) {
|
|
430
414
|
return GateResult.NEEDS_CHANGES;
|
|
431
415
|
}
|
|
432
416
|
return GateResult.REJECTED;
|
|
433
417
|
}
|
|
434
|
-
|
|
418
|
+
|
|
435
419
|
if (response.skipped) {
|
|
436
420
|
return GateResult.SKIPPED;
|
|
437
421
|
}
|
|
438
|
-
|
|
422
|
+
|
|
439
423
|
// Default based on gate type
|
|
440
424
|
switch (gateType) {
|
|
441
425
|
case GateType.CONFIRMATION:
|
|
@@ -465,14 +449,10 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
465
449
|
_createSummary(results, aborted) {
|
|
466
450
|
const skillSteps = results.filter(r => r.type === 'skill');
|
|
467
451
|
const gateSteps = results.filter(r => r.type === 'gate');
|
|
468
|
-
|
|
469
|
-
const approvedGates = gateSteps.filter(r =>
|
|
470
|
-
|
|
471
|
-
).length;
|
|
472
|
-
|
|
473
|
-
const rejectedGates = gateSteps.filter(r =>
|
|
474
|
-
r.result?.result === GateResult.REJECTED
|
|
475
|
-
).length;
|
|
452
|
+
|
|
453
|
+
const approvedGates = gateSteps.filter(r => r.result?.result === GateResult.APPROVED).length;
|
|
454
|
+
|
|
455
|
+
const rejectedGates = gateSteps.filter(r => r.result?.result === GateResult.REJECTED).length;
|
|
476
456
|
|
|
477
457
|
return {
|
|
478
458
|
totalSteps: results.length,
|
|
@@ -482,9 +462,8 @@ class HumanInLoopPattern extends BasePattern {
|
|
|
482
462
|
rejectedGates,
|
|
483
463
|
aborted,
|
|
484
464
|
completed: !aborted,
|
|
485
|
-
gateApprovalRate:
|
|
486
|
-
? (approvedGates / gateSteps.length * 100).toFixed(1) + '%'
|
|
487
|
-
: 'N/A'
|
|
465
|
+
gateApprovalRate:
|
|
466
|
+
gateSteps.length > 0 ? ((approvedGates / gateSteps.length) * 100).toFixed(1) + '%' : 'N/A',
|
|
488
467
|
};
|
|
489
468
|
}
|
|
490
469
|
}
|
|
@@ -502,5 +481,5 @@ module.exports = {
|
|
|
502
481
|
HumanInLoopPattern,
|
|
503
482
|
GateType,
|
|
504
483
|
GateResult,
|
|
505
|
-
createHumanInLoopPattern
|
|
484
|
+
createHumanInLoopPattern,
|
|
506
485
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* NestedPattern - Hierarchical skill delegation pattern
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* Executes tasks by delegating to sub-skills in a hierarchical manner.
|
|
5
5
|
* Each skill can spawn child tasks creating a tree-like execution structure.
|
|
6
6
|
*/
|
|
@@ -13,7 +13,7 @@ const { PatternType, ExecutionContext, ExecutionStatus } = require('../orchestra
|
|
|
13
13
|
*/
|
|
14
14
|
const NestedMode = {
|
|
15
15
|
DEPTH_FIRST: 'depth-first',
|
|
16
|
-
BREADTH_FIRST: 'breadth-first'
|
|
16
|
+
BREADTH_FIRST: 'breadth-first',
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -27,14 +27,10 @@ class NestedPattern extends BasePattern {
|
|
|
27
27
|
description: 'Execute tasks hierarchically, delegating to sub-skills',
|
|
28
28
|
version: '1.0.0',
|
|
29
29
|
tags: ['hierarchical', 'delegation', 'decomposition'],
|
|
30
|
-
useCases: [
|
|
31
|
-
'Complex task breakdown',
|
|
32
|
-
'Hierarchical processing',
|
|
33
|
-
'Multi-level delegation'
|
|
34
|
-
],
|
|
30
|
+
useCases: ['Complex task breakdown', 'Hierarchical processing', 'Multi-level delegation'],
|
|
35
31
|
complexity: 'high',
|
|
36
32
|
supportsParallel: false,
|
|
37
|
-
requiresHuman: false
|
|
33
|
+
requiresHuman: false,
|
|
38
34
|
});
|
|
39
35
|
|
|
40
36
|
this.options = {
|
|
@@ -42,7 +38,7 @@ class NestedPattern extends BasePattern {
|
|
|
42
38
|
mode: options.mode || NestedMode.DEPTH_FIRST,
|
|
43
39
|
allowSelfDelegation: options.allowSelfDelegation || false,
|
|
44
40
|
aggregateResults: options.aggregateResults || true,
|
|
45
|
-
...options
|
|
41
|
+
...options,
|
|
46
42
|
};
|
|
47
43
|
}
|
|
48
44
|
|
|
@@ -82,7 +78,7 @@ class NestedPattern extends BasePattern {
|
|
|
82
78
|
|
|
83
79
|
return {
|
|
84
80
|
valid: errors.length === 0,
|
|
85
|
-
errors
|
|
81
|
+
errors,
|
|
86
82
|
};
|
|
87
83
|
}
|
|
88
84
|
|
|
@@ -99,11 +95,11 @@ class NestedPattern extends BasePattern {
|
|
|
99
95
|
}
|
|
100
96
|
|
|
101
97
|
const { rootSkill, task, delegationMap = {}, initialInput = {} } = context.input;
|
|
102
|
-
|
|
98
|
+
|
|
103
99
|
engine.emit('nestedStarted', {
|
|
104
100
|
context,
|
|
105
101
|
rootSkill,
|
|
106
|
-
delegationMap
|
|
102
|
+
delegationMap,
|
|
107
103
|
});
|
|
108
104
|
|
|
109
105
|
// Determine root skill from task if not provided
|
|
@@ -120,18 +116,11 @@ class NestedPattern extends BasePattern {
|
|
|
120
116
|
children: [],
|
|
121
117
|
output: null,
|
|
122
118
|
status: ExecutionStatus.PENDING,
|
|
123
|
-
depth: 0
|
|
119
|
+
depth: 0,
|
|
124
120
|
};
|
|
125
121
|
|
|
126
122
|
try {
|
|
127
|
-
await this._executeNode(
|
|
128
|
-
executionTree,
|
|
129
|
-
initialInput,
|
|
130
|
-
delegationMap,
|
|
131
|
-
context,
|
|
132
|
-
engine,
|
|
133
|
-
0
|
|
134
|
-
);
|
|
123
|
+
await this._executeNode(executionTree, initialInput, delegationMap, context, engine, 0);
|
|
135
124
|
|
|
136
125
|
const aggregatedResult = this.options.aggregateResults
|
|
137
126
|
? this._aggregateResults(executionTree)
|
|
@@ -140,20 +129,19 @@ class NestedPattern extends BasePattern {
|
|
|
140
129
|
engine.emit('nestedCompleted', {
|
|
141
130
|
context,
|
|
142
131
|
tree: executionTree,
|
|
143
|
-
aggregatedResult
|
|
132
|
+
aggregatedResult,
|
|
144
133
|
});
|
|
145
134
|
|
|
146
135
|
return {
|
|
147
136
|
tree: executionTree,
|
|
148
137
|
aggregatedResult,
|
|
149
|
-
summary: this._createSummary(executionTree)
|
|
138
|
+
summary: this._createSummary(executionTree),
|
|
150
139
|
};
|
|
151
|
-
|
|
152
140
|
} catch (error) {
|
|
153
141
|
engine.emit('nestedFailed', {
|
|
154
142
|
context,
|
|
155
143
|
tree: executionTree,
|
|
156
|
-
error
|
|
144
|
+
error,
|
|
157
145
|
});
|
|
158
146
|
throw error;
|
|
159
147
|
}
|
|
@@ -178,8 +166,8 @@ class NestedPattern extends BasePattern {
|
|
|
178
166
|
metadata: {
|
|
179
167
|
pattern: PatternType.NESTED,
|
|
180
168
|
depth,
|
|
181
|
-
hasChildren: delegationMap[node.skill]?.length > 0
|
|
182
|
-
}
|
|
169
|
+
hasChildren: delegationMap[node.skill]?.length > 0,
|
|
170
|
+
},
|
|
183
171
|
});
|
|
184
172
|
|
|
185
173
|
parentContext.children.push(stepContext);
|
|
@@ -187,7 +175,7 @@ class NestedPattern extends BasePattern {
|
|
|
187
175
|
engine.emit('nestedNodeStarted', {
|
|
188
176
|
node,
|
|
189
177
|
depth,
|
|
190
|
-
stepContext
|
|
178
|
+
stepContext,
|
|
191
179
|
});
|
|
192
180
|
|
|
193
181
|
try {
|
|
@@ -201,7 +189,7 @@ class NestedPattern extends BasePattern {
|
|
|
201
189
|
|
|
202
190
|
// Check for child skills to delegate to
|
|
203
191
|
const childSkills = delegationMap[node.skill] || [];
|
|
204
|
-
|
|
192
|
+
|
|
205
193
|
if (childSkills.length > 0) {
|
|
206
194
|
for (const childSkill of childSkills) {
|
|
207
195
|
// Skip self-delegation unless allowed
|
|
@@ -214,7 +202,7 @@ class NestedPattern extends BasePattern {
|
|
|
214
202
|
children: [],
|
|
215
203
|
output: null,
|
|
216
204
|
status: ExecutionStatus.PENDING,
|
|
217
|
-
depth: depth + 1
|
|
205
|
+
depth: depth + 1,
|
|
218
206
|
};
|
|
219
207
|
node.children.push(childNode);
|
|
220
208
|
|
|
@@ -235,9 +223,8 @@ class NestedPattern extends BasePattern {
|
|
|
235
223
|
engine.emit('nestedNodeCompleted', {
|
|
236
224
|
node,
|
|
237
225
|
depth,
|
|
238
|
-
output
|
|
226
|
+
output,
|
|
239
227
|
});
|
|
240
|
-
|
|
241
228
|
} catch (error) {
|
|
242
229
|
node.status = ExecutionStatus.FAILED;
|
|
243
230
|
node.error = error.message;
|
|
@@ -246,7 +233,7 @@ class NestedPattern extends BasePattern {
|
|
|
246
233
|
engine.emit('nestedNodeFailed', {
|
|
247
234
|
node,
|
|
248
235
|
depth,
|
|
249
|
-
error
|
|
236
|
+
error,
|
|
250
237
|
});
|
|
251
238
|
|
|
252
239
|
throw error;
|
|
@@ -261,7 +248,7 @@ class NestedPattern extends BasePattern {
|
|
|
261
248
|
const result = {
|
|
262
249
|
skill: node.skill,
|
|
263
250
|
output: node.output,
|
|
264
|
-
childOutputs: []
|
|
251
|
+
childOutputs: [],
|
|
265
252
|
};
|
|
266
253
|
|
|
267
254
|
for (const child of node.children) {
|
|
@@ -281,12 +268,12 @@ class NestedPattern extends BasePattern {
|
|
|
281
268
|
let failed = 0;
|
|
282
269
|
let maxDepth = 0;
|
|
283
270
|
|
|
284
|
-
const traverse =
|
|
271
|
+
const traverse = node => {
|
|
285
272
|
totalNodes++;
|
|
286
273
|
if (node.status === ExecutionStatus.COMPLETED) completed++;
|
|
287
274
|
if (node.status === ExecutionStatus.FAILED) failed++;
|
|
288
275
|
if (node.depth > maxDepth) maxDepth = node.depth;
|
|
289
|
-
|
|
276
|
+
|
|
290
277
|
for (const child of node.children) {
|
|
291
278
|
traverse(child);
|
|
292
279
|
}
|
|
@@ -299,9 +286,7 @@ class NestedPattern extends BasePattern {
|
|
|
299
286
|
completed,
|
|
300
287
|
failed,
|
|
301
288
|
maxDepth,
|
|
302
|
-
successRate: totalNodes > 0
|
|
303
|
-
? (completed / totalNodes * 100).toFixed(1) + '%'
|
|
304
|
-
: '0%'
|
|
289
|
+
successRate: totalNodes > 0 ? ((completed / totalNodes) * 100).toFixed(1) + '%' : '0%',
|
|
305
290
|
};
|
|
306
291
|
}
|
|
307
292
|
}
|
|
@@ -318,5 +303,5 @@ function createNestedPattern(options = {}) {
|
|
|
318
303
|
module.exports = {
|
|
319
304
|
NestedPattern,
|
|
320
305
|
NestedMode,
|
|
321
|
-
createNestedPattern
|
|
306
|
+
createNestedPattern,
|
|
322
307
|
};
|