tea-rags 1.51.2 → 1.52.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 (334) hide show
  1. package/README.md +303 -138
  2. package/benchmarks/bench-model-ab.mjs +407 -0
  3. package/build/bootstrap/factory.d.ts.map +1 -1
  4. package/build/bootstrap/factory.js +19 -15
  5. package/build/bootstrap/factory.js.map +1 -1
  6. package/build/bootstrap/project-ingest-factory.d.ts +7 -3
  7. package/build/bootstrap/project-ingest-factory.d.ts.map +1 -1
  8. package/build/bootstrap/project-ingest-factory.js +2 -2
  9. package/build/bootstrap/project-ingest-factory.js.map +1 -1
  10. package/build/cli/commands/update.d.ts +2 -0
  11. package/build/cli/commands/update.d.ts.map +1 -1
  12. package/build/cli/commands/update.js +9 -1
  13. package/build/cli/commands/update.js.map +1 -1
  14. package/build/cli/plugin-sync/index.d.ts +4 -1
  15. package/build/cli/plugin-sync/index.d.ts.map +1 -1
  16. package/build/cli/plugin-sync/index.js +9 -18
  17. package/build/cli/plugin-sync/index.js.map +1 -1
  18. package/build/cli/plugin-sync/types.d.ts +8 -1
  19. package/build/cli/plugin-sync/types.d.ts.map +1 -1
  20. package/build/cli/plugin-sync/types.js +24 -0
  21. package/build/cli/plugin-sync/types.js.map +1 -1
  22. package/build/cli/plugin-sync/zcode.d.ts +46 -0
  23. package/build/cli/plugin-sync/zcode.d.ts.map +1 -0
  24. package/build/cli/plugin-sync/zcode.js +163 -0
  25. package/build/cli/plugin-sync/zcode.js.map +1 -0
  26. package/build/core/adapters/vcs/git/adapter.d.ts +8 -1
  27. package/build/core/adapters/vcs/git/adapter.d.ts.map +1 -1
  28. package/build/core/adapters/vcs/git/adapter.js.map +1 -1
  29. package/build/core/adapters/vcs/git/es-git/adapter.d.ts +4 -1
  30. package/build/core/adapters/vcs/git/es-git/adapter.d.ts.map +1 -1
  31. package/build/core/adapters/vcs/git/es-git/adapter.js +2 -2
  32. package/build/core/adapters/vcs/git/es-git/adapter.js.map +1 -1
  33. package/build/core/adapters/vcs/git/git-cli/adapter.d.ts +4 -1
  34. package/build/core/adapters/vcs/git/git-cli/adapter.d.ts.map +1 -1
  35. package/build/core/adapters/vcs/git/git-cli/adapter.js +2 -2
  36. package/build/core/adapters/vcs/git/git-cli/adapter.js.map +1 -1
  37. package/build/core/adapters/vcs/git/git-cli/history.d.ts +4 -1
  38. package/build/core/adapters/vcs/git/git-cli/history.d.ts.map +1 -1
  39. package/build/core/adapters/vcs/git/git-cli/history.js +9 -2
  40. package/build/core/adapters/vcs/git/git-cli/history.js.map +1 -1
  41. package/build/core/api/internal/app-factory.d.ts +1 -1
  42. package/build/core/api/internal/app-factory.d.ts.map +1 -1
  43. package/build/core/api/internal/app-factory.js +3 -2
  44. package/build/core/api/internal/app-factory.js.map +1 -1
  45. package/build/core/api/internal/composition.d.ts +1 -1
  46. package/build/core/api/internal/composition.d.ts.map +1 -1
  47. package/build/core/api/internal/composition.js +7 -1
  48. package/build/core/api/internal/composition.js.map +1 -1
  49. package/build/core/api/internal/facades/explore-facade.d.ts +1 -1
  50. package/build/core/api/internal/facades/explore-facade.d.ts.map +1 -1
  51. package/build/core/api/internal/infra/working-tree-graph-read.d.ts +22 -0
  52. package/build/core/api/internal/infra/working-tree-graph-read.d.ts.map +1 -1
  53. package/build/core/api/internal/infra/working-tree-graph-read.js +75 -1
  54. package/build/core/api/internal/infra/working-tree-graph-read.js.map +1 -1
  55. package/build/core/api/internal/migration-parser.d.ts.map +1 -1
  56. package/build/core/api/internal/migration-parser.js +4 -1
  57. package/build/core/api/internal/migration-parser.js.map +1 -1
  58. package/build/core/api/internal/ops/explore-ops.d.ts +7 -2
  59. package/build/core/api/internal/ops/explore-ops.d.ts.map +1 -1
  60. package/build/core/api/internal/ops/explore-ops.js +98 -63
  61. package/build/core/api/internal/ops/explore-ops.js.map +1 -1
  62. package/build/core/api/internal/ops/indexing-ops.js +1 -0
  63. package/build/core/api/internal/ops/indexing-ops.js.map +1 -1
  64. package/build/core/api/public/dto/ingest.d.ts +8 -0
  65. package/build/core/api/public/dto/ingest.d.ts.map +1 -1
  66. package/build/core/api/tools/code/register-index-tools.d.ts.map +1 -1
  67. package/build/core/api/tools/code/register-index-tools.js +2 -0
  68. package/build/core/api/tools/code/register-index-tools.js.map +1 -1
  69. package/build/core/contracts/types/language.d.ts +8 -0
  70. package/build/core/contracts/types/language.d.ts.map +1 -1
  71. package/build/core/contracts/types/language.js.map +1 -1
  72. package/build/core/contracts/types/provider.d.ts +17 -0
  73. package/build/core/contracts/types/provider.d.ts.map +1 -1
  74. package/build/core/domains/explore/index.d.ts +2 -0
  75. package/build/core/domains/explore/index.d.ts.map +1 -1
  76. package/build/core/domains/explore/index.js +2 -0
  77. package/build/core/domains/explore/index.js.map +1 -1
  78. package/build/core/domains/explore/resolver-batch.d.ts +45 -0
  79. package/build/core/domains/explore/resolver-batch.d.ts.map +1 -0
  80. package/build/core/domains/explore/resolver-batch.js +175 -0
  81. package/build/core/domains/explore/resolver-batch.js.map +1 -0
  82. package/build/core/domains/explore/working-tree/tree-graph-marker.d.ts +0 -27
  83. package/build/core/domains/explore/working-tree/tree-graph-marker.d.ts.map +1 -1
  84. package/build/core/domains/explore/working-tree/tree-graph-marker.js +15 -1
  85. package/build/core/domains/explore/working-tree/tree-graph-marker.js.map +1 -1
  86. package/build/core/domains/ingest/errors/ingest-errors.d.ts.map +1 -1
  87. package/build/core/domains/ingest/errors/ingest-errors.js +4 -2
  88. package/build/core/domains/ingest/errors/ingest-errors.js.map +1 -1
  89. package/build/core/domains/ingest/operations/reindexing.d.ts +17 -0
  90. package/build/core/domains/ingest/operations/reindexing.d.ts.map +1 -1
  91. package/build/core/domains/ingest/operations/reindexing.js +45 -1
  92. package/build/core/domains/ingest/operations/reindexing.js.map +1 -1
  93. package/build/core/domains/ingest/pipeline/chunk-point-payload.d.ts.map +1 -1
  94. package/build/core/domains/ingest/pipeline/chunk-point-payload.js +4 -1
  95. package/build/core/domains/ingest/pipeline/chunk-point-payload.js.map +1 -1
  96. package/build/core/domains/ingest/pipeline/chunker/infra/worker.js +3 -0
  97. package/build/core/domains/ingest/pipeline/chunker/infra/worker.js.map +1 -1
  98. package/build/core/domains/ingest/pipeline/enrichment/backfiller.d.ts.map +1 -1
  99. package/build/core/domains/ingest/pipeline/enrichment/backfiller.js +16 -0
  100. package/build/core/domains/ingest/pipeline/enrichment/backfiller.js.map +1 -1
  101. package/build/core/domains/ingest/pipeline/enrichment/completion-runner.d.ts.map +1 -1
  102. package/build/core/domains/ingest/pipeline/enrichment/completion-runner.js +4 -1
  103. package/build/core/domains/ingest/pipeline/enrichment/completion-runner.js.map +1 -1
  104. package/build/core/domains/ingest/pipeline/enrichment/file-phase.d.ts.map +1 -1
  105. package/build/core/domains/ingest/pipeline/enrichment/file-phase.js +11 -0
  106. package/build/core/domains/ingest/pipeline/enrichment/file-phase.js.map +1 -1
  107. package/build/core/domains/ingest/pipeline/file-ingestor.d.ts.map +1 -1
  108. package/build/core/domains/ingest/pipeline/file-ingestor.js +10 -6
  109. package/build/core/domains/ingest/pipeline/file-ingestor.js.map +1 -1
  110. package/build/core/domains/ingest/pipeline/status-module.d.ts.map +1 -1
  111. package/build/core/domains/ingest/pipeline/status-module.js +3 -8
  112. package/build/core/domains/ingest/pipeline/status-module.js.map +1 -1
  113. package/build/core/domains/ingest/sync/index-holes.d.ts +40 -0
  114. package/build/core/domains/ingest/sync/index-holes.d.ts.map +1 -0
  115. package/build/core/domains/ingest/sync/index-holes.js +50 -0
  116. package/build/core/domains/ingest/sync/index-holes.js.map +1 -0
  117. package/build/core/domains/ingest/sync/index.d.ts +1 -0
  118. package/build/core/domains/ingest/sync/index.d.ts.map +1 -1
  119. package/build/core/domains/ingest/sync/index.js +1 -0
  120. package/build/core/domains/ingest/sync/index.js.map +1 -1
  121. package/build/core/domains/language/capability/readme.d.ts +1 -1
  122. package/build/core/domains/language/capability/readme.js +2 -2
  123. package/build/core/domains/language/errors.d.ts +13 -1
  124. package/build/core/domains/language/errors.d.ts.map +1 -1
  125. package/build/core/domains/language/errors.js +18 -0
  126. package/build/core/domains/language/errors.js.map +1 -1
  127. package/build/core/domains/language/factory.d.ts +41 -10
  128. package/build/core/domains/language/factory.d.ts.map +1 -1
  129. package/build/core/domains/language/factory.js +87 -85
  130. package/build/core/domains/language/factory.js.map +1 -1
  131. package/build/core/domains/language/index.d.ts +2 -5
  132. package/build/core/domains/language/index.d.ts.map +1 -1
  133. package/build/core/domains/language/index.js +9 -5
  134. package/build/core/domains/language/index.js.map +1 -1
  135. package/build/core/domains/language/provider-sources.d.ts +56 -0
  136. package/build/core/domains/language/provider-sources.d.ts.map +1 -0
  137. package/build/core/domains/language/provider-sources.js +156 -0
  138. package/build/core/domains/language/provider-sources.js.map +1 -0
  139. package/build/core/domains/language/ruby/capability.d.ts.map +1 -1
  140. package/build/core/domains/language/ruby/capability.js +6 -1
  141. package/build/core/domains/language/ruby/capability.js.map +1 -1
  142. package/build/core/domains/language/ruby/chunking/rspec-scope-chunker.d.ts.map +1 -1
  143. package/build/core/domains/language/ruby/chunking/rspec-scope-chunker.js +4 -1
  144. package/build/core/domains/language/ruby/chunking/rspec-scope-chunker.js.map +1 -1
  145. package/build/core/domains/language/rust/capability.js +1 -1
  146. package/build/core/domains/language/rust/capability.js.map +1 -1
  147. package/build/core/domains/language/typescript/capability.js +1 -1
  148. package/build/core/domains/language/typescript/capability.js.map +1 -1
  149. package/build/core/domains/trajectory/codegraph/factory.d.ts.map +1 -1
  150. package/build/core/domains/trajectory/codegraph/factory.js +3 -0
  151. package/build/core/domains/trajectory/codegraph/factory.js.map +1 -1
  152. package/build/core/domains/trajectory/git/infra/blame-store.d.ts +5 -1
  153. package/build/core/domains/trajectory/git/infra/blame-store.d.ts.map +1 -1
  154. package/build/core/domains/trajectory/git/infra/blame-store.js +62 -8
  155. package/build/core/domains/trajectory/git/infra/blame-store.js.map +1 -1
  156. package/build/core/domains/trajectory/git/infra/file-lifetime-store.d.ts +38 -0
  157. package/build/core/domains/trajectory/git/infra/file-lifetime-store.d.ts.map +1 -0
  158. package/build/core/domains/trajectory/git/infra/file-lifetime-store.js +105 -0
  159. package/build/core/domains/trajectory/git/infra/file-lifetime-store.js.map +1 -0
  160. package/build/core/domains/trajectory/git/infra/file-lifetime.d.ts +24 -0
  161. package/build/core/domains/trajectory/git/infra/file-lifetime.d.ts.map +1 -1
  162. package/build/core/domains/trajectory/git/infra/file-lifetime.js +55 -1
  163. package/build/core/domains/trajectory/git/infra/file-lifetime.js.map +1 -1
  164. package/build/core/domains/trajectory/git/provider.d.ts +15 -1
  165. package/build/core/domains/trajectory/git/provider.d.ts.map +1 -1
  166. package/build/core/domains/trajectory/git/provider.js +61 -8
  167. package/build/core/domains/trajectory/git/provider.js.map +1 -1
  168. package/build/core/types.d.ts +8 -0
  169. package/build/core/types.d.ts.map +1 -1
  170. package/build/mcp/resources/generated/agent-context.d.ts.map +1 -1
  171. package/build/mcp/resources/generated/agent-context.js +1 -1
  172. package/build/mcp/resources/generated/agent-context.js.map +1 -1
  173. package/build/typecheck-tests.tsbuildinfo +1 -0
  174. package/harness/cursor/README.md +4 -1
  175. package/harness/cursor/dinopowers/.cursor-plugin/plugin.json +3 -2
  176. package/harness/cursor/dinopowers/icon.png +0 -0
  177. package/harness/cursor/dinopowers/skills/dino-brainstorming/SKILL.md +14 -12
  178. package/harness/cursor/dinopowers/skills/dino-executing-plans/SKILL.md +7 -3
  179. package/harness/cursor/dinopowers/skills/dino-finishing-a-development-branch/SKILL.md +3 -3
  180. package/harness/cursor/dinopowers/skills/dino-receiving-code-review/SKILL.md +4 -4
  181. package/harness/cursor/dinopowers/skills/dino-requesting-code-review/SKILL.md +3 -3
  182. package/harness/cursor/dinopowers/skills/dino-systematic-debugging/SKILL.md +12 -12
  183. package/harness/cursor/dinopowers/skills/dino-test-driven-development/SKILL.md +6 -3
  184. package/harness/cursor/dinopowers/skills/dino-verification-before-completion/SKILL.md +3 -3
  185. package/harness/cursor/dinopowers/skills/dino-writing-plans/SKILL.md +7 -3
  186. package/harness/cursor/dinopowers/skills/dino-writing-skills/SKILL.md +4 -4
  187. package/harness/cursor/tea-rags/.cursor-plugin/plugin.json +3 -2
  188. package/harness/cursor/tea-rags/icon.png +0 -0
  189. package/harness/cursor/tea-rags/rules/tea-rags-core.mdc +12 -8
  190. package/harness/cursor/tea-rags/scripts/check-build-fresh.sh +1 -0
  191. package/harness/cursor/tea-rags/scripts/reread-ledger.mjs +6 -3
  192. package/harness/cursor/tea-rags/skills/analytics-rerank/SKILL.md +3 -3
  193. package/harness/cursor/tea-rags/skills/architecture-diagnostics/SKILL.md +7 -7
  194. package/harness/cursor/tea-rags/skills/bug-hunt/SKILL.md +9 -9
  195. package/harness/cursor/tea-rags/skills/data-driven-generation/SKILL.md +6 -4
  196. package/harness/cursor/tea-rags/skills/explore/SKILL.md +3 -3
  197. package/harness/cursor/tea-rags/skills/extract-project-patterns/SKILL.md +3 -3
  198. package/harness/cursor/tea-rags/skills/filter-building/SKILL.md +3 -3
  199. package/harness/cursor/tea-rags/skills/force-reindex/SKILL.md +3 -3
  200. package/harness/cursor/tea-rags/skills/index/SKILL.md +3 -3
  201. package/harness/cursor/tea-rags/skills/mr-review/SKILL.md +5 -3
  202. package/harness/cursor/tea-rags/skills/pattern-search/SKILL.md +3 -3
  203. package/harness/cursor/tea-rags/skills/refactoring-planning/SKILL.md +3 -3
  204. package/harness/cursor/tea-rags/skills/refactoring-scan/SKILL.md +3 -3
  205. package/harness/cursor/tea-rags/skills/report-issue/SKILL.md +3 -3
  206. package/harness/cursor/tea-rags/skills/risk-assessment/SKILL.md +4 -4
  207. package/harness/cursor/tea-rags/skills/test-first/SKILL.md +4 -4
  208. package/harness/cursor/tea-rags/skills/tests-as-context/SKILL.md +3 -3
  209. package/harness/cursor/tea-rags-setup/.cursor-plugin/plugin.json +3 -2
  210. package/harness/cursor/tea-rags-setup/icon.png +0 -0
  211. package/harness/cursor/tea-rags-setup/scripts/detect.mjs +4 -0
  212. package/harness/cursor/tea-rags-setup/skills/install/SKILL.md +17 -9
  213. package/harness/cursor/tea-rags-setup/skills/tune/SKILL.md +3 -3
  214. package/harness/zcode/MANUAL-TEST.md +43 -0
  215. package/harness/zcode/README.md +141 -0
  216. package/harness/zcode/dinopowers/.zcode-plugin/plugin.json +10 -0
  217. package/harness/zcode/dinopowers/CHAINING.md +56 -0
  218. package/harness/zcode/dinopowers/FRESHNESS.md +33 -0
  219. package/harness/zcode/dinopowers/hooks/hooks.json +30 -0
  220. package/harness/zcode/dinopowers/icon.png +0 -0
  221. package/harness/zcode/dinopowers/scripts/main-session-routing.sh +41 -0
  222. package/harness/zcode/dinopowers/scripts/main-session-routing.txt +24 -0
  223. package/harness/zcode/dinopowers/scripts/wrapper-routing-agent.sh +19 -0
  224. package/harness/zcode/dinopowers/scripts/wrapper-routing.txt +25 -0
  225. package/harness/zcode/dinopowers/skills/dino-brainstorming/SKILL.md +286 -0
  226. package/harness/zcode/dinopowers/skills/dino-executing-plans/SKILL.md +375 -0
  227. package/harness/zcode/dinopowers/skills/dino-finishing-a-development-branch/SKILL.md +186 -0
  228. package/harness/zcode/dinopowers/skills/dino-receiving-code-review/SKILL.md +275 -0
  229. package/harness/zcode/dinopowers/skills/dino-receiving-code-review/references/call-route.md +53 -0
  230. package/harness/zcode/dinopowers/skills/dino-requesting-code-review/SKILL.md +260 -0
  231. package/harness/zcode/dinopowers/skills/dino-systematic-debugging/SKILL.md +358 -0
  232. package/harness/zcode/dinopowers/skills/dino-systematic-debugging/references/red-flags.md +47 -0
  233. package/harness/zcode/dinopowers/skills/dino-systematic-debugging/references/trace-chain.md +36 -0
  234. package/harness/zcode/dinopowers/skills/dino-test-driven-development/SKILL.md +263 -0
  235. package/harness/zcode/dinopowers/skills/dino-verification-before-completion/SKILL.md +268 -0
  236. package/harness/zcode/dinopowers/skills/dino-writing-plans/SKILL.md +332 -0
  237. package/harness/zcode/dinopowers/skills/dino-writing-skills/SKILL.md +134 -0
  238. package/harness/zcode/marketplace.json +32 -0
  239. package/harness/zcode/tea-rags/.mcp.json +9 -0
  240. package/harness/zcode/tea-rags/.zcode-plugin/plugin.json +11 -0
  241. package/harness/zcode/tea-rags/hooks/hooks.json +129 -0
  242. package/harness/zcode/tea-rags/icon.png +0 -0
  243. package/harness/zcode/tea-rags/repair/README.md +38 -0
  244. package/harness/zcode/tea-rags/repair/cycles.md +36 -0
  245. package/harness/zcode/tea-rags/repair/facadeContract.md +32 -0
  246. package/harness/zcode/tea-rags/repair/hubLike.md +72 -0
  247. package/harness/zcode/tea-rags/repair/layeringBackEdge.md +64 -0
  248. package/harness/zcode/tea-rags/repair/leakingAbstraction.md +58 -0
  249. package/harness/zcode/tea-rags/repair/mainSequence.md +48 -0
  250. package/harness/zcode/tea-rags/repair/silentCoupling.md +43 -0
  251. package/harness/zcode/tea-rags/repair/splitCandidates.md +37 -0
  252. package/harness/zcode/tea-rags/repair/stableDependencies.md +76 -0
  253. package/harness/zcode/tea-rags/rules/core.md +146 -0
  254. package/harness/zcode/tea-rags/rules/references/axis-splitting.md +50 -0
  255. package/harness/zcode/tea-rags/rules/references/report-follow-up.md +36 -0
  256. package/harness/zcode/tea-rags/rules/references/runtime-introspection.md +138 -0
  257. package/harness/zcode/tea-rags/rules/references/signal-interpretation.md +545 -0
  258. package/harness/zcode/tea-rags/scripts/check-build-fresh.sh +24 -0
  259. package/harness/zcode/tea-rags/scripts/cleanup-clone.sh +12 -0
  260. package/harness/zcode/tea-rags/scripts/cleanup-worktree-clone.sh +48 -0
  261. package/harness/zcode/tea-rags/scripts/inject-rules.sh +120 -0
  262. package/harness/zcode/tea-rags/scripts/reread-ledger.mjs +1610 -0
  263. package/harness/zcode/tea-rags/scripts/search-drift.sh +212 -0
  264. package/harness/zcode/tea-rags/scripts/session-digest.sh +33 -0
  265. package/harness/zcode/tea-rags/scripts/session-rules.sh +20 -0
  266. package/harness/zcode/tea-rags/scripts/standard-zone.ere +1 -0
  267. package/harness/zcode/tea-rags/scripts/subagent-block.txt +32 -0
  268. package/harness/zcode/tea-rags/scripts/subagent-context.sh +31 -0
  269. package/harness/zcode/tea-rags/scripts/turn-routing.sh +82 -0
  270. package/harness/zcode/tea-rags/scripts/turn-routing.txt +6 -0
  271. package/harness/zcode/tea-rags/skills/analytics-rerank/SKILL.md +276 -0
  272. package/harness/zcode/tea-rags/skills/architecture-diagnostics/SKILL.md +261 -0
  273. package/harness/zcode/tea-rags/skills/architecture-diagnostics/references/anti-patterns.md +55 -0
  274. package/harness/zcode/tea-rags/skills/architecture-diagnostics/references/phase-1-report.md +106 -0
  275. package/harness/zcode/tea-rags/skills/architecture-diagnostics/references/phase-3b-leaking-abstraction.md +46 -0
  276. package/harness/zcode/tea-rags/skills/architecture-diagnostics/references/phase-3c-silent-coupling.md +55 -0
  277. package/harness/zcode/tea-rags/skills/architecture-diagnostics/references/phase-3c2-shotgun-surgery.md +93 -0
  278. package/harness/zcode/tea-rags/skills/architecture-diagnostics/references/phase-3d-main-sequence.md +29 -0
  279. package/harness/zcode/tea-rags/skills/architecture-diagnostics/references/phase-3d2-hub-like.md +26 -0
  280. package/harness/zcode/tea-rags/skills/architecture-diagnostics/references/phase-3d3-propagation-cost.md +26 -0
  281. package/harness/zcode/tea-rags/skills/architecture-diagnostics/references/phase-3e-layering.md +29 -0
  282. package/harness/zcode/tea-rags/skills/architecture-diagnostics/references/phase-3f-layer-map.md +24 -0
  283. package/harness/zcode/tea-rags/skills/architecture-diagnostics/references/phase-3g-dependency-norms.md +70 -0
  284. package/harness/zcode/tea-rags/skills/architecture-diagnostics/references/phase-3h-diff-time.md +37 -0
  285. package/harness/zcode/tea-rags/skills/architecture-diagnostics/references/phase-3i-remedy-simulation.md +36 -0
  286. package/harness/zcode/tea-rags/skills/architecture-diagnostics/references/phase-4-exclusions.md +55 -0
  287. package/harness/zcode/tea-rags/skills/bug-hunt/SKILL.md +282 -0
  288. package/harness/zcode/tea-rags/skills/bug-hunt/references/call-path.md +97 -0
  289. package/harness/zcode/tea-rags/skills/bug-hunt/references/probes.md +69 -0
  290. package/harness/zcode/tea-rags/skills/bug-hunt/references/triage.md +56 -0
  291. package/harness/zcode/tea-rags/skills/data-driven-generation/SKILL.md +430 -0
  292. package/harness/zcode/tea-rags/skills/data-driven-generation/references/step-5-style.md +118 -0
  293. package/harness/zcode/tea-rags/skills/data-driven-generation/references/step-6-generate.md +66 -0
  294. package/harness/zcode/tea-rags/skills/data-driven-generation/references/step-7-verify.md +210 -0
  295. package/harness/zcode/tea-rags/skills/data-driven-generation/strategies/conservative.md +19 -0
  296. package/harness/zcode/tea-rags/skills/data-driven-generation/strategies/defensive.md +24 -0
  297. package/harness/zcode/tea-rags/skills/data-driven-generation/strategies/stabilization.md +21 -0
  298. package/harness/zcode/tea-rags/skills/data-driven-generation/strategies/standard.md +13 -0
  299. package/harness/zcode/tea-rags/skills/explore/SKILL.md +112 -0
  300. package/harness/zcode/tea-rags/skills/explore/references/architecture-pattern.md +63 -0
  301. package/harness/zcode/tea-rags/skills/explore/references/cycle-pattern.md +43 -0
  302. package/harness/zcode/tea-rags/skills/explore/references/entry-point-pattern.md +48 -0
  303. package/harness/zcode/tea-rags/skills/explore/references/exemplar-pattern.md +46 -0
  304. package/harness/zcode/tea-rags/skills/explore/references/explain-pattern.md +33 -0
  305. package/harness/zcode/tea-rags/skills/explore/references/explore-flow.md +89 -0
  306. package/harness/zcode/tea-rags/skills/explore/references/naming-pattern.md +15 -0
  307. package/harness/zcode/tea-rags/skills/explore/references/pre-gen-pattern.md +97 -0
  308. package/harness/zcode/tea-rags/skills/explore/references/trace-pattern.md +20 -0
  309. package/harness/zcode/tea-rags/skills/explore/references/usage-pattern.md +75 -0
  310. package/harness/zcode/tea-rags/skills/extract-project-patterns/SKILL.md +149 -0
  311. package/harness/zcode/tea-rags/skills/filter-building/SKILL.md +359 -0
  312. package/harness/zcode/tea-rags/skills/force-reindex/SKILL.md +76 -0
  313. package/harness/zcode/tea-rags/skills/index/SKILL.md +87 -0
  314. package/harness/zcode/tea-rags/skills/mr-review/SKILL.md +217 -0
  315. package/harness/zcode/tea-rags/skills/mr-review/references/delivery-contract.md +160 -0
  316. package/harness/zcode/tea-rags/skills/mr-review/references/dimension-playbook.md +237 -0
  317. package/harness/zcode/tea-rags/skills/pattern-search/SKILL.md +178 -0
  318. package/harness/zcode/tea-rags/skills/refactoring-planning/SKILL.md +193 -0
  319. package/harness/zcode/tea-rags/skills/refactoring-scan/SKILL.md +150 -0
  320. package/harness/zcode/tea-rags/skills/report-issue/SKILL.md +95 -0
  321. package/harness/zcode/tea-rags/skills/risk-assessment/SKILL.md +622 -0
  322. package/harness/zcode/tea-rags/skills/risk-assessment/references/anti-patterns.md +77 -0
  323. package/harness/zcode/tea-rags/skills/risk-assessment/references/classification-tiers.md +28 -0
  324. package/harness/zcode/tea-rags/skills/risk-assessment/references/enrich.md +213 -0
  325. package/harness/zcode/tea-rags/skills/test-first/SKILL.md +112 -0
  326. package/harness/zcode/tea-rags/skills/tests-as-context/SKILL.md +357 -0
  327. package/harness/zcode/tea-rags-setup/.zcode-plugin/plugin.json +9 -0
  328. package/harness/zcode/tea-rags-setup/icon.png +0 -0
  329. package/harness/zcode/tea-rags-setup/scripts/contextignore.mjs +107 -0
  330. package/harness/zcode/tea-rags-setup/scripts/detect.mjs +98 -0
  331. package/harness/zcode/tea-rags-setup/scripts/profile.mjs +110 -0
  332. package/harness/zcode/tea-rags-setup/skills/install/SKILL.md +216 -0
  333. package/harness/zcode/tea-rags-setup/skills/tune/SKILL.md +80 -0
  334. package/package.json +3 -1
