claude-flow-novice 1.6.1 → 1.6.3

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 (273) 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 +5 -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/auth-service.js +84 -38
  14. package/.claude-flow-novice/dist/src/api/auth-service.js.map +1 -1
  15. package/.claude-flow-novice/dist/src/api/claude-client.js +138 -3
  16. package/.claude-flow-novice/dist/src/api/claude-client.js.map +1 -1
  17. package/.claude-flow-novice/dist/src/cfn-loop/phase-orchestrator-example.js +1 -1
  18. package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js +247 -0
  19. package/.claude-flow-novice/dist/src/cfn-loop/scope-control.js.map +1 -0
  20. package/.claude-flow-novice/dist/src/cli/commands/swarm.js +32 -15
  21. package/.claude-flow-novice/dist/src/cli/commands/swarm.js.map +1 -1
  22. package/.claude-flow-novice/dist/src/cli/commands/transparency.js +455 -0
  23. package/.claude-flow-novice/dist/src/cli/commands/transparency.js.map +1 -0
  24. package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/CLAUDE.md +129 -13
  25. package/.claude-flow-novice/dist/src/components/visualizations/index.js +9 -0
  26. package/.claude-flow-novice/dist/src/components/visualizations/index.js.map +1 -0
  27. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js +462 -0
  28. package/.claude-flow-novice/dist/src/coordination/adapters/v1-coordinator-adapter.js.map +1 -0
  29. package/.claude-flow-novice/dist/src/coordination/config-translator.js +248 -0
  30. package/.claude-flow-novice/dist/src/coordination/config-translator.js.map +1 -0
  31. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js +287 -0
  32. package/.claude-flow-novice/dist/src/coordination/coordination-toggle.js.map +1 -0
  33. package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js +68 -9
  34. package/.claude-flow-novice/dist/src/coordination/distributed-consensus.js.map +1 -1
  35. package/.claude-flow-novice/dist/src/coordination/feature-flags.js +166 -0
  36. package/.claude-flow-novice/dist/src/coordination/feature-flags.js.map +1 -0
  37. package/.claude-flow-novice/dist/src/coordination/queen-agent.js +18 -4
  38. package/.claude-flow-novice/dist/src/coordination/queen-agent.js.map +1 -1
  39. package/.claude-flow-novice/dist/src/coordination/role-assignment.js +6 -110
  40. package/.claude-flow-novice/dist/src/coordination/role-assignment.js.map +1 -1
  41. package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js +632 -0
  42. package/.claude-flow-novice/dist/src/coordination/v2/cache/artifact-cache-optimizer.js.map +1 -0
  43. package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js +11 -0
  44. package/.claude-flow-novice/dist/src/coordination/v2/cache/index.js.map +1 -0
  45. package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js +318 -0
  46. package/.claude-flow-novice/dist/src/coordination/v2/checkpoints/checkpoint-compressor.js.map +1 -0
  47. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js +364 -0
  48. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.example.js.map +1 -0
  49. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js +492 -0
  50. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/cascading-shutdown.js.map +1 -0
  51. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js +786 -0
  52. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/hierarchical-coordinator.js.map +1 -0
  53. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js +16 -0
  54. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/index.js.map +1 -0
  55. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js +342 -0
  56. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/parent-child-manager.js.map +1 -0
  57. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js +601 -0
  58. package/.claude-flow-novice/dist/src/coordination/v2/coordinators/swarm-coordinator-v2.js.map +1 -0
  59. package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js +211 -0
  60. package/.claude-flow-novice/dist/src/coordination/v2/core/help-request-metrics.js.map +1 -0
  61. package/.claude-flow-novice/dist/src/coordination/v2/core/index.js +1 -0
  62. package/.claude-flow-novice/dist/src/coordination/v2/core/index.js.map +1 -1
  63. package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js +365 -6
  64. package/.claude-flow-novice/dist/src/coordination/v2/core/message-broker.js.map +1 -1
  65. package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js +478 -0
  66. package/.claude-flow-novice/dist/src/coordination/v2/core/resource-manager-safe.js.map +1 -0
  67. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js +5 -2
  68. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine-config.js.map +1 -1
  69. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js +189 -0
  70. package/.claude-flow-novice/dist/src/coordination/v2/core/state-machine.js.map +1 -1
  71. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js +424 -0
  72. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/deadlock-detector.js.map +1 -0
  73. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js +9 -0
  74. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/index.js.map +1 -0
  75. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js +669 -0
  76. package/.claude-flow-novice/dist/src/coordination/v2/deadlock/resource-manager.js.map +1 -0
  77. package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js +451 -0
  78. package/.claude-flow-novice/dist/src/coordination/v2/dependency/artifact-storage.js.map +1 -0
  79. package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js +271 -0
  80. package/.claude-flow-novice/dist/src/coordination/v2/dependency/cycle-detector.js.map +1 -0
  81. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js +335 -0
  82. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-graph.js.map +1 -0
  83. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js +439 -0
  84. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-manager.js.map +1 -0
  85. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js +92 -0
  86. package/.claude-flow-novice/dist/src/coordination/v2/dependency/dependency-request.js.map +1 -0
  87. package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js +21 -0
  88. package/.claude-flow-novice/dist/src/coordination/v2/dependency/index.js.map +1 -0
  89. package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js +223 -0
  90. package/.claude-flow-novice/dist/src/coordination/v2/dependency/topological-sort.js.map +1 -0
  91. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js +436 -0
  92. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-coordinator.js.map +1 -0
  93. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js +278 -0
  94. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-matcher.js.map +1 -0
  95. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js +317 -0
  96. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request-handler.js.map +1 -0
  97. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js +273 -0
  98. package/.claude-flow-novice/dist/src/coordination/v2/help-system/help-request.js.map +1 -0
  99. package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js +15 -0
  100. package/.claude-flow-novice/dist/src/coordination/v2/help-system/index.js.map +1 -0
  101. package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js +512 -0
  102. package/.claude-flow-novice/dist/src/coordination/v2/help-system/waiting-agent-pool.js.map +1 -0
  103. package/.claude-flow-novice/dist/src/coordination/v2/index.js +6 -0
  104. package/.claude-flow-novice/dist/src/coordination/v2/index.js.map +1 -1
  105. package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js +557 -0
  106. package/.claude-flow-novice/dist/src/coordination/v2/integration/help-deadlock-integration.js.map +1 -0
  107. package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js +14 -0
  108. package/.claude-flow-novice/dist/src/coordination/v2/integration/index.js.map +1 -0
  109. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js +212 -0
  110. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.example.js.map +1 -0
  111. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js +552 -0
  112. package/.claude-flow-novice/dist/src/coordination/v2/integration/message-bus-completion-integration.js.map +1 -0
  113. package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js +367 -0
  114. package/.claude-flow-novice/dist/src/coordination/v2/memory/dependency-storage.js.map +1 -0
  115. package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js +1 -0
  116. package/.claude-flow-novice/dist/src/coordination/v2/memory/index.js.map +1 -1
  117. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js +371 -0
  118. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channel.js.map +1 -0
  119. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js +355 -0
  120. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/dependency-channel.js.map +1 -0
  121. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js +424 -0
  122. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/help-channel.js.map +1 -0
  123. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js +16 -0
  124. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/index.js.map +1 -0
  125. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js +295 -0
  126. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/state-channel.js.map +1 -0
  127. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js +411 -0
  128. package/.claude-flow-novice/dist/src/coordination/v2/messaging/channels/task-channel.js.map +1 -0
  129. package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js +14 -0
  130. package/.claude-flow-novice/dist/src/coordination/v2/messaging/index.js.map +1 -0
  131. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js +387 -0
  132. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-bus.js.map +1 -0
  133. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js +589 -0
  134. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-persistence.js.map +1 -0
  135. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js +444 -0
  136. package/.claude-flow-novice/dist/src/coordination/v2/messaging/message-router.js.map +1 -0
  137. package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js +29 -8
  138. package/.claude-flow-novice/dist/src/coordination/v2/sdk/checkpoint-manager.js.map +1 -1
  139. package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js +470 -0
  140. package/.claude-flow-novice/dist/src/coordination/v2/sdk/help-coordinator.js.map +1 -0
  141. package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js +450 -0
  142. package/.claude-flow-novice/dist/src/coordination/v2/sdk/hierarchical-background-integration.js.map +1 -0
  143. package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js +5 -0
  144. package/.claude-flow-novice/dist/src/coordination/v2/sdk/index.js.map +1 -1
  145. package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js +545 -0
  146. package/.claude-flow-novice/dist/src/coordination/v2/sdk/multi-level-control.js.map +1 -0
  147. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js +44 -0
  148. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-controller.js.map +1 -1
  149. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js +415 -0
  150. package/.claude-flow-novice/dist/src/coordination/v2/sdk/query-message-integration.js.map +1 -0
  151. package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js +615 -0
  152. package/.claude-flow-novice/dist/src/coordination/v2/sdk/session-pool-optimizer.js.map +1 -0
  153. package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js +259 -0
  154. package/.claude-flow-novice/dist/src/coordination/v2/security/payload-validator.js.map +1 -0
  155. package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js +17 -0
  156. package/.claude-flow-novice/dist/src/coordination/v2/transparency/index.js.map +1 -0
  157. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js +357 -0
  158. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-integration.js.map +1 -0
  159. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js +679 -0
  160. package/.claude-flow-novice/dist/src/coordination/v2/transparency/transparency-system.js.map +1 -0
  161. package/.claude-flow-novice/dist/src/core/agent-manager.js +30 -0
  162. package/.claude-flow-novice/dist/src/core/agent-manager.js.map +1 -1
  163. package/.claude-flow-novice/dist/src/mcp/server.js +21 -2
  164. package/.claude-flow-novice/dist/src/mcp/server.js.map +1 -1
  165. package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js +719 -0
  166. package/.claude-flow-novice/dist/src/monitoring/apm/apm-integration.js.map +1 -0
  167. package/.claude-flow-novice/dist/src/monitoring/apm/datadog-collector.js +363 -0
  168. package/.claude-flow-novice/dist/src/monitoring/apm/datadog-collector.js.map +1 -0
  169. package/.claude-flow-novice/dist/src/monitoring/apm/index.js +97 -0
  170. package/.claude-flow-novice/dist/src/monitoring/apm/index.js.map +1 -0
  171. package/.claude-flow-novice/dist/src/monitoring/apm/newrelic-collector.js +384 -0
  172. package/.claude-flow-novice/dist/src/monitoring/apm/newrelic-collector.js.map +1 -0
  173. package/.claude-flow-novice/dist/src/monitoring/apm/performance-optimizer.js +612 -0
  174. package/.claude-flow-novice/dist/src/monitoring/apm/performance-optimizer.js.map +1 -0
  175. package/.claude-flow-novice/dist/src/monitoring/metrics-collector.js +282 -0
  176. package/.claude-flow-novice/dist/src/monitoring/metrics-collector.js.map +1 -0
  177. package/.claude-flow-novice/dist/src/observability/metrics-counter.js +268 -0
  178. package/.claude-flow-novice/dist/src/observability/metrics-counter.js.map +1 -0
  179. package/.claude-flow-novice/dist/src/observability/metrics-storage.js +265 -0
  180. package/.claude-flow-novice/dist/src/observability/metrics-storage.js.map +1 -0
  181. package/.claude-flow-novice/dist/src/observability/telemetry.js +26 -0
  182. package/.claude-flow-novice/dist/src/observability/telemetry.js.map +1 -1
  183. package/.claude-flow-novice/dist/src/providers/tiered-router.js +64 -10
  184. package/.claude-flow-novice/dist/src/providers/tiered-router.js.map +1 -1
  185. package/.claude-flow-novice/dist/src/providers/zai-provider.js +196 -97
  186. package/.claude-flow-novice/dist/src/providers/zai-provider.js.map +1 -1
  187. package/.claude-flow-novice/dist/src/slash-commands/cfn-claude-sync.js +533 -0
  188. package/.claude-flow-novice/dist/src/slash-commands/index.js +5 -0
  189. package/.claude-flow-novice/dist/src/slash-commands/metrics-summary-class.js +74 -0
  190. package/.claude-flow-novice/dist/src/slash-commands/metrics-summary.js +335 -0
  191. package/.claude-flow-novice/dist/src/slash-commands/register-all-commands.js +12 -0
  192. package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js +96 -0
  193. package/.claude-flow-novice/dist/src/verification/checkpoint-compression-demo.js.map +1 -0
  194. package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js +406 -0
  195. package/.claude-flow-novice/dist/src/verification/checkpoint-compression.js.map +1 -0
  196. package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js +35 -5
  197. package/.claude-flow-novice/dist/src/verification/checkpoint-manager.js.map +1 -1
  198. package/.claude-flow-novice/dist/src/web/api/apm-routes.js +355 -0
  199. package/.claude-flow-novice/dist/src/web/api/apm-routes.js.map +1 -0
  200. package/.claude-flow-novice/dist/src/web/api/config/api-config.js +186 -0
  201. package/.claude-flow-novice/dist/src/web/api/config/api-config.js.map +1 -0
  202. package/.claude-flow-novice/dist/src/web/api/middleware/auth.js +205 -0
  203. package/.claude-flow-novice/dist/src/web/api/middleware/auth.js.map +1 -0
  204. package/.claude-flow-novice/dist/src/web/api/middleware/cache.js +262 -0
  205. package/.claude-flow-novice/dist/src/web/api/middleware/cache.js.map +1 -0
  206. package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js +250 -0
  207. package/.claude-flow-novice/dist/src/web/api/middleware/error-handler.js.map +1 -0
  208. package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js +217 -0
  209. package/.claude-flow-novice/dist/src/web/api/middleware/request-logger.js.map +1 -0
  210. package/.claude-flow-novice/dist/src/web/api/middleware/validation.js +325 -0
  211. package/.claude-flow-novice/dist/src/web/api/middleware/validation.js.map +1 -0
  212. package/.claude-flow-novice/dist/src/web/api/routes/events.js +465 -0
  213. package/.claude-flow-novice/dist/src/web/api/routes/events.js.map +1 -0
  214. package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js +302 -0
  215. package/.claude-flow-novice/dist/src/web/api/routes/hierarchy.js.map +1 -0
  216. package/.claude-flow-novice/dist/src/web/api/routes/index.js +14 -0
  217. package/.claude-flow-novice/dist/src/web/api/routes/index.js.map +1 -0
  218. package/.claude-flow-novice/dist/src/web/api/routes/metrics.js +561 -0
  219. package/.claude-flow-novice/dist/src/web/api/routes/metrics.js.map +1 -0
  220. package/.claude-flow-novice/dist/src/web/api/routes/status.js +450 -0
  221. package/.claude-flow-novice/dist/src/web/api/routes/status.js.map +1 -0
  222. package/.claude-flow-novice/dist/src/web/api/server.js +451 -0
  223. package/.claude-flow-novice/dist/src/web/api/server.js.map +1 -0
  224. package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js +385 -0
  225. package/.claude-flow-novice/dist/src/web/dashboard/hooks/useWebSocket.js.map +1 -0
  226. package/.claude-flow-novice/dist/src/web/dashboard/index.js +87 -0
  227. package/.claude-flow-novice/dist/src/web/dashboard/index.js.map +1 -0
  228. package/.claude-flow-novice/dist/src/web/dashboard/types.js +6 -0
  229. package/.claude-flow-novice/dist/src/web/dashboard/types.js.map +1 -0
  230. package/.claude-flow-novice/dist/src/web/frontend/src/utils/security.js +425 -0
  231. package/.claude-flow-novice/dist/src/web/frontend/src/utils/security.js.map +1 -0
  232. package/.claude-flow-novice/dist/src/web/security/security-middleware.js +379 -0
  233. package/.claude-flow-novice/dist/src/web/security/security-middleware.js.map +1 -0
  234. package/.claude-flow-novice/dist/src/web/websocket/apm-websocket-handler.js +441 -0
  235. package/.claude-flow-novice/dist/src/web/websocket/apm-websocket-handler.js.map +1 -0
  236. package/.claude-flow-novice/dist/src/web/websocket/websocket-manager.js +255 -1
  237. package/.claude-flow-novice/dist/src/web/websocket/websocket-manager.js.map +1 -1
  238. package/.claude-flow-novice/metrics.db +0 -0
  239. package/.claude-flow-novice/metrics.db-shm +0 -0
  240. package/.claude-flow-novice/metrics.db-wal +0 -0
  241. package/AGENT_PERFORMANCE_GUIDELINES.md +88 -0
  242. package/CLAUDE.md +60 -3
  243. package/MEMORY_LEAK_ROOT_CAUSE.md +149 -0
  244. package/README.md +27 -0
  245. package/config/hooks/post-edit-pipeline.js +36 -2
  246. package/examples/metrics-counter-demo.ts +106 -0
  247. package/examples/persistent-metrics-demo.ts +83 -0
  248. package/examples/phase-5-multi-level-control.ts +282 -0
  249. package/examples/session-pool-optimizer-example.ts +311 -0
  250. package/package.json +18 -4
  251. package/scripts/check-routing-stats.cjs +122 -0
  252. package/scripts/monitor-loop.sh +65 -0
  253. package/scripts/monitor-memory.sh +47 -0
  254. package/scripts/monitor.py +43 -0
  255. package/scripts/pre-publish-validation.cjs +212 -0
  256. package/scripts/test-provider-routing.cjs +228 -0
  257. package/scripts/test-routing-telemetry.cjs +147 -0
  258. package/scripts/test-zai-10k.cjs +81 -0
  259. package/scripts/test-zai-api.cjs +191 -0
  260. package/scripts/test-zai-diagnostic.cjs +151 -0
  261. package/scripts/test-zai-final.cjs +128 -0
  262. package/scripts/test-zai-with-env.cjs +85 -0
  263. package/scripts/validate-coordination-cli.js +69 -0
  264. package/scripts/validate-coordination-toggle-integration.cjs +501 -0
  265. package/src/cli/simple-commands/init/templates/CLAUDE.md +29 -0
  266. package/src/observability/metrics-counter.ts +347 -0
  267. package/src/observability/metrics-storage.ts +356 -0
  268. package/src/observability/telemetry.ts +658 -0
  269. package/src/slash-commands/cfn-claude-sync.js +533 -0
  270. package/src/slash-commands/index.js +5 -0
  271. package/src/slash-commands/metrics-summary-class.js +74 -0
  272. package/src/slash-commands/metrics-summary.js +335 -0
  273. package/src/slash-commands/register-all-commands.js +12 -0
