claude-flow-novice 2.9.1 → 2.10.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 (349) hide show
  1. package/.claude/agents/cfn-dev-team/CLAUDE.md +1086 -0
  2. package/.claude/agents/cfn-dev-team/README.md +116 -0
  3. package/.claude/agents/cfn-dev-team/architecture/api-designer-persona.md +149 -0
  4. package/.claude/agents/cfn-dev-team/architecture/base-template-generator.md +196 -0
  5. package/.claude/agents/cfn-dev-team/architecture/goal-planner.md +183 -0
  6. package/.claude/agents/cfn-dev-team/architecture/planner.md +182 -0
  7. package/.claude/agents/cfn-dev-team/architecture/system-architect.md +162 -0
  8. package/.claude/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +540 -0
  9. package/.claude/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +20 -14
  10. package/.claude/agents/cfn-dev-team/coordinators/consensus-builder.md +167 -0
  11. package/.claude/agents/cfn-dev-team/dev-ops/devops-engineer.md +148 -0
  12. package/.claude/agents/cfn-dev-team/dev-ops/github-commit-agent.md +118 -0
  13. package/.claude/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +540 -0
  14. package/.claude/agents/cfn-dev-team/developers/backend-dev.md +20 -0
  15. package/.claude/agents/cfn-dev-team/developers/data/data-engineer.md +585 -0
  16. package/.claude/agents/cfn-dev-team/developers/database/database-architect.md +276 -0
  17. package/.claude/agents/cfn-dev-team/developers/dev-backend-api.md +147 -0
  18. package/.claude/agents/cfn-dev-team/developers/frontend/mobile-dev.md +218 -0
  19. package/.claude/agents/cfn-dev-team/developers/{react-frontend-engineer.md → frontend/react-frontend-engineer.md} +53 -5
  20. package/.claude/agents/cfn-dev-team/developers/frontend/spec-mobile-react-native.md +199 -0
  21. package/.claude/agents/cfn-dev-team/developers/graphql-specialist.md +615 -0
  22. package/.claude/agents/cfn-dev-team/developers/rust-developer.md +174 -0
  23. package/.claude/agents/cfn-dev-team/documentation/README-VALIDATION.md +243 -0
  24. package/.claude/agents/cfn-dev-team/documentation/agent-type-guidelines.md +465 -0
  25. package/.claude/agents/cfn-dev-team/documentation/api-docs.md +103 -0
  26. package/.claude/agents/cfn-dev-team/documentation/docs-api-openapi.md +98 -0
  27. package/.claude/agents/cfn-dev-team/documentation/pseudocode.md +159 -0
  28. package/.claude/agents/cfn-dev-team/documentation/specification.md +157 -0
  29. package/.claude/agents/cfn-dev-team/product-owners/accessibility-advocate-persona.md +109 -0
  30. package/.claude/agents/cfn-dev-team/{coordinators → product-owners}/cto-agent.md +8 -6
  31. package/.claude/agents/cfn-dev-team/product-owners/power-user-persona.md +190 -0
  32. package/.claude/agents/cfn-dev-team/{coordinators → product-owners}/product-owner.md +85 -59
  33. package/.claude/agents/cfn-dev-team/reviewers/quality/analyze-code-quality.md +141 -0
  34. package/.claude/agents/cfn-dev-team/reviewers/quality/code-analyzer.md +200 -0
  35. package/.claude/agents/cfn-dev-team/reviewers/quality/cyclomatic-complexity-reducer.md +321 -0
  36. package/.claude/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +238 -0
  37. package/.claude/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +101 -0
  38. package/.claude/agents/cfn-dev-team/reviewers/quality/quality-metrics.md +375 -0
  39. package/.claude/agents/cfn-dev-team/reviewers/quality/security-specialist.md +193 -0
  40. package/.claude/agents/cfn-dev-team/reviewers/reviewer.md +39 -0
  41. package/.claude/agents/cfn-dev-team/testers/interaction-tester.md +31 -0
  42. package/.claude/agents/cfn-dev-team/testers/load-testing-specialist.md +469 -0
  43. package/.claude/agents/cfn-dev-team/testers/playwright-tester.md +24 -0
  44. package/.claude/agents/cfn-dev-team/testers/tester.md +20 -0
  45. package/.claude/agents/cfn-dev-team/utility/agent-builder.md +151 -0
  46. package/.claude/agents/cfn-dev-team/utility/analyst.md +178 -0
  47. package/.claude/agents/cfn-dev-team/utility/claude-code-expert.md +1043 -0
  48. package/.claude/agents/cfn-dev-team/utility/code-booster.md +139 -0
  49. package/.claude/agents/cfn-dev-team/utility/context-curator.md +99 -0
  50. package/.claude/agents/cfn-dev-team/{developers → utility}/researcher.md +6 -4
  51. package/.claude/commands/cfn/CFN_LOOP_FRONTEND.md +741 -0
  52. package/.claude/commands/cfn/CFN_LOOP_TASK_MODE.md +353 -0
  53. package/.claude/commands/cfn/cfn-loop-frontend.md +555 -0
  54. package/.claude/commands/cfn/cfn-loop.md +168 -7
  55. package/{CFN-CLAUDE.md → .claude/root-claude-distribute/CFN-CLAUDE.md} +23 -3
  56. package/.claude/skills/cfn-ace-system/SKILL.md +364 -0
  57. package/.claude/skills/cfn-ace-system/add-bullet.sh +145 -0
  58. package/.claude/skills/cfn-ace-system/analyze-anti-pattern-effectiveness.sh +56 -0
  59. package/.claude/skills/cfn-ace-system/classify-task.sh +18 -0
  60. package/.claude/skills/cfn-ace-system/export-ace-metrics.sh +48 -0
  61. package/.claude/skills/cfn-ace-system/extract-tags.sh +385 -0
  62. package/.claude/skills/cfn-ace-system/format-negative-context.sh +180 -0
  63. package/.claude/skills/cfn-ace-system/init-indexes.sql +160 -0
  64. package/.claude/skills/cfn-ace-system/invoke-context-curate.sh +192 -0
  65. package/.claude/skills/cfn-ace-system/invoke-context-inject.sh +361 -0
  66. package/.claude/skills/cfn-ace-system/invoke-context-query.sh +139 -0
  67. package/.claude/skills/cfn-ace-system/invoke-context-reflect.sh +343 -0
  68. package/.claude/skills/cfn-ace-system/invoke-context-stats.sh +227 -0
  69. package/.claude/skills/cfn-ace-system/log-merge.sh +67 -0
  70. package/.claude/skills/cfn-ace-system/monitor-injection-performance.sh +138 -0
  71. package/.claude/skills/cfn-ace-system/optimize-injection-pipeline.sh +169 -0
  72. package/.claude/skills/cfn-ace-system/query-anti-patterns.sh +276 -0
  73. package/.claude/skills/cfn-ace-system/query-contexts.sh +150 -0
  74. package/.claude/skills/cfn-ace-system/query-reflections.sh +35 -0
  75. package/.claude/skills/cfn-ace-system/schema/001-create-context-reflections.sql +237 -0
  76. package/.claude/skills/cfn-ace-system/schema/README.md +723 -0
  77. package/.claude/skills/cfn-ace-system/schema/SCHEMA_DESIGN_SUMMARY.md +564 -0
  78. package/.claude/skills/cfn-ace-system/schema/populate-test-data-simple.sh +62 -0
  79. package/.claude/skills/cfn-ace-system/schema/populate-test-data.sh +247 -0
  80. package/.claude/skills/cfn-ace-system/schema/run-migration.sh +231 -0
  81. package/.claude/skills/cfn-ace-system/schema/validate-schema.sql +280 -0
  82. package/.claude/skills/cfn-ace-system/score-relevance-adapter.sh +138 -0
  83. package/.claude/skills/cfn-ace-system/score-relevance.sh +253 -0
  84. package/.claude/skills/cfn-ace-system/sprint-7-lessons.json +46 -0
  85. package/.claude/skills/cfn-ace-system/store-reflection.sh +46 -0
  86. package/.claude/skills/cfn-ace-system/test-ace-skill.sh +312 -0
  87. package/.claude/skills/cfn-ace-system/track-ab-test.sh +42 -0
  88. package/.claude/skills/cfn-ace-system/update-reflection.sh +41 -0
  89. package/.claude/skills/cfn-agent-discovery/SKILL.md +40 -0
  90. package/.claude/skills/cfn-agent-discovery/agents-registry-clean.json +0 -0
  91. package/.claude/skills/cfn-agent-discovery/agents-registry-fixed.json +19 -0
  92. package/.claude/skills/cfn-agent-discovery/agents-registry.json +718 -0
  93. package/.claude/skills/cfn-agent-discovery/discover-agents.py +184 -0
  94. package/.claude/skills/cfn-agent-discovery/discover-agents.sh +87 -0
  95. package/.claude/skills/cfn-agent-discovery/invoke-registry.sh +11 -0
  96. package/.claude/skills/cfn-agent-discovery/temp_script.py +0 -0
  97. package/.claude/skills/cfn-agent-execution/execute-agent.sh +126 -0
  98. package/.claude/skills/cfn-agent-output-processing/SKILL.md +359 -0
  99. package/.claude/skills/cfn-agent-selector/SKILL.md +90 -0
  100. package/.claude/skills/cfn-agent-selector/select-agents.sh +112 -0
  101. package/.claude/skills/cfn-agent-spawning/SKILL.md +135 -0
  102. package/.claude/skills/cfn-agent-spawning/agent-selection-guide.md +814 -0
  103. package/.claude/skills/cfn-agent-spawning/check-dependencies.sh +30 -0
  104. package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +263 -0
  105. package/.claude/skills/cfn-agent-spawning/spawn-templates.sh +613 -0
  106. package/.claude/skills/cfn-analytics/description-refinement-guide.md +164 -0
  107. package/.claude/skills/cfn-analytics/log-skill-invocation.js +122 -0
  108. package/.claude/skills/cfn-analytics/run-production-criteria-tests.sh +126 -0
  109. package/.claude/skills/cfn-analytics/skill-analytics-dashboard.js +113 -0
  110. package/.claude/skills/cfn-analytics/skill-invocation-hook.sh +28 -0
  111. package/.claude/skills/cfn-analytics/skill-invocations.sql +58 -0
  112. package/.claude/skills/cfn-analytics/test-corpus.json +32 -0
  113. package/.claude/skills/cfn-analytics/test-data-generator.js +115 -0
  114. package/.claude/skills/cfn-analytics/test-manual-override-rate.js +285 -0
  115. package/.claude/skills/cfn-analytics/validate-skill-selection.js +188 -0
  116. package/.claude/skills/cfn-config-management/SKILL.md +34 -0
  117. package/.claude/skills/cfn-config-management/check-dependencies.sh +56 -0
  118. package/.claude/skills/cfn-config-management/config.json +32 -0
  119. package/.claude/skills/cfn-config-management/manage-config.sh +113 -0
  120. package/.claude/skills/cfn-event-bus/SKILL.md +412 -0
  121. package/.claude/skills/cfn-event-bus/config.json +111 -0
  122. package/.claude/skills/cfn-event-bus/eventbus-wrapper.cjs +69 -0
  123. package/.claude/skills/cfn-event-bus/invoke-event-publish.sh +147 -0
  124. package/.claude/skills/cfn-event-bus/invoke-event-subscribe.sh +171 -0
  125. package/.claude/skills/cfn-event-bus/invoke-lifecycle-track.sh +201 -0
  126. package/.claude/skills/cfn-event-bus/test-event-bus.sh +280 -0
  127. package/.claude/skills/cfn-fleet-manager/SKILL.md +412 -0
  128. package/.claude/skills/cfn-fleet-manager/config.json +60 -0
  129. package/.claude/skills/cfn-fleet-manager/invoke-fleet-allocate.sh +182 -0
  130. package/.claude/skills/cfn-fleet-manager/invoke-fleet-balance.sh +239 -0
  131. package/.claude/skills/cfn-fleet-manager/invoke-fleet-metrics.sh +193 -0
  132. package/.claude/skills/cfn-fleet-manager/invoke-fleet-register.sh +124 -0
  133. package/.claude/skills/cfn-fleet-manager/test-fleet-manager.sh +345 -0
  134. package/.claude/skills/cfn-hook-pipeline/SKILL.md +148 -0
  135. package/.claude/skills/cfn-hook-pipeline/auto-resolve.sh +66 -0
  136. package/.claude/skills/cfn-hook-pipeline/check-dependencies.sh +40 -0
  137. package/.claude/skills/cfn-hook-pipeline/feedback-resolver.sh +452 -0
  138. package/.claude/skills/cfn-hook-pipeline/post-edit-handler.sh +154 -0
  139. package/.claude/skills/cfn-hook-pipeline/security-scan.json +60 -0
  140. package/.claude/skills/cfn-hook-pipeline/security-scanner.sh +121 -0
  141. package/.claude/skills/cfn-hook-pipeline/test-root-warning-resolution.sh +148 -0
  142. package/.claude/skills/cfn-hybrid-routing/SKILL.md +46 -0
  143. package/.claude/skills/cfn-hybrid-routing/check-dependencies.sh +52 -0
  144. package/.claude/skills/cfn-hybrid-routing/config.json +26 -0
  145. package/.claude/skills/cfn-hybrid-routing/spawn-worker.sh +44 -0
  146. package/.claude/skills/cfn-loop-orchestration/SKILL.md +299 -0
  147. package/.claude/skills/cfn-loop-orchestration/helpers/auto-tune-timeouts.sh +228 -0
  148. package/.claude/skills/cfn-loop-orchestration/helpers/consensus.sh +84 -0
  149. package/.claude/skills/cfn-loop-orchestration/helpers/context-injection.sh +142 -0
  150. package/.claude/skills/cfn-loop-orchestration/helpers/context-lookup.sh +359 -0
  151. package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier.sh +71 -0
  152. package/.claude/skills/cfn-loop-orchestration/helpers/gate-check.sh +90 -0
  153. package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager.sh +87 -0
  154. package/.claude/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +271 -0
  155. package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator.sh +51 -0
  156. package/.claude/skills/cfn-loop-orchestration/inject-loop-context.sh +41 -0
  157. package/.claude/skills/cfn-loop-orchestration/monitor-execution.sh +156 -0
  158. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +884 -0
  159. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh.backup +840 -0
  160. package/.claude/skills/cfn-loop-orchestration/security_utils.sh +99 -0
  161. package/.claude/skills/cfn-loop-orchestration/test-cfn-orchestration.sh +281 -0
  162. package/.claude/skills/cfn-loop-orchestration/test-edge-cases.sh +188 -0
  163. package/.claude/skills/cfn-loop-validation/SKILL.md +353 -0
  164. package/.claude/skills/cfn-loop-validation/check-dependencies.sh +31 -0
  165. package/.claude/skills/cfn-loop-validation/config.json +161 -0
  166. package/.claude/skills/cfn-loop-validation/consensus-calculator.js +477 -0
  167. package/.claude/skills/cfn-loop-validation/evidence-chain.sql +163 -0
  168. package/.claude/skills/cfn-loop-validation/examples/README.md +453 -0
  169. package/.claude/skills/cfn-loop-validation/examples/coordinator-full-cfn-loop.sh +234 -0
  170. package/.claude/skills/cfn-loop-validation/examples/coordinator-loop2-consensus.sh +132 -0
  171. package/.claude/skills/cfn-loop-validation/examples/coordinator-loop3-gate.sh +115 -0
  172. package/.claude/skills/cfn-loop-validation/examples/coordinator-redis-integration.sh +186 -0
  173. package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +252 -0
  174. package/.claude/skills/cfn-loop-validation/validate-iteration.sh +134 -0
  175. package/.claude/skills/cfn-process-lifecycle/SKILL.md +39 -0
  176. package/.claude/skills/cfn-process-lifecycle/check-dependencies.sh +58 -0
  177. package/.claude/skills/cfn-process-lifecycle/config.json +39 -0
  178. package/.claude/skills/cfn-process-lifecycle/process-manager.sh +144 -0
  179. package/.claude/skills/cfn-product-owner-decision/SKILL.md +332 -0
  180. package/.claude/skills/cfn-product-owner-decision/execute-decision.sh +176 -0
  181. package/.claude/skills/cfn-product-owner-decision/parse-decision.sh +66 -0
  182. package/.claude/skills/cfn-product-owner-decision/validate-deliverables.sh +82 -0
  183. package/.claude/skills/cfn-redis-coordination/AGENT_LOGGING.md +280 -0
  184. package/.claude/skills/cfn-redis-coordination/BZPOPMIN_FIX_SUMMARY.md +209 -0
  185. package/.claude/skills/cfn-redis-coordination/HEARTBEAT.md +57 -0
  186. package/.claude/skills/cfn-redis-coordination/HEARTBEAT_MONITORING.md +267 -0
  187. package/.claude/skills/cfn-redis-coordination/LOGGING.md +260 -0
  188. package/.claude/skills/cfn-redis-coordination/SECURITY_REVIEW.md +25 -0
  189. package/.claude/skills/cfn-redis-coordination/SHUTDOWN_HANDLING.md +164 -0
  190. package/.claude/skills/cfn-redis-coordination/SKILL.md +720 -0
  191. package/.claude/skills/cfn-redis-coordination/agent-log.sh +124 -0
  192. package/.claude/skills/cfn-redis-coordination/agent-recovery.sh +75 -0
  193. package/.claude/skills/cfn-redis-coordination/analyze-task-complexity.sh +277 -0
  194. package/.claude/skills/cfn-redis-coordination/cancel-swarm.sh +221 -0
  195. package/.claude/skills/cfn-redis-coordination/cfn-loop-exec.sh +468 -0
  196. package/.claude/skills/cfn-redis-coordination/cfn-loop-relaunch.sh +29 -0
  197. package/.claude/skills/cfn-redis-coordination/check-dependencies.sh +32 -0
  198. package/.claude/skills/cfn-redis-coordination/collect-confidence-scores.sh +179 -0
  199. package/.claude/skills/cfn-redis-coordination/collect-results.sh +75 -0
  200. package/.claude/skills/cfn-redis-coordination/complete-swarm.sh +75 -0
  201. package/.claude/skills/cfn-redis-coordination/config.json +61 -0
  202. package/.claude/skills/cfn-redis-coordination/data/cfn-loop.db +0 -0
  203. package/.claude/skills/cfn-redis-coordination/demos/phase4-wake-queue-test-report.md +82 -0
  204. package/.claude/skills/cfn-redis-coordination/demos/test-bzpopmin-fix.sh +274 -0
  205. package/.claude/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +276 -0
  206. package/.claude/skills/cfn-redis-coordination/demos/test-dlq.sh +129 -0
  207. package/.claude/skills/cfn-redis-coordination/demos/test-iteration-feedback.sh +320 -0
  208. package/.claude/skills/cfn-redis-coordination/demos/test-orchestrator.sh +249 -0
  209. package/.claude/skills/cfn-redis-coordination/demos/test-priority-wake-phase4-unix.sh +148 -0
  210. package/.claude/skills/cfn-redis-coordination/demos/test-priority-wake-phase4.sh +163 -0
  211. package/.claude/skills/cfn-redis-coordination/demos/test-priority-wake.sh +138 -0
  212. package/.claude/skills/cfn-redis-coordination/demos/test-quick-fix.sh +81 -0
  213. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-absolute.sh +45 -0
  214. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-fallback.sh +68 -0
  215. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-percentage.sh +56 -0
  216. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-with-retry.sh +81 -0
  217. package/.claude/skills/cfn-redis-coordination/demos/test-quorum.sh +57 -0
  218. package/.claude/skills/cfn-redis-coordination/demos/test-shutdown-handling.sh +187 -0
  219. package/.claude/skills/cfn-redis-coordination/demos/test-shutdown.sh +160 -0
  220. package/.claude/skills/cfn-redis-coordination/demos/test-utils-unix.sh +97 -0
  221. package/.claude/skills/cfn-redis-coordination/demos/test-utils.sh +97 -0
  222. package/.claude/skills/cfn-redis-coordination/demos/test-waiting-mode.sh +59 -0
  223. package/.claude/skills/cfn-redis-coordination/examples/README.md +73 -0
  224. package/.claude/skills/cfn-redis-coordination/examples/grafana-dashboard.json +352 -0
  225. package/.claude/skills/cfn-redis-coordination/examples/hierarchical-pattern.sh +127 -0
  226. package/.claude/skills/cfn-redis-coordination/examples/mesh-pattern.sh +171 -0
  227. package/.claude/skills/cfn-redis-coordination/examples/timeout-handling.sh +227 -0
  228. package/.claude/skills/cfn-redis-coordination/examples/waiting-mode-pattern.sh +239 -0
  229. package/.claude/skills/cfn-redis-coordination/execute-product-owner-decision.sh +258 -0
  230. package/.claude/skills/cfn-redis-coordination/get-agent-timeout.sh +177 -0
  231. package/.claude/skills/cfn-redis-coordination/heartbeat-functions.sh +137 -0
  232. package/.claude/skills/cfn-redis-coordination/heartbeat-protocol.md +106 -0
  233. package/.claude/skills/cfn-redis-coordination/heartbeat.sh +126 -0
  234. package/.claude/skills/cfn-redis-coordination/init-swarm.sh +148 -0
  235. package/.claude/skills/cfn-redis-coordination/invoke-redis-pattern.sh +220 -0
  236. package/.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh +283 -0
  237. package/.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh.backup-p7 +423 -0
  238. package/.claude/skills/cfn-redis-coordination/list-active-swarms.sh +147 -0
  239. package/.claude/skills/cfn-redis-coordination/log-event.sh +109 -0
  240. package/.claude/skills/cfn-redis-coordination/metrics-export.sh +674 -0
  241. package/.claude/skills/cfn-redis-coordination/metrics-schema.json +66 -0
  242. package/.claude/skills/cfn-redis-coordination/metrics-storage.md +31 -0
  243. package/.claude/skills/cfn-redis-coordination/monitor-cfn-violations.sh +391 -0
  244. package/.claude/skills/cfn-redis-coordination/monitor-heartbeats.sh +101 -0
  245. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop-v3.sh +141 -0
  246. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh +31 -0
  247. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup +38 -0
  248. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup-1761167675 +1672 -0
  249. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup-p5 +1604 -0
  250. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup-phase1 +1550 -0
  251. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup-phase2 +1621 -0
  252. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup-phase3 +1621 -0
  253. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.bak +0 -0
  254. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.broken +1627 -0
  255. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.corrupted +80 -0
  256. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.deprecated +1864 -0
  257. package/.claude/skills/cfn-redis-coordination/priority-wake-mechanism.md +75 -0
  258. package/.claude/skills/cfn-redis-coordination/priority_wake.py +134 -0
  259. package/.claude/skills/cfn-redis-coordination/query-dlq.sh +162 -0
  260. package/.claude/skills/cfn-redis-coordination/query-logs.sh +103 -0
  261. package/.claude/skills/cfn-redis-coordination/redis-pattern.sh +619 -0
  262. package/.claude/skills/cfn-redis-coordination/retrieve-context.sh +58 -0
  263. package/.claude/skills/cfn-redis-coordination/select-specialist-agent.sh +371 -0
  264. package/.claude/skills/cfn-redis-coordination/semantic-match-tfidf.py +252 -0
  265. package/.claude/skills/cfn-redis-coordination/send-heartbeat.sh +165 -0
  266. package/.claude/skills/cfn-redis-coordination/signal.sh +38 -0
  267. package/.claude/skills/cfn-redis-coordination/store-context.sh +86 -0
  268. package/.claude/skills/cfn-redis-coordination/store-epic-context.sh +123 -0
  269. package/.claude/skills/cfn-redis-coordination/test-context-injection.sh +354 -0
  270. package/.claude/skills/cfn-redis-coordination/test-timeout-enforcement.sh +513 -0
  271. package/.claude/skills/cfn-redis-coordination/tests/convert-line-endings.sh +15 -0
  272. package/.claude/skills/cfn-redis-coordination/tests/dlq-functionality-test.sh +102 -0
  273. package/.claude/skills/cfn-redis-coordination/tests/edge-cases-test.sh +99 -0
  274. package/.claude/skills/cfn-redis-coordination/tests/integration-test.sh +170 -0
  275. package/.claude/skills/cfn-redis-coordination/tests/retry-mechanism-test.sh +82 -0
  276. package/.claude/skills/cfn-redis-coordination/tests/run-test-suite.sh +92 -0
  277. package/.claude/skills/cfn-redis-coordination/tests/run-tests.sh +4 -0
  278. package/.claude/skills/cfn-redis-coordination/tests/test-heartbeat-monitoring.sh +418 -0
  279. package/.claude/skills/cfn-redis-coordination/tests/test-heartbeat-simple.sh +124 -0
  280. package/.claude/skills/cfn-redis-coordination/tests/test-primitives.sh +166 -0
  281. package/.claude/skills/cfn-redis-coordination/tests/test-utils.sh +54 -0
  282. package/.claude/skills/cfn-redis-coordination/tests/test_coordination_primitives.sh.deprecated +20 -0
  283. package/.claude/skills/cfn-redis-coordination/tests/test_utils.sh +49 -0
  284. package/.claude/skills/cfn-redis-coordination/v2_modularization/core_orchestration.sh +76 -0
  285. package/.claude/skills/cfn-redis-coordination/validate-parameters.sh +492 -0
  286. package/.claude/skills/cfn-sqlite-memory/IMPLEMENTATION_REPORT.md +393 -0
  287. package/.claude/skills/cfn-sqlite-memory/QUICK_REFERENCE.md +204 -0
  288. package/.claude/skills/cfn-sqlite-memory/SKILL.md +415 -0
  289. package/.claude/skills/cfn-sqlite-memory/acl-queries.sql +452 -0
  290. package/.claude/skills/cfn-sqlite-memory/check-dependencies.sh +36 -0
  291. package/.claude/skills/cfn-sqlite-memory/config.json +45 -0
  292. package/.claude/skills/cfn-sqlite-memory/memory-cli.sh +88 -0
  293. package/.claude/skills/cfn-sqlite-memory/test-state-persistence.js +187 -0
  294. package/.claude/skills/cfn-sqlite-memory/ttl-cleanup.sh +274 -0
  295. package/.claude/skills/cfn-test-execution/SKILL.md +128 -0
  296. package/.claude/skills/cfn-test-execution/check-dependencies.sh +36 -0
  297. package/.claude/skills/cfn-test-execution/test-cache-reader.sh +134 -0
  298. package/.claude/skills/cfn-test-execution/test-concurrent-conflicts.sh +115 -0
  299. package/.claude/skills/cfn-test-execution/test-coordinator-pattern.sh +109 -0
  300. package/.claude/skills/cfn-transparency-middleware/Cargo.toml +18 -0
  301. package/.claude/skills/cfn-transparency-middleware/SECURITY.md +41 -0
  302. package/.claude/skills/cfn-transparency-middleware/SKILL.md +91 -0
  303. package/.claude/skills/cfn-transparency-middleware/TEST_RESULTS.md +174 -0
  304. package/.claude/skills/cfn-transparency-middleware/config.json +31 -0
  305. package/.claude/skills/cfn-transparency-middleware/examples/basic-usage.ts +39 -0
  306. package/.claude/skills/cfn-transparency-middleware/examples/batch-processing.ts +52 -0
  307. package/.claude/skills/cfn-transparency-middleware/examples/custom-filtering.ts +61 -0
  308. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-filter.sh +98 -0
  309. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-init.sh +224 -0
  310. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-level.sh +333 -0
  311. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-metrics.sh +345 -0
  312. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-observe.sh +140 -0
  313. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-stop.sh +235 -0
  314. package/.claude/skills/cfn-transparency-middleware/memory_query.rs +85 -0
  315. package/.claude/skills/cfn-transparency-middleware/memory_repository.rs +140 -0
  316. package/.claude/skills/cfn-transparency-middleware/memory_schema.rs +64 -0
  317. package/.claude/skills/cfn-transparency-middleware/middleware-config.sh +29 -0
  318. package/.claude/skills/cfn-transparency-middleware/performance-benchmark.sh +79 -0
  319. package/.claude/skills/cfn-transparency-middleware/test-e2e.sh +406 -0
  320. package/.claude/skills/cfn-transparency-middleware/test-integration.sh +162 -0
  321. package/.claude/skills/cfn-transparency-middleware/test-transparency-skill.sh +368 -0
  322. package/.claude/skills/cfn-transparency-middleware/test-transparency-skill.sh.unix +126 -0
  323. package/.claude/skills/cfn-transparency-middleware/tests/input-validation.sh +93 -0
  324. package/.claude/skills/cfn-transparency-middleware/wrap-agent.sh +132 -0
  325. package/.claude/skills/cfn-webapp-testing/SCREENSHOT_NAMING_CONVENTION.md +547 -0
  326. package/.claude/skills/cfn-webapp-testing/SKILL.md +877 -0
  327. package/.claude/skills/cfn-webapp-testing/capture-screenshot.sh +238 -0
  328. package/.claude/skills/cfn-webapp-testing/cfn-loop-integration.sh +265 -0
  329. package/.claude/skills/cfn-webapp-testing/compare-screenshots.sh +199 -0
  330. package/.claude/skills/cfn-webapp-testing/init-storage.sh +150 -0
  331. package/.claude/skills/cfn-webapp-testing/set-baseline.sh +196 -0
  332. package/.claude/skills/cfn-webapp-testing/test-webapp-testing.sh +233 -0
  333. package/README.md +51 -2
  334. package/dist/ace/ace-reflector.js +109 -10
  335. package/dist/ace/ace-reflector.js.map +1 -1
  336. package/dist/cli/agent-executor.js +1 -1
  337. package/dist/cli/agent-executor.js.map +1 -1
  338. package/package.json +43 -7
  339. package/readme/README.md +15 -4
  340. package/scripts/init-project.js +76 -6
  341. package/scripts/run-marketing-tests.sh +43 -0
  342. package/scripts/update_paths.sh +47 -0
  343. package/tools/install-lizard.sh +37 -0
  344. package/tools/simple-complexity.sh +44 -0
  345. package/.claude/agents/cfn-dev-team/developers/coder.md +0 -270
  346. package/.claude/agents/cfn-dev-team/developers/state-architect.md +0 -127
  347. package/.claude/agents/cfn-dev-team/reviewers/code-quality-validator.md +0 -128
  348. /package/.claude/agents/cfn-dev-team/developers/{ui-designer.md → frontend/ui-designer.md} +0 -0
  349. /package/.claude/agents/cfn-dev-team/{coordinators → product-owners}/product-owner-agent.md +0 -0
