autonomous-coding-toolkit 1.0.0

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 (324) hide show
  1. package/.claude-plugin/marketplace.json +22 -0
  2. package/.claude-plugin/plugin.json +13 -0
  3. package/LICENSE +21 -0
  4. package/Makefile +21 -0
  5. package/README.md +140 -0
  6. package/SECURITY.md +28 -0
  7. package/agents/bash-expert.md +113 -0
  8. package/agents/dependency-auditor.md +138 -0
  9. package/agents/integration-tester.md +120 -0
  10. package/agents/lesson-scanner.md +149 -0
  11. package/agents/python-expert.md +179 -0
  12. package/agents/service-monitor.md +141 -0
  13. package/agents/shell-expert.md +147 -0
  14. package/benchmarks/runner.sh +147 -0
  15. package/benchmarks/tasks/01-rest-endpoint/rubric.sh +29 -0
  16. package/benchmarks/tasks/01-rest-endpoint/task.md +17 -0
  17. package/benchmarks/tasks/02-refactor-module/task.md +8 -0
  18. package/benchmarks/tasks/03-fix-integration-bug/task.md +8 -0
  19. package/benchmarks/tasks/04-add-test-coverage/task.md +8 -0
  20. package/benchmarks/tasks/05-multi-file-feature/task.md +8 -0
  21. package/bin/act.js +238 -0
  22. package/commands/autocode.md +6 -0
  23. package/commands/cancel-ralph.md +18 -0
  24. package/commands/code-factory.md +53 -0
  25. package/commands/create-prd.md +55 -0
  26. package/commands/ralph-loop.md +18 -0
  27. package/commands/run-plan.md +117 -0
  28. package/commands/submit-lesson.md +122 -0
  29. package/docs/ARCHITECTURE.md +630 -0
  30. package/docs/CONTRIBUTING.md +125 -0
  31. package/docs/lessons/0001-bare-exception-swallowing.md +34 -0
  32. package/docs/lessons/0002-async-def-without-await.md +28 -0
  33. package/docs/lessons/0003-create-task-without-callback.md +28 -0
  34. package/docs/lessons/0004-hardcoded-test-counts.md +28 -0
  35. package/docs/lessons/0005-sqlite-without-closing.md +33 -0
  36. package/docs/lessons/0006-venv-pip-path.md +27 -0
  37. package/docs/lessons/0007-runner-state-self-rejection.md +35 -0
  38. package/docs/lessons/0008-quality-gate-blind-spot.md +33 -0
  39. package/docs/lessons/0009-parser-overcount-empty-batches.md +36 -0
  40. package/docs/lessons/0010-local-outside-function-bash.md +33 -0
  41. package/docs/lessons/0011-batch-tests-for-unimplemented-code.md +36 -0
  42. package/docs/lessons/0012-api-markdown-unescaped-chars.md +33 -0
  43. package/docs/lessons/0013-export-prefix-env-parsing.md +33 -0
  44. package/docs/lessons/0014-decorator-registry-import-side-effect.md +43 -0
  45. package/docs/lessons/0015-frontend-backend-schema-drift.md +43 -0
  46. package/docs/lessons/0016-event-driven-cold-start-seeding.md +44 -0
  47. package/docs/lessons/0017-copy-paste-logic-diverges.md +43 -0
  48. package/docs/lessons/0018-layer-passes-pipeline-broken.md +45 -0
  49. package/docs/lessons/0019-systemd-envfile-ignores-export.md +41 -0
  50. package/docs/lessons/0020-persist-state-incrementally.md +44 -0
  51. package/docs/lessons/0021-dual-axis-testing.md +48 -0
  52. package/docs/lessons/0022-jsx-factory-shadowing.md +43 -0
  53. package/docs/lessons/0023-static-analysis-spiral.md +51 -0
  54. package/docs/lessons/0024-shared-pipeline-implementation.md +55 -0
  55. package/docs/lessons/0025-defense-in-depth-all-entry-points.md +65 -0
  56. package/docs/lessons/0026-linter-no-rules-false-enforcement.md +54 -0
  57. package/docs/lessons/0027-jsx-silent-prop-drop.md +64 -0
  58. package/docs/lessons/0028-no-infrastructure-in-client-code.md +49 -0
  59. package/docs/lessons/0029-never-write-secrets-to-files.md +61 -0
  60. package/docs/lessons/0030-cache-merge-not-replace.md +62 -0
  61. package/docs/lessons/0031-verify-units-at-boundaries.md +66 -0
  62. package/docs/lessons/0032-module-lifecycle-subscribe-unsubscribe.md +89 -0
  63. package/docs/lessons/0033-async-iteration-mutable-snapshot.md +72 -0
  64. package/docs/lessons/0034-caller-missing-await-silent-discard.md +65 -0
  65. package/docs/lessons/0035-duplicate-registration-silent-overwrite.md +85 -0
  66. package/docs/lessons/0036-websocket-dirty-disconnect.md +33 -0
  67. package/docs/lessons/0037-parallel-agents-worktree-corruption.md +31 -0
  68. package/docs/lessons/0038-subscribe-no-stored-ref.md +36 -0
  69. package/docs/lessons/0039-fallback-or-default-hides-bugs.md +34 -0
  70. package/docs/lessons/0040-event-firehose-filter-first.md +36 -0
  71. package/docs/lessons/0041-ambiguous-base-dir-path-nesting.md +32 -0
  72. package/docs/lessons/0042-spec-compliance-insufficient.md +36 -0
  73. package/docs/lessons/0043-exact-count-extensible-collections.md +32 -0
  74. package/docs/lessons/0044-relative-file-deps-worktree.md +39 -0
  75. package/docs/lessons/0045-iterative-design-improvement.md +33 -0
  76. package/docs/lessons/0046-plan-assertion-math-bugs.md +38 -0
  77. package/docs/lessons/0047-pytest-single-threaded-default.md +37 -0
  78. package/docs/lessons/0048-integration-wiring-batch.md +40 -0
  79. package/docs/lessons/0049-ab-verification.md +41 -0
  80. package/docs/lessons/0050-editing-sourced-files-during-execution.md +33 -0
  81. package/docs/lessons/0051-infrastructure-fixes-cant-self-heal.md +30 -0
  82. package/docs/lessons/0052-uncommitted-changes-poison-quality-gates.md +31 -0
  83. package/docs/lessons/0053-jq-compact-flag-inconsistency.md +31 -0
  84. package/docs/lessons/0054-parser-matches-inside-code-blocks.md +30 -0
  85. package/docs/lessons/0055-agents-compensate-for-garbled-prompts.md +31 -0
  86. package/docs/lessons/0056-grep-count-exit-code-on-zero.md +42 -0
  87. package/docs/lessons/0057-new-artifacts-break-git-clean-gates.md +42 -0
  88. package/docs/lessons/0058-dead-config-keys-never-consumed.md +49 -0
  89. package/docs/lessons/0059-contract-test-shared-structures.md +53 -0
  90. package/docs/lessons/0060-set-e-silent-death-in-runners.md +53 -0
  91. package/docs/lessons/0061-context-injection-dirty-state.md +50 -0
  92. package/docs/lessons/0062-sibling-bug-neighborhood-scan.md +29 -0
  93. package/docs/lessons/0063-one-flag-two-lifetimes.md +31 -0
  94. package/docs/lessons/0064-test-passes-wrong-reason.md +31 -0
  95. package/docs/lessons/0065-pipefail-grep-count-double-output.md +39 -0
  96. package/docs/lessons/0066-local-keyword-outside-function.md +37 -0
  97. package/docs/lessons/0067-stdin-hang-non-interactive-shell.md +36 -0
  98. package/docs/lessons/0068-agent-builds-wrong-thing-correctly.md +31 -0
  99. package/docs/lessons/0069-plan-quality-dominates-execution.md +30 -0
  100. package/docs/lessons/0070-spec-echo-back-prevents-drift.md +31 -0
  101. package/docs/lessons/0071-positive-instructions-outperform-negative.md +30 -0
  102. package/docs/lessons/0072-lost-in-the-middle-context-placement.md +30 -0
  103. package/docs/lessons/0073-unscoped-lessons-cause-false-positives.md +30 -0
  104. package/docs/lessons/0074-stale-context-injection-wrong-batch.md +32 -0
  105. package/docs/lessons/0075-research-artifacts-must-persist.md +32 -0
  106. package/docs/lessons/0076-wrong-decomposition-contaminates-downstream.md +30 -0
  107. package/docs/lessons/0077-cherry-pick-merges-need-manual-resolution.md +30 -0
  108. package/docs/lessons/0078-static-review-without-live-test.md +30 -0
  109. package/docs/lessons/0079-integration-wiring-batch-required.md +32 -0
  110. package/docs/lessons/FRAMEWORK.md +161 -0
  111. package/docs/lessons/SUMMARY.md +201 -0
  112. package/docs/lessons/TEMPLATE.md +85 -0
  113. package/docs/plans/2026-02-21-code-factory-v2-design.md +204 -0
  114. package/docs/plans/2026-02-21-code-factory-v2-implementation-plan.md +2189 -0
  115. package/docs/plans/2026-02-21-code-factory-v2-phase4-design.md +537 -0
  116. package/docs/plans/2026-02-21-code-factory-v2-phase4-implementation-plan.md +2012 -0
  117. package/docs/plans/2026-02-21-hardening-pass-design.md +108 -0
  118. package/docs/plans/2026-02-21-hardening-pass-plan.md +1378 -0
  119. package/docs/plans/2026-02-21-mab-research-report.md +406 -0
  120. package/docs/plans/2026-02-21-marketplace-restructure-design.md +240 -0
  121. package/docs/plans/2026-02-21-marketplace-restructure-plan.md +832 -0
  122. package/docs/plans/2026-02-21-phase4-completion-plan.md +697 -0
  123. package/docs/plans/2026-02-21-validator-suite-design.md +148 -0
  124. package/docs/plans/2026-02-21-validator-suite-plan.md +540 -0
  125. package/docs/plans/2026-02-22-mab-research-round2.md +556 -0
  126. package/docs/plans/2026-02-22-mab-run-design.md +462 -0
  127. package/docs/plans/2026-02-22-mab-run-plan.md +2046 -0
  128. package/docs/plans/2026-02-22-operations-design-methodology-research.md +681 -0
  129. package/docs/plans/2026-02-22-research-agent-failure-taxonomy.md +532 -0
  130. package/docs/plans/2026-02-22-research-code-guideline-policies.md +886 -0
  131. package/docs/plans/2026-02-22-research-codebase-audit-refactoring.md +908 -0
  132. package/docs/plans/2026-02-22-research-coding-standards-documentation.md +541 -0
  133. package/docs/plans/2026-02-22-research-competitive-landscape.md +687 -0
  134. package/docs/plans/2026-02-22-research-comprehensive-testing.md +1076 -0
  135. package/docs/plans/2026-02-22-research-context-utilization.md +459 -0
  136. package/docs/plans/2026-02-22-research-cost-quality-tradeoff.md +548 -0
  137. package/docs/plans/2026-02-22-research-lesson-transferability.md +508 -0
  138. package/docs/plans/2026-02-22-research-multi-agent-coordination.md +312 -0
  139. package/docs/plans/2026-02-22-research-phase-integration.md +602 -0
  140. package/docs/plans/2026-02-22-research-plan-quality.md +428 -0
  141. package/docs/plans/2026-02-22-research-prompt-engineering.md +558 -0
  142. package/docs/plans/2026-02-22-research-unconventional-perspectives.md +528 -0
  143. package/docs/plans/2026-02-22-research-user-adoption.md +638 -0
  144. package/docs/plans/2026-02-22-research-verification-effectiveness.md +433 -0
  145. package/docs/plans/2026-02-23-agent-suite-design.md +299 -0
  146. package/docs/plans/2026-02-23-agent-suite-plan.md +578 -0
  147. package/docs/plans/2026-02-23-phase3-cost-infrastructure-design.md +148 -0
  148. package/docs/plans/2026-02-23-phase3-cost-infrastructure-plan.md +1062 -0
  149. package/docs/plans/2026-02-23-research-bash-expert-agent.md +543 -0
  150. package/docs/plans/2026-02-23-research-dependency-auditor-agent.md +564 -0
  151. package/docs/plans/2026-02-23-research-improving-existing-agents.md +503 -0
  152. package/docs/plans/2026-02-23-research-integration-tester-agent.md +454 -0
  153. package/docs/plans/2026-02-23-research-python-expert-agent.md +429 -0
  154. package/docs/plans/2026-02-23-research-service-monitor-agent.md +425 -0
  155. package/docs/plans/2026-02-23-research-shell-expert-agent.md +533 -0
  156. package/docs/plans/2026-02-23-roadmap-to-completion.md +530 -0
  157. package/docs/plans/2026-02-24-headless-module-split-design.md +98 -0
  158. package/docs/plans/2026-02-24-headless-module-split.md +443 -0
  159. package/docs/plans/2026-02-24-lesson-scope-metadata-design.md +228 -0
  160. package/docs/plans/2026-02-24-lesson-scope-metadata-plan.md +968 -0
  161. package/docs/plans/2026-02-24-npm-packaging-design.md +841 -0
  162. package/docs/plans/2026-02-24-npm-packaging-plan.md +1965 -0
  163. package/docs/plans/audit-findings.md +186 -0
  164. package/docs/telegram-notification-format.md +98 -0
  165. package/examples/example-plan.md +51 -0
  166. package/examples/example-prd.json +72 -0
  167. package/examples/example-roadmap.md +33 -0
  168. package/examples/quickstart-plan.md +63 -0
  169. package/hooks/hooks.json +26 -0
  170. package/hooks/setup-symlinks.sh +48 -0
  171. package/hooks/stop-hook.sh +135 -0
  172. package/package.json +47 -0
  173. package/policies/bash.md +71 -0
  174. package/policies/python.md +71 -0
  175. package/policies/testing.md +61 -0
  176. package/policies/universal.md +60 -0
  177. package/scripts/analyze-report.sh +97 -0
  178. package/scripts/architecture-map.sh +145 -0
  179. package/scripts/auto-compound.sh +273 -0
  180. package/scripts/batch-audit.sh +42 -0
  181. package/scripts/batch-test.sh +101 -0
  182. package/scripts/entropy-audit.sh +221 -0
  183. package/scripts/failure-digest.sh +51 -0
  184. package/scripts/generate-ast-rules.sh +96 -0
  185. package/scripts/init.sh +112 -0
  186. package/scripts/lesson-check.sh +428 -0
  187. package/scripts/lib/common.sh +61 -0
  188. package/scripts/lib/cost-tracking.sh +153 -0
  189. package/scripts/lib/ollama.sh +60 -0
  190. package/scripts/lib/progress-writer.sh +128 -0
  191. package/scripts/lib/run-plan-context.sh +215 -0
  192. package/scripts/lib/run-plan-echo-back.sh +231 -0
  193. package/scripts/lib/run-plan-headless.sh +396 -0
  194. package/scripts/lib/run-plan-notify.sh +57 -0
  195. package/scripts/lib/run-plan-parser.sh +81 -0
  196. package/scripts/lib/run-plan-prompt.sh +215 -0
  197. package/scripts/lib/run-plan-quality-gate.sh +132 -0
  198. package/scripts/lib/run-plan-routing.sh +315 -0
  199. package/scripts/lib/run-plan-sampling.sh +170 -0
  200. package/scripts/lib/run-plan-scoring.sh +146 -0
  201. package/scripts/lib/run-plan-state.sh +142 -0
  202. package/scripts/lib/run-plan-team.sh +199 -0
  203. package/scripts/lib/telegram.sh +54 -0
  204. package/scripts/lib/thompson-sampling.sh +176 -0
  205. package/scripts/license-check.sh +74 -0
  206. package/scripts/mab-run.sh +575 -0
  207. package/scripts/module-size-check.sh +146 -0
  208. package/scripts/patterns/async-no-await.yml +5 -0
  209. package/scripts/patterns/bare-except.yml +6 -0
  210. package/scripts/patterns/empty-catch.yml +6 -0
  211. package/scripts/patterns/hardcoded-localhost.yml +9 -0
  212. package/scripts/patterns/retry-loop-no-backoff.yml +12 -0
  213. package/scripts/pipeline-status.sh +197 -0
  214. package/scripts/policy-check.sh +226 -0
  215. package/scripts/prior-art-search.sh +133 -0
  216. package/scripts/promote-mab-lessons.sh +126 -0
  217. package/scripts/prompts/agent-a-superpowers.md +29 -0
  218. package/scripts/prompts/agent-b-ralph.md +29 -0
  219. package/scripts/prompts/judge-agent.md +61 -0
  220. package/scripts/prompts/planner-agent.md +44 -0
  221. package/scripts/pull-community-lessons.sh +90 -0
  222. package/scripts/quality-gate.sh +266 -0
  223. package/scripts/research-gate.sh +90 -0
  224. package/scripts/run-plan.sh +329 -0
  225. package/scripts/scope-infer.sh +159 -0
  226. package/scripts/setup-ralph-loop.sh +155 -0
  227. package/scripts/telemetry.sh +230 -0
  228. package/scripts/tests/run-all-tests.sh +52 -0
  229. package/scripts/tests/test-act-cli.sh +46 -0
  230. package/scripts/tests/test-agents-md.sh +87 -0
  231. package/scripts/tests/test-analyze-report.sh +114 -0
  232. package/scripts/tests/test-architecture-map.sh +89 -0
  233. package/scripts/tests/test-auto-compound.sh +169 -0
  234. package/scripts/tests/test-batch-test.sh +65 -0
  235. package/scripts/tests/test-benchmark-runner.sh +25 -0
  236. package/scripts/tests/test-common.sh +168 -0
  237. package/scripts/tests/test-cost-tracking.sh +158 -0
  238. package/scripts/tests/test-echo-back.sh +180 -0
  239. package/scripts/tests/test-entropy-audit.sh +146 -0
  240. package/scripts/tests/test-failure-digest.sh +66 -0
  241. package/scripts/tests/test-generate-ast-rules.sh +145 -0
  242. package/scripts/tests/test-helpers.sh +82 -0
  243. package/scripts/tests/test-init.sh +47 -0
  244. package/scripts/tests/test-lesson-check.sh +278 -0
  245. package/scripts/tests/test-lesson-local.sh +55 -0
  246. package/scripts/tests/test-license-check.sh +109 -0
  247. package/scripts/tests/test-mab-run.sh +182 -0
  248. package/scripts/tests/test-ollama-lib.sh +49 -0
  249. package/scripts/tests/test-ollama.sh +60 -0
  250. package/scripts/tests/test-pipeline-status.sh +198 -0
  251. package/scripts/tests/test-policy-check.sh +124 -0
  252. package/scripts/tests/test-prior-art-search.sh +96 -0
  253. package/scripts/tests/test-progress-writer.sh +140 -0
  254. package/scripts/tests/test-promote-mab-lessons.sh +110 -0
  255. package/scripts/tests/test-pull-community-lessons.sh +149 -0
  256. package/scripts/tests/test-quality-gate.sh +241 -0
  257. package/scripts/tests/test-research-gate.sh +132 -0
  258. package/scripts/tests/test-run-plan-cli.sh +86 -0
  259. package/scripts/tests/test-run-plan-context.sh +305 -0
  260. package/scripts/tests/test-run-plan-e2e.sh +153 -0
  261. package/scripts/tests/test-run-plan-headless.sh +424 -0
  262. package/scripts/tests/test-run-plan-notify.sh +124 -0
  263. package/scripts/tests/test-run-plan-parser.sh +217 -0
  264. package/scripts/tests/test-run-plan-prompt.sh +254 -0
  265. package/scripts/tests/test-run-plan-quality-gate.sh +222 -0
  266. package/scripts/tests/test-run-plan-routing.sh +178 -0
  267. package/scripts/tests/test-run-plan-scoring.sh +148 -0
  268. package/scripts/tests/test-run-plan-state.sh +261 -0
  269. package/scripts/tests/test-run-plan-team.sh +157 -0
  270. package/scripts/tests/test-scope-infer.sh +150 -0
  271. package/scripts/tests/test-setup-ralph-loop.sh +63 -0
  272. package/scripts/tests/test-telegram-env.sh +38 -0
  273. package/scripts/tests/test-telegram.sh +121 -0
  274. package/scripts/tests/test-telemetry.sh +46 -0
  275. package/scripts/tests/test-thompson-sampling.sh +139 -0
  276. package/scripts/tests/test-validate-all.sh +60 -0
  277. package/scripts/tests/test-validate-commands.sh +89 -0
  278. package/scripts/tests/test-validate-hooks.sh +98 -0
  279. package/scripts/tests/test-validate-lessons.sh +150 -0
  280. package/scripts/tests/test-validate-plan-quality.sh +235 -0
  281. package/scripts/tests/test-validate-plans.sh +187 -0
  282. package/scripts/tests/test-validate-plugin.sh +106 -0
  283. package/scripts/tests/test-validate-prd.sh +184 -0
  284. package/scripts/tests/test-validate-skills.sh +134 -0
  285. package/scripts/validate-all.sh +57 -0
  286. package/scripts/validate-commands.sh +67 -0
  287. package/scripts/validate-hooks.sh +89 -0
  288. package/scripts/validate-lessons.sh +98 -0
  289. package/scripts/validate-plan-quality.sh +369 -0
  290. package/scripts/validate-plans.sh +120 -0
  291. package/scripts/validate-plugin.sh +86 -0
  292. package/scripts/validate-policies.sh +42 -0
  293. package/scripts/validate-prd.sh +118 -0
  294. package/scripts/validate-skills.sh +96 -0
  295. package/skills/autocode/SKILL.md +285 -0
  296. package/skills/autocode/ab-verification.md +51 -0
  297. package/skills/autocode/code-quality-standards.md +37 -0
  298. package/skills/autocode/competitive-mode.md +364 -0
  299. package/skills/brainstorming/SKILL.md +97 -0
  300. package/skills/capture-lesson/SKILL.md +187 -0
  301. package/skills/check-lessons/SKILL.md +116 -0
  302. package/skills/dispatching-parallel-agents/SKILL.md +110 -0
  303. package/skills/executing-plans/SKILL.md +85 -0
  304. package/skills/finishing-a-development-branch/SKILL.md +201 -0
  305. package/skills/receiving-code-review/SKILL.md +72 -0
  306. package/skills/requesting-code-review/SKILL.md +59 -0
  307. package/skills/requesting-code-review/code-reviewer.md +82 -0
  308. package/skills/research/SKILL.md +145 -0
  309. package/skills/roadmap/SKILL.md +115 -0
  310. package/skills/subagent-driven-development/SKILL.md +98 -0
  311. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +18 -0
  312. package/skills/subagent-driven-development/implementer-prompt.md +73 -0
  313. package/skills/subagent-driven-development/spec-reviewer-prompt.md +57 -0
  314. package/skills/systematic-debugging/SKILL.md +134 -0
  315. package/skills/systematic-debugging/condition-based-waiting.md +64 -0
  316. package/skills/systematic-debugging/defense-in-depth.md +32 -0
  317. package/skills/systematic-debugging/root-cause-tracing.md +55 -0
  318. package/skills/test-driven-development/SKILL.md +167 -0
  319. package/skills/using-git-worktrees/SKILL.md +219 -0
  320. package/skills/using-superpowers/SKILL.md +54 -0
  321. package/skills/verification-before-completion/SKILL.md +140 -0
  322. package/skills/verify/SKILL.md +82 -0
  323. package/skills/writing-plans/SKILL.md +128 -0
  324. package/skills/writing-skills/SKILL.md +93 -0
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env bash
2
+ # prior-art-search.sh — Search GitHub and local codebase for prior art
3
+ #
4
+ # Usage: prior-art-search.sh [--dry-run] [--local-only] [--github-only] <query>
5
+ #
6
+ # Searches:
7
+ # 1. GitHub repos (gh search repos)
8
+ # 2. GitHub code (gh search code)
9
+ # 3. Local ~/Documents/projects/ (grep -r)
10
+ #
11
+ # Output: Ranked results with source, relevance, and URL/path
12
+ set -euo pipefail
13
+
14
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15
+ source "$SCRIPT_DIR/lib/common.sh"
16
+
17
+ DRY_RUN=false
18
+ LOCAL_ONLY=false
19
+ GITHUB_ONLY=false
20
+ QUERY=""
21
+ MAX_RESULTS=10
22
+ PROJECTS_DIR="${PROJECTS_DIR:-$HOME/Documents/projects}"
23
+
24
+ while [[ $# -gt 0 ]]; do
25
+ case "$1" in
26
+ --dry-run) DRY_RUN=true; shift ;;
27
+ --local-only) LOCAL_ONLY=true; shift ;;
28
+ --github-only) GITHUB_ONLY=true; shift ;;
29
+ --max-results) MAX_RESULTS="$2"; shift 2 ;;
30
+ --projects-dir) PROJECTS_DIR="$2"; shift 2 ;;
31
+ -h|--help)
32
+ cat <<'USAGE'
33
+ prior-art-search.sh — Search for prior art before building
34
+
35
+ Usage: prior-art-search.sh [OPTIONS] <query>
36
+
37
+ Options:
38
+ --dry-run Show what would be searched without executing
39
+ --local-only Only search local projects
40
+ --github-only Only search GitHub
41
+ --max-results N Max results per source (default: 10)
42
+ --projects-dir P Local projects directory
43
+
44
+ Output: Results ranked by relevance with source attribution
45
+ USAGE
46
+ exit 0
47
+ ;;
48
+ -*) echo "Unknown option: $1" >&2; exit 1 ;;
49
+ *) QUERY="$1"; shift ;;
50
+ esac
51
+ done
52
+
53
+ if [[ -z "$QUERY" ]]; then
54
+ echo "Error: Query required" >&2
55
+ echo "Usage: prior-art-search.sh <query>" >&2
56
+ exit 1
57
+ fi
58
+
59
+ echo "=== Prior Art Search ==="
60
+ echo "Search query: $QUERY"
61
+ echo ""
62
+
63
+ if [[ "$DRY_RUN" == true ]]; then
64
+ echo "[dry-run] Would search:"
65
+ [[ "$LOCAL_ONLY" != true ]] && echo " - GitHub repos: gh search repos '$QUERY' --limit $MAX_RESULTS"
66
+ [[ "$LOCAL_ONLY" != true ]] && echo " - GitHub code: gh search code '$QUERY' --limit $MAX_RESULTS"
67
+ [[ "$GITHUB_ONLY" != true ]] && echo " - Local projects: grep -rl in $PROJECTS_DIR"
68
+ if command -v ast-grep >/dev/null 2>&1; then
69
+ echo " - Structural code search (ast-grep): scan with built-in patterns"
70
+ else
71
+ echo " - Structural code search (ast-grep): not installed — would skip"
72
+ fi
73
+ exit 0
74
+ fi
75
+
76
+ # Search 1: GitHub repos
77
+ if [[ "$LOCAL_ONLY" != true ]]; then
78
+ echo "--- GitHub Repos ---"
79
+ if command -v gh >/dev/null 2>&1; then
80
+ gh search repos "$QUERY" --limit "$MAX_RESULTS" --json name,url,description,stargazersCount \
81
+ --jq '.[] | "★ \(.stargazersCount) | \(.name) — \(.description // "no description") | \(.url)"' \
82
+ 2>/dev/null || echo " (GitHub search unavailable)"
83
+ else
84
+ echo " gh CLI not installed — skipping"
85
+ fi
86
+ echo ""
87
+
88
+ echo "--- GitHub Code ---"
89
+ if command -v gh >/dev/null 2>&1; then
90
+ gh search code "$QUERY" --limit "$MAX_RESULTS" --json repository,path \
91
+ --jq '.[] | "\(.repository.nameWithOwner)/\(.path)"' \
92
+ 2>/dev/null || echo " (GitHub code search unavailable)"
93
+ else
94
+ echo " gh CLI not installed — skipping"
95
+ fi
96
+ echo ""
97
+ fi
98
+
99
+ # Search 2: Local projects
100
+ if [[ "$GITHUB_ONLY" != true ]]; then
101
+ echo "--- Local Projects ---"
102
+ if [[ -d "$PROJECTS_DIR" ]]; then
103
+ grep -rl --include='*.py' --include='*.sh' --include='*.ts' --include='*.js' \
104
+ "$QUERY" "$PROJECTS_DIR" 2>/dev/null | head -"$MAX_RESULTS" || echo " No local matches"
105
+ else
106
+ echo " Projects directory not found: $PROJECTS_DIR"
107
+ fi
108
+ echo ""
109
+ fi
110
+
111
+ # Search 3: Structural code search (ast-grep)
112
+ if command -v ast-grep >/dev/null 2>&1; then
113
+ echo "--- Structural Code Search (ast-grep) ---"
114
+ PATTERNS_DIR="$SCRIPT_DIR/patterns"
115
+ if [[ -d "$PATTERNS_DIR" ]]; then
116
+ for pattern_file in "$PATTERNS_DIR"/*.yml; do
117
+ [[ -f "$pattern_file" ]] || continue
118
+ pattern_name=$(basename "$pattern_file" .yml)
119
+ matches=$(ast-grep scan --rule "$pattern_file" . 2>/dev/null | head -5 || true)
120
+ if [[ -n "$matches" ]]; then
121
+ echo " Pattern '$pattern_name': $(echo "$matches" | wc -l) matches"
122
+ fi
123
+ done
124
+ fi
125
+ echo ""
126
+ else
127
+ echo "--- Structural Code Search ---"
128
+ echo " ast-grep not installed — skipping structural analysis"
129
+ echo " Install: npm i -g @ast-grep/cli"
130
+ echo ""
131
+ fi
132
+
133
+ echo "=== Search Complete ==="
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env bash
2
+ # promote-mab-lessons.sh — Auto-promote MAB patterns with sufficient occurrences to docs/lessons/
3
+ #
4
+ # Usage: promote-mab-lessons.sh [--worktree <dir>] [--min-occurrences N] [--dry-run] [--help]
5
+ set -euo pipefail
6
+
7
+ WORKTREE="."
8
+ MIN_OCCURRENCES=3
9
+ DRY_RUN=false
10
+
11
+ usage() {
12
+ cat <<'USAGE'
13
+ promote-mab-lessons.sh — Promote recurring MAB patterns to lesson files
14
+
15
+ Usage: promote-mab-lessons.sh [--worktree <dir>] [--min-occurrences N] [--dry-run] [--help]
16
+
17
+ Options:
18
+ --worktree <dir> Project root (default: .)
19
+ --min-occurrences N Minimum occurrences to promote (default: 3)
20
+ --dry-run Show what would be promoted without creating files
21
+ -h, --help Show this help
22
+ USAGE
23
+ }
24
+
25
+ while [[ $# -gt 0 ]]; do
26
+ case "$1" in
27
+ -h|--help) usage; exit 0 ;;
28
+ --worktree) WORKTREE="$2"; shift 2 ;;
29
+ --min-occurrences) MIN_OCCURRENCES="$2"; shift 2 ;;
30
+ --dry-run) DRY_RUN=true; shift ;;
31
+ *) echo "ERROR: Unknown option: $1" >&2; exit 1 ;;
32
+ esac
33
+ done
34
+
35
+ LESSONS_FILE="$WORKTREE/logs/mab-lessons.json"
36
+ LESSONS_DIR="$WORKTREE/docs/lessons"
37
+
38
+ if [[ ! -f "$LESSONS_FILE" ]]; then
39
+ echo "No mab-lessons.json found at $LESSONS_FILE"
40
+ exit 0
41
+ fi
42
+
43
+ # Find next lesson number
44
+ next_num() {
45
+ local existing
46
+ existing=$(find "$LESSONS_DIR" -maxdepth 1 -name '*.md' 2>/dev/null \
47
+ | sed 's/.*\///; s/-.*//' \
48
+ | grep -E '^[0-9]+$' \
49
+ | sort -n \
50
+ | tail -1 || echo "0")
51
+ echo $((existing + 1))
52
+ }
53
+
54
+ # Slugify a pattern string
55
+ slugify() {
56
+ echo "$1" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g; s/--*/-/g; s/^-//; s/-$//' | cut -c1-50
57
+ }
58
+
59
+ promoted=0
60
+
61
+ # Read eligible patterns (not yet promoted, >= threshold)
62
+ while IFS= read -r line; do
63
+ pattern=$(echo "$line" | jq -r '.pattern')
64
+ context=$(echo "$line" | jq -r '.context // "general"')
65
+ winner=$(echo "$line" | jq -r '.winner // "unknown"')
66
+ occurrences=$(echo "$line" | jq -r '.occurrences // 0')
67
+
68
+ if [[ "$DRY_RUN" == true ]]; then
69
+ echo " Would promote: \"$pattern\" ($occurrences occurrences, context=$context)"
70
+ promoted=$((promoted + 1))
71
+ continue
72
+ fi
73
+
74
+ # Create lesson file
75
+ mkdir -p "$LESSONS_DIR"
76
+ num=$(next_num)
77
+ slug=$(slugify "$pattern")
78
+ filename=$(printf "%04d-%s.md" "$num" "$slug")
79
+
80
+ promoted_at=$(date -u +%Y-%m-%dT%H:%M:%SZ)
81
+ # Use printf to avoid shell expansion of LLM-sourced variables (security)
82
+ printf '%s\n' \
83
+ "---" \
84
+ "pattern: \"$pattern\"" \
85
+ "context: $context" \
86
+ "winning_strategy: $winner" \
87
+ "occurrences: $occurrences" \
88
+ "source: mab-auto-promoted" \
89
+ "promoted_at: $promoted_at" \
90
+ "---" \
91
+ "" \
92
+ "# $pattern" \
93
+ "" \
94
+ "**Context:** $context batch type" \
95
+ "**Winning strategy:** $winner" \
96
+ "**Occurrences:** $occurrences competing runs" \
97
+ "" \
98
+ "## Description" \
99
+ "" \
100
+ "This pattern was automatically promoted from MAB competing agent runs." \
101
+ "The $winner strategy consistently produced better results when this" \
102
+ "pattern was followed." \
103
+ "" \
104
+ "## Recommendation" \
105
+ "" \
106
+ "Apply this pattern when working on $context batches." \
107
+ > "$LESSONS_DIR/$filename"
108
+
109
+ echo " Promoted: $filename"
110
+ promoted=$((promoted + 1))
111
+
112
+ # Mark as promoted in JSON
113
+ tmp=$(mktemp)
114
+ jq --arg p "$pattern" \
115
+ '[.[] | if .pattern == $p then .promoted = true else . end]' \
116
+ "$LESSONS_FILE" > "$tmp" && mv "$tmp" "$LESSONS_FILE"
117
+
118
+ done < <(jq -c --argjson min "$MIN_OCCURRENCES" \
119
+ '.[] | select(.promoted != true and .occurrences >= $min)' \
120
+ "$LESSONS_FILE" 2>/dev/null)
121
+
122
+ echo ""
123
+ echo "Promoted $promoted patterns"
124
+ if [[ "$DRY_RUN" == true ]]; then
125
+ echo "(dry run — no files created)"
126
+ fi
@@ -0,0 +1,29 @@
1
+ # Agent A: Superpowers Strategy
2
+
3
+ You are executing a work unit using the **superpowers methodology** — disciplined skill invocation, TDD, systematic debugging, and verification before completion claims.
4
+
5
+ ## Work Unit
6
+
7
+ {WORK_UNIT_DESCRIPTION}
8
+
9
+ ## Context
10
+
11
+ - **PRD:** {PRD_PATH}
12
+ - **Architecture Map:** {ARCH_MAP_PATH}
13
+ - **Quality Gate:** `{QUALITY_GATE_CMD}`
14
+
15
+ ## MAB Lessons (from prior competing runs)
16
+
17
+ {MAB_LESSONS}
18
+
19
+ ## Instructions
20
+
21
+ 1. **Invoke skills before acting.** Check if brainstorming, TDD, or systematic-debugging applies. Follow skill discipline exactly.
22
+ 2. **TDD cycle:** Write failing tests first, then implement to make them pass, then refactor.
23
+ 3. **Quality gate:** Run `{QUALITY_GATE_CMD}` after implementation. All tests must pass.
24
+ 4. **Commit atomically:** One commit per logical change. Stage specific files only.
25
+ 5. **No completion claims without evidence.** Run the quality gate and report its output.
26
+
27
+ ## Strategy Differentiator
28
+
29
+ This strategy prioritizes **process discipline** — skills, TDD, verification gates. When in doubt, follow the skill chain exactly rather than improvising. The bet is that disciplined execution produces fewer defects even if it takes more steps.
@@ -0,0 +1,29 @@
1
+ # Agent B: Ralph Wiggum Strategy
2
+
3
+ You are executing a work unit using the **Ralph Wiggum methodology** — iterative loop with stop-hook verification. Ship fast, verify, fix, repeat.
4
+
5
+ ## Work Unit
6
+
7
+ {WORK_UNIT_DESCRIPTION}
8
+
9
+ ## Context
10
+
11
+ - **PRD:** {PRD_PATH}
12
+ - **Architecture Map:** {ARCH_MAP_PATH}
13
+ - **Quality Gate:** `{QUALITY_GATE_CMD}`
14
+
15
+ ## MAB Lessons (from prior competing runs)
16
+
17
+ {MAB_LESSONS}
18
+
19
+ ## Instructions
20
+
21
+ 1. **Read the work unit carefully.** Understand what "done" looks like before writing code.
22
+ 2. **Implement directly.** Write the code, then write the tests. Speed over ceremony.
23
+ 3. **Run the quality gate** after each significant change: `{QUALITY_GATE_CMD}`
24
+ 4. **If gate fails:** Read the error, fix the root cause, run again. Do not retry blindly.
25
+ 5. **Commit when green.** Stage specific files, commit with a descriptive message.
26
+
27
+ ## Strategy Differentiator
28
+
29
+ This strategy prioritizes **velocity and iteration** — get to a working state quickly, then iterate on failures. The bet is that fast feedback loops and direct implementation outperform ceremony-heavy approaches. When in doubt, ship something testable rather than planning further.
@@ -0,0 +1,61 @@
1
+ # Judge Agent: MAB Evaluation
2
+
3
+ You are evaluating two competing implementations of the same work unit. Your job is to pick the winner based on objective quality criteria.
4
+
5
+ ## Work Unit
6
+
7
+ {WORK_UNIT_DESCRIPTION}
8
+
9
+ ## Design Document
10
+
11
+ {DESIGN_DOC}
12
+
13
+ ## Agent A (Superpowers) Results
14
+
15
+ ### Diff
16
+ ```
17
+ {DIFF_A}
18
+ ```
19
+
20
+ ### Quality Gate Output
21
+ ```
22
+ {GATE_A}
23
+ ```
24
+
25
+ ## Agent B (Ralph Wiggum) Results
26
+
27
+ ### Diff
28
+ ```
29
+ {DIFF_B}
30
+ ```
31
+
32
+ ### Quality Gate Output
33
+ ```
34
+ {GATE_B}
35
+ ```
36
+
37
+ ## Evaluation Criteria
38
+
39
+ Score each agent 1-5 on these dimensions:
40
+
41
+ 1. **Correctness** — Does the implementation match the work unit spec? Are tests passing?
42
+ 2. **Completeness** — Are all specified deliverables present? Nothing missing?
43
+ 3. **Code Quality** — Clean, readable, maintainable? Follows project conventions?
44
+ 4. **Test Quality** — Meaningful assertions? Edge cases covered? No hardcoded counts?
45
+ 5. **Minimalism** — Smallest diff that solves the problem? No unnecessary changes?
46
+
47
+ ## Output Format
48
+
49
+ Respond with EXACTLY this format (parseable by the orchestrator):
50
+
51
+ ```
52
+ SCORES:
53
+ agent-a: correctness=N completeness=N quality=N tests=N minimalism=N total=N
54
+ agent-b: correctness=N completeness=N quality=N tests=N minimalism=N total=N
55
+
56
+ WINNER: agent-a|agent-b|tie
57
+
58
+ LESSON: <one-sentence pattern observation for future runs>
59
+ ```
60
+
61
+ Be decisive. Ties should be rare — only when scores are genuinely equal across all dimensions.
@@ -0,0 +1,44 @@
1
+ # Planner Agent: Routing Reference
2
+
3
+ > **NOTE:** This file is reference documentation only. The actual routing logic is
4
+ > implemented in `scripts/lib/thompson-sampling.sh` using Thompson Sampling —
5
+ > not an LLM planner.
6
+
7
+ ## How Routing Works
8
+
9
+ The MAB system uses **Thompson Sampling** (a Bayesian multi-armed bandit algorithm)
10
+ to decide whether each batch runs in competing mode (both strategies) or uses a
11
+ known winner (single strategy).
12
+
13
+ ### Decision Flow
14
+
15
+ 1. **Check data sufficiency:** If fewer than 5 data points per strategy for this
16
+ batch type, always run competing (`"mab"`).
17
+ 2. **Check batch type:** `integration` batches always run competing (too variable
18
+ for confident routing).
19
+ 3. **Check win rate spread:** If the gap between strategies is < 15%, run competing
20
+ (too close to call).
21
+ 4. **Check for clear winner:** If one strategy has ≥ 70% win rate with 10+ data
22
+ points, route directly to that strategy.
23
+ 5. **Thompson Sample:** Draw from Beta(wins+1, losses+1) for each strategy.
24
+ Higher sample wins the route.
25
+
26
+ ### Batch Types
27
+
28
+ | Type | Description | Routing Behavior |
29
+ |------|-------------|-----------------|
30
+ | `new-file` | Creating new files from scratch | Normal Thompson routing |
31
+ | `refactoring` | Modifying existing code | Normal Thompson routing |
32
+ | `integration` | Connecting components | Always competing (high variance) |
33
+ | `test-only` | Only running/adding tests | Normal Thompson routing |
34
+
35
+ ### Data Storage
36
+
37
+ - `logs/strategy-perf.json` — Win/loss counters per strategy per batch type
38
+ - `logs/mab-lessons.json` — Patterns observed by the judge agent
39
+
40
+ ### Human Calibration
41
+
42
+ The first 10 competing runs prompt for human override (if stdin is a tty).
43
+ This calibrates the system before it runs fully autonomously.
44
+ After `calibration_complete: true`, the system trusts its own routing.
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env bash
2
+ # pull-community-lessons.sh — Fetch lessons + strategy data from upstream remote
3
+ #
4
+ # Usage: pull-community-lessons.sh [--remote <name>] [--dry-run] [--help]
5
+ set -euo pipefail
6
+
7
+ REMOTE="upstream"
8
+ DRY_RUN=false
9
+
10
+ usage() {
11
+ cat <<'USAGE'
12
+ pull-community-lessons.sh — Fetch community lessons and strategy data from upstream
13
+
14
+ Usage: pull-community-lessons.sh [--remote <name>] [--dry-run] [--help]
15
+
16
+ Options:
17
+ --remote <name> Git remote name (default: upstream)
18
+ --dry-run Show what would be fetched without changing anything
19
+ -h, --help Show this help
20
+ USAGE
21
+ }
22
+
23
+ while [[ $# -gt 0 ]]; do
24
+ case "$1" in
25
+ -h|--help) usage; exit 0 ;;
26
+ --remote) REMOTE="$2"; shift 2 ;;
27
+ --dry-run) DRY_RUN=true; shift ;;
28
+ *) echo "ERROR: Unknown option: $1" >&2; exit 1 ;;
29
+ esac
30
+ done
31
+
32
+ # Verify remote exists
33
+ if ! git remote get-url "$REMOTE" > /dev/null 2>&1; then
34
+ echo "ERROR: Remote '$REMOTE' not found." >&2
35
+ echo "Add it with: git remote add $REMOTE <url>" >&2
36
+ exit 1
37
+ fi
38
+
39
+ echo "Fetching from $REMOTE..."
40
+ git fetch "$REMOTE" main 2>/dev/null || {
41
+ echo "ERROR: Failed to fetch from $REMOTE" >&2
42
+ exit 1
43
+ }
44
+
45
+ # Count new lessons
46
+ new_count=0
47
+ while IFS= read -r remote_lesson; do
48
+ local_path="docs/lessons/$(basename "$remote_lesson")"
49
+ if [[ ! -f "$local_path" ]]; then
50
+ new_count=$((new_count + 1))
51
+ if [[ "$DRY_RUN" == true ]]; then
52
+ echo " Would copy: $(basename "$remote_lesson")"
53
+ else
54
+ git show "$REMOTE/main:$remote_lesson" > "$local_path" 2>/dev/null || true
55
+ fi
56
+ fi
57
+ done < <(git ls-tree -r --name-only "$REMOTE/main" -- docs/lessons/ 2>/dev/null | grep '\.md$' || true)
58
+
59
+ # Merge strategy-perf.json additively
60
+ local_perf="logs/strategy-perf.json"
61
+ if git show "$REMOTE/main:logs/strategy-perf.json" > /dev/null 2>&1; then
62
+ if [[ -f "$local_perf" ]]; then
63
+ if [[ "$DRY_RUN" == true ]]; then
64
+ echo " Would merge strategy-perf.json (local wins + upstream wins)"
65
+ else
66
+ local_data=$(cat "$local_perf")
67
+ remote_data=$(git show "$REMOTE/main:logs/strategy-perf.json" 2>/dev/null)
68
+
69
+ # Merge: take max(local, upstream) per counter — idempotent on repeated pulls
70
+ tmp=$(mktemp)
71
+ echo "$local_data" | jq --argjson remote "$remote_data" '
72
+ def max(a; b): if a > b then a else b end;
73
+ . as $local |
74
+ ["new-file", "refactoring", "integration", "test-only"] | reduce .[] as $bt ($local;
75
+ .[$bt].superpowers.wins = max(.[$bt].superpowers.wins; $remote[$bt].superpowers.wins // 0) |
76
+ .[$bt].superpowers.losses = max(.[$bt].superpowers.losses; $remote[$bt].superpowers.losses // 0) |
77
+ .[$bt].ralph.wins = max(.[$bt].ralph.wins; $remote[$bt].ralph.wins // 0) |
78
+ .[$bt].ralph.losses = max(.[$bt].ralph.losses; $remote[$bt].ralph.losses // 0)
79
+ )
80
+ ' > "$tmp" && mv "$tmp" "$local_perf"
81
+ echo " Merged strategy-perf.json"
82
+ fi
83
+ fi
84
+ fi
85
+
86
+ echo ""
87
+ echo "Pull complete: $new_count new lessons"
88
+ if [[ "$DRY_RUN" == true ]]; then
89
+ echo "(dry run — no changes made)"
90
+ fi