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.
Files changed (232) hide show
  1. package/README.ja.md +106 -48
  2. package/README.md +110 -32
  3. package/bin/musubi-analyze.js +74 -67
  4. package/bin/musubi-browser.js +27 -26
  5. package/bin/musubi-change.js +48 -47
  6. package/bin/musubi-checkpoint.js +10 -7
  7. package/bin/musubi-convert.js +25 -25
  8. package/bin/musubi-costs.js +27 -10
  9. package/bin/musubi-gui.js +52 -46
  10. package/bin/musubi-init.js +1952 -10
  11. package/bin/musubi-orchestrate.js +327 -239
  12. package/bin/musubi-remember.js +69 -56
  13. package/bin/musubi-resolve.js +53 -45
  14. package/bin/musubi-trace.js +51 -22
  15. package/bin/musubi-validate.js +39 -30
  16. package/bin/musubi-workflow.js +33 -34
  17. package/bin/musubi.js +39 -2
  18. package/package.json +1 -1
  19. package/src/agents/agent-loop.js +94 -95
  20. package/src/agents/agentic/code-generator.js +119 -109
  21. package/src/agents/agentic/code-reviewer.js +105 -108
  22. package/src/agents/agentic/index.js +4 -4
  23. package/src/agents/browser/action-executor.js +13 -13
  24. package/src/agents/browser/ai-comparator.js +11 -10
  25. package/src/agents/browser/context-manager.js +6 -6
  26. package/src/agents/browser/index.js +5 -5
  27. package/src/agents/browser/nl-parser.js +31 -46
  28. package/src/agents/browser/screenshot.js +2 -2
  29. package/src/agents/browser/test-generator.js +6 -4
  30. package/src/agents/function-tool.js +71 -65
  31. package/src/agents/index.js +7 -7
  32. package/src/agents/schema-generator.js +98 -94
  33. package/src/analyzers/ast-extractor.js +164 -145
  34. package/src/analyzers/codegraph-auto-update.js +858 -0
  35. package/src/analyzers/complexity-analyzer.js +536 -0
  36. package/src/analyzers/context-optimizer.js +247 -125
  37. package/src/analyzers/impact-analyzer.js +1 -1
  38. package/src/analyzers/large-project-analyzer.js +766 -0
  39. package/src/analyzers/repository-map.js +83 -80
  40. package/src/analyzers/security-analyzer.js +19 -11
  41. package/src/analyzers/stuck-detector.js +19 -17
  42. package/src/converters/index.js +78 -57
  43. package/src/converters/ir/types.js +12 -12
  44. package/src/converters/parsers/musubi-parser.js +134 -126
  45. package/src/converters/parsers/openapi-parser.js +70 -53
  46. package/src/converters/parsers/speckit-parser.js +239 -175
  47. package/src/converters/writers/musubi-writer.js +123 -118
  48. package/src/converters/writers/speckit-writer.js +124 -113
  49. package/src/generators/rust-migration-generator.js +512 -0
  50. package/src/gui/public/index.html +1365 -1211
  51. package/src/gui/server.js +41 -40
  52. package/src/gui/services/file-watcher.js +23 -8
  53. package/src/gui/services/project-scanner.js +26 -20
  54. package/src/gui/services/replanning-service.js +27 -23
  55. package/src/gui/services/traceability-service.js +8 -8
  56. package/src/gui/services/workflow-service.js +14 -7
  57. package/src/index.js +151 -0
  58. package/src/integrations/cicd.js +90 -104
  59. package/src/integrations/codegraph-mcp.js +643 -0
  60. package/src/integrations/documentation.js +142 -103
  61. package/src/integrations/examples.js +95 -80
  62. package/src/integrations/github-client.js +17 -17
  63. package/src/integrations/index.js +5 -5
  64. package/src/integrations/mcp/index.js +21 -21
  65. package/src/integrations/mcp/mcp-context-provider.js +76 -78
  66. package/src/integrations/mcp/mcp-discovery.js +74 -72
  67. package/src/integrations/mcp/mcp-tool-registry.js +99 -94
  68. package/src/integrations/mcp-connector.js +70 -66
  69. package/src/integrations/platforms.js +50 -49
  70. package/src/integrations/tool-discovery.js +37 -31
  71. package/src/llm-providers/anthropic-provider.js +11 -11
  72. package/src/llm-providers/base-provider.js +16 -18
  73. package/src/llm-providers/copilot-provider.js +22 -19
  74. package/src/llm-providers/index.js +26 -25
  75. package/src/llm-providers/ollama-provider.js +11 -11
  76. package/src/llm-providers/openai-provider.js +12 -12
  77. package/src/managers/agent-memory.js +36 -24
  78. package/src/managers/checkpoint-manager.js +4 -8
  79. package/src/managers/delta-spec.js +19 -19
  80. package/src/managers/index.js +13 -4
  81. package/src/managers/memory-condenser.js +35 -45
  82. package/src/managers/repo-skill-manager.js +57 -31
  83. package/src/managers/skill-loader.js +25 -22
  84. package/src/managers/skill-tools.js +36 -72
  85. package/src/managers/workflow.js +30 -22
  86. package/src/monitoring/cost-tracker.js +53 -44
  87. package/src/monitoring/incident-manager.js +123 -103
  88. package/src/monitoring/index.js +144 -134
  89. package/src/monitoring/observability.js +82 -59
  90. package/src/monitoring/quality-dashboard.js +51 -39
  91. package/src/monitoring/release-manager.js +70 -50
  92. package/src/orchestration/agent-skill-binding.js +39 -47
  93. package/src/orchestration/error-handler.js +65 -107
  94. package/src/orchestration/guardrails/base-guardrail.js +26 -24
  95. package/src/orchestration/guardrails/guardrail-rules.js +50 -64
  96. package/src/orchestration/guardrails/index.js +5 -5
  97. package/src/orchestration/guardrails/input-guardrail.js +58 -45
  98. package/src/orchestration/guardrails/output-guardrail.js +104 -81
  99. package/src/orchestration/guardrails/safety-check.js +79 -79
  100. package/src/orchestration/index.js +38 -55
  101. package/src/orchestration/mcp-tool-adapters.js +96 -99
  102. package/src/orchestration/orchestration-engine.js +21 -21
  103. package/src/orchestration/pattern-registry.js +60 -45
  104. package/src/orchestration/patterns/auto.js +34 -47
  105. package/src/orchestration/patterns/group-chat.js +59 -65
  106. package/src/orchestration/patterns/handoff.js +67 -65
  107. package/src/orchestration/patterns/human-in-loop.js +51 -72
  108. package/src/orchestration/patterns/nested.js +25 -40
  109. package/src/orchestration/patterns/sequential.js +35 -34
  110. package/src/orchestration/patterns/swarm.js +63 -56
  111. package/src/orchestration/patterns/triage.js +150 -109
  112. package/src/orchestration/reasoning/index.js +9 -9
  113. package/src/orchestration/reasoning/planning-engine.js +143 -140
  114. package/src/orchestration/reasoning/reasoning-engine.js +206 -144
  115. package/src/orchestration/reasoning/self-correction.js +121 -128
  116. package/src/orchestration/replanning/adaptive-goal-modifier.js +107 -112
  117. package/src/orchestration/replanning/alternative-generator.js +37 -42
  118. package/src/orchestration/replanning/config.js +63 -59
  119. package/src/orchestration/replanning/goal-progress-tracker.js +98 -100
  120. package/src/orchestration/replanning/index.js +24 -20
  121. package/src/orchestration/replanning/plan-evaluator.js +49 -50
  122. package/src/orchestration/replanning/plan-monitor.js +32 -28
  123. package/src/orchestration/replanning/proactive-path-optimizer.js +175 -178
  124. package/src/orchestration/replanning/replan-history.js +33 -26
  125. package/src/orchestration/replanning/replanning-engine.js +106 -108
  126. package/src/orchestration/skill-executor.js +107 -109
  127. package/src/orchestration/skill-registry.js +85 -89
  128. package/src/orchestration/workflow-examples.js +228 -231
  129. package/src/orchestration/workflow-executor.js +65 -68
  130. package/src/orchestration/workflow-orchestrator.js +72 -73
  131. package/src/phase4-integration.js +47 -40
  132. package/src/phase5-integration.js +89 -30
  133. package/src/reporters/coverage-report.js +82 -30
  134. package/src/reporters/hierarchical-reporter.js +498 -0
  135. package/src/reporters/traceability-matrix-report.js +29 -20
  136. package/src/resolvers/issue-resolver.js +43 -31
  137. package/src/steering/advanced-validation.js +133 -124
  138. package/src/steering/auto-updater.js +60 -73
  139. package/src/steering/index.js +6 -6
  140. package/src/steering/quality-metrics.js +41 -35
  141. package/src/steering/steering-auto-update.js +83 -86
  142. package/src/steering/steering-validator.js +98 -106
  143. package/src/steering/template-constraints.js +53 -54
  144. package/src/templates/agents/claude-code/CLAUDE.md +32 -32
  145. package/src/templates/agents/claude-code/skills/agent-assistant/SKILL.md +13 -5
  146. package/src/templates/agents/claude-code/skills/ai-ml-engineer/mlops-guide.md +23 -23
  147. package/src/templates/agents/claude-code/skills/ai-ml-engineer/model-card-template.md +60 -41
  148. package/src/templates/agents/claude-code/skills/api-designer/api-patterns.md +27 -19
  149. package/src/templates/agents/claude-code/skills/api-designer/openapi-template.md +11 -7
  150. package/src/templates/agents/claude-code/skills/bug-hunter/SKILL.md +4 -3
  151. package/src/templates/agents/claude-code/skills/bug-hunter/root-cause-analysis.md +37 -15
  152. package/src/templates/agents/claude-code/skills/change-impact-analyzer/dependency-graph-patterns.md +36 -42
  153. package/src/templates/agents/claude-code/skills/change-impact-analyzer/impact-analysis-template.md +69 -60
  154. package/src/templates/agents/claude-code/skills/cloud-architect/aws-patterns.md +31 -38
  155. package/src/templates/agents/claude-code/skills/cloud-architect/azure-patterns.md +28 -23
  156. package/src/templates/agents/claude-code/skills/code-reviewer/SKILL.md +61 -0
  157. package/src/templates/agents/claude-code/skills/code-reviewer/best-practices.md +27 -0
  158. package/src/templates/agents/claude-code/skills/code-reviewer/review-checklist.md +29 -10
  159. package/src/templates/agents/claude-code/skills/code-reviewer/review-standards.md +29 -24
  160. package/src/templates/agents/claude-code/skills/constitution-enforcer/SKILL.md +8 -6
  161. package/src/templates/agents/claude-code/skills/constitution-enforcer/constitutional-articles.md +62 -26
  162. package/src/templates/agents/claude-code/skills/constitution-enforcer/phase-minus-one-gates.md +35 -16
  163. package/src/templates/agents/claude-code/skills/database-administrator/backup-recovery.md +27 -17
  164. package/src/templates/agents/claude-code/skills/database-administrator/tuning-guide.md +25 -20
  165. package/src/templates/agents/claude-code/skills/database-schema-designer/schema-patterns.md +39 -22
  166. package/src/templates/agents/claude-code/skills/devops-engineer/ci-cd-templates.md +25 -22
  167. package/src/templates/agents/claude-code/skills/issue-resolver/SKILL.md +24 -21
  168. package/src/templates/agents/claude-code/skills/orchestrator/SKILL.md +148 -63
  169. package/src/templates/agents/claude-code/skills/orchestrator/patterns.md +35 -16
  170. package/src/templates/agents/claude-code/skills/orchestrator/selection-matrix.md +69 -64
  171. package/src/templates/agents/claude-code/skills/performance-engineer/optimization-playbook.md +47 -47
  172. package/src/templates/agents/claude-code/skills/performance-optimizer/SKILL.md +69 -0
  173. package/src/templates/agents/claude-code/skills/performance-optimizer/benchmark-template.md +63 -45
  174. package/src/templates/agents/claude-code/skills/performance-optimizer/optimization-patterns.md +33 -35
  175. package/src/templates/agents/claude-code/skills/project-manager/SKILL.md +7 -6
  176. package/src/templates/agents/claude-code/skills/project-manager/agile-ceremonies.md +47 -28
  177. package/src/templates/agents/claude-code/skills/project-manager/project-templates.md +94 -78
  178. package/src/templates/agents/claude-code/skills/quality-assurance/SKILL.md +20 -17
  179. package/src/templates/agents/claude-code/skills/quality-assurance/qa-plan-template.md +63 -49
  180. package/src/templates/agents/claude-code/skills/release-coordinator/SKILL.md +5 -5
  181. package/src/templates/agents/claude-code/skills/release-coordinator/feature-flag-guide.md +30 -26
  182. package/src/templates/agents/claude-code/skills/release-coordinator/release-plan-template.md +67 -35
  183. package/src/templates/agents/claude-code/skills/requirements-analyst/ears-format.md +54 -42
  184. package/src/templates/agents/claude-code/skills/requirements-analyst/validation-rules.md +36 -33
  185. package/src/templates/agents/claude-code/skills/security-auditor/SKILL.md +77 -19
  186. package/src/templates/agents/claude-code/skills/security-auditor/audit-checklists.md +24 -24
  187. package/src/templates/agents/claude-code/skills/security-auditor/owasp-top-10.md +61 -20
  188. package/src/templates/agents/claude-code/skills/security-auditor/vulnerability-patterns.md +43 -11
  189. package/src/templates/agents/claude-code/skills/site-reliability-engineer/SKILL.md +1 -0
  190. package/src/templates/agents/claude-code/skills/site-reliability-engineer/incident-response-template.md +55 -25
  191. package/src/templates/agents/claude-code/skills/site-reliability-engineer/observability-patterns.md +78 -68
  192. package/src/templates/agents/claude-code/skills/site-reliability-engineer/slo-sli-guide.md +73 -53
  193. package/src/templates/agents/claude-code/skills/software-developer/solid-principles.md +83 -37
  194. package/src/templates/agents/claude-code/skills/software-developer/test-first-workflow.md +38 -31
  195. package/src/templates/agents/claude-code/skills/steering/SKILL.md +1 -0
  196. package/src/templates/agents/claude-code/skills/steering/auto-update-rules.md +31 -0
  197. package/src/templates/agents/claude-code/skills/system-architect/adr-template.md +25 -7
  198. package/src/templates/agents/claude-code/skills/system-architect/c4-model-guide.md +74 -61
  199. package/src/templates/agents/claude-code/skills/technical-writer/doc-templates/documentation-templates.md +70 -52
  200. package/src/templates/agents/claude-code/skills/test-engineer/SKILL.md +2 -0
  201. package/src/templates/agents/claude-code/skills/test-engineer/ears-test-mapping.md +75 -71
  202. package/src/templates/agents/claude-code/skills/test-engineer/test-types.md +85 -63
  203. package/src/templates/agents/claude-code/skills/traceability-auditor/coverage-matrix-template.md +39 -36
  204. package/src/templates/agents/claude-code/skills/traceability-auditor/gap-detection-rules.md +22 -17
  205. package/src/templates/agents/claude-code/skills/ui-ux-designer/SKILL.md +1 -0
  206. package/src/templates/agents/claude-code/skills/ui-ux-designer/accessibility-guidelines.md +49 -75
  207. package/src/templates/agents/claude-code/skills/ui-ux-designer/design-system-components.md +71 -59
  208. package/src/templates/agents/codex/AGENTS.md +74 -42
  209. package/src/templates/agents/cursor/AGENTS.md +74 -42
  210. package/src/templates/agents/gemini-cli/GEMINI.md +74 -42
  211. package/src/templates/agents/github-copilot/AGENTS.md +83 -51
  212. package/src/templates/agents/qwen-code/QWEN.md +74 -42
  213. package/src/templates/agents/windsurf/AGENTS.md +74 -42
  214. package/src/templates/architectures/README.md +41 -0
  215. package/src/templates/architectures/clean-architecture/README.md +113 -0
  216. package/src/templates/architectures/event-driven/README.md +162 -0
  217. package/src/templates/architectures/hexagonal/README.md +130 -0
  218. package/src/templates/index.js +6 -1
  219. package/src/templates/locale-manager.js +16 -16
  220. package/src/templates/shared/delta-spec-template.md +20 -13
  221. package/src/templates/shared/github-actions/musubi-issue-resolver.yml +5 -5
  222. package/src/templates/shared/github-actions/musubi-security-check.yml +3 -3
  223. package/src/templates/shared/github-actions/musubi-validate.yml +4 -4
  224. package/src/templates/shared/steering/structure.md +95 -0
  225. package/src/templates/skills/browser-agent.md +21 -16
  226. package/src/templates/skills/web-gui.md +8 -0
  227. package/src/templates/template-constraints.js +50 -53
  228. package/src/validators/advanced-validation.js +30 -36
  229. package/src/validators/constitutional-validator.js +77 -73
  230. package/src/validators/critic-system.js +49 -59
  231. package/src/validators/delta-format.js +59 -55
  232. package/src/validators/traceability-validator.js +7 -11