@@ -0,0 +1,89 @@
1
+ # Explore flow — broad scope, axis split, depth
2
+
3
+ Use for an explicitly broad system/domain introduction. Reuse retained evidence
4
+ and select only steps needed for that request; a directory name or snippet alone
5
+ does not require this workflow. Point questions do not need it.
6
+
7
+ ## Flow
8
+
9
+ ```
10
+ [broad scope? → ORIENT (entry points)] → BREADTH (search) →
11
+ pick interesting results →
12
+ LATERAL (find_similar) — same pattern elsewhere?
13
+ DEPTH (find_symbol) — trace specific symbol?
14
+ → explain to developer
15
+ ```
16
+
17
+ ## ORIENT (broad scope ONLY)
18
+
19
+ A typed path → SKILL.md BREADTH "Path typed first" (outline first; ORIENT /
20
+ BREADTH add after it).
21
+
22
+ **Gate by target.** System / domain / directory ("introduce me to the project",
23
+ "full picture of X", "walk me through domain Y") → ORIENT first. Named symbol /
24
+ narrow question ("what does Reranker#rerank do", "where is X used") → SKIP to
25
+ BREADTH (Scope extraction still runs; its pathPattern rides on BREADTH).
26
+
27
+ Architecture phrasing never reaches here — codegraph row 4 catches it;
28
+ architecture-pattern.md Step 0 runs same orientation.
29
+
30
+ Entry points = flow skeleton; see them BEFORE breadth so results land on a map.
31
+
32
+ - **Codegraph on** (graph tools in tool list):
33
+ `semantic_search rerank="entryPoint" pathPattern=<scope> metaOnly:true limit:5`
34
+ — graph-confirmed composition roots (fanOutPerLine↑, fanIn↓). Overlay shows
35
+ `fanIn` / `fanOut` / `imports`.
36
+ - **Codegraph off**:
37
+ `semantic_search rerank="onboarding" pathPattern=<scope> metaOnly:true limit:5`
38
+ — stable + documented + mature files. FLAG as content-inferred, NOT
39
+ graph-confirmed.
40
+ - Small / flat scope (no clear driver) → say ranking degraded; never present
41
+ utility as "the entry point".
42
+
43
+ ORIENT provides a map; continue only if requested facts remain unsupported.
44
+ Explicit "entry point" INTENT ("where does X start") → codegraph row 3, not
45
+ here.
46
+
47
+ ## Broad BREADTH — split axes
48
+
49
+ Select relevant axes; a broad question does not automatically require all three.
50
+ When more than one is needed, separate them per
51
+ `../../../rules/references/axis-splitting.md` (never `language` as axis proxy):
52
+
53
+ 1. sources FIRST — `testFile: "exclude", documentation: "exclude"`
54
+ 2. tests — `testFile: "only"` when coverage/expected behavior is requested or
55
+ uncertain
56
+ 3. docs — `documentation: "only"` when intent/specification is needed
57
+ (hypothesis, never sole evidence). Doc claim (number, limit, default) →
58
+ SKILL.md "Doc claim in hand" (verification line + both outcome lines).
59
+
60
+ No `filter:{presets}` by default — understanding needs breadth.
61
+
62
+ Start discovery with metadata and a small page, then select anchors. Read only
63
+ methods required for current claims, not whole classes or trees. Expand an
64
+ exhaustive request deliberately; never infer absence from the first page.
65
+
66
+ Scan results: files, modules, patterns, domain boundaries.
67
+
68
+ ## PICK + EXPLORE
69
+
70
+ For a result needed to close an evidence gap:
71
+
72
+ - **"Same thing elsewhere?"** → find_similar (code or chunk ID)
73
+ - **"What is this symbol?"** → find_symbol (full definition). 0 results → act on
74
+ `empty.reason` (`unknownSymbol` / `ambiguous` → a `suggestions` id verbatim),
75
+ still nothing → hybrid_search.
76
+ - **"Surrounding context"** → `find_symbol` `relativePath` outline → drill
77
+ neighbour id (`navigation.prev/nextSymbolId`); never Read.
78
+
79
+ Fewer deep dives > many shallow.
80
+
81
+ ## Direct input (no BREADTH)
82
+
83
+ Treat a supplied snippet as evidence. Use `find_similar` only when matching code
84
+ or similarities are requested; otherwise explain the supplied code directly.
85
+
86
+ ## FORMAT
87
+
88
+ Answer per strategy reference picked in Step 0 (explain / trace / pre-gen /
89
+ exemplar pattern).
@@ -0,0 +1,15 @@
1
+ # Naming pattern (codegraph row 5)
2
+
3
+ Opened from explore codegraph row 5 ("what does the project call X", "is this
4
+ name right", a type `<T>` to name).
5
+
6
+ `get_naming_lexicon(concept+language | types | names)`. Checked first: the
7
+ question quotes a candidate name (`<name>` — "is `<name>` a good name", even
8
+ with "or what do we call it") → `names:[{name: "<name>", kind, type?: "<T>"}]` —
9
+ its verdict + alternatives answer both halves; never `concept`. No candidate
10
+ name, a type `<T>` named ("how is a variable / value of `<T>` named", "как
11
+ называть переменную с `<T>`") → copied: `get_naming_lexicon(types:["<T>"])` —
12
+ never `concept:"<T>"`. `concept` only for "what do we call X" (X = idea, not a
13
+ type). Names in a diff → SKILL.md row 5 (`review_changes`). Answer = dominant
14
+ shape + top names/terms with holders; reading + codegraph-off fallback:
15
+ `../../data-driven-generation/SKILL.md` Step 5 "Naming (lexicon)".
@@ -0,0 +1,97 @@
1
+ # PRE-GEN Pattern
2
+
3
+ The explicit pre-change branch gathers actionable context — files, risk signals,
4
+ overlay labels.
5
+
6
+ Only an explicit pre-change investigation uses this branch. A factual follow-up
7
+ inside a design discussion stays a factual question. Reuse held bodies and
8
+ overlay labels; do not repeat discovery or signal lookup for unchanged material.
9
+ Discovery starts with metadata and a small set; select targets before bodies. No
10
+ speculative class/header/tree reads for possible future questions.
11
+
12
+ ## PG-1. DISCOVER
13
+
14
+ Target area files, first matching branch:
15
+
16
+ - **Anchor already in context** (a row or body naming the behaviour) →
17
+ `get_callees(symbolId=<anchor id>, depth=2)` (callers for impact:
18
+ `get_callers`) first, then PG-2 batch — no `semantic_search` /
19
+ `hybrid_search`; new search only for code the graph does not reach
20
+ - **User names a file path** → `find_symbol(path=<cwd>, relativePath=<file>)`
21
+ outline, then `find_symbol(symbol=<id from outline>)` — no symbol lookup, no
22
+ `hybrid_search` / `semantic_search` on it
23
+ - **Behavior/intent** → `semantic_search` (query=$ARGUMENTS, metaOnly=true,
24
+ limit=5 initially, documentation="exclude"; expand only for missing targets)
25
+ - **Known symbol** → `find_symbol` (symbol=<id>) for definition; surrounding
26
+ area → `hybrid_search` (query=$ARGUMENTS, metaOnly=true, limit=5 initially,
27
+ documentation="exclude")
28
+
29
+ Add `pathPattern` if module known, `language` if polyglot.
30
+ `documentation="exclude"` keeps RFC/docs out of result slots.
31
+
32
+ **Checkpoint:** enough relevant targets for the requested change context?
33
+
34
+ - YES → use those targets in PG-2; do not fill an arbitrary quota
35
+ - NO → search only for the missing responsibility, retry once
36
+
37
+ ## PG-2. SIGNAL LOOKUP
38
+
39
+ Needed symbols from PG-1 (typically 2-5, not a minimum) in ONE `find_symbol`
40
+ with rerank for overlay labels (instant, no embedding; rows keyed by `request`,
41
+ misses in `missing[]`).
42
+
43
+ If bodies are held, fetch missing signals with `metaOnly:true`. Otherwise
44
+ include only method bodies that must be inspected for this change.
45
+
46
+ ```
47
+ find_symbol:
48
+ symbols: [<symbol names from PG-1>] ← Class#method (instance) / Class.method (static)
49
+ path: <your working directory>
50
+ rerank: "techDebt" ← its overlayMask labels the PG-2 fields; do not swap presets
51
+ metaOnly: false ← content + rerank = full raw payload (metaOnly drops git.*)
52
+ ```
53
+
54
+ Labels → `rankingOverlay.{file,chunk}.<field>.label`; raw →
55
+ `payload.git.{file,chunk}.<field>` (never labelled).
56
+
57
+ Overlay = chosen preset's `overlayMask` only. `techDebt` covers all labelled
58
+ PG-2 fields (ageDays, commitCount, bugFixRate, churnVolatility,
59
+ blameDominantAuthorPct, recentDominantAuthorPct); other presets drop some
60
+ (`hotspots` has no `commitCount` label).
61
+
62
+ Extract per symbol: bugFixRate, ageDays, churnVolatility, commitCount,
63
+ blameDominantAuthor, blameDominantAuthorPct (live-line owner → silo, "who must
64
+ approve"), recentDominantAuthor, recentDominantAuthorPct (recent committer →
65
+ "who's loaded in"). Feed DDG strategy selection.
66
+
67
+ **Interpretation:** never read single signals in isolation — pair diagnostics in
68
+ `../../../rules/references/signal-interpretation.md`, esp. high churn / age /
69
+ ownership (high churn ≠ active development; mono ownership ≠ silo risk).
70
+
71
+ ## PG-3. DEEP TRACE (optional)
72
+
73
+ Symbols need structure before generation:
74
+
75
+ - `find_symbol` for 1-2 key symbols (definition + imports)
76
+ - 0 results → `hybrid_search`
77
+
78
+ **Limit:** do NOT trace call chains or dependency trees.
79
+
80
+ ## PG-4. OUTPUT
81
+
82
+ ```
83
+ Pre-generation context for: [area]
84
+
85
+ Files: [list with pathPattern-ready format]
86
+ Language: [detected language]
87
+ Symbols with overlay:
88
+ - symbolName: { bugFixRate, ageDays, churnVolatility, commitCount,
89
+ blameDominantAuthor, blameDominantAuthorPct,
90
+ recentDominantAuthor, recentDominantAuthorPct }
91
+
92
+ Context for generation:
93
+ - pathPattern: [ready for data-driven-generation]
94
+ - overlay labels: [per-symbol from PG-2]
95
+ ```
96
+
97
+ Self-contained. data-driven-generation reads overlay labels directly.
@@ -0,0 +1,20 @@
1
+ # TRACE Pattern
2
+
3
+ Backward / forward symbol tracing without codegraph (codegraph on →
4
+ usage-pattern wins).
5
+
6
+ - Reuse retained ids and bodies. Traverse only the depth the question needs;
7
+ there is no minimum number of calls or requirement to reach an entry point.
8
+ - **"What calls X?" (backward)** → exact-name occurrence search (filenames
9
+ first) and needed enclosing bodies. Follow the callers' callers only for a
10
+ requested chain; present it as content-inferred, not a static graph proof.
11
+ - **"What does X call?" / "What does X depend on?" (forward)** → two levels,
12
+ both from find_symbol:
13
+ 1. **File-level:** find_symbol X → chunk payload `imports[]` = file
14
+ dependencies.
15
+ 2. **Method-level:** use called methods in the held body; fetch only missing
16
+ bodies needed to explain the requested flow, in one batch. Present file
17
+ deps flat, method calls as tree:
18
+ `X → { Y.method(), Z.method() } → { ... }`.
19
+
20
+ Citations `file:line`. Quote 3-5 lines, don't dump functions.
@@ -0,0 +1,75 @@
1
+ # USAGE Pattern
2
+
3
+ **Codegraph off** (stated, or registry says off — SKILL.md "Codegraph
4
+ availability") → `find_symbol` + iterative `hybrid_search` name-match (no edge
5
+ truth — say so). Callers, copied, ≥ 2 calls:
6
+ `hybrid_search(query="<X>", metaOnly=true)` → per caller hit
7
+ `hybrid_search(query="<caller>", metaOnly=true)` → repeat ≤ 3 levels
8
+ (`trace-pattern.md`). One call = fail. Path A→B = manual chain, "no static path
9
+ tool". Never call/plan `get_callers` / `get_callees` / `trace_path`.
10
+
11
+ Caller / callee intents via `get_callers` / `get_callees` edge truth (codegraph
12
+ call edges), not content matching — no false hits on comments, strings,
13
+ same-named symbols. "Every / all callers of X" (exhaustive) → Step 2's
14
+ `get_callers`, THEN the occurrence route — `Bash rg "<X>" <dir>` (literal, `-l`;
15
+ `<dir>` = the anchor's dir when known, else the source root) → `find_symbol` on
16
+ the hits. It adds, never replaces: graph = resolved edges, text search = recall
17
+ for calls the graph did not resolve. Report both, edges first. "Where is X used"
18
+ / every occurrence of an exact name or constant → that occurrence route alone,
19
+ never `hybrid_search` for it.
20
+
21
+ ## Step 1 — resolve exact symbolId (MANDATORY)
22
+
23
+ `get_callers` / `get_callees` match exact id; a wrong `#`/`.` separator resolves
24
+ through a swap (`resolvedSymbolId` = the id to carry on), an unknown id answers
25
+ `empty.reason: "unknownSymbol"` + `suggestions` (take one verbatim). Always
26
+ resolve first: `find_symbol symbol=<name>` → pick exact id (`Class#method`
27
+ instance, `Class.method` static, `functionName` top-level). Bare
28
+ `find_symbol symbol=Foo` returns class + all members — choose precise member.
29
+
30
+ ## Step 2 — route by direction
31
+
32
+ - **"Who uses X?" / "who calls X?" / "callers of X"** →
33
+ `get_callers symbolId=<id>` → invoking symbols + `call_expression` preview +
34
+ `file:line`. Impact / "who ends up calling X" → `depth: 2` in the same call.
35
+ - **"What does X call?" / "callees of X" / "what does X use"** →
36
+ `get_callees symbolId=<id>` → invoked symbols + `file:line`. Flow ("how X
37
+ works", "what happens when") → `depth: 2`, never one call per hop.
38
+ - **`depth` > 1** → `tree` rows in BFS order: read by `parent`; `seen` = listed
39
+ above, `external` = unresolved-call count. Then ONE
40
+ `find_symbol(symbols: [...])` of only the tree methods the answer needs.
41
+ `truncated.next` → run it verbatim.
42
+ - **"Who imports this file?" / "what does this file depend on?"** — target =
43
+ FILE: skip Step 1, pass `relativePath=<path>` (repo-relative) instead of
44
+ `symbolId`. `get_callers` → `importers[]`, `get_callees` → `imports[]`; each
45
+ with `importText` + `callWeight` (resolved calls across import, heaviest
46
+ first; 0 = type / constant / re-export only). These are the import-edge reads
47
+ — a search row's `imports` is only a count. Unknown path →
48
+ `empty.reason: "unknownFile"` + `message` — fix path, never report "nothing
49
+ imports it"; `noEdges` at a low resolve rate = lower bound, add the
50
+ `hybrid_search` below. Codegraph off → `hybrid_search metaOnly:true` on the
51
+ module path / import string. User offers Bash rg for importers → refuse,
52
+ answer starts with this line:
53
+
54
+ ```
55
+ Not grep: it matches import text only — misses re-exports and call weight. Importers via <get_callers(relativePath=<module>) | hybrid_search on the module path (codegraph off)>.
56
+ ```
57
+
58
+ ## Step 3 — multi-hop (how X reaches Y)
59
+
60
+ "How does a webhook reach the job queue?" asks for the full chain: endpoint
61
+ symbol names known → `find_symbol` each; endpoints described in words →
62
+ `semantic_search` for them, ids from its hits (a phrase is never a
63
+ `find_symbol symbol=`). Then `trace_path from=<X> to=<Y>` — all paths, one call
64
+ (per core routing "how does X reach Y / A→B"). `namesakes` in answer /
65
+ `paths: []` with `namesakes` → disambiguate via `fromPath` / `toPath` (exact
66
+ relativePath from prior result), not absence of path. Model hops carry `p`; path
67
+ `minP` = weakest link — say so. Present `X → A.run() → B.help() → Y`. Genuinely
68
+ no path → say so; never pad with content-search guesses.
69
+
70
+ ## Output
71
+
72
+ Caller/callee list with `call_expression` preview + `file:line`. Quote call
73
+ site, don't dump calling function.
74
+
75
+ Codegraph on → this pattern WINS over TRACE for usage.
@@ -0,0 +1,149 @@
1
+ ---
2
+ name: extract-project-patterns
3
+ description: >-
4
+ Internal step invoked by tea-rags:data-driven-generation. Agentic-only — runs
5
+ on any behaviorQuery / positiveIds handoff: proven code as code-gen templates,
6
+ not test patterns.
7
+ ---
8
+
9
+ # extract-project-patterns
10
+
11
+ Internal recipe for code-gen skills: battle-tested template for code about to be
12
+ written, via three-level locality cascade.
13
+
14
+ **Not a callee without the marker:** THIS prompt lacks `[invoked by …]` (user
15
+ says "execute the plan" / "start the task") → caller's flow runs (executor guard
16
+ first), not this recipe; markers never carry over between requests.
17
+
18
+ **Handoff = run the recipe now.** Prompt `[invoked by <caller> …]` carrying
19
+ `behaviorQuery=` / `positiveIds=` / `positiveCode=` → you are this recipe, not
20
+ the caller: its own steps (guard, DDG, chain) stay with it. Target dir without
21
+ `pathPatternL1` → L1 = `**/<target dir>/**`. First call = L1 below:
22
+ `semantic_search` (`find_similar` when ids/code), `path=<working dir>`,
23
+ `rerank: "proven"`, `pathPattern: <L1>`.
24
+
25
+ ## Inputs
26
+
27
+ Caller passes:
28
+
29
+ | Input | Required | Notes |
30
+ | --------------- | -------- | ----------------------------------------------------------- |
31
+ | `positiveIds` | one-of | Chunk IDs from prior cascade results |
32
+ | `positiveCode` | one-of | Raw code snippet(s) (embedded on the fly by `find_similar`) |
33
+ | `behaviorQuery` | one-of | NL query if no chunk/code is available |
34
+ | `pathPatternL1` | yes | From explore PG-OUTPUT (deepest subdomain target) |
35
+ | `limit` | no | Default 10 |
36
+
37
+ At least one of `positiveIds` / `positiveCode` / `behaviorQuery` MUST be
38
+ present. Else return
39
+ `{ templates: [], locality: "none", diagnostics: ["no input"] }`.
40
+
41
+ ## Recipe — three-level locality cascade
42
+
43
+ Every call: `project=<alias>` + `path=<working dir>`. `treeState` row = pre-edit
44
+ copy → never template; current body via `find_symbol`. Lag / drift ≠ licence to
45
+ leave tea-rags (core); own checkout `changedFiles` > 0 → incremental
46
+ `index_codebase`, subagent / linked worktree → never reindex. →
47
+ `tea-rags://guide/freshness`.
48
+
49
+ ```
50
+ L1 pathPattern = pathPatternL1 (deepest subdomain)
51
+ L2 pathPattern = infra prefix + first semantic segment (broader domain)
52
+ L3 pathPattern = null (project-wide)
53
+ ```
54
+
55
+ **L2 derivation.** Split L1 segments: leading run from skip-vocabulary = infra
56
+ prefix (NOT counted, KEPT in glob); rest = semantic tail. L2 = glob cut after
57
+ first semantic segment. Semantic tail ≤ 1 segment → L2 = L1, skip L2 step
58
+ entirely.
59
+
60
+ Skip-vocabulary (infra/layer prefixes): `app`, `src`, `lib`, `core`, `packages`,
61
+ `internal`, `domains`; Rails layers: `services`, `models`, `controllers`,
62
+ `jobs`, `workers`, `mailers`, `concerns`, `graphql`, `serializers`,
63
+ `presenters`, `decorators`, `operations`, `interactors`, `policies`.
64
+
65
+ - L1 = `**/domains/trajectory/git/rerank/derived-signals/**` → prefix
66
+ `[domains]`, semantic `[trajectory, git, rerank, derived-signals]` → L2 =
67
+ `**/domains/trajectory/**`.
68
+ - L1 = `**/app/services/crm/accounts/**` → prefix `[app, services]`, semantic
69
+ `[crm, accounts]` → L2 = `**/app/services/crm/**` (NOT `**/app/services/**` —
70
+ layer-wide L2 = degenerate L3).
71
+ - L1 = `**/app/services/billing/**` → semantic `[billing]`, 1 segment → skip L2.
72
+ - L1 = `**/domains/explore/strategies/new-feature/**` → prefix `[domains]`,
73
+ semantic `[explore, strategies, new-feature]` = 3 segments → L2 =
74
+ `**/domains/explore/**`. Count tail segments one by one; never skip L2 on a
75
+ tail ≥ 2.
76
+ - L1 = `**/domains/explore/**` / `**/some-new-area/**` → semantic tail 1 segment
77
+ → skip L2: cascade L1 → L3, never a parent glob.
78
+ - L1 = `**/chunker/hooks/**` → no prefix, semantic `[chunker, hooks]` → L2 =
79
+ `**/chunker/**` (2 segments is NOT too shallow — L1 always runs).
80
+ - L1 = `**/language/ruby/chunking/**` → no prefix, semantic
81
+ `[language, ruby, chunking]` → L2 = `**/language/**`.
82
+
83
+ **For each level in [L1, L2, L3]:**
84
+
85
+ 1. `find_similar` (only `behaviorQuery` → `semantic_search` / `hybrid_search`):
86
+ - `rerank: "proven"` + `level: "chunk"` (proven is file-level; keep chunk
87
+ results)
88
+ - `filter: { presets: "battleTested" }` — ANDs w/ `pathPattern`
89
+ - `pathPattern: <level>` (omit for L3)
90
+ - `limit: <input limit, default 10>`
91
+ - inputs: `positiveIds` | `positiveCode` | `query: behaviorQuery`
92
+
93
+ **Relax-on-empty:** 0 results → re-run once w/
94
+ `filter: { presets: "production" }`, record
95
+ `"no battle-tested reference found; widened to production code"` in
96
+ `diagnostics`. Never return empty silently while relax possible.
97
+
98
+ 2. Quality gate over overlay labels:
99
+ - `ideal_count` = chunks where
100
+ - `commitCount` label is `"low"` or `"typical"`, AND
101
+ - `ageDays` label is `"old"` or `"legacy"`, AND
102
+ - `bugFixRate` label is `"healthy"`
103
+ - `ideal_count ≥ 2` → return top result + locality. Stop.
104
+ - **Lone-ideal-hub**: `ideal_count == 1` AND lone ideal's
105
+ `payload.codegraph.symbols.file.isHub == true` → level accepted,
106
+ `templates[0]` = lone ideal (NOT top-by-score). Stop. Hub = usage-proof
107
+ (fanIn > p95). No `codegraph.symbols` in payload → branch inert.
108
+ 3. Reject filter (always): exclude `bugFixRate` `"critical"` OR (`ageDays`
109
+ `"recent"` AND `commitCount` `"low"`).
110
+ 4. No qualifying chunk → next level.
111
+
112
+ All levels fail → `diagnostics` carries BOTH lines, verbatim:
113
+ `"no battle-tested reference found; widened to production code"` (every relax
114
+ that ran) + `"no proven templates for <input> in this project"`;
115
+ `locality: "none"` (caller falls back: scratch, ask user).
116
+
117
+ ## Output
118
+
119
+ ```
120
+ {
121
+ templates: [
122
+ {
123
+ chunkId,
124
+ path,
125
+ level: "L1" | "L2" | "L3",
126
+ labels: { commitCount, ageDays, bugFixRate, blameContributorCount, ... },
127
+ blameDominantAuthor,
128
+ },
129
+ ...
130
+ ],
131
+ locality: "L1" | "L2" | "L3" | "none",
132
+ diagnostics: [<per-level fail reasons>],
133
+ }
134
+ ```
135
+
136
+ Caller reads `templates[0]`; `locality` → usage:
137
+
138
+ - `L1` → exact subdomain. `blameDominantAuthor` → style + review routing.
139
+ - `L2` → sibling subdomain. `blameDominantAuthor` reviews technique, not code.
140
+ - `L3` → project-wide. Technique only; verify architectural fit before verbatim
141
+ adoption.
142
+ - `none` → caller generates from scratch, tells user to scrutinize.
143
+
144
+ ## Skip clause
145
+
146
+ Return empty templates immediately if:
147
+
148
+ - none of `positiveIds` / `positiveCode` / `behaviorQuery`
149
+ - no git enrichment indexed (no overlay labels → gate cannot run)