claude-flow-novice 2.18.5 → 2.18.6

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 (1023) hide show
  1. package/.claude/.cfn-initialized +1 -0
  2. package/.claude/FILE_MANIFEST.md +50 -0
  3. package/.claude/MANIFEST_INDEX.md +224 -0
  4. package/.claude/MANIFEST_README.md +308 -0
  5. package/.claude/TRIGGER_TASKS_MANIFEST.md +11 -0
  6. package/.claude/WORKING-SETUP.md +67 -0
  7. package/.claude/adaptive-context/cfn-v3-reflection.json +21 -0
  8. package/.claude/agent-principles/SPARSE_LANGUAGE_FINDINGS.md +991 -0
  9. package/.claude/agent-principles/agent-template.md +96 -0
  10. package/.claude/agent-principles/prompt-engineering.md +501 -0
  11. package/.claude/agents/AGENT_LIFECYCLE.md +532 -0
  12. package/.claude/agents/README-AGENT_LIFECYCLE.md +522 -0
  13. package/.claude/agents/README-VALIDATION.md +243 -0
  14. package/.claude/agents/SHARED_PROTOCOL.md +64 -0
  15. package/.claude/agents/cfn-dev-team/CLAUDE.md +1000 -0
  16. package/.claude/agents/cfn-dev-team/README.md +219 -0
  17. package/.claude/agents/cfn-dev-team/analysts/analyst.md +120 -0
  18. package/.claude/agents/cfn-dev-team/analysts/root-cause-analyst.md +264 -0
  19. package/.claude/agents/cfn-dev-team/architecture/api-designer-persona.md +152 -0
  20. package/.claude/agents/cfn-dev-team/architecture/base-template-generator.md +157 -0
  21. package/.claude/agents/cfn-dev-team/architecture/goal-planner.md +180 -0
  22. package/.claude/agents/cfn-dev-team/architecture/planner.md +139 -0
  23. package/.claude/agents/cfn-dev-team/architecture/system-architect.md +132 -0
  24. package/.claude/agents/cfn-dev-team/coordinators/README.md +42 -0
  25. package/.claude/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +893 -0
  26. package/.claude/agents/cfn-dev-team/coordinators/consensus-builder.md +480 -0
  27. package/.claude/agents/cfn-dev-team/coordinators/handoff-coordinator.md +747 -0
  28. package/.claude/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +510 -0
  29. package/.claude/agents/cfn-dev-team/dev-ops/devops-engineer.md +157 -0
  30. package/.claude/agents/cfn-dev-team/dev-ops/docker-specialist.md +671 -0
  31. package/.claude/agents/cfn-dev-team/dev-ops/github-commit-agent.md +123 -0
  32. package/.claude/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +624 -0
  33. package/.claude/agents/cfn-dev-team/developers/README.md +69 -0
  34. package/.claude/agents/cfn-dev-team/developers/api-gateway-specialist.md +977 -0
  35. package/.claude/agents/cfn-dev-team/developers/backend-developer-cerebras.md +210 -0
  36. package/.claude/agents/cfn-dev-team/developers/backend-developer.md +206 -0
  37. package/.claude/agents/cfn-dev-team/developers/data/data-engineer.md +672 -0
  38. package/.claude/agents/cfn-dev-team/developers/database/database-architect.md +376 -0
  39. package/.claude/agents/cfn-dev-team/developers/database/supabase-specialist.md +746 -0
  40. package/.claude/agents/cfn-dev-team/developers/frontend/mobile-dev.md +247 -0
  41. package/.claude/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +272 -0
  42. package/.claude/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +396 -0
  43. package/.claude/agents/cfn-dev-team/developers/frontend/ui-designer.md +221 -0
  44. package/.claude/agents/cfn-dev-team/developers/graphql-specialist.md +707 -0
  45. package/.claude/agents/cfn-dev-team/developers/rust-developer.md +228 -0
  46. package/.claude/agents/cfn-dev-team/documentation/README-VALIDATION.md +245 -0
  47. package/.claude/agents/cfn-dev-team/documentation/agent-type-guidelines.md +476 -0
  48. package/.claude/agents/cfn-dev-team/documentation/api-documentation.md +111 -0
  49. package/.claude/agents/cfn-dev-team/documentation/pseudocode.md +144 -0
  50. package/.claude/agents/cfn-dev-team/documentation/specification-agent.md +152 -0
  51. package/.claude/agents/cfn-dev-team/product-owners/accessibility-advocate-persona.md +119 -0
  52. package/.claude/agents/cfn-dev-team/product-owners/cto-agent.md +138 -0
  53. package/.claude/agents/cfn-dev-team/product-owners/power-user-persona.md +151 -0
  54. package/.claude/agents/cfn-dev-team/product-owners/product-owner.md +483 -0
  55. package/.claude/agents/cfn-dev-team/reviewers/README.md +58 -0
  56. package/.claude/agents/cfn-dev-team/reviewers/code-reviewer.md +303 -0
  57. package/.claude/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +220 -0
  58. package/.claude/agents/cfn-dev-team/reviewers/quality/cyclomatic-complexity-reducer.md +334 -0
  59. package/.claude/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +257 -0
  60. package/.claude/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +160 -0
  61. package/.claude/agents/cfn-dev-team/reviewers/quality/quality-metrics.md +386 -0
  62. package/.claude/agents/cfn-dev-team/testers/README.md +94 -0
  63. package/.claude/agents/cfn-dev-team/testers/api-testing-specialist.md +757 -0
  64. package/.claude/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +944 -0
  65. package/.claude/agents/cfn-dev-team/testers/contract-tester.md +687 -0
  66. package/.claude/agents/cfn-dev-team/testers/e2e/playwright-tester.md +124 -0
  67. package/.claude/agents/cfn-dev-team/testers/integration-tester.md +785 -0
  68. package/.claude/agents/cfn-dev-team/testers/interaction-tester.md +188 -0
  69. package/.claude/agents/cfn-dev-team/testers/load-testing-specialist.md +505 -0
  70. package/.claude/agents/cfn-dev-team/testers/mutation-testing-specialist.md +643 -0
  71. package/.claude/agents/cfn-dev-team/testers/playwright-tester.md +253 -0
  72. package/.claude/agents/cfn-dev-team/testers/tester.md +224 -0
  73. package/.claude/agents/cfn-dev-team/testers/unit/tdd-london-unit-swarm.md +37 -0
  74. package/.claude/agents/cfn-dev-team/testers/validation/validation-production-validator.md +27 -0
  75. package/.claude/agents/cfn-dev-team/testing/test-validation-agent.md +280 -0
  76. package/.claude/agents/cfn-dev-team/utility/agent-builder.md +487 -0
  77. package/.claude/agents/cfn-dev-team/utility/context-curator.md +69 -0
  78. package/.claude/agents/cfn-dev-team/utility/epic-creator-v2.md +2 -0
  79. package/.claude/agents/cfn-dev-team/utility/epic-creator.md +7 -0
  80. package/.claude/agents/cfn-dev-team/utility/memory-leak-specialist.md +177 -0
  81. package/.claude/agents/cfn-dev-team/utility/researcher.md +116 -0
  82. package/.claude/agents/cfn-dev-team/utility/z-ai-specialist.md +218 -0
  83. package/.claude/agents/csuite/cto-agent.md +371 -0
  84. package/.claude/agents/custom/cfn-docker-expert.md +132 -0
  85. package/.claude/agents/custom/cfn-loops-cli-expert.md +9 -0
  86. package/.claude/agents/custom/cfn-redis-operations.md +538 -0
  87. package/.claude/agents/custom/cfn-system-expert.md +489 -0
  88. package/.claude/agents/custom/claude-code-expert.md +298 -0
  89. package/.claude/agents/custom/mdap-trigger-specialist.md +82 -0
  90. package/.claude/agents/custom/trigger-dev-expert.md +386 -0
  91. package/.claude/agents/docker-coordinators/cfn-docker-v3-coordinator.md +1101 -0
  92. package/.claude/agents/docker-ts-fixer.md +65 -0
  93. package/.claude/agents/project-only-agents/npm-package-specialist.md +334 -0
  94. package/.claude/agents/validate-agent.js +841 -0
  95. package/.claude/cfn-config/team-providers.json +102 -0
  96. package/.claude/cfn-extras/.gs-api-quota.json +16 -0
  97. package/.claude/cfn-extras/.gs-progress-state.json +22 -0
  98. package/.claude/cfn-extras/agents/cfn-coordinator-enterprise.md +1303 -0
  99. package/.claude/cfn-extras/agents/cfn-coordinator-mvp.md +942 -0
  100. package/.claude/cfn-extras/agents/cfn-coordinator-standard.md +1062 -0
  101. package/.claude/cfn-extras/agents/cfn-loop-coordinator.md +157 -0
  102. package/.claude/cfn-extras/agents/cfn-v3-coordinator.md +517 -0
  103. package/.claude/cfn-extras/agents/code-booster.md +67 -0
  104. package/.claude/cfn-extras/agents/coordinator.md +182 -0
  105. package/.claude/cfn-extras/agents/cost-savings-cfn-loop-coordinator.md +760 -0
  106. package/.claude/cfn-extras/agents/cost-savings-coordinator.md +173 -0
  107. package/.claude/cfn-extras/agents/deprecated-coordinators/adaptive-coordinator-enhanced.md +147 -0
  108. package/.claude/cfn-extras/agents/deprecated-coordinators/adaptive-coordinator.md +162 -0
  109. package/.claude/cfn-extras/agents/deprecated-coordinators/blocking-coordinator-example.md +729 -0
  110. package/.claude/cfn-extras/agents/deprecated-coordinators/byzantine-coordinator.md +100 -0
  111. package/.claude/cfn-extras/agents/deprecated-coordinators/cfn-coordinator-enterprise.md +323 -0
  112. package/.claude/cfn-extras/agents/deprecated-coordinators/cfn-coordinator-mvp.md +157 -0
  113. package/.claude/cfn-extras/agents/deprecated-coordinators/cfn-coordinator-standard.md +229 -0
  114. package/.claude/cfn-extras/agents/deprecated-coordinators/cfn-coordinator-unified.md +149 -0
  115. package/.claude/cfn-extras/agents/deprecated-coordinators/coordinator-hybrid.md +231 -0
  116. package/.claude/cfn-extras/agents/deprecated-coordinators/gossip-coordinator.md +165 -0
  117. package/.claude/cfn-extras/agents/deprecated-coordinators/hierarchical-coordinator.md +95 -0
  118. package/.claude/cfn-extras/agents/deprecated-coordinators/mesh-coordinator.md +132 -0
  119. package/.claude/cfn-extras/agents/deprecated-coordinators/task-coordinator.md +109 -0
  120. package/.claude/cfn-extras/agents/deprecated-coordinators/test-coordinator.md +142 -0
  121. package/.claude/cfn-extras/agents/docker-team/csuite/c-suite-template.md +529 -0
  122. package/.claude/cfn-extras/agents/docker-team/infrastructure/team-coordinator-template.md +467 -0
  123. package/.claude/cfn-extras/agents/docker-team/micro-sprint-planner.md +747 -0
  124. package/.claude/cfn-extras/agents/google-sheets/README.md +114 -0
  125. package/.claude/cfn-extras/agents/google-sheets/google-sheets-advanced-analytics-specialist.md +288 -0
  126. package/.claude/cfn-extras/agents/google-sheets/google-sheets-api-integrator.md +127 -0
  127. package/.claude/cfn-extras/agents/google-sheets/google-sheets-automation-scripting-specialist.md +195 -0
  128. package/.claude/cfn-extras/agents/google-sheets/google-sheets-business-validator.md +179 -0
  129. package/.claude/cfn-extras/agents/google-sheets/google-sheets-collaboration-security-specialist.md +240 -0
  130. package/.claude/cfn-extras/agents/google-sheets/google-sheets-coordinator.md +214 -0
  131. package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-transformer.md +127 -0
  132. package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-validation-quality-specialist.md +177 -0
  133. package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-validator.md +119 -0
  134. package/.claude/cfn-extras/agents/google-sheets/google-sheets-data-visualization-specialist.md +135 -0
  135. package/.claude/cfn-extras/agents/google-sheets/google-sheets-design-layout-specialist.md +109 -0
  136. package/.claude/cfn-extras/agents/google-sheets/google-sheets-formula-engineer.md +127 -0
  137. package/.claude/cfn-extras/agents/google-sheets/google-sheets-formula-engineering-specialist.md +138 -0
  138. package/.claude/cfn-extras/agents/google-sheets/google-sheets-formula-validator.md +128 -0
  139. package/.claude/cfn-extras/agents/google-sheets/google-sheets-generalist.md +645 -0
  140. package/.claude/cfn-extras/agents/google-sheets/google-sheets-integration-api-specialist.md +258 -0
  141. package/.claude/cfn-extras/agents/google-sheets/google-sheets-performance-analyst.md +125 -0
  142. package/.claude/cfn-extras/agents/google-sheets/google-sheets-performance-optimization-specialist.md +211 -0
  143. package/.claude/cfn-extras/agents/google-sheets/google-sheets-schema-designer.md +130 -0
  144. package/.claude/cfn-extras/agents/google-sheets/google-sheets-template-architecture-specialist.md +259 -0
  145. package/.claude/cfn-extras/agents/google-sheets-specialist.md +614 -0
  146. package/.claude/cfn-extras/commands/cfn-docker/CFN_DOCKER_CLI.md +527 -0
  147. package/.claude/cfn-extras/commands/cfn-docker/CFN_DOCKER_LOOP.md +377 -0
  148. package/.claude/cfn-extras/commands/cfn-docker/CFN_DOCKER_NATIVE.md +295 -0
  149. package/.claude/cfn-extras/commands/cfn-docker/CFN_DOCKER_TASK.md +490 -0
  150. package/.claude/cfn-extras/commands/cfn-docker/cfn-docker-core-test-suite.md +326 -0
  151. package/.claude/cfn-extras/commands/deprecated/CFN_EXPERT_UPDATE.md +142 -0
  152. package/.claude/cfn-extras/commands/deprecated/README.md +55 -0
  153. package/.claude/cfn-extras/commands/deprecated/cfn-loop-epic.md +478 -0
  154. package/.claude/cfn-extras/commands/deprecated/cfn-loop-single.md +256 -0
  155. package/.claude/cfn-extras/commands/deprecated/cfn-loop-sprints.md +396 -0
  156. package/.claude/cfn-extras/commands/deprecated/context-curate.md +200 -0
  157. package/.claude/cfn-extras/commands/deprecated/context-inject.md +251 -0
  158. package/.claude/cfn-extras/commands/deprecated/context-query.md +210 -0
  159. package/.claude/cfn-extras/commands/deprecated/context-stats.md +269 -0
  160. package/.claude/cfn-extras/commands/deprecated/cost-savings-off.md +35 -0
  161. package/.claude/cfn-extras/commands/deprecated/cost-savings-on.md +35 -0
  162. package/.claude/cfn-extras/commands/deprecated/custom-routing-activate.md +55 -0
  163. package/.claude/cfn-extras/commands/deprecated/custom-routing-deactivate.md +46 -0
  164. package/.claude/cfn-extras/commands/deprecated/github-commit.md +289 -0
  165. package/.claude/cfn-extras/commands/deprecated/github.md +221 -0
  166. package/.claude/cfn-extras/commands/deprecated/hello-world-tests.md +381 -0
  167. package/.claude/cfn-extras/commands/deprecated/parse-epic.md +357 -0
  168. package/.claude/cfn-extras/commands/deprecated/run-tests.md +119 -0
  169. package/.claude/cfn-extras/commands/deprecated/suggest-improvements.md +95 -0
  170. package/.claude/cfn-extras/commands/google-sheets/google-sheets-loop.md +289 -0
  171. package/.claude/cfn-extras/docs/GOOGLE_SHEETS_CFN_LOOP.md +619 -0
  172. package/.claude/cfn-extras/skills/GOOGLE_SHEETS_SKILLS_README.md +453 -0
  173. package/.claude/cfn-extras/skills/advanced-features/cfn-agent-swap/SKILL.md +36 -0
  174. package/.claude/cfn-extras/skills/advanced-features/cfn-agent-swap/recommend-swap.sh +60 -0
  175. package/.claude/cfn-extras/skills/advanced-features/cfn-api-validation/test-endpoints.sh +54 -0
  176. package/.claude/cfn-extras/skills/advanced-features/cfn-context-pruner/SKILL.md +75 -0
  177. package/.claude/cfn-extras/skills/advanced-features/cfn-context-pruner/prune-context.sh +73 -0
  178. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/README.md +299 -0
  179. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/SKILL.md +412 -0
  180. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/config.json +111 -0
  181. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/eventbus-wrapper.cjs +69 -0
  182. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/invoke-event-publish.sh +147 -0
  183. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/invoke-event-subscribe.sh +171 -0
  184. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/invoke-lifecycle-track.sh +201 -0
  185. package/.claude/cfn-extras/skills/advanced-features/cfn-event-bus/test-event-bus.sh +280 -0
  186. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/README.md +74 -0
  187. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/SKILL.md +412 -0
  188. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/config.json +60 -0
  189. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/invoke-fleet-allocate.sh +182 -0
  190. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/invoke-fleet-balance.sh +239 -0
  191. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/invoke-fleet-metrics.sh +193 -0
  192. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/invoke-fleet-register.sh +124 -0
  193. package/.claude/cfn-extras/skills/advanced-features/cfn-fleet-manager/test-fleet-manager.sh +345 -0
  194. package/.claude/cfn-extras/skills/advanced-features/cfn-task-mode-safety/cli-coordination.sh +519 -0
  195. package/.claude/cfn-extras/skills/advanced-features/cfn-task-mode-safety/mode-detection.sh +326 -0
  196. package/.claude/cfn-extras/skills/advanced-features/cfn-task-mode-sanitize/task-mode-env-sanitizer.sh +267 -0
  197. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/SKILL.md +40 -0
  198. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/agents-registry-clean.json +0 -0
  199. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/agents-registry-fixed.json +19 -0
  200. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/agents-registry.json +719 -0
  201. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/discover-agents.py +184 -0
  202. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/discover-agents.sh +87 -0
  203. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/invoke-registry.sh +11 -0
  204. package/.claude/cfn-extras/skills/deprecated/cfn-agent-discovery/temp_script.py +0 -0
  205. package/.claude/cfn-extras/skills/deprecated/cfn-agent-selector/SKILL.md +91 -0
  206. package/.claude/cfn-extras/skills/deprecated/cfn-agent-selector/select-agents.sh +112 -0
  207. package/.claude/cfn-extras/skills/deprecated/cfn-cli-setup/validate-cli-environment.sh +192 -0
  208. package/.claude/cfn-extras/skills/deprecated/cfn-simplified-agent-lifecycle/DESIGN.md +98 -0
  209. package/.claude/cfn-extras/skills/google-sheets-api-coordinator/SKILL.md +272 -0
  210. package/.claude/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh +254 -0
  211. package/.claude/cfn-extras/skills/google-sheets-api-coordinator/test.sh +174 -0
  212. package/.claude/cfn-extras/skills/google-sheets-api-coordinator/validate.sh +98 -0
  213. package/.claude/cfn-extras/skills/google-sheets-decomposition/SKILL.md +269 -0
  214. package/.claude/cfn-extras/skills/google-sheets-decomposition/decompose.sh +313 -0
  215. package/.claude/cfn-extras/skills/google-sheets-formula-builder/SKILL.md +237 -0
  216. package/.claude/cfn-extras/skills/google-sheets-formula-builder/build-formula.sh +220 -0
  217. package/.claude/cfn-extras/skills/google-sheets-formula-builder/test.sh +172 -0
  218. package/.claude/cfn-extras/skills/google-sheets-formula-builder/validate.sh +98 -0
  219. package/.claude/cfn-extras/skills/google-sheets-progress/SKILL.md +287 -0
  220. package/.claude/cfn-extras/skills/google-sheets-progress/test.sh +385 -0
  221. package/.claude/cfn-extras/skills/google-sheets-progress/track-progress.sh +516 -0
  222. package/.claude/cfn-extras/skills/google-sheets-progress/validate.sh +119 -0
  223. package/.claude/cfn-extras/skills/google-sheets-sprint-order/SKILL.md +277 -0
  224. package/.claude/cfn-extras/skills/google-sheets-sprint-order/order-sprints.sh +233 -0
  225. package/.claude/cfn-extras/skills/google-sheets-validation/SKILL.md +352 -0
  226. package/.claude/cfn-extras/skills/google-sheets-validation/test.sh +355 -0
  227. package/.claude/cfn-extras/skills/google-sheets-validation/validate-state.sh +374 -0
  228. package/.claude/cfn-extras/skills/google-sheets-validation/validate.sh +128 -0
  229. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/SKILL.md +392 -0
  230. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/create-campaign.sh +231 -0
  231. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/get-campaign-performance.sh +190 -0
  232. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/pause-campaign.sh +142 -0
  233. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/set-budget.sh +181 -0
  234. package/.claude/cfn-extras/skills/marketing/cfn-marketing-ad-campaigns/operations/update-bid-strategy.sh +133 -0
  235. package/.claude/cfn-extras/skills/marketing/cfn-marketing-analytics-data/SKILL.md +124 -0
  236. package/.claude/cfn-extras/skills/marketing/cfn-marketing-analytics-data/operations/get-ad-performance.sh +105 -0
  237. package/.claude/cfn-extras/skills/marketing/cfn-marketing-analytics-data/operations/get-conversion-funnel.sh +102 -0
  238. package/.claude/cfn-extras/skills/marketing/cfn-marketing-analytics-data/operations/get-email-performance.sh +105 -0
  239. package/.claude/cfn-extras/skills/marketing/cfn-marketing-analytics-data/operations/get-social-engagement.sh +105 -0
  240. package/.claude/cfn-extras/skills/marketing/cfn-marketing-analytics-data/operations/get-website-traffic.sh +107 -0
  241. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/SKILL.md +340 -0
  242. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/get-conversation-history.sh +121 -0
  243. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/qualify-lead.sh +156 -0
  244. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/schedule-demo.sh +181 -0
  245. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/send-message.sh +137 -0
  246. package/.claude/cfn-extras/skills/marketing/cfn-marketing-chatbot-conversations/operations/transfer-to-human.sh +179 -0
  247. package/.claude/cfn-extras/skills/marketing/cfn-marketing-competitive-intel/SKILL.md +350 -0
  248. package/.claude/cfn-extras/skills/marketing/cfn-marketing-competitive-intel/operations/get-backlink-profile.sh +154 -0
  249. package/.claude/cfn-extras/skills/marketing/cfn-marketing-competitive-intel/operations/get-keyword-rankings.sh +173 -0
  250. package/.claude/cfn-extras/skills/marketing/cfn-marketing-competitive-intel/operations/get-trending-topics.sh +147 -0
  251. package/.claude/cfn-extras/skills/marketing/cfn-marketing-competitive-intel/operations/monitor-competitor.sh +146 -0
  252. package/.claude/cfn-extras/skills/marketing/cfn-marketing-competitive-intel/operations/search-brand-mentions.sh +167 -0
  253. package/.claude/cfn-extras/skills/marketing/cfn-marketing-crm-contacts/SKILL.md +116 -0
  254. package/.claude/cfn-extras/skills/marketing/cfn-marketing-crm-contacts/operations/add-to-segment.sh +78 -0
  255. package/.claude/cfn-extras/skills/marketing/cfn-marketing-crm-contacts/operations/create-contact.sh +113 -0
  256. package/.claude/cfn-extras/skills/marketing/cfn-marketing-crm-contacts/operations/get-contact.sh +86 -0
  257. package/.claude/cfn-extras/skills/marketing/cfn-marketing-crm-contacts/operations/remove-from-segment.sh +78 -0
  258. package/.claude/cfn-extras/skills/marketing/cfn-marketing-crm-contacts/operations/update-contact.sh +120 -0
  259. package/.claude/cfn-extras/skills/marketing/cfn-marketing-email-campaigns/SKILL.md +106 -0
  260. package/.claude/cfn-extras/skills/marketing/cfn-marketing-email-campaigns/operations/create-campaign.sh +123 -0
  261. package/.claude/cfn-extras/skills/marketing/cfn-marketing-email-campaigns/operations/get-campaign-stats.sh +66 -0
  262. package/.claude/cfn-extras/skills/marketing/cfn-marketing-email-campaigns/operations/list-templates.sh +68 -0
  263. package/.claude/cfn-extras/skills/marketing/cfn-marketing-email-campaigns/operations/schedule-campaign.sh +85 -0
  264. package/.claude/cfn-extras/skills/marketing/cfn-marketing-email-campaigns/operations/send-test-email.sh +81 -0
  265. package/.claude/cfn-extras/skills/marketing/cfn-marketing-landing-pages/SKILL.md +366 -0
  266. package/.claude/cfn-extras/skills/marketing/cfn-marketing-landing-pages/operations/create-ab-test.sh +231 -0
  267. package/.claude/cfn-extras/skills/marketing/cfn-marketing-landing-pages/operations/create-landing-page.sh +190 -0
  268. package/.claude/cfn-extras/skills/marketing/cfn-marketing-landing-pages/operations/get-page-performance.sh +137 -0
  269. package/.claude/cfn-extras/skills/marketing/cfn-marketing-landing-pages/operations/publish-page.sh +120 -0
  270. package/.claude/cfn-extras/skills/marketing/cfn-marketing-landing-pages/operations/unpublish-page.sh +108 -0
  271. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-monitoring/SKILL.md +202 -0
  272. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-monitoring/operations/create-crisis-alert.sh +104 -0
  273. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-monitoring/operations/export-report.sh +92 -0
  274. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-monitoring/operations/get-sentiment-analysis.sh +85 -0
  275. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-monitoring/operations/search-mentions.sh +86 -0
  276. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-outreach/SKILL.md +168 -0
  277. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-outreach/operations/search-journalists.sh +74 -0
  278. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-outreach/operations/send-pitch.sh +80 -0
  279. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-outreach/operations/submit-haro-response.sh +88 -0
  280. package/.claude/cfn-extras/skills/marketing/cfn-marketing-media-outreach/operations/track-pitch-engagement.sh +66 -0
  281. package/.claude/cfn-extras/skills/marketing/cfn-marketing-press-distribution/SKILL.md +159 -0
  282. package/.claude/cfn-extras/skills/marketing/cfn-marketing-press-distribution/operations/distribute-press-release.sh +94 -0
  283. package/.claude/cfn-extras/skills/marketing/cfn-marketing-press-distribution/operations/get-distribution-status.sh +59 -0
  284. package/.claude/cfn-extras/skills/marketing/cfn-marketing-press-distribution/operations/get-pickup-metrics.sh +72 -0
  285. package/.claude/cfn-extras/skills/marketing/cfn-marketing-press-distribution/operations/list-templates.sh +53 -0
  286. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/SKILL.md +429 -0
  287. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/create-campaign.sh +183 -0
  288. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/get-delivery-status.sh +139 -0
  289. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/opt-out.sh +150 -0
  290. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/schedule-campaign.sh +187 -0
  291. package/.claude/cfn-extras/skills/marketing/cfn-marketing-sms-campaigns/operations/send-sms.sh +181 -0
  292. package/.claude/cfn-extras/skills/marketing/cfn-marketing-social-publishing/SKILL.md +108 -0
  293. package/.claude/cfn-extras/skills/marketing/cfn-marketing-social-publishing/operations/create-post.sh +104 -0
  294. package/.claude/cfn-extras/skills/marketing/cfn-marketing-social-publishing/operations/delete-post.sh +76 -0
  295. package/.claude/cfn-extras/skills/marketing/cfn-marketing-social-publishing/operations/get-post-stats.sh +66 -0
  296. package/.claude/cfn-extras/skills/marketing/cfn-marketing-social-publishing/operations/schedule-post.sh +85 -0
  297. package/.claude/cfn-extras/skills/marketing/cfn-marketing-social-publishing/operations/upload-media.sh +88 -0
  298. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/DESIGN.md +117 -0
  299. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/SKILL.md +679 -0
  300. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/invoke-portal-agents.sh +129 -0
  301. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/invoke-portal-dashboard.sh +85 -0
  302. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/invoke-portal-events.sh +125 -0
  303. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/invoke-portal-metrics.sh +112 -0
  304. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/invoke-portal-start.sh +135 -0
  305. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/invoke-portal-stop.sh +121 -0
  306. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/test-web-portal-skill.sh +51 -0
  307. package/.claude/cfn-extras/skills/ui-portal/cfn-web-portal/validate-deployment.sh +85 -0
  308. package/.claude/cfn-extras/skills/utility/cfn-environment-sanitization/SKILL.md +200 -0
  309. package/.claude/cfn-extras/skills/utility/cfn-environment-sanitization/sanitize-environment.sh +244 -0
  310. package/.claude/cfn-extras/skills/utility/cfn-process-instrumentation/SKILL.md +279 -0
  311. package/.claude/cfn-extras/skills/utility/cfn-process-instrumentation/instrument-process.sh +327 -0
  312. package/.claude/cfn-extras/workflows/marketing-ad-campaigns.json +125 -0
  313. package/.claude/cfn-extras/workflows/marketing-analytics-data.json +93 -0
  314. package/.claude/cfn-extras/workflows/marketing-chatbot-conversations.json +89 -0
  315. package/.claude/cfn-extras/workflows/marketing-competitive-intel.json +140 -0
  316. package/.claude/cfn-extras/workflows/marketing-crm-contacts.json +86 -0
  317. package/.claude/cfn-extras/workflows/marketing-email-campaigns.json +86 -0
  318. package/.claude/cfn-extras/workflows/marketing-landing-pages.json +137 -0
  319. package/.claude/cfn-extras/workflows/marketing-media-outreach.json +211 -0
  320. package/.claude/cfn-extras/workflows/marketing-press-distribution.json +224 -0
  321. package/.claude/cfn-extras/workflows/marketing-sms-campaigns.json +81 -0
  322. package/.claude/cfn-extras/workflows/marketing-social-publishing.json +86 -0
  323. package/.claude/commands/README.md +204 -0
  324. package/.claude/commands/cfn-loop/CFN_LOOP_FRONTEND.md +741 -0
  325. package/.claude/commands/cfn-loop/cfn-loop-cli.md +273 -0
  326. package/.claude/commands/cfn-loop/cfn-loop-document.md +499 -0
  327. package/.claude/commands/cfn-loop/cfn-loop-task.md +490 -0
  328. package/.claude/commands/cfn-loop/cfn-loop-trigger.md +56 -0
  329. package/.claude/commands/cfn-loop/cfn-mode.md +20 -0
  330. package/.claude/commands/cfn-loop/cfn-optimize-agents.md +103 -0
  331. package/.claude/commands/cfn-loop/list-agents-rebuild.md +205 -0
  332. package/.claude/commands/cfn-ruvector/codebase-reindex.md +37 -0
  333. package/.claude/commands/cfn-ruvector/codebase-search.md +38 -0
  334. package/.claude/commands/cfn-ruvector/detect-stale-docs.md +41 -0
  335. package/.claude/commands/cfn-test-framework +5 -0
  336. package/.claude/commands/check-errors.md +34 -0
  337. package/.claude/commands/cost-routing/switch-api.md +109 -0
  338. package/.claude/commands/detect-stale-docs.md +26 -0
  339. package/.claude/commands/epic-creator-v2.md +10 -0
  340. package/.claude/commands/ruvector-search.md +46 -0
  341. package/.claude/commands/sparc.md +46 -0
  342. package/.claude/commands/update-search-index.md +31 -0
  343. package/.claude/commands/workflow.md +295 -0
  344. package/.claude/commands/write-plan.md +275 -0
  345. package/.claude/coordinator-feedback-pattern.md +326 -0
  346. package/.claude/coordinator-patterns.md +126 -0
  347. package/.claude/core/agent-manager.js +80 -0
  348. package/.claude/core/agent-manager.js.map +1 -0
  349. package/.claude/core/config.js +1241 -0
  350. package/.claude/core/config.js.map +1 -0
  351. package/.claude/core/event-bus.js +136 -0
  352. package/.claude/core/event-bus.js.map +1 -0
  353. package/.claude/core/index.js +6 -0
  354. package/.claude/core/index.js.map +1 -0
  355. package/.claude/core/json-persistence.js +112 -0
  356. package/.claude/core/json-persistence.js.map +1 -0
  357. package/.claude/core/logger.js +245 -0
  358. package/.claude/core/logger.js.map +1 -0
  359. package/.claude/core/orchestrator-fixed.js +236 -0
  360. package/.claude/core/orchestrator-fixed.js.map +1 -0
  361. package/.claude/core/orchestrator.js +1136 -0
  362. package/.claude/core/orchestrator.js.map +1 -0
  363. package/.claude/core/persistence.js +185 -0
  364. package/.claude/core/persistence.js.map +1 -0
  365. package/.claude/core/project-manager.js +80 -0
  366. package/.claude/core/project-manager.js.map +1 -0
  367. package/.claude/core/slash-command.js +24 -0
  368. package/.claude/core/version.js +35 -0
  369. package/.claude/core/version.js.map +1 -0
  370. package/.claude/helpers/checkpoint-manager.sh +251 -0
  371. package/.claude/helpers/github-safe.js +106 -0
  372. package/.claude/helpers/github-setup.sh +28 -0
  373. package/.claude/helpers/quick-start.sh +19 -0
  374. package/.claude/helpers/setup-mcp.sh +18 -0
  375. package/.claude/helpers/standard-checkpoint-hooks.sh +179 -0
  376. package/.claude/hooks/GIT-HOOKS-USAGE-EXAMPLES.md +116 -0
  377. package/.claude/hooks/README-GIT-HOOKS.md +443 -0
  378. package/.claude/hooks/SKILL.md +518 -0
  379. package/.claude/hooks/SKILL.md.backup +471 -0
  380. package/.claude/hooks/cfn-BACKUP_USAGE.md +243 -0
  381. package/.claude/hooks/cfn-invoke-post-edit-ts.sh +100 -0
  382. package/.claude/hooks/cfn-invoke-post-edit.sh +135 -0
  383. package/.claude/hooks/cfn-invoke-pre-edit-ts.sh +116 -0
  384. package/.claude/hooks/cfn-invoke-pre-edit.sh +110 -0
  385. package/.claude/hooks/cfn-invoke-security-validation.sh +70 -0
  386. package/.claude/hooks/cfn-lint-sql-injection.sh +61 -0
  387. package/.claude/hooks/cfn-post-edit-cfn-retrospective.sh +110 -0
  388. package/.claude/hooks/cfn-post-edit.config.json +51 -0
  389. package/.claude/hooks/cfn-post-edit.sh +21 -0
  390. package/.claude/hooks/cfn-post-execution/memory-cleanup.sh +20 -0
  391. package/.claude/hooks/cfn-pre-edit-backup.sh +71 -0
  392. package/.claude/hooks/cfn-pre-edit-security-warning.sh +40 -0
  393. package/.claude/hooks/cfn-pre-execution/SESSION_START_README.md +87 -0
  394. package/.claude/hooks/cfn-pre-execution/TEST_SESSION_START.md +128 -0
  395. package/.claude/hooks/cfn-pre-execution/memory-check.sh +20 -0
  396. package/.claude/hooks/cfn-pre-execution/session-start-context.sh +111 -0
  397. package/.claude/hooks/cfn-restore-from-backup.sh +37 -0
  398. package/.claude/hooks/detect-hardcoded-credentials.sh +212 -0
  399. package/.claude/hooks/install-git-hooks.sh +243 -0
  400. package/.claude/hooks/post-commit-codebase-index +75 -0
  401. package/.claude/hooks/subagent-start.sh +98 -0
  402. package/.claude/hooks/subagent-stop.sh +93 -0
  403. package/.claude/hooks/validators/credential-scanner.sh +172 -0
  404. package/.claude/hooks.json +33 -0
  405. package/.claude/logs/sprint1-hybrid-routing-v2-decision.json +18 -0
  406. package/.claude/prompts/cfn-loop-context.md +115 -0
  407. package/.claude/prompts/loop-specific/loop2.md +50 -0
  408. package/.claude/prompts/loop-specific/loop3.md +43 -0
  409. package/.claude/prompts/loop-specific/loop4.md +54 -0
  410. package/.claude/root-claude-distribute/CFN-CLAUDE.md +513 -0
  411. package/.claude/settings.json +172 -0
  412. package/.claude/settings.local.json +41 -0
  413. package/.claude/settings.playwright.json +198 -0
  414. package/.claude/skills/.cfn/task-configs/task-test-123.json +48 -0
  415. package/.claude/skills/SKILL_TEMPLATE.md +774 -0
  416. package/.claude/skills/bulk-add-ruvector-instructions.sh +89 -0
  417. package/.claude/skills/cfn-agent-lifecycle/SKILL.md +290 -0
  418. package/.claude/skills/cfn-agent-lifecycle/cli/lifecycle-hook.sh +5 -0
  419. package/.claude/skills/cfn-agent-lifecycle/cli/select-agents.sh +5 -0
  420. package/.claude/skills/cfn-agent-lifecycle/cli/spawn-agent.sh +5 -0
  421. package/.claude/skills/cfn-agent-lifecycle/execute.sh +355 -0
  422. package/.claude/skills/cfn-agent-lifecycle/lib/audit/execute-lifecycle-hook.sh +544 -0
  423. package/.claude/skills/cfn-agent-lifecycle/lib/audit/simple-audit.sh +58 -0
  424. package/.claude/skills/cfn-agent-lifecycle/lib/output/README.md +359 -0
  425. package/.claude/skills/cfn-agent-lifecycle/lib/selection/SKILL.md +29 -0
  426. package/.claude/skills/cfn-agent-lifecycle/lib/selection/agent-mappings.json +142 -0
  427. package/.claude/skills/cfn-agent-lifecycle/lib/selection/select-agents-with-fallback.sh +195 -0
  428. package/.claude/skills/cfn-agent-lifecycle/lib/selection/select-agents.sh +94 -0
  429. package/.claude/skills/cfn-agent-lifecycle/lib/selection/src/agent-selector.ts +350 -0
  430. package/.claude/skills/cfn-agent-lifecycle/lib/selection/src/cli.ts +74 -0
  431. package/.claude/skills/cfn-agent-lifecycle/lib/selection/task-classifier.sh +93 -0
  432. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/SKILL.md +38 -0
  433. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/check-dependencies.sh +52 -0
  434. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/execute-agent.sh +126 -0
  435. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/get-agent-provider-env.sh +149 -0
  436. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/parse-agent-provider.sh +81 -0
  437. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/spawn-agent-wrapper.sh +63 -0
  438. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/spawn-agent.sh +308 -0
  439. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/spawn-templates.sh +635 -0
  440. package/.claude/skills/cfn-agent-lifecycle/lib/spawning/spawn-worker.sh +198 -0
  441. package/.claude/skills/cfn-agent-tooling/SKILL.md +52 -0
  442. package/.claude/skills/cfn-agent-tooling/lib/generator/SKILL.md +440 -0
  443. package/.claude/skills/cfn-agent-tooling/lib/generator/generate-agent.sh +405 -0
  444. package/.claude/skills/cfn-agent-tooling/lib/linter/SKILL.md +589 -0
  445. package/.claude/skills/cfn-agent-tooling/lib/linter/lint-agents.sh +271 -0
  446. package/.claude/skills/cfn-cerebras-code-generator/SKILL.md +53 -0
  447. package/.claude/skills/cfn-cerebras-code-generator/context-analyzer.sh +96 -0
  448. package/.claude/skills/cfn-cerebras-code-generator/generate-code.sh +205 -0
  449. package/.claude/skills/cfn-cerebras-coordinator/SKILL.md +103 -0
  450. package/.claude/skills/cfn-cerebras-coordinator/TEST_RESULTS.md +98 -0
  451. package/.claude/skills/cfn-cerebras-coordinator/coordinate-generation.sh +381 -0
  452. package/.claude/skills/cfn-cerebras-coordinator/example-fix-scenario.md +254 -0
  453. package/.claude/skills/cfn-cerebras-coordinator/example-workflow.md +142 -0
  454. package/.claude/skills/cfn-cerebras-coordinator/feedback-logger.sh +254 -0
  455. package/.claude/skills/cfn-cerebras-coordinator/fix-existing-code-v2.sh +443 -0
  456. package/.claude/skills/cfn-cerebras-coordinator/fix-existing-code.sh +519 -0
  457. package/.claude/skills/cfn-cerebras-coordinator/pattern-examples.md +317 -0
  458. package/.claude/skills/cfn-cerebras-coordinator/query-patterns.sh +182 -0
  459. package/.claude/skills/cfn-cerebras-coordinator/tdd-coordinator.sh +638 -0
  460. package/.claude/skills/cfn-cerebras-coordinator/test-runner.sh +335 -0
  461. package/.claude/skills/cfn-cerebras-mcp/SKILL.md +64 -0
  462. package/.claude/skills/cfn-compilation-error-fixer/HANDOFF.md +29 -0
  463. package/.claude/skills/cfn-compilation-error-fixer/README.md +202 -0
  464. package/.claude/skills/cfn-compilation-error-fixer/SKILL.md +426 -0
  465. package/.claude/skills/cfn-compilation-error-fixer/bin/fix-errors.sh +75 -0
  466. package/.claude/skills/cfn-compilation-error-fixer/index.js +81 -0
  467. package/.claude/skills/cfn-compilation-error-fixer/install.sh +60 -0
  468. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/README-TypeScript.md +164 -0
  469. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/cerebras-gated-fixer-v2.ts +1475 -0
  470. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/cerebras-gated-fixer-v2.ts.bak +1475 -0
  471. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/cerebras-sdk.d.ts +30 -0
  472. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/cerebras-wrapper.ts +93 -0
  473. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/package.json +30 -0
  474. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/package.json.bak +23 -0
  475. package/.claude/skills/cfn-compilation-error-fixer/lib/fixer/typescript-gated-fixer-v2.ts +977 -0
  476. package/.claude/skills/cfn-compilation-error-fixer/lib/gates/typescript-gates.ts +704 -0
  477. package/.claude/skills/cfn-compilation-error-fixer/package.json +47 -0
  478. package/.claude/skills/cfn-compilation-error-fixer/test-fixer-logic.sh +96 -0
  479. package/.claude/skills/cfn-compilation-error-fixer/test-installation.sh +97 -0
  480. package/.claude/skills/cfn-compilation-error-fixer/test-rust-fixer-validation.sh +54 -0
  481. package/.claude/skills/cfn-compilation-error-fixer/test-rust-fixer.sh +380 -0
  482. package/.claude/skills/cfn-compilation-error-fixer/test-typescript-fixer.sh +278 -0
  483. package/.claude/skills/cfn-compilation-error-fixer/validate-setup.md +70 -0
  484. package/.claude/skills/cfn-config/SKILL.md +52 -0
  485. package/.claude/skills/cfn-config/lib/management/README.md +42 -0
  486. package/.claude/skills/cfn-config/lib/management/SKILL.md +34 -0
  487. package/.claude/skills/cfn-config/lib/management/check-dependencies.sh +56 -0
  488. package/.claude/skills/cfn-config/lib/management/config.json +32 -0
  489. package/.claude/skills/cfn-config/lib/management/manage-config.sh +115 -0
  490. package/.claude/skills/cfn-config/lib/sanitization/sanitize-environment.sh +48 -0
  491. package/.claude/skills/cfn-conversation-sync/README.md +133 -0
  492. package/.claude/skills/cfn-conversation-sync/SKILL.md +82 -0
  493. package/.claude/skills/cfn-conversation-sync/sync-conversations.sh +229 -0
  494. package/.claude/skills/cfn-dependency-management/SKILL.md +118 -0
  495. package/.claude/skills/cfn-dependency-management/cfn-dependency-management.sh +18 -0
  496. package/.claude/skills/cfn-dependency-management/execute.sh +306 -0
  497. package/.claude/skills/cfn-dependency-management/lib/extractor/SKILL.md +35 -0
  498. package/.claude/skills/cfn-dependency-management/lib/extractor/extract-dependencies.sh +66 -0
  499. package/.claude/skills/cfn-dependency-management/lib/ingestion/README.md +101 -0
  500. package/.claude/skills/cfn-dependency-management/lib/ingestion/SKILL.md +397 -0
  501. package/.claude/skills/cfn-dependency-management/lib/ingestion/build.sh +23 -0
  502. package/.claude/skills/cfn-dependency-management/lib/ingestion/ingest-dependencies.sh +295 -0
  503. package/.claude/skills/cfn-dependency-management/lib/ingestion/ingest.sh +237 -0
  504. package/.claude/skills/cfn-dependency-management/lib/ingestion/manifests/cli-mode-dependencies.txt +219 -0
  505. package/.claude/skills/cfn-dependency-management/lib/ingestion/manifests/shared-dependencies.txt +57 -0
  506. package/.claude/skills/cfn-dependency-management/lib/ingestion/manifests/trigger-dev-dependencies.txt +82 -0
  507. package/.claude/skills/cfn-dependency-management/lib/ingestion/manifests/trigger-mode-dependencies.txt +80 -0
  508. package/.claude/skills/cfn-dependency-management/lib/ingestion/src/ingest-dependencies.ts +563 -0
  509. package/.claude/skills/cfn-deployment-lifecycle/SKILL.md +53 -0
  510. package/.claude/skills/cfn-deployment-lifecycle/lib/deployment/SKILL.md +293 -0
  511. package/.claude/skills/cfn-deployment-lifecycle/lib/deployment/execute.sh +21 -0
  512. package/.claude/skills/cfn-deployment-lifecycle/lib/promotion/SKILL.md +305 -0
  513. package/.claude/skills/cfn-docker-runtime/SKILL.md +84 -0
  514. package/.claude/skills/cfn-docker-runtime/execute.sh +386 -0
  515. package/.claude/skills/cfn-docker-runtime/lib/coordination/README.md +349 -0
  516. package/.claude/skills/cfn-docker-runtime/lib/coordination/docker-helpers.sh +433 -0
  517. package/.claude/skills/cfn-docker-runtime/lib/coordination/package.json +38 -0
  518. package/.claude/skills/cfn-docker-runtime/lib/coordination/src/agent-container.ts +471 -0
  519. package/.claude/skills/cfn-docker-runtime/lib/coordination/src/docker-client.ts +483 -0
  520. package/.claude/skills/cfn-docker-runtime/lib/coordination/src/health-checker.ts +418 -0
  521. package/.claude/skills/cfn-docker-runtime/lib/coordination/src/index.ts +45 -0
  522. package/.claude/skills/cfn-docker-runtime/lib/coordination/src/network-manager.ts +377 -0
  523. package/.claude/skills/cfn-docker-runtime/lib/coordination/src/types.ts +412 -0
  524. package/.claude/skills/cfn-docker-runtime/lib/coordination/src/volume-manager.ts +389 -0
  525. package/.claude/skills/cfn-docker-runtime/lib/logging/INTEGRATION.md +268 -0
  526. package/.claude/skills/cfn-docker-runtime/lib/logging/SAMPLE_OUTPUTS.md +237 -0
  527. package/.claude/skills/cfn-docker-runtime/lib/logging/SKILL.md +442 -0
  528. package/.claude/skills/cfn-docker-runtime/lib/logging/capture-container-logs.sh +120 -0
  529. package/.claude/skills/cfn-docker-runtime/lib/logging/enable-logging.sh +430 -0
  530. package/.claude/skills/cfn-docker-runtime/lib/logging/init-hybrid-logging.sh +210 -0
  531. package/.claude/skills/cfn-docker-runtime/lib/logging/queries/analytics-summary.sh +87 -0
  532. package/.claude/skills/cfn-docker-runtime/lib/logging/queries/query-agent-timeline.sh +51 -0
  533. package/.claude/skills/cfn-docker-runtime/lib/logging/queries/query-consensus-history.sh +56 -0
  534. package/.claude/skills/cfn-docker-runtime/lib/logging/queries/query-coordination-timeline.sh +39 -0
  535. package/.claude/skills/cfn-docker-runtime/lib/logging/queries/query-failed-containers.sh +40 -0
  536. package/.claude/skills/cfn-docker-runtime/lib/logging/queries/query-gate-checks.sh +39 -0
  537. package/.claude/skills/cfn-docker-runtime/lib/logging/schema.sql +111 -0
  538. package/.claude/skills/cfn-docker-runtime/lib/logging/sqlite-helpers.sh +240 -0
  539. package/.claude/skills/cfn-docker-runtime/lib/logging/test-hybrid-logging.sh +331 -0
  540. package/.claude/skills/cfn-docker-runtime/lib/mcp/SKILL.md +555 -0
  541. package/.claude/skills/cfn-docker-runtime/lib/mcp/skill-mcp-selector.js +472 -0
  542. package/.claude/skills/cfn-docker-runtime/lib/orchestration/SKILL.md +449 -0
  543. package/.claude/skills/cfn-docker-runtime/lib/orchestration/orchestrate.sh +1722 -0
  544. package/.claude/skills/cfn-docker-runtime/lib/spawning/SKILL.md +418 -0
  545. package/.claude/skills/cfn-docker-runtime/lib/spawning/spawn-agent.sh +569 -0
  546. package/.claude/skills/cfn-docker-runtime/lib/waves/SKILL.md +944 -0
  547. package/.claude/skills/cfn-docker-runtime/lib/waves/cleanup-wave.sh +445 -0
  548. package/.claude/skills/cfn-docker-runtime/lib/waves/lib/docker-helpers.sh +804 -0
  549. package/.claude/skills/cfn-docker-runtime/lib/waves/monitor-wave.sh +485 -0
  550. package/.claude/skills/cfn-docker-runtime/lib/waves/spawn-wave.sh +547 -0
  551. package/.claude/skills/cfn-edit-safety/README.md +160 -0
  552. package/.claude/skills/cfn-edit-safety/SKILL.md +62 -0
  553. package/.claude/skills/cfn-edit-safety/cli/edit-safety-cli.sh +337 -0
  554. package/.claude/skills/cfn-edit-safety/edit-safety.sh +375 -0
  555. package/.claude/skills/cfn-edit-safety/lib/backup/SKILL.md +324 -0
  556. package/.claude/skills/cfn-edit-safety/lib/backup/SKILL.md.backup +277 -0
  557. package/.claude/skills/cfn-edit-safety/lib/backup/backup.sh +129 -0
  558. package/.claude/skills/cfn-edit-safety/lib/backup/backup.sh.backup +107 -0
  559. package/.claude/skills/cfn-edit-safety/lib/hooks/README.md +74 -0
  560. package/.claude/skills/cfn-edit-safety/lib/hooks/SKILL.md +148 -0
  561. package/.claude/skills/cfn-edit-safety/lib/hooks/auto-resolve.sh +66 -0
  562. package/.claude/skills/cfn-edit-safety/lib/hooks/check-dependencies.sh +40 -0
  563. package/.claude/skills/cfn-edit-safety/lib/hooks/feedback-resolver.sh +452 -0
  564. package/.claude/skills/cfn-edit-safety/lib/hooks/post-edit-handler.sh +155 -0
  565. package/.claude/skills/cfn-edit-safety/lib/hooks/security-scan.json +60 -0
  566. package/.claude/skills/cfn-edit-safety/lib/hooks/security-scanner.sh +121 -0
  567. package/.claude/skills/cfn-edit-safety/lib/hooks/test-root-warning-resolution.sh +148 -0
  568. package/.claude/skills/cfn-epic-parser/SKILL.md +220 -0
  569. package/.claude/skills/cfn-epic-parser/example-epic.md +49 -0
  570. package/.claude/skills/cfn-epic-parser/parse.sh +517 -0
  571. package/.claude/skills/cfn-epic-parser/test-parser.sh +299 -0
  572. package/.claude/skills/cfn-error-management/SKILL.md +176 -0
  573. package/.claude/skills/cfn-error-management/cli/batch-errors.sh +4 -0
  574. package/.claude/skills/cfn-error-management/cli/capture-error.sh +4 -0
  575. package/.claude/skills/cfn-error-management/cli/log-error.sh +4 -0
  576. package/.claude/skills/cfn-error-management/lib/batching/README.md +1016 -0
  577. package/.claude/skills/cfn-error-management/lib/batching/analyze-errors.sh +327 -0
  578. package/.claude/skills/cfn-error-management/lib/batching/calculate-waves.sh +256 -0
  579. package/.claude/skills/cfn-error-management/lib/batching/cli.sh +523 -0
  580. package/.claude/skills/cfn-error-management/lib/batching/cluster-files.sh +196 -0
  581. package/.claude/skills/cfn-error-management/lib/batching/create-batches.sh +261 -0
  582. package/.claude/skills/cfn-error-management/lib/capture/README.md +56 -0
  583. package/.claude/skills/cfn-error-management/lib/capture/capture-agent-error.sh +87 -0
  584. package/.claude/skills/cfn-error-management/lib/logging/README.md +339 -0
  585. package/.claude/skills/cfn-error-management/lib/logging/cleanup-error-logs.sh +334 -0
  586. package/.claude/skills/cfn-error-management/lib/logging/integrate-cli.sh +232 -0
  587. package/.claude/skills/cfn-error-management/lib/logging/integrate-docker.sh +294 -0
  588. package/.claude/skills/cfn-error-management/lib/logging/invoke-error-logging.sh +839 -0
  589. package/.claude/skills/cfn-error-management/lib/logging/src/error-logger.ts +1042 -0
  590. package/.claude/skills/cfn-error-management/lib/logging/src/index.ts +12 -0
  591. package/.claude/skills/cfn-error-management/lib/logging/src/types.ts +456 -0
  592. package/.claude/skills/cfn-error-management/lib/logging/test-error-logging.sh +475 -0
  593. package/.claude/skills/cfn-expert-update/SKILL.md +149 -0
  594. package/.claude/skills/cfn-expert-update/test-expert-update.sh +254 -0
  595. package/.claude/skills/cfn-expert-update/update-expert.sh +484 -0
  596. package/.claude/skills/cfn-intervention-system/SKILL.md +52 -0
  597. package/.claude/skills/cfn-intervention-system/lib/detector/SKILL.md +39 -0
  598. package/.claude/skills/cfn-intervention-system/lib/detector/detect-intervention.sh +106 -0
  599. package/.claude/skills/cfn-intervention-system/lib/orchestrator/SKILL.md +43 -0
  600. package/.claude/skills/cfn-intervention-system/lib/orchestrator/execute-intervention.sh +59 -0
  601. package/.claude/skills/cfn-knowledge-base/SKILL.md +109 -0
  602. package/.claude/skills/cfn-knowledge-base/cli/knowledge-base.sh +435 -0
  603. package/.claude/skills/cfn-knowledge-base/execute.sh +163 -0
  604. package/.claude/skills/cfn-knowledge-base/lib/playbook/SKILL.md +153 -0
  605. package/.claude/skills/cfn-knowledge-base/lib/playbook/init-playbook.sh +54 -0
  606. package/.claude/skills/cfn-knowledge-base/lib/playbook/lib/auto-update/auto-update-playbook.sh +86 -0
  607. package/.claude/skills/cfn-knowledge-base/lib/playbook/query-playbook.sh +89 -0
  608. package/.claude/skills/cfn-knowledge-base/lib/playbook/update-playbook.sh +67 -0
  609. package/.claude/skills/cfn-knowledge-base/lib/workflow/APPROVAL_WORKFLOW.md +806 -0
  610. package/.claude/skills/cfn-knowledge-base/lib/workflow/COST_TRACKING.md +637 -0
  611. package/.claude/skills/cfn-knowledge-base/lib/workflow/DEPLOY_QUICK_REFERENCE.md +106 -0
  612. package/.claude/skills/cfn-knowledge-base/lib/workflow/EDGE_CASE_TRACKING.md +404 -0
  613. package/.claude/skills/cfn-knowledge-base/lib/workflow/PROPAGATE_UPDATE_QUICK_REFERENCE.md +366 -0
  614. package/.claude/skills/cfn-knowledge-base/lib/workflow/README_PHASE4.md +457 -0
  615. package/.claude/skills/cfn-knowledge-base/lib/workflow/SKILL.md +110 -0
  616. package/.claude/skills/cfn-knowledge-base/lib/workflow/approval-workflow.sh +514 -0
  617. package/.claude/skills/cfn-knowledge-base/lib/workflow/deploy-approved-skill.sh +481 -0
  618. package/.claude/skills/cfn-knowledge-base/lib/workflow/deploy-approved-skill.sh.backup-1763392820 +512 -0
  619. package/.claude/skills/cfn-knowledge-base/lib/workflow/generate-skill-update.sh +525 -0
  620. package/.claude/skills/cfn-knowledge-base/lib/workflow/lib/security-utils.sh +204 -0
  621. package/.claude/skills/cfn-knowledge-base/lib/workflow/package.json +30 -0
  622. package/.claude/skills/cfn-knowledge-base/lib/workflow/propagate-skill-update.sh +654 -0
  623. package/.claude/skills/cfn-knowledge-base/lib/workflow/propagate-skill-update.sh.backup-1763392820 +664 -0
  624. package/.claude/skills/cfn-knowledge-base/lib/workflow/review-skill.sh +643 -0
  625. package/.claude/skills/cfn-knowledge-base/lib/workflow/src/index.ts +24 -0
  626. package/.claude/skills/cfn-knowledge-base/lib/workflow/src/pattern-analyzer.ts +537 -0
  627. package/.claude/skills/cfn-knowledge-base/lib/workflow/src/types.ts +180 -0
  628. package/.claude/skills/cfn-knowledge-base/lib/workflow/test-integration.sh +296 -0
  629. package/.claude/skills/cfn-knowledge-base/lib/workflow/test-metadata-update.sh +350 -0
  630. package/.claude/skills/cfn-knowledge-base/lib/workflow/track-cost-savings.sh +486 -0
  631. package/.claude/skills/cfn-knowledge-base/lib/workflow/track-cost-savings.sh.backup-1763392821 +445 -0
  632. package/.claude/skills/cfn-knowledge-base/lib/workflow/track-edge-case.sh +290 -0
  633. package/.claude/skills/cfn-local-ruvector-accelerator/Cargo.toml +40 -0
  634. package/.claude/skills/cfn-local-ruvector-accelerator/README.md +563 -0
  635. package/.claude/skills/cfn-local-ruvector-accelerator/SKILL.md +343 -0
  636. package/.claude/skills/cfn-local-ruvector-accelerator/cfn-integration.sh +179 -0
  637. package/.claude/skills/cfn-local-ruvector-accelerator/embeddings_manager.py +289 -0
  638. package/.claude/skills/cfn-local-ruvector-accelerator/index-code.sh +234 -0
  639. package/.claude/skills/cfn-local-ruvector-accelerator/init-local-ruvector.sh +112 -0
  640. package/.claude/skills/cfn-local-ruvector-accelerator/project-structure.md +53 -0
  641. package/.claude/skills/cfn-local-ruvector-accelerator/query-local.sh +169 -0
  642. package/.claude/skills/cfn-local-ruvector-accelerator/requirements.txt +2 -0
  643. package/.claude/skills/cfn-local-ruvector-accelerator/search_engine.py +200 -0
  644. package/.claude/skills/cfn-local-ruvector-accelerator/search_engine_v2.py +238 -0
  645. package/.claude/skills/cfn-local-ruvector-accelerator/sqlite_store.py +220 -0
  646. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/cleanup.rs +134 -0
  647. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/export.rs +40 -0
  648. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/index.rs +301 -0
  649. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/init.rs +127 -0
  650. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/migration.rs +74 -0
  651. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/mod.rs +18 -0
  652. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/query.rs +222 -0
  653. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/reset.rs +37 -0
  654. package/.claude/skills/cfn-local-ruvector-accelerator/src/cli/stats.rs +133 -0
  655. package/.claude/skills/cfn-local-ruvector-accelerator/src/embeddings.rs +121 -0
  656. package/.claude/skills/cfn-local-ruvector-accelerator/src/main.rs +359 -0
  657. package/.claude/skills/cfn-local-ruvector-accelerator/src/migration.rs +318 -0
  658. package/.claude/skills/cfn-local-ruvector-accelerator/src/search_engine.rs +281 -0
  659. package/.claude/skills/cfn-local-ruvector-accelerator/src/sqlite_store.rs +211 -0
  660. package/.claude/skills/cfn-local-ruvector-accelerator/test-local-ruvector.sh +250 -0
  661. package/.claude/skills/cfn-loop-orchestration-v2/SKILL.md +57 -0
  662. package/.claude/skills/cfn-loop-orchestration-v2/cli/cfn-orchestrator.cjs +49 -0
  663. package/.claude/skills/cfn-loop-orchestration-v2/cli/orchestrate.sh +21 -0
  664. package/.claude/skills/cfn-loop-orchestration-v2/cli/resolve-provider-model.cjs +69 -0
  665. package/.claude/skills/cfn-loop-orchestration-v2/lib/coordination/agent-completion.sh.backup +36 -0
  666. package/.claude/skills/cfn-loop-orchestration-v2/lib/coordination/coordination-patterns.ts +194 -0
  667. package/.claude/skills/cfn-loop-orchestration-v2/lib/coordination/coordination-signal.sh.backup +36 -0
  668. package/.claude/skills/cfn-loop-orchestration-v2/lib/coordination/coordination-wait.sh.backup +36 -0
  669. package/.claude/skills/cfn-loop-orchestration-v2/lib/coordination/index.ts +25 -0
  670. package/.claude/skills/cfn-loop-orchestration-v2/lib/decision/SKILL.md +664 -0
  671. package/.claude/skills/cfn-loop-orchestration-v2/lib/decision/TYPESCRIPT_IMPLEMENTATION.md +653 -0
  672. package/.claude/skills/cfn-loop-orchestration-v2/lib/decision/parse-decision.sh +66 -0
  673. package/.claude/skills/cfn-loop-orchestration-v2/lib/decision/test-backlog-integration.sh +148 -0
  674. package/.claude/skills/cfn-loop-orchestration-v2/lib/decision/validate-deliverables.sh +82 -0
  675. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/CONFIGURATION_IMPROVEMENTS.md +318 -0
  676. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/CONTEXT_LOOKUP_QUICK_START.md +378 -0
  677. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/NORTH_STAR_INDEX.md +323 -0
  678. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/ORCHESTRATOR_IMPLEMENTATION.md +493 -0
  679. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/ORCHESTRATOR_QUICK_START.md +499 -0
  680. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/README.md +149 -0
  681. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/SKILL.md +418 -0
  682. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/SPAWN_AGENTS_IMPLEMENTATION.md +188 -0
  683. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/VALIDATION_SUMMARY.txt +196 -0
  684. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/VALIDATOR_MODULE_GUIDE.md +526 -0
  685. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/e2e-validation-fixed.js +240 -0
  686. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/e2e-validation.js +213 -0
  687. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/package.json +53 -0
  688. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/run-north-star-e2e.ts +210 -0
  689. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/security_utils.sh +123 -0
  690. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/agent-spawner/agent-spawner.ts +34 -0
  691. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/cli/orchestrator-cli.ts +396 -0
  692. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/gate-checker/gate-checker.ts +36 -0
  693. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/CONFIDENCE_AGGREGATOR.md +564 -0
  694. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/CONFIDENCE_AGGREGATOR_QUICK_REF.md +241 -0
  695. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/CONTEXT_INJECTOR_QUICK_REFERENCE.md +362 -0
  696. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/CONTEXT_INJECTOR_README.md +307 -0
  697. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/CONTEXT_INJECTOR_USAGE_GUIDE.md +508 -0
  698. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/confidence-aggregator.ts +473 -0
  699. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/consensus.ts +87 -0
  700. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/context-injector.ts +349 -0
  701. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/context-lookup.ts +486 -0
  702. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/deliverable-verifier.ts +107 -0
  703. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/gate-check.ts +115 -0
  704. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/iteration-manager.ts +45 -0
  705. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/parse-test-results.ts +372 -0
  706. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/product-owner-decision.ts +316 -0
  707. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/spawn-agents.ts +357 -0
  708. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/timeout-calculator.ts +41 -0
  709. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/helpers/validator.ts +276 -0
  710. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/index.ts +16 -0
  711. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/orchestrate.ts +1389 -0
  712. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/orchestrator/orchestrator.ts +31 -0
  713. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/redis/redis-coordinator.ts +72 -0
  714. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/types.ts +244 -0
  715. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/src/utils/logger.ts +32 -0
  716. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/test-cfn-orchestration.sh +281 -0
  717. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/test-cli.sh +92 -0
  718. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/test-edge-cases.sh +188 -0
  719. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/test-iteration-context-injection.sh +366 -0
  720. package/.claude/skills/cfn-loop-orchestration-v2/lib/orchestrator/test-typescript-integration.sh +442 -0
  721. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/DELIVERY_SUMMARY.txt +462 -0
  722. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/EXAMPLES.md +609 -0
  723. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/INDEX.md +531 -0
  724. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/README.md +114 -0
  725. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/SKILL.md +633 -0
  726. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/index.ts +6 -0
  727. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/output-processor.ts +183 -0
  728. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/package.json +50 -0
  729. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/src/cli/process-loop2.ts +195 -0
  730. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/src/cli/process-loop3.ts +157 -0
  731. package/.claude/skills/cfn-loop-orchestration-v2/lib/output/src/output-processor.ts +632 -0
  732. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/INDEX.md +531 -0
  733. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/README.md +256 -0
  734. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/README_TYPESCRIPT.md +454 -0
  735. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/SKILL.md +400 -0
  736. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/SKILL.md.backup +353 -0
  737. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/SKILL_TYPESCRIPT.md +782 -0
  738. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/VAPOR_DETECTION_EXAMPLES.md +598 -0
  739. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/check-dependencies.sh +53 -0
  740. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/check-dependencies.sh.backup +31 -0
  741. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/config.json +161 -0
  742. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/consensus-calculator.js +477 -0
  743. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/detect-vapor.sh +59 -0
  744. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/detect-vapor.sh.backup +37 -0
  745. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/evidence-chain.sql +163 -0
  746. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/index.ts +12 -0
  747. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/orchestrate-cfn-loop.sh +274 -0
  748. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/orchestrate-cfn-loop.sh.backup +252 -0
  749. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/package.json +93 -0
  750. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/src/cli/detect-vapor.ts +177 -0
  751. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/src/cli/validate-deliverables.ts +161 -0
  752. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/src/cli/validate-gate.ts +139 -0
  753. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/src/types.ts +215 -0
  754. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/src/validator.ts +503 -0
  755. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/validate-deliverables.sh +59 -0
  756. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/validate-deliverables.sh.backup +37 -0
  757. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/validate-gate.sh +63 -0
  758. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/validate-gate.sh.backup +41 -0
  759. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/validate-iteration.sh +156 -0
  760. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/validate-iteration.sh.backup +134 -0
  761. package/.claude/skills/cfn-loop-orchestration-v2/lib/validation/validation-framework.ts +237 -0
  762. package/.claude/skills/cfn-mdap-context-injection/SKILL.md +21 -0
  763. package/.claude/skills/cfn-mdap-context-injection/inject.sh +348 -0
  764. package/.claude/skills/cfn-mdap-error-fixer/HANDOFF.md +383 -0
  765. package/.claude/skills/cfn-mdap-error-fixer/lib/fixer/cerebras-gated-fixer-v2.ts +1500 -0
  766. package/.claude/skills/cfn-mdap-error-fixer/lib/fixer/package.json +20 -0
  767. package/.claude/skills/cfn-mdap-error-fixer/skill.md +205 -0
  768. package/.claude/skills/cfn-memory-persistence/SKILL.md +59 -0
  769. package/.claude/skills/cfn-memory-persistence/lib/auto/SKILL.md +73 -0
  770. package/.claude/skills/cfn-memory-persistence/lib/auto/persist-agent-output.sh +49 -0
  771. package/.claude/skills/cfn-memory-persistence/lib/auto/query-agent-history.sh +35 -0
  772. package/.claude/skills/cfn-memory-persistence/lib/auto/test-memory-persistence.sh +230 -0
  773. package/.claude/skills/cfn-memory-persistence/lib/management/SKILL.md +271 -0
  774. package/.claude/skills/cfn-memory-persistence/lib/management/check-memory.sh +160 -0
  775. package/.claude/skills/cfn-memory-persistence/lib/management/cleanup-memory.sh +197 -0
  776. package/.claude/skills/cfn-memory-persistence/lib/redis/SKILL.md +42 -0
  777. package/.claude/skills/cfn-memory-persistence/lib/redis/agent-log.sh.backup +128 -0
  778. package/.claude/skills/cfn-memory-persistence/lib/redis/agent-recovery.sh.backup +75 -0
  779. package/.claude/skills/cfn-memory-persistence/lib/redis/analyze-task-complexity.sh.backup +277 -0
  780. package/.claude/skills/cfn-memory-persistence/lib/redis/bash-wrappers/store-context.sh.backup +23 -0
  781. package/.claude/skills/cfn-memory-persistence/lib/redis/cancel-swarm.sh.backup +221 -0
  782. package/.claude/skills/cfn-memory-persistence/lib/redis/cfn-loop-exec.sh.backup +468 -0
  783. package/.claude/skills/cfn-memory-persistence/lib/redis/cfn-loop-relaunch.sh.backup +29 -0
  784. package/.claude/skills/cfn-memory-persistence/lib/redis/collect-confidence-scores.sh.backup +209 -0
  785. package/.claude/skills/cfn-memory-persistence/lib/redis/collect-results.sh.backup +75 -0
  786. package/.claude/skills/cfn-memory-persistence/lib/redis/complete-swarm.sh.backup +75 -0
  787. package/.claude/skills/cfn-memory-persistence/lib/redis/get-context.sh.backup +146 -0
  788. package/.claude/skills/cfn-memory-persistence/lib/redis/get-success-criteria.sh.backup +54 -0
  789. package/.claude/skills/cfn-memory-persistence/lib/redis/invoke-waiting-mode.sh.backup +225 -0
  790. package/.claude/skills/cfn-memory-persistence/lib/redis/redis-cli-wrapper.sh.backup +43 -0
  791. package/.claude/skills/cfn-memory-persistence/lib/redis/redis-functions.sh.backup +34 -0
  792. package/.claude/skills/cfn-memory-persistence/lib/redis/report-completion.sh.backup +134 -0
  793. package/.claude/skills/cfn-memory-persistence/lib/redis/store-context.sh.backup +123 -0
  794. package/.claude/skills/cfn-memory-persistence/lib/sqlite/QUICK_REFERENCE.md +204 -0
  795. package/.claude/skills/cfn-memory-persistence/lib/sqlite/README.md +65 -0
  796. package/.claude/skills/cfn-memory-persistence/lib/sqlite/SKILL.md +415 -0
  797. package/.claude/skills/cfn-memory-persistence/lib/sqlite/acl-queries.sql +452 -0
  798. package/.claude/skills/cfn-memory-persistence/lib/sqlite/check-dependencies.sh +36 -0
  799. package/.claude/skills/cfn-memory-persistence/lib/sqlite/config.json +45 -0
  800. package/.claude/skills/cfn-memory-persistence/lib/sqlite/memory-cli.sh +74 -0
  801. package/.claude/skills/cfn-memory-persistence/lib/sqlite/test-state-persistence.js +187 -0
  802. package/.claude/skills/cfn-memory-persistence/lib/sqlite/ttl-cleanup.sh +266 -0
  803. package/.claude/skills/cfn-node-heap-sizer/SKILL.md +313 -0
  804. package/.claude/skills/cfn-node-heap-sizer/task-mode-heap-limiter.sh +326 -0
  805. package/.claude/skills/cfn-operations/SKILL.md +52 -0
  806. package/.claude/skills/cfn-operations/execute.sh +175 -0
  807. package/.claude/skills/cfn-operations/lib/file/SKILL.md +290 -0
  808. package/.claude/skills/cfn-operations/lib/file/execute.sh +129 -0
  809. package/.claude/skills/cfn-operations/lib/file/lib/atomic-write.sh +294 -0
  810. package/.claude/skills/cfn-operations/lib/file/lib/lock.sh +361 -0
  811. package/.claude/skills/cfn-operations/lib/file/test.sh +373 -0
  812. package/.claude/skills/cfn-operations/lib/log/SKILL.md +308 -0
  813. package/.claude/skills/cfn-operations/lib/log/execute.sh +420 -0
  814. package/.claude/skills/cfn-operations/lib/log/lib/rotate.sh +406 -0
  815. package/.claude/skills/cfn-operations/lib/log/lib/search.sh +448 -0
  816. package/.claude/skills/cfn-operations/lib/log/test.sh +400 -0
  817. package/.claude/skills/cfn-parameterized-queries/SKILL.md +368 -0
  818. package/.claude/skills/cfn-parameterized-queries/parameterized-queries.sh +249 -0
  819. package/.claude/skills/cfn-parameterized-queries/test-implementation.sh +237 -0
  820. package/.claude/skills/cfn-planning/SKILL.md +55 -0
  821. package/.claude/skills/cfn-planning/execute.sh +159 -0
  822. package/.claude/skills/cfn-planning/lib/coordinator/README.md +256 -0
  823. package/.claude/skills/cfn-planning/lib/coordinator/SKILL.md +62 -0
  824. package/.claude/skills/cfn-planning/lib/coordinator/map-dependencies-conflicts.sh +376 -0
  825. package/.claude/skills/cfn-planning/lib/coordinator/plan-coordinator-resources.sh +258 -0
  826. package/.claude/skills/cfn-planning/lib/coordinator/plan-multi-coordinator-work.sh +267 -0
  827. package/.claude/skills/cfn-planning/lib/coordinator/plan-risk-rollout.sh +350 -0
  828. package/.claude/skills/cfn-planning/lib/coordinator/test-multi-coordinator-planning.sh +338 -0
  829. package/.claude/skills/cfn-planning/lib/coordinator/validate-task-planning.sh +189 -0
  830. package/.claude/skills/cfn-planning/lib/epic/SKILL.md +44 -0
  831. package/.claude/skills/cfn-planning/lib/epic/decompose-epic.sh +104 -0
  832. package/.claude/skills/cfn-planning/lib/scope/SKILL.md +37 -0
  833. package/.claude/skills/cfn-planning/lib/scope/simplify-scope.sh +68 -0
  834. package/.claude/skills/cfn-process-management/SKILL.md +52 -0
  835. package/.claude/skills/cfn-process-management/cfn-process +16 -0
  836. package/.claude/skills/cfn-process-management/cli/process-manager +186 -0
  837. package/.claude/skills/cfn-process-management/lib/instrumentation/instrument-process.sh +44 -0
  838. package/.claude/skills/cfn-process-management/lib/lifecycle/README.md +43 -0
  839. package/.claude/skills/cfn-process-management/lib/lifecycle/SKILL.md +39 -0
  840. package/.claude/skills/cfn-process-management/lib/lifecycle/check-dependencies.sh +58 -0
  841. package/.claude/skills/cfn-process-management/lib/lifecycle/config.json +39 -0
  842. package/.claude/skills/cfn-process-management/lib/lifecycle/process-manager.sh +334 -0
  843. package/.claude/skills/cfn-project-management/SKILL.md +60 -0
  844. package/.claude/skills/cfn-project-management/lib/backlog/SKILL.md +199 -0
  845. package/.claude/skills/cfn-project-management/lib/backlog/add-backlog-item.sh +208 -0
  846. package/.claude/skills/cfn-project-management/lib/changelog/SKILL.md +349 -0
  847. package/.claude/skills/cfn-project-management/lib/changelog/add-changelog-entry.sh +202 -0
  848. package/.claude/skills/cfn-project-management/lib/changelog/bulk-import.sh +268 -0
  849. package/.claude/skills/cfn-project-management/lib/changelog/lib/README.md +212 -0
  850. package/.claude/skills/cfn-project-management/lib/changelog/lib/validation.sh +72 -0
  851. package/.claude/skills/cfn-routing-config/SKILL.md +52 -0
  852. package/.claude/skills/cfn-routing-config/lib/hybrid/README.md +50 -0
  853. package/.claude/skills/cfn-routing-config/lib/hybrid/SKILL.md +54 -0
  854. package/.claude/skills/cfn-routing-config/lib/hybrid/check-dependencies.sh +52 -0
  855. package/.claude/skills/cfn-routing-config/lib/hybrid/config.json +26 -0
  856. package/.claude/skills/cfn-routing-config/lib/hybrid/spawn-worker.sh +44 -0
  857. package/.claude/skills/cfn-routing-config/lib/provider/README.md +129 -0
  858. package/.claude/skills/cfn-routing-config/lib/provider/SKILL.md +215 -0
  859. package/.claude/skills/cfn-routing-config/lib/provider/resolve-provider-model.ts +252 -0
  860. package/.claude/skills/cfn-session-handoff/SKILL.md +53 -0
  861. package/.claude/skills/cfn-skill-management/FIXES_APPLIED.md +80 -0
  862. package/.claude/skills/cfn-skill-management/SKILL.md +55 -0
  863. package/.claude/skills/cfn-skill-management/lib/builder/SKILL.md +910 -0
  864. package/.claude/skills/cfn-skill-management/lib/loader/SKILL.md +466 -0
  865. package/.claude/skills/cfn-skill-management/lib/loader/execute.sh +344 -0
  866. package/.claude/skills/cfn-skill-management/lib/propagation/README.md +233 -0
  867. package/.claude/skills/cfn-skill-management/lib/propagation/package.json +56 -0
  868. package/.claude/skills/cfn-skill-management/lib/propagation/propagate-skill-update.sh +32 -0
  869. package/.claude/skills/cfn-skill-management/lib/propagation/src/cli.ts +75 -0
  870. package/.claude/skills/cfn-skill-management/lib/propagation/src/database-adapter.ts +239 -0
  871. package/.claude/skills/cfn-skill-management/lib/propagation/src/file-system-adapter.ts +113 -0
  872. package/.claude/skills/cfn-skill-management/lib/propagation/src/index.ts +72 -0
  873. package/.claude/skills/cfn-skill-management/lib/propagation/src/logger.ts +43 -0
  874. package/.claude/skills/cfn-skill-management/lib/propagation/src/metadata-parser.ts +154 -0
  875. package/.claude/skills/cfn-skill-management/lib/propagation/src/skill-propagator.ts +274 -0
  876. package/.claude/skills/cfn-skill-management/lib/propagation/src/skill-validator.ts +179 -0
  877. package/.claude/skills/cfn-skill-management/lib/propagation/src/types.ts +143 -0
  878. package/.claude/skills/cfn-skill-management/lib/propagation/src/version-manager.ts +118 -0
  879. package/.claude/skills/cfn-skill-management/src/cli/skill-loader.ts +364 -0
  880. package/.claude/skills/cfn-skill-management/src/lib/database-service.ts +313 -0
  881. package/.claude/skills/cfn-sprint-execution/SKILL.md +55 -0
  882. package/.claude/skills/cfn-sprint-execution/execute.sh +257 -0
  883. package/.claude/skills/cfn-sprint-execution/lib/checkpoint/SKILL.md +333 -0
  884. package/.claude/skills/cfn-sprint-execution/lib/checkpoint/cleanup-orphans.sh +374 -0
  885. package/.claude/skills/cfn-sprint-execution/lib/checkpoint/resume-wave.sh +325 -0
  886. package/.claude/skills/cfn-sprint-execution/lib/checkpoint/save-checkpoint.sh +284 -0
  887. package/.claude/skills/cfn-sprint-execution/lib/execution/SKILL.md +27 -0
  888. package/.claude/skills/cfn-sprint-execution/lib/execution/execute-sprint-task.sh +68 -0
  889. package/.claude/skills/cfn-sprint-execution/lib/execution/execute-sprint.sh +65 -0
  890. package/.claude/skills/cfn-task-decomposition/explore-123-subtasks.json +27 -0
  891. package/.claude/skills/cfn-task-decomposition/prompts/explore-123-analyze-prompt.md +36 -0
  892. package/.claude/skills/cfn-task-decomposition/prompts/explore-123-scan-prompt.md +36 -0
  893. package/.claude/skills/cfn-task-decomposition/prompts/test-final-fix-prompt.md +36 -0
  894. package/.claude/skills/cfn-task-decomposition/prompts/test-final-pattern-prompt.md +36 -0
  895. package/.claude/skills/cfn-task-decomposition/prompts/test-final-recon-prompt.md +36 -0
  896. package/.claude/skills/cfn-task-decomposition/prompts/test-final-validate-prompt.md +36 -0
  897. package/.claude/skills/cfn-task-decomposition/test-456-subtasks.json +60 -0
  898. package/.claude/skills/cfn-task-decomposition/test-789-subtasks.json +60 -0
  899. package/.claude/skills/cfn-task-decomposition/test-999-subtasks.json +27 -0
  900. package/.claude/skills/cfn-task-decomposition/test-debug-subtasks.json +60 -0
  901. package/.claude/skills/cfn-task-decomposition/test-debug2-subtasks.json +60 -0
  902. package/.claude/skills/cfn-task-decomposition/test-final-subtasks.json +60 -0
  903. package/.claude/skills/cfn-task-decomposition/test-simple-subtasks.json +60 -0
  904. package/.claude/skills/cfn-task-intelligence/SKILL.md +18 -0
  905. package/.claude/skills/cfn-task-intelligence/cfn-task-intelligence.sh +158 -0
  906. package/.claude/skills/cfn-task-intelligence/lib/classifier/SKILL.md +81 -0
  907. package/.claude/skills/cfn-task-intelligence/lib/classifier/classify-task.sh +297 -0
  908. package/.claude/skills/cfn-task-intelligence/lib/complexity/SKILL.md +96 -0
  909. package/.claude/skills/cfn-task-intelligence/lib/complexity/estimate-complexity.sh +144 -0
  910. package/.claude/skills/cfn-task-intelligence/lib/integration/SKILL.md +339 -0
  911. package/.claude/skills/cfn-task-intelligence/lib/integration/learning-loop.sh +127 -0
  912. package/.claude/skills/cfn-task-intelligence/lib/integration/post-feedback-hook.sh +124 -0
  913. package/.claude/skills/cfn-task-intelligence/lib/integration/pre-execution-hook.sh +59 -0
  914. package/.claude/skills/cfn-task-intelligence/lib/specialist/SKILL.md +41 -0
  915. package/.claude/skills/cfn-task-intelligence/lib/specialist/recommend-specialist.sh +57 -0
  916. package/.claude/skills/cfn-task-planning/SKILL.md +15 -0
  917. package/.claude/skills/cfn-task-planning/cli/classify-task.sh +4 -0
  918. package/.claude/skills/cfn-task-planning/cli/decompose-task.sh +4 -0
  919. package/.claude/skills/cfn-task-planning/cli/init-config.sh +4 -0
  920. package/.claude/skills/cfn-task-planning/lib/audit/get-audit-data.sh +397 -0
  921. package/.claude/skills/cfn-task-planning/lib/audit/store-task-audit.sh +191 -0
  922. package/.claude/skills/cfn-task-planning/lib/classifier/README.md +81 -0
  923. package/.claude/skills/cfn-task-planning/lib/classifier/classify-task.sh +297 -0
  924. package/.claude/skills/cfn-task-planning/lib/decomposition/task-decomposer.sh +415 -0
  925. package/.claude/skills/cfn-test-framework/CLI.md +191 -0
  926. package/.claude/skills/cfn-test-framework/SKILL.md +55 -0
  927. package/.claude/skills/cfn-test-framework/execute.sh +386 -0
  928. package/.claude/skills/cfn-test-framework/lib/execution/README.md +129 -0
  929. package/.claude/skills/cfn-test-framework/lib/execution/SKILL.md +128 -0
  930. package/.claude/skills/cfn-test-framework/lib/execution/check-dependencies.sh +36 -0
  931. package/.claude/skills/cfn-test-framework/lib/execution/test-cache-reader.sh +134 -0
  932. package/.claude/skills/cfn-test-framework/lib/execution/test-concurrent-conflicts.sh +115 -0
  933. package/.claude/skills/cfn-test-framework/lib/execution/test-coordinator-pattern.sh +109 -0
  934. package/.claude/skills/cfn-test-framework/lib/runner/SKILL.md +288 -0
  935. package/.claude/skills/cfn-test-framework/lib/runner/detect-regressions.sh +58 -0
  936. package/.claude/skills/cfn-test-framework/lib/runner/detect-regressions.sh.backup-1763392821 +55 -0
  937. package/.claude/skills/cfn-test-framework/lib/runner/init-benchmark-db.sh +48 -0
  938. package/.claude/skills/cfn-test-framework/lib/runner/run-all-tests.sh +222 -0
  939. package/.claude/skills/cfn-test-framework/lib/runner/store-benchmarks.sh +53 -0
  940. package/.claude/skills/cfn-test-framework/lib/runner/validate-redis-keys.sh +143 -0
  941. package/.claude/skills/cfn-test-framework/lib/webapp/README.md +142 -0
  942. package/.claude/skills/cfn-test-framework/lib/webapp/SCREENSHOT_NAMING_CONVENTION.md +547 -0
  943. package/.claude/skills/cfn-test-framework/lib/webapp/SKILL.md +877 -0
  944. package/.claude/skills/cfn-test-framework/lib/webapp/capture-screenshot.sh +238 -0
  945. package/.claude/skills/cfn-test-framework/lib/webapp/cfn-loop-integration.sh +265 -0
  946. package/.claude/skills/cfn-test-framework/lib/webapp/compare-screenshots.sh +199 -0
  947. package/.claude/skills/cfn-test-framework/lib/webapp/init-storage.sh +150 -0
  948. package/.claude/skills/cfn-test-framework/lib/webapp/set-baseline.sh +196 -0
  949. package/.claude/skills/cfn-test-framework/lib/webapp/test-webapp-testing.sh +233 -0
  950. package/.claude/skills/cfn-transparency-middleware/CACHE_MANAGER.md +98 -0
  951. package/.claude/skills/cfn-transparency-middleware/Cargo.lock +2358 -0
  952. package/.claude/skills/cfn-transparency-middleware/Cargo.toml +20 -0
  953. package/.claude/skills/cfn-transparency-middleware/README.md +327 -0
  954. package/.claude/skills/cfn-transparency-middleware/SECURITY.md +41 -0
  955. package/.claude/skills/cfn-transparency-middleware/SKILL.md +327 -0
  956. package/.claude/skills/cfn-transparency-middleware/TEST_RESULTS.md +174 -0
  957. package/.claude/skills/cfn-transparency-middleware/config.json +23 -0
  958. package/.claude/skills/cfn-transparency-middleware/fix_redact.sh +12 -0
  959. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-filter.sh +98 -0
  960. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-init.sh +224 -0
  961. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-level.sh +333 -0
  962. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-metrics.sh +345 -0
  963. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-observe.sh +140 -0
  964. package/.claude/skills/cfn-transparency-middleware/invoke-transparency-stop.sh +235 -0
  965. package/.claude/skills/cfn-transparency-middleware/middleware-config.sh +29 -0
  966. package/.claude/skills/cfn-transparency-middleware/performance-benchmark.sh +79 -0
  967. package/.claude/skills/cfn-transparency-middleware/src/agent_metrics.rs +480 -0
  968. package/.claude/skills/cfn-transparency-middleware/src/api_handler.rs +318 -0
  969. package/.claude/skills/cfn-transparency-middleware/src/cache_manager.rs +219 -0
  970. package/.claude/skills/cfn-transparency-middleware/src/fix_regex.rs +9 -0
  971. package/.claude/skills/cfn-transparency-middleware/src/lib.rs +391 -0
  972. package/.claude/skills/cfn-transparency-middleware/src/lib.rs.backup +388 -0
  973. package/.claude/skills/cfn-transparency-middleware/src/main.rs +205 -0
  974. package/.claude/skills/cfn-transparency-middleware/src/memory_query.rs +93 -0
  975. package/.claude/skills/cfn-transparency-middleware/src/memory_repository.rs +169 -0
  976. package/.claude/skills/cfn-transparency-middleware/src/memory_schema.rs +154 -0
  977. package/.claude/skills/cfn-transparency-middleware/src/test_fix.txt +2 -0
  978. package/.claude/skills/cfn-transparency-middleware/test-e2e.sh +421 -0
  979. package/.claude/skills/cfn-transparency-middleware/test-integration.sh +162 -0
  980. package/.claude/skills/cfn-transparency-middleware/test-transparency-skill.sh +368 -0
  981. package/.claude/skills/cfn-transparency-middleware/test-transparency-skill.sh.unix +126 -0
  982. package/.claude/skills/cfn-transparency-middleware/wrap-agent.sh +132 -0
  983. package/.claude/skills/cfn-utilities/SKILL.md +239 -0
  984. package/.claude/skills/cfn-utilities/execute.sh +32 -0
  985. package/.claude/skills/cfn-utilities/lib/errors.sh +56 -0
  986. package/.claude/skills/cfn-utilities/lib/file-ops.sh +164 -0
  987. package/.claude/skills/cfn-utilities/lib/logging.sh +77 -0
  988. package/.claude/skills/cfn-utilities/lib/retry.sh +127 -0
  989. package/.claude/skills/cfn-utilities/test.sh +317 -0
  990. package/.claude/skills/cfn-validation-framework/SKILL.md +60 -0
  991. package/.claude/skills/cfn-validation-framework/execute.sh +223 -0
  992. package/.claude/skills/cfn-validation-framework/lib/deliverables/confidence-calculator.sh +262 -0
  993. package/.claude/skills/cfn-validation-framework/lib/instrumentation/wrapped-executor.sh +291 -0
  994. package/.claude/skills/cfn-validation-framework/lib/json/SKILL.md +431 -0
  995. package/.claude/skills/cfn-validation-framework/lib/json/test-validate-success-criteria.sh +421 -0
  996. package/.claude/skills/cfn-validation-framework/lib/json/validate-success-criteria.sh +197 -0
  997. package/.claude/skills/cfn-validation-framework/lib/layers/SKILL.md +133 -0
  998. package/.claude/skills/cfn-vision-analysis/SKILL.md +20 -0
  999. package/.claude/skills/deprecated/analyze-patterns.sh +899 -0
  1000. package/.claude/skills/equation-solver/README.md +327 -0
  1001. package/.claude/skills/equation-solver/SECURITY.md +306 -0
  1002. package/.claude/skills/equation-solver/SKILL.md +335 -0
  1003. package/.claude/skills/equation-solver/package.json +32 -0
  1004. package/.claude/skills/equation-solver/solve.sh +352 -0
  1005. package/.claude/skills/equation-solver/test-equation-solver-minimal.sh +103 -0
  1006. package/.claude/skills/equation-solver/test-equation-solver.sh +510 -0
  1007. package/.claude/skills/equation-solver/test.cjs +25 -0
  1008. package/.claude/skills/shared/bootstrap/sqlite-params.sh +156 -0
  1009. package/.claude/skills/shared/lib/path-utils.sh +139 -0
  1010. package/.claude/skills-database/APPROVAL_CRITERIA.md +925 -0
  1011. package/.claude/skills-database/APPROVAL_WORKFLOW.md +1482 -0
  1012. package/.claude/skills-database/ARCHITECTURE_DECISIONS.md +456 -0
  1013. package/.claude/skills-database/IMPLEMENTATION_GUIDE.md +763 -0
  1014. package/.claude/skills-database/README.md +564 -0
  1015. package/.claude/skills-database/TDD_SKILLS_DB_INTEGRATION.md +2286 -0
  1016. package/.claude/skills-database/schema-v2.sql +587 -0
  1017. package/.claude/slash-commands.json +92 -0
  1018. package/.claude/spawn-pattern-examples.md +500 -0
  1019. package/.claude/sprint-configs/cfn-naming-standardization.json +729 -0
  1020. package/.claude/state/cfn-expert-last-commit +2 -0
  1021. package/.claude/tooling/jq +0 -0
  1022. package/fix-node_modules.md +68 -0
  1023. package/package.json +2 -2