@@ -0,0 +1,335 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Metrics Summary Slash Command
5
+ *
6
+ * Displays aggregated metrics statistics with configurable time frame.
7
+ *
8
+ * Usage:
9
+ * /metrics-summary [--minutes=60] [--provider=all] [--model=all]
10
+ */
11
+
12
+ import Database from 'better-sqlite3';
13
+ import { fileURLToPath } from 'url';
14
+ import { dirname, join } from 'path';
15
+ import { readFile, writeFile } from 'fs/promises';
16
+
17
+ const __filename = fileURLToPath(import.meta.url);
18
+ const __dirname = dirname(__filename);
19
+
20
+ // Parse command line arguments
21
+ function parseArgs(args) {
22
+ const options = {
23
+ minutes: 60, // Default: last hour
24
+ provider: 'all',
25
+ model: 'all',
26
+ action: null, // enable, disable, status
27
+ };
28
+
29
+ for (const arg of args) {
30
+ if (arg.startsWith('--minutes=')) {
31
+ options.minutes = parseInt(arg.split('=')[1], 10);
32
+ } else if (arg.startsWith('--provider=')) {
33
+ options.provider = arg.split('=')[1];
34
+ } else if (arg.startsWith('--model=')) {
35
+ options.model = arg.split('=')[1];
36
+ } else if (arg === '--enable' || arg === 'enable') {
37
+ options.action = 'enable';
38
+ } else if (arg === '--disable' || arg === 'disable') {
39
+ options.action = 'disable';
40
+ } else if (arg === '--status' || arg === 'status') {
41
+ options.action = 'status';
42
+ }
43
+ }
44
+
45
+ return options;
46
+ }
47
+
48
+ // Format large numbers
49
+ function formatNumber(num) {
50
+ return num.toLocaleString();
51
+ }
52
+
53
+ // Format duration
54
+ function formatDuration(ms) {
55
+ if (ms < 1000) return `${ms.toFixed(0)}ms`;
56
+ return `${(ms / 1000).toFixed(2)}s`;
57
+ }
58
+
59
+ // Calculate cost estimate
60
+ function estimateCost(inputTokens, outputTokens, model, provider) {
61
+ // Pricing per 1K tokens (USD)
62
+ const pricing = {
63
+ 'anthropic': {
64
+ 'claude-3-5-sonnet-20241022': { input: 0.003, output: 0.015 },
65
+ 'claude-3-sonnet-20240229': { input: 0.003, output: 0.015 },
66
+ },
67
+ 'z.ai': {
68
+ 'glm-4.5': { input: 0.003, output: 0.015 },
69
+ 'glm-4.6': { input: 0.003, output: 0.015 },
70
+ 'claude-3-5-sonnet-20241022': { input: 0.003, output: 0.015 },
71
+ },
72
+ };
73
+
74
+ const providerPricing = pricing[provider];
75
+ if (!providerPricing || !providerPricing[model]) {
76
+ return null;
77
+ }
78
+
79
+ const modelPricing = providerPricing[model];
80
+ const inputCost = (inputTokens / 1000) * modelPricing.input;
81
+ const outputCost = (outputTokens / 1000) * modelPricing.output;
82
+
83
+ return inputCost + outputCost;
84
+ }
85
+
86
+ // Generate metrics summary
87
+ function generateSummary(options) {
88
+ const dbPath = join(__dirname, '../../.claude-flow-novice/metrics.db');
89
+ const db = new Database(dbPath, { readonly: true });
90
+
91
+ // Calculate time threshold
92
+ const now = Date.now();
93
+ const timeThreshold = now - (options.minutes * 60 * 1000);
94
+
95
+ console.log(`\n📊 Metrics Summary (Last ${options.minutes} minutes)\n`);
96
+ console.log(`Time Range: ${new Date(timeThreshold).toLocaleString()} → ${new Date(now).toLocaleString()}\n`);
97
+ console.log('─'.repeat(80) + '\n');
98
+
99
+ // Query: API Requests by Provider
100
+ const requestQuery = `
101
+ SELECT
102
+ json_extract(tags, '$.provider') as provider,
103
+ COUNT(*) as count
104
+ FROM metrics
105
+ WHERE name = 'claude.api.request'
106
+ AND timestamp >= ?
107
+ ${options.provider !== 'all' ? `AND json_extract(tags, '$.provider') = '${options.provider}'` : ''}
108
+ ${options.model !== 'all' ? `AND json_extract(tags, '$.model') = '${options.model}'` : ''}
109
+ GROUP BY provider
110
+ ORDER BY count DESC
111
+ `;
112
+
113
+ const requests = db.prepare(requestQuery).all(timeThreshold);
114
+
115
+ if (requests.length > 0) {
116
+ console.log('🌐 API Requests by Provider:');
117
+ let totalRequests = 0;
118
+ requests.forEach(row => {
119
+ console.log(` ${row.provider || 'unknown'}: ${formatNumber(row.count)}`);
120
+ totalRequests += row.count;
121
+ });
122
+ console.log(` TOTAL: ${formatNumber(totalRequests)}\n`);
123
+ } else {
124
+ console.log('🌐 API Requests: No data in time range\n');
125
+ }
126
+
127
+ // Query: Token Usage by Provider and Model
128
+ const tokenQuery = `
129
+ SELECT
130
+ json_extract(tags, '$.provider') as provider,
131
+ json_extract(tags, '$.model') as model,
132
+ SUM(CASE WHEN name = 'claude.tokens.input' THEN value ELSE 0 END) as input_tokens,
133
+ SUM(CASE WHEN name = 'claude.tokens.output' THEN value ELSE 0 END) as output_tokens,
134
+ SUM(CASE WHEN name = 'claude.tokens.total' THEN value ELSE 0 END) as total_tokens
135
+ FROM metrics
136
+ WHERE name IN ('claude.tokens.input', 'claude.tokens.output', 'claude.tokens.total')
137
+ AND timestamp >= ?
138
+ ${options.provider !== 'all' ? `AND json_extract(tags, '$.provider') = '${options.provider}'` : ''}
139
+ ${options.model !== 'all' ? `AND json_extract(tags, '$.model') = '${options.model}'` : ''}
140
+ GROUP BY provider, model
141
+ ORDER BY total_tokens DESC
142
+ `;
143
+
144
+ const tokens = db.prepare(tokenQuery).all(timeThreshold);
145
+
146
+ if (tokens.length > 0) {
147
+ console.log('🎯 Token Usage by Provider & Model:');
148
+ let totalInput = 0;
149
+ let totalOutput = 0;
150
+ let totalCost = 0;
151
+
152
+ tokens.forEach(row => {
153
+ const inputTokens = row.input_tokens || 0;
154
+ const outputTokens = row.output_tokens || 0;
155
+ const totalTokens = row.total_tokens || 0;
156
+
157
+ totalInput += inputTokens;
158
+ totalOutput += outputTokens;
159
+
160
+ const cost = estimateCost(inputTokens, outputTokens, row.model, row.provider);
161
+ if (cost !== null) {
162
+ totalCost += cost;
163
+ }
164
+
165
+ console.log(` ${row.provider || 'unknown'} / ${row.model || 'unknown'}:`);
166
+ console.log(` Input: ${formatNumber(inputTokens)}`);
167
+ console.log(` Output: ${formatNumber(outputTokens)}`);
168
+ console.log(` Total: ${formatNumber(totalTokens)}`);
169
+ if (cost !== null) {
170
+ console.log(` Cost: $${cost.toFixed(4)}`);
171
+ }
172
+ });
173
+
174
+ console.log(` TOTAL:`);
175
+ console.log(` Input: ${formatNumber(totalInput)}`);
176
+ console.log(` Output: ${formatNumber(totalOutput)}`);
177
+ console.log(` Total: ${formatNumber(totalInput + totalOutput)}`);
178
+ if (totalCost > 0) {
179
+ console.log(` Cost: $${totalCost.toFixed(4)}`);
180
+ }
181
+ console.log();
182
+ } else {
183
+ console.log('🎯 Token Usage: No data in time range\n');
184
+ }
185
+
186
+ // Query: Error Rate
187
+ const errorQuery = `
188
+ SELECT
189
+ COUNT(*) as total_errors
190
+ FROM metrics
191
+ WHERE name = 'claude.api.error'
192
+ AND timestamp >= ?
193
+ ${options.provider !== 'all' ? `AND json_extract(tags, '$.provider') = '${options.provider}'` : ''}
194
+ ${options.model !== 'all' ? `AND json_extract(tags, '$.model') = '${options.model}'` : ''}
195
+ `;
196
+
197
+ const errors = db.prepare(errorQuery).get(timeThreshold);
198
+ const totalRequests = requests.reduce((sum, r) => sum + r.count, 0);
199
+
200
+ if (totalRequests > 0) {
201
+ const errorRate = ((errors.total_errors || 0) / totalRequests) * 100;
202
+ console.log('⚠️ Error Rate:');
203
+ console.log(` Errors: ${formatNumber(errors.total_errors || 0)} / ${formatNumber(totalRequests)}`);
204
+ console.log(` Rate: ${errorRate.toFixed(2)}%\n`);
205
+ } else {
206
+ console.log('⚠️ Error Rate: No requests in time range\n');
207
+ }
208
+
209
+ // Query: Average Duration by Provider
210
+ const durationQuery = `
211
+ SELECT
212
+ json_extract(tags, '$.provider') as provider,
213
+ json_extract(tags, '$.status') as status,
214
+ AVG(value) as avg_duration,
215
+ MIN(value) as min_duration,
216
+ MAX(value) as max_duration,
217
+ COUNT(*) as count
218
+ FROM metrics
219
+ WHERE name = 'claude.api.duration'
220
+ AND timestamp >= ?
221
+ ${options.provider !== 'all' ? `AND json_extract(tags, '$.provider') = '${options.provider}'` : ''}
222
+ ${options.model !== 'all' ? `AND json_extract(tags, '$.model') = '${options.model}'` : ''}
223
+ GROUP BY provider, status
224
+ ORDER BY provider, status
225
+ `;
226
+
227
+ const durations = db.prepare(durationQuery).all(timeThreshold);
228
+
229
+ if (durations.length > 0) {
230
+ console.log('⏱️ API Duration by Provider:');
231
+ durations.forEach(row => {
232
+ console.log(` ${row.provider || 'unknown'} (${row.status || 'unknown'}):`);
233
+ console.log(` Avg: ${formatDuration(row.avg_duration)}`);
234
+ console.log(` Min: ${formatDuration(row.min_duration)}`);
235
+ console.log(` Max: ${formatDuration(row.max_duration)}`);
236
+ console.log(` Count: ${formatNumber(row.count)}`);
237
+ });
238
+ console.log();
239
+ } else {
240
+ console.log('⏱️ API Duration: No data in time range\n');
241
+ }
242
+
243
+ // Query: Top Models
244
+ const modelQuery = `
245
+ SELECT
246
+ json_extract(tags, '$.model') as model,
247
+ COUNT(*) as count
248
+ FROM metrics
249
+ WHERE name = 'claude.api.request'
250
+ AND timestamp >= ?
251
+ ${options.provider !== 'all' ? `AND json_extract(tags, '$.provider') = '${options.provider}'` : ''}
252
+ ${options.model !== 'all' ? `AND json_extract(tags, '$.model') = '${options.model}'` : ''}
253
+ GROUP BY model
254
+ ORDER BY count DESC
255
+ LIMIT 5
256
+ `;
257
+
258
+ const topModels = db.prepare(modelQuery).all(timeThreshold);
259
+
260
+ if (topModels.length > 0) {
261
+ console.log('🏆 Top Models:');
262
+ topModels.forEach((row, idx) => {
263
+ console.log(` ${idx + 1}. ${row.model || 'unknown'}: ${formatNumber(row.count)} requests`);
264
+ });
265
+ console.log();
266
+ } else {
267
+ console.log('🏆 Top Models: No data in time range\n');
268
+ }
269
+
270
+ console.log('─'.repeat(80) + '\n');
271
+
272
+ db.close();
273
+ }
274
+
275
+ // Manage metrics tracking toggle
276
+ async function manageTracking(action) {
277
+ const configPath = join(__dirname, '../../.claude/settings.json');
278
+
279
+ try {
280
+ // Read current settings
281
+ const settingsContent = await readFile(configPath, 'utf8');
282
+ const settings = JSON.parse(settingsContent);
283
+
284
+ if (action === 'status') {
285
+ const enabled = settings.env?.CLAUDE_FLOW_TELEMETRY_ENABLED !== 'false';
286
+ console.log('\n📊 Metrics Tracking Status:\n');
287
+ console.log(`Status: ${enabled ? '✅ ENABLED' : '❌ DISABLED'}`);
288
+ console.log(`Setting: CLAUDE_FLOW_TELEMETRY_ENABLED=${settings.env?.CLAUDE_FLOW_TELEMETRY_ENABLED || 'true'}`);
289
+ console.log(`\nTo change: /metrics-summary --enable OR /metrics-summary --disable\n`);
290
+ return;
291
+ }
292
+
293
+ if (action === 'enable') {
294
+ settings.env = settings.env || {};
295
+ settings.env.CLAUDE_FLOW_TELEMETRY_ENABLED = 'true';
296
+ await writeFile(configPath, JSON.stringify(settings, null, 2));
297
+ console.log('\n✅ Metrics tracking ENABLED');
298
+ console.log('All API requests, tokens, and performance metrics will now be tracked.\n');
299
+ return;
300
+ }
301
+
302
+ if (action === 'disable') {
303
+ settings.env = settings.env || {};
304
+ settings.env.CLAUDE_FLOW_TELEMETRY_ENABLED = 'false';
305
+ await writeFile(configPath, JSON.stringify(settings, null, 2));
306
+ console.log('\n❌ Metrics tracking DISABLED');
307
+ console.log('No metrics will be collected until re-enabled.\n');
308
+ return;
309
+ }
310
+ } catch (error) {
311
+ console.error('❌ Error managing tracking settings:', error.message);
312
+ process.exit(1);
313
+ }
314
+ }
315
+
316
+ // Main execution
317
+ (async () => {
318
+ try {
319
+ const args = process.argv.slice(2);
320
+ const options = parseArgs(args);
321
+
322
+ // Handle tracking management actions
323
+ if (options.action) {
324
+ await manageTracking(options.action);
325
+ process.exit(0);
326
+ }
327
+
328
+ // Generate summary
329
+ generateSummary(options);
330
+ process.exit(0);
331
+ } catch (error) {
332
+ console.error('❌ Error:', error.message);
333
+ process.exit(1);
334
+ }
335
+ })();
@@ -18,10 +18,12 @@ import { CfnLoopCommand } from './cfn-loop.js';
18
18
  import { CfnLoopSingleCommand } from './cfn-loop-single.js';
