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.
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 +158 -146
  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 +241 -126
  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 +77 -81
  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 +48 -46
  87. package/src/monitoring/incident-manager.js +116 -106
  88. package/src/monitoring/index.js +144 -134
  89. package/src/monitoring/observability.js +75 -62
  90. package/src/monitoring/quality-dashboard.js +45 -41
  91. package/src/monitoring/release-manager.js +63 -53
  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
@@ -15,33 +15,33 @@ const EventEmitter = require('events');
15
15
  const DEFAULT_CONFIG = {
16
16
  // Enable goal tracking
17
17
  enabled: true,
18
-
18
+
19
19
  // Minimum progress rate (percentage per time unit)
20
20
  minProgressRate: 0.05,
21
-
21
+
22
22
  // Time window for progress rate calculation (ms)
23
23
  progressWindow: 60000,
24
-
24
+
25
25
  // Threshold for goal completion (0-1)
26
26
  completionThreshold: 1.0,
27
-
27
+
28
28
  // Enable sub-goal decomposition
29
29
  subGoalTracking: true,
30
-
30
+
31
31
  // Trigger replan if progress stalls
32
32
  triggerOnStall: true,
33
-
33
+
34
34
  // Stall detection threshold (no progress for N consecutive checks)
35
35
  stallThreshold: 3,
36
-
36
+
37
37
  // Progress check interval (ms)
38
38
  checkInterval: 10000,
39
-
39
+
40
40
  // Enable predictive analysis
41
41
  predictiveAnalysis: true,
42
-
42
+
43
43
  // Confidence threshold for goal predictions
44
- predictionConfidence: 0.7
44
+ predictionConfidence: 0.7,
45
45
  };
46
46
 
47
47
  /**
@@ -126,10 +126,10 @@ class Goal {
126
126
  */
127
127
  isAtRisk(currentRate) {
128
128
  if (!this.deadline) return false;
129
-
129
+
130
130
  const eta = this.getETA(currentRate);
131
131
  if (eta === null) return true;
132
-
132
+
133
133
  const timeRemaining = this.deadline - Date.now();
134
134
  return eta > timeRemaining;
135
135
  }
@@ -154,7 +154,7 @@ class Goal {
154
154
  progress: this.progress,
155
155
  startedAt: this.startedAt,
156
156
  completedAt: this.completedAt,
157
- metadata: this.metadata
157
+ metadata: this.metadata,
158
158
  };
159
159
  }
160
160
  }
@@ -181,24 +181,24 @@ class GoalProgressTracker extends EventEmitter {
181
181
  */
182
182
  constructor(options = {}) {
183
183
  super();
184
-
184
+
185
185
  this.config = { ...DEFAULT_CONFIG, ...options.config };
186
-
186
+
187
187
  // Goals registry
188
188
  this.goals = new Map();
189
-
189
+
190
190
  // Progress history for trend analysis
191
191
  this.progressHistory = new Map(); // goalId -> ProgressSnapshot[]
192
-
192
+
193
193
  // Stall counters
194
194
  this.stallCounters = new Map(); // goalId -> count
195
-
195
+
196
196
  // Task to goal mapping
197
197
  this.taskGoalMapping = new Map(); // taskId -> goalId[]
198
-
198
+
199
199
  // Check interval timer
200
200
  this.checkTimer = null;
201
-
201
+
202
202
  // State
203
203
  this.isTracking = false;
204
204
  }
@@ -210,18 +210,18 @@ class GoalProgressTracker extends EventEmitter {
210
210
  */
211
211
  registerGoal(goalData) {
212
212
  const goal = goalData instanceof Goal ? goalData : new Goal(goalData);
213
-
213
+
214
214
  this.goals.set(goal.id, goal);
215
215
  this.progressHistory.set(goal.id, []);
216
216
  this.stallCounters.set(goal.id, 0);
217
-
217
+
218
218
  // Register sub-goals
219
219
  if (goal.hasSubGoals()) {
220
220
  for (const subGoal of goal.subGoals) {
221
221
  this.registerGoal(subGoal);
222
222
  }
223
223
  }
224
-
224
+
225
225
  this.emit('goal:registered', { goal });
226
226
  return goal;
227
227
  }
@@ -233,7 +233,7 @@ class GoalProgressTracker extends EventEmitter {
233
233
  */
234
234
  registerGoalsFromPlan(plan) {
235
235
  const goals = [];
236
-
236
+
237
237
  // Create main goal from plan
238
238
  const mainGoal = new Goal({
239
239
  id: `plan-${plan.id}`,
@@ -246,22 +246,22 @@ class GoalProgressTracker extends EventEmitter {
246
246
  description: task.description || `Execute ${task.skill || task.name}`,
247
247
  type: 'completion',
248
248
  priority: task.priority || 1,
249
- metadata: { taskId: task.id }
250
- }))
249
+ metadata: { taskId: task.id },
250
+ })),
251
251
  });
