@proflandrigan/shards 1.1.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 (397) hide show
  1. package/README.md +475 -0
  2. package/package.json +37 -0
  3. package/src/agents/academic.md +276 -0
  4. package/src/agents/ai-engineer.md +377 -0
  5. package/src/agents/analytics-engineer.md +364 -0
  6. package/src/agents/applied-ml-scientist.md +410 -0
  7. package/src/agents/backend-engineer.md +255 -0
  8. package/src/agents/bi-engineer.md +333 -0
  9. package/src/agents/data-analyst.md +343 -0
  10. package/src/agents/data-engineer.md +260 -0
  11. package/src/agents/data-modeller.md +386 -0
  12. package/src/agents/data-scientist.md +366 -0
  13. package/src/agents/deep-learning-engineer.md +389 -0
  14. package/src/agents/ml-engineer.md +424 -0
  15. package/src/agents/mlops-engineer.md +339 -0
  16. package/src/agents/researcher.md +187 -0
  17. package/src/agents/specific_instructions/academic/critical_review.md +263 -0
  18. package/src/agents/specific_instructions/academic/report.md +113 -0
  19. package/src/agents/specific_instructions/ai_engineer/advise.md +162 -0
  20. package/src/agents/specific_instructions/ai_engineer/bi_engineer_handoff.md +86 -0
  21. package/src/agents/specific_instructions/ai_engineer/experiment.md +471 -0
  22. package/src/agents/specific_instructions/ai_engineer/experiment_ui_mode.md +44 -0
  23. package/src/agents/specific_instructions/ai_engineer/phases/index.md +45 -0
  24. package/src/agents/specific_instructions/ai_engineer/phases/phase-1.md +55 -0
  25. package/src/agents/specific_instructions/ai_engineer/phases/phase-2.md +86 -0
  26. package/src/agents/specific_instructions/ai_engineer/phases/phase-3.md +96 -0
  27. package/src/agents/specific_instructions/ai_engineer/phases/phase-4.md +138 -0
  28. package/src/agents/specific_instructions/ai_engineer/phases/phase-5.md +157 -0
  29. package/src/agents/specific_instructions/ai_engineer/phases/phase-6.md +196 -0
  30. package/src/agents/specific_instructions/ai_engineer/phases/phase-7.md +313 -0
  31. package/src/agents/specific_instructions/ai_engineer/phases.md +1011 -0
  32. package/src/agents/specific_instructions/ai_engineer/prompt_lab.md +161 -0
  33. package/src/agents/specific_instructions/ai_engineer/prompt_lab_ui_mode.md +28 -0
  34. package/src/agents/specific_instructions/ai_engineer/research.md +393 -0
  35. package/src/agents/specific_instructions/ai_engineer/research_ui_mode.md +66 -0
  36. package/src/agents/specific_instructions/ai_engineer/review.md +159 -0
  37. package/src/agents/specific_instructions/ai_engineer/validation_checklist.md +182 -0
  38. package/src/agents/specific_instructions/analytics_engineer/advise.md +155 -0
  39. package/src/agents/specific_instructions/analytics_engineer/bi_engineer_handoff.md +91 -0
  40. package/src/agents/specific_instructions/analytics_engineer/data_analyst_handoff.md +84 -0
  41. package/src/agents/specific_instructions/analytics_engineer/deep_phases.md +818 -0
  42. package/src/agents/specific_instructions/analytics_engineer/phases_deep/index.md +24 -0
  43. package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-1.md +77 -0
  44. package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-2.md +106 -0
  45. package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-3.md +93 -0
  46. package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-4.md +79 -0
  47. package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-5.md +61 -0
  48. package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-6.md +45 -0
  49. package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-7.md +235 -0
  50. package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-8.md +221 -0
  51. package/src/agents/specific_instructions/analytics_engineer/phases_quick/index.md +19 -0
  52. package/src/agents/specific_instructions/analytics_engineer/phases_quick/phase-1.md +47 -0
  53. package/src/agents/specific_instructions/analytics_engineer/phases_quick/phase-2.md +78 -0
  54. package/src/agents/specific_instructions/analytics_engineer/quick_phases.md +112 -0
  55. package/src/agents/specific_instructions/analytics_engineer/review.md +167 -0
  56. package/src/agents/specific_instructions/analytics_engineer/service_mode.md +369 -0
  57. package/src/agents/specific_instructions/analytics_engineer/ui_mode.md +45 -0
  58. package/src/agents/specific_instructions/analytics_engineer/update.md +162 -0
  59. package/src/agents/specific_instructions/analytics_engineer/validation_checklist.md +121 -0
  60. package/src/agents/specific_instructions/applied_ml_scientist/advise.md +143 -0
  61. package/src/agents/specific_instructions/applied_ml_scientist/phases/index.md +21 -0
  62. package/src/agents/specific_instructions/applied_ml_scientist/phases/phase-1.md +51 -0
  63. package/src/agents/specific_instructions/applied_ml_scientist/phases/phase-2.md +66 -0
  64. package/src/agents/specific_instructions/applied_ml_scientist/phases/phase-3.md +113 -0
  65. package/src/agents/specific_instructions/applied_ml_scientist/phases/phase-4.md +104 -0
  66. package/src/agents/specific_instructions/applied_ml_scientist/phases/phase-5.md +156 -0
  67. package/src/agents/specific_instructions/applied_ml_scientist/phases.md +428 -0
  68. package/src/agents/specific_instructions/applied_ml_scientist/research.md +379 -0
  69. package/src/agents/specific_instructions/applied_ml_scientist/review.md +142 -0
  70. package/src/agents/specific_instructions/applied_ml_scientist/validation_checklist.md +136 -0
  71. package/src/agents/specific_instructions/backend_engineer/clean.md +149 -0
  72. package/src/agents/specific_instructions/backend_engineer/review.md +91 -0
  73. package/src/agents/specific_instructions/backend_engineer/review_checklist.md +54 -0
  74. package/src/agents/specific_instructions/backend_engineer/service_mode.md +67 -0
  75. package/src/agents/specific_instructions/bi_engineer/advise.md +137 -0
  76. package/src/agents/specific_instructions/bi_engineer/data_analyst_handoff.md +77 -0
  77. package/src/agents/specific_instructions/bi_engineer/incoming_handoff.md +45 -0
  78. package/src/agents/specific_instructions/bi_engineer/phases/index.md +20 -0
  79. package/src/agents/specific_instructions/bi_engineer/phases/phase-1.md +164 -0
  80. package/src/agents/specific_instructions/bi_engineer/phases/phase-2.md +92 -0
  81. package/src/agents/specific_instructions/bi_engineer/phases/phase-3.md +121 -0
  82. package/src/agents/specific_instructions/bi_engineer/phases/phase-4.md +106 -0
  83. package/src/agents/specific_instructions/bi_engineer/phases.md +451 -0
  84. package/src/agents/specific_instructions/bi_engineer/review.md +166 -0
  85. package/src/agents/specific_instructions/bi_engineer/update.md +147 -0
  86. package/src/agents/specific_instructions/bi_engineer/validation_checklist.md +124 -0
  87. package/src/agents/specific_instructions/data_analyst/advise.md +138 -0
  88. package/src/agents/specific_instructions/data_analyst/explain.md +221 -0
  89. package/src/agents/specific_instructions/data_analyst/incoming_handoff.md +40 -0
  90. package/src/agents/specific_instructions/data_analyst/phases/index.md +20 -0
  91. package/src/agents/specific_instructions/data_analyst/phases/phase-1.md +159 -0
  92. package/src/agents/specific_instructions/data_analyst/phases/phase-2.md +112 -0
  93. package/src/agents/specific_instructions/data_analyst/phases/phase-3.md +265 -0
  94. package/src/agents/specific_instructions/data_analyst/phases/phase-4.md +100 -0
  95. package/src/agents/specific_instructions/data_analyst/phases.md +501 -0
  96. package/src/agents/specific_instructions/data_analyst/review.md +138 -0
  97. package/src/agents/specific_instructions/data_analyst/ui_mode.md +26 -0
  98. package/src/agents/specific_instructions/data_analyst/update.md +144 -0
  99. package/src/agents/specific_instructions/data_analyst/validation_checklist.md +95 -0
  100. package/src/agents/specific_instructions/data_engineer/advise.md +137 -0
  101. package/src/agents/specific_instructions/data_engineer/phases.md +466 -0
  102. package/src/agents/specific_instructions/data_engineer/phases_deep/index.md +23 -0
  103. package/src/agents/specific_instructions/data_engineer/phases_deep/phase-1.md +49 -0
  104. package/src/agents/specific_instructions/data_engineer/phases_deep/phase-2.md +93 -0
  105. package/src/agents/specific_instructions/data_engineer/phases_deep/phase-3.md +55 -0
  106. package/src/agents/specific_instructions/data_engineer/phases_deep/phase-4.md +48 -0
  107. package/src/agents/specific_instructions/data_engineer/phases_deep/phase-5.md +40 -0
  108. package/src/agents/specific_instructions/data_engineer/phases_deep/phase-6.md +102 -0
  109. package/src/agents/specific_instructions/data_engineer/phases_deep/phase-7.md +87 -0
  110. package/src/agents/specific_instructions/data_engineer/phases_quick/index.md +19 -0
  111. package/src/agents/specific_instructions/data_engineer/phases_quick/phase-1.md +45 -0
  112. package/src/agents/specific_instructions/data_engineer/phases_quick/phase-2.md +54 -0
  113. package/src/agents/specific_instructions/data_engineer/review.md +135 -0
  114. package/src/agents/specific_instructions/data_engineer/validation_checklist.md +136 -0
  115. package/src/agents/specific_instructions/data_modeller/advise.md +137 -0
  116. package/src/agents/specific_instructions/data_modeller/phases.md +581 -0
  117. package/src/agents/specific_instructions/data_modeller/phases_deep/index.md +23 -0
  118. package/src/agents/specific_instructions/data_modeller/phases_deep/phase-1.md +52 -0
  119. package/src/agents/specific_instructions/data_modeller/phases_deep/phase-2.md +113 -0
  120. package/src/agents/specific_instructions/data_modeller/phases_deep/phase-3.md +47 -0
  121. package/src/agents/specific_instructions/data_modeller/phases_deep/phase-4.md +51 -0
  122. package/src/agents/specific_instructions/data_modeller/phases_deep/phase-5.md +45 -0
  123. package/src/agents/specific_instructions/data_modeller/phases_deep/phase-6.md +105 -0
  124. package/src/agents/specific_instructions/data_modeller/phases_deep/phase-7.md +136 -0
  125. package/src/agents/specific_instructions/data_modeller/phases_quick/index.md +19 -0
  126. package/src/agents/specific_instructions/data_modeller/phases_quick/phase-1.md +47 -0
  127. package/src/agents/specific_instructions/data_modeller/phases_quick/phase-2.md +65 -0
  128. package/src/agents/specific_instructions/data_modeller/review.md +141 -0
  129. package/src/agents/specific_instructions/data_modeller/service_mode.md +218 -0
  130. package/src/agents/specific_instructions/data_modeller/validation_checklist.md +125 -0
  131. package/src/agents/specific_instructions/data_scientist/advise.md +158 -0
  132. package/src/agents/specific_instructions/data_scientist/bi_engineer_handoff.md +63 -0
  133. package/src/agents/specific_instructions/data_scientist/experiment.md +482 -0
  134. package/src/agents/specific_instructions/data_scientist/experiment_ui_mode.md +44 -0
  135. package/src/agents/specific_instructions/data_scientist/explain.md +247 -0
  136. package/src/agents/specific_instructions/data_scientist/greenfield_data.md +35 -0
  137. package/src/agents/specific_instructions/data_scientist/ml_engineer_handoff.md +52 -0
  138. package/src/agents/specific_instructions/data_scientist/notebook_walkthrough.md +76 -0
  139. package/src/agents/specific_instructions/data_scientist/phases/index.md +24 -0
  140. package/src/agents/specific_instructions/data_scientist/phases/phase-1.md +45 -0
  141. package/src/agents/specific_instructions/data_scientist/phases/phase-2.md +67 -0
  142. package/src/agents/specific_instructions/data_scientist/phases/phase-3.md +89 -0
  143. package/src/agents/specific_instructions/data_scientist/phases/phase-4.md +143 -0
  144. package/src/agents/specific_instructions/data_scientist/phases/phase-5.md +71 -0
  145. package/src/agents/specific_instructions/data_scientist/phases/phase-6.md +239 -0
  146. package/src/agents/specific_instructions/data_scientist/phases/phase-7.md +207 -0
  147. package/src/agents/specific_instructions/data_scientist/phases.md +651 -0
  148. package/src/agents/specific_instructions/data_scientist/research.md +345 -0
  149. package/src/agents/specific_instructions/data_scientist/research_ui_mode.md +52 -0
  150. package/src/agents/specific_instructions/data_scientist/review.md +136 -0
  151. package/src/agents/specific_instructions/data_scientist/service_mode.md +247 -0
  152. package/src/agents/specific_instructions/data_scientist/validation_checklist.md +183 -0
  153. package/src/agents/specific_instructions/deep_learning_engineer/advise.md +145 -0
  154. package/src/agents/specific_instructions/deep_learning_engineer/phases/index.md +21 -0
  155. package/src/agents/specific_instructions/deep_learning_engineer/phases/phase-1.md +74 -0
  156. package/src/agents/specific_instructions/deep_learning_engineer/phases/phase-2.md +98 -0
  157. package/src/agents/specific_instructions/deep_learning_engineer/phases/phase-3.md +76 -0
  158. package/src/agents/specific_instructions/deep_learning_engineer/phases/phase-4.md +128 -0
  159. package/src/agents/specific_instructions/deep_learning_engineer/phases/phase-5.md +292 -0
  160. package/src/agents/specific_instructions/deep_learning_engineer/phases.md +567 -0
  161. package/src/agents/specific_instructions/deep_learning_engineer/research.md +389 -0
  162. package/src/agents/specific_instructions/deep_learning_engineer/review.md +155 -0
  163. package/src/agents/specific_instructions/deep_learning_engineer/validation_checklist.md +147 -0
  164. package/src/agents/specific_instructions/ml_engineer/advise.md +174 -0
  165. package/src/agents/specific_instructions/ml_engineer/bi_engineer_handoff.md +71 -0
  166. package/src/agents/specific_instructions/ml_engineer/experiment.md +474 -0
  167. package/src/agents/specific_instructions/ml_engineer/experiment_ui_mode.md +44 -0
  168. package/src/agents/specific_instructions/ml_engineer/notebook_walkthrough.md +75 -0
  169. package/src/agents/specific_instructions/ml_engineer/phases/index.md +25 -0
  170. package/src/agents/specific_instructions/ml_engineer/phases/phase-1.md +49 -0
  171. package/src/agents/specific_instructions/ml_engineer/phases/phase-2.md +75 -0
  172. package/src/agents/specific_instructions/ml_engineer/phases/phase-3.md +124 -0
  173. package/src/agents/specific_instructions/ml_engineer/phases/phase-4.md +279 -0
  174. package/src/agents/specific_instructions/ml_engineer/phases/phase-5.md +160 -0
  175. package/src/agents/specific_instructions/ml_engineer/phases/phase-6-5.md +170 -0
  176. package/src/agents/specific_instructions/ml_engineer/phases/phase-6.md +295 -0
  177. package/src/agents/specific_instructions/ml_engineer/phases/phase-7.md +337 -0
  178. package/src/agents/specific_instructions/ml_engineer/phases.md +1068 -0
  179. package/src/agents/specific_instructions/ml_engineer/research.md +437 -0
  180. package/src/agents/specific_instructions/ml_engineer/research_ui_mode.md +71 -0
  181. package/src/agents/specific_instructions/ml_engineer/review.md +187 -0
  182. package/src/agents/specific_instructions/ml_engineer/service_mode.md +273 -0
  183. package/src/agents/specific_instructions/ml_engineer/validation_checklist.md +185 -0
  184. package/src/agents/specific_instructions/mlops_engineer/advise.md +139 -0
  185. package/src/agents/specific_instructions/mlops_engineer/phases/index.md +23 -0
  186. package/src/agents/specific_instructions/mlops_engineer/phases/phase-1.md +52 -0
  187. package/src/agents/specific_instructions/mlops_engineer/phases/phase-2.md +86 -0
  188. package/src/agents/specific_instructions/mlops_engineer/phases/phase-3.md +105 -0
  189. package/src/agents/specific_instructions/mlops_engineer/phases/phase-4.md +128 -0
  190. package/src/agents/specific_instructions/mlops_engineer/phases/phase-5.md +106 -0
  191. package/src/agents/specific_instructions/mlops_engineer/phases/phase-6.md +128 -0
  192. package/src/agents/specific_instructions/mlops_engineer/phases/phase-7.md +144 -0
  193. package/src/agents/specific_instructions/mlops_engineer/phases.md +671 -0
  194. package/src/agents/specific_instructions/mlops_engineer/review.md +164 -0
  195. package/src/agents/specific_instructions/mlops_engineer/service_mode.md +81 -0
  196. package/src/agents/specific_instructions/mlops_engineer/validation_checklist.md +151 -0
  197. package/src/agents/specific_instructions/researcher/critical_review.md +292 -0
  198. package/src/agents/specific_instructions/researcher/review_checklist.md +67 -0
  199. package/src/agents/specific_instructions/researcher/service_mode.md +224 -0
  200. package/src/agents/specific_instructions/shared/auto_verify_mode.md +141 -0
  201. package/src/agents/specific_instructions/shared/autonomous_research.md +1289 -0
  202. package/src/agents/specific_instructions/shared/behavioral_rules.md +36 -0
  203. package/src/agents/specific_instructions/shared/diverge_protocol.md +387 -0
  204. package/src/agents/specific_instructions/shared/engineering_guidelines.md +136 -0
  205. package/src/agents/specific_instructions/shared/experiment_versioning.md +184 -0
  206. package/src/agents/specific_instructions/shared/goal_mode.md +187 -0
  207. package/src/agents/specific_instructions/shared/incremental_testing.md +139 -0
  208. package/src/agents/specific_instructions/shared/intent_discovery.md +223 -0
  209. package/src/agents/specific_instructions/shared/join_path_protocol.md +168 -0
  210. package/src/agents/specific_instructions/shared/knowledge_checkpoint.md +83 -0
  211. package/src/agents/specific_instructions/shared/knowledge_harvest.md +220 -0
  212. package/src/agents/specific_instructions/shared/knowledge_retrieval.md +100 -0
  213. package/src/agents/specific_instructions/shared/notebook_walkthrough_protocol.md +367 -0
  214. package/src/agents/specific_instructions/shared/reviewer_verdict_protocol.md +74 -0
  215. package/src/agents/specific_instructions/shared/swarm_protocol.md +97 -0
  216. package/src/agents/specific_instructions/shared/validation_protocol.md +139 -0
  217. package/src/agents/specific_instructions/syn/arbiter.md +140 -0
  218. package/src/agents/specific_instructions/syn/brainstorm.md +550 -0
  219. package/src/agents/specific_instructions/syn/code_review.md +232 -0
  220. package/src/agents/specific_instructions/syn/diff.md +239 -0
  221. package/src/agents/specific_instructions/syn/final_review.md +65 -0
  222. package/src/agents/specific_instructions/syn/fixer.md +240 -0
  223. package/src/agents/specific_instructions/syn/free_form.md +130 -0
  224. package/src/agents/specific_instructions/syn/knowledge.md +468 -0
  225. package/src/agents/specific_instructions/syn/notebook_walkthrough.md +78 -0
  226. package/src/agents/specific_instructions/syn/panel_review.md +634 -0
  227. package/src/agents/specific_instructions/syn/pm.md +453 -0
  228. package/src/agents/specific_instructions/syn/pr_review.md +255 -0
  229. package/src/agents/specific_instructions/syn/slides.md +417 -0
  230. package/src/agents/syn.md +729 -0
  231. package/src/commands/academic.md +41 -0
  232. package/src/commands/ai-engineer.md +45 -0
  233. package/src/commands/analytics-engineer.md +48 -0
  234. package/src/commands/applied-ml-scientist.md +45 -0
  235. package/src/commands/backend-engineer.md +35 -0
  236. package/src/commands/bi-engineer.md +40 -0
  237. package/src/commands/brainstorm.md +24 -0
  238. package/src/commands/data-analyst.md +38 -0
  239. package/src/commands/data-engineer.md +37 -0
  240. package/src/commands/data-modeller.md +38 -0
  241. package/src/commands/data-scientist.md +38 -0
  242. package/src/commands/deep-learning-engineer.md +47 -0
  243. package/src/commands/end.md +49 -0
  244. package/src/commands/knowledge.md +24 -0
  245. package/src/commands/ml-engineer.md +42 -0
  246. package/src/commands/mlops-engineer.md +47 -0
  247. package/src/commands/notebook-walkthrough.md +58 -0
  248. package/src/commands/researcher.md +40 -0
  249. package/src/commands/resume.md +57 -0
  250. package/src/commands/review-pr.md +26 -0
  251. package/src/commands/shards-guide.md +41 -0
  252. package/src/commands/shards-ui.md +32 -0
  253. package/src/commands/shards.md +41 -0
  254. package/src/docs/01-getting-started/concepts.md +109 -0
  255. package/src/docs/01-getting-started/first-session.md +79 -0
  256. package/src/docs/01-getting-started/install.md +61 -0
  257. package/src/docs/02-agents/academic.md +71 -0
  258. package/src/docs/02-agents/ai-engineer.md +78 -0
  259. package/src/docs/02-agents/analytics-engineer.md +58 -0
  260. package/src/docs/02-agents/applied-ml-scientist.md +59 -0
  261. package/src/docs/02-agents/backend-engineer.md +58 -0
  262. package/src/docs/02-agents/bi-engineer.md +65 -0
  263. package/src/docs/02-agents/data-analyst.md +67 -0
  264. package/src/docs/02-agents/data-engineer.md +57 -0
  265. package/src/docs/02-agents/data-modeller.md +51 -0
  266. package/src/docs/02-agents/data-scientist.md +78 -0
  267. package/src/docs/02-agents/deep-learning-engineer.md +64 -0
  268. package/src/docs/02-agents/ml-engineer.md +80 -0
  269. package/src/docs/02-agents/mlops-engineer.md +59 -0
  270. package/src/docs/02-agents/overview.md +62 -0
  271. package/src/docs/02-agents/researcher.md +73 -0
  272. package/src/docs/02-agents/syn.md +88 -0
  273. package/src/docs/03-protocols/auto-verify.md +82 -0
  274. package/src/docs/03-protocols/autonomous-research.md +59 -0
  275. package/src/docs/03-protocols/behavioral-rules.md +35 -0
  276. package/src/docs/03-protocols/diverge.md +50 -0
  277. package/src/docs/03-protocols/engineering-guidelines.md +56 -0
  278. package/src/docs/03-protocols/experiment-versioning.md +38 -0
  279. package/src/docs/03-protocols/gate-pattern.md +65 -0
  280. package/src/docs/03-protocols/incremental-testing.md +68 -0
  281. package/src/docs/03-protocols/join-path.md +46 -0
  282. package/src/docs/03-protocols/knowledge-ledger.md +70 -0
  283. package/src/docs/03-protocols/reviewer-verdicts.md +39 -0
  284. package/src/docs/03-protocols/swarm.md +40 -0
  285. package/src/docs/03-protocols/validation.md +174 -0
  286. package/src/docs/04-ui/activity-bar.md +70 -0
  287. package/src/docs/04-ui/chat-pane.md +80 -0
  288. package/src/docs/04-ui/code-intel.md +62 -0
  289. package/src/docs/04-ui/file-editing.md +61 -0
  290. package/src/docs/04-ui/git.md +54 -0
  291. package/src/docs/04-ui/keybindings.md +79 -0
  292. package/src/docs/04-ui/knowledge-map.md +76 -0
  293. package/src/docs/04-ui/overview.md +93 -0
  294. package/src/docs/04-ui/panels.md +49 -0
  295. package/src/docs/04-ui/pinboard-selection.md +66 -0
  296. package/src/docs/04-ui/quick-open-palette.md +56 -0
  297. package/src/docs/04-ui/sessions.md +81 -0
  298. package/src/docs/04-ui/settings-permissions.md +56 -0
  299. package/src/docs/05-commands/reference.md +59 -0
  300. package/src/docs/06-outputs/directory-map.md +116 -0
  301. package/src/docs/07-workflows/ai-eval-first.md +57 -0
  302. package/src/docs/07-workflows/deep-study-to-production.md +76 -0
  303. package/src/docs/07-workflows/diverge-exploration.md +77 -0
  304. package/src/docs/07-workflows/quick-analysis.md +45 -0
  305. package/src/docs/08-integrations/claude-code-auto-mode.md +191 -0
  306. package/src/docs/08-integrations/google-slides.md +175 -0
  307. package/src/docs/README.md +30 -0
  308. package/src/docs/manifest.json +108 -0
  309. package/src/templates/analysis-template.md +20 -0
  310. package/src/templates/branch-report.md +46 -0
  311. package/src/templates/diff-report.md +88 -0
  312. package/src/templates/knowledge-index.md +7 -0
  313. package/src/templates/model-card-schema.json +186 -0
  314. package/src/templates/model-card-schema.md +88 -0
  315. package/src/templates/model-card.md +124 -0
  316. package/src/templates/project-plan.md +47 -0
  317. package/src/templates/project-specs.md +81 -0
  318. package/src/templates/report-template.md +43 -0
  319. package/src/templates/study-template.md +25 -0
  320. package/src/ui/cc-readonly.js +181 -0
  321. package/src/ui/chat-session.js +466 -0
  322. package/src/ui/css/base.css +136 -0
  323. package/src/ui/css/brainstorm.css +525 -0
  324. package/src/ui/css/chat.css +1405 -0
  325. package/src/ui/css/editor.css +546 -0
  326. package/src/ui/css/eval-dashboard.css +157 -0
  327. package/src/ui/css/experiment.css +237 -0
  328. package/src/ui/css/guide.css +186 -0
  329. package/src/ui/css/knowledge-map.css +383 -0
  330. package/src/ui/css/layout.css +431 -0
  331. package/src/ui/css/model-card.css +161 -0
  332. package/src/ui/css/notebook-walkthrough.css +271 -0
  333. package/src/ui/css/pr-review.css +403 -0
  334. package/src/ui/css/prompt-lab.css +325 -0
  335. package/src/ui/css/sessions.css +258 -0
  336. package/src/ui/css/sidebar.css +661 -0
  337. package/src/ui/css/terminal.css +113 -0
  338. package/src/ui/css/theme-light.css +542 -0
  339. package/src/ui/index.html +389 -0
  340. package/src/ui/js/agents.js +32 -0
  341. package/src/ui/js/bookmarks.js +230 -0
  342. package/src/ui/js/chat.js +1776 -0
  343. package/src/ui/js/code-intel.js +328 -0
  344. package/src/ui/js/command-palette.js +142 -0
  345. package/src/ui/js/events.js +591 -0
  346. package/src/ui/js/explorer.js +317 -0
  347. package/src/ui/js/file-view.js +477 -0
  348. package/src/ui/js/git.js +536 -0
  349. package/src/ui/js/guide.js +198 -0
  350. package/src/ui/js/hud.js +75 -0
  351. package/src/ui/js/init.js +351 -0
  352. package/src/ui/js/knowledge-map.js +906 -0
  353. package/src/ui/js/markdown.js +114 -0
  354. package/src/ui/js/monaco.js +164 -0
  355. package/src/ui/js/notebook-walkthrough.js +272 -0
  356. package/src/ui/js/notebook.js +448 -0
  357. package/src/ui/js/panels.js +2681 -0
  358. package/src/ui/js/pinboard.js +186 -0
  359. package/src/ui/js/quick-open.js +164 -0
  360. package/src/ui/js/selection-context.js +131 -0
  361. package/src/ui/js/sessions.js +256 -0
  362. package/src/ui/js/settings.js +476 -0
  363. package/src/ui/js/split-view.js +82 -0
  364. package/src/ui/js/state.js +343 -0
  365. package/src/ui/js/table.js +161 -0
  366. package/src/ui/js/tabs.js +284 -0
  367. package/src/ui/js/tabular.js +125 -0
  368. package/src/ui/js/terminal.js +354 -0
  369. package/src/ui/js/timeline.js +137 -0
  370. package/src/ui/js/utils.js +293 -0
  371. package/src/ui/notebook-kernel.py +790 -0
  372. package/src/ui/open-browser.js +55 -0
  373. package/src/ui/permission-pattern.js +42 -0
  374. package/src/ui/relay.js +513 -0
  375. package/src/ui/server.js +3072 -0
  376. package/src/ui/session-index.js +225 -0
  377. package/src/ui/shards_icon.png +0 -0
  378. package/src/ui/spawn-server.js +41 -0
  379. package/src/ui/symbol-index.js +813 -0
  380. package/src/ui/ui-push.js +177 -0
  381. package/tools/gate-hook/VALIDATION_SPEC.md +273 -0
  382. package/tools/gate-hook/__tests__/auto-verify.test.js +343 -0
  383. package/tools/gate-hook/auto-allowlist.js +179 -0
  384. package/tools/gate-hook/auto-state.js +68 -0
  385. package/tools/gate-hook/classify.js +21 -0
  386. package/tools/gate-hook/log.js +57 -0
  387. package/tools/gate-hook/parser.js +205 -0
  388. package/tools/gate-hook/sql-guard.js +230 -0
  389. package/tools/gate-hook/state.js +170 -0
  390. package/tools/gate-hook/sweep.js +139 -0
  391. package/tools/gate-hook/transcript.js +45 -0
  392. package/tools/gate-hook/validation.js +321 -0
  393. package/tools/gate-hook.js +475 -0
  394. package/tools/install.js +914 -0
  395. package/tools/shards-gates.js +311 -0
  396. package/tools/shards-sessions.js +261 -0
  397. package/tools/shards-ui.js +377 -0
