@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.
- package/README.md +475 -0
- package/package.json +37 -0
- package/src/agents/academic.md +276 -0
- package/src/agents/ai-engineer.md +377 -0
- package/src/agents/analytics-engineer.md +364 -0
- package/src/agents/applied-ml-scientist.md +410 -0
- package/src/agents/backend-engineer.md +255 -0
- package/src/agents/bi-engineer.md +333 -0
- package/src/agents/data-analyst.md +343 -0
- package/src/agents/data-engineer.md +260 -0
- package/src/agents/data-modeller.md +386 -0
- package/src/agents/data-scientist.md +366 -0
- package/src/agents/deep-learning-engineer.md +389 -0
- package/src/agents/ml-engineer.md +424 -0
- package/src/agents/mlops-engineer.md +339 -0
- package/src/agents/researcher.md +187 -0
- package/src/agents/specific_instructions/academic/critical_review.md +263 -0
- package/src/agents/specific_instructions/academic/report.md +113 -0
- package/src/agents/specific_instructions/ai_engineer/advise.md +162 -0
- package/src/agents/specific_instructions/ai_engineer/bi_engineer_handoff.md +86 -0
- package/src/agents/specific_instructions/ai_engineer/experiment.md +471 -0
- package/src/agents/specific_instructions/ai_engineer/experiment_ui_mode.md +44 -0
- package/src/agents/specific_instructions/ai_engineer/phases/index.md +45 -0
- package/src/agents/specific_instructions/ai_engineer/phases/phase-1.md +55 -0
- package/src/agents/specific_instructions/ai_engineer/phases/phase-2.md +86 -0
- package/src/agents/specific_instructions/ai_engineer/phases/phase-3.md +96 -0
- package/src/agents/specific_instructions/ai_engineer/phases/phase-4.md +138 -0
- package/src/agents/specific_instructions/ai_engineer/phases/phase-5.md +157 -0
- package/src/agents/specific_instructions/ai_engineer/phases/phase-6.md +196 -0
- package/src/agents/specific_instructions/ai_engineer/phases/phase-7.md +313 -0
- package/src/agents/specific_instructions/ai_engineer/phases.md +1011 -0
- package/src/agents/specific_instructions/ai_engineer/prompt_lab.md +161 -0
- package/src/agents/specific_instructions/ai_engineer/prompt_lab_ui_mode.md +28 -0
- package/src/agents/specific_instructions/ai_engineer/research.md +393 -0
- package/src/agents/specific_instructions/ai_engineer/research_ui_mode.md +66 -0
- package/src/agents/specific_instructions/ai_engineer/review.md +159 -0
- package/src/agents/specific_instructions/ai_engineer/validation_checklist.md +182 -0
- package/src/agents/specific_instructions/analytics_engineer/advise.md +155 -0
- package/src/agents/specific_instructions/analytics_engineer/bi_engineer_handoff.md +91 -0
- package/src/agents/specific_instructions/analytics_engineer/data_analyst_handoff.md +84 -0
- package/src/agents/specific_instructions/analytics_engineer/deep_phases.md +818 -0
- package/src/agents/specific_instructions/analytics_engineer/phases_deep/index.md +24 -0
- package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-1.md +77 -0
- package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-2.md +106 -0
- package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-3.md +93 -0
- package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-4.md +79 -0
- package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-5.md +61 -0
- package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-6.md +45 -0
- package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-7.md +235 -0
- package/src/agents/specific_instructions/analytics_engineer/phases_deep/phase-8.md +221 -0
- package/src/agents/specific_instructions/analytics_engineer/phases_quick/index.md +19 -0
- package/src/agents/specific_instructions/analytics_engineer/phases_quick/phase-1.md +47 -0
- package/src/agents/specific_instructions/analytics_engineer/phases_quick/phase-2.md +78 -0
- package/src/agents/specific_instructions/analytics_engineer/quick_phases.md +112 -0
- package/src/agents/specific_instructions/analytics_engineer/review.md +167 -0
- package/src/agents/specific_instructions/analytics_engineer/service_mode.md +369 -0
- package/src/agents/specific_instructions/analytics_engineer/ui_mode.md +45 -0
- package/src/agents/specific_instructions/analytics_engineer/update.md +162 -0
- package/src/agents/specific_instructions/analytics_engineer/validation_checklist.md +121 -0
- package/src/agents/specific_instructions/applied_ml_scientist/advise.md +143 -0
- package/src/agents/specific_instructions/applied_ml_scientist/phases/index.md +21 -0
- package/src/agents/specific_instructions/applied_ml_scientist/phases/phase-1.md +51 -0
- package/src/agents/specific_instructions/applied_ml_scientist/phases/phase-2.md +66 -0
- package/src/agents/specific_instructions/applied_ml_scientist/phases/phase-3.md +113 -0
- package/src/agents/specific_instructions/applied_ml_scientist/phases/phase-4.md +104 -0
- package/src/agents/specific_instructions/applied_ml_scientist/phases/phase-5.md +156 -0
- package/src/agents/specific_instructions/applied_ml_scientist/phases.md +428 -0
- package/src/agents/specific_instructions/applied_ml_scientist/research.md +379 -0
- package/src/agents/specific_instructions/applied_ml_scientist/review.md +142 -0
- package/src/agents/specific_instructions/applied_ml_scientist/validation_checklist.md +136 -0
- package/src/agents/specific_instructions/backend_engineer/clean.md +149 -0
- package/src/agents/specific_instructions/backend_engineer/review.md +91 -0
- package/src/agents/specific_instructions/backend_engineer/review_checklist.md +54 -0
- package/src/agents/specific_instructions/backend_engineer/service_mode.md +67 -0
- package/src/agents/specific_instructions/bi_engineer/advise.md +137 -0
- package/src/agents/specific_instructions/bi_engineer/data_analyst_handoff.md +77 -0
- package/src/agents/specific_instructions/bi_engineer/incoming_handoff.md +45 -0
- package/src/agents/specific_instructions/bi_engineer/phases/index.md +20 -0
- package/src/agents/specific_instructions/bi_engineer/phases/phase-1.md +164 -0
- package/src/agents/specific_instructions/bi_engineer/phases/phase-2.md +92 -0
- package/src/agents/specific_instructions/bi_engineer/phases/phase-3.md +121 -0
- package/src/agents/specific_instructions/bi_engineer/phases/phase-4.md +106 -0
- package/src/agents/specific_instructions/bi_engineer/phases.md +451 -0
- package/src/agents/specific_instructions/bi_engineer/review.md +166 -0
- package/src/agents/specific_instructions/bi_engineer/update.md +147 -0
- package/src/agents/specific_instructions/bi_engineer/validation_checklist.md +124 -0
- package/src/agents/specific_instructions/data_analyst/advise.md +138 -0
- package/src/agents/specific_instructions/data_analyst/explain.md +221 -0
- package/src/agents/specific_instructions/data_analyst/incoming_handoff.md +40 -0
- package/src/agents/specific_instructions/data_analyst/phases/index.md +20 -0
- package/src/agents/specific_instructions/data_analyst/phases/phase-1.md +159 -0
- package/src/agents/specific_instructions/data_analyst/phases/phase-2.md +112 -0
- package/src/agents/specific_instructions/data_analyst/phases/phase-3.md +265 -0
- package/src/agents/specific_instructions/data_analyst/phases/phase-4.md +100 -0
- package/src/agents/specific_instructions/data_analyst/phases.md +501 -0
- package/src/agents/specific_instructions/data_analyst/review.md +138 -0
- package/src/agents/specific_instructions/data_analyst/ui_mode.md +26 -0
- package/src/agents/specific_instructions/data_analyst/update.md +144 -0
- package/src/agents/specific_instructions/data_analyst/validation_checklist.md +95 -0
- package/src/agents/specific_instructions/data_engineer/advise.md +137 -0
- package/src/agents/specific_instructions/data_engineer/phases.md +466 -0
- package/src/agents/specific_instructions/data_engineer/phases_deep/index.md +23 -0
- package/src/agents/specific_instructions/data_engineer/phases_deep/phase-1.md +49 -0
- package/src/agents/specific_instructions/data_engineer/phases_deep/phase-2.md +93 -0
- package/src/agents/specific_instructions/data_engineer/phases_deep/phase-3.md +55 -0
- package/src/agents/specific_instructions/data_engineer/phases_deep/phase-4.md +48 -0
- package/src/agents/specific_instructions/data_engineer/phases_deep/phase-5.md +40 -0
- package/src/agents/specific_instructions/data_engineer/phases_deep/phase-6.md +102 -0
- package/src/agents/specific_instructions/data_engineer/phases_deep/phase-7.md +87 -0
- package/src/agents/specific_instructions/data_engineer/phases_quick/index.md +19 -0
- package/src/agents/specific_instructions/data_engineer/phases_quick/phase-1.md +45 -0
- package/src/agents/specific_instructions/data_engineer/phases_quick/phase-2.md +54 -0
- package/src/agents/specific_instructions/data_engineer/review.md +135 -0
- package/src/agents/specific_instructions/data_engineer/validation_checklist.md +136 -0
- package/src/agents/specific_instructions/data_modeller/advise.md +137 -0
- package/src/agents/specific_instructions/data_modeller/phases.md +581 -0
- package/src/agents/specific_instructions/data_modeller/phases_deep/index.md +23 -0
- package/src/agents/specific_instructions/data_modeller/phases_deep/phase-1.md +52 -0
- package/src/agents/specific_instructions/data_modeller/phases_deep/phase-2.md +113 -0
- package/src/agents/specific_instructions/data_modeller/phases_deep/phase-3.md +47 -0
- package/src/agents/specific_instructions/data_modeller/phases_deep/phase-4.md +51 -0
- package/src/agents/specific_instructions/data_modeller/phases_deep/phase-5.md +45 -0
- package/src/agents/specific_instructions/data_modeller/phases_deep/phase-6.md +105 -0
- package/src/agents/specific_instructions/data_modeller/phases_deep/phase-7.md +136 -0
- package/src/agents/specific_instructions/data_modeller/phases_quick/index.md +19 -0
- package/src/agents/specific_instructions/data_modeller/phases_quick/phase-1.md +47 -0
- package/src/agents/specific_instructions/data_modeller/phases_quick/phase-2.md +65 -0
- package/src/agents/specific_instructions/data_modeller/review.md +141 -0
- package/src/agents/specific_instructions/data_modeller/service_mode.md +218 -0
- package/src/agents/specific_instructions/data_modeller/validation_checklist.md +125 -0
- package/src/agents/specific_instructions/data_scientist/advise.md +158 -0
- package/src/agents/specific_instructions/data_scientist/bi_engineer_handoff.md +63 -0
- package/src/agents/specific_instructions/data_scientist/experiment.md +482 -0
- package/src/agents/specific_instructions/data_scientist/experiment_ui_mode.md +44 -0
- package/src/agents/specific_instructions/data_scientist/explain.md +247 -0
- package/src/agents/specific_instructions/data_scientist/greenfield_data.md +35 -0
- package/src/agents/specific_instructions/data_scientist/ml_engineer_handoff.md +52 -0
- package/src/agents/specific_instructions/data_scientist/notebook_walkthrough.md +76 -0
- package/src/agents/specific_instructions/data_scientist/phases/index.md +24 -0
- package/src/agents/specific_instructions/data_scientist/phases/phase-1.md +45 -0
- package/src/agents/specific_instructions/data_scientist/phases/phase-2.md +67 -0
- package/src/agents/specific_instructions/data_scientist/phases/phase-3.md +89 -0
- package/src/agents/specific_instructions/data_scientist/phases/phase-4.md +143 -0
- package/src/agents/specific_instructions/data_scientist/phases/phase-5.md +71 -0
- package/src/agents/specific_instructions/data_scientist/phases/phase-6.md +239 -0
- package/src/agents/specific_instructions/data_scientist/phases/phase-7.md +207 -0
- package/src/agents/specific_instructions/data_scientist/phases.md +651 -0
- package/src/agents/specific_instructions/data_scientist/research.md +345 -0
- package/src/agents/specific_instructions/data_scientist/research_ui_mode.md +52 -0
- package/src/agents/specific_instructions/data_scientist/review.md +136 -0
- package/src/agents/specific_instructions/data_scientist/service_mode.md +247 -0
- package/src/agents/specific_instructions/data_scientist/validation_checklist.md +183 -0
- package/src/agents/specific_instructions/deep_learning_engineer/advise.md +145 -0
- package/src/agents/specific_instructions/deep_learning_engineer/phases/index.md +21 -0
- package/src/agents/specific_instructions/deep_learning_engineer/phases/phase-1.md +74 -0
- package/src/agents/specific_instructions/deep_learning_engineer/phases/phase-2.md +98 -0
- package/src/agents/specific_instructions/deep_learning_engineer/phases/phase-3.md +76 -0
- package/src/agents/specific_instructions/deep_learning_engineer/phases/phase-4.md +128 -0
- package/src/agents/specific_instructions/deep_learning_engineer/phases/phase-5.md +292 -0
- package/src/agents/specific_instructions/deep_learning_engineer/phases.md +567 -0
- package/src/agents/specific_instructions/deep_learning_engineer/research.md +389 -0
- package/src/agents/specific_instructions/deep_learning_engineer/review.md +155 -0
- package/src/agents/specific_instructions/deep_learning_engineer/validation_checklist.md +147 -0
- package/src/agents/specific_instructions/ml_engineer/advise.md +174 -0
- package/src/agents/specific_instructions/ml_engineer/bi_engineer_handoff.md +71 -0
- package/src/agents/specific_instructions/ml_engineer/experiment.md +474 -0
- package/src/agents/specific_instructions/ml_engineer/experiment_ui_mode.md +44 -0
- package/src/agents/specific_instructions/ml_engineer/notebook_walkthrough.md +75 -0
- package/src/agents/specific_instructions/ml_engineer/phases/index.md +25 -0
- package/src/agents/specific_instructions/ml_engineer/phases/phase-1.md +49 -0
- package/src/agents/specific_instructions/ml_engineer/phases/phase-2.md +75 -0
- package/src/agents/specific_instructions/ml_engineer/phases/phase-3.md +124 -0
- package/src/agents/specific_instructions/ml_engineer/phases/phase-4.md +279 -0
- package/src/agents/specific_instructions/ml_engineer/phases/phase-5.md +160 -0
- package/src/agents/specific_instructions/ml_engineer/phases/phase-6-5.md +170 -0
- package/src/agents/specific_instructions/ml_engineer/phases/phase-6.md +295 -0
- package/src/agents/specific_instructions/ml_engineer/phases/phase-7.md +337 -0
- package/src/agents/specific_instructions/ml_engineer/phases.md +1068 -0
- package/src/agents/specific_instructions/ml_engineer/research.md +437 -0
- package/src/agents/specific_instructions/ml_engineer/research_ui_mode.md +71 -0
- package/src/agents/specific_instructions/ml_engineer/review.md +187 -0
- package/src/agents/specific_instructions/ml_engineer/service_mode.md +273 -0
- package/src/agents/specific_instructions/ml_engineer/validation_checklist.md +185 -0
- package/src/agents/specific_instructions/mlops_engineer/advise.md +139 -0
- package/src/agents/specific_instructions/mlops_engineer/phases/index.md +23 -0
- package/src/agents/specific_instructions/mlops_engineer/phases/phase-1.md +52 -0
- package/src/agents/specific_instructions/mlops_engineer/phases/phase-2.md +86 -0
- package/src/agents/specific_instructions/mlops_engineer/phases/phase-3.md +105 -0
- package/src/agents/specific_instructions/mlops_engineer/phases/phase-4.md +128 -0
- package/src/agents/specific_instructions/mlops_engineer/phases/phase-5.md +106 -0
- package/src/agents/specific_instructions/mlops_engineer/phases/phase-6.md +128 -0
- package/src/agents/specific_instructions/mlops_engineer/phases/phase-7.md +144 -0
- package/src/agents/specific_instructions/mlops_engineer/phases.md +671 -0
- package/src/agents/specific_instructions/mlops_engineer/review.md +164 -0
- package/src/agents/specific_instructions/mlops_engineer/service_mode.md +81 -0
- package/src/agents/specific_instructions/mlops_engineer/validation_checklist.md +151 -0
- package/src/agents/specific_instructions/researcher/critical_review.md +292 -0
- package/src/agents/specific_instructions/researcher/review_checklist.md +67 -0
- package/src/agents/specific_instructions/researcher/service_mode.md +224 -0
- package/src/agents/specific_instructions/shared/auto_verify_mode.md +141 -0
- package/src/agents/specific_instructions/shared/autonomous_research.md +1289 -0
- package/src/agents/specific_instructions/shared/behavioral_rules.md +36 -0
- package/src/agents/specific_instructions/shared/diverge_protocol.md +387 -0
- package/src/agents/specific_instructions/shared/engineering_guidelines.md +136 -0
- package/src/agents/specific_instructions/shared/experiment_versioning.md +184 -0
- package/src/agents/specific_instructions/shared/goal_mode.md +187 -0
- package/src/agents/specific_instructions/shared/incremental_testing.md +139 -0
- package/src/agents/specific_instructions/shared/intent_discovery.md +223 -0
- package/src/agents/specific_instructions/shared/join_path_protocol.md +168 -0
- package/src/agents/specific_instructions/shared/knowledge_checkpoint.md +83 -0
- package/src/agents/specific_instructions/shared/knowledge_harvest.md +220 -0
- package/src/agents/specific_instructions/shared/knowledge_retrieval.md +100 -0
- package/src/agents/specific_instructions/shared/notebook_walkthrough_protocol.md +367 -0
- package/src/agents/specific_instructions/shared/reviewer_verdict_protocol.md +74 -0
- package/src/agents/specific_instructions/shared/swarm_protocol.md +97 -0
- package/src/agents/specific_instructions/shared/validation_protocol.md +139 -0
- package/src/agents/specific_instructions/syn/arbiter.md +140 -0
- package/src/agents/specific_instructions/syn/brainstorm.md +550 -0
- package/src/agents/specific_instructions/syn/code_review.md +232 -0
- package/src/agents/specific_instructions/syn/diff.md +239 -0
- package/src/agents/specific_instructions/syn/final_review.md +65 -0
- package/src/agents/specific_instructions/syn/fixer.md +240 -0
- package/src/agents/specific_instructions/syn/free_form.md +130 -0
- package/src/agents/specific_instructions/syn/knowledge.md +468 -0
- package/src/agents/specific_instructions/syn/notebook_walkthrough.md +78 -0
- package/src/agents/specific_instructions/syn/panel_review.md +634 -0
- package/src/agents/specific_instructions/syn/pm.md +453 -0
- package/src/agents/specific_instructions/syn/pr_review.md +255 -0
- package/src/agents/specific_instructions/syn/slides.md +417 -0
- package/src/agents/syn.md +729 -0
- package/src/commands/academic.md +41 -0
- package/src/commands/ai-engineer.md +45 -0
- package/src/commands/analytics-engineer.md +48 -0
- package/src/commands/applied-ml-scientist.md +45 -0
- package/src/commands/backend-engineer.md +35 -0
- package/src/commands/bi-engineer.md +40 -0
- package/src/commands/brainstorm.md +24 -0
- package/src/commands/data-analyst.md +38 -0
- package/src/commands/data-engineer.md +37 -0
- package/src/commands/data-modeller.md +38 -0
- package/src/commands/data-scientist.md +38 -0
- package/src/commands/deep-learning-engineer.md +47 -0
- package/src/commands/end.md +49 -0
- package/src/commands/knowledge.md +24 -0
- package/src/commands/ml-engineer.md +42 -0
- package/src/commands/mlops-engineer.md +47 -0
- package/src/commands/notebook-walkthrough.md +58 -0
- package/src/commands/researcher.md +40 -0
- package/src/commands/resume.md +57 -0
- package/src/commands/review-pr.md +26 -0
- package/src/commands/shards-guide.md +41 -0
- package/src/commands/shards-ui.md +32 -0
- package/src/commands/shards.md +41 -0
- package/src/docs/01-getting-started/concepts.md +109 -0
- package/src/docs/01-getting-started/first-session.md +79 -0
- package/src/docs/01-getting-started/install.md +61 -0
- package/src/docs/02-agents/academic.md +71 -0
- package/src/docs/02-agents/ai-engineer.md +78 -0
- package/src/docs/02-agents/analytics-engineer.md +58 -0
- package/src/docs/02-agents/applied-ml-scientist.md +59 -0
- package/src/docs/02-agents/backend-engineer.md +58 -0
- package/src/docs/02-agents/bi-engineer.md +65 -0
- package/src/docs/02-agents/data-analyst.md +67 -0
- package/src/docs/02-agents/data-engineer.md +57 -0
- package/src/docs/02-agents/data-modeller.md +51 -0
- package/src/docs/02-agents/data-scientist.md +78 -0
- package/src/docs/02-agents/deep-learning-engineer.md +64 -0
- package/src/docs/02-agents/ml-engineer.md +80 -0
- package/src/docs/02-agents/mlops-engineer.md +59 -0
- package/src/docs/02-agents/overview.md +62 -0
- package/src/docs/02-agents/researcher.md +73 -0
- package/src/docs/02-agents/syn.md +88 -0
- package/src/docs/03-protocols/auto-verify.md +82 -0
- package/src/docs/03-protocols/autonomous-research.md +59 -0
- package/src/docs/03-protocols/behavioral-rules.md +35 -0
- package/src/docs/03-protocols/diverge.md +50 -0
- package/src/docs/03-protocols/engineering-guidelines.md +56 -0
- package/src/docs/03-protocols/experiment-versioning.md +38 -0
- package/src/docs/03-protocols/gate-pattern.md +65 -0
- package/src/docs/03-protocols/incremental-testing.md +68 -0
- package/src/docs/03-protocols/join-path.md +46 -0
- package/src/docs/03-protocols/knowledge-ledger.md +70 -0
- package/src/docs/03-protocols/reviewer-verdicts.md +39 -0
- package/src/docs/03-protocols/swarm.md +40 -0
- package/src/docs/03-protocols/validation.md +174 -0
- package/src/docs/04-ui/activity-bar.md +70 -0
- package/src/docs/04-ui/chat-pane.md +80 -0
- package/src/docs/04-ui/code-intel.md +62 -0
- package/src/docs/04-ui/file-editing.md +61 -0
- package/src/docs/04-ui/git.md +54 -0
- package/src/docs/04-ui/keybindings.md +79 -0
- package/src/docs/04-ui/knowledge-map.md +76 -0
- package/src/docs/04-ui/overview.md +93 -0
- package/src/docs/04-ui/panels.md +49 -0
- package/src/docs/04-ui/pinboard-selection.md +66 -0
- package/src/docs/04-ui/quick-open-palette.md +56 -0
- package/src/docs/04-ui/sessions.md +81 -0
- package/src/docs/04-ui/settings-permissions.md +56 -0
- package/src/docs/05-commands/reference.md +59 -0
- package/src/docs/06-outputs/directory-map.md +116 -0
- package/src/docs/07-workflows/ai-eval-first.md +57 -0
- package/src/docs/07-workflows/deep-study-to-production.md +76 -0
- package/src/docs/07-workflows/diverge-exploration.md +77 -0
- package/src/docs/07-workflows/quick-analysis.md +45 -0
- package/src/docs/08-integrations/claude-code-auto-mode.md +191 -0
- package/src/docs/08-integrations/google-slides.md +175 -0
- package/src/docs/README.md +30 -0
- package/src/docs/manifest.json +108 -0
- package/src/templates/analysis-template.md +20 -0
- package/src/templates/branch-report.md +46 -0
- package/src/templates/diff-report.md +88 -0
- package/src/templates/knowledge-index.md +7 -0
- package/src/templates/model-card-schema.json +186 -0
- package/src/templates/model-card-schema.md +88 -0
- package/src/templates/model-card.md +124 -0
- package/src/templates/project-plan.md +47 -0
- package/src/templates/project-specs.md +81 -0
- package/src/templates/report-template.md +43 -0
- package/src/templates/study-template.md +25 -0
- package/src/ui/cc-readonly.js +181 -0
- package/src/ui/chat-session.js +466 -0
- package/src/ui/css/base.css +136 -0
- package/src/ui/css/brainstorm.css +525 -0
- package/src/ui/css/chat.css +1405 -0
- package/src/ui/css/editor.css +546 -0
- package/src/ui/css/eval-dashboard.css +157 -0
- package/src/ui/css/experiment.css +237 -0
- package/src/ui/css/guide.css +186 -0
- package/src/ui/css/knowledge-map.css +383 -0
- package/src/ui/css/layout.css +431 -0
- package/src/ui/css/model-card.css +161 -0
- package/src/ui/css/notebook-walkthrough.css +271 -0
- package/src/ui/css/pr-review.css +403 -0
- package/src/ui/css/prompt-lab.css +325 -0
- package/src/ui/css/sessions.css +258 -0
- package/src/ui/css/sidebar.css +661 -0
- package/src/ui/css/terminal.css +113 -0
- package/src/ui/css/theme-light.css +542 -0
- package/src/ui/index.html +389 -0
- package/src/ui/js/agents.js +32 -0
- package/src/ui/js/bookmarks.js +230 -0
- package/src/ui/js/chat.js +1776 -0
- package/src/ui/js/code-intel.js +328 -0
- package/src/ui/js/command-palette.js +142 -0
- package/src/ui/js/events.js +591 -0
- package/src/ui/js/explorer.js +317 -0
- package/src/ui/js/file-view.js +477 -0
- package/src/ui/js/git.js +536 -0
- package/src/ui/js/guide.js +198 -0
- package/src/ui/js/hud.js +75 -0
- package/src/ui/js/init.js +351 -0
- package/src/ui/js/knowledge-map.js +906 -0
- package/src/ui/js/markdown.js +114 -0
- package/src/ui/js/monaco.js +164 -0
- package/src/ui/js/notebook-walkthrough.js +272 -0
- package/src/ui/js/notebook.js +448 -0
- package/src/ui/js/panels.js +2681 -0
- package/src/ui/js/pinboard.js +186 -0
- package/src/ui/js/quick-open.js +164 -0
- package/src/ui/js/selection-context.js +131 -0
- package/src/ui/js/sessions.js +256 -0
- package/src/ui/js/settings.js +476 -0
- package/src/ui/js/split-view.js +82 -0
- package/src/ui/js/state.js +343 -0
- package/src/ui/js/table.js +161 -0
- package/src/ui/js/tabs.js +284 -0
- package/src/ui/js/tabular.js +125 -0
- package/src/ui/js/terminal.js +354 -0
- package/src/ui/js/timeline.js +137 -0
- package/src/ui/js/utils.js +293 -0
- package/src/ui/notebook-kernel.py +790 -0
- package/src/ui/open-browser.js +55 -0
- package/src/ui/permission-pattern.js +42 -0
- package/src/ui/relay.js +513 -0
- package/src/ui/server.js +3072 -0
- package/src/ui/session-index.js +225 -0
- package/src/ui/shards_icon.png +0 -0
- package/src/ui/spawn-server.js +41 -0
- package/src/ui/symbol-index.js +813 -0
- package/src/ui/ui-push.js +177 -0
- package/tools/gate-hook/VALIDATION_SPEC.md +273 -0
- package/tools/gate-hook/__tests__/auto-verify.test.js +343 -0
- package/tools/gate-hook/auto-allowlist.js +179 -0
- package/tools/gate-hook/auto-state.js +68 -0
- package/tools/gate-hook/classify.js +21 -0
- package/tools/gate-hook/log.js +57 -0
- package/tools/gate-hook/parser.js +205 -0
- package/tools/gate-hook/sql-guard.js +230 -0
- package/tools/gate-hook/state.js +170 -0
- package/tools/gate-hook/sweep.js +139 -0
- package/tools/gate-hook/transcript.js +45 -0
- package/tools/gate-hook/validation.js +321 -0
- package/tools/gate-hook.js +475 -0
- package/tools/install.js +914 -0
- package/tools/shards-gates.js +311 -0
- package/tools/shards-sessions.js +261 -0
- package/tools/shards-ui.js +377 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════
|
|
2
|
+
// Markdown renderer (marked.js v4 + custom code highlighting)
|
|
3
|
+
// ═══════════════════════════════════════════════════════════════
|
|
4
|
+
|
|
5
|
+
(function initMarked() {
|
|
6
|
+
var renderer = new marked.Renderer();
|
|
7
|
+
|
|
8
|
+
renderer.code = function(code, lang) {
|
|
9
|
+
var highlighted = highlightCode(esc(code), lang || '');
|
|
10
|
+
return '<div class="code-block-wrapper"><button class="copy-code-btn" onclick="copyCodeBlock(this)">Copy</button><pre><code>' + highlighted + '</code></pre></div>';
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
marked.setOptions({
|
|
14
|
+
gfm: true,
|
|
15
|
+
breaks: false,
|
|
16
|
+
renderer: renderer
|
|
17
|
+
});
|
|
18
|
+
})();
|
|
19
|
+
|
|
20
|
+
function renderMarkdown(md) {
|
|
21
|
+
if (!md) return '';
|
|
22
|
+
return marked.parse(md);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ═══════════════════════════════════════════════════════════════
|
|
26
|
+
// Syntax highlighting
|
|
27
|
+
// ═══════════════════════════════════════════════════════════════
|
|
28
|
+
|
|
29
|
+
function highlightCode(escapedCode, lang) {
|
|
30
|
+
if (!lang) return escapedCode;
|
|
31
|
+
switch (lang.toLowerCase()) {
|
|
32
|
+
case 'python': case 'py': return hlPython(escapedCode);
|
|
33
|
+
case 'sql': return hlSQL(escapedCode);
|
|
34
|
+
case 'javascript': case 'js': case 'typescript': case 'ts': return hlJS(escapedCode);
|
|
35
|
+
case 'json': return hlJSON(escapedCode);
|
|
36
|
+
case 'yaml': case 'yml': return hlYAML(escapedCode);
|
|
37
|
+
default: return escapedCode;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Single-pass tokenizer: comments/strings claim their full regions first, then
|
|
42
|
+
// keywords and numbers match only in the remaining unclaimed code. Avoids later
|
|
43
|
+
// regexes matching inside HTML produced by earlier ones (e.g. `class` keyword
|
|
44
|
+
// matching inside `<span class="cmt">`).
|
|
45
|
+
function hlPython(code) {
|
|
46
|
+
var kws = 'def|class|import|from|return|if|elif|else|for|while|in|not|and|or|with|as|try|except|finally|raise|pass|break|continue|lambda|yield|global|nonlocal|del|assert|True|False|None|async|await|is|print';
|
|
47
|
+
var pattern = new RegExp(
|
|
48
|
+
'(#[^\\n]*)' +
|
|
49
|
+
'|("""[\\s\\S]*?"""|\'\'\'[\\s\\S]*?\'\'\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\')' +
|
|
50
|
+
'|\\b(' + kws + ')\\b' +
|
|
51
|
+
'|\\b(\\d+\\.?\\d*)\\b',
|
|
52
|
+
'g'
|
|
53
|
+
);
|
|
54
|
+
return code.replace(pattern, function(m, cmt, str, kw, num) {
|
|
55
|
+
if (cmt) return '<span class="cmt">' + cmt + '</span>';
|
|
56
|
+
if (str) return '<span class="str">' + str + '</span>';
|
|
57
|
+
if (kw) return '<span class="kw">' + kw + '</span>';
|
|
58
|
+
if (num) return '<span class="num">' + num + '</span>';
|
|
59
|
+
return m;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function hlSQL(code) {
|
|
64
|
+
var kws = 'SELECT|FROM|WHERE|JOIN|LEFT|RIGHT|INNER|OUTER|FULL|ON|GROUP|BY|ORDER|HAVING|LIMIT|OFFSET|INSERT|INTO|VALUES|UPDATE|SET|DELETE|CREATE|TABLE|DROP|ALTER|ADD|COLUMN|INDEX|VIEW|WITH|AS|AND|OR|NOT|IN|IS|NULL|LIKE|BETWEEN|EXISTS|DISTINCT|COUNT|SUM|AVG|MIN|MAX|CASE|WHEN|THEN|ELSE|END|UNION|ALL|OVER|PARTITION|ROW_NUMBER|RANK|DENSE_RANK|COALESCE|CAST|DATE|TIMESTAMP';
|
|
65
|
+
var pattern = new RegExp(
|
|
66
|
+
'(--[^\\n]*)' +
|
|
67
|
+
'|(\'(?:[^\'\\\\]|\\\\.)*\')' +
|
|
68
|
+
'|\\b(' + kws + ')\\b' +
|
|
69
|
+
'|\\b(\\d+\\.?\\d*)\\b',
|
|
70
|
+
'gi'
|
|
71
|
+
);
|
|
72
|
+
return code.replace(pattern, function(m, cmt, str, kw, num) {
|
|
73
|
+
if (cmt) return '<span class="cmt">' + cmt + '</span>';
|
|
74
|
+
if (str) return '<span class="str">' + str + '</span>';
|
|
75
|
+
if (kw) return '<span class="kw">' + kw.toUpperCase() + '</span>';
|
|
76
|
+
if (num) return '<span class="num">' + num + '</span>';
|
|
77
|
+
return m;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function hlJS(code) {
|
|
82
|
+
var kws = 'const|let|var|function|return|if|else|for|while|do|class|extends|import|export|default|from|new|this|typeof|instanceof|in|of|try|catch|finally|throw|async|await|true|false|null|undefined|break|continue|switch|case|delete|void|yield|interface|type|enum|static|get|set';
|
|
83
|
+
var pattern = new RegExp(
|
|
84
|
+
'(\\/\\/[^\\n]*)' +
|
|
85
|
+
'|("(?:[^"\\\\]|\\\\.)*"|\'(?:[^\'\\\\]|\\\\.)*\'|`(?:[^`\\\\]|\\\\.)*`)' +
|
|
86
|
+
'|\\b(' + kws + ')\\b' +
|
|
87
|
+
'|\\b(\\d+\\.?\\d*)\\b',
|
|
88
|
+
'g'
|
|
89
|
+
);
|
|
90
|
+
return code.replace(pattern, function(m, cmt, str, kw, num) {
|
|
91
|
+
if (cmt) return '<span class="cmt">' + cmt + '</span>';
|
|
92
|
+
if (str) return '<span class="str">' + str + '</span>';
|
|
93
|
+
if (kw) return '<span class="kw">' + kw + '</span>';
|
|
94
|
+
if (num) return '<span class="num">' + num + '</span>';
|
|
95
|
+
return m;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function hlJSON(code) {
|
|
100
|
+
return code
|
|
101
|
+
.replace(/("(?:[^"\\]|\\.)*")(\s*:)/g, '<span class="attr">$1</span>$2')
|
|
102
|
+
.replace(/:\s*("(?:[^"\\]|\\.)*")/g, ': <span class="str">$1</span>')
|
|
103
|
+
.replace(/:\s*(\d+\.?\d*(?:[eE][+-]?\d+)?)/g, ': <span class="num">$1</span>')
|
|
104
|
+
.replace(/:\s*(true|false|null)/g, ': <span class="kw">$1</span>');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function hlYAML(code) {
|
|
108
|
+
return code.split('\n').map(function(line) {
|
|
109
|
+
if (/^\s*#/.test(line)) return '<span class="cmt">' + line + '</span>';
|
|
110
|
+
var m = line.match(/^(\s*\S[^:]*:)(.*)/);
|
|
111
|
+
if (m) return '<span class="attr">' + m[1] + '</span><span class="str">' + m[2] + '</span>';
|
|
112
|
+
return line;
|
|
113
|
+
}).join('\n');
|
|
114
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════
|
|
2
|
+
// Monaco Editor loader
|
|
3
|
+
// ═══════════════════════════════════════════════════════════════
|
|
4
|
+
|
|
5
|
+
function loadMonaco() {
|
|
6
|
+
if (monacoLoadPromise) return monacoLoadPromise;
|
|
7
|
+
monacoLoadPromise = new Promise(function(resolve, reject) {
|
|
8
|
+
if (monacoLoaded) { resolve(window.monaco); return; }
|
|
9
|
+
if (monacoFailed) { reject(new Error('Monaco load failed previously')); return; }
|
|
10
|
+
|
|
11
|
+
var script = document.createElement('script');
|
|
12
|
+
script.src = 'https://cdn.jsdelivr.net/npm/monaco-editor@0.45.0/min/vs/loader.js';
|
|
13
|
+
script.onload = function() {
|
|
14
|
+
window.require.config({
|
|
15
|
+
paths: { vs: 'https://cdn.jsdelivr.net/npm/monaco-editor@0.45.0/min/vs' }
|
|
16
|
+
});
|
|
17
|
+
window.require(['vs/editor/editor.main'], function() {
|
|
18
|
+
monacoLoaded = true;
|
|
19
|
+
defineShardsDarkTheme();
|
|
20
|
+
if (typeof registerCodeIntelProviders === 'function') {
|
|
21
|
+
registerCodeIntelProviders();
|
|
22
|
+
}
|
|
23
|
+
resolve(window.monaco);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
script.onerror = function() {
|
|
27
|
+
monacoFailed = true;
|
|
28
|
+
reject(new Error('Monaco CDN load failed'));
|
|
29
|
+
};
|
|
30
|
+
// Timeout fallback
|
|
31
|
+
setTimeout(function() {
|
|
32
|
+
if (!monacoLoaded) {
|
|
33
|
+
monacoFailed = true;
|
|
34
|
+
reject(new Error('Monaco load timeout'));
|
|
35
|
+
}
|
|
36
|
+
}, 15000);
|
|
37
|
+
document.head.appendChild(script);
|
|
38
|
+
});
|
|
39
|
+
return monacoLoadPromise;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function defineShardsDarkTheme() {
|
|
43
|
+
monaco.editor.defineTheme('shards-dark', {
|
|
44
|
+
base: 'vs-dark',
|
|
45
|
+
inherit: true,
|
|
46
|
+
rules: [
|
|
47
|
+
{ token: 'keyword', foreground: 'c678dd' },
|
|
48
|
+
{ token: 'string', foreground: '98c379' },
|
|
49
|
+
{ token: 'number', foreground: 'd19a66' },
|
|
50
|
+
{ token: 'comment', foreground: '4a5060', fontStyle: 'italic' },
|
|
51
|
+
{ token: 'type', foreground: '61afef' },
|
|
52
|
+
{ token: 'function', foreground: '61afef' },
|
|
53
|
+
{ token: 'variable', foreground: 'b0b0c4' },
|
|
54
|
+
{ token: 'operator', foreground: '56b6c2' },
|
|
55
|
+
{ token: 'delimiter', foreground: '808098' },
|
|
56
|
+
{ token: 'tag', foreground: 'e06c75' },
|
|
57
|
+
{ token: 'attribute.name', foreground: 'd19a66' },
|
|
58
|
+
{ token: 'attribute.value', foreground: '98c379' },
|
|
59
|
+
],
|
|
60
|
+
colors: {
|
|
61
|
+
'editor.background': '#0a0a16',
|
|
62
|
+
'editor.foreground': '#b0b0c4',
|
|
63
|
+
'editor.lineHighlightBackground': '#0e0e1e',
|
|
64
|
+
'editor.selectionBackground': '#1a1a3a',
|
|
65
|
+
'editorCursor.foreground': '#5080e0',
|
|
66
|
+
'editorLineNumber.foreground': '#2a2a44',
|
|
67
|
+
'editorLineNumber.activeForeground': '#4a4a68',
|
|
68
|
+
'editor.inactiveSelectionBackground': '#141428',
|
|
69
|
+
'editorIndentGuide.background': '#141420',
|
|
70
|
+
'editorWhitespace.foreground': '#1a1a2c',
|
|
71
|
+
'scrollbarSlider.background': '#1a1a2c80',
|
|
72
|
+
'scrollbarSlider.hoverBackground': '#25254080',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
monaco.editor.defineTheme('shards-light', {
|
|
76
|
+
base: 'vs',
|
|
77
|
+
inherit: true,
|
|
78
|
+
rules: [
|
|
79
|
+
{ token: 'keyword', foreground: '8b2fc9' },
|
|
80
|
+
{ token: 'string', foreground: '248a3d' },
|
|
81
|
+
{ token: 'number', foreground: 'b05000' },
|
|
82
|
+
{ token: 'comment', foreground: '8e8e93', fontStyle: 'italic' },
|
|
83
|
+
{ token: 'type', foreground: '2560c4' },
|
|
84
|
+
{ token: 'function', foreground: '2560c4' },
|
|
85
|
+
{ token: 'variable', foreground: '333333' },
|
|
86
|
+
{ token: 'operator', foreground: '1a7a7a' },
|
|
87
|
+
{ token: 'delimiter', foreground: '666666' },
|
|
88
|
+
{ token: 'tag', foreground: 'c23030' },
|
|
89
|
+
{ token: 'attribute.name', foreground: 'b05000' },
|
|
90
|
+
{ token: 'attribute.value', foreground: '248a3d' },
|
|
91
|
+
],
|
|
92
|
+
colors: {
|
|
93
|
+
'editor.background': '#f5f5f8',
|
|
94
|
+
'editor.foreground': '#333333',
|
|
95
|
+
'editor.lineHighlightBackground': '#f0f0f4',
|
|
96
|
+
'editor.selectionBackground': '#c5cae9',
|
|
97
|
+
'editorCursor.foreground': '#4a80e0',
|
|
98
|
+
'editorLineNumber.foreground': '#bbbbbb',
|
|
99
|
+
'editorLineNumber.activeForeground': '#888888',
|
|
100
|
+
'editor.inactiveSelectionBackground': '#dde4f4',
|
|
101
|
+
'editorIndentGuide.background': '#e0e0e0',
|
|
102
|
+
'editorWhitespace.foreground': '#d0d0d0',
|
|
103
|
+
'scrollbarSlider.background': '#cccccc80',
|
|
104
|
+
'scrollbarSlider.hoverBackground': '#aaaaaa80',
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function currentMonacoTheme() {
|
|
110
|
+
return document.documentElement.getAttribute('data-theme') === 'light' ? 'shards-light' : 'shards-dark';
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function disposeMonacoInstance() {
|
|
114
|
+
if (activeMonacoInstance) {
|
|
115
|
+
activeMonacoInstance.dispose();
|
|
116
|
+
activeMonacoInstance = null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function disposeNotebookCellMonaco() {
|
|
121
|
+
if (activeNotebookCellMonaco) {
|
|
122
|
+
// Save current value before disposing
|
|
123
|
+
var key = getCurrentFileKey();
|
|
124
|
+
if (key && openFiles[key] && openFiles[key].notebookData && activeNotebookCellIdx !== null) {
|
|
125
|
+
var cell = openFiles[key].notebookData.cells[activeNotebookCellIdx];
|
|
126
|
+
if (cell) {
|
|
127
|
+
cell.source = activeNotebookCellMonaco.getValue();
|
|
128
|
+
if (cell.cell_type === 'markdown') {
|
|
129
|
+
cell.editing = false;
|
|
130
|
+
// Update DOM directly to show rendered markdown without a full re-render
|
|
131
|
+
var inputEl = document.querySelector('[data-cell-input="' + activeNotebookCellIdx + '"]');
|
|
132
|
+
if (inputEl) {
|
|
133
|
+
inputEl.innerHTML = '<div class="file-rendered">' + renderMarkdown(cell.source) + '</div>';
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
activeNotebookCellMonaco.dispose();
|
|
139
|
+
activeNotebookCellMonaco = null;
|
|
140
|
+
activeNotebookCellIdx = null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function createMonacoEditor(container, options) {
|
|
145
|
+
return monaco.editor.create(container, {
|
|
146
|
+
theme: currentMonacoTheme(),
|
|
147
|
+
minimap: { enabled: false },
|
|
148
|
+
scrollBeyondLastLine: false,
|
|
149
|
+
automaticLayout: true,
|
|
150
|
+
fontSize: 13,
|
|
151
|
+
fontFamily: "'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace",
|
|
152
|
+
lineHeight: 20,
|
|
153
|
+
renderLineHighlight: 'line',
|
|
154
|
+
scrollbar: { verticalScrollbarSize: 5, horizontalScrollbarSize: 5 },
|
|
155
|
+
overviewRulerLanes: 0,
|
|
156
|
+
hideCursorInOverviewRuler: true,
|
|
157
|
+
overviewRulerBorder: false,
|
|
158
|
+
padding: { top: 8, bottom: 8 },
|
|
159
|
+
quickSuggestions: true,
|
|
160
|
+
parameterHints: { enabled: true },
|
|
161
|
+
gotoLocation: { multiple: 'peek', multipleDefinitions: 'peek', multipleReferences: 'peek' },
|
|
162
|
+
...options,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════
|
|
2
|
+
// Notebook Walkthrough Panel
|
|
3
|
+
// ═══════════════════════════════════════════════════════════════
|
|
4
|
+
// Interactive cell-by-cell notebook walkthrough driven by an agent
|
|
5
|
+
// (Data Scientist, ML Engineer, or Syn). The agent owns the kernel
|
|
6
|
+
// and the .ipynb file on disk; this panel renders the current state
|
|
7
|
+
// from a watched JSON file (.shards/notebook-walkthrough.json) and
|
|
8
|
+
// dispatches user actions back to the agent as chat messages prefixed
|
|
9
|
+
// with [NOTEBOOK-WALKTHROUGH].
|
|
10
|
+
//
|
|
11
|
+
// The renderer signature matches the other panel renderers in panels.js:
|
|
12
|
+
// renderNotebookWalkthrough(container, panel)
|
|
13
|
+
// where panel.rawData is the parsed walkthrough state JSON.
|
|
14
|
+
|
|
15
|
+
function cleanupNotebookWalkthrough(panel) {
|
|
16
|
+
// No long-lived editor instances or Plotly charts to dispose.
|
|
17
|
+
// The state is rebuilt from rawData on every render.
|
|
18
|
+
panel._nwState = panel._nwState || {};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function renderNotebookWalkthrough(container, panel) {
|
|
22
|
+
var d = panel.rawData;
|
|
23
|
+
if (!d) {
|
|
24
|
+
container.innerHTML = '<div class="nw-empty">No walkthrough data yet. The agent will push state once the kernel is started.</div>';
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Preserve view-only state (e.g. which cell is expanded for editing) across
|
|
29
|
+
// re-renders. The agent owns the source-of-truth state JSON.
|
|
30
|
+
panel._nwState = panel._nwState || { editingCellIdx: null, editBuffer: '' };
|
|
31
|
+
var view = panel._nwState;
|
|
32
|
+
var pid = panel.panelId;
|
|
33
|
+
|
|
34
|
+
var cells = (d.cells || []);
|
|
35
|
+
var current = (typeof d.currentCellIndex === 'number') ? d.currentCellIndex : 0;
|
|
36
|
+
|
|
37
|
+
// ── Scroll preservation ──
|
|
38
|
+
// The whole container's innerHTML is rewritten on every state update, so the
|
|
39
|
+
// inner .nw-cells scroll position resets to 0. Capture it before rebuilding
|
|
40
|
+
// and restore it after — unless the current cell index changed (Next cell,
|
|
41
|
+
// jump, etc.), in which case scroll the new current cell into view.
|
|
42
|
+
var prevScrollTop = 0;
|
|
43
|
+
var prevCellsEl = container.querySelector('.nw-cells');
|
|
44
|
+
if (prevCellsEl) prevScrollTop = prevCellsEl.scrollTop;
|
|
45
|
+
var prevCurrent = (typeof view.lastRenderedCurrentIndex === 'number')
|
|
46
|
+
? view.lastRenderedCurrentIndex : null;
|
|
47
|
+
var indexChanged = prevCurrent !== null && prevCurrent !== current;
|
|
48
|
+
var status = d.status || 'ready';
|
|
49
|
+
var nbPath = d.notebookPath || '';
|
|
50
|
+
var nbBaseName = nbPath ? nbPath.split('/').pop() : '(no notebook)';
|
|
51
|
+
var staleCount = 0;
|
|
52
|
+
for (var ci = 0; ci < cells.length; ci++) { if (cells[ci] && cells[ci].stale) staleCount++; }
|
|
53
|
+
|
|
54
|
+
var html = '<div class="notebook-walkthrough" data-panel-id="' + esc(pid) + '">';
|
|
55
|
+
|
|
56
|
+
// ── Status strip ──
|
|
57
|
+
html += '<div class="nw-status-strip">';
|
|
58
|
+
html += '<div class="nw-strip-left">';
|
|
59
|
+
html += '<span class="nw-nb-name" title="' + esc(nbPath) + '">' + esc(nbBaseName) + '</span>';
|
|
60
|
+
html += '<span class="nw-cell-counter">Cell ' + (current + 1) + ' / ' + cells.length + '</span>';
|
|
61
|
+
html += '<span class="nw-status-badge nw-status-' + esc(status) + '">' + esc(status) + '</span>';
|
|
62
|
+
if (staleCount > 0) {
|
|
63
|
+
html += '<span class="nw-stale-count" title="' + staleCount + ' cell(s) are stale (ancestors changed)">' + staleCount + ' stale</span>';
|
|
64
|
+
}
|
|
65
|
+
html += '</div>';
|
|
66
|
+
html += '<div class="nw-strip-right">';
|
|
67
|
+
html += '<button class="nw-strip-btn" data-nw-action="send-command" data-nw-command="Restart kernel" title="Restart kernel">Restart</button>';
|
|
68
|
+
html += '<button class="nw-strip-btn" data-nw-action="send-command" data-nw-command="Restart & run all" title="Restart the kernel and run every cell top-to-bottom (reproducibility check)">Run All</button>';
|
|
69
|
+
html += '<button class="nw-strip-btn" data-nw-action="send-command" data-nw-command="End walkthrough" title="End walkthrough">End</button>';
|
|
70
|
+
html += '</div>';
|
|
71
|
+
html += '</div>';
|
|
72
|
+
|
|
73
|
+
// ── Cells ──
|
|
74
|
+
html += '<div class="nw-cells">';
|
|
75
|
+
for (var i = 0; i < cells.length; i++) {
|
|
76
|
+
var c = cells[i] || {};
|
|
77
|
+
var rawCell = (d.notebookCells && d.notebookCells[i]) ? d.notebookCells[i] : null;
|
|
78
|
+
html += renderWalkthroughCell(pid, i, c, rawCell, current, view);
|
|
79
|
+
}
|
|
80
|
+
html += '</div>';
|
|
81
|
+
|
|
82
|
+
// ── Empty notebook fallback ──
|
|
83
|
+
if (cells.length === 0) {
|
|
84
|
+
html += '<div class="nw-empty">Notebook has no cells.</div>';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
html += '</div>';
|
|
88
|
+
container.innerHTML = html;
|
|
89
|
+
|
|
90
|
+
// Wire up button click handlers (replaces inline onclicks so that pids or
|
|
91
|
+
// commands containing apostrophes don't break the HTML attribute parser).
|
|
92
|
+
container.querySelectorAll('[data-nw-action]').forEach(function(el) {
|
|
93
|
+
el.addEventListener('click', function(ev) {
|
|
94
|
+
var action = el.getAttribute('data-nw-action');
|
|
95
|
+
if (action === 'send-command') {
|
|
96
|
+
nwSendCommand(pid, el.getAttribute('data-nw-command'));
|
|
97
|
+
} else if (action === 'prompt-question') {
|
|
98
|
+
nwPromptQuestion(pid, parseInt(el.getAttribute('data-cell-idx'), 10));
|
|
99
|
+
} else if (action === 'prompt-insert') {
|
|
100
|
+
nwPromptInsert(pid, parseInt(el.getAttribute('data-cell-idx'), 10));
|
|
101
|
+
} else if (action === 'confirm-delete') {
|
|
102
|
+
nwConfirmDelete(pid, parseInt(el.getAttribute('data-cell-idx'), 10));
|
|
103
|
+
} else if (action === 'toggle-edit') {
|
|
104
|
+
nwToggleEdit(pid, parseInt(el.getAttribute('data-cell-idx'), 10));
|
|
105
|
+
} else if (action === 'apply-edit') {
|
|
106
|
+
nwApplyEdit(pid, parseInt(el.getAttribute('data-cell-idx'), 10));
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// ── Restore scroll / focus the current cell ──
|
|
112
|
+
var newCellsEl = container.querySelector('.nw-cells');
|
|
113
|
+
if (newCellsEl) {
|
|
114
|
+
if (indexChanged) {
|
|
115
|
+
var target = newCellsEl.querySelector('[data-cell-idx="' + current + '"]');
|
|
116
|
+
if (target) {
|
|
117
|
+
// scrollIntoView is relative to the nearest scrollable ancestor —
|
|
118
|
+
// .nw-cells. Center the cell so the user sees it and a bit of context
|
|
119
|
+
// above and below.
|
|
120
|
+
try {
|
|
121
|
+
target.scrollIntoView({ block: 'center', behavior: 'auto' });
|
|
122
|
+
} catch (e) {
|
|
123
|
+
// Older browsers: fallback to math.
|
|
124
|
+
var rect = target.getBoundingClientRect();
|
|
125
|
+
var parentRect = newCellsEl.getBoundingClientRect();
|
|
126
|
+
newCellsEl.scrollTop += (rect.top - parentRect.top) - (parentRect.height - rect.height) / 2;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
newCellsEl.scrollTop = prevScrollTop;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
view.lastRenderedCurrentIndex = current;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function renderWalkthroughCell(pid, idx, cellState, rawCell, current, view) {
|
|
137
|
+
var isCurrent = idx === current;
|
|
138
|
+
var isEditing = view && view.editingCellIdx === idx;
|
|
139
|
+
var stale = !!cellState.stale;
|
|
140
|
+
var executed = !!cellState.executed;
|
|
141
|
+
var cellType = cellState.type || (rawCell ? rawCell.cell_type : 'code');
|
|
142
|
+
var cls = 'nw-cell';
|
|
143
|
+
if (isCurrent) cls += ' nw-cell-current';
|
|
144
|
+
if (stale) cls += ' nw-cell-stale';
|
|
145
|
+
if (executed) cls += ' nw-cell-executed';
|
|
146
|
+
|
|
147
|
+
var html = '<div class="' + cls + '" data-cell-idx="' + idx + '">';
|
|
148
|
+
|
|
149
|
+
// Header strip per cell (index + type + status badges + action row)
|
|
150
|
+
html += '<div class="nw-cell-header">';
|
|
151
|
+
html += '<span class="nw-cell-idx">[' + idx + ']</span>';
|
|
152
|
+
html += '<span class="nw-cell-type ' + esc(cellType) + '">' + esc(cellType) + '</span>';
|
|
153
|
+
if (executed && !stale) html += '<span class="nw-cell-flag nw-flag-ok">ran</span>';
|
|
154
|
+
if (stale) html += '<span class="nw-cell-flag nw-flag-stale">stale</span>';
|
|
155
|
+
if (isCurrent) html += '<span class="nw-cell-flag nw-flag-current">current</span>';
|
|
156
|
+
|
|
157
|
+
// Action row
|
|
158
|
+
html += '<div class="nw-cell-actions">';
|
|
159
|
+
if (cellType === 'code') {
|
|
160
|
+
html += '<button class="nw-act-btn nw-act-run" data-nw-action="send-command" data-nw-command="Run cell ' + idx + '" title="Run cell">Run</button>';
|
|
161
|
+
}
|
|
162
|
+
html += '<button class="nw-act-btn" data-nw-action="send-command" data-nw-command="Re-explain cell ' + idx + '" title="Ask agent to re-explain">Explain</button>';
|
|
163
|
+
html += '<button class="nw-act-btn" data-nw-action="prompt-question" data-cell-idx="' + idx + '" title="Ask a question about this cell">Ask</button>';
|
|
164
|
+
if (cellType === 'code') {
|
|
165
|
+
html += '<button class="nw-act-btn" data-nw-action="toggle-edit" data-cell-idx="' + idx + '" title="Edit cell source">' + (isEditing ? 'Cancel' : 'Edit') + '</button>';
|
|
166
|
+
}
|
|
167
|
+
html += '<button class="nw-act-btn" data-nw-action="prompt-insert" data-cell-idx="' + idx + '" title="Insert a new cell after this one">Insert</button>';
|
|
168
|
+
html += '<button class="nw-act-btn nw-act-delete" data-nw-action="confirm-delete" data-cell-idx="' + idx + '" title="Delete this cell">Delete</button>';
|
|
169
|
+
if (stale) {
|
|
170
|
+
html += '<button class="nw-act-btn nw-act-rerun" data-nw-action="send-command" data-nw-command="Re-run from cell ' + idx + '" title="Re-run this cell and all downstream stale cells">Re-run from here</button>';
|
|
171
|
+
}
|
|
172
|
+
html += '</div>';
|
|
173
|
+
html += '</div>';
|
|
174
|
+
|
|
175
|
+
// Body — code/markdown source + outputs (or Monaco editor in edit mode)
|
|
176
|
+
html += '<div class="nw-cell-body">';
|
|
177
|
+
if (isEditing) {
|
|
178
|
+
var src = (rawCell && (Array.isArray(rawCell.source) ? rawCell.source.join('') : rawCell.source)) || '';
|
|
179
|
+
html += '<textarea class="nw-edit-textarea" id="nw-edit-' + esc(pid) + '-' + idx + '">' + esc(src) + '</textarea>';
|
|
180
|
+
html += '<div class="nw-edit-actions">';
|
|
181
|
+
html += '<button class="nw-act-btn nw-act-primary" data-nw-action="apply-edit" data-cell-idx="' + idx + '">Apply & Re-run</button>';
|
|
182
|
+
html += '<button class="nw-act-btn" data-nw-action="toggle-edit" data-cell-idx="' + idx + '">Cancel</button>';
|
|
183
|
+
html += '</div>';
|
|
184
|
+
} else if (rawCell && typeof renderStaticCellHtml === 'function') {
|
|
185
|
+
var staticCell = {
|
|
186
|
+
cell_type: rawCell.cell_type || cellType,
|
|
187
|
+
source: Array.isArray(rawCell.source) ? rawCell.source.join('') : (rawCell.source || ''),
|
|
188
|
+
outputs: rawCell.outputs || [],
|
|
189
|
+
};
|
|
190
|
+
html += renderStaticCellHtml(staticCell);
|
|
191
|
+
} else {
|
|
192
|
+
html += '<div class="nw-cell-no-source">(source unavailable — agent has not yet pushed cell snapshots)</div>';
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Last explanation/output summary if present
|
|
196
|
+
if (cellState.outputSummary) {
|
|
197
|
+
html += '<div class="nw-output-summary"><strong>Last result:</strong> ' + esc(cellState.outputSummary) + '</div>';
|
|
198
|
+
}
|
|
199
|
+
if (cellState.explanation) {
|
|
200
|
+
html += '<div class="nw-explanation"><strong>Explanation:</strong> ' + esc(cellState.explanation) + '</div>';
|
|
201
|
+
}
|
|
202
|
+
if (cellState.lastRunAt) {
|
|
203
|
+
html += '<div class="nw-last-run">ran ' + esc(cellState.lastRunAt) + '</div>';
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
html += '</div>';
|
|
207
|
+
html += '</div>';
|
|
208
|
+
return html;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// ─── Action dispatchers ──────────────────────────────────────────────────────
|
|
212
|
+
// All actions become chat messages prefixed [NOTEBOOK-WALKTHROUGH] sent via
|
|
213
|
+
// /chat/send to the active session — same pattern as the Prompt Lab.
|
|
214
|
+
|
|
215
|
+
function nwSendCommand(panelId, commandText) {
|
|
216
|
+
var msg = '[NOTEBOOK-WALKTHROUGH] ' + commandText;
|
|
217
|
+
var sessionId = activeSessionId;
|
|
218
|
+
if (typeof authFetch !== 'function') return;
|
|
219
|
+
authFetch('/chat/send', {
|
|
220
|
+
method: 'POST',
|
|
221
|
+
headers: { 'Content-Type': 'application/json' },
|
|
222
|
+
body: JSON.stringify({ message: msg, sessionId: sessionId }),
|
|
223
|
+
}).catch(function() {});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function nwPromptQuestion(panelId, idx) {
|
|
227
|
+
var q = window.prompt('Question about cell ' + idx + ':', '');
|
|
228
|
+
if (!q) return;
|
|
229
|
+
nwSendCommand(panelId, 'Question on cell ' + idx + ': ' + q);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function nwPromptInsert(panelId, idx) {
|
|
233
|
+
var typeAns = window.prompt('Insert what kind of cell after [' + idx + ']? Type "code" or "markdown":', 'code');
|
|
234
|
+
if (!typeAns) return;
|
|
235
|
+
typeAns = String(typeAns).trim().toLowerCase();
|
|
236
|
+
if (typeAns !== 'code' && typeAns !== 'markdown') return;
|
|
237
|
+
var content = window.prompt('Cell content (you can also leave blank and ask the agent to fill it in):', '');
|
|
238
|
+
if (content === null) return;
|
|
239
|
+
// Encode newlines so the chat protocol stays single-line-friendly. Agent
|
|
240
|
+
// will decode \n on receipt.
|
|
241
|
+
var encoded = content.replace(/\r\n?/g, '\n').replace(/\n/g, '\\n');
|
|
242
|
+
nwSendCommand(panelId, 'Insert cell after ' + idx + ' (' + typeAns + '): ' + encoded);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function nwConfirmDelete(panelId, idx) {
|
|
246
|
+
if (!window.confirm('Delete cell ' + idx + '? Downstream cells may go stale.')) return;
|
|
247
|
+
nwSendCommand(panelId, 'Delete cell ' + idx);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function nwToggleEdit(panelId, idx) {
|
|
251
|
+
var p = openPanels[panelId];
|
|
252
|
+
if (!p) return;
|
|
253
|
+
p._nwState = p._nwState || { editingCellIdx: null };
|
|
254
|
+
if (p._nwState.editingCellIdx === idx) {
|
|
255
|
+
p._nwState.editingCellIdx = null;
|
|
256
|
+
} else {
|
|
257
|
+
p._nwState.editingCellIdx = idx;
|
|
258
|
+
}
|
|
259
|
+
var container = document.getElementById('file-rendered-view');
|
|
260
|
+
if (container) renderNotebookWalkthrough(container, p);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function nwApplyEdit(panelId, idx) {
|
|
264
|
+
var ta = document.getElementById('nw-edit-' + panelId + '-' + idx);
|
|
265
|
+
if (!ta) return;
|
|
266
|
+
var newSrc = ta.value || '';
|
|
267
|
+
var encoded = newSrc.replace(/\r\n?/g, '\n').replace(/\n/g, '\\n');
|
|
268
|
+
// Reset edit-mode view state before re-render
|
|
269
|
+
var p = openPanels[panelId];
|
|
270
|
+
if (p && p._nwState) p._nwState.editingCellIdx = null;
|
|
271
|
+
nwSendCommand(panelId, 'Edit cell ' + idx + ': ' + encoded);
|
|
272
|
+
}
|