@@ -0,0 +1,1500 @@
1
+ #!/usr/bin/env npx tsx
2
+ /**
3
+ * Gated Rust Error Fixer V2 - Enhanced Gate Architecture
4
+ *
5
+ * Improvements over V1:
6
+ * - New semantic gates (G-K) for import paths, pattern duplicates, impl location, type casts
7
+ * - Regression seed corpus to catch known-bad patterns
8
+ * - Hardened prompts with explicit preservation rules
9
+ * - Enhanced Layer 3 reviewer with checklist
10
+ * - Dry-run patch mode
11
+ * - Gate rejection logging with feedback loop
12
+ * - Targeted crate compile testing
13
+ */
14
+
15
+ import Cerebras from '@cerebras/cerebras_cloud_sdk';
16
+ import * as fs from 'fs';
17
+ import * as path from 'path';
18
+ import { execSync } from 'child_process';
19
+
20
+ // ============== CONFIGURATION ==============
21
+
22
+ // Get project path from: 1) CLI arg, 2) env var, 3) current directory
23
+ function getProjectPath(): string {
24
+ // Check for --project=/path/to/rust CLI arg
25
+ const projectArg = process.argv.find(arg => arg.startsWith('--project='));
26
+ if (projectArg) {
27
+ return projectArg.split('=')[1];
28
+ }
29
+ // Check for RUST_PROJECT_PATH env var
30
+ if (process.env.RUST_PROJECT_PATH) {
31
+ return process.env.RUST_PROJECT_PATH;
32
+ }
33
+ // Default to current working directory
34
+ return process.cwd();
35
+ }
36
+
37
+ const CONFIG = {
38
+ maxGlobalIterations: 5,
39
+ maxFileRetries: 2,
40
+ maxLayer1Retries: 3, // Max retries when Layer 1 gates reject
41
+ maxTokens: 4000,
42
+ model: process.env.CEREBRAS_MODEL || 'zai-glm-4.6',
43
+ projectPath: getProjectPath(),
44
+ parallelLLMCalls: 10,
45
+ enableLayer3: !process.argv.includes('--no-layer3'),
46
+ enableClippy: !process.argv.includes('--no-clippy'),
47
+ dryRun: process.argv.includes('--dry-run'),
48
+ patchDir: '/tmp/rust-fix-patches',
49
+ verbose: process.argv.includes('--verbose'),
50
+ };
51
+
52
+ // ============== TYPE DEFINITIONS ==============
53
+
54
+ type ErrorDifficulty = 'easy' | 'medium' | 'hard';
55
+
56
+ interface RustError {
57
+ code: string;
58
+ line: number;
59
+ column: number;
60
+ message: string;
61
+ suggestion?: string;
62
+ difficulty: ErrorDifficulty;
63
+ }
64
+
65
+ interface LineFix {
66
+ line: number;
67
+ action: 'replace' | 'insert_after' | 'insert_before' | 'delete';
68
+ content: string;
69
+ }
70
+
71
+ interface LLMFixResult {
72
+ error: RustError;
73
+ fixes: LineFix[];
74
+ success: boolean;
75
+ }
76
+
77
+ interface GateResult {
78
+ passed: boolean;
79
+ reason?: string;
80
+ riskLevel: 1 | 2 | 3 | 4 | 5;
81
+ }
82
+
83
+ interface ReviewResult {
84
+ verdict: 'APPROVE' | 'REJECT';
85
+ reason: string;
86
+ riskLevel: 1 | 2 | 3 | 4 | 5;
87
+ }
88
+
89
+ interface GateStats {
90
+ layer1Rejections: number;
91
+ layer2Rejections: number;
92
+ layer3Rejections: number;
93
+ approvals: number;
94
+ byGate: Record<string, number>;
95
+ }
96
+
97
+ interface GateRejectionLog {
98
+ timestamp: string;
99
+ file: string;
100
+ gate: string;
101
+ reason: string;
102
+ errorCode: string;
103
+ }
104
+
105
+ interface Layer1RetryContext {
106
+ attempt: number;
107
+ previousFailures: Array<{ gate: string; reason: string }>;
108
+ }
109
+
110
+ const gateStats: GateStats & { layer1Retries: number } = {
111
+ layer1Rejections: 0,
112
+ layer2Rejections: 0,
113
+ layer3Rejections: 0,
114
+ layer1Retries: 0,
115
+ approvals: 0,
116
+ byGate: {}
117
+ };
118
+
119
+ const rejectionLog: GateRejectionLog[] = [];
120
+
121
+ const ERROR_CLASSIFICATION: Record<string, ErrorDifficulty> = {
122
+ 'E0425': 'easy', 'E0433': 'easy', 'E0432': 'easy', 'E0412': 'easy',
123
+ 'E0422': 'easy', 'E0599': 'easy', 'E0609': 'easy', 'E0616': 'easy',
124
+ 'E0624': 'easy', 'E0603': 'easy', 'E0559': 'easy',
125
+ 'E0308': 'medium', 'E0277': 'medium', 'E0061': 'medium', 'E0063': 'medium',
126
+ 'E0560': 'medium', 'E0369': 'medium', 'E0507': 'medium', 'E0515': 'medium',
127
+ 'E0596': 'medium', 'E0597': 'medium', 'E0283': 'medium', 'E0282': 'medium',
128
+ 'E0382': 'hard', 'E0499': 'hard', 'E0502': 'hard', 'E0505': 'hard',
129
+ };
130
+
131
+ // ============== REGRESSION SEED CORPUS ==============
132
+
133
+ /**
134
+ * Known-bad patterns that should ALWAYS be rejected.
135
+ * These are learned from previous verification agent failures.
136
+ */
137
+ const REGRESSION_SEEDS = [
138
+ {
139
+ pattern: /use\s+crate::\w*errors::/,
140
+ antiPattern: /use\s+crate::\w*error::/,
141
+ name: 'error vs errors module confusion',
142
+ description: 'Changed error to errors or vice versa'
143
+ },
144
+ {
145
+ pattern: /(\w+):\s*_,\s*\1:\s*_/,
146
+ name: 'duplicate field binding in match',
147
+ description: 'Same field bound twice in pattern'
148
+ },
149
+ {
150
+ pattern: /impl\s+\w+[^}]*\n\s*(enum|struct)\s+\w+/,
151
+ name: 'impl before type definition',
152
+ description: 'impl block appears to be inside enum/struct'
153
+ },
154
+ {
155
+ pattern: /enum\s+\w+\s*\{[^}]*impl\s+/,
156
+ name: 'impl inside enum',
157
+ description: 'impl block nested inside enum definition'
158
+ },
159
+ {
160
+ pattern: /as\s+usize\s*\)[^;]*\.get\s*\(/,
161
+ name: 'usize cast with Redis get',
162
+ description: 'Redis operations typically need i64, not usize'
163
+ },
164
+ {
165
+ pattern: /\.get\s*\([^)]*as\s+i64/,
166
+ name: 'i64 cast inside get call',
167
+ description: 'Cast should be outside the get call'
168
+ },
169
+ ];
170
+
171
+ /**
172
+ * Gate L: Regression Seed Check
173
+ * Validates that the fix doesn't introduce known-bad patterns
174
+ */
175
+ function gateRegressionSeeds(before: string, after: string): GateResult {
176
+ for (const seed of REGRESSION_SEEDS) {
177
+ const beforeHas = seed.pattern.test(before);
178
+ const afterHas = seed.pattern.test(after);
179
+
180
+ // Pattern introduced by fix
181
+ if (!beforeHas && afterHas) {
182
+ return {
183
+ passed: false,
184
+ reason: `Regression: ${seed.name} - ${seed.description}`,
185
+ riskLevel: 5
186
+ };
187
+ }
188
+
189
+ // Check anti-pattern (e.g., error -> errors swap)
190
+ if (seed.antiPattern) {
191
+ const beforeAnti = seed.antiPattern.test(before);
192
+ const afterAnti = seed.antiPattern.test(after);
193
+
194
+ if (beforeAnti && !afterAnti && afterHas) {
195
+ return {
196
+ passed: false,
197
+ reason: `Regression: ${seed.name} - swapped pattern`,
198
+ riskLevel: 5
199
+ };
200
+ }
201
+ }
202
+ }
203
+
204
+ return { passed: true, riskLevel: 1 };
205
+ }
206
+
207
+ // ============== LAYER 1: STRUCTURAL GATES (A-F from V1) ==============
208
+
209
+ /**
210
+ * Gate A: Line Count Delta Check
211
+ * Rejects fixes that change too many lines for the error type
212
+ */
213
+ function gateLineCountDelta(before: string, after: string, errorCode: string): GateResult {
214
+ const beforeLines = before.split('\n').length;
215
+ const afterLines = after.split('\n').length;
216
+ const delta = Math.abs(afterLines - beforeLines);
217
+
218
+ const importErrors = ['E0432', 'E0433', 'E0425', 'E0412'];
219
+ if (importErrors.includes(errorCode) && delta > 5) {
220
+ return { passed: false, reason: `Too many line changes (${delta}) for import fix`, riskLevel: 3 };
221
+ }
222
+
223
+ if (delta > 20) {
224
+ return { passed: false, reason: `Suspicious line count change: ${delta} lines`, riskLevel: 4 };
225
+ }
226
+
227
+ return { passed: true, riskLevel: delta > 10 ? 2 : 1 };
228
+ }
229
+
230
+ /**
231
+ * Gate B: Function Signature Preservation
232
+ * Rejects fixes that change function signatures far from the error
233
+ */
234
+ function gateFunctionSignature(before: string, after: string, errorLine: number): GateResult {
235
+ const fnPattern = /fn\s+(\w+)\s*(?:<[^>]*>)?\s*\([^)]*\)/g;
236
+
237
+ const beforeFns = new Map<string, { sig: string; line: number }>();
238
+ let match;
239
+ let lineNum = 1;
240
+
241
+ for (const line of before.split('\n')) {
242
+ fnPattern.lastIndex = 0;
243
+ while ((match = fnPattern.exec(line)) !== null) {
244
+ beforeFns.set(match[1], { sig: match[0], line: lineNum });
245
+ }
246
+ lineNum++;
247
+ }
248
+
249
+ lineNum = 1;
250
+ for (const line of after.split('\n')) {
251
+ fnPattern.lastIndex = 0;
252
+ while ((match = fnPattern.exec(line)) !== null) {
253
+ const existing = beforeFns.get(match[1]);
254
+ if (existing && existing.sig !== match[0]) {
255
+ if (Math.abs(existing.line - errorLine) > 15) {
256
+ return {
257
+ passed: false,
258
+ reason: `Function ${match[1]} signature changed but not near error`,
259
+ riskLevel: 4
260
+ };
261
+ }
262
+ }
263
+ }
264
+ lineNum++;
265
+ }
266
+
267
+ return { passed: true, riskLevel: 1 };
268
+ }
269
+
270
+ /**
271
+ * Gate C: Import Duplicate Check
272
+ * Rejects fixes that introduce duplicate use statements
273
+ */
274
+ function gateImportDuplicates(content: string): GateResult {
275
+ const useStatements = new Map<string, number[]>();
276
+ const lines = content.split('\n');
277
+
278
+ lines.forEach((line, idx) => {
279
+ const useMatch = line.match(/^\s*use\s+(.+);/);
280
+ if (useMatch) {
281
+ const key = useMatch[1].trim();
282
+ if (!useStatements.has(key)) useStatements.set(key, []);
283
+ useStatements.get(key)!.push(idx + 1);
284
+ }
285
+ });
286
+
287
+ for (const [stmt, lineNums] of useStatements) {
288
+ if (lineNums.length > 1) {
289
+ return {
290
+ passed: false,
291
+ reason: `Duplicate import "${stmt.substring(0, 40)}..." on lines ${lineNums.join(', ')}`,
292
+ riskLevel: 5
293
+ };
294
+ }
295
+ }
296
+
297
+ return { passed: true, riskLevel: 1 };
298
+ }
299
+
300
+ /**
301
+ * Gate D: Brace Balance Check
302
+ * Rejects fixes with unbalanced delimiters
303
+ */
304
+ function gateBraceBalance(content: string): GateResult {
305
+ let braceDepth = 0;
306
+ let parenDepth = 0;
307
+ let bracketDepth = 0;
308
+ const lines = content.split('\n');
309
+ let inString = false;
310
+ let inChar = false;
311
+
312
+ for (let i = 0; i < lines.length; i++) {
313
+ const line = lines[i];
314
+ for (let j = 0; j < line.length; j++) {
315
+ const char = line[j];
316
+ const prevChar = j > 0 ? line[j - 1] : '';
317
+
318
+ if (char === '"' && prevChar !== '\\') inString = !inString;
319
+ if (char === "'" && prevChar !== '\\' && !inString) inChar = !inChar;
320
+
321
+ if (!inString && !inChar) {
322
+ if (char === '{') braceDepth++;
323
+ if (char === '}') braceDepth--;
324
+ if (char === '(') parenDepth++;
325
+ if (char === ')') parenDepth--;
326
+ if (char === '[') bracketDepth++;
327
+ if (char === ']') bracketDepth--;
328
+ }
329
+ }
330
+
331
+ if (braceDepth < 0 || parenDepth < 0 || bracketDepth < 0) {
332
+ return { passed: false, reason: `Unbalanced delimiters at line ${i + 1}`, riskLevel: 5 };
333
+ }
334
+ }
335
+
336
+ if (braceDepth !== 0) {
337
+ return { passed: false, reason: `Unbalanced braces: ${braceDepth > 0 ? 'missing }' : 'extra }'}`, riskLevel: 5 };
338
+ }
339
+ if (parenDepth !== 0) {
340
+ return { passed: false, reason: `Unbalanced parentheses`, riskLevel: 5 };
341
+ }
342
+
343
+ return { passed: true, riskLevel: 1 };
344
+ }
345
+
346
+ /**
347
+ * Gate E: Semantic Diff Analysis
348
+ * Rejects fixes that duplicate existing code blocks
349
+ */
350
+ function gateSemanticDiff(before: string, after: string): GateResult {
351
+ const beforeLines = new Set(
352
+ before.split('\n')
353
+ .map(l => l.trim())
354
+ .filter(l => l.length > 15 && !l.startsWith('//') && !l.startsWith('use '))
355
+ );
356
+
357
+ const afterLines = after.split('\n');
358
+ let duplicateCount = 0;
359
+
360
+ for (const line of afterLines) {
361
+ const trimmed = line.trim();
362
+ if (trimmed.length > 15 && beforeLines.has(trimmed)) {
363
+ const count = afterLines.filter(l => l.trim() === trimmed).length;
364
+ const originalCount = before.split('\n').filter(l => l.trim() === trimmed).length;
365
+ if (count > originalCount) {
366
+ duplicateCount++;
367
+ }
368
+ }
369
+ }
370
+
371
+ if (duplicateCount > 3) {
372
+ return {
373
+ passed: false,
374
+ reason: `${duplicateCount} lines appear more times than in original`,
375
+ riskLevel: 4
376
+ };
377
+ }
378
+
379
+ return { passed: true, riskLevel: duplicateCount > 0 ? 2 : 1 };
380
+ }
381
+
382
+ /**
383
+ * Gate F: Orphaned Code Detection
384
+ * Detects semicolons breaking method chains or orphaned pattern fields
385
+ */
386
+ function gateOrphanedCode(content: string): GateResult {
387
+ const lines = content.split('\n');
388
+
389
+ for (let i = 0; i < lines.length - 1; i++) {
390
+ const line = lines[i].trim();
391
+ const nextLine = lines[i + 1]?.trim() || '';
392
+
393
+ if (line.endsWith(';') && nextLine.startsWith('.')) {
394
+ return { passed: false, reason: `Semicolon breaks method chain at line ${i + 1}`, riskLevel: 5 };
395
+ }
396
+
397
+ if (line.match(/\}\s*=>\s*[\(\{]/) && nextLine.match(/^\w+:\s*_,?$/)) {
398
+ return { passed: false, reason: `Orphaned field pattern at line ${i + 2}`, riskLevel: 5 };
399
+ }
400
+ }
401
+
402
+ return { passed: true, riskLevel: 1 };
403
+ }
404
+
405
+ // ============== LAYER 1: NEW SEMANTIC GATES (G-K) ==============
406
+
407
+ /**
408
+ * Find crate root directory from a file path
409
+ */
410
+ function findCrateRoot(filePath: string, projectPath: string): string | null {
411
+ const parts = filePath.split('/');
412
+ for (let i = parts.length - 1; i >= 0; i--) {
413
+ const testPath = path.join(projectPath, ...parts.slice(0, i + 1), 'Cargo.toml');
414
+ if (fs.existsSync(testPath)) {
415
+ return path.join(projectPath, ...parts.slice(0, i + 1));
416
+ }
417
+ }
418
+ return null;
419
+ }
420
+
421
+ /**
422
+ * Gate G: Import Path Validator
423
+ * Validates that `use crate::...` paths match actual filesystem/module structure
424
+ */
425
+ function gateImportPath(before: string, after: string, filePath: string): GateResult {
426
+ const beforeImports = new Set(
427
+ before.split('\n')
428
+ .filter(l => l.match(/^\s*use\s+/))
429
+ .map(l => l.trim())
430
+ );
431
+
432
+ const afterLines = after.split('\n');
433
+ const newImports: string[] = [];
434
+
435
+ for (const line of afterLines) {
436
+ const trimmed = line.trim();
437
+ if (trimmed.match(/^use\s+/) && !beforeImports.has(trimmed)) {
438
+ newImports.push(trimmed);
439
+ }
440
+ }
441
+
442
+ const crateDir = findCrateRoot(filePath, CONFIG.projectPath);
443
+ if (!crateDir) return { passed: true, riskLevel: 1 };
444
+
445
+ for (const imp of newImports) {
446
+ // Check crate imports
447
+ const crateMatch = imp.match(/use\s+crate::(\w+)/);
448
+ if (crateMatch) {
449
+ const moduleName = crateMatch[1];
450
+
451
+ const modFile = path.join(crateDir, 'src', `${moduleName}.rs`);
452
+ const modDir = path.join(crateDir, 'src', moduleName, 'mod.rs');
453
+ const libPath = path.join(crateDir, 'src', 'lib.rs');
454
+ const mainPath = path.join(crateDir, 'src', 'main.rs');
455
+
456
+ const moduleExists = fs.existsSync(modFile) || fs.existsSync(modDir);
457
+
458
+ if (!moduleExists) {
459
+ // Check if module is declared in lib.rs or main.rs
460
+ let isDeclared = false;
461
+ for (const entryPath of [libPath, mainPath]) {
462
+ if (fs.existsSync(entryPath)) {
463
+ try {
464
+ const content = fs.readFileSync(entryPath, 'utf-8');
465
+ if (content.includes(`mod ${moduleName}`) || content.includes(`pub mod ${moduleName}`)) {
466
+ isDeclared = true;
467
+ break;
468
+ }
469
+ } catch {}
470
+ }
471
+ }
472
+
473
+ if (!isDeclared) {
474
+ return {
475
+ passed: false,
476
+ reason: `Import references non-existent module: crate::${moduleName}`,
477
+ riskLevel: 5
478
+ };
479
+ }
480
+ }
481
+ }
482
+
483
+ // Check for error vs errors confusion
484
+ if (imp.includes('::error::') || imp.includes('::errors::')) {
485
+ const hasError = before.includes('::error::');
486
+ const hasErrors = before.includes('::errors::');
487
+ const newHasError = imp.includes('::error::');
488
+ const newHasErrors = imp.includes('::errors::');
489
+
490
+ if (hasError && newHasErrors && !hasErrors) {
491
+ return {
492
+ passed: false,
493
+ reason: `Import changed 'error' to 'errors' - likely incorrect`,
494
+ riskLevel: 5
495
+ };
496
+ }
497
+ if (hasErrors && newHasError && !hasError) {
498
+ return {
499
+ passed: false,
500
+ reason: `Import changed 'errors' to 'error' - likely incorrect`,
501
+ riskLevel: 5
502
+ };
503
+ }
504
+ }
505
+ }
506
+
507
+ return { passed: true, riskLevel: 1 };
508
+ }
509
+
510
+ /**
511
+ * Gate H: Pattern Duplicate Detector
512
+ * Detects duplicate field bindings in match patterns like `field: _, field: _`
513
+ */
514
+ function gatePatternDuplicates(content: string): GateResult {
515
+ const lines = content.split('\n');
516
+
517
+ for (let i = 0; i < lines.length; i++) {
518
+ const line = lines[i];
519
+
520
+ // Look for pattern lines with field bindings
521
+ if (line.includes('=>') || line.match(/\{\s*\w+:\s*[_\w]/)) {
522
+ // Extract all field names in pattern (field: _ or field: value)
523
+ const fieldMatches = [...line.matchAll(/(\w+)\s*:\s*[_\w]/g)];
524
+ const fields: string[] = [];
525
+
526
+ for (const match of fieldMatches) {
527
+ const field = match[1];
528
+ // Skip common keywords
529
+ if (['ref', 'mut', 'box'].includes(field)) continue;
530
+
531
+ if (fields.includes(field)) {
532
+ return {
533
+ passed: false,
534
+ reason: `Duplicate field binding '${field}' in match pattern at line ${i + 1}`,
535
+ riskLevel: 5
536
+ };
537
+ }
538
+ fields.push(field);
539
+ }
540
+ }
541
+ }
542
+
543
+ return { passed: true, riskLevel: 1 };
544
+ }
545
+
546
+ /**
547
+ * Gate I: Impl Location Checker
548
+ * Ensures impl blocks are not nested inside enum/struct definitions
549
+ */
550
+ function gateImplLocation(content: string): GateResult {
551
+ const lines = content.split('\n');
552
+ let depth = 0;
553
+ let inEnumOrStruct = false;
554
+ let enumStructName = '';
555
+ let enumStructStart = 0;
556
+ let enumStructDepth = 0;
557
+
558
+ for (let i = 0; i < lines.length; i++) {
559
+ const line = lines[i];
560
+ const trimmed = line.trim();
561
+
562
+ // Track enum/struct definitions (not impl blocks)
563
+ const typeMatch = trimmed.match(/^(pub\s+)?(enum|struct)\s+(\w+)/);
564
+ if (typeMatch && !trimmed.includes(';')) {
565
+ // Only track if this starts a block (has { or will have { on next line)
566
+ if (trimmed.includes('{') || (i < lines.length - 1 && lines[i + 1].trim().startsWith('{'))) {
567
+ inEnumOrStruct = true;
568
+ enumStructName = typeMatch[3];
569
+ enumStructStart = i + 1;
570
+ enumStructDepth = depth;
571
+ }
572
+ }
573
+
574
+ // Count braces
575
+ for (const char of line) {
576
+ if (char === '{') depth++;
577
+ if (char === '}') depth--;
578
+ }
579
+
580
+ // Exit enum/struct when we return to original depth
581
+ if (inEnumOrStruct && depth <= enumStructDepth && trimmed.includes('}')) {
582
+ inEnumOrStruct = false;
583
+ }
584
+
585
+ // Check for impl inside enum/struct
586
+ if (inEnumOrStruct && depth > enumStructDepth && trimmed.match(/^impl\s+/)) {
587
+ return {
588
+ passed: false,
589
+ reason: `impl block found inside ${enumStructName} definition (line ${enumStructStart})`,
590
+ riskLevel: 5
591
+ };
592
+ }
593
+ }
594
+
595
+ return { passed: true, riskLevel: 1 };
596
+ }
597
+
598
+ /**
599
+ * Gate J: Type Cast Validator
600
+ * Detects suspicious type cast changes (e.g., `as i64` <-> `as usize`)
601
+ */
602
+ function gateTypeCast(before: string, after: string): GateResult {
603
+ const castPattern = /as\s+(i8|i16|i32|i64|i128|u8|u16|u32|u64|u128|usize|isize|f32|f64)/g;
604
+
605
+ const beforeCasts = [...before.matchAll(castPattern)];
606
+ const afterCasts = [...after.matchAll(castPattern)];
607
+
608
+ const beforeFreq: Record<string, number> = {};
609
+ const afterFreq: Record<string, number> = {};
610
+
611
+ for (const m of beforeCasts) beforeFreq[m[1]] = (beforeFreq[m[1]] || 0) + 1;
612
+ for (const m of afterCasts) afterFreq[m[1]] = (afterFreq[m[1]] || 0) + 1;
613
+
614
+ // Check for suspicious swaps
615
+ const suspiciousSwaps = [
616
+ ['i64', 'usize'],
617
+ ['usize', 'i64'],
618
+ ['i32', 'usize'],
619
+ ['usize', 'i32'],
620
+ ];
621
+
622
+ for (const [from, to] of suspiciousSwaps) {
623
+ const beforeFrom = beforeFreq[from] || 0;
624
+ const afterFrom = afterFreq[from] || 0;
625
+ const beforeTo = beforeFreq[to] || 0;
626
+ const afterTo = afterFreq[to] || 0;
627
+
628
+ // Cast type decreased while other increased
629
+ if (beforeFrom > afterFrom && afterTo > beforeTo) {
630
+ return {
631
+ passed: false,
632
+ reason: `Suspicious cast change: 'as ${from}' -> 'as ${to}'`,
633
+ riskLevel: 4
634
+ };
635
+ }
636
+ }
637
+
638
+ return { passed: true, riskLevel: 1 };
639
+ }
640
+
641
+ /**
642
+ * Gate K: Match Arm Validator
643
+ * Validates match block structure wasn't significantly altered
644
+ */
645
+ function gateMatchArm(before: string, after: string): GateResult {
646
+ // Count match blocks
647
+ const matchCount = (s: string) => (s.match(/\bmatch\s+\w+/g) || []).length;
648
+ const beforeCount = matchCount(before);
649
+ const afterCount = matchCount(after);
650
+
651
+ if (Math.abs(beforeCount - afterCount) > 2) {
652
+ return {
653
+ passed: false,
654
+ reason: `Match block count changed significantly: ${beforeCount} -> ${afterCount}`,
655
+ riskLevel: 3
656
+ };
657
+ }
658
+
659
+ // Check for orphaned match arms (=> without match)
660
+ const afterLines = after.split('\n');
661
+ for (let i = 0; i < afterLines.length; i++) {
662
+ const line = afterLines[i].trim();
663
+ if (line.match(/^\w+\s*=>\s*\{?$/) && i > 0) {
664
+ // Look backward for a match statement
665
+ let foundMatch = false;
666
+ for (let j = i - 1; j >= Math.max(0, i - 20); j--) {
667
+ if (afterLines[j].includes('match ')) {
668
+ foundMatch = true;
669
+ break;
670
+ }
671
+ if (afterLines[j].trim().startsWith('fn ') || afterLines[j].trim().startsWith('impl ')) {
672
+ break;
673
+ }
674
+ }
675
+ if (!foundMatch) {
676
+ return {
677
+ passed: false,
678
+ reason: `Orphaned match arm at line ${i + 1}`,
679
+ riskLevel: 4
680
+ };
681
+ }
682
+ }
683
+ }
684
+
685
+ return { passed: true, riskLevel: 1 };
686
+ }
687
+
688
+ // ============== RUN ALL LAYER 1 GATES ==============
689
+
690
+ interface GateDefinition {
691
+ name: string;
692
+ check: () => GateResult;
693
+ }
694
+
695
+ function runLayer1Gates(
696
+ before: string,
697
+ after: string,
698
+ errorCode: string,
699
+ errorLine: number,
700
+ filePath: string
701
+ ): GateResult {
702
+ const gates: GateDefinition[] = [
703
+ // Original gates A-F
704
+ { name: 'LineCount', check: () => gateLineCountDelta(before, after, errorCode) },
705
+ { name: 'FnSignature', check: () => gateFunctionSignature(before, after, errorLine) },
706
+ { name: 'ImportDup', check: () => gateImportDuplicates(after) },
707
+ { name: 'BraceBalance', check: () => gateBraceBalance(after) },
708
+ { name: 'SemanticDiff', check: () => gateSemanticDiff(before, after) },
709
+ { name: 'OrphanedCode', check: () => gateOrphanedCode(after) },
710
+ // New gates G-L
711
+ { name: 'ImportPath', check: () => gateImportPath(before, after, filePath) },
712
+ { name: 'PatternDup', check: () => gatePatternDuplicates(after) },
713
+ { name: 'ImplLocation', check: () => gateImplLocation(after) },
714
+ { name: 'TypeCast', check: () => gateTypeCast(before, after) },
715
+ { name: 'MatchArm', check: () => gateMatchArm(before, after) },
716
+ { name: 'Regression', check: () => gateRegressionSeeds(before, after) },
717
+ ];
718
+
719
+ let maxRisk: 1 | 2 | 3 | 4 | 5 = 1;
720
+
721
+ for (const gate of gates) {
722
+ const result = gate.check();
723
+ if (!result.passed) {
724
+ if (CONFIG.verbose) {
725
+ console.log(` [L1] ${gate.name}: ${result.reason}`);
726
+ }
727
+ gateStats.byGate[gate.name] = (gateStats.byGate[gate.name] || 0) + 1;
728
+ return { ...result, reason: `[${gate.name}] ${result.reason}` };
729
+ }
730
+ maxRisk = Math.max(maxRisk, result.riskLevel) as 1 | 2 | 3 | 4 | 5;
731
+ }
732
+
733
+ return { passed: true, riskLevel: maxRisk };
734
+ }
735
+
736
+ // ============== LAYER 2: COMPILATION VALIDATION ==============
737
+
738
+ function getPackageName(filePath: string): string {
739
+ const parts = filePath.split('/');
740
+ for (let i = parts.length - 1; i >= 0; i--) {
741
+ const cargoPath = path.join(CONFIG.projectPath, ...parts.slice(0, i + 1), 'Cargo.toml');
742
+ if (fs.existsSync(cargoPath)) {
743
+ try {
744
+ const content = fs.readFileSync(cargoPath, 'utf-8');
745
+ const match = content.match(/name\s*=\s*"([^"]+)"/);
746
+ if (match) return match[1];
747
+ } catch {}
748
+ }
749
+ }
750
+ return '';
751
+ }
752
+
753
+ function runTargetedCargoCheck(affectedFiles: string[]): { errors: Map<string, RustError[]>; totalCount: number } {
754
+ const packages = new Set<string>();
755
+ for (const file of affectedFiles) {
756
+ const pkg = getPackageName(file);
757
+ if (pkg) packages.add(pkg);
758
+ }
759
+
760
+ if (packages.size === 0) return runCargoCheck();
761
+
762
+ const pkgArgs = [...packages].map(p => `-p ${p}`).join(' ');
763
+ try {
764
+ execSync(`SQLX_OFFLINE=true cargo check ${pkgArgs} 2>&1`, {
765
+ cwd: CONFIG.projectPath,
766
+ encoding: 'utf-8',
767
+ maxBuffer: 50 * 1024 * 1024,
768
+ });
769
+ return { errors: new Map(), totalCount: 0 };
770
+ } catch (error: any) {
771
+ const errors = parseCargoErrors(error.stdout || error.stderr || '');
772
+ let totalCount = 0;
773
+ for (const e of errors.values()) totalCount += e.length;
774
+ return { errors, totalCount };
775
+ }
776
+ }
777
+
778
+ function runClippyCheck(filePath: string): { warnings: number; critical: string[] } {
779
+ if (!CONFIG.enableClippy) return { warnings: 0, critical: [] };
780
+
781
+ const pkg = getPackageName(filePath);
782
+ if (!pkg) return { warnings: 0, critical: [] };
783
+
784
+ try {
785
+ execSync(
786
+ `SQLX_OFFLINE=true cargo clippy -p ${pkg} -- -W clippy::match_same_arms -W clippy::if_same_then_else 2>&1`,
787
+ { cwd: CONFIG.projectPath, encoding: 'utf-8', maxBuffer: 50 * 1024 * 1024 }
788
+ );
789
+ return { warnings: 0, critical: [] };
790
+ } catch (error: any) {
791
+ const output = error.stdout || error.stderr || '';
792
+ const warnings = (output.match(/warning:/g) || []).length;
793
+
794
+ const criticalPatterns = [
795
+ { pattern: /match_same_arms/, name: 'match_same_arms' },
796
+ { pattern: /if_same_then_else/, name: 'if_same_then_else' },
797
+ { pattern: /redundant_clone/, name: 'redundant_clone' },
798
+ { pattern: /duplicate_mod/, name: 'duplicate_mod' },
799
+ ];
800
+
801
+ const critical: string[] = [];
802
+ for (const { pattern, name } of criticalPatterns) {
803
+ if (pattern.test(output)) {
804
+ critical.push(name);
805
+ }
806
+ }
807
+
808
+ return { warnings, critical };
809
+ }
810
+ }
811
+
812
+ // ============== LAYER 3: ENHANCED LLM REVIEW ==============
813
+
814
+ async function llmReviewGate(
815
+ client: Cerebras,
816
+ originalCode: string,
817
+ fixedCode: string,
818
+ errorMessage: string,
819
+ filePath: string
820
+ ): Promise<ReviewResult> {
821
+ const beforeContext = originalCode.split('\n').slice(0, 150).join('\n');
822
+ const afterContext = fixedCode.split('\n').slice(0, 150).join('\n');
823
+
824
+ const reviewPrompt = `ROLE: Strict Code Review Gate with Checklist
825
+
826
+ CHECKLIST - REJECT if ANY violation:
827
+ 1. Import paths match filesystem (no 'error' vs 'errors' confusion)
828
+ 2. No duplicate field bindings in match patterns
829
+ 3. Type casts unchanged unless error explicitly requires it
830
+ 4. No impl blocks inside enum/struct definitions
831
+ 5. All added imports reference modules that exist
832
+ 6. Match block count unchanged
833
+ 7. No semantic behavior changes beyond the error fix
834
+
835
+ ERROR: ${errorMessage}
836
+ FILE: ${filePath}
837
+
838
+ BEFORE:
839
+ \`\`\`rust
840
+ ${beforeContext}
841
+ \`\`\`
842
+
843
+ AFTER:
844
+ \`\`\`rust
845
+ ${afterContext}
846
+ \`\`\`
847
+
848
+ Instructions:
849
+ - Review the diff against each checklist item
850
+ - If ANY violation found, output REJECT with the LINE NUMBER
851
+ - Only APPROVE if all 7 checklist items pass
852
+
853
+ Output ONLY valid JSON:
854
+ {"verdict":"APPROVE"|"REJECT","reason":"<cite line numbers if rejecting>","riskLevel":1-5}`;
855
+
856
+ try {
857
+ const response = await client.chat.completions.create({
858
+ model: CONFIG.model,
859
+ messages: [{ role: 'user', content: reviewPrompt }],
860
+ max_completion_tokens: 200,
861
+ temperature: 0.0,
862
+ });
863
+
864
+ const content = (response as any).choices?.[0]?.message?.content || '';
865
+ const jsonMatch = content.match(/\{[\s\S]*\}/);
866
+
867
+ if (jsonMatch) {
868
+ try {
869
+ const parsed = JSON.parse(jsonMatch[0]);
870
+ return {
871
+ verdict: parsed.verdict === 'APPROVE' ? 'APPROVE' : 'REJECT',
872
+ reason: String(parsed.reason || 'Unknown').substring(0, 100),
873
+ riskLevel: Math.min(5, Math.max(1, Number(parsed.riskLevel) || 3)) as 1 | 2 | 3 | 4 | 5,
874
+ };
875
+ } catch {}
876
+ }
877
+
878
+ // Default to REJECT if can't parse (fail-safe)
879
+ return { verdict: 'REJECT', reason: 'Could not parse review response', riskLevel: 4 };
880
+ } catch (error: any) {
881
+ console.log(` [L3] Review API error`);
882
+ return { verdict: 'REJECT', reason: 'API error', riskLevel: 3 };
883
+ }
884
+ }
885
+
886
+ // ============== CORE FUNCTIONS ==============
887
+
888
+ function loadCerebrasKey(): string {
889
+ // First check environment variable (preferred)
890
+ if (process.env.CEREBRAS_API_KEY) {
891
+ return process.env.CEREBRAS_API_KEY;
892
+ }
893
+
894
+ // Fallback: look for .env in project directory or current directory
895
+ const envPaths = [
896
+ path.join(CONFIG.projectPath, '.env'),
897
+ path.join(CONFIG.projectPath, '../.env'),
898
+ path.join(process.cwd(), '.env'),
899
+ ];
900
+ for (const envPath of envPaths) {
901
+ try {
902
+ const content = fs.readFileSync(envPath, 'utf-8');
903
+ const match = content.match(/CEREBRAS_API_KEY=([^\r\n]+)/);
904
+ if (match) return match[1].trim();
905
+ } catch {}
906
+ }
907
+ return '';
908
+ }
909
+
910
+ function parseCargoErrors(output: string): Map<string, RustError[]> {
911
+ const errorsByFile = new Map<string, RustError[]>();
912
+ const lines = output.split('\n');
913
+
914
+ for (let i = 0; i < lines.length; i++) {
915
+ const fileMatch = lines[i].match(/^\s*-->\s+(.+):(\d+):(\d+)/);
916
+ if (!fileMatch) continue;
917
+
918
+ const [, filePath, lineNum, colNum] = fileMatch;
919
+ let code = '', message = '', suggestion = '';
920
+
921
+ for (let j = i - 1; j >= Math.max(0, i - 15); j--) {
922
+ const errorMatch = lines[j].match(/error\[(E\d{4})\]:\s*(.+)/);
923
+ if (errorMatch) {
924
+ code = errorMatch[1];
925
+ message = errorMatch[2];
926
+ break;
927
+ }
928
+ }
929
+
930
+ for (let j = i + 1; j < Math.min(lines.length, i + 20); j++) {
931
+ if (lines[j].includes('help:')) {
932
+ suggestion = lines[j].replace(/.*help:\s*/, '').trim();
933
+ break;
934
+ }
935
+ if (lines[j].match(/^error\[/)) break;
936
+ }
937
+
938
+ if (code && message) {
939
+ if (!errorsByFile.has(filePath)) errorsByFile.set(filePath, []);
940
+ errorsByFile.get(filePath)!.push({
941
+ code,
942
+ line: parseInt(lineNum, 10),
943
+ column: parseInt(colNum, 10),
944
+ message,
945
+ suggestion,
946
+ difficulty: ERROR_CLASSIFICATION[code] || 'medium',
947
+ });
948
+ }
949
+ }
950
+ return errorsByFile;
951
+ }
952
+
953
+ function runCargoCheck(): { errors: Map<string, RustError[]>; totalCount: number } {
954
+ try {
955
+ execSync(`SQLX_OFFLINE=true cargo check 2>&1`, {
956
+ cwd: CONFIG.projectPath,
957
+ encoding: 'utf-8',
958
+ maxBuffer: 50 * 1024 * 1024,
959
+ });
960
+ return { errors: new Map(), totalCount: 0 };
961
+ } catch (error: any) {
962
+ const errors = parseCargoErrors(error.stdout || error.stderr || '');
963
+ let totalCount = 0;
964
+ for (const e of errors.values()) totalCount += e.length;
965
+ return { errors, totalCount };
966
+ }
967
+ }
968
+
969
+ function applyLineFixes(content: string, fixes: LineFix[]): string {
970
+ const lines = content.split('\n');
971
+ const sortedFixes = [...fixes].sort((a, b) => {
972
+ if (b.line !== a.line) return b.line - a.line;
973
+ const priority = { insert_before: 0, insert_after: 1, replace: 2, delete: 3 };
974
+ return priority[a.action] - priority[b.action];
975
+ });
976
+
977
+ const seenLines = new Set<string>();
978
+ const dedupedFixes = sortedFixes.filter(f => {
979
+ const key = `${f.line}-${f.action}`;
980
+ if (seenLines.has(key)) return false;
981
+ seenLines.add(key);
982
+ return true;
983
+ });
984
+
985
+ for (const fix of dedupedFixes) {
986
+ const idx = fix.line - 1;
987
+ if (idx < 0 || idx >= lines.length + 10) continue;
988
+
989
+ switch (fix.action) {
990
+ case 'replace': if (idx < lines.length) lines[idx] = fix.content; break;
991
+ case 'insert_after': lines.splice(idx + 1, 0, fix.content); break;
992
+ case 'insert_before': lines.splice(idx, 0, fix.content); break;
993
+ case 'delete': if (idx < lines.length) lines.splice(idx, 1); break;
994
+ }
995
+ }
996
+ return lines.join('\n');
997
+ }
998
+
999
+ function getCrateContext(filePath: string): string {
1000
+ const crateDir = findCrateRoot(filePath, CONFIG.projectPath);
1001
+ if (!crateDir) return '';
1002
+
1003
+ let context = '';
1004
+
1005
+ const libPath = path.join(crateDir, 'src', 'lib.rs');
1006
+ const mainPath = path.join(crateDir, 'src', 'main.rs');
1007
+ const entryPath = fs.existsSync(libPath) ? libPath : (fs.existsSync(mainPath) ? mainPath : '');
1008
+
1009
+ if (entryPath) {
1010
+ try {
1011
+ const content = fs.readFileSync(entryPath, 'utf-8');
1012
+ const lines = content.split('\n');
1013
+ const exports = lines.slice(0, 100).filter(l =>
1014
+ l.match(/^pub\s+(mod|use|struct|enum|type|trait|fn)\s+/) ||
1015
+ l.match(/^mod\s+\w+;/)
1016
+ );
1017
+ if (exports.length > 0) {
1018
+ context += `\nCRATE EXPORTS:\n${exports.join('\n')}\n`;
1019
+ }
1020
+ } catch {}
1021
+ }
1022
+
1023
+ return context;
1024
+ }
1025
+
1026
+ function parseJsonResponse(response: string): LineFix[] | null {
1027
+ const patterns = [/\[\s*\{[\s\S]*?\}\s*\]/g, /```json\s*([\s\S]*?)\s*```/, /```\s*([\s\S]*?)\s*```/];
1028
+ for (const pattern of patterns) {
1029
+ const match = response.match(pattern);
1030
+ if (match) {
1031
+ try {
1032
+ const parsed = JSON.parse(match[1] || match[0]);
1033
+ if (Array.isArray(parsed)) {
1034
+ return parsed.filter(f =>
1035
+ typeof f.line === 'number' &&
1036
+ ['replace', 'insert_after', 'insert_before', 'delete'].includes(f.action) &&
1037
+ typeof f.content === 'string'
1038
+ );
1039
+ }
1040
+ } catch {}
1041
+ }
1042
+ }
1043
+ return null;
1044
+ }
1045
+
1046
+ function buildPrompt(error: RustError, fileContent: string, filePath: string, feedback?: string, layer1Context?: Layer1RetryContext): string {
1047
+ const lines = fileContent.split('\n');
1048
+ const contextSize = 20;
1049
+ const start = Math.max(0, error.line - contextSize - 1);
1050
+ const end = Math.min(lines.length, error.line + contextSize);
1051
+
1052
+ const errorContext = lines.slice(start, end).map((line, i) => {
1053
+ const num = start + i + 1;
1054
+ const marker = num === error.line ? ' >>> ' : ' ';
1055
+ return `${num}:${marker}${line}`;
1056
+ }).join('\n');
1057
+
1058
+ const imports = lines.filter(l =>
1059
+ l.startsWith('use ') || l.startsWith('pub use ') ||
1060
+ l.startsWith('mod ') || l.startsWith('pub mod ')
1061
+ ).slice(0, 60).join('\n');
1062
+
1063
+ const crateContext = getCrateContext(filePath);
1064
+
1065
+ // Build Layer 1 failure feedback if retrying
1066
+ let layer1Feedback = '';
1067
+ if (layer1Context && layer1Context.previousFailures.length > 0) {
1068
+ layer1Feedback = `
1069
+ PREVIOUS LAYER 1 GATE FAILURES (attempt ${layer1Context.attempt}/${CONFIG.maxLayer1Retries}):
1070
+ ${layer1Context.previousFailures.map((f, i) => ` ${i + 1}. [${f.gate}] ${f.reason}`).join('\n')}
1071
+
1072
+ Your previous fix was REJECTED by these structural validation gates. You MUST:
1073
+ - Avoid the specific issues mentioned above
1074
+ - Generate a DIFFERENT fix that passes these gates
1075
+ - If Gate BraceBalance failed: ensure all {}, (), [] are balanced
1076
+ - If Gate ImportDup failed: do NOT add imports that already exist
1077
+ - If Gate FnSignature failed: do NOT change function signatures
1078
+ - If Gate SemanticDiff failed: do NOT duplicate existing code
1079
+ - If Gate ImportPath failed: verify module paths exist
1080
+ - If Gate PatternDup failed: no duplicate field bindings in match
1081
+
1082
+ `;
1083
+ }
1084
+
1085
+ // HARDENED PROMPT with explicit preservation rules
1086
+ const prompt = `Fix this Rust error. Return ONLY JSON array.
1087
+ ${layer1Feedback}
1088
+
1089
+ ERROR: [${error.code}] ${error.message}
1090
+ ${error.suggestion ? `HINT: ${error.suggestion}` : ''}
1091
+ FILE: ${filePath}
1092
+
1093
+ CURRENT IMPORTS:
1094
+ ${imports}
1095
+ ${crateContext}
1096
+ CODE (line ${error.line}):
1097
+ ${errorContext}
1098
+
1099
+ CRITICAL RULES (VIOLATIONS WILL BE REJECTED):
1100
+ 1. PRESERVE EXACT MODULE PATHS - Do not change 'error' to 'errors' or vice versa
1101
+ 2. NO DUPLICATE IMPORTS - Never add an import that already exists
1102
+ 3. NO DUPLICATE PATTERN BINDINGS - Never use same field twice in a match pattern
1103
+ 4. KEEP TYPE CASTS UNCHANGED - Do not change 'as i64' to 'as usize' unless error requires it
1104
+ 5. NO IMPL INSIDE ENUM/STRUCT - impl blocks must be outside type definitions
1105
+ 6. IMPORTS MUST EXIST - Only add imports for modules declared in lib.rs/mod.rs
1106
+ 7. PRESERVE FUNCTION SIGNATURES - Don't change fn signatures unless error requires it
1107
+ 8. FAIL-SAFE - Return [] if uncertain about the fix
1108
+
1109
+ ${feedback ? `PREVIOUS FIX FAILED: ${feedback}\nAdjust your fix accordingly.\n` : ''}
1110
+ OUTPUT: JSON array only
1111
+ [{"line": N, "action": "replace"|"insert_after"|"insert_before"|"delete", "content": "exact line"}]
1112
+
1113
+ Return [] if unsure or if fix requires significant changes.
1114
+ JSON:`;
1115
+
1116
+ return prompt;
1117
+ }
1118
+
1119
+ async function processInChunks<T, R>(
1120
+ items: T[],
1121
+ processor: (item: T) => Promise<R>,
1122
+ concurrency: number
1123
+ ): Promise<R[]> {
1124
+ const results: R[] = [];
1125
+ for (let i = 0; i < items.length; i += concurrency) {
1126
+ const chunk = items.slice(i, i + concurrency);
1127
+ const chunkResults = await Promise.all(chunk.map(processor));
1128
+ results.push(...chunkResults);
1129
+ }
1130
+ return results;
1131
+ }
1132
+
1133
+ async function getLLMFix(
1134
+ client: Cerebras,
1135
+ error: RustError,
1136
+ fileContent: string,
1137
+ filePath: string,
1138
+ feedback?: string,
1139
+ layer1Context?: Layer1RetryContext
1140
+ ): Promise<LLMFixResult> {
1141
+ const prompt = buildPrompt(error, fileContent, filePath, feedback, layer1Context);
1142
+
1143
+ try {
1144
+ const response = await client.chat.completions.create({
1145
+ model: CONFIG.model,
1146
+ messages: [{ role: 'user', content: prompt }],
1147
+ max_completion_tokens: CONFIG.maxTokens,
1148
+ temperature: 0.1,
1149
+ });
1150
+
1151
+ const content = (response as any).choices?.[0]?.message?.content || '';
1152
+ const fixes = parseJsonResponse(content);
1153
+
1154
+ return {
1155
+ error,
1156
+ fixes: fixes || [],
1157
+ success: fixes !== null && fixes.length > 0,
1158
+ };
1159
+ } catch (err: any) {
1160
+ return { error, fixes: [], success: false };
1161
+ }
1162
+ }
1163
+
1164
+ function generateUnifiedDiff(before: string, after: string, filePath: string): string {
1165
+ const beforeLines = before.split('\n');
1166
+ const afterLines = after.split('\n');
1167
+
1168
+ let diff = `--- a/${filePath}\n+++ b/${filePath}\n`;
1169
+
1170
+ // Simple line-by-line diff (not a true unified diff, but useful)
1171
+ const maxLines = Math.max(beforeLines.length, afterLines.length);
1172
+ let inHunk = false;
1173
+ let hunkStart = 0;
1174
+ let hunkLines: string[] = [];
1175
+
1176
+ for (let i = 0; i < maxLines; i++) {
1177
+ const beforeLine = beforeLines[i] || '';
1178
+ const afterLine = afterLines[i] || '';
1179
+
1180
+ if (beforeLine !== afterLine) {
1181
+ if (!inHunk) {
1182
+ inHunk = true;
1183
+ hunkStart = i + 1;
1184
+ hunkLines = [`@@ -${hunkStart},3 +${hunkStart},3 @@`];
1185
+ }
1186
+ if (beforeLines[i] !== undefined) hunkLines.push(`-${beforeLine}`);
1187
+ if (afterLines[i] !== undefined) hunkLines.push(`+${afterLine}`);
1188
+ } else {
1189
+ if (inHunk) {
1190
+ hunkLines.push(` ${beforeLine}`);
1191
+ if (hunkLines.length > 10) {
1192
+ diff += hunkLines.join('\n') + '\n';
1193
+ inHunk = false;
1194
+ hunkLines = [];
1195
+ }
1196
+ }
1197
+ }
1198
+ }
1199
+
1200
+ if (hunkLines.length > 0) {
1201
+ diff += hunkLines.join('\n') + '\n';
1202
+ }
1203
+
1204
+ return diff;
1205
+ }
1206
+
1207
+ async function processFileWithGates(
1208
+ client: Cerebras,
1209
+ filePath: string,
1210
+ errors: RustError[],
1211
+ feedback?: Map<number, string>
1212
+ ): Promise<{ applied: number; content: string }> {
1213
+ const fullPath = path.join(CONFIG.projectPath, filePath);
1214
+ const originalContent = fs.readFileSync(fullPath, 'utf-8');
1215
+
1216
+ const fixableErrors = errors.filter(e => e.difficulty !== 'hard');
1217
+ if (fixableErrors.length === 0) {
1218
+ return { applied: 0, content: originalContent };
1219
+ }
1220
+
1221
+ // Layer 1 retry context for tracking failures across attempts
1222
+ const layer1RetryContext: Layer1RetryContext = {
1223
+ attempt: 0,
1224
+ previousFailures: []
1225
+ };
1226
+
1227
+ let candidateContent = '';
1228
+ let successCount = 0;
1229
+ let layer1RiskLevel: 1 | 2 | 3 | 4 | 5 = 1;
1230
+
1231
+ // ===== LAYER 1 RETRY LOOP =====
1232
+ while (layer1RetryContext.attempt < CONFIG.maxLayer1Retries) {
1233
+ layer1RetryContext.attempt++;
1234
+
1235
+ // Get LLM fixes (with retry context if not first attempt)
1236
+ const llmResults = await processInChunks(
1237
+ fixableErrors,
1238
+ (error) => getLLMFix(
1239
+ client,
1240
+ error,
1241
+ originalContent,
1242
+ filePath,
1243
+ feedback?.get(error.line),
1244
+ layer1RetryContext.attempt > 1 ? layer1RetryContext : undefined
1245
+ ),
1246
+ CONFIG.parallelLLMCalls
1247
+ );
1248
+
1249
+ const allFixes: LineFix[] = [];
1250
+ successCount = 0;
1251
+ for (const result of llmResults) {
1252
+ if (result.success && result.fixes.length > 0) {
1253
+ allFixes.push(...result.fixes);
1254
+ successCount++;
1255
+ }
1256
+ }
1257
+
1258
+ if (allFixes.length === 0) {
1259
+ if (layer1RetryContext.attempt === 1) {
1260
+ return { applied: 0, content: originalContent };
1261
+ }
1262
+ // No fixes on retry, give up
1263
+ console.log(` No fixes generated on retry ${layer1RetryContext.attempt}`);
1264
+ return { applied: 0, content: originalContent };
1265
+ }
1266
+
1267
+ candidateContent = applyLineFixes(originalContent, allFixes);
1268
+
1269
+ // ===== LAYER 1: Pre-application structural gates =====
1270
+ const attemptLabel = layer1RetryContext.attempt > 1
1271
+ ? ` (retry ${layer1RetryContext.attempt}/${CONFIG.maxLayer1Retries})`
1272
+ : '';
1273
+ console.log(` [L1] Running 12 structural gates...${attemptLabel}`);
1274
+
1275
+ const layer1Result = runLayer1Gates(
1276
+ originalContent,
1277
+ candidateContent,
1278
+ errors[0].code,
1279
+ errors[0].line,
1280
+ filePath
1281
+ );
1282
+
1283
+ if (layer1Result.passed) {
1284
+ console.log(` OK (risk: ${layer1Result.riskLevel}/5)`);
1285
+ layer1RiskLevel = layer1Result.riskLevel;
1286
+ break; // Exit retry loop on success
1287
+ }
1288
+
1289
+ // Gate failed - record failure and potentially retry
1290
+ const failedGate = layer1Result.reason?.match(/\[(\w+)\]/)?.[1] || 'Unknown';
1291
+ layer1RetryContext.previousFailures.push({
1292
+ gate: failedGate,
1293
+ reason: layer1Result.reason || 'Unknown'
1294
+ });
1295
+
1296
+ gateStats.byGate[failedGate] = (gateStats.byGate[failedGate] || 0) + 1;
1297
+
1298
+ if (layer1RetryContext.attempt >= CONFIG.maxLayer1Retries) {
1299
+ // Final attempt failed, reject
1300
+ gateStats.layer1Rejections++;
1301
+ rejectionLog.push({
1302
+ timestamp: new Date().toISOString(),
1303
+ file: filePath,
1304
+ gate: 'Layer1',
1305
+ reason: `Failed after ${layer1RetryContext.attempt} attempts: ${layer1Result.reason}`,
1306
+ errorCode: errors[0].code
1307
+ });
1308
+ console.log(` REJECTED after ${layer1RetryContext.attempt} retries: ${layer1Result.reason}`);
1309
+ return { applied: 0, content: originalContent };
1310
+ }
1311
+
1312
+ // Log retry
1313
+ gateStats.layer1Retries++;
1314
+ console.log(` Gate failed [${failedGate}]: ${layer1Result.reason}`);
1315
+ console.log(` Retrying with feedback (attempt ${layer1RetryContext.attempt + 1}/${CONFIG.maxLayer1Retries})...`);
1316
+ }
1317
+
1318
+ // ===== LAYER 3: LLM Review Gate (for high-risk fixes) =====
1319
+ if (CONFIG.enableLayer3 && layer1RiskLevel >= 2) {
1320
+ console.log(` [L3] LLM review with checklist...`);
1321
+ const reviewResult = await llmReviewGate(
1322
+ client,
1323
+ originalContent,
1324
+ candidateContent,
1325
+ errors.map(e => `[${e.code}] ${e.message}`).join('; '),
1326
+ filePath
1327
+ );
1328
+
1329
+ if (reviewResult.verdict === 'REJECT') {
1330
+ console.log(` REJECTED: ${reviewResult.reason}`);
1331
+ gateStats.layer3Rejections++;
1332
+ rejectionLog.push({
1333
+ timestamp: new Date().toISOString(),
1334
+ file: filePath,
1335
+ gate: 'Layer3-LLMReview',
1336
+ reason: reviewResult.reason,
1337
+ errorCode: errors[0].code
1338
+ });
1339
+ return { applied: 0, content: originalContent };
1340
+ }
1341
+ console.log(` APPROVED (risk: ${reviewResult.riskLevel}/5)`);
1342
+ }
1343
+
1344
+ // ===== DRY-RUN MODE =====
1345
+ if (CONFIG.dryRun) {
1346
+ const patchContent = generateUnifiedDiff(originalContent, candidateContent, filePath);
1347
+ const patchFile = path.join(CONFIG.patchDir, `${path.basename(filePath)}.patch`);
1348
+ fs.mkdirSync(CONFIG.patchDir, { recursive: true });
1349
+ fs.writeFileSync(patchFile, patchContent);
1350
+ console.log(` [DRY-RUN] Patch written to ${patchFile}`);
1351
+ return { applied: 0, content: originalContent };
1352
+ }
1353
+
1354
+ gateStats.approvals++;
1355
+ return { applied: successCount, content: candidateContent };
1356
+ }
1357
+
1358
+ async function main() {
1359
+ console.log('=== Gated Rust Error Fixer V2 ===');
1360
+ console.log('Enhanced Gate Architecture with 12 Layer-1 Gates + Retry-with-Feedback');
1361
+ console.log();
1362
+ console.log('Gates:');
1363
+ console.log(' A: LineCount B: FnSignature C: ImportDup D: BraceBalance');
1364
+ console.log(' E: SemanticDiff F: OrphanedCode G: ImportPath H: PatternDup');
1365
+ console.log(' I: ImplLocation J: TypeCast K: MatchArm L: Regression');
1366
+ console.log();
1367
+ console.log(`Layer 3 LLM Review: ${CONFIG.enableLayer3 ? 'ON' : 'OFF'}`);
1368
+ console.log(`Clippy: ${CONFIG.enableClippy ? 'ON' : 'OFF'}`);
1369
+ console.log(`Dry-Run: ${CONFIG.dryRun ? 'ON' : 'OFF'}`);
1370
+ console.log();
1371
+
1372
+ const apiKey = loadCerebrasKey();
1373
+ if (!apiKey) {
1374
+ console.error('No CEREBRAS_API_KEY found');
1375
+ process.exit(1);
1376
+ }
1377
+ const client = new Cerebras({ apiKey });
1378
+
1379
+ let iteration = 0;
1380
+ let previousErrorCount = Infinity;
1381
+ const allAffectedFiles: string[] = [];
1382
+
1383
+ while (iteration < CONFIG.maxGlobalIterations) {
1384
+ iteration++;
1385
+ console.log(`\n========== ITERATION ${iteration} ==========`);
1386
+
1387
+ console.log('Running cargo check...');
1388
+ const { errors: allErrors, totalCount } = runCargoCheck();
1389
+
1390
+ console.log(`Found ${totalCount} errors in ${allErrors.size} files`);
1391
+
1392
+ if (totalCount === 0) {
1393
+ console.log('\n*** All errors fixed! ***');
1394
+ break;
1395
+ }
1396
+
1397
+ if (totalCount >= previousErrorCount) {
1398
+ console.log(`\nNo progress (${totalCount} >= ${previousErrorCount}). Stopping.`);
1399
+ break;
1400
+ }
1401
+
1402
+ previousErrorCount = totalCount;
1403
+
1404
+ const originalContents = new Map<string, string>();
1405
+ const fileFeedback = new Map<string, Map<number, string>>();
1406
+
1407
+ let totalApplied = 0;
1408
+ const files = [...allErrors.entries()];
1409
+
1410
+ for (const [filePath, errors] of files) {
1411
+ const fullPath = path.join(CONFIG.projectPath, filePath);
1412
+ try {
1413
+ originalContents.set(filePath, fs.readFileSync(fullPath, 'utf-8'));
1414
+ } catch { continue; }
1415
+
1416
+ const feedback = fileFeedback.get(filePath);
1417
+ console.log(`\n ${filePath}: ${errors.length} errors`);
1418
+
1419
+ const result = await processFileWithGates(client, filePath, errors, feedback);
1420
+
1421
+ if (result.applied > 0) {
1422
+ fs.writeFileSync(fullPath, result.content);
1423
+ console.log(` Applied ${result.applied} fixes`);
1424
+ totalApplied += result.applied;
1425
+ allAffectedFiles.push(filePath);
1426
+ } else {
1427
+ console.log(` No fixes passed gates`);
1428
+ }
1429
+ }
1430
+
1431
+ if (totalApplied === 0) {
1432
+ console.log('\nNo fixes applied this iteration. Stopping.');
1433
+ break;
1434
+ }
1435
+
1436
+ // ===== LAYER 2: Targeted compilation validation =====
1437
+ console.log('\n[L2] Validating changes (targeted crates)...');
1438
+ const { totalCount: newCount, errors: newErrors } = runTargetedCargoCheck(allAffectedFiles);
1439
+
1440
+ if (newCount > totalCount) {
1441
+ console.log(`\n[L2] FAILED: More errors (${newCount} > ${totalCount})`);
1442
+ gateStats.layer2Rejections++;
1443
+
1444
+ for (const [filePath, original] of originalContents) {
1445
+ const fullPath = path.join(CONFIG.projectPath, filePath);
1446
+ fs.writeFileSync(fullPath, original);
1447
+ }
1448
+
1449
+ for (const [filePath, errors] of newErrors) {
1450
+ if (!fileFeedback.has(filePath)) {
1451
+ fileFeedback.set(filePath, new Map());
1452
+ }
1453
+ for (const error of errors) {
1454
+ fileFeedback.get(filePath)!.set(error.line, `Previous fix caused: ${error.message}`);
1455
+ }
1456
+ }
1457
+
1458
+ console.log('Rolled back. Will retry with feedback.');
1459
+ } else {
1460
+ const reduced = totalCount - newCount;
1461
+ console.log(`[L2] OK: Reduced by ${reduced} (${totalCount} -> ${newCount})`);
1462
+ }
1463
+ }
1464
+
1465
+ // ===== FINAL SUMMARY =====
1466
+ console.log('\n========== FINAL SUMMARY ==========');
1467
+ const { totalCount: finalCount } = runCargoCheck();
1468
+ console.log(`Final error count: ${finalCount}`);
1469
+
1470
+ console.log('\n========== GATE STATISTICS ==========');
1471
+ console.log(`Layer 1 rejections: ${gateStats.layer1Rejections}`);
1472
+ console.log(`Layer 1 retries: ${gateStats.layer1Retries}`);
1473
+ console.log(`Layer 2 rejections: ${gateStats.layer2Rejections}`);
1474
+ console.log(`Layer 3 rejections: ${gateStats.layer3Rejections}`);
1475
+ console.log(`Approved fixes: ${gateStats.approvals}`);
1476
+
1477
+ if (Object.keys(gateStats.byGate).length > 0) {
1478
+ console.log('\nRejections by gate:');
1479
+ for (const [gate, count] of Object.entries(gateStats.byGate).sort((a, b) => b[1] - a[1])) {
1480
+ console.log(` ${gate}: ${count}`);
1481
+ }
1482
+ }
1483
+
1484
+ const totalAttempts = gateStats.approvals + gateStats.layer1Rejections +
1485
+ gateStats.layer2Rejections + gateStats.layer3Rejections;
1486
+ if (totalAttempts > 0) {
1487
+ const rejectionRate = ((gateStats.layer1Rejections + gateStats.layer2Rejections +
1488
+ gateStats.layer3Rejections) / totalAttempts * 100).toFixed(1);
1489
+ console.log(`\nRejection rate: ${rejectionRate}%`);
1490
+ }
1491
+
1492
+ // Save rejection log
1493
+ if (rejectionLog.length > 0) {
1494
+ const logPath = '/tmp/gate-rejections.json';
1495
+ fs.writeFileSync(logPath, JSON.stringify(rejectionLog, null, 2));
1496
+ console.log(`\nGate rejections logged to ${logPath}`);
1497
+ }
1498
+ }
1499
+
1500
+ main().catch(console.error);