@@ -0,0 +1,139 @@
1
+ // Stale-gate sweep + operator force-close escape hatch.
2
+ // Extracted from gate-hook.js for direct unit testing.
3
+ 'use strict';
4
+
5
+ const state = require('./state.js');
6
+ const { appendViolation, appendHistory } = require('./log.js');
7
+
8
+ // Operator escape hatch — Bash invocations of `shards-gates force-close`
9
+ // (the npm bin or a direct `node tools/shards-gates.js force-close`) are
10
+ // allowed even while a gate is open, so a stuck-gate deadlock can be
11
+ // unstuck from inside a Claude session. Chain/pipe/command-substitution
12
+ // operators are rejected so the override can't piggyback another command.
13
+ const FORCE_CLOSE_RE = /\bshards-gates(?:\.js)?\s+force-close\b/;
14
+ const SHELL_CHAIN_RE = /[|;&`]|\$\(/;
15
+
16
+ function isForceCloseBash(toolName, toolInput) {
17
+ if (toolName !== 'Bash') return false;
18
+ const cmd = (toolInput && toolInput.command) || '';
19
+ if (!FORCE_CLOSE_RE.test(cmd)) return false;
20
+ if (SHELL_CHAIN_RE.test(cmd)) return false;
21
+ return true;
22
+ }
23
+
24
+ // Stale-gate sweep — gates with missing/invalid opened_at OR older than 24h
25
+ // are auto-closed. Symmetric with the session-index abandonment sweep at
26
+ // src/ui/session-index.js (also 24h).
27
+ const STALE_GATE_MS = 24 * 60 * 60 * 1000;
28
+
29
+ // Staleness is a property of a SINGLE gate object (one session's slot), not
30
+ // the global state. A non-open gate is never stale.
31
+ function isStaleGate(gate, now = Date.now()) {
32
+ if (!gate || !gate.open) return false;
33
+ if (!gate.opened_at) return true;
34
+ const t = Date.parse(gate.opened_at);
35
+ if (Number.isNaN(t)) return true;
36
+ return (now - t) > STALE_GATE_MS;
37
+ }
38
+
39
+ function staleReason(gate) {
40
+ if (!gate.opened_at) return 'missing-opened-at';
41
+ if (Number.isNaN(Date.parse(gate.opened_at))) return 'invalid-opened-at';
42
+ return 'older-than-24h';
43
+ }
44
+
45
+ // Append a stale-sweep record to the shared history + audit logs for one gate.
46
+ // Returns the history entry pushed (so callers can compose).
47
+ function logStaleSweep(gate, sessionId) {
48
+ const closed_at = new Date().toISOString();
49
+ const reason = staleReason(gate);
50
+ const entry = {
51
+ id: gate.id || 'unknown',
52
+ phase: typeof gate.phase !== 'undefined' ? gate.phase : null,
53
+ kind: gate.kind || null,
54
+ opened_at: gate.opened_at || null,
55
+ closed_at,
56
+ confirmed_by: 'stale-sweep',
57
+ closed_reason: reason,
58
+ };
59
+ appendViolation({
60
+ type: 'stale-sweep',
61
+ gate_id: gate.id || 'unknown',
62
+ opened_at: gate.opened_at || null,
63
+ reason,
64
+ session_id: sessionId,
65
+ });
66
+ appendHistory({
67
+ event: 'closed',
68
+ gate_id: gate.id || 'unknown',
69
+ kind: gate.kind || 'phase',
70
+ confirmed_by: 'stale-sweep',
71
+ });
72
+ return entry;
73
+ }
74
+
75
+ // Sweep stale gates across the v2 state, persisting the result.
76
+ //
77
+ // Always sweeps THIS session's gate if it is stale. Additionally sweeps any
78
+ // OTHER session's gate that is genuinely abandoned (older than 24h, or with a
79
+ // missing/invalid opened_at) — those carry no risk of clobbering live work.
80
+ // Other sessions' FRESH gates are left untouched.
81
+ //
82
+ // Each swept gate is appended to the shared `history` with
83
+ // confirmed_by:'stale-sweep'. Returns the new state object (also written).
84
+ function sweepStaleSessions(s, sessionId, now = Date.now()) {
85
+ const cur = normalizeForSweep(s);
86
+ const sessions = { ...cur.sessions };
87
+ const history = [...cur.history];
88
+ let changed = false;
89
+
90
+ for (const [sid, gate] of Object.entries(cur.sessions)) {
91
+ if (!gate || !gate.open) continue;
92
+ const stale = isStaleGate(gate, now);
93
+ // This session's gate sweeps whenever stale; other sessions only when
94
+ // genuinely abandoned (which is exactly what isStaleGate detects: missing/
95
+ // invalid opened_at or >24h). So the predicate is the same either way.
96
+ if (!stale) continue;
97
+ history.push(logStaleSweep(gate, sessionId));
98
+ delete sessions[sid];
99
+ changed = true;
100
+ }
101
+
102
+ const next = { version: 2, sessions, history };
103
+ if (changed) state.write(next);
104
+ return next;
105
+ }
106
+
107
+ // Local normalize so sweep doesn't depend on state.normalize being exported —
108
+ // mirrors the v2 shape and tolerates legacy input (upgraded by state.read()
109
+ // before it reaches here, but we stay defensive).
110
+ function normalizeForSweep(s) {
111
+ if (s && (s.version === 2 || s.sessions)) {
112
+ return {
113
+ sessions: (s.sessions && typeof s.sessions === 'object') ? s.sessions : {},
114
+ history: Array.isArray(s.history) ? s.history : [],
115
+ };
116
+ }
117
+ // Legacy single slot.
118
+ const sessions = {};
119
+ if (s && s.open) {
120
+ sessions[s.agent || '__legacy__'] = {
121
+ open: true,
122
+ id: s.id,
123
+ phase: typeof s.phase !== 'undefined' ? s.phase : null,
124
+ kind: s.kind || null,
125
+ agent: s.agent || null,
126
+ opened_at: s.opened_at || null,
127
+ };
128
+ }
129
+ return { sessions, history: Array.isArray(s && s.history) ? s.history : [] };
130
+ }
131
+
132
+ module.exports = {
133
+ FORCE_CLOSE_RE,
134
+ SHELL_CHAIN_RE,
135
+ STALE_GATE_MS,
136
+ isForceCloseBash,
137
+ isStaleGate,
138
+ sweepStaleSessions,
139
+ };
@@ -0,0 +1,45 @@
1
+ // Read last assistant message from a Claude Code transcript (JSONL)
2
+ 'use strict';
3
+
4
+ const fs = require('fs');
5
+
6
+ function readLastAssistantMessage(transcriptPath) {
7
+ if (!transcriptPath) return '';
8
+
9
+ let raw;
10
+ try {
11
+ raw = fs.readFileSync(transcriptPath, 'utf8');
12
+ } catch {
13
+ return '';
14
+ }
15
+
16
+ const lines = raw.split('\n').filter(Boolean);
17
+ let lastAssistantText = '';
18
+
19
+ for (const line of lines) {
20
+ try {
21
+ const entry = JSON.parse(line);
22
+ // Claude Code transcript shape: {type: "assistant", message: {role, content}}
23
+ // Test/legacy shape: {role: "assistant", content: [...]}
24
+ let content = null;
25
+ if (entry.type === 'assistant' && entry.message && Array.isArray(entry.message.content)) {
26
+ content = entry.message.content;
27
+ } else if (entry.role === 'assistant' && Array.isArray(entry.content)) {
28
+ content = entry.content;
29
+ }
30
+ if (!content) continue;
31
+
32
+ const text = content
33
+ .filter((c) => c && c.type === 'text' && typeof c.text === 'string')
34
+ .map((c) => c.text)
35
+ .join('');
36
+ if (text) lastAssistantText = text;
37
+ } catch {
38
+ // malformed line — skip
39
+ }
40
+ }
41
+
42
+ return lastAssistantText;
43
+ }
44
+
45
+ module.exports = { readLastAssistantMessage };
@@ -0,0 +1,321 @@
1
+ // Validation section parser + checker for the gate hook.
2
+ // Implements src/agents/specific_instructions/shared/validation_protocol.md
3
+ // and tools/gate-hook/VALIDATION_SPEC.md.
4
+ 'use strict';
5
+
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+
9
+ const VALID_TRACKS = new Set(['quick', 'deep', 'fixer']);
10
+ const VALID_PASS_FAIL = new Set(['✓', '✗', 'n/a']);
11
+
12
+ // ─── Specs file resolution ───────────────────────────────────────────────────
13
+
14
+ // Shards projects live under convention directories — see CLAUDE.md output
15
+ // directory map. We search these for the most recently modified project-specs.md.
16
+ const PROJECT_DIRS = [
17
+ 'analysis', 'studies', 'models', 'data_models', 'services',
18
+ 'research', 'dashboards', 'brainstorm', 'fixes',
19
+ ];
20
+
21
+ // Find the most recently modified project-specs.md in any immediate subdirectory
22
+ // of the conventional project dirs (e.g. analysis/*/project-specs.md).
23
+ function findLatestSpecs(root) {
24
+ let best = null;
25
+ let bestMtime = 0;
26
+ for (const d of PROJECT_DIRS) {
27
+ const base = path.join(root, d);
28
+ let entries;
29
+ try {
30
+ entries = fs.readdirSync(base, { withFileTypes: true });
31
+ } catch {
32
+ continue;
33
+ }
34
+ for (const e of entries) {
35
+ if (!e.isDirectory()) continue;
36
+ const candidate = path.join(base, e.name, 'project-specs.md');
37
+ try {
38
+ const st = fs.statSync(candidate);
39
+ if (st.mtimeMs > bestMtime) {
40
+ bestMtime = st.mtimeMs;
41
+ best = candidate;
42
+ }
43
+ } catch {
44
+ // no specs file here — skip
45
+ }
46
+ }
47
+ }
48
+ return best;
49
+ }
50
+
51
+ function specsPath() {
52
+ if (process.env.SHARDS_PROJECT_SPECS_PATH) {
53
+ return process.env.SHARDS_PROJECT_SPECS_PATH;
54
+ }
55
+ // Backward-compatible: prefer a specs file at CWD if one exists.
56
+ const cwdPath = path.join(process.cwd(), 'project-specs.md');
57
+ try {
58
+ fs.accessSync(cwdPath, fs.constants.R_OK);
59
+ return cwdPath;
60
+ } catch {
61
+ // Not at CWD — search conventional project subdirectories.
62
+ }
63
+ return findLatestSpecs(process.cwd()) || cwdPath;
64
+ }
65
+
66
+ function readSpecs() {
67
+ try {
68
+ return fs.readFileSync(specsPath(), 'utf8');
69
+ } catch {
70
+ return null;
71
+ }
72
+ }
73
+
74
+ // ─── Section extraction ──────────────────────────────────────────────────────
75
+
76
+ // Return the body of the LAST `## Validation` section in the file.
77
+ // A section body runs from the heading line to the next `## ` heading or EOF.
78
+ function extractValidationBody(content) {
79
+ if (!content) return null;
80
+ const lines = content.split('\n');
81
+ let lastStart = -1;
82
+ for (let i = 0; i < lines.length; i++) {
83
+ if (/^##\s+Validation\s*$/.test(lines[i])) lastStart = i;
84
+ }
85
+ if (lastStart === -1) return null;
86
+
87
+ let end = lines.length;
88
+ for (let i = lastStart + 1; i < lines.length; i++) {
89
+ if (/^##\s+/.test(lines[i])) { end = i; break; }
90
+ }
91
+ return lines.slice(lastStart + 1, end).join('\n');
92
+ }
93
+
94
+ // Extract the body of a `### <heading>` subsection within the validation body.
95
+ function extractSubsection(body, heading) {
96
+ if (!body) return null;
97
+ const lines = body.split('\n');
98
+ let start = -1;
99
+ for (let i = 0; i < lines.length; i++) {
100
+ if (new RegExp('^###\\s+' + heading.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&') + '\\s*$').test(lines[i])) {
101
+ start = i;
102
+ break;
103
+ }
104
+ }
105
+ if (start === -1) return null;
106
+
107
+ let end = lines.length;
108
+ for (let i = start + 1; i < lines.length; i++) {
109
+ if (/^###\s+/.test(lines[i])) { end = i; break; }
110
+ }
111
+ return lines.slice(start + 1, end).join('\n');
112
+ }
113
+
114
+ function hasSubsectionHeading(body, heading) {
115
+ if (!body) return false;
116
+ return new RegExp('^###\\s+' + heading.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&') + '\\s*$', 'm').test(body);
117
+ }
118
+
119
+ // ─── Field parsers ───────────────────────────────────────────────────────────
120
+
121
+ function matchOne(body, re) {
122
+ if (!body) return null;
123
+ const m = body.match(re);
124
+ return m ? m[1].trim() : null;
125
+ }
126
+
127
+ function modePresent(body) {
128
+ if (!body) return false;
129
+ return /^\*\*Mode:\*\*/m.test(body);
130
+ }
131
+
132
+ // Parse a markdown pipe table. Returns array of row objects keyed by header name (lowercased, trimmed).
133
+ // Skips separator row (|---|---|).
134
+ function parsePipeTable(section) {
135
+ if (!section) return [];
136
+ const lines = section.split('\n').map(l => l.trim()).filter(Boolean);
137
+ if (lines.length < 2) return [];
138
+
139
+ const tableLines = lines.filter(l => l.startsWith('|'));
140
+ if (tableLines.length < 2) return [];
141
+
142
+ const header = tableLines[0]
143
+ .replace(/^\||\|$/g, '')
144
+ .split('|')
145
+ .map(c => c.trim().toLowerCase());
146
+
147
+ // The next line should be the separator row — skip it if it's all dashes.
148
+ const dataStart = /^\|[-\s|:]+\|?$/.test(tableLines[1]) ? 2 : 1;
149
+
150
+ const rows = [];
151
+ for (let i = dataStart; i < tableLines.length; i++) {
152
+ const cells = tableLines[i]
153
+ .replace(/^\||\|$/g, '')
154
+ .split('|')
155
+ .map(c => c.trim());
156
+ if (cells.length !== header.length) continue;
157
+ const row = {};
158
+ header.forEach((h, idx) => { row[h] = cells[idx]; });
159
+ rows.push(row);
160
+ }
161
+ return rows;
162
+ }
163
+
164
+ // Parse a bulleted list, return array of bullet texts (trimmed).
165
+ // Accepts `- ` or `* ` prefix.
166
+ function parseBullets(section) {
167
+ if (!section) return [];
168
+ return section
169
+ .split('\n')
170
+ .map(l => l.trim())
171
+ .filter(l => /^[-*]\s+/.test(l))
172
+ .map(l => l.replace(/^[-*]\s+/, '').trim());
173
+ }
174
+
175
+ function nonWhitespaceLength(s) {
176
+ if (!s) return 0;
177
+ return s.replace(/\s+/g, '').length;
178
+ }
179
+
180
+ // ─── Top-level parse + check ─────────────────────────────────────────────────
181
+
182
+ function parseValidationSection(content) {
183
+ const body = extractValidationBody(content);
184
+ if (body === null) return { present: false };
185
+
186
+ const evidence = extractSubsection(body, 'Evidence');
187
+ const artifacts = extractSubsection(body, 'Artifacts');
188
+ const downstream = extractSubsection(body, 'Downstream Impact');
189
+ const openIssues = hasSubsectionHeading(body, 'Open Issues');
190
+ const summary = extractSubsection(body, 'Summary');
191
+
192
+ return {
193
+ present: true,
194
+ // Anchor each field match to the same line as the label — otherwise
195
+ // \s* would greedily consume newlines and swallow subsequent lines
196
+ // when the label's value is empty.
197
+ track: matchOne(body, /\*\*Track:\*\*[^\S\n]*(quick|deep|fixer)\b/i),
198
+ modeLinePresent: modePresent(body),
199
+ mode: matchOne(body, /\*\*Mode:\*\*[^\S\n]*([^\n]+)/),
200
+ checklist: matchOne(body, /\*\*Checklist:\*\*[^\S\n]*([^\n]+validation_checklist\.md)/),
201
+ appliedAt: matchOne(body, /\*\*Applied at:\*\*[^\S\n]*([^\n]+)/),
202
+ evidenceRows: parsePipeTable(evidence),
203
+ artifactBullets: parseBullets(artifacts),
204
+ downstreamBullets: parseBullets(downstream),
205
+ openIssuesHeadingPresent: openIssues,
206
+ summaryLength: nonWhitespaceLength(summary),
207
+ };
208
+ }
209
+
210
+ function checkValidation(parsed) {
211
+ const errors = [];
212
+ if (!parsed.present) return [{ code: 'MISSING_SECTION' }];
213
+
214
+ if (!parsed.track || !VALID_TRACKS.has(parsed.track.toLowerCase())) {
215
+ errors.push({ code: 'MISSING_TRACK' });
216
+ }
217
+
218
+ // Mode: optional. If the line is present, value must be non-empty.
219
+ if (parsed.modeLinePresent && (!parsed.mode || !parsed.mode.trim())) {
220
+ errors.push({ code: 'EMPTY_MODE' });
221
+ }
222
+
223
+ if (!parsed.checklist) errors.push({ code: 'MISSING_CHECKLIST' });
224
+
225
+ if (parsed.evidenceRows.length === 0) {
226
+ errors.push({ code: 'NO_EVIDENCE_ROWS' });
227
+ } else {
228
+ for (let i = 0; i < parsed.evidenceRows.length; i++) {
229
+ const row = parsed.evidenceRows[i];
230
+ const check = (row.check || '').trim();
231
+ const expected = (row.expected || '').trim();
232
+ const observed = (row.observed || '').trim();
233
+ const passFail = (row['pass/fail'] || row.passfail || '').trim();
234
+ const notes = (row.notes || '').trim();
235
+
236
+ if (!check || !expected || !observed) {
237
+ errors.push({ code: 'INCOMPLETE_EVIDENCE_ROW', row: i + 1 });
238
+ continue;
239
+ }
240
+ if (!VALID_PASS_FAIL.has(passFail)) {
241
+ errors.push({ code: 'INVALID_PASS_FAIL', row: i + 1, got: passFail });
242
+ continue;
243
+ }
244
+ if (passFail === 'n/a' && !notes) {
245
+ errors.push({ code: 'NA_WITHOUT_JUSTIFICATION', row: i + 1 });
246
+ }
247
+ }
248
+ }
249
+
250
+ if (parsed.artifactBullets.length === 0) errors.push({ code: 'NO_ARTIFACTS' });
251
+ if (parsed.downstreamBullets.length === 0) errors.push({ code: 'NO_DOWNSTREAM' });
252
+ if (parsed.summaryLength < 20) {
253
+ errors.push({ code: 'SUMMARY_TOO_SHORT', length: parsed.summaryLength });
254
+ }
255
+
256
+ return errors;
257
+ }
258
+
259
+ // ─── Error formatting ────────────────────────────────────────────────────────
260
+
261
+ const ERROR_DESCRIPTIONS = {
262
+ MISSING_SECTION: 'No `## Validation` heading found in project-specs.md',
263
+ MISSING_TRACK: '`**Track:**` line missing or value is not quick/deep/fixer',
264
+ EMPTY_MODE: '`**Mode:**` line present but value is blank (omit the line entirely if Mode is not meaningful)',
265
+ MISSING_CHECKLIST: '`**Checklist:**` line missing or doesn\'t reference a `validation_checklist.md`',
266
+ NO_EVIDENCE_ROWS: 'Evidence table has zero data rows',
267
+ INCOMPLETE_EVIDENCE_ROW: 'A row has an empty Check, Expected, or Observed cell',
268
+ INVALID_PASS_FAIL: 'A row\'s Pass/Fail value is not one of ✓, ✗, or n/a',
269
+ NA_WITHOUT_JUSTIFICATION: 'A row has `Pass/Fail: n/a` but the Notes cell is empty',
270
+ NO_ARTIFACTS: 'Artifacts section has no bullets (use `- none (see Summary)` to override intentionally)',
271
+ NO_DOWNSTREAM: 'Downstream Impact section has no bullets',
272
+ SUMMARY_TOO_SHORT: 'Summary has fewer than 20 non-whitespace characters',
273
+ };
274
+
275
+ function describe(err) {
276
+ const base = ERROR_DESCRIPTIONS[err.code] || err.code;
277
+ if (err.row) return `row ${err.row}: ${base}${err.got ? ` (got: "${err.got}")` : ''}`;
278
+ return base;
279
+ }
280
+
281
+ function formatValidationError(checklist, gate, errors) {
282
+ const lines = [
283
+ '::GATE-BLOCK:: Validation evidence is missing or incomplete.',
284
+ '',
285
+ `Required checklist: ${checklist}/validation_checklist.md`,
286
+ `Gate: ${gate.id} (phase ${gate.phase || '?'}, kind ${gate.kind || '?'})`,
287
+ '',
288
+ 'Problems:',
289
+ ...errors.map(e => ` - ${e.code}: ${describe(e)}`),
290
+ '',
291
+ 'What to do:',
292
+ ' 1. Re-read .claude/agents/specific_instructions/shared/validation_protocol.md',
293
+ ' for the required `## Validation` section schema.',
294
+ ` 2. Re-read .claude/agents/specific_instructions/${checklist}/validation_checklist.md`,
295
+ ' for the domain-specific checks.',
296
+ ' 3. Run the checks, record observed values in the Evidence table, and',
297
+ ' re-emit the gate fence.',
298
+ '',
299
+ 'If this phase should not require validation, remove the `validates=...`',
300
+ 'attribute from the gate fence.',
301
+ ];
302
+ return lines.join('\n');
303
+ }
304
+
305
+ module.exports = {
306
+ parseValidationSection,
307
+ checkValidation,
308
+ formatValidationError,
309
+ readSpecs,
310
+ // Exported for tests
311
+ _internals: {
312
+ extractValidationBody,
313
+ extractSubsection,
314
+ parsePipeTable,
315
+ parseBullets,
316
+ nonWhitespaceLength,
317
+ VALID_TRACKS,
318
+ VALID_PASS_FAIL,
319
+ ERROR_DESCRIPTIONS,
320
+ },
321
+ };