claude-flow-novice 1.6.1 → 1.6.2

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 (244) hide show
  1. package/.claude/agents/cfn-loop/product-owner.md +54 -4
  2. package/.claude/commands/cfn-claude-sync.md +303 -0
  3. package/.claude/commands/cfn-loop-epic.md +290 -0
  4. package/.claude/commands/cfn-loop-single.md +168 -0
  5. package/.claude/commands/cfn-loop-sprints.md +384 -0
  6. package/.claude/commands/cfn-loop.md +180 -0
  7. package/.claude/commands/metrics-summary.md +58 -0
  8. package/.claude/commands/parse-epic.md +357 -0
  9. package/.claude/settings.json +4 -4
  10. package/.claude/settings.local.json +9 -2
  11. package/.claude-flow-novice/.claude/agents/cfn-loop/product-owner.md +792 -0
  12. package/.claude-flow-novice/dist/mcp/server.js +21 -2
  13. package/.claude-flow-novice/dist/src/api/claude-client.js +138 -3
  14. package/.claude-flow-novice/dist/src/api/claude-client.js.map +1 -1
  15. package/.claude-flow-novice/dist/src/cfn-loop/phase-orchestrator-example.js +1 -1
  16. package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js +247 -0
  17. package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js.map +1 -0
  18. package/.claude-flow-novice/dist/src/cli/commands/swarm.js +32 -15
  19. package/.claude-flow-novice/dist/src/cli/commands/swarm.js.map +1 -1
  20. package/.claude-flow-novice/dist/src/cli/commands/transparency.js +455 -0
  21. package/.claude-flow-novice/dist/src/cli/commands/transparency.js.map +1 -0
  22. package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/CLAUDE.md +129 -13
  23. package/.claude-flow-novice/dist/src/components/visualizations/index.js +9 -0
  24. package/.claude-flow-novice/dist/src/components/visualizations/index.js.map +1 -0
  25. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js +462 -0
  26. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js.map +1 -0
  27. package/.claude-flow-novice/dist/src/coordination/config-translator.js +248 -0
  28. package/.claude-flow-novice/dist/src/coordination/config-translator.js.map +1 -0
  29. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js +287 -0
  30. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js.map +1 -0
  31. package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js +68 -9
  32. package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js.map +1 -1
  33. package/.claude-flow-novice/dist/src/coordination/feature-flags.js +166 -0
  34. package/.claude-flow-novice/dist/src/coordination/feature-flags.js.map +1 -0
  35. package/.claude-flow-novice/dist/src/coordination/queen-agent.js +18 -4
  36. package/.claude-flow-novice/dist/src/coordination/queen-agent.js.map +1 -1
  37. package/.claude-flow-novice/dist/src/coordination/role-assignment.js +6 -110
  38. package/.claude-flow-novice/dist/src/coordination/role-assignment.js.map +1 -1
  39. package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js +632 -0
  40. package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js.map +1 -0
  41. package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js +11 -0
  42. package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js.map +1 -0
  43. package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js +318 -0
  44. package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js.map +1 -0
  45. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js +364 -0
  46. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js.map +1 -0
  47. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js +492 -0
  48. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js.map +1 -0
  49. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js +786 -0
  50. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js.map +1 -0
  51. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js +16 -0
  52. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js.map +1 -0
  53. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js +342 -0
  54. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js.map +1 -0
  55. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js +601 -0
  56. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js.map +1 -0
  57. package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js +211 -0
  58. package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js.map +1 -0
  59. package/.claude-flow-novice/dist/src/coordination/v2/core/index.js +1 -0
  60. package/.claude-flow-novice/dist/src/coordination/v2/core/index.js.map +1 -1
  61. package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js +365 -6
  62. package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js.map +1 -1
  63. package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js +478 -0
  64. package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js.map +1 -0
  65. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js +5 -2
  66. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js.map +1 -1
  67. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js +189 -0
  68. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js.map +1 -1
  69. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js +424 -0
  70. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js.map +1 -0
  71. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js +9 -0
  72. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js.map +1 -0
  73. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js +669 -0
  74. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js.map +1 -0
  75. package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js +451 -0
  76. package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js.map +1 -0
  77. package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js +271 -0
  78. package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js.map +1 -0
  79. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js +335 -0
  80. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js.map +1 -0
  81. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js +439 -0
  82. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js.map +1 -0
  83. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js +92 -0
  84. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js.map +1 -0
  85. package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js +21 -0
  86. package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js.map +1 -0
  87. package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js +223 -0
  88. package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js.map +1 -0
  89. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js +436 -0
  90. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js.map +1 -0
  91. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js +278 -0
  92. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js.map +1 -0
  93. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js +317 -0
  94. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js.map +1 -0
  95. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js +273 -0
  96. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js.map +1 -0
  97. package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js +15 -0
  98. package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js.map +1 -0
  99. package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js +512 -0
  100. package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js.map +1 -0
  101. package/.claude-flow-novice/dist/src/coordination/v2/index.js +6 -0
  102. package/.claude-flow-novice/dist/src/coordination/v2/index.js.map +1 -1
  103. package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js +557 -0
  104. package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js.map +1 -0
  105. package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js +14 -0
  106. package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js.map +1 -0
  107. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js +212 -0
  108. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js.map +1 -0
  109. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js +552 -0
  110. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js.map +1 -0
  111. package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js +367 -0
  112. package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js.map +1 -0
  113. package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js +1 -0
  114. package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js.map +1 -1
  115. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js +371 -0
  116. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js.map +1 -0
  117. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js +355 -0
  118. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js.map +1 -0
  119. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js +424 -0
  120. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js.map +1 -0
  121. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js +16 -0
  122. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js.map +1 -0
  123. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js +295 -0
  124. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js.map +1 -0
  125. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js +411 -0
  126. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js.map +1 -0
  127. package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js +14 -0
  128. package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js.map +1 -0
  129. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js +387 -0
  130. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js.map +1 -0
  131. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js +589 -0
  132. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js.map +1 -0
  133. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js +444 -0
  134. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js.map +1 -0
  135. package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js +29 -8
  136. package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js.map +1 -1
  137. package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js +470 -0
  138. package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js.map +1 -0
  139. package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js +450 -0
  140. package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js.map +1 -0
  141. package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js +5 -0
  142. package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js.map +1 -1
  143. package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js +545 -0
  144. package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js.map +1 -0
  145. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js +44 -0
  146. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js.map +1 -1
  147. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js +415 -0
  148. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js.map +1 -0
  149. package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js +615 -0
  150. package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js.map +1 -0
  151. package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js +259 -0
  152. package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js.map +1 -0
  153. package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js +17 -0
  154. package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js.map +1 -0
  155. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js +357 -0
  156. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js.map +1 -0
  157. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js +679 -0
  158. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js.map +1 -0
  159. package/.claude-flow-novice/dist/src/core/agent-manager.js +30 -0
  160. package/.claude-flow-novice/dist/src/core/agent-manager.js.map +1 -1
  161. package/.claude-flow-novice/dist/src/mcp/server.js +21 -2
  162. package/.claude-flow-novice/dist/src/mcp/server.js.map +1 -1
  163. package/.claude-flow-novice/dist/src/observability/metrics-counter.js +268 -0
  164. package/.claude-flow-novice/dist/src/observability/metrics-counter.js.map +1 -0
  165. package/.claude-flow-novice/dist/src/observability/metrics-storage.js +265 -0
  166. package/.claude-flow-novice/dist/src/observability/metrics-storage.js.map +1 -0
  167. package/.claude-flow-novice/dist/src/observability/telemetry.js +26 -0
  168. package/.claude-flow-novice/dist/src/observability/telemetry.js.map +1 -1
  169. package/.claude-flow-novice/dist/src/providers/tiered-router.js +64 -10
  170. package/.claude-flow-novice/dist/src/providers/tiered-router.js.map +1 -1
  171. package/.claude-flow-novice/dist/src/providers/zai-provider.js +196 -97
  172. package/.claude-flow-novice/dist/src/providers/zai-provider.js.map +1 -1
  173. package/.claude-flow-novice/dist/src/slash-commands/cfn-claude-sync.js +533 -0
  174. package/.claude-flow-novice/dist/src/slash-commands/index.js +5 -0
  175. package/.claude-flow-novice/dist/src/slash-commands/metrics-summary-class.js +74 -0
  176. package/.claude-flow-novice/dist/src/slash-commands/metrics-summary.js +335 -0
  177. package/.claude-flow-novice/dist/src/slash-commands/register-all-commands.js +12 -0
  178. package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js +96 -0
  179. package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js.map +1 -0
  180. package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js +406 -0
  181. package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js.map +1 -0
  182. package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js +35 -5
  183. package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js.map +1 -1
  184. package/.claude-flow-novice/dist/src/web/api/config/api-config.js +186 -0
  185. package/.claude-flow-novice/dist/src/web/api/config/api-config.js.map +1 -0
  186. package/.claude-flow-novice/dist/src/web/api/middleware/auth.js +205 -0
  187. package/.claude-flow-novice/dist/src/web/api/middleware/auth.js.map +1 -0
  188. package/.claude-flow-novice/dist/src/web/api/middleware/cache.js +262 -0
  189. package/.claude-flow-novice/dist/src/web/api/middleware/cache.js.map +1 -0
  190. package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js +250 -0
  191. package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js.map +1 -0
  192. package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js +217 -0
  193. package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js.map +1 -0
  194. package/.claude-flow-novice/dist/src/web/api/middleware/validation.js +325 -0
  195. package/.claude-flow-novice/dist/src/web/api/middleware/validation.js.map +1 -0
  196. package/.claude-flow-novice/dist/src/web/api/routes/events.js +465 -0
  197. package/.claude-flow-novice/dist/src/web/api/routes/events.js.map +1 -0
  198. package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js +302 -0
  199. package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js.map +1 -0
  200. package/.claude-flow-novice/dist/src/web/api/routes/index.js +14 -0
  201. package/.claude-flow-novice/dist/src/web/api/routes/index.js.map +1 -0
  202. package/.claude-flow-novice/dist/src/web/api/routes/metrics.js +561 -0
  203. package/.claude-flow-novice/dist/src/web/api/routes/metrics.js.map +1 -0
  204. package/.claude-flow-novice/dist/src/web/api/routes/status.js +450 -0
  205. package/.claude-flow-novice/dist/src/web/api/routes/status.js.map +1 -0
  206. package/.claude-flow-novice/dist/src/web/api/server.js +451 -0
  207. package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -0
  208. package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js +385 -0
  209. package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js.map +1 -0
  210. package/.claude-flow-novice/dist/src/web/dashboard/index.js +87 -0
  211. package/.claude-flow-novice/dist/src/web/dashboard/index.js.map +1 -0
  212. package/.claude-flow-novice/dist/src/web/dashboard/types.js +6 -0
  213. package/.claude-flow-novice/dist/src/web/dashboard/types.js.map +1 -0
  214. package/.claude-flow-novice/metrics.db +0 -0
  215. package/.claude-flow-novice/metrics.db-shm +0 -0
  216. package/.claude-flow-novice/metrics.db-wal +0 -0
  217. package/CLAUDE.md +29 -0
  218. package/README.md +27 -0
  219. package/config/hooks/post-edit-pipeline.js +36 -2
  220. package/examples/metrics-counter-demo.ts +106 -0
  221. package/examples/persistent-metrics-demo.ts +83 -0
  222. package/examples/phase-5-multi-level-control.ts +282 -0
  223. package/examples/session-pool-optimizer-example.ts +311 -0
  224. package/package.json +15 -3
  225. package/scripts/check-routing-stats.cjs +122 -0
  226. package/scripts/pre-publish-validation.cjs +212 -0
  227. package/scripts/test-provider-routing.cjs +228 -0
  228. package/scripts/test-routing-telemetry.cjs +147 -0
  229. package/scripts/test-zai-10k.cjs +81 -0
  230. package/scripts/test-zai-api.cjs +191 -0
  231. package/scripts/test-zai-diagnostic.cjs +151 -0
  232. package/scripts/test-zai-final.cjs +128 -0
  233. package/scripts/test-zai-with-env.cjs +85 -0
  234. package/scripts/validate-coordination-cli.js +69 -0
  235. package/scripts/validate-coordination-toggle-integration.cjs +501 -0
  236. package/src/cli/simple-commands/init/templates/CLAUDE.md +29 -0
  237. package/src/observability/metrics-counter.ts +347 -0
  238. package/src/observability/metrics-storage.ts +356 -0
  239. package/src/observability/telemetry.ts +658 -0
  240. package/src/slash-commands/cfn-claude-sync.js +533 -0
  241. package/src/slash-commands/index.js +5 -0
  242. package/src/slash-commands/metrics-summary-class.js +74 -0
  243. package/src/slash-commands/metrics-summary.js +335 -0
  244. package/src/slash-commands/register-all-commands.js +12 -0