@@ -22,7 +22,7 @@ class PlanEvaluator {
22
22
  llmWeight: 0.4,
23
23
  historyWeight: 0.3,
24
24
  resourceWeight: 0.2,
25
- complexityWeight: 0.1
25
+ complexityWeight: 0.1,
26
26
  };
27
27
  this.historyStore = options.historyStore || new Map();
28
28
  this.metrics = new Map();
@@ -53,7 +53,7 @@ class PlanEvaluator {
53
53
  const health = this.calculateHealthScore({
54
54
  progress,
55
55
  efficiency,
56
- failureRate: totalTasks > 0 ? failedTasks.length / totalTasks : 0
56
+ failureRate: totalTasks > 0 ? failedTasks.length / totalTasks : 0,
57
57
  });
58
58
 
59
59
  const evaluation = {
@@ -64,12 +64,12 @@ class PlanEvaluator {
64
64
  completed: completedTasks.length,
65
65
  pending: pendingTasks.length,
66
66
  failed: failedTasks.length,
67
- total: totalTasks
67
+ total: totalTasks,
68
68
  },
69
69
  efficiency,
70
70
  remaining,
71
71
  health,
72
- recommendations: this.generateRecommendations({ progress, efficiency, health, failedTasks })
72
+ recommendations: this.generateRecommendations({ progress, efficiency, health, failedTasks }),
73
73
  };
74
74
 
75
75
  // Store metrics
@@ -98,31 +98,26 @@ class PlanEvaluator {
98
98
  const startTime = state.startTime || Date.now();
99
99
  const elapsed = Date.now() - startTime;
100
100
  const completedTasks = state.completed || [];
101
-
101
+
102
102
  // Tasks per minute
103
- const tasksPerMinute = elapsed > 0
104
- ? (completedTasks.length / (elapsed / 60000))
105
- : 0;
103
+ const tasksPerMinute = elapsed > 0 ? completedTasks.length / (elapsed / 60000) : 0;
106
104
 
107
105
  // Average task duration
108
- const taskDurations = completedTasks
109
- .filter(t => t.duration)
110
- .map(t => t.duration);
111
- const avgDuration = taskDurations.length > 0
112
- ? taskDurations.reduce((a, b) => a + b, 0) / taskDurations.length
113
- : 0;
106
+ const taskDurations = completedTasks.filter(t => t.duration).map(t => t.duration);
107
+ const avgDuration =
108
+ taskDurations.length > 0
109
+ ? taskDurations.reduce((a, b) => a + b, 0) / taskDurations.length
110
+ : 0;
114
111
 
115
112
  // Retry ratio
116
113
  const retryCount = state.retries || 0;
117
- const retryRatio = completedTasks.length > 0
118
- ? retryCount / completedTasks.length
119
- : 0;
114
+ const retryRatio = completedTasks.length > 0 ? retryCount / completedTasks.length : 0;
120
115
 
121
116
  return {
122
117
  tasksPerMinute: Math.round(tasksPerMinute * 100) / 100,
123
118
  avgTaskDuration: Math.round(avgDuration),
124
119
  retryRatio: Math.round(retryRatio * 100) / 100,
125
- elapsedTime: elapsed
120
+ elapsedTime: elapsed,
126
121
  };
127
122
  }
128
123
 
@@ -135,7 +130,7 @@ class PlanEvaluator {
135
130
  estimateRemaining(plan, currentState) {
136
131
  const pendingTasks = currentState.pending || [];
137
132
  const efficiency = this.calculateEfficiency(currentState);
138
-
133
+
139
134
  // Use average duration to estimate remaining time
140
135
  let estimatedTime = 0;
141
136
  if (efficiency.avgTaskDuration > 0 && pendingTasks.length > 0) {
@@ -151,7 +146,7 @@ class PlanEvaluator {
151
146
  taskCount: pendingTasks.length,
152
147
  estimatedTime,
153
148
  estimatedTimeFormatted: this.formatDuration(estimatedTime),
154
- confidence: Math.round(confidence * 100) / 100
149
+ confidence: Math.round(confidence * 100) / 100,
155
150
  };
156
151
  }
157
152
 
@@ -164,14 +159,17 @@ class PlanEvaluator {
164
159
  compareEfficiency(currentPath, alternativePath) {
165
160
  // Estimate current path remaining effort
166
161
  const currentRemaining = this.estimatePathEffort(currentPath);
167
-
162
+
168
163
  // Estimate alternative path effort
169
164
  const alternativeEffort = this.estimatePathEffort(alternativePath);
170
165
 
171
166
  // Calculate improvement
172
- const improvement = currentRemaining.estimatedTime > 0
173
- ? ((currentRemaining.estimatedTime - alternativeEffort.estimatedTime) / currentRemaining.estimatedTime) * 100
174
- : 0;
167
+ const improvement =
168
+ currentRemaining.estimatedTime > 0
169
+ ? ((currentRemaining.estimatedTime - alternativeEffort.estimatedTime) /
170
+ currentRemaining.estimatedTime) *
171
+ 100
172
+ : 0;
175
173
 
176
174
  // Factor in switching cost
177
175
  const switchingCost = this.estimateSwitchingCost(currentPath, alternativePath);
@@ -182,7 +180,7 @@ class PlanEvaluator {
182
180
  improvement: Math.round(improvement * 100) / 100,
183
181
  switchingCost,
184
182
  netBenefit: improvement - switchingCost.percentage,
185
- recommendation: this.getPathRecommendation(improvement, switchingCost)
183
+ recommendation: this.getPathRecommendation(improvement, switchingCost),
186
184
  };
187
185
  }
188
186
 
@@ -195,7 +193,7 @@ class PlanEvaluator {
195
193
  estimatePathEffort(path) {
196
194
  const tasks = path.tasks || [];
197
195
  let totalEstimate = 0;
198
-
196
+
199
197
  for (const task of tasks) {
200
198
  const historicalData = this.getHistoricalData(task.skill || task.name);
201
199
  if (historicalData) {
@@ -209,7 +207,7 @@ class PlanEvaluator {
209
207
  return {
210
208
  taskCount: tasks.length,
211
209
  estimatedTime: totalEstimate,
212
- estimatedTimeFormatted: this.formatDuration(totalEstimate)
210
+ estimatedTimeFormatted: this.formatDuration(totalEstimate),
213
211
  };
214
212
  }
215
213
 
@@ -224,24 +222,25 @@ class PlanEvaluator {
224
222
  // Calculate overlap between paths
225
223
  const currentTaskIds = new Set((currentPath.tasks || []).map(t => t.id));
226
224
  const altTaskIds = new Set((alternativePath.tasks || []).map(t => t.id));
227
-
225
+
228
226
  const overlap = [...currentTaskIds].filter(id => altTaskIds.has(id)).length;
229
227
  const divergence = altTaskIds.size - overlap;
230
-
228
+
231
229
  // Switching cost increases with divergence
232
230
  const baseCost = divergence * 5000; // 5s per divergent task
233
231
  const contextCost = currentPath.contextSize ? currentPath.contextSize * 1000 : 0;
234
-
232
+
235
233
  const totalCost = baseCost + contextCost;
236
- const percentage = totalCost > 0 && alternativePath.estimatedTime
237
- ? (totalCost / alternativePath.estimatedTime) * 100
238
- : 0;
234
+ const percentage =
235
+ totalCost > 0 && alternativePath.estimatedTime
236
+ ? (totalCost / alternativePath.estimatedTime) * 100
237
+ : 0;
239
238
 
240
239
  return {
241
240
  time: totalCost,
242
241
  percentage: Math.round(percentage * 100) / 100,
243
242
  overlap,
244
- divergence
243
+ divergence,
245
244
  };
246
245
  }
247
246
 
@@ -254,7 +253,7 @@ class PlanEvaluator {
254
253
  */
255
254
  getPathRecommendation(improvement, switchingCost) {
256
255
  const netBenefit = improvement - switchingCost.percentage;
257
-
256
+
258
257
  if (netBenefit > 20) return 'strongly-recommended';
259
258
  if (netBenefit > 10) return 'recommended';
260
259
  if (netBenefit > 0) return 'marginally-better';
@@ -270,27 +269,23 @@ class PlanEvaluator {
270
269
  */
271
270
  calculateHealthScore(metrics) {
272
271
  const { progress, efficiency, failureRate } = metrics;
273
-
272
+
274
273
  // Calculate component scores
275
274
  const progressScore = progress / 100;
276
275
  const efficiencyScore = Math.min(1, efficiency.tasksPerMinute / 2); // Normalize to 2 tasks/min
277
276
  const reliabilityScore = 1 - Math.min(1, failureRate * 5); // 20% failure = 0 score
278
-
277
+
279
278
  // Weighted average
280
- const overall = (
281
- progressScore * 0.3 +
282
- efficiencyScore * 0.3 +
283
- reliabilityScore * 0.4
284
- );
279
+ const overall = progressScore * 0.3 + efficiencyScore * 0.3 + reliabilityScore * 0.4;
285
280
 
286
281
  return {
287
282
  overall: Math.round(overall * 100) / 100,
288
283
  components: {
289
284
  progress: Math.round(progressScore * 100) / 100,
290
285
  efficiency: Math.round(efficiencyScore * 100) / 100,
291
- reliability: Math.round(reliabilityScore * 100) / 100
286
+ reliability: Math.round(reliabilityScore * 100) / 100,
292
287
  },
293
- status: this.getHealthStatus(overall)
288
+ status: this.getHealthStatus(overall),
294
289
  };
295
290
  }
296
291
 
@@ -316,14 +311,18 @@ class PlanEvaluator {
316
311
  */
317
312
  generateRecommendations(data) {
318
313
  const recommendations = [];
319
- const { progress, efficiency, health, failedTasks } = data;
314
+ const { progress: _progress, efficiency, health, failedTasks } = data;
320
315
 
321
316
  if (health.components?.reliability < 0.5) {
322
- recommendations.push('High failure rate detected. Consider reviewing failed task configurations.');
317
+ recommendations.push(
318
+ 'High failure rate detected. Consider reviewing failed task configurations.'
319
+ );
323
320
  }
324
321
 
325
322
  if (health.components?.efficiency < 0.3) {
326
- recommendations.push('Low efficiency detected. Consider parallelizing tasks or optimizing task parameters.');
323
+ recommendations.push(
324
+ 'Low efficiency detected. Consider parallelizing tasks or optimizing task parameters.'
325
+ );
327
326
  }
328
327
 
329
328
  if (failedTasks && failedTasks.length > 2) {
@@ -345,12 +344,12 @@ class PlanEvaluator {
345
344
  */
346
345
  estimateTaskComplexity(task) {
347
346
  let complexity = 1;
348
-
347
+
349
348
  if (task.dependencies?.length > 0) complexity += 0.5;
350
349
  if (task.parameters && Object.keys(task.parameters).length > 3) complexity += 0.5;
351
350
  if (task.skill?.includes('analysis') || task.skill?.includes('generate')) complexity += 1;
352
351
  if (task.retryable === false) complexity += 0.5;
353
-
352
+
354
353
  return Math.min(5, complexity);
355
354
  }
356
355
 
@@ -373,7 +372,7 @@ class PlanEvaluator {
373
372
  const existing = this.historyStore.get(skillName) || {
374
373
  executions: 0,
375
374
  successCount: 0,
376
- totalDuration: 0
375
+ totalDuration: 0,
377
376
  };
378
377
 
379
378
  existing.executions++;
@@ -47,7 +47,7 @@ class PlanMonitor extends EventEmitter {
47
47
  startTime: Date.now(),
48
48
  taskResults: [],
49
49
  failureCount: 0,
50
- lastUpdate: Date.now()
50
+ lastUpdate: Date.now(),
51
51
  };
52
52
 
53
53
  this.watchedContexts.set(contextId, watchContext);
@@ -70,7 +70,7 @@ class PlanMonitor extends EventEmitter {
70
70
  unwatch(contextId) {
71
71
  this.watchedContexts.delete(contextId);
72
72
  this.failureCounts.delete(contextId);
73
-
73
+
74
74
  // Clear timeout
75
75
  const timeout = this.timeouts.get(contextId);
76
76
  if (timeout) {
@@ -110,7 +110,7 @@ class PlanMonitor extends EventEmitter {
110
110
 
111
111
  // Check for triggers based on result
112
112
  const trigger = this.checkTriggers(contextId, result, context);
113
-
113
+
114
114
  if (trigger) {
115
115
  this.emit('trigger', trigger);
116
116
  return trigger;
@@ -143,8 +143,8 @@ class PlanMonitor extends EventEmitter {
143
143
  data: {
144
144
  changes,
145
145
  previousContext: { ...context },
146
- reason: 'Context or requirements changed'
147
- }
146
+ reason: 'Context or requirements changed',
147
+ },
148
148
  };
149
149
 
150
150
  // Update context with changes
@@ -169,8 +169,8 @@ class PlanMonitor extends EventEmitter {
169
169
  timestamp: Date.now(),
170
170
  data: {
171
171
  reason,
172
- context: context || null
173
- }
172
+ context: context || null,
173
+ },
174
174
  };
175
175
 
176
176
  this.emit('trigger', trigger);
@@ -188,7 +188,7 @@ class PlanMonitor extends EventEmitter {
188
188
  checkTriggers(contextId, result, context) {
189
189
  const enabledTriggers = this.config.triggers?.enabled || [
190
190
  ReplanTrigger.TASK_FAILED,
191
- ReplanTrigger.TIMEOUT
191
+ ReplanTrigger.TIMEOUT,
192
192
  ];
193
193
 
194
194
  // Check for task failure
@@ -197,7 +197,7 @@ class PlanMonitor extends EventEmitter {
197
197
  this.failureCounts.set(contextId, failureCount);
198
198
 
199
199
  const threshold = this.config.triggers?.failureThreshold || 2;
200
-
200
+
201
201
  if (failureCount >= threshold) {
202
202
  return {
203
203
  type: ReplanTrigger.TASK_FAILED,
@@ -208,8 +208,8 @@ class PlanMonitor extends EventEmitter {
208
208
  error: result.error,
209
209
  failureCount,
210
210
  threshold,
211
- context: this.sanitizeContext(context)
212
- }
211
+ context: this.sanitizeContext(context),
212
+ },
213
213
  };
214
214
  }
215
215
  }
@@ -223,15 +223,17 @@ class PlanMonitor extends EventEmitter {
223
223
  data: {
224
224
  taskId: result.taskId,
225
225
  elapsed: Date.now() - context.startTime,
226
- context: this.sanitizeContext(context)
227
- }
226
+ context: this.sanitizeContext(context),
227
+ },
228
228
  };
229
229
  }
230
230
 
231
231
  // Check for goal unreachable (based on error analysis)
232
- if (result.status === 'failed' &&
233
- enabledTriggers.includes(ReplanTrigger.GOAL_UNREACHABLE) &&
234
- this.isGoalUnreachable(result)) {
232
+ if (
233
+ result.status === 'failed' &&
234
+ enabledTriggers.includes(ReplanTrigger.GOAL_UNREACHABLE) &&
235
+ this.isGoalUnreachable(result)
236
+ ) {
235
237
  return {
236
238
  type: ReplanTrigger.GOAL_UNREACHABLE,
237
239
  contextId,
@@ -240,8 +242,8 @@ class PlanMonitor extends EventEmitter {
240
242
  taskId: result.taskId,
241
243
  error: result.error,
242
244
  reason: 'Goal determined to be unreachable',
243
- context: this.sanitizeContext(context)
244
- }
245
+ context: this.sanitizeContext(context),
246
+ },
245
247
  };
246
248
  }
247
249
 
@@ -264,7 +266,7 @@ class PlanMonitor extends EventEmitter {
264
266
  /access denied/i,
265
267
  /unauthorized/i,
266
268
  /impossible/i,
267
- /cannot be completed/i
269
+ /cannot be completed/i,
268
270
  ];
269
271
 
270
272
  const errorMessage = result.error.message || String(result.error);
@@ -288,8 +290,8 @@ class PlanMonitor extends EventEmitter {
288
290
  data: {
289
291
  reason: 'Overall task timeout exceeded',
290
292
  elapsed: Date.now() - context.startTime,
291
- context: this.sanitizeContext(context)
292
- }
293
+ context: this.sanitizeContext(context),
294
+ },
293
295
  };
294
296
  this.emit('trigger', trigger);
295
297
  }
@@ -327,11 +329,13 @@ class PlanMonitor extends EventEmitter {
327
329
  lastUpdate: context.lastUpdate,
328
330
  failureCount: context.failureCount,
329
331
  taskResultCount: context.taskResults?.length || 0,
330
- plan: context.plan ? {
331
- id: context.plan.id,
332
- version: context.plan.version,
333
- taskCount: context.plan.tasks?.length
334
- } : null
332
+ plan: context.plan
333
+ ? {
334
+ id: context.plan.id,
335
+ version: context.plan.version,
336
+ taskCount: context.plan.tasks?.length,
337
+ }
338
+ : null,
335
339
  };
336
340
  }
337
341
 
@@ -347,14 +351,14 @@ class PlanMonitor extends EventEmitter {
347
351
  startTime: context.startTime,
348
352
  lastUpdate: context.lastUpdate,
349
353
  failureCount: this.failureCounts.get(contextId) || 0,
350
- taskResultCount: context.taskResults?.length || 0
354
+ taskResultCount: context.taskResults?.length || 0,
351
355
  });
352
356
  }
353
357
 
354
358
  return {
355
359
  isWatching: this.isWatching,
356
360
  activeContexts: this.watchedContexts.size,
357
- contexts
361
+ contexts,
358
362
  };
359
363
  }
360
364