@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,220 @@
1
+ ---
2
+ name: knowledge-harvest-protocol
3
+ description: Shared protocol for extracting reusable knowledge at project completion — all specialists
4
+ type: reference
5
+ ---
6
+
7
+ # Knowledge Ledger — Harvest Protocol
8
+
9
+ This protocol runs once, after all reviews in the final phase are complete and before marking `Status: Complete`. It extracts reusable knowledge from the project and writes it to the workspace-wide Knowledge Ledger (`.shards/knowledge/`).
10
+
11
+ ---
12
+
13
+ ## Special case: Autonomous Research (`[AR]`) fan-out
14
+
15
+ When an AR session ran as a **fan-out** (multiple parallel branches converged by Syn Arbiter — see `autonomous_research.md` Section H):
16
+
17
+ - **Losing branches do NOT run this protocol independently.** Running harvest in each branch would flood the ledger with duplicate or conflicting candidates across branches exploring adjacent territory.
18
+ - **Only the parent specialist runs harvest**, after promotion (`diverge_protocol.md` Section G), as part of the consolidated Phase 3.
19
+ - Harvest candidates come from:
20
+ 1. The **winning branch's** artifacts (research_brief.md, results.json, iteration files).
21
+ 2. **Cross-branch patterns** that Syn Arbiter flagged in the leaderboard (e.g., "three of four branches hit the same data leakage issue"). These are worth harvesting even when no single branch would have flagged them, because they reveal structural properties of the data or methodology.
22
+
23
+ For **solo AR** sessions, run this protocol normally at Phase 3 per the agent's `research.md`. Candidate sources are the AR artifacts (brief, results.json, per-iteration files) and the final `research_summary.md` patterns section.
24
+
25
+ ---
26
+
27
+ ---
28
+
29
+ ## Steps
30
+
31
+ ### 1. Review the project
32
+
33
+ Read the full `project-specs.md` for this project. Identify candidates across four categories:
34
+
35
+ | Category | Directory | What to look for |
36
+ |----------|-----------|-----------------|
37
+ | **Entities** | `entities/` | Data table quirks, column semantics that surprised you, grain discoveries, type mismatches (e.g., "user_id is a string UUID in billing but an integer in events"), unexpected nullability |
38
+ | **Infrastructure** | `infrastructure/` | Warehouse behaviors, API rate limits, system quirks, connection patterns, freshness guarantees (or lack thereof) |
39
+ | **Patterns** | `patterns/` | Reusable SQL snippets, Python patterns, transformation techniques, join strategies that solved a non-obvious problem |
40
+ | **Features** | `features/` | Verified ML features with SQL, grain, and performance data — **Data Scientist and ML Engineer only** |
41
+
42
+ ### 1b. Check for contradiction resolutions
43
+
44
+ Search `project-specs.md` for lines matching the structured template:
45
+
46
+ ```
47
+ **Knowledge contradiction:** "<title>" claims ...
48
+ ```
49
+
50
+ This template is written by the checkpoint protocol (`knowledge_checkpoint.md`) whenever an agent observes data that contradicts a ledger entry during execution.
51
+
52
+ For each contradiction found where "Ledger update needed: Yes":
53
+
54
+ - Identify the existing knowledge file path from INDEX.md (match by title)
55
+ - Draft an **update candidate** with:
56
+ - **Action:** Update (not a new entry — overwrite the existing file)
57
+ - **Existing entry:** `.shards/knowledge/<category>/<filename>.md`
58
+ - **Change:** old claim → new claim (extracted from the contradiction template)
59
+ - **New confidence:** re-assess based on observed data (usually downgrade or upgrade from original)
60
+
61
+ When multiple contradictions exist in a single project, group them in the harvest candidate list as a subsection:
62
+
63
+ ```
64
+ Ledger updates from contradictions:
65
+ 1. Update "<title>" — old claim: <X> → new claim: <Y> (confidence: <new>)
66
+ 2. Update "<title>" — old claim: <X> → new claim: <Y> (confidence: <new>)
67
+ ```
68
+
69
+ Present these alongside new candidates in Step 3 so the user can confirm or reject them as a batch.
70
+
71
+ **On confirm:** Overwrite the existing knowledge file — update the `date`, `confidence`, and content fields in place. Do **not** create a `_v2` file for contradiction resolutions. Update the INDEX.md row to reflect the new date and confidence.
72
+
73
+ If no contradiction lines are found in `project-specs.md`, skip this step.
74
+
75
+ ### 1c. Check for validation findings worth harvesting
76
+
77
+ Read the `## Validation` section of `project-specs.md` (per `shared/validation_protocol.md`). Validation that caught a real issue is often the highest-signal source of harvest candidates — the check surfaced something that would have quietly been wrong otherwise.
78
+
79
+ Look for:
80
+
81
+ - **Checks with `Pass/Fail: ✗` that were fixed.** The issue that was caught is a candidate entity/infrastructure/pattern entry ("billing.revenue column contains negative values on refunds"; "incremental predicate on `updated_at` misses rows when source clock drifts").
82
+ - **Checks with surprising `Observed` values even when Pass/Fail = ✓.** Distribution shifts, null-rate anomalies, unexpected fan-out multipliers — the check passed but the value is worth remembering (e.g., "orders-to-items fan-out is 4.8x on this warehouse, not the industry-typical 2-3x — use for capacity planning").
83
+ - **`n/a` with an instructive justification.** When a check is genuinely inapplicable for a non-obvious reason, that reason is a pattern (e.g., "DL-09 inference parity is n/a for this service because training and serving share the same feature module — note the pattern, not the skip").
84
+ - **Downstream impact discoveries.** Consumers that were affected in non-obvious ways. These are often infrastructure or feature-level knowledge.
85
+
86
+ These candidates blend in with the Step 1 / Step 2 draft list — tag them clearly so the user sees that they came from the validation section:
87
+
88
+ ```
89
+ 4. [patterns] "orders-items fan-out is 4.8x in this warehouse" (high confidence, from Validation AE-06)
90
+ — Verified across two quarters of data. Use for capacity planning and query tier assessment.
91
+ ```
92
+
93
+ If the `## Validation` section is absent or contains nothing worth harvesting, skip this step.
94
+
95
+ ### 2. Draft candidates
96
+
97
+ For each candidate, draft:
98
+
99
+ - **Title:** short, specific, grep-friendly (e.g., "billing.user_id is string UUID not integer")
100
+ - **Category:** entities | infrastructure | patterns | features
101
+ - **Domain tags:** 2–4 keywords for INDEX.md matching
102
+ - **Confidence:** high (verified in production data) | medium (observed in this project) | low (inferred, not directly tested)
103
+ - **Content:** 3–10 lines explaining the knowledge. Be specific — include table names, column names, SQL snippets, system names. Vague entries are worthless.
104
+
105
+ For **feature** candidates (Data Scientist / ML Engineer only), also draft:
106
+ - **SQL snippet:** the feature computation
107
+ - **Feature type:** numeric | categorical | boolean | temporal | embedding
108
+ - **Grain:** one row per what
109
+ - **Verified by:** which agent, in which project, with what metric impact
110
+
111
+ **Minimum:** explicit assessment — 1+ candidates or "None — trivial project". For Quick tracks, default to "None" unless something genuinely surprising was discovered during the fix.
112
+
113
+ ### 3. Present to user (GATE)
114
+
115
+ Present all candidates to the user in a numbered list:
116
+
117
+ ```
118
+ Knowledge harvest — candidates for the Knowledge Ledger:
119
+
120
+ 1. [entities] "billing.user_id is string UUID not integer" (high confidence)
121
+ — billing.users.user_id is VARCHAR(36) UUID, not INT. Joins to events.user_id require CAST.
122
+
123
+ 2. [patterns] "incremental merge for slowly changing dims in BigQuery" (medium confidence)
124
+ — MERGE pattern that handles late-arriving updates without full refresh. SQL included.
125
+
126
+ 3. [features] "days_since_last_login" (high confidence, grain: user-day)
127
+ — Verified: +3.2% AUC in churn model. SQL: DATEDIFF(CURRENT_DATE, last_login_at).
128
+
129
+ Add, edit, or remove? Or confirm to write.
130
+ ```
131
+
132
+ ::GATE:: id=specific-instructions-shared-knowledge-harvest-phase0 phase=0 kind=phase
133
+ Do not write any files until the user confirms.
134
+ ::ENDGATE::
135
+
136
+ The user may edit titles, remove candidates, adjust confidence, or add new ones.
137
+
138
+ ### 4. Create directory structure
139
+
140
+ If `.shards/knowledge/` does not exist, create it with subdirectories:
141
+
142
+ ```
143
+ .shards/knowledge/
144
+ INDEX.md (copy from templates/knowledge-index.md if missing)
145
+ entities/
146
+ infrastructure/
147
+ patterns/
148
+ features/
149
+ ```
150
+
151
+ ### 5. Write knowledge files
152
+
153
+ For each confirmed candidate, write a markdown file:
154
+
155
+ **File path:** `.shards/knowledge/<category>/<slugified-title>.md`
156
+
157
+ Slugify: lowercase, replace spaces with hyphens, remove special characters, max 60 characters.
158
+
159
+ **Conflict handling:** if a file with that name already exists, append `_v2` (or `_v3`, etc.) to the filename and note the prior entry in the content.
160
+
161
+ **File format:**
162
+
163
+ ```markdown
164
+ ---
165
+ title: <title>
166
+ domain: [<keyword1>, <keyword2>, <keyword3>]
167
+ source_project: <project directory path>
168
+ contributed_by: <agent name>
169
+ date: <YYYY-MM-DD>
170
+ type: <entities | infrastructure | patterns | features>
171
+ confidence: <high | medium | low>
172
+ ---
173
+
174
+ <content — 3-10 lines, specific, with table/column/system names>
175
+ ```
176
+
177
+ **Extended frontmatter for features:**
178
+
179
+ ```markdown
180
+ ---
181
+ title: <title>
182
+ domain: [<keyword1>, <keyword2>, <keyword3>]
183
+ source_project: <project directory path>
184
+ contributed_by: <agent name>
185
+ date: <YYYY-MM-DD>
186
+ type: features
187
+ confidence: <high | medium | low>
188
+ sql_snippet: |
189
+ <the SQL that computes this feature>
190
+ feature_type: <numeric | categorical | boolean | temporal | embedding>
191
+ grain: <one row per what>
192
+ verified_by: <agent name> in <source_project> — <metric>: <impact>
193
+ ---
194
+
195
+ <content — what this feature captures, when to use it, caveats>
196
+ ```
197
+
198
+ ### 6. Update INDEX.md
199
+
200
+ Append one row per entry to the table in `.shards/knowledge/INDEX.md`:
201
+
202
+ ```
203
+ | <YYYY-MM-DD> | <type> | <title> | <domain keywords> | <confidence> | <category>/<filename>.md |
204
+ ```
205
+
206
+ **Size warning:** if INDEX.md exceeds 200 entries after appending, warn the user:
207
+
208
+ > "INDEX.md now has <N> entries. Consider pruning stale or low-confidence entries to keep retrieval fast."
209
+
210
+ ### 7. Report
211
+
212
+ Tell the user what was written:
213
+
214
+ ```
215
+ Knowledge harvested:
216
+ - <title> → .shards/knowledge/<type>/<filename>.md
217
+ - <title> → .shards/knowledge/<type>/<filename>.md
218
+
219
+ INDEX.md updated (<N> total entries).
220
+ ```
@@ -0,0 +1,100 @@
1
+ ---
2
+ name: knowledge-retrieval-protocol
3
+ description: Shared protocol for checking the Knowledge Ledger before Phase 1 — all specialists
4
+ type: reference
5
+ ---
6
+
7
+ # Knowledge Ledger — Retrieval Protocol
8
+
9
+ This protocol runs once, between Phase 0 confirmation and Phase 1 start. It is non-blocking — if the ledger doesn't exist or is empty, document "N/A" and proceed.
10
+
11
+ **Scope:** Build mode (Phase 0 → final), and Autonomous Research (`[AR]`) mode (Phase 0 setup). Do NOT run in Review, Advise, Service, Explain, Experiment (`[EX]`/`[EXP]`), or Prompt Lab modes.
12
+
13
+ **AR entry point.** `[AR]` mode calls this protocol from `autonomous_research.md` Section A.1, before the research brief is drafted. Prior AR runs in the ledger may have already established saturation points, known-leaky features, or architectural dead ends that should shape hypotheses from iteration 1. The match criteria most useful for AR are:
14
+
15
+ - **Metric** — has a prior AR or study measured the same primary metric on similar data?
16
+ - **Domain / dataset / entity** — normal domain match.
17
+ - **Approach family** — prior runs that explored the same model family (gradient boosting, transformer, prompt-chain, etc.) — these often document why a family is or is not a fit.
18
+
19
+ Add these keywords to the extraction step alongside the normal domain keywords.
20
+
21
+ **Syn handoff sessions:** Still run this protocol. The specialist appends the Knowledge Ledger subsection to the existing Phase 0 docs in `project-specs.md`.
22
+
23
+ ---
24
+
25
+ ## Steps
26
+
27
+ ### 1. Check for the ledger
28
+
29
+ Check if `.shards/knowledge/INDEX.md` exists. If it does not exist or is empty (only the header row), document:
30
+
31
+ ```
32
+ ### Knowledge Ledger
33
+ - **Entries checked:** N/A — ledger not found
34
+ ```
35
+
36
+ Append this to the Phase 0 section in `project-specs.md` and proceed to Phase 1. Stop here — skip the remaining steps.
37
+
38
+ ### 2. Extract domain keywords
39
+
40
+ From the Phase 0 answers already documented in `project-specs.md`, extract 3–5 domain keywords that describe the project's data domain, business area, and technical focus. Examples: "billing", "churn", "user_id", "Stripe", "incremental", "recommender".
41
+
42
+ ### 3. Scan INDEX.md
43
+
44
+ Read `.shards/knowledge/INDEX.md` in full. Scan the table for rows whose **Title** or **Domains** columns contain any of your keywords (case-insensitive partial match). Collect up to 5 matching entries.
45
+
46
+ ### 4. Deep-read relevant entries
47
+
48
+ For each matching entry (up to 5), read the file at `.shards/knowledge/<File column value>` (the File column contains paths relative to `.shards/knowledge/`). Assess relevance to the current project:
49
+
50
+ - **Relevant:** the entry describes a data quirk, pattern, or infrastructure behavior that applies to the tables, systems, or domain this project will touch.
51
+ - **Not relevant:** keyword match was coincidental (e.g., same word, different context).
52
+
53
+ Discard entries that are not relevant after reading.
54
+
55
+ For entries with a **Date** older than 6 months from today, flag as `(possibly stale)` in the output.
56
+
57
+ ### 4b. Validation-pattern retrieval
58
+
59
+ In addition to the general keyword scan, match ledger entries against the checks your agent's validation checklist will apply in later phases. Entries that describe:
60
+
61
+ - a **known distribution anomaly** relevant to a check like `AE-05` / `ML-02` / `DS-02`
62
+ - a **grain or fan-out surprise** relevant to `AE-03` / `AE-06`
63
+ - a **historical downstream break** relevant to the Downstream Impact analysis for this agent
64
+ - a **prior validation failure** on a similar entity (check title or content references check IDs or validation findings)
65
+
66
+ ...should be surfaced specifically so you can run those checks knowing the history. Add a note in the Phase 0 documentation when such entries are found:
67
+
68
+ ```
69
+ - <title> — relevant to validation check <ID>: <1-line relevance note>
70
+ ```
71
+
72
+ If the ledger has nothing validation-specific, skip without writing an empty line.
73
+
74
+ ### 5. Feature Registry check (Data Scientist and ML Engineer only)
75
+
76
+ If the current agent is the Data Scientist or ML Engineer, also check `.shards/knowledge/features/`:
77
+
78
+ 1. List files in `.shards/knowledge/features/` (skip if directory doesn't exist or is empty).
79
+ 2. For each feature file, read the YAML frontmatter and check if its `domain` tags overlap with the project's data domain keywords.
80
+ 3. Include relevant features in the output below, noting their `feature_type`, `grain`, and `verified_by` metadata.
81
+
82
+ This is a preliminary scan for awareness only. A deeper Feature Registry import check happens in Phase 4.
83
+
84
+ ### 6. Document in project-specs.md
85
+
86
+ Append the following subsection to the Phase 0 section in `project-specs.md`:
87
+
88
+ ```markdown
89
+ ### Knowledge Ledger
90
+ - **Entries checked:** <N entries in INDEX.md>
91
+ - **Relevant entries found:** <N>
92
+ - <title> (<type>, <confidence>) — <1-line relevance note>
93
+ - <title> (<type>, <confidence>, possibly stale) — <1-line relevance note>
94
+ - **Or:** No relevant entries found
95
+ - **Relevant features:** <N> (Data Scientist / ML Engineer only)
96
+ - <feature title> (<feature_type>, grain: <grain>, verified by: <agent> in <source_project>)
97
+ - Or: No relevant features found | N/A — not a DS/ML project
98
+ ```
99
+
100
+ Read the subsection back to the user as part of Phase 0 confirmation (or as an addendum if Phase 0 was already confirmed). Then proceed to Phase 1.
@@ -0,0 +1,367 @@
1
+ # Notebook Walkthrough — Shared Protocol
2
+
3
+ This document defines the **interactive notebook walkthrough** mode shared by
4
+ the Data Scientist, ML Engineer, and Syn shards. The per-agent variant files
5
+ under `specific_instructions/<agent>/notebook_walkthrough.md` set the persona
6
+ spin and reference this document for the protocol.
7
+
8
+ The walkthrough lets the agent guide the user through a Jupyter notebook
9
+ **cell by cell**: execute the cell against a live kernel, explain it in chat,
10
+ take questions, and (when asked) edit, insert, or delete cells and re-run
11
+ downstream. It is **not** a Phase 0+ project workflow — there is no
12
+ project-specs.md, no gate sequence, and no Syn final review. It is a live,
13
+ read-and-react session.
14
+
15
+ ---
16
+
17
+ ## Architecture
18
+
19
+ Three pieces:
20
+
21
+ 1. **The notebook on disk** (`.ipynb`) — the source of truth for cell source
22
+ and cell outputs. Mutated only via `NotebookEdit` (for source) or via the
23
+ kernel helper's `exec` subcommand (for outputs after execution).
24
+ 2. **The walkthrough state JSON** — the agent's view of the walkthrough
25
+ (current cell, which cells are stale, transcript of explanations and
26
+ user questions). Lives at:
27
+ `<project_root>/.shards/notebook-walkthrough.json`
28
+ The Shards UI watches this file via the panel's `--source` flag and
29
+ re-renders on every change.
30
+ 3. **The kernel helper** — `python .shards/ui/notebook-kernel.py` keeps a
31
+ persistent Jupyter kernel alive between agent invocations. Connection
32
+ files live under `.shards/notebooks/<session_id>/`.
33
+
34
+ The agent owns the choreography between the three. The UI is read-mostly:
35
+ it shows the current state and dispatches user actions back as chat messages.
36
+
37
+ ---
38
+
39
+ ## Bootstrap sequence (on activation)
40
+
41
+ 1. **Ask** the user for the notebook path. Validate it exists and ends in
42
+ `.ipynb`. (If invoked via `/notebook-walkthrough` slash command, the path
43
+ may already be in the user's first message.)
44
+
45
+ 2. **Generate a session id**:
46
+ ```bash
47
+ python .shards/ui/notebook-kernel.py new-session
48
+ ```
49
+ The helper prints `{"ok": true, "sessionId": "<uuid>"}`. Capture the
50
+ sessionId — every subsequent helper call needs it.
51
+
52
+ 3. **Start the kernel**:
53
+ ```bash
54
+ python .shards/ui/notebook-kernel.py start <session_id> <notebook_path>
55
+ ```
56
+ Helper writes the connection file, spawns ipykernel, and creates the
57
+ initial walkthrough state at `.shards/notebooks/<session_id>/state.json`.
58
+ On success the response includes `cellCount` and `stateFile`.
59
+
60
+ 4. **Read** the notebook from disk so you have the cell sources in
61
+ memory. Read both `<notebook_path>` and the helper's `state.json`.
62
+
63
+ 5. **Compose** the UI-facing walkthrough state JSON. Required shape:
64
+ ```json
65
+ {
66
+ "sessionId": "<uuid>",
67
+ "notebookPath": "<absolute or project-relative path>",
68
+ "currentCellIndex": 0,
69
+ "status": "ready",
70
+ "cells": [
71
+ {
72
+ "index": 0,
73
+ "type": "code|markdown",
74
+ "executed": false,
75
+ "stale": false,
76
+ "explained": false,
77
+ "lastRunAt": null,
78
+ "explanation": null,
79
+ "outputSummary": null
80
+ }
81
+ ],
82
+ "notebookCells": [
83
+ { "cell_type": "code|markdown", "source": "...", "outputs": [] }
84
+ ],
85
+ "transcript": []
86
+ }
87
+ ```
88
+ - `cells[].*` is per-cell walkthrough state (the helper's `state.json`
89
+ already gives you this — copy it forward).
90
+ - `notebookCells` is a flat snapshot of the on-disk `.ipynb` cells. The
91
+ UI uses this to render cell source and existing outputs without making
92
+ a separate file fetch.
93
+ - `transcript` accumulates `{ role, kind, cellIndex, text }` entries.
94
+
95
+ Write this JSON to `<project_root>/.shards/notebook-walkthrough.json`.
96
+
97
+ 6. **Push the panel** to the UI:
98
+ ```bash
99
+ node .shards/ui/ui-push.js notebook-walkthrough \
100
+ --title "Walkthrough: <notebook_basename>" \
101
+ --agent "<agent-name>" \
102
+ --panel-id "nw-<session_id>" \
103
+ --source "<project_root>/.shards/notebook-walkthrough.json"
104
+ ```
105
+ The `--source` flag tells the server to watch the file. Subsequent state
106
+ updates need only re-write the file — no further pushes required.
107
+
108
+ 7. **Explain cell 0** to the user in chat. Set `cells[0].explained = true`
109
+ and append an entry to `transcript`. Update the state JSON.
110
+
111
+ 8. **Wait** for the user to send a `[NOTEBOOK-WALKTHROUGH] ...` message or
112
+ to reply in chat.
113
+
114
+ If the UI is not running, the `ui-push.js` call exits silently — that is
115
+ fine, the walkthrough still works in chat-only mode (the user just won't
116
+ see the panel; they can still read explanations and request actions in plain
117
+ chat).
118
+
119
+ ---
120
+
121
+ ## Message protocol
122
+
123
+ The UI dispatches user actions as chat messages prefixed with
124
+ `[NOTEBOOK-WALKTHROUGH]`. Recognize and handle:
125
+
126
+ | Pattern | Action |
127
+ |---|---|
128
+ | `Run cell <N>` | Execute cell N via the kernel helper, update state |
129
+ | `Next cell` | Advance `currentCellIndex` by 1, explain the new cell |
130
+ | `Re-explain cell <N>` | Generate a fresh explanation for cell N |
131
+ | `Question on cell <N>: <text>` | Answer in chat; record in transcript; do not advance |
132
+ | `Edit cell <N>: <new content>` | Mutate cell source via NotebookEdit, mark stale, re-run if user asked |
133
+ | `Insert cell after <N> (<type>): <content>` | Insert a cell, shift indices, update state |
134
+ | `Delete cell <N>` | Delete via NotebookEdit, shift indices, mark downstream stale |
135
+ | `Re-run from cell <N>` | Execute cells N..end, clearing stale flags as you go |
136
+ | `Restart kernel` | Call helper `restart`; mark all executed cells stale |
137
+ | `Restart & run all` | Call helper `run-all`; fresh-kernel top-to-bottom reproducibility check; report per-cell pass/fail and the first error |
138
+ | `End walkthrough` | Call helper `stop`; finalize transcript; offer summary |
139
+
140
+ In `Insert` and `Edit` payloads, `\n` is the literal escape sequence — replace
141
+ `\n` with newline before applying.
142
+
143
+ User messages **without** the `[NOTEBOOK-WALKTHROUGH]` prefix are normal
144
+ chat: treat them as questions or instructions, answer in chat, and record
145
+ relevant ones in the transcript with `kind: "question"`.
146
+
147
+ ---
148
+
149
+ ## Cell execution
150
+
151
+ Always go through the helper:
152
+
153
+ ```bash
154
+ python .shards/ui/notebook-kernel.py exec <session_id> <cell_index>
155
+ ```
156
+
157
+ The helper:
158
+ - Reads cell source from the `.ipynb` on disk (so any prior `NotebookEdit`
159
+ is picked up automatically).
160
+ - Sends the source to the live kernel.
161
+ - Captures stream/result/error outputs.
162
+ - Writes outputs back into the `.ipynb` file (so the file pane reflects the
163
+ fresh outputs).
164
+ - Updates the helper's `state.json` with `executed`, `lastRunAt`, and
165
+ `outputSummary` for that cell.
166
+
167
+ After every `exec` call:
168
+ 1. Re-read the helper's `state.json` (or just the relevant cell entry).
169
+ 2. Re-read the relevant `.ipynb` cell so `notebookCells` in the UI state JSON
170
+ reflects the new outputs.
171
+ 3. Update `<project_root>/.shards/notebook-walkthrough.json`. Set
172
+ `currentCellIndex` to the cell that just ran.
173
+ 4. Explain the result in chat — what the cell did, what to read in the
174
+ output, anything surprising.
175
+
176
+ If `status` in the helper response is `"error"`, do not advance to the next
177
+ cell. Explain the error in business/methodology terms and ask the user how
178
+ to proceed.
179
+
180
+ ---
181
+
182
+ ## Cell mutation (edit / insert / delete)
183
+
184
+ All cell mutations go through the **NotebookEdit** tool — never write the
185
+ `.ipynb` directly.
186
+
187
+ After any mutation:
188
+ 1. **Reload** the `.ipynb` from disk. Cell indices may have shifted.
189
+ 2. **Recompute the staleness pass**:
190
+ - Find the smallest index `K` that was mutated.
191
+ - Every cell at index `≥ K` that was previously executed gets
192
+ `stale: true` in walkthrough state.
193
+ - The mutated cell itself becomes `stale: true` and `executed: false`
194
+ (its old execution count is no longer meaningful).
195
+ 3. **Update `notebookCells`** in the walkthrough state JSON to mirror the
196
+ new cell list, and update `cells[]` so length matches.
197
+ 4. If the user asked for "Edit and re-run" (edit followed immediately by a
198
+ run), call `exec` for that cell now; otherwise leave it stale and tell
199
+ the user it is staged for re-run.
200
+ 5. Save the walkthrough state JSON.
201
+
202
+ When inserting a cell, decide whether to insert with empty source (and let
203
+ the user fill it later) or generate plausible code/markdown. **Default: ask
204
+ the user.** Never invent analysis code without confirmation — this is the
205
+ "facilitate, don't generate" rule still in force, even in walkthrough mode.
206
+
207
+ ---
208
+
209
+ ## Re-run from cell N
210
+
211
+ When the user sends `Re-run from cell N`:
212
+
213
+ 1. Iterate `i` from `N` through the last executed-or-stale cell.
214
+ 2. For each `i`, call `exec <session_id> <i>`.
215
+ 3. After each successful run, clear `stale` and update `lastRunAt` /
216
+ `outputSummary`. Save the walkthrough state JSON between iterations so
217
+ the UI shows progress.
218
+ 4. If any cell errors, **stop** the loop, leave subsequent stale flags
219
+ intact, explain the error, and ask the user.
220
+
221
+ ---
222
+
223
+ ## Restart & run all
224
+
225
+ When the user sends `Restart & run all` (the final reproducibility check —
226
+ does the notebook run clean top-to-bottom on a *fresh* kernel?):
227
+
228
+ 1. Call the helper once:
229
+ ```bash
230
+ python .shards/ui/notebook-kernel.py run-all <session_id>
231
+ ```
232
+ It restarts the kernel, executes every code cell in order on the fresh
233
+ kernel, writes outputs back into the `.ipynb`, updates `state.json` per
234
+ cell, and stops at the first failing cell.
235
+ 2. Parse the roll-up: `cellsTotal`, `cellsRun`, `cellsPassed`, `perCell`
236
+ (`[{index, status}]`), and `firstError` (`{cellIndex, ename, evalue}` or
237
+ `null`).
238
+ 3. Re-read `state.json` and the `.ipynb`, then update
239
+ `<project_root>/.shards/notebook-walkthrough.json` to mirror the fresh
240
+ run — every passing cell `executed: true`, `stale: false`.
241
+ 4. Report the outcome in chat:
242
+ - **All passed** (`firstError == null`): say so plainly — the notebook is
243
+ reproducible from a cold start. This is the evidence DS-11 wants.
244
+ - **Failed**: name the failing cell, translate `ename`/`evalue` into
245
+ business/methodology terms, and **stop** (honoring "kernel errors halt
246
+ progress"). Every cell after `firstError.cellIndex` did not run.
247
+ 5. This is an *offer-and-run on request* action — never trigger it on your
248
+ own; the user clicks "Run All" or types the command.
249
+
250
+ ---
251
+
252
+ ## Explanations — how to write them
253
+
254
+ Carried over from the existing Explain mode:
255
+
256
+ - **Explain intent and logic, not syntax.** "We're imputing missing income
257
+ with the median because the column is right-skewed and the mean would be
258
+ dragged by outliers." Not: "We call `df['income'].median()` and pass it
259
+ to `fillna()`."
260
+ - **Tie to the question.** Every cell either gathers data, transforms it,
261
+ models it, evaluates it, or visualizes it — name the role.
262
+ - **Flag what to look at in the output.** "The KS statistic of 0.31 is what
263
+ matters here — anything above 0.2 is a meaningful distributional shift."
264
+ - **Be honest about gaps.** If a cell's logic seems off, say so —
265
+ walkthrough mode is also implicit review.
266
+ - Keep each explanation short — 2–4 sentences, occasionally a small list.
267
+ The user can ask for more.
268
+
269
+ After explaining a cell, set `cells[N].explained = true` and append the
270
+ explanation to `transcript`:
271
+
272
+ ```json
273
+ { "role": "agent", "kind": "explanation", "cellIndex": N, "text": "..." }
274
+ ```
275
+
276
+ ---
277
+
278
+ ## Question handling
279
+
280
+ When the user asks a question (either with `[NOTEBOOK-WALKTHROUGH] Question
281
+ on cell N: ...` or as a free-form chat message):
282
+
283
+ 1. Answer in chat. Reference the cell by index when relevant.
284
+ 2. Append to `transcript`:
285
+ ```json
286
+ { "role": "user", "kind": "question", "cellIndex": N, "text": "..." }
287
+ { "role": "agent", "kind": "answer", "cellIndex": N, "text": "..." }
288
+ ```
289
+ 3. Save the walkthrough state JSON.
290
+ 4. Do **not** advance `currentCellIndex`. The user is on this cell.
291
+
292
+ If the question implies a code change ("could you also compute the median
293
+ imputation?"), confirm the change in chat first, then apply it via the Edit
294
+ flow above.
295
+
296
+ ---
297
+
298
+ ## End walkthrough
299
+
300
+ When the user sends `End walkthrough` or otherwise signals completion:
301
+
302
+ 1. **Optional reproducibility check:** if cells were edited or run during the
303
+ walkthrough, offer to run `Restart & run all` once before ending — the
304
+ fresh-kernel top-to-bottom check that proves the notebook still works as a
305
+ whole. If the user accepts and an artifact is written (step 4), fold the
306
+ roll-up (`cellsPassed / cellsTotal`, first error if any) into the summary.
307
+ Offer only — never run it without confirmation.
308
+ 2. Call `python .shards/ui/notebook-kernel.py stop <session_id>`.
309
+ 3. Set walkthrough state `status = "ended"` and save.
310
+ 4. **Optional artifact:** if the notebook lives under `studies/` (Data
311
+ Scientist) or `models/` / `services/` / `research/` (ML Engineer / Syn),
312
+ offer to write a brief transcript summary to
313
+ `<project_dir>/walkthroughs/<session_id>.md` — list of cells walked
314
+ through, key explanations, user questions, and any edits applied.
315
+ Do not write this without explicit user confirmation.
316
+ 5. Close the panel:
317
+ ```bash
318
+ node .shards/ui/ui-push.js close --panel-id "nw-<session_id>"
319
+ ```
320
+
321
+ ---
322
+
323
+ ## Behavioral rules
324
+
325
+ - **Never auto-run cells the user did not ask to run.** The user clicks Run
326
+ or types `Run cell N` / `Next cell`. Even when the kernel is fresh and
327
+ the notebook obviously needs all cells executed in order, ask before
328
+ running through.
329
+ - **Never edit cells without confirmation**, even if the user is clearly
330
+ hinting. Confirm the change first.
331
+ - **Never silently skip a stale cell.** If the user asks to advance past
332
+ a stale cell, point it out and ask whether to re-run it first.
333
+ - **Save the walkthrough state JSON after every state-changing action.**
334
+ The UI is read-only — if you forget to write, the UI goes stale and the
335
+ user sees stale info.
336
+ - **One action at a time.** Don't batch. The walkthrough is conversational.
337
+ - **Kernel errors halt progress** — surface them and wait for the user.
338
+ - **Keep outputs clean.** Every `exec` writes the cell's output back into the
339
+ `.ipynb` *and* into your context. Before running a cell that would print a
340
+ secret/token or dump a full DataFrame, suggest a `.head()` / `.shape` /
341
+ summary edit first — full dumps bloat the notebook and burn context on every
342
+ state read.
343
+ - **Persona stays in character.** Use the per-agent variant's voice for
344
+ explanations and confirmations. The protocol mechanics here apply
345
+ unchanged across all three agents.
346
+
347
+ ---
348
+
349
+ ## Resume
350
+
351
+ If `<project_root>/.shards/notebook-walkthrough.json` already exists when
352
+ the agent activates:
353
+
354
+ 1. Offer to **resume** the existing session, with the same notebook and
355
+ `currentCellIndex`. State which cell you'd resume on and how many cells
356
+ are stale.
357
+ 2. If the user agrees, check the kernel:
358
+ ```bash
359
+ python .shards/ui/notebook-kernel.py status <session_id>
360
+ ```
361
+ - If `alive`: re-push the panel pointed at the existing state JSON,
362
+ re-explain the current cell, wait.
363
+ - If `dead` or `missing`: ask whether to **restart** (fresh kernel, all
364
+ executed cells become stale) or **start over** (new session id, drop
365
+ existing state).
366
+ 3. If the user prefers a fresh walkthrough, run the bootstrap sequence
367
+ from scratch — pick a new session id and overwrite the state JSON.