@@ -0,0 +1,533 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * CFN Claude Sync Slash Command
5
+ * Usage: /cfn-claude-sync [--dry-run] [--verbose]
6
+ *
7
+ * Synchronizes CFN Loop configuration from CLAUDE.md to slash command files.
8
+ * Ensures single source of truth (DRY principle) for CFN Loop rules.
9
+ *
10
+ * Extracts from CLAUDE.md:
11
+ * - Consensus threshold (≥90%)
12
+ * - Confidence gate (≥75%)
13
+ * - Loop 2/3 iteration limits
14
+ * - Complexity tiers and agent counts
15
+ * - GOAP decision types
16
+ * - Autonomous execution rules
17
+ */
18
+
19
+ import { SlashCommand } from "../core/slash-command.js";
20
+ import fs from "fs";
21
+ import path from "path";
22
+
23
+ export class CfnClaudeSyncCommand extends SlashCommand {
24
+ constructor() {
25
+ super(
26
+ "cfn-claude-sync",
27
+ "Sync CFN Loop rules from CLAUDE.md to slash command files (DRY principle enforcement)",
28
+ );
29
+ }
30
+
31
+ getUsage() {
32
+ return "/cfn-claude-sync [--dry-run] [--verbose]";
33
+ }
34
+
35
+ getExamples() {
36
+ return [
37
+ "/cfn-claude-sync",
38
+ "/cfn-claude-sync --dry-run",
39
+ "/cfn-claude-sync --verbose",
40
+ ];
41
+ }
42
+
43
+ async execute(args, context) {
44
+ const options = this.parseArgs(args);
45
+
46
+ try {
47
+ const projectRoot = process.cwd();
48
+ const claudeMdPath = path.join(projectRoot, "CLAUDE.md");
49
+
50
+ // Step 1: Verify CLAUDE.md exists
51
+ if (!fs.existsSync(claudeMdPath)) {
52
+ return this.formatResponse({
53
+ success: false,
54
+ error: "CLAUDE.md not found in project root",
55
+ path: claudeMdPath,
56
+ suggestion:
57
+ "Please ensure CLAUDE.md exists before running sync command",
58
+ });
59
+ }
60
+
61
+ // Step 2: Extract CFN Loop configuration from CLAUDE.md
62
+ const config = this.extractCfnConfig(claudeMdPath, options.verbose);
63
+
64
+ if (options.verbose) {
65
+ console.log("📋 Extracted Configuration:");
66
+ console.log(JSON.stringify(config, null, 2));
67
+ }
68
+
69
+ // Step 3: Identify target files
70
+ const targetFiles = this.getTargetFiles(projectRoot);
71
+
72
+ if (options.verbose) {
73
+ console.log("\n📂 Target Files:");
74
+ console.log(
75
+ ` Markdown templates: ${targetFiles.markdown.length} files`,
76
+ );
77
+ console.log(
78
+ ` JavaScript generators: ${targetFiles.javascript.length} files`,
79
+ );
80
+ }
81
+
82
+ // Step 4: Analyze required changes
83
+ const changes = this.analyzeChanges(targetFiles, config, options.verbose);
84
+
85
+ // Step 5: Dry run or apply changes
86
+ if (options.dryRun) {
87
+ return this.formatDryRunReport(config, changes);
88
+ } else {
89
+ const results = await this.applyChanges(
90
+ targetFiles,
91
+ config,
92
+ changes,
93
+ options.verbose,
94
+ );
95
+ return this.formatSyncReport(config, results);
96
+ }
97
+ } catch (error) {
98
+ return this.formatResponse({
99
+ success: false,
100
+ error: error.message,
101
+ stack: options.verbose ? error.stack : undefined,
102
+ });
103
+ }
104
+ }
105
+
106
+ parseArgs(args) {
107
+ const options = {
108
+ dryRun: false,
109
+ verbose: false,
110
+ };
111
+
112
+ for (const arg of args) {
113
+ if (arg === "--dry-run") {
114
+ options.dryRun = true;
115
+ } else if (arg === "--verbose") {
116
+ options.verbose = true;
117
+ }
118
+ }
119
+
120
+ return options;
121
+ }
122
+
123
+ extractCfnConfig(claudeMdPath, verbose) {
124
+ const content = fs.readFileSync(claudeMdPath, "utf-8");
125
+
126
+ // Extract CFN Loop section
127
+ const cfnSectionMatch = content.match(
128
+ /## 🔄 MANDATORY CFN LOOP[\s\S]*?(?=\n## [^#]|$)/,
129
+ );
130
+
131
+ if (!cfnSectionMatch) {
132
+ throw new Error(
133
+ "Could not find '## 🔄 MANDATORY CFN LOOP' section in CLAUDE.md",
134
+ );
135
+ }
136
+
137
+ const cfnSection = cfnSectionMatch[0];
138
+
139
+ // Extract configuration values with robust regex patterns
140
+ const config = {
141
+ consensusThreshold: this.extractValue(
142
+ cfnSection,
143
+ /≥(\d+)%.*consensus/i,
144
+ "90",
145
+ ),
146
+ confidenceGate: this.extractValue(
147
+ cfnSection,
148
+ /ALL agents ≥(\d+)%|≥(\d+)%.*confidence/i,
149
+ "75",
150
+ ),
151
+ loop2MaxIterations: this.extractValue(
152
+ cfnSection,
153
+ /Loop 2.*[Mm]ax.*?(\d+)|Loop 2.*\(.*?(\d+).*iterations\)/i,
154
+ "10",
155
+ ),
156
+ loop3MaxIterations: this.extractValue(
157
+ cfnSection,
158
+ /Loop 3.*[Mm]ax.*?(\d+)|Loop 3.*\(.*?(\d+).*iterations\)/i,
159
+ "10",
160
+ ),
161
+
162
+ // Complexity tiers
163
+ complexityTiers: {
164
+ simple: this.extractComplexityTier(cfnSection, "Simple", "2-3", "mesh"),
165
+ medium: this.extractComplexityTier(cfnSection, "Medium", "4-6", "mesh"),
166
+ complex: this.extractComplexityTier(
167
+ cfnSection,
168
+ "Complex",
169
+ "8-12",
170
+ "hierarchical",
171
+ ),
172
+ enterprise: this.extractComplexityTier(
173
+ cfnSection,
174
+ "Enterprise",
175
+ "15-20",
176
+ "hierarchical",
177
+ ),
178
+ },
179
+
180
+ // GOAP decision types
181
+ goapDecisions: ["PROCEED", "DEFER", "ESCALATE"],
182
+
183
+ // Autonomous rules
184
+ autonomousRules: [
185
+ "NO approval needed for retries",
186
+ "IMMEDIATE relaunch on consensus failure",
187
+ "AUTO-TRANSITION on phase completion",
188
+ ],
189
+ };
190
+
191
+ if (verbose) {
192
+ console.log("✅ Successfully extracted CFN Loop configuration");
193
+ }
194
+
195
+ return config;
196
+ }
197
+
198
+ extractValue(text, pattern, fallback) {
199
+ const match = text.match(pattern);
200
+ if (match) {
201
+ // Return first captured group that's not undefined
202
+ for (let i = 1; i < match.length; i++) {
203
+ if (match[i] !== undefined) {
204
+ return match[i];
205
+ }
206
+ }
207
+ }
208
+ return fallback;
209
+ }
210
+
211
+ extractComplexityTier(text, tierName, defaultAgents, defaultTopology) {
212
+ // Try to find agent count for this tier
213
+ const agentPattern = new RegExp(
214
+ `\\*\\*${tierName}\\*\\*.*?(\\d+-?\\d*)\\s+agents`,
215
+ "i",
216
+ );
217
+ const agentMatch = text.match(agentPattern);
218
+
219
+ // Try to find topology for this tier
220
+ const topologyPattern = new RegExp(
221
+ `${tierName}.*?(mesh|hierarchical)`,
222
+ "i",
223
+ );
224
+ const topologyMatch = text.match(topologyPattern);
225
+
226
+ return {
227
+ agents: agentMatch ? agentMatch[1] : defaultAgents,
228
+ topology: topologyMatch
229
+ ? topologyMatch[1].toLowerCase()
230
+ : defaultTopology,
231
+ };
232
+ }
233
+
234
+ getTargetFiles(projectRoot) {
235
+ return {
236
+ markdown: [
237
+ ".claude/commands/cfn-loop.md",
238
+ ".claude/commands/cfn-loop-epic.md",
239
+ ".claude/commands/cfn-loop-sprints.md",
240
+ ".claude/commands/cfn-loop-single.md",
241
+ ].map((f) => path.join(projectRoot, f)),
242
+
243
+ javascript: [
244
+ "src/slash-commands/cfn-loop.js",
245
+ "src/slash-commands/cfn-loop-epic.js",
246
+ "src/slash-commands/cfn-loop-sprints.js",
247
+ "src/slash-commands/cfn-loop-single.js",
248
+ ].map((f) => path.join(projectRoot, f)),
249
+ };
250
+ }
251
+
252
+ analyzeChanges(targetFiles, config, verbose) {
253
+ const changes = {
254
+ markdown: [],
255
+ javascript: [],
256
+ };
257
+
258
+ // Analyze markdown files
259
+ for (const file of targetFiles.markdown) {
260
+ if (!fs.existsSync(file)) {
261
+ if (verbose) console.log(`⚠️ Skipping missing file: ${file}`);
262
+ continue;
263
+ }
264
+
265
+ const content = fs.readFileSync(file, "utf-8");
266
+ const fileChanges = [];
267
+
268
+ // Check consensus threshold
269
+ const consensusPattern = /≥(\d+)%.*consensus/gi;
270
+ let match;
271
+ while ((match = consensusPattern.exec(content)) !== null) {
272
+ if (match[1] !== config.consensusThreshold) {
273
+ fileChanges.push({
274
+ line: this.getLineNumber(content, match.index),
275
+ type: "consensus_threshold",
276
+ current: match[1],
277
+ expected: config.consensusThreshold,
278
+ });
279
+ }
280
+ }
281
+
282
+ // Check confidence gate
283
+ const confidencePattern = /ALL agents ≥(\d+)%/gi;
284
+ while ((match = confidencePattern.exec(content)) !== null) {
285
+ if (match[1] !== config.confidenceGate) {
286
+ fileChanges.push({
287
+ line: this.getLineNumber(content, match.index),
288
+ type: "confidence_gate",
289
+ current: match[1],
290
+ expected: config.confidenceGate,
291
+ });
292
+ }
293
+ }
294
+
295
+ if (fileChanges.length > 0) {
296
+ changes.markdown.push({ file, changes: fileChanges });
297
+ }
298
+ }
299
+
300
+ // Analyze JavaScript files
301
+ for (const file of targetFiles.javascript) {
302
+ if (!fs.existsSync(file)) {
303
+ if (verbose) console.log(`⚠️ Skipping missing file: ${file}`);
304
+ continue;
305
+ }
306
+
307
+ const content = fs.readFileSync(file, "utf-8");
308
+ const fileChanges = [];
309
+
310
+ // Check maxLoop2 default
311
+ const loop2Pattern = /maxLoop2:\s*(\d+)/g;
312
+ let match;
313
+ while ((match = loop2Pattern.exec(content)) !== null) {
314
+ if (match[1] !== config.loop2MaxIterations) {
315
+ fileChanges.push({
316
+ line: this.getLineNumber(content, match.index),
317
+ type: "loop2_max",
318
+ current: match[1],
319
+ expected: config.loop2MaxIterations,
320
+ });
321
+ }
322
+ }
323
+
324
+ // Check maxLoop3 default
325
+ const loop3Pattern = /maxLoop3:\s*(\d+)/g;
326
+ while ((match = loop3Pattern.exec(content)) !== null) {
327
+ if (match[1] !== config.loop3MaxIterations) {
328
+ fileChanges.push({
329
+ line: this.getLineNumber(content, match.index),
330
+ type: "loop3_max",
331
+ current: match[1],
332
+ expected: config.loop3MaxIterations,
333
+ });
334
+ }
335
+ }
336
+
337
+ if (fileChanges.length > 0) {
338
+ changes.javascript.push({ file, changes: fileChanges });
339
+ }
340
+ }
341
+
342
+ return changes;
343
+ }
344
+
345
+ getLineNumber(content, charIndex) {
346
+ return content.substring(0, charIndex).split("\n").length;
347
+ }
348
+
349
+ async applyChanges(targetFiles, config, changes, verbose) {
350
+ const results = {
351
+ updated: [],
352
+ errors: [],
353
+ skipped: [],
354
+ };
355
+
356
+ // Create backup directory
357
+ const backupDir = path.join(
358
+ process.cwd(),
359
+ ".claude",
360
+ "backups",
361
+ `cfn-sync-${Date.now()}`,
362
+ );
363
+ fs.mkdirSync(backupDir, { recursive: true });
364
+
365
+ // Apply markdown changes
366
+ for (const fileChange of changes.markdown) {
367
+ try {
368
+ const { file } = fileChange;
369
+ let content = fs.readFileSync(file, "utf-8");
370
+
371
+ // Backup original
372
+ const backupPath = path.join(backupDir, path.basename(file));
373
+ fs.writeFileSync(backupPath, content);
374
+
375
+ // Apply replacements
376
+ content = content.replace(
377
+ /≥(\d+)%(\s*.*?consensus)/gi,
378
+ `≥${config.consensusThreshold}%$2`,
379
+ );
380
+ content = content.replace(
381
+ /ALL agents ≥(\d+)%/gi,
382
+ `ALL agents ≥${config.confidenceGate}%`,
383
+ );
384
+
385
+ fs.writeFileSync(file, content);
386
+ results.updated.push({
387
+ file,
388
+ changes: fileChange.changes.length,
389
+ });
390
+
391
+ if (verbose) {
392
+ console.log(
393
+ `✅ Updated ${path.basename(file)} (${fileChange.changes.length} changes)`,
394
+ );
395
+ }
396
+ } catch (error) {
397
+ results.errors.push({ file: fileChange.file, error: error.message });
398
+ }
399
+ }
400
+
401
+ // Apply JavaScript changes
402
+ for (const fileChange of changes.javascript) {
403
+ try {
404
+ const { file } = fileChange;
405
+ let content = fs.readFileSync(file, "utf-8");
406
+
407
+ // Backup original
408
+ const backupPath = path.join(backupDir, path.basename(file));
409
+ fs.writeFileSync(backupPath, content);
410
+
411
+ // Apply replacements
412
+ content = content.replace(
413
+ /maxLoop2:\s*\d+/g,
414
+ `maxLoop2: ${config.loop2MaxIterations}`,
415
+ );
416
+ content = content.replace(
417
+ /maxLoop3:\s*\d+/g,
418
+ `maxLoop3: ${config.loop3MaxIterations}`,
419
+ );
420
+
421
+ fs.writeFileSync(file, content);
422
+ results.updated.push({
423
+ file,
424
+ changes: fileChange.changes.length,
425
+ });
426
+
427
+ if (verbose) {
428
+ console.log(
429
+ `✅ Updated ${path.basename(file)} (${fileChange.changes.length} changes)`,
430
+ );
431
+ }
432
+ } catch (error) {
433
+ results.errors.push({ file: fileChange.file, error: error.message });
434
+ }
435
+ }
436
+
437
+ return results;
438
+ }
439
+
440
+ formatDryRunReport(config, changes) {
441
+ const totalChanges =
442
+ changes.markdown.reduce((sum, f) => sum + f.changes.length, 0) +
443
+ changes.javascript.reduce((sum, f) => sum + f.changes.length, 0);
444
+
445
+ let report = `
446
+ 🔍 **CFN Claude Sync (DRY RUN)**
447
+
448
+ **Extracted from CLAUDE.md:**
449
+ - Consensus threshold: ≥${config.consensusThreshold}%
450
+ - Confidence gate: ≥${config.confidenceGate}%
451
+ - Loop 2 max iterations: ${config.loop2MaxIterations}
452
+ - Loop 3 max iterations: ${config.loop3MaxIterations}
453
+
454
+ **Changes to be made:**
455
+ `;
456
+
457
+ for (const fileChange of changes.markdown) {
458
+ report += `\n ${path.basename(fileChange.file)}:\n`;
459
+ for (const change of fileChange.changes) {
460
+ report += ` Line ${change.line}: ${change.current}% → ${config.consensusThreshold}% (${change.type})\n`;
461
+ }
462
+ }
463
+
464
+ for (const fileChange of changes.javascript) {
465
+ report += `\n ${path.basename(fileChange.file)}:\n`;
466
+ for (const change of fileChange.changes) {
467
+ report += ` Line ${change.line}: ${change.current} → ${change.expected} (${change.type})\n`;
468
+ }
469
+ }
470
+
471
+ report += `\n**Total files to update:** ${changes.markdown.length + changes.javascript.length}`;
472
+ report += `\n**Total changes:** ${totalChanges}`;
473
+ report += `\n\nRun without --dry-run to apply changes.`;
474
+
475
+ return this.formatResponse({
476
+ success: true,
477
+ dryRun: true,
478
+ report: report,
479
+ config: config,
480
+ changes: changes,
481
+ });
482
+ }
483
+
484
+ formatSyncReport(config, results) {
485
+ let report = `
486
+ ✅ **CFN Claude Sync Complete**
487
+
488
+ **Updated files:**
489
+ `;
490
+
491
+ for (const update of results.updated) {
492
+ report += ` ✅ ${path.basename(update.file)} (${update.changes} changes)\n`;
493
+ }
494
+
495
+ if (results.errors.length > 0) {
496
+ report += `\n**Errors:**\n`;
497
+ for (const error of results.errors) {
498
+ report += ` ❌ ${path.basename(error.file)}: ${error.error}\n`;
499
+ }
500
+ }
501
+
502
+ if (results.skipped.length > 0) {
503
+ report += `\n**Skipped:**\n`;
504
+ for (const skip of results.skipped) {
505
+ report += ` ⚠️ ${path.basename(skip)}\n`;
506
+ }
507
+ }
508
+
509
+ report += `
510
+ **Configuration now synchronized:**
511
+ - Consensus threshold: ≥${config.consensusThreshold}%
512
+ - Confidence gate: ≥${config.confidenceGate}%
513
+ - Loop 2 max: ${config.loop2MaxIterations} iterations
514
+ - Loop 3 max: ${config.loop3MaxIterations} iterations
515
+
516
+ **Next steps:**
517
+ 1. Review changes: git diff
518
+ 2. Run tests: npm test
519
+ 3. Validate: /cfn-loop "test task" --dry-run
520
+ 4. Commit: git commit -m "chore: sync CFN Loop from CLAUDE.md"
521
+ `;
522
+
523
+ return this.formatResponse({
524
+ success: true,
525
+ report: report,
526
+ config: config,
527
+ results: results,
528
+ });
529
+ }
530
+ }
531
+
532
+ // Register command
533
+ export default CfnClaudeSyncCommand;
@@ -23,6 +23,7 @@ export { CfnLoopSingleCommand } from "./cfn-loop-single.js";
23
23
  export { CfnLoopSprintsCommand } from "./cfn-loop-sprints.js";