19
19
  import { CfnLoopSprintsCommand } from './cfn-loop-sprints.js';
20
20
  import { CfnLoopEpicCommand } from './cfn-loop-epic.js';
21
+ import { CfnClaudeSyncCommand } from './cfn-claude-sync.js';
21
22
  import { executeClaudeSoulCommand } from './claude-soul.js';
22
23
  import { ParseEpicCommand } from './parse-epic.js';
23
24
  import { CustomRoutingActivateCommand } from './custom-routing-activate-class.js';
24
25
  import { CustomRoutingDeactivateCommand } from './custom-routing-deactivate-class.js';
26
+ import { MetricsSummaryCommand } from './metrics-summary-class.js';
25
27
 
26
28
  /**
27
29
  * Command Registry Class
@@ -54,6 +56,11 @@ export class SlashCommandRegistry {
54
56
  this.register(new CfnLoopEpicCommand());
55
57
  this.addAlias('cfn-loop-epic', 'cfn-epic');
56
58
 
59
+ // CFN Claude Sync - Sync CFN Loop rules from CLAUDE.md
60
+ this.register(new CfnClaudeSyncCommand());
61
+ this.addAlias('cfn-claude-sync', 'cfn-sync');
62
+ this.addAlias('cfn-claude-sync', 'sync');
63
+
57
64
  // Core SPARC methodology command
58
65
  this.register(new SparcCommand());
59
66
 
@@ -93,6 +100,11 @@ export class SlashCommandRegistry {
93
100
  this.register(new CustomRoutingActivateCommand());
94
101
  this.register(new CustomRoutingDeactivateCommand());
95
102
 
103
+ // Metrics summary command
104
+ this.register(new MetricsSummaryCommand());
105
+ this.addAlias('metrics-summary', 'metrics');
106
+ this.addAlias('metrics-summary', 'stats');
107
+
96
108
  // Legacy function-based commands
97
109
  this.registerLegacyCommand('claude-md', {
98
110
  description: 'Generate CLAUDE.md configuration file',