252
-
252
+
253
253
  this.registerGoal(mainGoal);
254
254
  goals.push(mainGoal);
255
-
255
+
256
256
  // Build task-goal mapping
257
- for (const task of (plan.tasks || [])) {
257
+ for (const task of plan.tasks || []) {
258
258
  const goalId = `task-${task.id}`;
259
259
  if (!this.taskGoalMapping.has(task.id)) {
260
260
  this.taskGoalMapping.set(task.id, []);
261
261
  }
262
262
  this.taskGoalMapping.get(task.id).push(goalId);
263
263
  }
264
-
264
+
265
265
  return goals;
266
266
  }
267
267
 
@@ -279,15 +279,15 @@ class GoalProgressTracker extends EventEmitter {
279
279
  */
280
280
  startTracking() {
281
281
  if (this.isTracking) return;
282
-
282
+
283
283
  this.isTracking = true;
284
-
284
+
285
285
  if (this.config.checkInterval > 0) {
286
286
  this.checkTimer = setInterval(() => {
287
287
  this.performCheck();
288
288
  }, this.config.checkInterval);
289
289
  }
290
-
290
+
291
291
  this.emit('tracking:started');
292
292
  }
293
293
 
@@ -296,14 +296,14 @@ class GoalProgressTracker extends EventEmitter {
296
296
  */
297
297
  stopTracking() {
298
298
  if (!this.isTracking) return;
299
-
299
+
300
300
  this.isTracking = false;
301
-
301
+
302
302
  if (this.checkTimer) {
303
303
  clearInterval(this.checkTimer);
304
304
  this.checkTimer = null;
305
305
  }
306
-
306
+
307
307
  this.emit('tracking:stopped');
308
308
  }
309
309
 
@@ -316,10 +316,10 @@ class GoalProgressTracker extends EventEmitter {
316
316
  updateProgress(goalId, progress, metadata = {}) {
317
317
  const goal = this.goals.get(goalId);
318
318
  if (!goal) return;
319
-
319
+
320
320
  const previousProgress = goal.progress;
321
321
  goal.progress = Math.max(0, Math.min(1, progress));
322
-
322
+
323
323
  // Update status
324
324
  if (goal.progress >= this.config.completionThreshold) {
325
325
  goal.status = 'completed';
@@ -328,10 +328,10 @@ class GoalProgressTracker extends EventEmitter {
328
328
  goal.status = 'in-progress';
329
329
  goal.startedAt = goal.startedAt || Date.now();
330
330
  }
331
-
331
+
332
332
  // Record snapshot
333
333
  this.recordSnapshot(goalId, goal.progress);
334
-
334
+
335
335
  // Check for stall
336
336
  if (progress === previousProgress) {
337
337
  const count = this.stallCounters.get(goalId) + 1;
@@ -339,21 +339,21 @@ class GoalProgressTracker extends EventEmitter {
339
339
  } else {
340
340
  this.stallCounters.set(goalId, 0);
341
341
  }
342
-
342
+
343
343
  // Emit progress event
344
344
  this.emit('progress:updated', {
345
345
  goalId,
346
346
  previousProgress,
347
347
  newProgress: goal.progress,
348
348
  delta: goal.progress - previousProgress,
349
- metadata
349
+ metadata,
350
350
  });
351
-
351
+
352
352
  // Check for completion
353
353
  if (goal.status === 'completed') {
354
354
  this.emit('goal:completed', { goal });
355
355
  }
356
-
356
+
357
357
  // Update parent goals
358
358
  this.updateParentGoals(goalId);
359
359
  }
@@ -380,7 +380,7 @@ class GoalProgressTracker extends EventEmitter {
380
380
  */
381
381
  onTaskComplete(taskId, result = {}) {
382
382
  const goalIds = this.taskGoalMapping.get(taskId) || [];
383
-
383
+
384
384
  for (const goalId of goalIds) {
385
385
  this.updateProgress(goalId, 1.0, { taskResult: result });
386
386
  }
@@ -393,7 +393,7 @@ class GoalProgressTracker extends EventEmitter {
393
393
  */
394
394
  onTaskFailed(taskId, error) {
395
395
  const goalIds = this.taskGoalMapping.get(taskId) || [];
396
-
396
+
397
397
  for (const goalId of goalIds) {
398
398
  const goal = this.goals.get(goalId);
399
399
  if (goal) {
@@ -412,9 +412,9 @@ class GoalProgressTracker extends EventEmitter {
412
412
  recordSnapshot(goalId, progress) {
413
413
  const snapshots = this.progressHistory.get(goalId);
414
414
  if (!snapshots) return;
415
-
415
+
416
416
  snapshots.push(new ProgressSnapshot(goalId, progress));
417
-
417
+
418
418
  // Keep only snapshots within the progress window
419
419
  const cutoff = Date.now() - this.config.progressWindow * 2;
420
420
  while (snapshots.length > 0 && snapshots[0].timestamp < cutoff) {
@@ -430,17 +430,17 @@ class GoalProgressTracker extends EventEmitter {
430
430
  calculateProgressRate(goalId) {
431
431
  const snapshots = this.progressHistory.get(goalId);
432
432
  if (!snapshots || snapshots.length < 2) return 0;
433
-
433
+
434
434
  const cutoff = Date.now() - this.config.progressWindow;
435
435
  const recent = snapshots.filter(s => s.timestamp >= cutoff);
436
-
436
+
437
437
  if (recent.length < 2) return 0;
438
-
438
+
439
439
  const first = recent[0];
440
440
  const last = recent[recent.length - 1];
441
441
  const progressDelta = last.progress - first.progress;
442
442
  const timeDelta = last.timestamp - first.timestamp;
443
-
443
+
444
444
  return timeDelta > 0 ? progressDelta / timeDelta : 0;
445
445
  }
446
446
 
@@ -450,36 +450,36 @@ class GoalProgressTracker extends EventEmitter {
450
450
  performCheck() {
451
451
  for (const [goalId, goal] of this.goals) {
452
452
  if (goal.status === 'completed' || goal.status === 'failed') continue;
453
-
453
+
454
454
  const rate = this.calculateProgressRate(goalId);
455
455
  const stallCount = this.stallCounters.get(goalId);
456
-
456
+
457
457
  // Check for stall
458
458
  if (this.config.triggerOnStall && stallCount >= this.config.stallThreshold) {
459
459
  this.emit('goal:stalled', {
460
460
  goal,
461
461
  stallCount,
462
462
  currentProgress: goal.progress,
463
- progressRate: rate
463
+ progressRate: rate,
464
464
  });
465
465
  }
466
-
466
+
467
467
  // Check progress rate
468
468
  if (rate < this.config.minProgressRate && goal.progress > 0 && goal.progress < 0.9) {
469
469
  this.emit('goal:slow-progress', {
470
470
  goal,
471
471
  currentRate: rate,
472
- minRate: this.config.minProgressRate
472
+ minRate: this.config.minProgressRate,
473
473
  });
474
474
  }
475
-
475
+
476
476
  // Check deadline risk
477
477
  if (goal.isAtRisk(rate)) {
478
478
  this.emit('goal:at-risk', {
479
479
  goal,
480
480
  eta: goal.getETA(rate),
481
481
  deadline: goal.deadline,
482
- currentProgress: goal.progress
482
+ currentProgress: goal.progress,
483
483
  });
484
484
  }
485
485
  }
@@ -497,30 +497,28 @@ class GoalProgressTracker extends EventEmitter {
497
497
  'in-progress': 0,
498
498
  completed: 0,
499
499
  failed: 0,
500
- blocked: 0
500
+ blocked: 0,
501
501
  },
502
502
  overallProgress: 0,
503
503
  atRiskCount: 0,
504
- stalledCount: 0
504
+ stalledCount: 0,
505
505
  };
506
-
506
+
507
507
  let totalProgress = 0;
508
-
508
+
509
509
  for (const [goalId, goal] of this.goals) {
510
510
  summary.byStatus[goal.status] = (summary.byStatus[goal.status] || 0) + 1;
511
511
  totalProgress += goal.calculateProgress();
512
-
512
+
513
513
  const rate = this.calculateProgressRate(goalId);
514
514
  if (goal.isAtRisk(rate)) summary.atRiskCount++;
515
-
515
+
516
516
  const stallCount = this.stallCounters.get(goalId);
517
517
  if (stallCount >= this.config.stallThreshold) summary.stalledCount++;
518
518
  }
519
-
520
- summary.overallProgress = this.goals.size > 0
521
- ? totalProgress / this.goals.size
522
- : 0;
523
-
519
+
520
+ summary.overallProgress = this.goals.size > 0 ? totalProgress / this.goals.size : 0;
521
+
524
522
  return summary;
525
523
  }
526
524
 
@@ -532,11 +530,11 @@ class GoalProgressTracker extends EventEmitter {
532
530
  getGoalReport(goalId) {
533
531
  const goal = this.goals.get(goalId);
534
532
  if (!goal) return null;
535
-
533
+
536
534
  const rate = this.calculateProgressRate(goalId);
537
535
  const stallCount = this.stallCounters.get(goalId);
538
536
  const snapshots = this.progressHistory.get(goalId) || [];
539
-
537
+
540
538
  return {
541
539
  goal: goal.toJSON(),
542
540
  metrics: {
@@ -545,18 +543,18 @@ class GoalProgressTracker extends EventEmitter {
545
543
  stallCount,
546
544
  eta: goal.getETA(rate),
547
545
  isAtRisk: goal.isAtRisk(rate),
548
- isStalled: stallCount >= this.config.stallThreshold
546
+ isStalled: stallCount >= this.config.stallThreshold,
549
547
  },
550
548
  history: snapshots.slice(-20).map(s => ({
551
549
  progress: s.progress,
552
- timestamp: s.timestamp
550
+ timestamp: s.timestamp,
553
551
  })),
554
552
  subGoalProgress: goal.subGoals.map(sg => ({
555
553
  id: sg.id,
556
554
  name: sg.name,
557
555
  progress: sg.calculateProgress(),
558
- status: sg.status
559
- }))
556
+ status: sg.status,
557
+ })),
560
558
  };
561
559
  }
562
560
 
@@ -568,22 +566,22 @@ class GoalProgressTracker extends EventEmitter {
568
566
  predictCompletion(goalId) {
569
567
  const goal = this.goals.get(goalId);
570
568
  if (!goal) return null;
571
-
569
+
572
570
  const rate = this.calculateProgressRate(goalId);
573
571
  const currentProgress = goal.calculateProgress();
574
-
572
+
575
573
  if (rate <= 0) {
576
574
  return {
577
575
  willComplete: false,
578
576
  confidence: 0.5,
579
- reason: 'No positive progress rate detected'
577
+ reason: 'No positive progress rate detected',
580
578
  };
581
579
  }
582
-
580
+
583
581
  const remaining = 1.0 - currentProgress;
584
582
  const eta = remaining / rate;
585
583
  const predictedCompletion = Date.now() + eta;
586
-
584
+
587
585
  // Check deadline
588
586
  if (goal.deadline && predictedCompletion > goal.deadline) {
589
587
  return {
@@ -591,16 +589,16 @@ class GoalProgressTracker extends EventEmitter {
591
589
  predictedCompletion,
592
590
  deadline: goal.deadline,
593
591
  confidence: this.config.predictionConfidence,
594
- reason: 'Current pace will miss deadline'
592
+ reason: 'Current pace will miss deadline',
595
593
  };
596
594
  }
597
-
595
+
598
596
  return {
599
597
  willComplete: true,
600
598
  predictedCompletion,
601
599
  eta,
602
600
  confidence: this.calculatePredictionConfidence(goalId, rate),
603
- reason: 'On track for completion'
601
+ reason: 'On track for completion',
604
602
  };
605
603
  }
606
604
 
@@ -610,29 +608,29 @@ class GoalProgressTracker extends EventEmitter {
610
608
  * @param {number} currentRate - Current progress rate
611
609
  * @returns {number} Confidence (0-1)
612
610
  */
613
- calculatePredictionConfidence(goalId, currentRate) {
611
+ calculatePredictionConfidence(goalId, _currentRate) {
614
612
  const snapshots = this.progressHistory.get(goalId) || [];
615
-
613
+
616
614
  if (snapshots.length < 5) return 0.5; // Low confidence with little data
617
-
615
+
618
616
  // Calculate variance in progress rate
619
617
  const rates = [];
620
618
  for (let i = 1; i < snapshots.length; i++) {
621
- const dt = snapshots[i].timestamp - snapshots[i-1].timestamp;
622
- const dp = snapshots[i].progress - snapshots[i-1].progress;
619
+ const dt = snapshots[i].timestamp - snapshots[i - 1].timestamp;
620
+ const dp = snapshots[i].progress - snapshots[i - 1].progress;
623
621
  if (dt > 0) rates.push(dp / dt);
624
622
  }
625
-
623
+
626
624
  if (rates.length < 2) return 0.5;
627
-
625
+
628
626
  const mean = rates.reduce((a, b) => a + b, 0) / rates.length;
629
627
  const variance = rates.reduce((sum, r) => sum + Math.pow(r - mean, 2), 0) / rates.length;
630
628
  const stdDev = Math.sqrt(variance);
631
-
629
+
632
630
  // Lower variance = higher confidence
633
631
  const coefficientOfVariation = mean !== 0 ? stdDev / Math.abs(mean) : 1;
634
632
  const confidence = Math.max(0.3, Math.min(0.95, 1 - coefficientOfVariation));
635
-
633
+
636
634
  return confidence;
637
635
  }
638
636
 
@@ -674,12 +672,12 @@ class GoalProgressTracker extends EventEmitter {
674
672
  progressHistory: Object.fromEntries(
675
673
  Array.from(this.progressHistory.entries()).map(([k, v]) => [
676
674
  k,
677
- v.map(s => ({ progress: s.progress, timestamp: s.timestamp }))
675
+ v.map(s => ({ progress: s.progress, timestamp: s.timestamp })),
678
676
  ])
679
677
  ),
680
678
  stallCounters: Object.fromEntries(this.stallCounters),
681
679
  taskGoalMapping: Object.fromEntries(this.taskGoalMapping),
682
- summary: this.getStatusSummary()
680
+ summary: this.getStatusSummary(),
683
681
  };
684
682
  }
685
683
 
@@ -689,13 +687,13 @@ class GoalProgressTracker extends EventEmitter {
689
687
  */
690
688
  importState(state) {
691
689
  this.reset();
692
-
690
+
693
691
  if (state.goals) {
694
692
  for (const goalData of state.goals) {
695
693
  this.registerGoal(goalData);
696
694
  }
697
695
  }
698
-
696
+
699
697
  if (state.progressHistory) {
700
698
  for (const [goalId, snapshots] of Object.entries(state.progressHistory)) {
701
699
  this.progressHistory.set(
@@ -704,13 +702,13 @@ class GoalProgressTracker extends EventEmitter {
704
702
  );
705
703
  }
706
704
  }
707
-
705
+
708
706
  if (state.stallCounters) {
709
707
  for (const [goalId, count] of Object.entries(state.stallCounters)) {
710
708
  this.stallCounters.set(goalId, count);
711
709
  }
712
710
  }
713
-
711
+
714
712
  if (state.taskGoalMapping) {
715
713
  for (const [taskId, goalIds] of Object.entries(state.taskGoalMapping)) {
716
714
  this.taskGoalMapping.set(taskId, goalIds);
@@ -723,5 +721,5 @@ module.exports = {
723
721
  GoalProgressTracker,
724
722
  Goal,
725
723
  ProgressSnapshot,
726
- DEFAULT_CONFIG
724
+ DEFAULT_CONFIG,
727
725
  };
@@ -9,42 +9,46 @@
9
9
  const { ReplanningEngine } = require('./replanning-engine');
10
10
  const { PlanMonitor } = require('./plan-monitor');
11
11
  const { PlanEvaluator } = require('./plan-evaluator');
12
- const { AlternativeGenerator, ContextAnalyzer, ConfidenceScorer } = require('./alternative-generator');
12
+ const {
13
+ AlternativeGenerator,
14
+ ContextAnalyzer,
15
+ ConfidenceScorer,
16
+ } = require('./alternative-generator');
13
17
  const { ReplanHistory } = require('./replan-history');
14
18
  const {
15
19
  ReplanTrigger,
16
20
  ReplanDecision,
17
21
  defaultReplanningConfig,
18
22
  mergeConfig,
19
- validateConfig
23
+ validateConfig,
20
24
  } = require('./config');
21
25
 
22
26
  // v3.6.0+ Advanced Replanning Components
23
- const {
24
- ProactivePathOptimizer,
25
- PathAnalyzer,
26
- OptimizationStrategy
27
+ const {
28
+ ProactivePathOptimizer,
29
+ PathAnalyzer,
30
+ OptimizationStrategy,
27
31
  } = require('./proactive-path-optimizer');
28
- const {
29
- GoalProgressTracker,
30
- ProgressCalculator,
31
- MilestoneManager,
32
- DeviationDetector,
33
- ProjectionEngine
32
+ const {
33
+ GoalProgressTracker,
34
+ ProgressCalculator,
35
+ MilestoneManager,
36
+ DeviationDetector,
37
+ ProjectionEngine,
34
38
  } = require('./goal-progress-tracker');
35
- const {
36
- AdaptiveGoalModifier,
37
- ImpactAnalyzer,
38
- ModificationStrategy,
39
+ const {
40
+ AdaptiveGoalModifier,
41
+ ImpactAnalyzer,
42
+ ModificationStrategy,
39
43
  ModificationHistoryManager,
40
44
  ModificationReason,
41
- ModificationType
45
+ ModificationType,
42
46
  } = require('./adaptive-goal-modifier');
43
47
 
44
48
  module.exports = {
45
49
  // Core Engine
46
50
  ReplanningEngine,
47
-
51
+
48
52
  // Components
49
53
  PlanMonitor,
50
54
  PlanEvaluator,
@@ -52,7 +56,7 @@ module.exports = {
52
56
  ContextAnalyzer,
53
57
  ConfidenceScorer,
54
58
  ReplanHistory,
55
-
59
+
56
60
  // Configuration
57
61
  ReplanTrigger,
58
62
  ReplanDecision,
@@ -78,5 +82,5 @@ module.exports = {
78
82
  ModificationStrategy,
79
83
  ModificationHistoryManager,
80
84
  ModificationReason,
81
- ModificationType
85
+ ModificationType,
82
86
  };