@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,591 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════════════════════════
|
|
2
|
+
// SSE connection
|
|
3
|
+
// ═══════════════════════════════════════════════════════════════
|
|
4
|
+
|
|
5
|
+
function isChatEvent(type) {
|
|
6
|
+
return type && (type.indexOf('chat-') === 0 || type === 'agent-consulting' || type === 'permission-request' || type === 'permission-resolved');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// R2/R3 — small helpers for deriving tab subline + timeline entries.
|
|
10
|
+
function basenameOf(p) {
|
|
11
|
+
if (!p) return '';
|
|
12
|
+
var s = String(p).replace(/\\/g, '/');
|
|
13
|
+
var i = s.lastIndexOf('/');
|
|
14
|
+
return i >= 0 ? s.slice(i + 1) : s;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function setSessionSignal(session, kind, label) {
|
|
18
|
+
if (!session) return;
|
|
19
|
+
session.lastSignal = { kind: kind, label: label, ts: Date.now() };
|
|
20
|
+
session.lastActivityAt = Date.now();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Format the streamed tool input into a short, human-readable label for the
|
|
24
|
+
// activity timeline + tab subline. Returns just the tool name when the input
|
|
25
|
+
// is missing or has no useful field for that tool.
|
|
26
|
+
function formatToolDetail(name, input) {
|
|
27
|
+
if (!name) return 'tool';
|
|
28
|
+
if (!input || typeof input !== 'object') return name;
|
|
29
|
+
var detail = '';
|
|
30
|
+
switch (name) {
|
|
31
|
+
case 'Read':
|
|
32
|
+
if (input.file_path) detail = basenameOf(input.file_path);
|
|
33
|
+
break;
|
|
34
|
+
case 'Edit':
|
|
35
|
+
if (input.file_path) detail = basenameOf(input.file_path);
|
|
36
|
+
break;
|
|
37
|
+
case 'Write':
|
|
38
|
+
if (input.file_path) detail = basenameOf(input.file_path);
|
|
39
|
+
break;
|
|
40
|
+
case 'NotebookEdit':
|
|
41
|
+
if (input.notebook_path) detail = basenameOf(input.notebook_path);
|
|
42
|
+
break;
|
|
43
|
+
case 'Bash':
|
|
44
|
+
detail = input.description || (input.command || '').replace(/\s+/g, ' ').slice(0, 60);
|
|
45
|
+
break;
|
|
46
|
+
case 'Grep':
|
|
47
|
+
if (input.pattern) {
|
|
48
|
+
detail = '"' + String(input.pattern).slice(0, 40) + '"';
|
|
49
|
+
if (input.path) detail += ' in ' + basenameOf(input.path);
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
case 'Glob':
|
|
53
|
+
if (input.pattern) detail = String(input.pattern).slice(0, 60);
|
|
54
|
+
break;
|
|
55
|
+
case 'Task':
|
|
56
|
+
if (input.subagent_type) return 'Consulting ' + input.subagent_type;
|
|
57
|
+
if (input.description) return 'Task: ' + String(input.description).slice(0, 60);
|
|
58
|
+
break;
|
|
59
|
+
case 'WebFetch':
|
|
60
|
+
if (input.url) {
|
|
61
|
+
try { detail = new URL(input.url).hostname; }
|
|
62
|
+
catch (e) { detail = String(input.url).slice(0, 60); }
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
case 'WebSearch':
|
|
66
|
+
if (input.query) detail = '"' + String(input.query).slice(0, 50) + '"';
|
|
67
|
+
break;
|
|
68
|
+
case 'TodoWrite':
|
|
69
|
+
if (Array.isArray(input.todos)) detail = input.todos.length + ' items';
|
|
70
|
+
break;
|
|
71
|
+
default:
|
|
72
|
+
// First string-valued field wins for unknown tools — better than nothing.
|
|
73
|
+
for (var k in input) {
|
|
74
|
+
if (!Object.prototype.hasOwnProperty.call(input, k)) continue;
|
|
75
|
+
if (typeof input[k] === 'string' && input[k]) {
|
|
76
|
+
detail = String(input[k]).slice(0, 60);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return detail ? name + ': ' + detail : name;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Detects "::GATE::" markers in agent messages (the gate fence pattern from
|
|
85
|
+
// CLAUDE.md). Falls back to a softer "phase N gate" heuristic.
|
|
86
|
+
function extractGateLabel(content) {
|
|
87
|
+
if (typeof content !== 'string') return null;
|
|
88
|
+
var m = content.match(/::GATE::[^\n]*?id=([\w-]+)/);
|
|
89
|
+
if (m) return m[1];
|
|
90
|
+
m = content.match(/gate[\s:]+([\w-]+phase[\w-]+)/i);
|
|
91
|
+
if (m) return m[1];
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function handleSSEEvent(e) {
|
|
96
|
+
var data;
|
|
97
|
+
try { data = JSON.parse(e.data); } catch(err) { return; }
|
|
98
|
+
|
|
99
|
+
if (data.type === 'connected') return;
|
|
100
|
+
|
|
101
|
+
if (isChatEvent(data.type)) {
|
|
102
|
+
var session = getSessionState(data.sessionId);
|
|
103
|
+
// For events without sessionId, fall back to active session
|
|
104
|
+
if (!session && !data.sessionId) {
|
|
105
|
+
session = getActiveSession();
|
|
106
|
+
}
|
|
107
|
+
if (!session) {
|
|
108
|
+
// Unknown session — ignore (e.g., chat-ended for already-removed session)
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
var isActive = (session.sessionId === activeSessionId);
|
|
112
|
+
handleChatEventForSession(data, session, isActive);
|
|
113
|
+
} else {
|
|
114
|
+
handleGlobalEvent(data);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function handleGlobalEvent(data) {
|
|
119
|
+
switch (data.type) {
|
|
120
|
+
case 'user-message':
|
|
121
|
+
case 'agent-message':
|
|
122
|
+
case 'agent-activated':
|
|
123
|
+
break;
|
|
124
|
+
|
|
125
|
+
case 'agent-consulting':
|
|
126
|
+
// Handled as chat event via isChatEvent
|
|
127
|
+
break;
|
|
128
|
+
|
|
129
|
+
case 'artifact-updated':
|
|
130
|
+
handleArtifactUpdate(data.path, data.content, data.sessionFile);
|
|
131
|
+
// Also update the file in other sessions' workspaces (state only)
|
|
132
|
+
for (var artSid in chatSessions) {
|
|
133
|
+
if (artSid === activeSessionId) continue;
|
|
134
|
+
var sessFiles = chatSessions[artSid].openFiles;
|
|
135
|
+
if (data.path in sessFiles) {
|
|
136
|
+
var sf = sessFiles[data.path];
|
|
137
|
+
if (!sf.modified && !sf.editMode) {
|
|
138
|
+
sf.content = data.content;
|
|
139
|
+
sf.originalContent = data.content;
|
|
140
|
+
sf.tabularData = null;
|
|
141
|
+
sf.notebookData = null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
|
|
147
|
+
case 'file-touched': {
|
|
148
|
+
// Route to the correct session's touched-files set
|
|
149
|
+
var ftSess = data.sessionId ? getSessionState(data.sessionId) : getActiveSession();
|
|
150
|
+
if (ftSess) {
|
|
151
|
+
ftSess.sessionTouchedFiles.add(data.path);
|
|
152
|
+
var fname = basenameOf(data.path);
|
|
153
|
+
setSessionSignal(ftSess, 'file', fname);
|
|
154
|
+
if (typeof pushTimeline === 'function') pushTimeline(ftSess, 'file', fname, { path: data.path });
|
|
155
|
+
if (typeof renderSessionTabs === 'function') renderSessionTabs();
|
|
156
|
+
if (typeof renderTimeline === 'function') renderTimeline();
|
|
157
|
+
} else {
|
|
158
|
+
sessionTouchedFiles.add(data.path);
|
|
159
|
+
}
|
|
160
|
+
// Only refresh explorer UI when it's the active session's file
|
|
161
|
+
if (!data.sessionId || data.sessionId === activeSessionId) {
|
|
162
|
+
if (explorerViewMode === 'tree') {
|
|
163
|
+
invalidateTreeAncestors(data.path);
|
|
164
|
+
renderTree();
|
|
165
|
+
} else if (currentBrowseDir) browseDir(currentBrowseDir);
|
|
166
|
+
if (typeof renderSessionFiles === 'function') renderSessionFiles();
|
|
167
|
+
}
|
|
168
|
+
// Debounced git status refresh
|
|
169
|
+
if (typeof scheduleGitRefresh === 'function') scheduleGitRefresh();
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// R4 — server detected the project slug for a session (first matching
|
|
174
|
+
// file-touched under analysis/, studies/, services/, etc.)
|
|
175
|
+
case 'session-context': {
|
|
176
|
+
var ctxSess = data.sessionId ? getSessionState(data.sessionId) : null;
|
|
177
|
+
if (ctxSess) {
|
|
178
|
+
ctxSess.projectName = data.projectName || null;
|
|
179
|
+
ctxSess.projectDir = data.projectDir || null;
|
|
180
|
+
if (typeof renderSessionTabs === 'function') renderSessionTabs();
|
|
181
|
+
if (typeof renderTimeline === 'function') renderTimeline();
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// event-log carries low-priority text describing a Bash invocation or
|
|
187
|
+
// persona transfer. We use it only to enrich the timeline; the active
|
|
188
|
+
// session's chat view doesn't need it (tool indicators already render).
|
|
189
|
+
case 'event-log': {
|
|
190
|
+
var elSess = data.sessionId ? getSessionState(data.sessionId) : getActiveSession();
|
|
191
|
+
if (elSess && data.text) {
|
|
192
|
+
// De-dup: if the most recent timeline entry already carries the same
|
|
193
|
+
// (or richer) label from the streamed-input formatter, skip this push.
|
|
194
|
+
// The client-side formatter is the source of truth for tool details.
|
|
195
|
+
var skipDup = false;
|
|
196
|
+
var tl = elSess.timeline;
|
|
197
|
+
if (tl && tl.length) {
|
|
198
|
+
var lastEntry = tl[tl.length - 1];
|
|
199
|
+
if (lastEntry && lastEntry.kind === 'tool' && lastEntry.label) {
|
|
200
|
+
var prefixMatch = data.text.split(':')[0];
|
|
201
|
+
if (prefixMatch && lastEntry.label.indexOf(prefixMatch + ':') === 0) {
|
|
202
|
+
skipDup = true;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (data.text.indexOf('Bash:') === 0 && !skipDup) {
|
|
207
|
+
setSessionSignal(elSess, 'tool', data.text);
|
|
208
|
+
}
|
|
209
|
+
if (!skipDup && typeof pushTimeline === 'function') {
|
|
210
|
+
pushTimeline(elSess, 'log', data.text, null);
|
|
211
|
+
}
|
|
212
|
+
if (typeof renderSessionTabs === 'function') renderSessionTabs();
|
|
213
|
+
if (typeof renderTimeline === 'function') renderTimeline();
|
|
214
|
+
}
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
case 'agent-changed': {
|
|
219
|
+
var acSess = data.sessionId ? getSessionState(data.sessionId) : getActiveSession();
|
|
220
|
+
if (acSess) {
|
|
221
|
+
var changeLabel = (data.from || '?') + ' → ' + (data.to || '?');
|
|
222
|
+
if (typeof pushTimeline === 'function') pushTimeline(acSess, 'agent', changeLabel, { from: data.from, to: data.to });
|
|
223
|
+
if (typeof renderTimeline === 'function') renderTimeline();
|
|
224
|
+
}
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
case 'session-end': {
|
|
229
|
+
// Clear only the ending session's touched-files set
|
|
230
|
+
var seSess = data.sessionId ? getSessionState(data.sessionId) : getActiveSession();
|
|
231
|
+
if (seSess) {
|
|
232
|
+
seSess.sessionTouchedFiles = new Set();
|
|
233
|
+
if (seSess.sessionId === activeSessionId) sessionTouchedFiles = seSess.sessionTouchedFiles;
|
|
234
|
+
} else {
|
|
235
|
+
sessionTouchedFiles.clear();
|
|
236
|
+
}
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// ─── Agent-pushed panel events ────────────────────────────────────
|
|
241
|
+
case 'ui-panel':
|
|
242
|
+
openPanelTab(data.panelId, data);
|
|
243
|
+
break;
|
|
244
|
+
|
|
245
|
+
case 'ui-panel-close':
|
|
246
|
+
if (data.panelId) closePanelTab(data.panelId);
|
|
247
|
+
break;
|
|
248
|
+
|
|
249
|
+
case 'ui-panel-update':
|
|
250
|
+
updatePanelData(data.panelId, data.data);
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function handleChatEventForSession(data, session, isActive) {
|
|
256
|
+
switch (data.type) {
|
|
257
|
+
case 'chat-started':
|
|
258
|
+
if (typeof updateEndChatButton === 'function') updateEndChatButton();
|
|
259
|
+
if (typeof refreshSessions === 'function') refreshSessions();
|
|
260
|
+
break;
|
|
261
|
+
|
|
262
|
+
case 'chat-user-message':
|
|
263
|
+
session.messages.push({
|
|
264
|
+
role: 'user',
|
|
265
|
+
content: data.content,
|
|
266
|
+
agent: data.agent,
|
|
267
|
+
attachments: data.attachments || null,
|
|
268
|
+
});
|
|
269
|
+
// R2 — track responding state for both active and inactive sessions so the
|
|
270
|
+
// tab subline can render "responding…". Was previously inactive-only.
|
|
271
|
+
session.chatResponding = true;
|
|
272
|
+
session.lastActivityAt = Date.now();
|
|
273
|
+
if (isActive) {
|
|
274
|
+
addMessageDirect('user', data.content, data.agent, false, data.attachments);
|
|
275
|
+
setChatInputEnabled(false);
|
|
276
|
+
showThinkingIndicator();
|
|
277
|
+
} else {
|
|
278
|
+
session.domDirty = true;
|
|
279
|
+
}
|
|
280
|
+
if (typeof renderSessionTabs === 'function') renderSessionTabs();
|
|
281
|
+
break;
|
|
282
|
+
|
|
283
|
+
case 'chat-token':
|
|
284
|
+
if (isActive) {
|
|
285
|
+
removeThinkingIndicator();
|
|
286
|
+
ensurePendingBubble();
|
|
287
|
+
appendToken(data.text);
|
|
288
|
+
}
|
|
289
|
+
// Skip token rendering for inactive sessions
|
|
290
|
+
break;
|
|
291
|
+
|
|
292
|
+
case 'chat-tool-use':
|
|
293
|
+
if (isActive) {
|
|
294
|
+
removeThinkingIndicator();
|
|
295
|
+
if (session.pendingBubble && session.tokenBuffer) flushTokens();
|
|
296
|
+
if (data.tool === 'Task') showConsultingIndicator();
|
|
297
|
+
addToolIndicator(data.tool);
|
|
298
|
+
}
|
|
299
|
+
setSessionSignal(session, 'tool', data.tool || 'tool');
|
|
300
|
+
if (typeof pushTimeline === 'function') pushTimeline(session, 'tool', data.tool || 'tool', { id: data.id });
|
|
301
|
+
// Record the call so input-delta / block-stop can finalize the entry
|
|
302
|
+
// with a richer label once the streamed input is complete.
|
|
303
|
+
if (data.id != null && data.index != null) {
|
|
304
|
+
if (!session.pendingToolCalls) session.pendingToolCalls = {};
|
|
305
|
+
session.pendingToolCalls[data.index] = {
|
|
306
|
+
id: data.id,
|
|
307
|
+
name: data.tool || 'tool',
|
|
308
|
+
inputBuffer: '',
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
if (typeof renderSessionTabs === 'function') renderSessionTabs();
|
|
312
|
+
if (typeof renderTimeline === 'function') renderTimeline();
|
|
313
|
+
break;
|
|
314
|
+
|
|
315
|
+
case 'chat-tool-input-delta':
|
|
316
|
+
if (data.index != null && session.pendingToolCalls) {
|
|
317
|
+
var pendingDelta = session.pendingToolCalls[data.index];
|
|
318
|
+
if (pendingDelta && typeof data.partial_json === 'string') {
|
|
319
|
+
pendingDelta.inputBuffer += data.partial_json;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
break;
|
|
323
|
+
|
|
324
|
+
case 'chat-block-stop':
|
|
325
|
+
if (isActive && session.chatResponding && !session.thinkingIndicatorEl && !session.workingIndicatorEl) {
|
|
326
|
+
showThinkingIndicator();
|
|
327
|
+
}
|
|
328
|
+
// If this block was a tool_use we've been buffering, parse the input,
|
|
329
|
+
// format a richer label, and patch the existing timeline entry in place.
|
|
330
|
+
if (data.index != null && session.pendingToolCalls) {
|
|
331
|
+
var pendingStop = session.pendingToolCalls[data.index];
|
|
332
|
+
if (pendingStop) {
|
|
333
|
+
var parsedInput = null;
|
|
334
|
+
try { parsedInput = JSON.parse(pendingStop.inputBuffer || '{}'); }
|
|
335
|
+
catch (_e) { parsedInput = null; }
|
|
336
|
+
var richLabel = formatToolDetail(pendingStop.name, parsedInput || {});
|
|
337
|
+
if (richLabel && richLabel !== pendingStop.name) {
|
|
338
|
+
if (typeof updateToolTimelineEntry === 'function') {
|
|
339
|
+
updateToolTimelineEntry(session, pendingStop.id, { label: richLabel });
|
|
340
|
+
}
|
|
341
|
+
setSessionSignal(session, 'tool', richLabel);
|
|
342
|
+
if (typeof renderSessionTabs === 'function') renderSessionTabs();
|
|
343
|
+
if (typeof renderTimeline === 'function') renderTimeline();
|
|
344
|
+
}
|
|
345
|
+
delete session.pendingToolCalls[data.index];
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
break;
|
|
349
|
+
|
|
350
|
+
case 'chat-message':
|
|
351
|
+
session.messages.push({ role: 'assistant', content: data.content, agent: data.agent });
|
|
352
|
+
// R2/R3 — derive gate signal for both active and inactive sessions
|
|
353
|
+
var gateLabel = extractGateLabel(data.content);
|
|
354
|
+
if (gateLabel) {
|
|
355
|
+
setSessionSignal(session, 'gate', 'gate ' + gateLabel);
|
|
356
|
+
if (typeof pushTimeline === 'function') pushTimeline(session, 'gate', gateLabel, null);
|
|
357
|
+
} else {
|
|
358
|
+
// Note: don't overwrite a tool/file signal with "message" — chat-message
|
|
359
|
+
// fires after every assistant turn and would clobber more useful state.
|
|
360
|
+
session.lastActivityAt = Date.now();
|
|
361
|
+
}
|
|
362
|
+
if (isActive) {
|
|
363
|
+
if (session.pendingBubble) {
|
|
364
|
+
finalizePendingBubble(data.content);
|
|
365
|
+
} else {
|
|
366
|
+
addMessageDirect('assistant', data.content, data.agent);
|
|
367
|
+
}
|
|
368
|
+
} else {
|
|
369
|
+
session.domDirty = true;
|
|
370
|
+
session.unread = true;
|
|
371
|
+
// Check for gate pattern to provide better notification later
|
|
372
|
+
if (typeof isGateMessage === 'function' && isGateMessage(data.content)) {
|
|
373
|
+
session.attentionReason = 'gate';
|
|
374
|
+
}
|
|
375
|
+
renderSessionTabs();
|
|
376
|
+
updateTitleNotification();
|
|
377
|
+
}
|
|
378
|
+
if (typeof renderSessionTabs === 'function') renderSessionTabs();
|
|
379
|
+
if (typeof renderTimeline === 'function') renderTimeline();
|
|
380
|
+
break;
|
|
381
|
+
|
|
382
|
+
case 'chat-usage':
|
|
383
|
+
if (session) {
|
|
384
|
+
session.contextUsage = data.usage || null;
|
|
385
|
+
if (typeof renderHud === 'function') renderHud();
|
|
386
|
+
}
|
|
387
|
+
break;
|
|
388
|
+
|
|
389
|
+
case 'chat-turn-end':
|
|
390
|
+
session.chatResponding = false;
|
|
391
|
+
session.lastActivityAt = Date.now();
|
|
392
|
+
if (data.cost != null) session.totalCost = (session.totalCost || 0) + data.cost;
|
|
393
|
+
if (data.duration != null) session.totalDuration = (session.totalDuration || 0) + data.duration;
|
|
394
|
+
if (typeof renderHud === 'function') renderHud();
|
|
395
|
+
if (typeof renderSessionTabs === 'function') renderSessionTabs();
|
|
396
|
+
if (typeof renderTimeline === 'function') renderTimeline();
|
|
397
|
+
if (isActive) {
|
|
398
|
+
removeThinkingIndicator();
|
|
399
|
+
setChatInputEnabled(true);
|
|
400
|
+
document.getElementById('chat-input').focus();
|
|
401
|
+
// If tab is hidden, still show a notification for the active session
|
|
402
|
+
if (document.visibilityState !== 'visible') {
|
|
403
|
+
var reason = 'Ready for input';
|
|
404
|
+
if (session.messages.length > 0) {
|
|
405
|
+
var last = session.messages[session.messages.length - 1];
|
|
406
|
+
if (last.role === 'assistant' && typeof isGateMessage === 'function' && isGateMessage(last.content)) {
|
|
407
|
+
reason = 'Gate reached';
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
showNotificationToast(session, reason);
|
|
411
|
+
}
|
|
412
|
+
} else {
|
|
413
|
+
session.needsAttention = true;
|
|
414
|
+
var reason = 'Waiting for input';
|
|
415
|
+
if (session.attentionReason === 'gate') {
|
|
416
|
+
reason = 'Gate reached';
|
|
417
|
+
}
|
|
418
|
+
session.attentionReason = 'turn-end';
|
|
419
|
+
renderSessionTabs();
|
|
420
|
+
showNotificationToast(session, reason);
|
|
421
|
+
updateTitleNotification();
|
|
422
|
+
}
|
|
423
|
+
break;
|
|
424
|
+
|
|
425
|
+
case 'chat-init':
|
|
426
|
+
break;
|
|
427
|
+
|
|
428
|
+
case 'chat-error':
|
|
429
|
+
session.chatResponding = false;
|
|
430
|
+
setSessionSignal(session, 'error', data.error || 'error');
|
|
431
|
+
if (typeof pushTimeline === 'function') pushTimeline(session, 'error', data.error || 'error', null);
|
|
432
|
+
if (isActive) {
|
|
433
|
+
removeThinkingIndicator();
|
|
434
|
+
addSystemNotice(data.error || 'An error occurred');
|
|
435
|
+
setChatInputEnabled(true);
|
|
436
|
+
} else {
|
|
437
|
+
session.needsAttention = true;
|
|
438
|
+
session.attentionReason = 'error';
|
|
439
|
+
session.domDirty = true;
|
|
440
|
+
renderSessionTabs();
|
|
441
|
+
showNotificationToast(session, 'Error occurred');
|
|
442
|
+
updateTitleNotification();
|
|
443
|
+
}
|
|
444
|
+
if (typeof renderSessionTabs === 'function') renderSessionTabs();
|
|
445
|
+
if (typeof renderTimeline === 'function') renderTimeline();
|
|
446
|
+
break;
|
|
447
|
+
|
|
448
|
+
case 'chat-stderr': {
|
|
449
|
+
if (!isActive) break;
|
|
450
|
+
var txt = (data.text || '').toLowerCase();
|
|
451
|
+
var authPhrases = ['not logged in', 'authentication required', 'invalid api key', 'api key expired', 'please login', 'please log in', 'run claude login', 'unauthorized', 'auth token'];
|
|
452
|
+
var isAuth = false;
|
|
453
|
+
for (var ap = 0; ap < authPhrases.length; ap++) {
|
|
454
|
+
if (txt.includes(authPhrases[ap])) { isAuth = true; break; }
|
|
455
|
+
}
|
|
456
|
+
if (isAuth) {
|
|
457
|
+
addSystemNotice('Claude CLI auth error: ' + (data.text || 'unknown') + '\n\nRun "claude login" in your terminal, then try again.');
|
|
458
|
+
}
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
case 'chat-agent-switching':
|
|
463
|
+
session.chatTransitioning = true;
|
|
464
|
+
if (isActive) {
|
|
465
|
+
// Reset streaming state
|
|
466
|
+
session.pendingBubble = null;
|
|
467
|
+
session.tokenBuffer = '';
|
|
468
|
+
session.messages = [];
|
|
469
|
+
session._promptSnippet = null;
|
|
470
|
+
session.hasMessages = false;
|
|
471
|
+
document.getElementById('messages').innerHTML = '';
|
|
472
|
+
addSystemNotice('Switching to ' + (AGENTS[data.to] ? AGENTS[data.to].label : data.to) + '...');
|
|
473
|
+
session.agent = data.to;
|
|
474
|
+
activateAgent(data.to);
|
|
475
|
+
setChatInputEnabled(false);
|
|
476
|
+
renderSessionTabs();
|
|
477
|
+
} else {
|
|
478
|
+
session.messages = [];
|
|
479
|
+
session._promptSnippet = null;
|
|
480
|
+
session.agent = data.to;
|
|
481
|
+
session.domDirty = true;
|
|
482
|
+
}
|
|
483
|
+
break;
|
|
484
|
+
|
|
485
|
+
case 'chat-system-notice':
|
|
486
|
+
if (isActive) {
|
|
487
|
+
addSystemNotice(data.text);
|
|
488
|
+
}
|
|
489
|
+
break;
|
|
490
|
+
|
|
491
|
+
case 'chat-clear-messages':
|
|
492
|
+
session.messages = [];
|
|
493
|
+
session._promptSnippet = null;
|
|
494
|
+
if (isActive) {
|
|
495
|
+
document.getElementById('messages').innerHTML = '';
|
|
496
|
+
session.hasMessages = false;
|
|
497
|
+
} else {
|
|
498
|
+
session.domDirty = true;
|
|
499
|
+
}
|
|
500
|
+
break;
|
|
501
|
+
|
|
502
|
+
case 'chat-ended':
|
|
503
|
+
// Ignore chat-ended during compact or agent switch
|
|
504
|
+
if (session.chatTransitioning) {
|
|
505
|
+
session.chatTransitioning = false;
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
508
|
+
if (typeof pushTimeline === 'function') pushTimeline(session, 'end', 'session ended', null);
|
|
509
|
+
if (data.code && data.code !== 0 && isActive) {
|
|
510
|
+
addSystemNotice('Session ended unexpectedly (exit code ' + data.code + '). If Claude CLI is not logged in, run "claude login" in your terminal.');
|
|
511
|
+
}
|
|
512
|
+
if (typeof renderTimeline === 'function') renderTimeline();
|
|
513
|
+
endSessionTab(session.sessionId);
|
|
514
|
+
if (typeof updateEndChatButton === 'function') updateEndChatButton();
|
|
515
|
+
if (typeof refreshSessions === 'function') refreshSessions();
|
|
516
|
+
break;
|
|
517
|
+
|
|
518
|
+
case 'agent-consulting':
|
|
519
|
+
if (isActive) {
|
|
520
|
+
updateConsultingIndicator(data.agent);
|
|
521
|
+
}
|
|
522
|
+
setSessionSignal(session, 'consult', data.agent || 'subagent');
|
|
523
|
+
if (typeof pushTimeline === 'function') pushTimeline(session, 'consult', data.agent || 'subagent', null);
|
|
524
|
+
if (typeof renderSessionTabs === 'function') renderSessionTabs();
|
|
525
|
+
if (typeof renderTimeline === 'function') renderTimeline();
|
|
526
|
+
break;
|
|
527
|
+
|
|
528
|
+
case 'permission-request':
|
|
529
|
+
if (isActive) {
|
|
530
|
+
renderPermissionCard(data.id, data.tool, data.command, data.sessionId);
|
|
531
|
+
// Also notify if tab hidden
|
|
532
|
+
if (document.visibilityState !== 'visible') {
|
|
533
|
+
showNotificationToast(session, 'Permission required');
|
|
534
|
+
}
|
|
535
|
+
} else {
|
|
536
|
+
session.pendingPermissions.push({
|
|
537
|
+
id: data.id,
|
|
538
|
+
tool: data.tool,
|
|
539
|
+
command: data.command,
|
|
540
|
+
sessionId: data.sessionId
|
|
541
|
+
});
|
|
542
|
+
session.needsAttention = true;
|
|
543
|
+
session.attentionReason = 'permission';
|
|
544
|
+
renderSessionTabs();
|
|
545
|
+
showNotificationToast(session, 'Permission required');
|
|
546
|
+
updateTitleNotification();
|
|
547
|
+
}
|
|
548
|
+
break;
|
|
549
|
+
|
|
550
|
+
case 'permission-resolved':
|
|
551
|
+
if (isActive) {
|
|
552
|
+
resolvePermissionCard(data.id, data.decision);
|
|
553
|
+
} else {
|
|
554
|
+
// Remove from pending queue (resolved externally, e.g. via CLI)
|
|
555
|
+
var pq = session.pendingPermissions;
|
|
556
|
+
for (var pi = pq.length - 1; pi >= 0; pi--) {
|
|
557
|
+
if (pq[pi].id === data.id) {
|
|
558
|
+
pq.splice(pi, 1);
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
if (pq.length === 0 && session.chatResponding) {
|
|
563
|
+
session.needsAttention = false;
|
|
564
|
+
session.attentionReason = null;
|
|
565
|
+
renderSessionTabs();
|
|
566
|
+
updateTitleNotification();
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function connect() {
|
|
574
|
+
var indicator = document.getElementById('conn-indicator');
|
|
575
|
+
var text = document.getElementById('conn-text');
|
|
576
|
+
// P1: Include auth token as query param (EventSource can't set headers)
|
|
577
|
+
var sseUrl = '/events?token=' + encodeURIComponent(SHARDS_TOKEN);
|
|
578
|
+
var es = new EventSource(sseUrl);
|
|
579
|
+
|
|
580
|
+
es.onopen = function() {
|
|
581
|
+
indicator.className = 'conn-indicator connected';
|
|
582
|
+
text.textContent = 'Connected';
|
|
583
|
+
};
|
|
584
|
+
es.onmessage = handleSSEEvent;
|
|
585
|
+
es.onerror = function() {
|
|
586
|
+
indicator.className = 'conn-indicator disconnected';
|
|
587
|
+
text.textContent = 'Reconnecting...';
|
|
588
|
+
es.close();
|
|
589
|
+
setTimeout(connect, 3000);
|
|
590
|
+
};
|
|
591
|
+
}
|