@@ -0,0 +1,138 @@
1
+ #!/bin/bash
2
+ # ACE System: Context Injection Performance Monitoring
3
+ # Phase 3.3 Performance Tracking
4
+
5
+ set -euo pipefail
6
+
7
+ # Logging setup
8
+ TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
9
+ LOG_DIR="/tmp/ace-performance-logs"
10
+ PERFORMANCE_LOG="${LOG_DIR}/injection-performance-${TIMESTAMP}.log"
11
+ METRICS_FILE="${LOG_DIR}/injection-metrics-${TIMESTAMP}.json"
12
+
13
+ mkdir -p "${LOG_DIR}"
14
+
15
+ # Redis connection parameters (use environment variables or defaults)
16
+ REDIS_HOST="${REDIS_HOST:-localhost}"
17
+ REDIS_PORT="${REDIS_PORT:-6379}"
18
+ REDIS_DB="${REDIS_DB:-0}"
19
+
20
+ # Performance tracking functions
21
+ log_message() {
22
+ echo "[$(date +'%Y-%m-%d %H:%M:%S')] $*" | tee -a "${PERFORMANCE_LOG}"
23
+ }
24
+
25
+ calculate_percentile() {
26
+ local percentiles=("$@")
27
+ local temp_file=$(mktemp)
28
+
29
+ # Sort and calculate percentiles
30
+ for p in "${percentiles[@]}"; do
31
+ local percentile_value=$(sort -n "${temp_file}" | awk -v p="${p}" 'BEGIN{c=0} NR>=int(NR*p/100+1){print $1; exit}')
32
+ echo "P${p}: ${percentile_value}"
33
+ done
34
+
35
+ rm "${temp_file}"
36
+ }
37
+
38
+ # Injection Performance Monitoring
39
+ monitor_injection_performance() {
40
+ local domain_metrics_key="cfn_ace:injection:domain_metrics"
41
+ local latency_key="cfn_ace:injection:latency"
42
+
43
+ # Collect domain-specific metrics
44
+ local domain_hits=$(redis-cli -h "${REDIS_HOST}" -p "${REDIS_PORT}" -n "${REDIS_DB}" \
45
+ HGETALL "${domain_metrics_key}")
46
+
47
+ # Collect latency measurements
48
+ local latency_measurements=$(redis-cli -h "${REDIS_HOST}" -p "${REDIS_PORT}" -n "${REDIS_DB}" \
49
+ LRANGE "${latency_key}" 0 -1)
50
+
51
+ # Performance Analysis
52
+ log_message "Collecting Injection Performance Metrics..."
53
+
54
+ # Domain Hit Rates
55
+ log_message "Domain Hit Rates:"
56
+ echo "${domain_hits}" | while read -r domain hits; do
57
+ log_message " ${domain}: ${hits} hits"
58
+ done
59
+
60
+ # Latency Analysis
61
+ log_message "Latency Analysis:"
62
+ local percentiles=(50 95 99)
63
+ local p_results=$(calculate_percentile "${percentiles[@]}" <<< "${latency_measurements}")
64
+ log_message "${p_results}"
65
+
66
+ # Identify Slow Queries
67
+ local threshold_ms=500 # 500ms threshold for slow queries
68
+ local slow_queries=$(echo "${latency_measurements}" | awk -v threshold="${threshold_ms}" '$1 > threshold')
69
+
70
+ if [ -n "${slow_queries}" ]; then
71
+ log_message "Slow Queries Detected (>${threshold_ms}ms):"
72
+ log_message "${slow_queries}"
73
+ fi
74
+
75
+ # Generate Performance Report
76
+ generate_performance_report
77
+ }
78
+
79
+ generate_performance_report() {
80
+ local report_file="${LOG_DIR}/injection-performance-report-${TIMESTAMP}.json"
81
+
82
+ jq -n \
83
+ --arg timestamp "${TIMESTAMP}" \
84
+ --arg log_file "${PERFORMANCE_LOG}" \
85
+ --argjson percentiles_50 50 \
86
+ --argjson percentiles_95 95 \
87
+ --argjson percentiles_99 99 \
88
+ '{
89
+ "timestamp": $timestamp,
90
+ "log_file": $log_file,
91
+ "performance_metrics": {
92
+ "p50_latency_ms": $percentiles_50,
93
+ "p95_latency_ms": $percentiles_95,
94
+ "p99_latency_ms": $percentiles_99
95
+ },
96
+ "recommendations": [
97
+ "Investigate SQLite query optimization",
98
+ "Consider additional Redis caching",
99
+ "Review domain classifier performance"
100
+ ]
101
+ }' > "${report_file}"
102
+
103
+ log_message "Performance Report Generated: ${report_file}"
104
+ }
105
+
106
+ # Main Execution
107
+ main() {
108
+ log_message "Starting ACE System Injection Performance Monitoring"
109
+
110
+ # Pre-flight checks
111
+ command -v redis-cli >/dev/null 2>&1 || {
112
+ log_message "Error: redis-cli not found. Please install Redis.";
113
+ exit 1;
114
+ }
115
+
116
+ command -v jq >/dev/null 2>&1 || {
117
+ log_message "Error: jq not found. Please install jq.";
118
+ exit 1;
119
+ }
120
+
121
+ monitor_injection_performance
122
+
123
+ log_message "Injection Performance Monitoring Complete"
124
+ }
125
+
126
+ # Run main and capture exit status
127
+ main "$@"
128
+ exit_status=$?
129
+
130
+ # Optional: Send metrics to centralized monitoring
131
+ # This could be expanded to push to Prometheus, DataDog, etc.
132
+ if [ ${exit_status} -eq 0 ]; then
133
+ log_message "Performance monitoring successful"
134
+ else
135
+ log_message "Performance monitoring encountered issues"
136
+ fi
137
+
138
+ exit ${exit_status}
@@ -0,0 +1,169 @@
1
+ #!/bin/bash
2
+ # ACE System: Context Injection Pipeline Optimization
3
+ # Phase 3.3 Performance Enhancement
4
+
5
+ set -euo pipefail
6
+
7
+ # Logging and Configuration
8
+ TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
9
+ LOG_DIR="/tmp/ace-optimization-logs"
10
+ OPTIMIZATION_LOG="${LOG_DIR}/injection-optimization-${TIMESTAMP}.log"
11
+ BENCHMARK_RESULTS="${LOG_DIR}/benchmark-${TIMESTAMP}.json"
12
+
13
+ mkdir -p "${LOG_DIR}"
14
+
15
+ # Configuration Parameters
16
+ REDIS_TTL=3600 # 1 hour cache TTL
17
+ CACHE_WARMUP_DOMAINS=("software_engineering" "devops" "machine_learning" "data_science")
18
+ SQLITE_CACHE_SIZE=2000 # Prepare statements cache size
19
+
20
+ log_message() {
21
+ echo "[$(date +'%Y-%m-%d %H:%M:%S')] $*" | tee -a "${OPTIMIZATION_LOG}"
22
+ }
23
+
24
+ # Redis Caching Strategy
25
+ configure_redis_cache() {
26
+ local redis_host="${REDIS_HOST:-localhost}"
27
+ local redis_port="${REDIS_PORT:-6379}"
28
+
29
+ log_message "Configuring Redis Caching Strategy"
30
+
31
+ # Set global cache configuration
32
+ redis-cli -h "${redis_host}" -p "${redis_port}" \
33
+ CONFIG SET maxmemory-policy allkeys-lru
34
+ redis-cli -h "${redis_host}" -p "${redis_port}" \
35
+ CONFIG SET maxmemory 1GB
36
+
37
+ # Warm up cache for common domains
38
+ for domain in "${CACHE_WARMUP_DOMAINS[@]}"; do
39
+ log_message "Warming up cache for domain: ${domain}"
40
+ redis-cli -h "${redis_host}" -p "${redis_port}" \
41
+ SETEX "cfn_ace:domain_cache:${domain}" "${REDIS_TTL}" "$(generate_domain_cache_entry "${domain}")"
42
+ done
43
+ }
44
+
45
+ generate_domain_cache_entry() {
46
+ local domain="$1"
47
+ # Simulate generating a comprehensive domain context entry
48
+ jq -n \
49
+ --arg domain "${domain}" \
50
+ '{
51
+ "domain": $domain,
52
+ "anti_patterns": ["over_engineering", "premature_optimization"],
53
+ "best_practices": ["modular_design", "clear_interfaces"],
54
+ "timestamp": now
55
+ }'
56
+ }
57
+
58
+ # SQLite Optimization
59
+ optimize_sqlite_queries() {
60
+ local sqlite_db="/path/to/ace_system.sqlite"
61
+
62
+ log_message "Optimizing SQLite Query Performance"
63
+
64
+ # Prepare common anti-pattern queries
65
+ sqlite3 "${sqlite_db}" << EOF
66
+ -- Pragma configurations for performance
67
+ PRAGMA journal_mode=WAL;
68
+ PRAGMA cache_size=-${SQLITE_CACHE_SIZE};
69
+ PRAGMA mmap_size=30000000;
70
+
71
+ -- Prepared statements for common queries
72
+ PREPARE anti_pattern_query AS
73
+ SELECT * FROM anti_patterns
74
+ WHERE domain = ? AND confidence_threshold > ?;
75
+ EOF
76
+
77
+ log_message "SQLite optimization complete"
78
+ }
79
+
80
+ # Benchmark Performance Improvements
81
+ benchmark_performance() {
82
+ local iterations=50
83
+ local total_time_before=0
84
+ local total_time_after=0
85
+
86
+ log_message "Running Performance Benchmarks"
87
+
88
+ # Benchmark Before Optimization
89
+ for ((i=1; i<=iterations; i++)); do
90
+ local start_time=$(date +%s.%N)
91
+ run_sample_context_injection "before"
92
+ local end_time=$(date +%s.%N)
93
+ total_time_before=$(echo "${total_time_before} + (${end_time} - ${start_time})" | bc)
94
+ done
95
+
96
+ # Apply Optimizations
97
+ configure_redis_cache
98
+ optimize_sqlite_queries
99
+
100
+ # Benchmark After Optimization
101
+ for ((i=1; i<=iterations; i++)); do
102
+ local start_time=$(date +%s.%N)
103
+ run_sample_context_injection "after"
104
+ local end_time=$(date +%s.%N)
105
+ total_time_after=$(echo "${total_time_after} + (${end_time} - ${start_time})" | bc)
106
+ done
107
+
108
+ # Calculate Performance Improvement
109
+ local avg_before=$(echo "scale=4; ${total_time_before} / ${iterations}" | bc)
110
+ local avg_after=$(echo "scale=4; ${total_time_after} / ${iterations}" | bc)
111
+ local improvement_percentage=$(echo "scale=2; (1 - ${avg_after} / ${avg_before}) * 100" | bc)
112
+
113
+ # Generate Benchmark Report
114
+ jq -n \
115
+ --arg timestamp "${TIMESTAMP}" \
116
+ --arg avg_before "${avg_before}" \
117
+ --arg avg_after "${avg_after}" \
118
+ --arg improvement "${improvement_percentage}" \
119
+ '{
120
+ "timestamp": $timestamp,
121
+ "before_optimization_avg_ms": $avg_before,
122
+ "after_optimization_avg_ms": $avg_after,
123
+ "improvement_percentage": $improvement
124
+ }' > "${BENCHMARK_RESULTS}"
125
+
126
+ log_message "Performance Improvement: ${improvement_percentage}%"
127
+ }
128
+
129
+ # Simulate Context Injection for Benchmarking
130
+ run_sample_context_injection() {
131
+ local phase="$1"
132
+ # Simulate context injection process
133
+ local domain="software_engineering"
134
+
135
+ if [ "${phase}" == "before" ]; then
136
+ # Simulate non-optimized path
137
+ redis-cli HGET "cfn_ace:domain_metrics" "${domain}"
138
+ else
139
+ # Simulate optimized path with Redis cache
140
+ redis-cli HGETALL "cfn_ace:domain_cache:${domain}"
141
+ fi
142
+ }
143
+
144
+ # Main Execution
145
+ main() {
146
+ log_message "Starting ACE System Context Injection Optimization"
147
+
148
+ # Pre-flight checks
149
+ command -v redis-cli >/dev/null 2>&1 || {
150
+ log_message "Error: redis-cli not found. Please install Redis.";
151
+ exit 1;
152
+ }
153
+
154
+ command -v sqlite3 >/dev/null 2>&1 || {
155
+ log_message "Error: sqlite3 not found. Please install SQLite.";
156
+ exit 1;
157
+ }
158
+
159
+ benchmark_performance
160
+
161
+ log_message "Context Injection Optimization Complete"
162
+ }
163
+
164
+ # Execute main function
165
+ main "$@"
166
+ exit_status=$?
167
+
168
+ # Exit with benchmark status
169
+ exit ${exit_status}
@@ -0,0 +1,276 @@
1
+ #!/bin/bash
2
+
3
+ # ACE System Anti-Pattern Query System
4
+ # Purpose: Query relevant anti-patterns based on task classification to prevent repeating mistakes
5
+ # Usage: query-anti-patterns.sh "task description" [--limit N] [--format json|simple]
6
+
7
+ set -euo pipefail
8
+
9
+ TASK_DESCRIPTION=""
10
+ LIMIT=3
11
+ MIN_CONFIDENCE=0.0
12
+ OUTPUT_FORMAT="json"
13
+
14
+ # Parse arguments
15
+ while [[ $# -gt 0 ]]; do
16
+ case $1 in
17
+ --limit)
18
+ LIMIT="$2"
19
+ shift 2
20
+ ;;
21
+ --min-confidence)
22
+ MIN_CONFIDENCE="$2"
23
+ shift 2
24
+ ;;
25
+ --format)
26
+ OUTPUT_FORMAT="$2"
27
+ shift 2
28
+ ;;
29
+ *)
30
+ if [ -z "$TASK_DESCRIPTION" ]; then
31
+ TASK_DESCRIPTION="$1"
32
+ fi
33
+ shift
34
+ ;;
35
+ esac
36
+ done
37
+
38
+ if [ -z "$TASK_DESCRIPTION" ]; then
39
+ echo "Usage: query-anti-patterns.sh 'task description' [--limit N] [--format json|simple]" >&2
40
+ exit 1
41
+ fi
42
+
43
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
44
+ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
45
+ DB_PATH="${PROJECT_ROOT}/ace-context.db"
46
+ CLASSIFIER_PATH="${SCRIPT_DIR}/../cfn-task-classifier/classify-task.sh"
47
+
48
+ # Verify dependencies
49
+ if [ ! -f "$CLASSIFIER_PATH" ]; then
50
+ echo "ERROR: Task classifier not found at $CLASSIFIER_PATH" >&2
51
+ exit 1
52
+ fi
53
+
54
+ if [ ! -f "$DB_PATH" ]; then
55
+ echo "ERROR: ACE database not found at $DB_PATH" >&2
56
+ exit 1
57
+ fi
58
+
59
+ # Step 1: Classify task to extract domains
60
+ CLASSIFICATION=$("$CLASSIFIER_PATH" "$TASK_DESCRIPTION" --format=json)
61
+ if [ $? -ne 0 ]; then
62
+ echo "ERROR: Task classification failed" >&2
63
+ exit 1
64
+ fi
65
+
66
+ DOMAINS=$(echo "$CLASSIFICATION" | jq -r '.domains[]' 2>/dev/null || echo "")
67
+ COMPLEXITY=$(echo "$CLASSIFICATION" | jq -r '.complexity' 2>/dev/null || echo "medium")
68
+ TASK_TYPE=$(echo "$CLASSIFICATION" | jq -r '.task_type' 2>/dev/null || echo "general")
69
+
70
+ # Handle empty domains
71
+ if [ -z "$DOMAINS" ]; then
72
+ DOMAINS="general"
73
+ fi
74
+
75
+ # Step 2: Query anti-patterns by domain with severity sorting
76
+ TEMP_RESULTS="/tmp/ace-antipattern-results-$$.json"
77
+ echo "[]" > "$TEMP_RESULTS"
78
+
79
+ for DOMAIN in $DOMAINS; do
80
+ # Query anti-patterns for this domain
81
+ QUERY_RESULT=$(sqlite3 "$DB_PATH" -json << EOF
82
+ SELECT
83
+ id,
84
+ reflection_type,
85
+ json_extract(extracted_lessons, '\$.anti_pattern') as anti_pattern,
86
+ json_extract(extracted_lessons, '\$.solution') as solution,
87
+ json_extract(extracted_lessons, '\$.impact') as impact,
88
+ json_extract(metadata, '\$.severity') as severity,
89
+ json_extract(metadata, '\$.domain') as domain,
90
+ json_extract(metadata, '\$.sprint_ref') as sprint_ref,
91
+ json_extract(metadata, '\$.keywords') as keywords,
92
+ json_extract(execution_trace, '\$.iterations') as iterations_caused,
93
+ confidence,
94
+ created_at,
95
+ success_count,
96
+ total_count
97
+ FROM context_reflections
98
+ WHERE reflection_type IN ('anti-pattern', 'warning', 'failure')
99
+ AND (
100
+ json_extract(metadata, '\$.domain') = '$DOMAIN'
101
+ OR json_extract(metadata, '\$.domain') = 'general'
102
+ )
103
+ AND confidence >= $MIN_CONFIDENCE
104
+ AND curator_status IN ('curated', 'pending')
105
+ ORDER BY
106
+ CASE json_extract(metadata, '\$.severity')
107
+ WHEN 'critical' THEN 1
108
+ WHEN 'high' THEN 2
109
+ WHEN 'medium' THEN 3
110
+ ELSE 4
111
+ END,
112
+ confidence DESC,
113
+ created_at DESC;
114
+ EOF
115
+ )
116
+
117
+ # Merge results
118
+ if [ -n "$QUERY_RESULT" ] && [ "$QUERY_RESULT" != "[]" ]; then
119
+ MERGED=$(jq -s '.[0] + .[1]' "$TEMP_RESULTS" <(echo "$QUERY_RESULT"))
120
+ echo "$MERGED" > "$TEMP_RESULTS"
121
+ fi
122
+ done
123
+
124
+ # Step 3: Deduplication - remove similar anti-patterns
125
+ # Strategy: Group by first 60 characters of anti_pattern, keep highest confidence
126
+ DEDUPED_RESULTS=$(jq '
127
+ group_by(.anti_pattern[:60]) |
128
+ map(
129
+ sort_by(-.confidence) |
130
+ .[0]
131
+ )
132
+ ' "$TEMP_RESULTS")
133
+
134
+ echo "$DEDUPED_RESULTS" > "$TEMP_RESULTS"
135
+
136
+ # Step 4: Calculate relevance scores
137
+ # Scoring factors:
138
+ # - Severity weight: 50% (critical=1.0, high=0.8, medium=0.5, low=0.3)
139
+ # - Domain match: 30% (exact=1.0, general=0.5)
140
+ # - Recency: 10% (exponential decay, half-life=90 days)
141
+ # - Frequency: 10% (based on usage ratio: success_count/total_count)
142
+
143
+ SCORED_RESULTS=$(jq --arg current_date "$(date -u +%Y-%m-%dT%H:%M:%SZ)" '
144
+ map(
145
+ . as $item |
146
+
147
+ # Calculate severity score
148
+ (
149
+ if .severity == "critical" then 1.0
150
+ elif .severity == "high" then 0.8
151
+ elif .severity == "medium" then 0.5
152
+ elif .severity == "low" then 0.3
153
+ else 0.4
154
+ end
155
+ ) as $severity_score |
156
+
157
+ # Calculate domain match score
158
+ (
159
+ if (.domain | type == "array") then
160
+ if (.domain | any(. == $item.domain)) then 1.0 else 0.5 end
161
+ else
162
+ if .domain == $item.domain then 1.0 else 0.5 end
163
+ end
164
+ ) as $domain_score |
165
+
166
+ # Calculate recency score (exponential decay)
167
+ # Handle both Unix timestamps and SQLite datetime strings
168
+ (
169
+ if (.created_at | type == "number") then
170
+ .created_at
171
+ elif (.created_at | type == "string") then
172
+ (.created_at | gsub(" "; "T") | . + "Z" | fromdateiso8601)
173
+ else
174
+ ($current_date | fromdateiso8601)
175
+ end
176
+ ) as $created_timestamp |
177
+
178
+ (
179
+ (
180
+ ($current_date | fromdateiso8601) - $created_timestamp
181
+ ) / 86400
182
+ ) as $days_ago |
183
+
184
+ (
185
+ if $days_ago <= 0 then 1.0
186
+ elif $days_ago > 1000 then 0.1
187
+ else (1.0 / (1.0 + ($days_ago / 90.0)))
188
+ end
189
+ ) as $recency_score |
190
+
191
+ # Calculate frequency score (failure rate)
192
+ (
193
+ if (.total_count // 0) > 0 then
194
+ (1.0 - ((.success_count // 0) / (.total_count // 1)))
195
+ else 0.5
196
+ end
197
+ ) as $frequency_score |
198
+
199
+ # Combined relevance score
200
+ (
201
+ (0.5 * $severity_score) +
202
+ (0.3 * $domain_score) +
203
+ (0.1 * $recency_score) +
204
+ (0.1 * $frequency_score)
205
+ ) as $relevance_score |
206
+
207
+ . + {
208
+ relevance_score: ($relevance_score | . * 100 | round / 100),
209
+ scoring_breakdown: {
210
+ severity: ($severity_score | . * 100 | round / 100),
211
+ domain: ($domain_score | . * 100 | round / 100),
212
+ recency: ($recency_score | . * 100 | round / 100),
213
+ frequency: ($frequency_score | . * 100 | round / 100)
214
+ }
215
+ }
216
+ ) |
217
+ sort_by(-.relevance_score)
218
+ ' "$TEMP_RESULTS")
219
+
220
+ # Step 5: Limit results
221
+ FINAL_RESULTS=$(echo "$SCORED_RESULTS" | jq ".[:$LIMIT]")
222
+ TOTAL_COUNT=$(echo "$SCORED_RESULTS" | jq 'length')
223
+
224
+ # Step 6: Output results
225
+ case "$OUTPUT_FORMAT" in
226
+ json)
227
+ echo "$FINAL_RESULTS" | jq \
228
+ --arg task "$TASK_DESCRIPTION" \
229
+ --arg domains "$(echo $DOMAINS | tr '\n' ',' | sed 's/,$//')" \
230
+ --arg complexity "$COMPLEXITY" \
231
+ --arg task_type "$TASK_TYPE" \
232
+ --argjson total_count "$TOTAL_COUNT" \
233
+ --argjson limit "$LIMIT" \
234
+ '{
235
+ query: {
236
+ task: $task,
237
+ domains: ($domains | split(",")),
238
+ complexity: $complexity,
239
+ task_type: $task_type
240
+ },
241
+ anti_patterns: .,
242
+ total_count: $total_count,
243
+ filtered_count: (. | length),
244
+ limit: $limit
245
+ }'
246
+ ;;
247
+
248
+ simple)
249
+ echo "=== Anti-Pattern Query Results ==="
250
+ echo "Task: $TASK_DESCRIPTION"
251
+ echo "Domains: $(echo $DOMAINS | tr '\n' ',' | sed 's/,$//')"
252
+ echo "Total Found: $TOTAL_COUNT"
253
+ echo "Returned: $(echo "$FINAL_RESULTS" | jq 'length')"
254
+ echo ""
255
+
256
+ echo "$FINAL_RESULTS" | jq -r '
257
+ .[] |
258
+ "[\(.severity // "medium" | ascii_upcase)] \(.domain // "general") - Relevance: \(.relevance_score)\n" +
259
+ " Anti-Pattern: \(.anti_pattern // "N/A")\n" +
260
+ " Solution: \(.solution // "N/A")\n" +
261
+ " Sprint Ref: \(.sprint_ref // "N/A")\n" +
262
+ " Confidence: \(.confidence)\n"
263
+ '
264
+ ;;
265
+
266
+ *)
267
+ echo "ERROR: Unknown format $OUTPUT_FORMAT" >&2
268
+ rm -f "$TEMP_RESULTS"
269
+ exit 1
270
+ ;;
271
+ esac
272
+
273
+ # Cleanup
274
+ rm -f "$TEMP_RESULTS"
275
+
276
+ exit 0