24
24
  export { CfnLoopEpicCommand } from "./cfn-loop-epic.js";
25
25
  export { ParseEpicCommand } from "./parse-epic.js";
26
+ export { CfnClaudeSyncCommand } from "./cfn-claude-sync.js";
26
27
 
27
28
  // Command executors
28
29
  export { executeClaudeSoulCommand } from "./claude-soul.js";
@@ -60,6 +61,7 @@ export const Commands = {
60
61
  CFN_LOOP_SPRINTS: "cfn-loop-sprints",
61
62
  CFN_LOOP_EPIC: "cfn-loop-epic",
62
63
  PARSE_EPIC: "parse-epic",
64
+ CFN_CLAUDE_SYNC: "cfn-claude-sync",
63
65
  };
64
66
 
65
67
  /**
@@ -82,6 +84,8 @@ export const Aliases = {
82
84
  "cfn-epic": "cfn-loop-epic",
83
85
  parse: "parse-epic",
84
86
  epic: "parse-epic",
87
+ sync: "cfn-claude-sync",
88
+ "cfn-sync": "cfn-claude-sync",
85
89
  };
86
90
 
87
91
  /**
@@ -110,6 +114,7 @@ export function getQuickHelp() {
110
114
  **Essential Commands:**
111
115
  - \`/cfn-loop "task description"\` - Autonomous self-correcting 3-loop workflow (IMMEDIATE retries)
112
116
  - \`/fullstack "goal"\` - Autonomous full-stack team with CFN Loop (NO approvals)
117
+ - \`/cfn-claude-sync\` - Sync CFN Loop rules from CLAUDE.md to slash commands (DRY principle)
113
118
  - \`/swarm init mesh 8\` - Initialize agent swarm
114
119
  - \`/hooks enable\` - Enable automation hooks
115
120
  - \`/sparc spec "task"\` - Run SPARC methodology
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Metrics Summary Slash Command Class
5
+ *
6
+ * Slash command wrapper for metrics-summary.js script.
7
+ */
8
+
9
+ import { fileURLToPath } from 'url';
10
+ import { dirname, join } from 'path';
11
+ import { execSync } from 'child_process';
12
+
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = dirname(__filename);
15
+
16
+ export class MetricsSummaryCommand {
17
+ constructor() {
18
+ this.name = 'metrics-summary';
19
+ this.description = 'Display aggregated metrics statistics with configurable time frame';
20
+ this.usage = '/metrics-summary [--minutes=60] [--provider=all] [--model=all]';
21
+ }
22
+
23
+ /**
24
+ * Get command help
25
+ */
26
+ getHelp() {
27
+ return {
28
+ name: this.name,
29
+ description: this.description,
30
+ usage: this.usage,
31
+ examples: [
32
+ '/metrics-summary',
33
+ '/metrics-summary --minutes=1440',
34
+ '/metrics-summary --minutes=60 --provider=z.ai',
35
+ '/metrics-summary --minutes=10080 --model=glm-4.6',
36
+ ],
37
+ options: [
38
+ '--minutes=<N> Time frame in minutes (default: 60 = last hour)',
39
+ '--provider=<P> Filter by provider: all, anthropic, z.ai (default: all)',
40
+ '--model=<M> Filter by model name (default: all)',
41
+ ],
42
+ };
43
+ }
44
+
45
+ /**
46
+ * Execute command
47
+ */
48
+ async execute(args, context = {}) {
49
+ try {
50
+ const scriptPath = join(__dirname, 'metrics-summary.js');
51
+ const nodeArgs = args.join(' ');
52
+
53
+ // Execute metrics-summary.js script
54
+ const output = execSync(`node "${scriptPath}" ${nodeArgs}`, {
55
+ encoding: 'utf8',
56
+ cwd: join(__dirname, '../..'),
57
+ stdio: 'pipe',
58
+ });
59
+
60
+ return {
61
+ success: true,
62
+ output: output,
63
+ };
64
+ } catch (error) {
65
+ return {
66
+ success: false,
67
+ error: error.message,
68
+ stderr: error.stderr?.toString() || '',
69
+ };
70
+ }
71
+ }
72
+ }
73
+
74
+ export default MetricsSummaryCommand;