@monoes/monomindcli 2.16.1 → 2.16.3
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/.claude/agents/architecture/system-design/arch-system-design.md +4 -1
- package/.claude/agents/consensus/quorum-manager.md +3 -0
- package/.claude/agents/consensus/security-manager.md +4 -1
- package/.claude/agents/core/coder.md +4 -1
- package/.claude/agents/core/coordinator.md +3 -0
- package/.claude/agents/core/planner.md +4 -1
- package/.claude/agents/core/researcher.md +4 -1
- package/.claude/agents/core/reviewer.md +4 -1
- package/.claude/agents/core/tester.md +4 -1
- package/.claude/agents/design/design-monodesign.md +4 -1
- package/.claude/agents/engineering/engineering-ai-data-remediation-engineer.md +4 -1
- package/.claude/agents/engineering/engineering-ai-engineer.md +4 -1
- package/.claude/agents/engineering/engineering-autonomous-optimization-architect.md +3 -0
- package/.claude/agents/engineering/engineering-backend-architect.md +4 -1
- package/.claude/agents/engineering/engineering-code-reviewer.md +5 -0
- package/.claude/agents/engineering/engineering-data-engineer.md +4 -1
- package/.claude/agents/engineering/engineering-database-optimizer.md +4 -1
- package/.claude/agents/engineering/engineering-devops-automator.md +3 -0
- package/.claude/agents/engineering/engineering-embedded-firmware-engineer.md +3 -0
- package/.claude/agents/engineering/engineering-feishu-integration-developer.md +4 -1
- package/.claude/agents/engineering/engineering-frontend-developer.md +3 -0
- package/.claude/agents/engineering/engineering-git-workflow-master.md +4 -1
- package/.claude/agents/engineering/engineering-incident-response-commander.md +4 -1
- package/.claude/agents/engineering/engineering-mobile-app-builder.md +3 -0
- package/.claude/agents/engineering/engineering-rapid-prototyper.md +3 -0
- package/.claude/agents/engineering/engineering-security-engineer.md +4 -1
- package/.claude/agents/engineering/engineering-senior-developer.md +3 -0
- package/.claude/agents/engineering/engineering-software-architect.md +4 -1
- package/.claude/agents/engineering/engineering-solidity-smart-contract-engineer.md +4 -1
- package/.claude/agents/engineering/engineering-sre.md +3 -0
- package/.claude/agents/engineering/engineering-technical-writer.md +4 -1
- package/.claude/agents/engineering/engineering-threat-detection-engineer.md +4 -1
- package/.claude/agents/engineering/engineering-wechat-mini-program-developer.md +4 -1
- package/.claude/agents/github/github-modes.md +4 -2
- package/.claude/agents/github/issue-tracker.md +4 -2
- package/.claude/agents/github/monoswarm-code-review.md +4 -2
- package/.claude/agents/github/monoswarm-issue.md +5 -0
- package/.claude/agents/github/monoswarm-multi-repo.md +4 -1
- package/.claude/agents/github/monoswarm-pr.md +5 -0
- package/.claude/agents/github/pr-manager.md +4 -2
- package/.claude/agents/github/project-board-sync.md +4 -2
- package/.claude/agents/github/release-manager.md +4 -2
- package/.claude/agents/github/repo-architect.md +4 -2
- package/.claude/agents/github/sync-coordinator.md +4 -2
- package/.claude/agents/github/workflow-automation.md +4 -2
- package/.claude/agents/goal/goal-planner.md +16 -2
- package/.claude/agents/marketing/marketing-competitive-content.md +4 -1
- package/.claude/agents/marketing/marketing-cro-specialist.md +4 -1
- package/.claude/agents/marketing/marketing-email-specialist.md +4 -1
- package/.claude/agents/marketing/marketing-launch-strategist.md +4 -1
- package/.claude/agents/marketing/marketing-pricing-strategist.md +4 -1
- package/.claude/agents/monoswarm/collective-intelligence-coordinator.md +3 -0
- package/.claude/agents/monoswarm/mesh-coordinator.md +3 -0
- package/.claude/agents/monoswarm/monoswarm-memory-manager.md +4 -2
- package/.claude/agents/monoswarm/scout-explorer.md +4 -2
- package/.claude/agents/monoswarm/worker-specialist.md +3 -0
- package/.claude/agents/optimization/benchmark-suite.md +3 -0
- package/.claude/agents/optimization/load-balancer.md +3 -0
- package/.claude/agents/optimization/performance-monitor.md +3 -0
- package/.claude/agents/optimization/resource-allocator.md +3 -0
- package/.claude/agents/optimization/topology-optimizer.md +3 -0
- package/.claude/agents/specialists/integration-architect.md +4 -2
- package/.claude/agents/specialized/agentic-identity-trust.md +4 -1
- package/.claude/agents/specialized/agents-orchestrator.md +3 -0
- package/.claude/agents/specialized/automation-governance-architect.md +3 -0
- package/.claude/agents/specialized/blockchain-security-auditor.md +4 -1
- package/.claude/agents/specialized/compliance-auditor.md +4 -1
- package/.claude/agents/specialized/identity-graph-operator.md +4 -1
- package/.claude/agents/specialized/lsp-index-engineer.md +3 -0
- package/.claude/agents/specialized/mobile/spec-mobile-react-native.md +5 -0
- package/.claude/agents/specialized/specialized-cultural-intelligence-strategist.md +3 -0
- package/.claude/agents/specialized/specialized-developer-advocate.md +4 -1
- package/.claude/agents/specialized/specialized-document-generator.md +4 -1
- package/.claude/agents/specialized/specialized-mcp-builder.md +3 -0
- package/.claude/agents/specialized/specialized-model-qa.md +4 -1
- package/.claude/agents/specialized/specialized-workflow-architect.md +4 -1
- package/.claude/agents/specialized/zk-steward.md +4 -1
- package/.claude/agents/templates/automation-smart-agent.md +4 -1
- package/.claude/agents/templates/coordinator-monoswarm-init.md +4 -1
- package/.claude/agents/testing/production-validator.md +3 -0
- package/.claude/agents/testing/tdd-london-monoswarm.md +3 -0
- package/.claude/agents/testing/testing-accessibility-auditor.md +4 -1
- package/.claude/agents/testing/testing-api-tester.md +4 -1
- package/.claude/agents/testing/testing-evidence-collector.md +3 -0
- package/.claude/agents/testing/testing-performance-benchmarker.md +4 -1
- package/.claude/agents/testing/testing-test-results-analyzer.md +4 -1
- package/.claude/agents/testing/testing-tool-evaluator.md +4 -1
- package/.claude/agents/testing/testing-workflow-optimizer.md +4 -1
- package/.claude/commands/agents/agent-types.md +7 -5
- package/.claude/commands/mastermind/code-review.md +5 -5
- package/.claude/commands/mastermind/content.md +8 -2
- package/.claude/commands/mastermind/createtask.md +2 -2
- package/.claude/commands/mastermind/do.md +18 -36
- package/.claude/commands/mastermind/finance.md +8 -2
- package/.claude/commands/mastermind/ideate.md +4 -4
- package/.claude/commands/mastermind/improve.md +3 -3
- package/.claude/commands/mastermind/marketing.md +8 -2
- package/.claude/commands/mastermind/master.md +63 -45
- package/.claude/commands/mastermind/monoswarm.md +7 -5
- package/.claude/commands/mastermind/ops.md +8 -2
- package/.claude/commands/mastermind/sales.md +8 -2
- package/.claude/commands/mastermind.md +7 -7
- package/.claude/commands/monoswarm/analysis.md +1 -1
- package/.claude/commands/monoswarm/development.md +1 -1
- package/.claude/commands/monoswarm/maintenance.md +1 -1
- package/.claude/commands/monoswarm/optimization.md +2 -1
- package/.claude/commands/monoswarm/research.md +1 -1
- package/.claude/commands/monoswarm/testing.md +1 -1
- package/.claude/commands/pair/examples.md +3 -2
- package/.claude/commands/pair/modes.md +3 -3
- package/.claude/helpers/build-skill-registry.cjs +186 -26
- package/.claude/helpers/handlers/agent-start-handler.cjs +3 -0
- package/.claude/helpers/handlers/capture-handler.cjs +22 -14
- package/.claude/helpers/handlers/edit-handler.cjs +15 -13
- package/.claude/helpers/handlers/pick-core.cjs +445 -0
- package/.claude/helpers/handlers/route-handler.cjs +87 -180
- package/.claude/helpers/handlers/session-handler.cjs +44 -62
- package/.claude/helpers/handlers/session-restore-handler.cjs +5 -1
- package/.claude/helpers/handlers/task-handler.cjs +11 -6
- package/.claude/helpers/hook-handler.cjs +9 -2
- package/.claude/helpers/jev-catalog.cjs +225 -0
- package/.claude/helpers/jev-picker.cjs +36 -147
- package/.claude/helpers/monograph-freshen.cjs +31 -113
- package/.claude/helpers/org-skill-index.cjs +230 -0
- package/.claude/helpers/pick-rank.cjs +221 -0
- package/.claude/helpers/pick-stats.cjs +413 -0
- package/.claude/helpers/router.cjs +7 -379
- package/.claude/helpers/utils/monograph-resolve.cjs +505 -0
- package/.claude/helpers/utils/monograph.cjs +8 -51
- package/.claude/settings.json +51 -41
- package/.claude/skills/hooks-automation/SKILL.md +4 -4
- package/.claude/skills/mastermind-access/SKILL.md +4 -3
- package/.claude/skills/mastermind-activity/SKILL.md +3 -2
- package/.claude/skills/mastermind-adapter-manager/SKILL.md +2 -1
- package/.claude/skills/mastermind-adapters/SKILL.md +2 -1
- package/.claude/skills/mastermind-agent-detail/SKILL.md +5 -4
- package/.claude/skills/mastermind-agent-select/SKILL.md +99 -100
- package/.claude/skills/mastermind-agents/SKILL.md +2 -1
- package/.claude/skills/mastermind-approval-detail/SKILL.md +2 -1
- package/.claude/skills/mastermind-backup/SKILL.md +2 -1
- package/.claude/skills/mastermind-bootstrap/SKILL.md +2 -2
- package/.claude/skills/mastermind-budgets/SKILL.md +4 -3
- package/.claude/skills/mastermind-createorg/SKILL.md +23 -5
- package/.claude/skills/mastermind-delegation/SKILL.md +11 -19
- package/.claude/skills/mastermind-diagnose/SKILL.md +3 -3
- package/.claude/skills/mastermind-env/SKILL.md +2 -1
- package/.claude/skills/mastermind-environments/SKILL.md +2 -1
- package/.claude/skills/mastermind-execute/SKILL.md +1 -1
- package/.claude/skills/mastermind-export/SKILL.md +2 -1
- package/.claude/skills/mastermind-goal-detail/SKILL.md +3 -2
- package/.claude/skills/mastermind-goals/SKILL.md +3 -2
- package/.claude/skills/mastermind-idea/SKILL.md +52 -92
- package/.claude/skills/mastermind-import/SKILL.md +2 -1
- package/.claude/skills/mastermind-inbox/SKILL.md +3 -2
- package/.claude/skills/mastermind-instance/SKILL.md +3 -2
- package/.claude/skills/mastermind-invite-landing/SKILL.md +3 -2
- package/.claude/skills/mastermind-invites/SKILL.md +3 -2
- package/.claude/skills/mastermind-issue-detail/SKILL.md +4 -3
- package/.claude/skills/mastermind-issues/SKILL.md +4 -3
- package/.claude/skills/mastermind-join-queue/SKILL.md +5 -4
- package/.claude/skills/mastermind-liveness/SKILL.md +5 -4
- package/.claude/skills/mastermind-monitor/SKILL.md +15 -15
- package/.claude/skills/mastermind-my-issues/SKILL.md +2 -1
- package/.claude/skills/mastermind-new-agent/SKILL.md +120 -137
- package/.claude/skills/mastermind-org-settings/SKILL.md +6 -5
- package/.claude/skills/mastermind-orgs/SKILL.md +1 -0
- package/.claude/skills/mastermind-orgstatus/SKILL.md +2 -1
- package/.claude/skills/mastermind-plan-to-tasks/SKILL.md +1 -1
- package/.claude/skills/mastermind-plugin-manager/SKILL.md +4 -3
- package/.claude/skills/mastermind-plugin-settings/SKILL.md +5 -4
- package/.claude/skills/mastermind-plugins/SKILL.md +3 -2
- package/.claude/skills/mastermind-profile/SKILL.md +2 -1
- package/.claude/skills/mastermind-protocol/SKILL.md +3 -3
- package/.claude/skills/mastermind-release/SKILL.md +13 -8
- package/.claude/skills/mastermind-research/SKILL.md +10 -8
- package/.claude/skills/mastermind-review/SKILL.md +16 -11
- package/.claude/skills/mastermind-routine-detail/SKILL.md +2 -1
- package/.claude/skills/mastermind-routines/SKILL.md +3 -2
- package/.claude/skills/mastermind-search/SKILL.md +2 -1
- package/.claude/skills/mastermind-secrets/SKILL.md +3 -2
- package/.claude/skills/mastermind-skills/SKILL.md +2 -1
- package/.claude/skills/mastermind-stoporg/SKILL.md +1 -0
- package/.claude/skills/mastermind-tasks/SKILL.md +3 -2
- package/.claude/skills/mastermind-threads/SKILL.md +4 -3
- package/.claude/skills/mastermind-tree-control/SKILL.md +5 -4
- package/.claude/skills/mastermind-workspace-detail/SKILL.md +4 -3
- package/.claude/skills/mastermind-workspaces/SKILL.md +2 -1
- package/.claude/skills/monoswarm/SKILL.md +7 -5
- package/.claude/skills/specialagent/SKILL.md +32 -51
- package/README.md +1 -1
- package/dist/src/agents/registry-builder.d.ts +23 -2
- package/dist/src/agents/registry-builder.d.ts.map +1 -1
- package/dist/src/agents/registry-builder.js +64 -11
- package/dist/src/agents/registry-builder.js.map +1 -1
- package/dist/src/agents/registry-freshness.d.ts +21 -0
- package/dist/src/agents/registry-freshness.d.ts.map +1 -0
- package/dist/src/agents/registry-freshness.js +94 -0
- package/dist/src/agents/registry-freshness.js.map +1 -0
- package/dist/src/commands/agent-lifecycle.d.ts +11 -5
- package/dist/src/commands/agent-lifecycle.d.ts.map +1 -1
- package/dist/src/commands/agent-lifecycle.js +78 -42
- package/dist/src/commands/agent-lifecycle.js.map +1 -1
- package/dist/src/commands/doctor-env-checks.d.ts +18 -3
- package/dist/src/commands/doctor-env-checks.d.ts.map +1 -1
- package/dist/src/commands/doctor-env-checks.js +35 -16
- package/dist/src/commands/doctor-env-checks.js.map +1 -1
- package/dist/src/commands/doctor-fresh-install.d.ts +9 -0
- package/dist/src/commands/doctor-fresh-install.d.ts.map +1 -0
- package/dist/src/commands/doctor-fresh-install.js +43 -0
- package/dist/src/commands/doctor-fresh-install.js.map +1 -0
- package/dist/src/commands/doctor-hook-monograph-checks.d.ts +10 -0
- package/dist/src/commands/doctor-hook-monograph-checks.d.ts.map +1 -0
- package/dist/src/commands/doctor-hook-monograph-checks.js +88 -0
- package/dist/src/commands/doctor-hook-monograph-checks.js.map +1 -0
- package/dist/src/commands/doctor-hook-settings-checks.d.ts +5 -0
- package/dist/src/commands/doctor-hook-settings-checks.d.ts.map +1 -0
- package/dist/src/commands/doctor-hook-settings-checks.js +50 -0
- package/dist/src/commands/doctor-hook-settings-checks.js.map +1 -0
- package/dist/src/commands/doctor-json.d.ts +41 -0
- package/dist/src/commands/doctor-json.d.ts.map +1 -0
- package/dist/src/commands/doctor-json.js +60 -0
- package/dist/src/commands/doctor-json.js.map +1 -0
- package/dist/src/commands/doctor-mode.d.ts +28 -0
- package/dist/src/commands/doctor-mode.d.ts.map +1 -0
- package/dist/src/commands/doctor-mode.js +109 -0
- package/dist/src/commands/doctor-mode.js.map +1 -0
- package/dist/src/commands/doctor-monoes-checks.d.ts.map +1 -1
- package/dist/src/commands/doctor-monoes-checks.js +3 -1
- package/dist/src/commands/doctor-monoes-checks.js.map +1 -1
- package/dist/src/commands/doctor-pick-checks.d.ts +19 -0
- package/dist/src/commands/doctor-pick-checks.d.ts.map +1 -0
- package/dist/src/commands/doctor-pick-checks.js +164 -0
- package/dist/src/commands/doctor-pick-checks.js.map +1 -0
- package/dist/src/commands/doctor-project-checks.d.ts +3 -1
- package/dist/src/commands/doctor-project-checks.d.ts.map +1 -1
- package/dist/src/commands/doctor-project-checks.js +67 -20
- package/dist/src/commands/doctor-project-checks.js.map +1 -1
- package/dist/src/commands/doctor.d.ts.map +1 -1
- package/dist/src/commands/doctor.js +325 -333
- package/dist/src/commands/doctor.js.map +1 -1
- package/dist/src/commands/hooks-coverage-routing.js +1 -1
- package/dist/src/commands/hooks-coverage-routing.js.map +1 -1
- package/dist/src/commands/hooks-coverage-utils.js +1 -1
- package/dist/src/commands/hooks-coverage-utils.js.map +1 -1
- package/dist/src/commands/hooks-routing-commands.js +1 -1
- package/dist/src/commands/init-upgrade.d.ts.map +1 -1
- package/dist/src/commands/init-upgrade.js +4 -0
- package/dist/src/commands/init-upgrade.js.map +1 -1
- package/dist/src/commands/monograph.d.ts.map +1 -1
- package/dist/src/commands/monograph.js +16 -1
- package/dist/src/commands/monograph.js.map +1 -1
- package/dist/src/commands/monoswarm.d.ts.map +1 -1
- package/dist/src/commands/monoswarm.js +16 -10
- package/dist/src/commands/monoswarm.js.map +1 -1
- package/dist/src/commands/pick.d.ts.map +1 -1
- package/dist/src/commands/pick.js +66 -16
- package/dist/src/commands/pick.js.map +1 -1
- package/dist/src/commands/route.d.ts +2 -1
- package/dist/src/commands/route.d.ts.map +1 -1
- package/dist/src/commands/route.js +73 -117
- package/dist/src/commands/route.js.map +1 -1
- package/dist/src/decision/catalogs.d.ts +24 -3
- package/dist/src/decision/catalogs.d.ts.map +1 -1
- package/dist/src/decision/catalogs.js +100 -22
- package/dist/src/decision/catalogs.js.map +1 -1
- package/dist/src/decision/jev.d.ts +26 -6
- package/dist/src/decision/jev.d.ts.map +1 -1
- package/dist/src/decision/jev.js +15 -4
- package/dist/src/decision/jev.js.map +1 -1
- package/dist/src/decision/pick-eval.d.ts +67 -0
- package/dist/src/decision/pick-eval.d.ts.map +1 -0
- package/dist/src/decision/pick-eval.js +113 -0
- package/dist/src/decision/pick-eval.js.map +1 -0
- package/dist/src/decision/pick-stats.d.ts +49 -0
- package/dist/src/decision/pick-stats.d.ts.map +1 -0
- package/dist/src/decision/pick-stats.js +68 -0
- package/dist/src/decision/pick-stats.js.map +1 -0
- package/dist/src/decision/picks.d.ts +37 -6
- package/dist/src/decision/picks.d.ts.map +1 -1
- package/dist/src/decision/picks.js +67 -32
- package/dist/src/decision/picks.js.map +1 -1
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +43 -22
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/agent-refresh.d.ts +8 -0
- package/dist/src/init/agent-refresh.d.ts.map +1 -0
- package/dist/src/init/agent-refresh.js +89 -0
- package/dist/src/init/agent-refresh.js.map +1 -0
- package/dist/src/init/claudemd-generator.d.ts.map +1 -1
- package/dist/src/init/claudemd-generator.js +27 -9
- package/dist/src/init/claudemd-generator.js.map +1 -1
- package/dist/src/init/helpers-generator.d.ts +4 -1
- package/dist/src/init/helpers-generator.d.ts.map +1 -1
- package/dist/src/init/helpers-generator.js +84 -55
- package/dist/src/init/helpers-generator.js.map +1 -1
- package/dist/src/init/hook-settings.d.ts +57 -0
- package/dist/src/init/hook-settings.d.ts.map +1 -0
- package/dist/src/init/hook-settings.js +133 -0
- package/dist/src/init/hook-settings.js.map +1 -0
- package/dist/src/init/settings-generator.d.ts.map +1 -1
- package/dist/src/init/settings-generator.js +44 -25
- package/dist/src/init/settings-generator.js.map +1 -1
- package/dist/src/init/shared.d.ts +9 -0
- package/dist/src/init/shared.d.ts.map +1 -1
- package/dist/src/init/shared.js +22 -0
- package/dist/src/init/shared.js.map +1 -1
- package/dist/src/init/upgrade.d.ts +4 -0
- package/dist/src/init/upgrade.d.ts.map +1 -1
- package/dist/src/init/upgrade.js +123 -129
- package/dist/src/init/upgrade.js.map +1 -1
- package/dist/src/init/write-capabilities.d.ts.map +1 -1
- package/dist/src/init/write-capabilities.js +10 -33
- package/dist/src/init/write-capabilities.js.map +1 -1
- package/dist/src/init/write-claude.d.ts.map +1 -1
- package/dist/src/init/write-claude.js +5 -2
- package/dist/src/init/write-claude.js.map +1 -1
- package/dist/src/mcp-client.d.ts.map +1 -1
- package/dist/src/mcp-client.js +4 -0
- package/dist/src/mcp-client.js.map +1 -1
- package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/agent-tools.js +3 -0
- package/dist/src/mcp-tools/agent-tools.js.map +1 -1
- package/dist/src/mcp-tools/guidance-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/guidance-tools.js +19 -10
- package/dist/src/mcp-tools/guidance-tools.js.map +1 -1
- package/dist/src/mcp-tools/hooks-embedding.d.ts +1 -32
- package/dist/src/mcp-tools/hooks-embedding.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-embedding.js +22 -200
- package/dist/src/mcp-tools/hooks-embedding.js.map +1 -1
- package/dist/src/mcp-tools/hooks-routing.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-routing.js +77 -192
- package/dist/src/mcp-tools/hooks-routing.js.map +1 -1
- package/dist/src/mcp-tools/index.d.ts +1 -0
- package/dist/src/mcp-tools/index.d.ts.map +1 -1
- package/dist/src/mcp-tools/index.js +1 -0
- package/dist/src/mcp-tools/index.js.map +1 -1
- package/dist/src/mcp-tools/org-skill-tools.d.ts +4 -0
- package/dist/src/mcp-tools/org-skill-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/org-skill-tools.js +42 -0
- package/dist/src/mcp-tools/org-skill-tools.js.map +1 -0
- package/dist/src/mcp-tools/pick-tools.d.ts +4 -0
- package/dist/src/mcp-tools/pick-tools.d.ts.map +1 -0
- package/dist/src/mcp-tools/pick-tools.js +53 -0
- package/dist/src/mcp-tools/pick-tools.js.map +1 -0
- package/dist/src/monovector/coverage-router.d.ts +2 -1
- package/dist/src/monovector/coverage-router.d.ts.map +1 -1
- package/dist/src/monovector/coverage-router.js +6 -5
- package/dist/src/monovector/coverage-router.js.map +1 -1
- package/dist/src/monovector/coverage-tools.js +1 -1
- package/dist/src/monovector/coverage-tools.js.map +1 -1
- package/dist/src/monovector/index.d.ts +1 -1
- package/dist/src/monovector/index.d.ts.map +1 -1
- package/dist/src/monovector/index.js +11 -35
- package/dist/src/monovector/index.js.map +1 -1
- package/dist/src/monovector/route-outcomes.d.ts.map +1 -1
- package/dist/src/monovector/route-outcomes.js +89 -34
- package/dist/src/monovector/route-outcomes.js.map +1 -1
- package/dist/src/orgrt/bash-timeout.d.ts +14 -0
- package/dist/src/orgrt/bash-timeout.d.ts.map +1 -0
- package/dist/src/orgrt/bash-timeout.js +18 -0
- package/dist/src/orgrt/bash-timeout.js.map +1 -0
- package/dist/src/orgrt/block-recheck.d.ts +30 -0
- package/dist/src/orgrt/block-recheck.d.ts.map +1 -0
- package/dist/src/orgrt/block-recheck.js +81 -0
- package/dist/src/orgrt/block-recheck.js.map +1 -0
- package/dist/src/orgrt/completion-gate.d.ts +4 -0
- package/dist/src/orgrt/completion-gate.d.ts.map +1 -1
- package/dist/src/orgrt/completion-gate.js +22 -2
- package/dist/src/orgrt/completion-gate.js.map +1 -1
- package/dist/src/orgrt/daemon.d.ts +7 -13
- package/dist/src/orgrt/daemon.d.ts.map +1 -1
- package/dist/src/orgrt/daemon.js +18 -27
- package/dist/src/orgrt/daemon.js.map +1 -1
- package/dist/src/orgrt/decisions.d.ts +4 -9
- package/dist/src/orgrt/decisions.d.ts.map +1 -1
- package/dist/src/orgrt/decisions.js +44 -47
- package/dist/src/orgrt/decisions.js.map +1 -1
- package/dist/src/orgrt/dispatch-hold.d.ts +34 -0
- package/dist/src/orgrt/dispatch-hold.d.ts.map +1 -0
- package/dist/src/orgrt/dispatch-hold.js +75 -0
- package/dist/src/orgrt/dispatch-hold.js.map +1 -0
- package/dist/src/orgrt/mailbox.d.ts +14 -0
- package/dist/src/orgrt/mailbox.d.ts.map +1 -1
- package/dist/src/orgrt/mailbox.js +31 -1
- package/dist/src/orgrt/mailbox.js.map +1 -1
- package/dist/src/orgrt/runner-registry.d.ts +20 -0
- package/dist/src/orgrt/runner-registry.d.ts.map +1 -1
- package/dist/src/orgrt/runner-registry.js +39 -0
- package/dist/src/orgrt/runner-registry.js.map +1 -1
- package/dist/src/orgrt/sandbox-deny-write.d.ts +11 -1
- package/dist/src/orgrt/sandbox-deny-write.d.ts.map +1 -1
- package/dist/src/orgrt/sandbox-deny-write.js +23 -2
- package/dist/src/orgrt/sandbox-deny-write.js.map +1 -1
- package/dist/src/orgrt/sandbox-fault.d.ts +21 -7
- package/dist/src/orgrt/sandbox-fault.d.ts.map +1 -1
- package/dist/src/orgrt/sandbox-fault.js +92 -35
- package/dist/src/orgrt/sandbox-fault.js.map +1 -1
- package/dist/src/orgrt/session.d.ts +20 -10
- package/dist/src/orgrt/session.d.ts.map +1 -1
- package/dist/src/orgrt/session.js +60 -72
- package/dist/src/orgrt/session.js.map +1 -1
- package/dist/src/orgrt/skill-library.d.ts +4 -0
- package/dist/src/orgrt/skill-library.d.ts.map +1 -1
- package/dist/src/orgrt/skill-library.js +12 -0
- package/dist/src/orgrt/skill-library.js.map +1 -1
- package/dist/src/orgrt/skill-tools.d.ts +11 -0
- package/dist/src/orgrt/skill-tools.d.ts.map +1 -0
- package/dist/src/orgrt/skill-tools.js +40 -0
- package/dist/src/orgrt/skill-tools.js.map +1 -0
- package/dist/src/orgrt/task-cancel.d.ts +64 -0
- package/dist/src/orgrt/task-cancel.d.ts.map +1 -0
- package/dist/src/orgrt/task-cancel.js +134 -0
- package/dist/src/orgrt/task-cancel.js.map +1 -0
- package/dist/src/orgrt/task-dag.d.ts +18 -3
- package/dist/src/orgrt/task-dag.d.ts.map +1 -1
- package/dist/src/orgrt/task-dag.js +10 -4
- package/dist/src/orgrt/task-dag.js.map +1 -1
- package/dist/src/orgrt/task-match.d.ts +121 -0
- package/dist/src/orgrt/task-match.d.ts.map +1 -0
- package/dist/src/orgrt/task-match.js +241 -0
- package/dist/src/orgrt/task-match.js.map +1 -0
- package/dist/src/orgrt/task-provenance.d.ts +26 -0
- package/dist/src/orgrt/task-provenance.d.ts.map +1 -0
- package/dist/src/orgrt/task-provenance.js +93 -0
- package/dist/src/orgrt/task-provenance.js.map +1 -0
- package/dist/src/orgrt/task-tools.d.ts +24 -0
- package/dist/src/orgrt/task-tools.d.ts.map +1 -0
- package/dist/src/orgrt/task-tools.js +75 -0
- package/dist/src/orgrt/task-tools.js.map +1 -0
- package/dist/src/orgrt/types.d.ts +11 -0
- package/dist/src/orgrt/types.d.ts.map +1 -1
- package/dist/src/orgrt/types.js +18 -0
- package/dist/src/orgrt/types.js.map +1 -1
- package/dist/src/output.d.ts +6 -0
- package/dist/src/output.d.ts.map +1 -1
- package/dist/src/output.js +13 -2
- package/dist/src/output.js.map +1 -1
- package/dist/src/protocol-capabilities.d.ts +8 -1
- package/dist/src/protocol-capabilities.d.ts.map +1 -1
- package/dist/src/protocol-capabilities.js +10 -0
- package/dist/src/protocol-capabilities.js.map +1 -1
- package/dist/src/routing/agent-pick.d.ts +44 -0
- package/dist/src/routing/agent-pick.d.ts.map +1 -0
- package/dist/src/routing/agent-pick.js +114 -0
- package/dist/src/routing/agent-pick.js.map +1 -0
- package/dist/src/routing/pick-step.d.ts +26 -0
- package/dist/src/routing/pick-step.d.ts.map +1 -0
- package/dist/src/routing/pick-step.js +40 -0
- package/dist/src/routing/pick-step.js.map +1 -0
- package/dist/src/routing/route-layer-factory.d.ts.map +1 -1
- package/dist/src/routing/route-layer-factory.js +19 -17
- package/dist/src/routing/route-layer-factory.js.map +1 -1
- package/dist/src/utils/resource-governor.d.ts.map +1 -1
- package/dist/src/utils/resource-governor.js +55 -2
- package/dist/src/utils/resource-governor.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/org-skills/SOURCES.md +6 -6
- package/org-skills/TAGS.md +146 -0
- package/org-skills/ab-testing/SKILL.md +2 -2
- package/org-skills/accessibility-compliance/SKILL.md +2 -2
- package/org-skills/account-strategist/SKILL.md +2 -2
- package/org-skills/accounts-payable/SKILL.md +2 -2
- package/org-skills/ad-creative/SKILL.md +2 -2
- package/org-skills/adaptive-coordinator/SKILL.md +2 -2
- package/org-skills/adaptive-coordinator2/SKILL.md +2 -2
- package/org-skills/advanced-evaluation/SKILL.md +2 -2
- package/org-skills/adversarial-reviewer/SKILL.md +2 -2
- package/org-skills/agent-evaluation/SKILL.md +2 -2
- package/org-skills/agent-memory-systems/SKILL.md +2 -2
- package/org-skills/agent-tool-design/SKILL.md +2 -2
- package/org-skills/agile-product-owner/SKILL.md +2 -2
- package/org-skills/ai-citation/SKILL.md +2 -2
- package/org-skills/ai-engineer/SKILL.md +2 -2
- package/org-skills/ai-seo/SKILL.md +2 -2
- package/org-skills/analytics-reporter/SKILL.md +2 -2
- package/org-skills/analytics-tracking/SKILL.md +2 -2
- package/org-skills/android-clean-architecture/SKILL.md +2 -2
- package/org-skills/angular-architect/SKILL.md +2 -2
- package/org-skills/api-design/SKILL.md +2 -2
- package/org-skills/api-designer/SKILL.md +2 -2
- package/org-skills/api-tester/SKILL.md +2 -2
- package/org-skills/app-store-optimization/SKILL.md +2 -2
- package/org-skills/architecture-decision-records/SKILL.md +2 -2
- package/org-skills/architecture-designer/SKILL.md +2 -2
- package/org-skills/architecture-patterns/SKILL.md +2 -2
- package/org-skills/article-writing/SKILL.md +2 -2
- package/org-skills/auth-implementation-patterns/SKILL.md +2 -2
- package/org-skills/automation-governance/SKILL.md +2 -2
- package/org-skills/avoid-ai-writing/SKILL.md +2 -2
- package/org-skills/backend-dev/SKILL.md +2 -2
- package/org-skills/backend-patterns/SKILL.md +2 -2
- package/org-skills/bash-defensive-patterns/SKILL.md +2 -2
- package/org-skills/before-you-build/SKILL.md +2 -2
- package/org-skills/benchmark-methodology/SKILL.md +2 -2
- package/org-skills/benchmarker/SKILL.md +2 -2
- package/org-skills/blockchain-auditor/SKILL.md +2 -2
- package/org-skills/board-deck-builder/SKILL.md +2 -2
- package/org-skills/business-investment-advisor/SKILL.md +2 -2
- package/org-skills/byzantine-coord/SKILL.md +2 -2
- package/org-skills/canvas-design/SKILL.md +2 -2
- package/org-skills/carrier-relationship-management/SKILL.md +2 -2
- package/org-skills/case-analyst/SKILL.md +2 -2
- package/org-skills/ceo-advisor/SKILL.md +2 -2
- package/org-skills/cfo-advisor/SKILL.md +2 -2
- package/org-skills/change-management/SKILL.md +2 -2
- package/org-skills/changelog-automation/SKILL.md +2 -2
- package/org-skills/chro-advisor/SKILL.md +2 -2
- package/org-skills/churn-prevention/SKILL.md +2 -2
- package/org-skills/cicd-engineer/SKILL.md +2 -2
- package/org-skills/ciso-advisor/SKILL.md +2 -2
- package/org-skills/click-path-audit/SKILL.md +2 -2
- package/org-skills/cloud-architect/SKILL.md +2 -2
- package/org-skills/cloud-architecture/SKILL.md +2 -2
- package/org-skills/cmo-advisor/SKILL.md +2 -2
- package/org-skills/co-marketing/SKILL.md +2 -2
- package/org-skills/code-documenter/SKILL.md +2 -2
- package/org-skills/code-review-swarm/SKILL.md +2 -2
- package/org-skills/code-reviewer/SKILL.md +2 -2
- package/org-skills/coder/SKILL.md +2 -2
- package/org-skills/coding-standards/SKILL.md +2 -2
- package/org-skills/cold-email/SKILL.md +2 -2
- package/org-skills/collective-coord/SKILL.md +2 -2
- package/org-skills/community-marketing/SKILL.md +2 -2
- package/org-skills/competitive-landscape/SKILL.md +2 -2
- package/org-skills/competitive-platform-analysis/SKILL.md +2 -2
- package/org-skills/competitive-report-structure/SKILL.md +2 -2
- package/org-skills/competitive-teardown/SKILL.md +2 -2
- package/org-skills/competitor-comparison-pages/SKILL.md +2 -2
- package/org-skills/compliance-auditor/SKILL.md +2 -2
- package/org-skills/consensus-coordinator/SKILL.md +2 -2
- package/org-skills/content-creator/SKILL.md +2 -2
- package/org-skills/content-engine/SKILL.md +2 -2
- package/org-skills/content-strategy/SKILL.md +2 -2
- package/org-skills/context-compression/SKILL.md +2 -2
- package/org-skills/context-degradation/SKILL.md +2 -2
- package/org-skills/context-fundamentals/SKILL.md +2 -2
- package/org-skills/context-optimization/SKILL.md +2 -2
- package/org-skills/contract-and-proposal-writer/SKILL.md +1 -1
- package/org-skills/contract-first/SKILL.md +2 -2
- package/org-skills/coo-advisor/SKILL.md +2 -2
- package/org-skills/copy-editing/SKILL.md +2 -2
- package/org-skills/copywriting/SKILL.md +2 -2
- package/org-skills/cost-aware-llm-pipeline/SKILL.md +2 -2
- package/org-skills/cost-optimization/SKILL.md +2 -2
- package/org-skills/cpp-coding-standards/SKILL.md +2 -2
- package/org-skills/cpp-pro/SKILL.md +2 -2
- package/org-skills/cro-advisor/SKILL.md +2 -2
- package/org-skills/cro-specialist/SKILL.md +2 -2
- package/org-skills/csharp-developer/SKILL.md +2 -2
- package/org-skills/cto-advisor/SKILL.md +2 -2
- package/org-skills/culture-architect/SKILL.md +2 -2
- package/org-skills/customer-research/SKILL.md +2 -2
- package/org-skills/customs-trade-compliance/SKILL.md +2 -2
- package/org-skills/dart-flutter-patterns/SKILL.md +2 -2
- package/org-skills/dashboard-builder/SKILL.md +2 -2
- package/org-skills/data-consolidator/SKILL.md +2 -2
- package/org-skills/data-engineer/SKILL.md +2 -2
- package/org-skills/data-quality-frameworks/SKILL.md +2 -2
- package/org-skills/data-storytelling/SKILL.md +2 -2
- package/org-skills/database-migrations/SKILL.md +2 -2
- package/org-skills/database-optimizer/SKILL.md +2 -2
- package/org-skills/dbt-transformation-patterns/SKILL.md +2 -2
- package/org-skills/deal-strategist/SKILL.md +2 -2
- package/org-skills/debugging-wizard/SKILL.md +2 -2
- package/org-skills/deep-research/SKILL.md +2 -2
- package/org-skills/defender/SKILL.md +2 -2
- package/org-skills/dependency-upgrade/SKILL.md +2 -2
- package/org-skills/deployment-patterns/SKILL.md +2 -2
- package/org-skills/deployment-pipeline-design/SKILL.md +2 -2
- package/org-skills/design-system/SKILL.md +2 -2
- package/org-skills/design-system-patterns/SKILL.md +2 -2
- package/org-skills/devops-automator/SKILL.md +2 -2
- package/org-skills/devops-engineer/SKILL.md +2 -2
- package/org-skills/discovery-coach/SKILL.md +2 -2
- package/org-skills/django-expert/SKILL.md +2 -2
- package/org-skills/django-patterns/SKILL.md +2 -2
- package/org-skills/docker-patterns/SKILL.md +2 -2
- package/org-skills/dotnet-patterns/SKILL.md +2 -2
- package/org-skills/e2e-testing/SKILL.md +2 -2
- package/org-skills/email-marketing/SKILL.md +2 -2
- package/org-skills/email-sequences/SKILL.md +2 -2
- package/org-skills/embedded-firmware/SKILL.md +2 -2
- package/org-skills/embedded-systems/SKILL.md +2 -2
- package/org-skills/employment-contract-templates/SKILL.md +2 -2
- package/org-skills/energy-procurement/SKILL.md +2 -2
- package/org-skills/error-handling/SKILL.md +2 -2
- package/org-skills/event-marketing/SKILL.md +2 -2
- package/org-skills/evidence-collector/SKILL.md +2 -2
- package/org-skills/experiment-designer/SKILL.md +2 -2
- package/org-skills/experiment-tracker/SKILL.md +2 -2
- package/org-skills/experimental-design/SKILL.md +2 -2
- package/org-skills/fastapi-expert/SKILL.md +2 -2
- package/org-skills/fastapi-patterns/SKILL.md +2 -2
- package/org-skills/feedback-synthesizer/SKILL.md +2 -2
- package/org-skills/finance-tracker/SKILL.md +2 -2
- package/org-skills/finishing-a-development-branch/SKILL.md +2 -2
- package/org-skills/flutter-expert/SKILL.md +2 -2
- package/org-skills/focused-fix/SKILL.md +2 -2
- package/org-skills/free-tool-strategy/SKILL.md +2 -2
- package/org-skills/frontend-design/SKILL.md +2 -2
- package/org-skills/frontend-design-direction/SKILL.md +2 -2
- package/org-skills/frontend-developer/SKILL.md +2 -2
- package/org-skills/frontend-patterns/SKILL.md +2 -2
- package/org-skills/game-audio-engineer/SKILL.md +2 -2
- package/org-skills/game-designer/SKILL.md +2 -2
- package/org-skills/gdpr-data-handling/SKILL.md +2 -2
- package/org-skills/general-counsel-advisor/SKILL.md +2 -2
- package/org-skills/git-advanced-workflows/SKILL.md +2 -2
- package/org-skills/git-workflow/SKILL.md +2 -2
- package/org-skills/golang-patterns/SKILL.md +2 -2
- package/org-skills/golang-pro/SKILL.md +2 -2
- package/org-skills/harness-engineering/SKILL.md +2 -2
- package/org-skills/healthcare-phi-compliance/SKILL.md +2 -2
- package/org-skills/hexagonal-architecture/SKILL.md +2 -2
- package/org-skills/hierarchical-coord/SKILL.md +2 -2
- package/org-skills/huggingface-transformers/SKILL.md +2 -2
- package/org-skills/hypothesis-generation/SKILL.md +2 -2
- package/org-skills/incident-command-playbook/SKILL.md +2 -2
- package/org-skills/incident-commander/SKILL.md +2 -2
- package/org-skills/incident-runbook-templates/SKILL.md +2 -2
- package/org-skills/influencer-marketing/SKILL.md +2 -2
- package/org-skills/infrastructure/SKILL.md +2 -2
- package/org-skills/input-validator/SKILL.md +2 -2
- package/org-skills/intent-driven-development/SKILL.md +2 -2
- package/org-skills/inventory-demand-planning/SKILL.md +2 -2
- package/org-skills/investor-materials/SKILL.md +2 -2
- package/org-skills/ios-developer/SKILL.md +2 -2
- package/org-skills/isms-audit-expert/SKILL.md +2 -2
- package/org-skills/issue-tracker/SKILL.md +2 -2
- package/org-skills/java-architect/SKILL.md +2 -2
- package/org-skills/java-coding-standards/SKILL.md +2 -2
- package/org-skills/judge/SKILL.md +2 -2
- package/org-skills/kotlin-patterns/SKILL.md +2 -2
- package/org-skills/kotlin-specialist/SKILL.md +2 -2
- package/org-skills/kpi-dashboard-design/SKILL.md +2 -2
- package/org-skills/kubernetes-patterns/SKILL.md +2 -2
- package/org-skills/kubernetes-specialist/SKILL.md +2 -2
- package/org-skills/laravel-patterns/SKILL.md +2 -2
- package/org-skills/launch-strategist/SKILL.md +2 -2
- package/org-skills/launch-strategy/SKILL.md +2 -2
- package/org-skills/lead-magnets/SKILL.md +2 -2
- package/org-skills/legacy-modernizer/SKILL.md +2 -2
- package/org-skills/legal-compliance/SKILL.md +2 -2
- package/org-skills/level-designer/SKILL.md +2 -2
- package/org-skills/llm-cost-optimizer/SKILL.md +2 -2
- package/org-skills/llm-evaluation/SKILL.md +2 -2
- package/org-skills/llm-project-development/SKILL.md +2 -2
- package/org-skills/load-balancer/SKILL.md +2 -2
- package/org-skills/logistics-exception-management/SKILL.md +2 -2
- package/org-skills/long-horizon-prompting/SKILL.md +2 -2
- package/org-skills/make-interfaces-feel-better/SKILL.md +2 -2
- package/org-skills/markdown-mermaid-writing/SKILL.md +2 -2
- package/org-skills/market-research/SKILL.md +2 -2
- package/org-skills/market-research-reports/SKILL.md +2 -2
- package/org-skills/market-sizing-analysis/SKILL.md +2 -2
- package/org-skills/marketing-attribution/SKILL.md +2 -2
- package/org-skills/marketing-campaign/SKILL.md +2 -2
- package/org-skills/marketing-council/SKILL.md +2 -2
- package/org-skills/marketing-demand-acquisition/SKILL.md +2 -2
- package/org-skills/marketing-loops/SKILL.md +2 -2
- package/org-skills/marketing-plan/SKILL.md +2 -2
- package/org-skills/marketing-psychology/SKILL.md +2 -2
- package/org-skills/marketing-strategy-pmm/SKILL.md +2 -2
- package/org-skills/markitdown-document-conversion/SKILL.md +2 -2
- package/org-skills/mcp-builder/SKILL.md +2 -2
- package/org-skills/mcp-server-builder/SKILL.md +2 -2
- package/org-skills/mcp-server-patterns/SKILL.md +2 -2
- package/org-skills/memory-coordinator/SKILL.md +2 -2
- package/org-skills/mesh-coordinator/SKILL.md +2 -2
- package/org-skills/ml-developer/SKILL.md +2 -2
- package/org-skills/ml-pipeline/SKILL.md +2 -2
- package/org-skills/mle-workflow/SKILL.md +2 -2
- package/org-skills/mobile-app-builder/SKILL.md +2 -2
- package/org-skills/mobile-dev/SKILL.md +2 -2
- package/org-skills/model-qa/SKILL.md +2 -2
- package/org-skills/monitoring-expert/SKILL.md +2 -2
- package/org-skills/monodesign-ui-quality/SKILL.md +2 -2
- package/org-skills/monograph-code-navigation/SKILL.md +2 -2
- package/org-skills/monolean-minimal-change/SKILL.md +2 -2
- package/org-skills/multi-agent-patterns/SKILL.md +2 -2
- package/org-skills/mysql-patterns/SKILL.md +2 -2
- package/org-skills/narrative-designer/SKILL.md +2 -2
- package/org-skills/nextjs-developer/SKILL.md +2 -2
- package/org-skills/offer-design/SKILL.md +2 -2
- package/org-skills/onboarding-cro/SKILL.md +2 -2
- package/org-skills/outbound-strategist/SKILL.md +2 -2
- package/org-skills/page-cro/SKILL.md +2 -2
- package/org-skills/paid-ads/SKILL.md +2 -2
- package/org-skills/pandas-pro/SKILL.md +2 -2
- package/org-skills/path-validator/SKILL.md +2 -2
- package/org-skills/payment-agent/SKILL.md +2 -2
- package/org-skills/pci-compliance/SKILL.md +2 -2
- package/org-skills/perf-analyzer/SKILL.md +2 -2
- package/org-skills/php-pro/SKILL.md +2 -2
- package/org-skills/pipeline-analyst/SKILL.md +2 -2
- package/org-skills/planner/SKILL.md +2 -2
- package/org-skills/playwright-expert/SKILL.md +2 -2
- package/org-skills/postgres-patterns/SKILL.md +2 -2
- package/org-skills/postgresql-table-design/SKILL.md +2 -2
- package/org-skills/postmortem-writing/SKILL.md +2 -2
- package/org-skills/pr-manager/SKILL.md +2 -2
- package/org-skills/pricing-strategist/SKILL.md +2 -2
- package/org-skills/pricing-strategy/SKILL.md +2 -2
- package/org-skills/prisma-patterns/SKILL.md +2 -2
- package/org-skills/product-capability/SKILL.md +2 -2
- package/org-skills/product-discovery/SKILL.md +2 -2
- package/org-skills/product-lens/SKILL.md +2 -2
- package/org-skills/product-manager/SKILL.md +2 -2
- package/org-skills/product-marketing-context/SKILL.md +2 -2
- package/org-skills/production-audit/SKILL.md +2 -2
- package/org-skills/production-scheduling/SKILL.md +2 -2
- package/org-skills/production-validator/SKILL.md +2 -2
- package/org-skills/programmatic-seo/SKILL.md +2 -2
- package/org-skills/project-shepherd/SKILL.md +2 -2
- package/org-skills/prompt-engineer/SKILL.md +2 -2
- package/org-skills/proposal-strategist/SKILL.md +2 -2
- package/org-skills/prosecutor/SKILL.md +2 -2
- package/org-skills/public-relations/SKILL.md +2 -2
- package/org-skills/pymc-bayesian-modeling/SKILL.md +2 -2
- package/org-skills/python-patterns/SKILL.md +2 -2
- package/org-skills/python-pro/SKILL.md +2 -2
- package/org-skills/python-testing/SKILL.md +2 -2
- package/org-skills/quality-nonconformance/SKILL.md +2 -2
- package/org-skills/queen-coordinator/SKILL.md +2 -2
- package/org-skills/quorum-manager/SKILL.md +2 -2
- package/org-skills/raft-manager/SKILL.md +2 -2
- package/org-skills/rag-architect/SKILL.md +2 -2
- package/org-skills/rails-patterns/SKILL.md +2 -2
- package/org-skills/react-expert/SKILL.md +2 -2
- package/org-skills/react-native-expert/SKILL.md +2 -2
- package/org-skills/react-native-patterns/SKILL.md +2 -2
- package/org-skills/react-patterns/SKILL.md +2 -2
- package/org-skills/react-performance/SKILL.md +2 -2
- package/org-skills/react-testing/SKILL.md +2 -2
- package/org-skills/reality-checker/SKILL.md +2 -2
- package/org-skills/receiving-code-review/SKILL.md +2 -2
- package/org-skills/recruitment/SKILL.md +2 -2
- package/org-skills/redis-patterns/SKILL.md +2 -2
- package/org-skills/referral-programs/SKILL.md +2 -2
- package/org-skills/release-manager/SKILL.md +2 -2
- package/org-skills/repo-architect/SKILL.md +2 -2
- package/org-skills/researcher/SKILL.md +2 -2
- package/org-skills/resource-allocator/SKILL.md +2 -2
- package/org-skills/responsive-design/SKILL.md +2 -2
- package/org-skills/returns-reverse-logistics/SKILL.md +2 -2
- package/org-skills/reviewer/SKILL.md +2 -2
- package/org-skills/revops/SKILL.md +2 -2
- package/org-skills/roadmap-communicator/SKILL.md +2 -2
- package/org-skills/rust-engineer/SKILL.md +2 -2
- package/org-skills/rust-patterns/SKILL.md +2 -2
- package/org-skills/safe-executor/SKILL.md +2 -2
- package/org-skills/sales-coach/SKILL.md +2 -2
- package/org-skills/sales-enablement/SKILL.md +2 -2
- package/org-skills/sales-engineer/SKILL.md +2 -2
- package/org-skills/sales-prospecting/SKILL.md +2 -2
- package/org-skills/schema-markup/SKILL.md +2 -2
- package/org-skills/scientific-brainstorming/SKILL.md +2 -2
- package/org-skills/scientific-critical-thinking/SKILL.md +2 -2
- package/org-skills/scientific-thinking-literature-review/SKILL.md +2 -2
- package/org-skills/scientific-thinking-scholar-evaluation/SKILL.md +2 -2
- package/org-skills/scientific-visualization/SKILL.md +2 -2
- package/org-skills/scientific-writing/SKILL.md +2 -2
- package/org-skills/scout-explorer/SKILL.md +2 -2
- package/org-skills/secrets-vault-manager/SKILL.md +2 -2
- package/org-skills/secure-code-guardian/SKILL.md +2 -2
- package/org-skills/security-architect/SKILL.md +2 -2
- package/org-skills/security-auditor/SKILL.md +2 -2
- package/org-skills/security-review/SKILL.md +2 -2
- package/org-skills/security-reviewer/SKILL.md +2 -2
- package/org-skills/senior-data-scientist/SKILL.md +2 -2
- package/org-skills/senior-developer/SKILL.md +2 -2
- package/org-skills/senior-pm/SKILL.md +2 -2
- package/org-skills/senior-pm-playbook/SKILL.md +2 -2
- package/org-skills/seo/SKILL.md +2 -2
- package/org-skills/seo-audit/SKILL.md +2 -2
- package/org-skills/seo-specialist/SKILL.md +2 -2
- package/org-skills/shap-model-explainability/SKILL.md +2 -2
- package/org-skills/signup-flow-cro/SKILL.md +2 -2
- package/org-skills/site-architecture/SKILL.md +2 -2
- package/org-skills/sms-marketing/SKILL.md +2 -2
- package/org-skills/soc2-compliance/SKILL.md +2 -2
- package/org-skills/social-content/SKILL.md +2 -2
- package/org-skills/social-media/SKILL.md +2 -2
- package/org-skills/social-media-manager/SKILL.md +2 -2
- package/org-skills/solidity-engineer/SKILL.md +2 -2
- package/org-skills/spark-engineer/SKILL.md +2 -2
- package/org-skills/spec-driven-workflow/SKILL.md +2 -2
- package/org-skills/springboot-patterns/SKILL.md +2 -2
- package/org-skills/sprint-prioritizer/SKILL.md +2 -2
- package/org-skills/sql-pro/SKILL.md +2 -2
- package/org-skills/sre/SKILL.md +2 -2
- package/org-skills/sre-engineer/SKILL.md +2 -2
- package/org-skills/startup-financial-modeling/SKILL.md +2 -2
- package/org-skills/startup-metrics-framework/SKILL.md +2 -2
- package/org-skills/statistical-analysis/SKILL.md +2 -2
- package/org-skills/statistical-power/SKILL.md +2 -2
- package/org-skills/stride-analysis-patterns/SKILL.md +2 -2
- package/org-skills/stripe-integration/SKILL.md +2 -2
- package/org-skills/studio-operations/SKILL.md +2 -2
- package/org-skills/studio-producer/SKILL.md +2 -2
- package/org-skills/support-responder/SKILL.md +2 -2
- package/org-skills/swift-expert/SKILL.md +2 -2
- package/org-skills/swiftui-patterns/SKILL.md +2 -2
- package/org-skills/system-architect/SKILL.md +2 -2
- package/org-skills/systematic-debugging/SKILL.md +2 -2
- package/org-skills/task-orchestrator/SKILL.md +2 -2
- package/org-skills/team-communications/SKILL.md +2 -2
- package/org-skills/team-composition-analysis/SKILL.md +2 -2
- package/org-skills/technical-artist/SKILL.md +2 -2
- package/org-skills/technical-writer/SKILL.md +2 -2
- package/org-skills/terraform-engineer/SKILL.md +2 -2
- package/org-skills/test-driven-development/SKILL.md +2 -2
- package/org-skills/test-master/SKILL.md +2 -2
- package/org-skills/tester/SKILL.md +2 -2
- package/org-skills/the-fool/SKILL.md +2 -2
- package/org-skills/theme-factory/SKILL.md +2 -2
- package/org-skills/threat-detection/SKILL.md +2 -2
- package/org-skills/threat-mitigation-mapping/SKILL.md +2 -2
- package/org-skills/trend-researcher/SKILL.md +2 -2
- package/org-skills/trial-director/SKILL.md +2 -2
- package/org-skills/typescript-pro/SKILL.md +2 -2
- package/org-skills/unity-architect/SKILL.md +2 -2
- package/org-skills/using-git-worktrees/SKILL.md +2 -2
- package/org-skills/ux-researcher-designer/SKILL.md +2 -2
- package/org-skills/verification-before-completion/SKILL.md +2 -2
- package/org-skills/visionos-engineer/SKILL.md +2 -2
- package/org-skills/visual-design-foundations/SKILL.md +2 -2
- package/org-skills/vue-expert/SKILL.md +2 -2
- package/org-skills/vue-patterns/SKILL.md +2 -2
- package/org-skills/worker-specialist/SKILL.md +2 -2
- package/org-skills/workflow-architect/SKILL.md +2 -2
- package/org-skills/workflow-automation/SKILL.md +2 -2
- package/org-skills/writing-plans/SKILL.md +2 -2
- package/org-skills/zk-steward/SKILL.md +2 -2
- package/package.json +7 -7
- package/.claude/helpers/skill-registry.json +0 -5997
- package/.claude/skills/monodesign/SKILL.md +0 -257
- package/.claude/skills/monodesign/adapt.md +0 -53
- package/.claude/skills/monodesign/agents/monodesign-asset-producer.md +0 -100
- package/.claude/skills/monodesign/agents/monodesign-manual-edit-applier.md +0 -103
- package/.claude/skills/monodesign/animate.md +0 -65
- package/.claude/skills/monodesign/audit.md +0 -89
- package/.claude/skills/monodesign/bolder.md +0 -50
- package/.claude/skills/monodesign/clarify.md +0 -64
- package/.claude/skills/monodesign/colorize.md +0 -68
- package/.claude/skills/monodesign/craft.md +0 -51
- package/.claude/skills/monodesign/critique.md +0 -66
- package/.claude/skills/monodesign/delight.md +0 -47
- package/.claude/skills/monodesign/distill.md +0 -56
- package/.claude/skills/monodesign/document.md +0 -83
- package/.claude/skills/monodesign/extract.md +0 -74
- package/.claude/skills/monodesign/harden.md +0 -65
- package/.claude/skills/monodesign/init.md +0 -30
- package/.claude/skills/monodesign/layout.md +0 -36
- package/.claude/skills/monodesign/live.md +0 -34
- package/.claude/skills/monodesign/onboard.md +0 -50
- package/.claude/skills/monodesign/optimize.md +0 -64
- package/.claude/skills/monodesign/overdrive.md +0 -56
- package/.claude/skills/monodesign/polish.md +0 -68
- package/.claude/skills/monodesign/quieter.md +0 -57
- package/.claude/skills/monodesign/reference/adapt.md +0 -312
- package/.claude/skills/monodesign/reference/adapt.native.md +0 -58
- package/.claude/skills/monodesign/reference/android.md +0 -40
- package/.claude/skills/monodesign/reference/animate.md +0 -203
- package/.claude/skills/monodesign/reference/antipatterns-catalog.md +0 -410
- package/.claude/skills/monodesign/reference/audit.md +0 -135
- package/.claude/skills/monodesign/reference/audit.native.md +0 -139
- package/.claude/skills/monodesign/reference/bolder.md +0 -120
- package/.claude/skills/monodesign/reference/brand-workflow.md +0 -180
- package/.claude/skills/monodesign/reference/brand.md +0 -108
- package/.claude/skills/monodesign/reference/clarify.md +0 -288
- package/.claude/skills/monodesign/reference/codex.md +0 -105
- package/.claude/skills/monodesign/reference/cognitive-load.md +0 -106
- package/.claude/skills/monodesign/reference/color-and-contrast.md +0 -105
- package/.claude/skills/monodesign/reference/colorize.md +0 -257
- package/.claude/skills/monodesign/reference/component-specs.md +0 -260
- package/.claude/skills/monodesign/reference/component-states.md +0 -274
- package/.claude/skills/monodesign/reference/component-system.md +0 -358
- package/.claude/skills/monodesign/reference/copy-formulas.md +0 -160
- package/.claude/skills/monodesign/reference/craft.md +0 -123
- package/.claude/skills/monodesign/reference/critique.md +0 -780
- package/.claude/skills/monodesign/reference/delight.md +0 -302
- package/.claude/skills/monodesign/reference/design-principles.md +0 -246
- package/.claude/skills/monodesign/reference/distill.md +0 -111
- package/.claude/skills/monodesign/reference/document.md +0 -429
- package/.claude/skills/monodesign/reference/extract.md +0 -69
- package/.claude/skills/monodesign/reference/harden.md +0 -347
- package/.claude/skills/monodesign/reference/heuristics-scoring.md +0 -234
- package/.claude/skills/monodesign/reference/hooks.md +0 -92
- package/.claude/skills/monodesign/reference/image-prompts.md +0 -130
- package/.claude/skills/monodesign/reference/init.md +0 -221
- package/.claude/skills/monodesign/reference/interaction-design.md +0 -189
- package/.claude/skills/monodesign/reference/ios.md +0 -45
- package/.claude/skills/monodesign/reference/layout.md +0 -185
- package/.claude/skills/monodesign/reference/live.md +0 -710
- package/.claude/skills/monodesign/reference/motion-design.md +0 -109
- package/.claude/skills/monodesign/reference/onboard.md +0 -234
- package/.claude/skills/monodesign/reference/optimize.md +0 -258
- package/.claude/skills/monodesign/reference/overdrive.md +0 -130
- package/.claude/skills/monodesign/reference/personas.md +0 -179
- package/.claude/skills/monodesign/reference/polish.md +0 -241
- package/.claude/skills/monodesign/reference/pre-delivery-checklist.md +0 -108
- package/.claude/skills/monodesign/reference/product.md +0 -60
- package/.claude/skills/monodesign/reference/quieter.md +0 -99
- package/.claude/skills/monodesign/reference/responsive-design.md +0 -114
- package/.claude/skills/monodesign/reference/shape.md +0 -165
- package/.claude/skills/monodesign/reference/spatial-design.md +0 -100
- package/.claude/skills/monodesign/reference/teach.md +0 -10
- package/.claude/skills/monodesign/reference/token-architecture.md +0 -222
- package/.claude/skills/monodesign/reference/typeset.md +0 -301
- package/.claude/skills/monodesign/reference/typography.md +0 -159
- package/.claude/skills/monodesign/reference/ux-research.md +0 -143
- package/.claude/skills/monodesign/reference/ux-rules.md +0 -211
- package/.claude/skills/monodesign/reference/ux-writing.md +0 -107
- package/.claude/skills/monodesign/scripts/command-metadata.json +0 -94
- package/.claude/skills/monodesign/scripts/context-signals.mjs +0 -260
- package/.claude/skills/monodesign/scripts/context.mjs +0 -1065
- package/.claude/skills/monodesign/scripts/critique-storage.mjs +0 -416
- package/.claude/skills/monodesign/scripts/detect-csp.mjs +0 -193
- package/.claude/skills/monodesign/scripts/detect.mjs +0 -33
- package/.claude/skills/monodesign/scripts/detector/browser/injected/index.mjs +0 -1960
- package/.claude/skills/monodesign/scripts/detector/cli/main.mjs +0 -321
- package/.claude/skills/monodesign/scripts/detector/design-system.mjs +0 -814
- package/.claude/skills/monodesign/scripts/detector/detect-antipatterns-browser.js +0 -5628
- package/.claude/skills/monodesign/scripts/detector/detect-antipatterns.mjs +0 -50
- package/.claude/skills/monodesign/scripts/detector/engines/browser/detect-url.mjs +0 -259
- package/.claude/skills/monodesign/scripts/detector/engines/browser/drivers.mjs +0 -339
- package/.claude/skills/monodesign/scripts/detector/engines/regex/detect-text.mjs +0 -636
- package/.claude/skills/monodesign/scripts/detector/engines/static-html/css-cascade.mjs +0 -1016
- package/.claude/skills/monodesign/scripts/detector/engines/static-html/detect-html.mjs +0 -253
- package/.claude/skills/monodesign/scripts/detector/engines/visual/screenshot-contrast.mjs +0 -198
- package/.claude/skills/monodesign/scripts/detector/findings.mjs +0 -12
- package/.claude/skills/monodesign/scripts/detector/fix/css-regions.mjs +0 -181
- package/.claude/skills/monodesign/scripts/detector/fix/fixers.mjs +0 -373
- package/.claude/skills/monodesign/scripts/detector/fix/index.mjs +0 -426
- package/.claude/skills/monodesign/scripts/detector/node/file-system.mjs +0 -198
- package/.claude/skills/monodesign/scripts/detector/profile/profiler.mjs +0 -166
- package/.claude/skills/monodesign/scripts/detector/registry/antipatterns.mjs +0 -563
- package/.claude/skills/monodesign/scripts/detector/rules/checks.mjs +0 -3024
- package/.claude/skills/monodesign/scripts/detector/shared/color.mjs +0 -124
- package/.claude/skills/monodesign/scripts/detector/shared/constants.mjs +0 -101
- package/.claude/skills/monodesign/scripts/detector/shared/fonts.mjs +0 -30
- package/.claude/skills/monodesign/scripts/detector/shared/inline-ignores.mjs +0 -148
- package/.claude/skills/monodesign/scripts/detector/shared/page.mjs +0 -7
- package/.claude/skills/monodesign/scripts/hook-admin.mjs +0 -694
- package/.claude/skills/monodesign/scripts/hook-before-edit.mjs +0 -516
- package/.claude/skills/monodesign/scripts/hook-lib.mjs +0 -1785
- package/.claude/skills/monodesign/scripts/hook.mjs +0 -61
- package/.claude/skills/monodesign/scripts/lib/design-parser.mjs +0 -809
- package/.claude/skills/monodesign/scripts/lib/is-generated.mjs +0 -69
- package/.claude/skills/monodesign/scripts/lib/monodesign-config.mjs +0 -640
- package/.claude/skills/monodesign/scripts/lib/monodesign-paths.mjs +0 -129
- package/.claude/skills/monodesign/scripts/lib/provider.mjs +0 -4
- package/.claude/skills/monodesign/scripts/lib/target-args.mjs +0 -42
- package/.claude/skills/monodesign/scripts/live/browser-script-parts.mjs +0 -50
- package/.claude/skills/monodesign/scripts/live/completion.mjs +0 -19
- package/.claude/skills/monodesign/scripts/live/event-validation.mjs +0 -137
- package/.claude/skills/monodesign/scripts/live/insert-ui.mjs +0 -458
- package/.claude/skills/monodesign/scripts/live/manual-apply.mjs +0 -939
- package/.claude/skills/monodesign/scripts/live/manual-edit-routes.mjs +0 -357
- package/.claude/skills/monodesign/scripts/live/manual-edits-buffer.mjs +0 -152
- package/.claude/skills/monodesign/scripts/live/session-store.mjs +0 -293
- package/.claude/skills/monodesign/scripts/live/svelte-component.mjs +0 -826
- package/.claude/skills/monodesign/scripts/live/sveltekit-adapter.mjs +0 -279
- package/.claude/skills/monodesign/scripts/live/ui-core.mjs +0 -180
- package/.claude/skills/monodesign/scripts/live/vocabulary.mjs +0 -36
- package/.claude/skills/monodesign/scripts/live-accept.mjs +0 -812
- package/.claude/skills/monodesign/scripts/live-browser-dom.js +0 -147
- package/.claude/skills/monodesign/scripts/live-browser-session.js +0 -124
- package/.claude/skills/monodesign/scripts/live-browser.js +0 -11213
- package/.claude/skills/monodesign/scripts/live-commit-manual-edits.mjs +0 -1241
- package/.claude/skills/monodesign/scripts/live-complete.mjs +0 -75
- package/.claude/skills/monodesign/scripts/live-copy-edit-agent.mjs +0 -683
- package/.claude/skills/monodesign/scripts/live-discard-manual-edits.mjs +0 -51
- package/.claude/skills/monodesign/scripts/live-inject.mjs +0 -596
- package/.claude/skills/monodesign/scripts/live-insert.mjs +0 -272
- package/.claude/skills/monodesign/scripts/live-manual-edit-evidence.mjs +0 -363
- package/.claude/skills/monodesign/scripts/live-poll.mjs +0 -384
- package/.claude/skills/monodesign/scripts/live-resume.mjs +0 -94
- package/.claude/skills/monodesign/scripts/live-server.mjs +0 -1210
- package/.claude/skills/monodesign/scripts/live-status.mjs +0 -61
- package/.claude/skills/monodesign/scripts/live-target.mjs +0 -30
- package/.claude/skills/monodesign/scripts/live-wrap.mjs +0 -884
- package/.claude/skills/monodesign/scripts/live.mjs +0 -297
- package/.claude/skills/monodesign/scripts/modern-screenshot.umd.js +0 -14
- package/.claude/skills/monodesign/scripts/palette.mjs +0 -635
- package/.claude/skills/monodesign/scripts/pin.mjs +0 -221
- package/.claude/skills/monodesign/shape.md +0 -71
- package/.claude/skills/monodesign/teach.md +0 -18
- package/.claude/skills/monodesign/typeset.md +0 -59
- package/dist/src/routing/jev-step.d.ts +0 -17
- package/dist/src/routing/jev-step.d.ts.map +0 -1
- package/dist/src/routing/jev-step.js +0 -27
- package/dist/src/routing/jev-step.js.map +0 -1
- package/org-skills/accessibility/LICENSE.txt +0 -21
- package/org-skills/accessibility/SKILL.md +0 -149
- package/org-skills/database-migration/LICENSE.txt +0 -21
- package/org-skills/database-migration/SKILL.md +0 -337
- package/org-skills/database-migration/references/details.md +0 -76
- package/org-skills/error-handling-patterns/LICENSE.txt +0 -21
- package/org-skills/error-handling-patterns/SKILL.md +0 -126
- package/org-skills/error-handling-patterns/references/details.md +0 -516
- package/org-skills/internal-comms/LICENSE.txt +0 -202
- package/org-skills/internal-comms/SKILL.md +0 -36
- package/org-skills/internal-comms/examples/3p-updates.md +0 -47
- package/org-skills/internal-comms/examples/company-newsletter.md +0 -65
- package/org-skills/internal-comms/examples/faq-answers.md +0 -30
- package/org-skills/internal-comms/examples/general-comms.md +0 -16
|
@@ -1,1210 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Live variant mode server (self-contained, zero dependencies).
|
|
4
|
-
*
|
|
5
|
-
* Serves the browser script (/live.js), the detection overlay (/detect.js),
|
|
6
|
-
* uses Server-Sent Events (SSE) for server→browser push, and HTTP POST for
|
|
7
|
-
* browser→server events. Agent communicates via HTTP long-poll (/poll).
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* node <scripts_path>/live-server.mjs # start
|
|
11
|
-
* node <scripts_path>/live-server.mjs stop # stop + remove injected live.js tag
|
|
12
|
-
* node <scripts_path>/live-server.mjs stop --keep-inject # stop only
|
|
13
|
-
* node <scripts_path>/live-server.mjs --help
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import http from 'node:http';
|
|
17
|
-
import { randomUUID } from 'node:crypto';
|
|
18
|
-
import { spawn, execFileSync } from 'node:child_process';
|
|
19
|
-
import fs from 'node:fs';
|
|
20
|
-
import path from 'node:path';
|
|
21
|
-
import net from 'node:net';
|
|
22
|
-
import { fileURLToPath } from 'node:url';
|
|
23
|
-
import { parseDesignMd } from './lib/design-parser.mjs';
|
|
24
|
-
import { loadContext } from './context.mjs';
|
|
25
|
-
import {
|
|
26
|
-
assembleLiveBrowserScript,
|
|
27
|
-
assertLiveBrowserScriptParts,
|
|
28
|
-
readLiveBrowserScriptParts,
|
|
29
|
-
resolveLiveBrowserScriptParts,
|
|
30
|
-
} from './live/browser-script-parts.mjs';
|
|
31
|
-
import { createLiveSessionStore } from './live/session-store.mjs';
|
|
32
|
-
import { validateEvent } from './live/event-validation.mjs';
|
|
33
|
-
import { createManualEditRoutes } from './live/manual-edit-routes.mjs';
|
|
34
|
-
import { LIVE_COMMANDS } from './live/vocabulary.mjs';
|
|
35
|
-
import {
|
|
36
|
-
getDesignSidecarPath,
|
|
37
|
-
getLiveDir,
|
|
38
|
-
getLiveAnnotationsDir,
|
|
39
|
-
MONODESIGN_COMMAND_PREFIX,
|
|
40
|
-
readLiveServerInfo,
|
|
41
|
-
removeLiveServerInfo,
|
|
42
|
-
resolveDesignSidecarPath,
|
|
43
|
-
writeLiveServerInfo,
|
|
44
|
-
} from './lib/monodesign-paths.mjs';
|
|
45
|
-
import { countByPage as countPendingByPage } from './live/manual-edits-buffer.mjs';
|
|
46
|
-
import {
|
|
47
|
-
createManualApplyController,
|
|
48
|
-
summarizeManualApplyFailures,
|
|
49
|
-
} from './live/manual-apply.mjs';
|
|
50
|
-
import {
|
|
51
|
-
applyDeferredSvelteComponentAccepts,
|
|
52
|
-
removeAllSvelteComponentSessions,
|
|
53
|
-
} from './live/svelte-component.mjs';
|
|
54
|
-
|
|
55
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
56
|
-
// PRODUCT.md / DESIGN.md live wherever context.mjs resolves. The generated
|
|
57
|
-
// DESIGN sidecar is project-local at .monodesign/design.json, with legacy
|
|
58
|
-
// DESIGN.json fallback for existing projects.
|
|
59
|
-
const PROJECT_CONTEXT = loadContext(process.cwd());
|
|
60
|
-
const CONTEXT_DIR = PROJECT_CONTEXT.contextDir;
|
|
61
|
-
const DESIGN_MD_PATH = PROJECT_CONTEXT.designPath
|
|
62
|
-
? path.resolve(process.cwd(), PROJECT_CONTEXT.designPath)
|
|
63
|
-
: null;
|
|
64
|
-
const DEFAULT_POLL_TIMEOUT = 600_000; // 10 min — agent re-polls on timeout anyway
|
|
65
|
-
const SSE_HEARTBEAT_INTERVAL = 30_000; // keepalive ping every 30s
|
|
66
|
-
// Query param name every protected route checks against the per-process credential.
|
|
67
|
-
const AUTH_QUERY_KEY = 'token';
|
|
68
|
-
|
|
69
|
-
// ---------------------------------------------------------------------------
|
|
70
|
-
// Port detection
|
|
71
|
-
// ---------------------------------------------------------------------------
|
|
72
|
-
|
|
73
|
-
async function findOpenPort(start = 8400) {
|
|
74
|
-
return new Promise((resolve) => {
|
|
75
|
-
const srv = net.createServer();
|
|
76
|
-
srv.listen(start, '127.0.0.1', () => {
|
|
77
|
-
const port = srv.address().port;
|
|
78
|
-
srv.close(() => resolve(port));
|
|
79
|
-
});
|
|
80
|
-
srv.on('error', () => resolve(findOpenPort(start + 1)));
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// ---------------------------------------------------------------------------
|
|
85
|
-
// Session state
|
|
86
|
-
// ---------------------------------------------------------------------------
|
|
87
|
-
|
|
88
|
-
const state = {
|
|
89
|
-
token: null,
|
|
90
|
-
port: null,
|
|
91
|
-
sseClients: new Set(), // SSE response objects (server→browser push)
|
|
92
|
-
pendingEvents: [], // browser events waiting for agent ack ({ event, leaseUntil })
|
|
93
|
-
pendingPolls: [], // agent poll callbacks waiting for browser events
|
|
94
|
-
nextEventSeq: 1,
|
|
95
|
-
lastAgentPollingBroadcast: null,
|
|
96
|
-
exitTimer: null,
|
|
97
|
-
sessionDir: null, // per-session tmp dir for annotation screenshots
|
|
98
|
-
sessionStore: null,
|
|
99
|
-
leaseTimer: null,
|
|
100
|
-
manualEditActivity: null,
|
|
101
|
-
nextManualEditSeq: 1,
|
|
102
|
-
// Deferreds for in-flight chat-routed Apply events. Keyed by event id; each
|
|
103
|
-
// entry is resolved when the chat agent POSTs an ack carrying the batch
|
|
104
|
-
// result, or rejected when the hard timeout fires.
|
|
105
|
-
pendingApplyDeferreds: new Map(),
|
|
106
|
-
// Updated whenever a /poll long-poll request arrives or is resolved with an
|
|
107
|
-
// event. Used to detect "a chat agent is likely attached" without requiring
|
|
108
|
-
// a poll to be parked at the exact moment we dispatch.
|
|
109
|
-
lastPollAt: 0,
|
|
110
|
-
timedOutApplyIds: new Map(),
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const CHAT_POLL_FRESHNESS_MS = 60_000;
|
|
114
|
-
const POLL_LEASE_EXPIRY_TIMER_GRACE_MS = 2;
|
|
115
|
-
const DEBUG_MANUAL_EDIT_EVENTS = /^(1|true|yes)$/i.test(process.env.MONODESIGN_LIVE_DEBUG_EVENTS || '');
|
|
116
|
-
|
|
117
|
-
const manualApply = createManualApplyController({
|
|
118
|
-
pendingEvents: state.pendingEvents,
|
|
119
|
-
pendingApplyDeferreds: state.pendingApplyDeferreds,
|
|
120
|
-
timedOutApplyIds: state.timedOutApplyIds,
|
|
121
|
-
enqueueEvent,
|
|
122
|
-
acknowledgePendingEvent,
|
|
123
|
-
flushPendingPolls,
|
|
124
|
-
recordManualEditActivity,
|
|
125
|
-
cwd: () => process.cwd(),
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
const manualEditRoutes = createManualEditRoutes({
|
|
129
|
-
getToken: () => state.token,
|
|
130
|
-
manualApply,
|
|
131
|
-
recordManualEditActivity,
|
|
132
|
-
getManualEditStatus,
|
|
133
|
-
chatAgentLikelyActive,
|
|
134
|
-
cwd: () => process.cwd(),
|
|
135
|
-
env: () => process.env,
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
function chatAgentLikelyActive() {
|
|
139
|
-
if (state.pendingPolls.length > 0) return true;
|
|
140
|
-
if (!state.lastPollAt) return false;
|
|
141
|
-
return Date.now() - state.lastPollAt < CHAT_POLL_FRESHNESS_MS;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Cap per-annotation upload size. A full 1920×1080 PNG is typically <1 MB;
|
|
145
|
-
// cap at 10 MB to guard against runaway writes from a misbehaving client.
|
|
146
|
-
const MAX_ANNOTATION_BYTES = 10 * 1024 * 1024;
|
|
147
|
-
|
|
148
|
-
function enqueueEvent(event) {
|
|
149
|
-
if (!event || (event.id && state.pendingEvents.some((entry) => entry.event?.id === event.id && entry.event?.type === event.type))) return;
|
|
150
|
-
state.pendingEvents.push({ event, leaseUntil: 0, seq: state.nextEventSeq++ });
|
|
151
|
-
flushPendingPolls();
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function restorePendingEventsFromStore() {
|
|
155
|
-
if (!state.sessionStore) return;
|
|
156
|
-
for (const snapshot of state.sessionStore.listActiveSessions()) {
|
|
157
|
-
if (snapshot.pendingEvent) enqueueEvent(snapshot.pendingEvent);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function findAvailablePendingEvent(now = Date.now()) {
|
|
162
|
-
for (const entry of state.pendingEvents) {
|
|
163
|
-
if (entry.leaseUntil && entry.leaseUntil > now) continue;
|
|
164
|
-
return entry;
|
|
165
|
-
}
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function leaseEvent(entry, leaseMs) {
|
|
170
|
-
if (!entry.event?.id) {
|
|
171
|
-
const idx = state.pendingEvents.indexOf(entry);
|
|
172
|
-
if (idx !== -1) state.pendingEvents.splice(idx, 1);
|
|
173
|
-
return entry.event;
|
|
174
|
-
}
|
|
175
|
-
entry.leaseUntil = Date.now() + leaseMs;
|
|
176
|
-
scheduleLeaseFlush();
|
|
177
|
-
broadcastAgentPollingIfChanged();
|
|
178
|
-
return entry.event;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function acknowledgePendingEvent(id) {
|
|
182
|
-
if (!id) return false;
|
|
183
|
-
const idx = state.pendingEvents.findIndex((entry) => entry.event?.id === id);
|
|
184
|
-
if (idx === -1) return false;
|
|
185
|
-
const acknowledged = state.pendingEvents[idx].event;
|
|
186
|
-
state.pendingEvents.splice(idx, 1);
|
|
187
|
-
scheduleLeaseFlush();
|
|
188
|
-
broadcastAgentPollingIfChanged();
|
|
189
|
-
return acknowledged;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function findPendingEventById(id) {
|
|
193
|
-
if (!id) return null;
|
|
194
|
-
const entry = state.pendingEvents.find((item) => item.event?.id === id);
|
|
195
|
-
return entry?.event || null;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
function summarizePendingEventForStatus(entry) {
|
|
199
|
-
const event = entry.event || {};
|
|
200
|
-
const summary = {
|
|
201
|
-
id: event.id,
|
|
202
|
-
type: event.type,
|
|
203
|
-
leased: !!(entry.leaseUntil && entry.leaseUntil > Date.now()),
|
|
204
|
-
leaseUntil: entry.leaseUntil || null,
|
|
205
|
-
};
|
|
206
|
-
if (event.type === 'manual_edit_apply') {
|
|
207
|
-
summary.pageUrl = event.pageUrl || null;
|
|
208
|
-
summary.chunk = event.chunk || null;
|
|
209
|
-
summary.repair = event.repair || null;
|
|
210
|
-
summary.evidencePath = event.evidencePath || null;
|
|
211
|
-
summary.agentAction = event.agentAction || manualApply.buildAgentAction(event);
|
|
212
|
-
summary.manualApplySummary = manualApply.summarizeEvent(event, manualApply.getDeferred(event.id)?.batch || event.batch);
|
|
213
|
-
}
|
|
214
|
-
return summary;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function summarizeActiveSessionForClient(snapshot = {}) {
|
|
218
|
-
return {
|
|
219
|
-
id: snapshot.id,
|
|
220
|
-
phase: snapshot.phase,
|
|
221
|
-
pageUrl: snapshot.pageUrl ?? null,
|
|
222
|
-
sourceFile: snapshot.sourceFile ?? null,
|
|
223
|
-
previewFile: snapshot.previewFile ?? null,
|
|
224
|
-
previewMode: snapshot.previewMode ?? null,
|
|
225
|
-
expectedVariants: snapshot.expectedVariants ?? 0,
|
|
226
|
-
arrivedVariants: snapshot.arrivedVariants ?? 0,
|
|
227
|
-
visibleVariant: snapshot.visibleVariant ?? null,
|
|
228
|
-
checkpointRevision: snapshot.checkpointRevision ?? 0,
|
|
229
|
-
paramValues: snapshot.paramValues || {},
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function activeSessionSummaries() {
|
|
234
|
-
if (!state.sessionStore) return [];
|
|
235
|
-
return state.sessionStore.listActiveSessions().map((snapshot) => summarizeActiveSessionForClient(snapshot));
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function cancelQueuedAnonymousExitEvents() {
|
|
239
|
-
let removed = 0;
|
|
240
|
-
for (let i = state.pendingEvents.length - 1; i >= 0; i -= 1) {
|
|
241
|
-
const event = state.pendingEvents[i]?.event;
|
|
242
|
-
if (event?.type !== 'exit' || event.id) continue;
|
|
243
|
-
state.pendingEvents.splice(i, 1);
|
|
244
|
-
removed += 1;
|
|
245
|
-
}
|
|
246
|
-
if (removed > 0) {
|
|
247
|
-
scheduleLeaseFlush();
|
|
248
|
-
broadcastAgentPollingIfChanged();
|
|
249
|
-
}
|
|
250
|
-
return removed;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function scheduleLeaseFlush() {
|
|
254
|
-
if (state.leaseTimer) {
|
|
255
|
-
clearTimeout(state.leaseTimer);
|
|
256
|
-
state.leaseTimer = null;
|
|
257
|
-
}
|
|
258
|
-
const now = Date.now();
|
|
259
|
-
const nextLeaseUntil = state.pendingEvents
|
|
260
|
-
.map((entry) => entry.leaseUntil || 0)
|
|
261
|
-
.filter((leaseUntil) => leaseUntil > now)
|
|
262
|
-
.sort((a, b) => a - b)[0];
|
|
263
|
-
if (!nextLeaseUntil) return;
|
|
264
|
-
state.leaseTimer = setTimeout(() => {
|
|
265
|
-
state.leaseTimer = null;
|
|
266
|
-
flushPendingPolls();
|
|
267
|
-
broadcastAgentPollingIfChanged();
|
|
268
|
-
}, Math.max(0, nextLeaseUntil - now + POLL_LEASE_EXPIRY_TIMER_GRACE_MS));
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function flushPendingPolls() {
|
|
272
|
-
let changed = false;
|
|
273
|
-
while (state.pendingPolls.length > 0) {
|
|
274
|
-
const entry = findAvailablePendingEvent();
|
|
275
|
-
if (!entry) {
|
|
276
|
-
scheduleLeaseFlush();
|
|
277
|
-
broadcastAgentPollingIfChanged();
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
const poll = state.pendingPolls.shift();
|
|
281
|
-
poll.resolve(leaseEvent(entry, poll.leaseMs));
|
|
282
|
-
changed = true;
|
|
283
|
-
}
|
|
284
|
-
scheduleLeaseFlush();
|
|
285
|
-
if (changed) broadcastAgentPollingIfChanged();
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
function agentPollingConnected() {
|
|
289
|
-
const now = Date.now();
|
|
290
|
-
return state.pendingPolls.length > 0
|
|
291
|
-
|| state.pendingEvents.some((entry) => entry.leaseUntil && entry.leaseUntil > now);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function broadcastAgentPollingIfChanged() {
|
|
295
|
-
const connected = agentPollingConnected();
|
|
296
|
-
if (state.lastAgentPollingBroadcast === connected) return;
|
|
297
|
-
state.lastAgentPollingBroadcast = connected;
|
|
298
|
-
broadcast({ type: 'agent_polling', connected });
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/** Push a message to all connected SSE clients. */
|
|
302
|
-
function broadcast(msg) {
|
|
303
|
-
const data = `data: ${JSON.stringify(msg)}\n\n`;
|
|
304
|
-
for (const res of state.sseClients) {
|
|
305
|
-
try { res.write(data); } catch { /* client gone */ }
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
function recordManualEditActivity(type, details = {}) {
|
|
310
|
-
const entry = {
|
|
311
|
-
seq: state.nextManualEditSeq++,
|
|
312
|
-
type,
|
|
313
|
-
ts: new Date().toISOString(),
|
|
314
|
-
...details,
|
|
315
|
-
};
|
|
316
|
-
state.manualEditActivity = entry;
|
|
317
|
-
if (DEBUG_MANUAL_EDIT_EVENTS) {
|
|
318
|
-
try {
|
|
319
|
-
const filePath = path.join(getLiveDir(process.cwd()), 'manual-edit-events.jsonl');
|
|
320
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
321
|
-
fs.appendFileSync(filePath, `${JSON.stringify(entry)}\n`);
|
|
322
|
-
} catch {
|
|
323
|
-
/* diagnostics are best-effort; never block live mode on observability */
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
broadcast(entry);
|
|
327
|
-
return entry;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
function getManualEditStatus() {
|
|
331
|
-
try {
|
|
332
|
-
const { totalCount, perPage } = countPendingByPage(process.cwd());
|
|
333
|
-
return { totalCount, perPage, lastActivity: state.manualEditActivity };
|
|
334
|
-
} catch (err) {
|
|
335
|
-
return {
|
|
336
|
-
totalCount: null,
|
|
337
|
-
perPage: {},
|
|
338
|
-
lastActivity: state.manualEditActivity,
|
|
339
|
-
error: err.message,
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// ---------------------------------------------------------------------------
|
|
345
|
-
// Load scripts
|
|
346
|
-
// ---------------------------------------------------------------------------
|
|
347
|
-
|
|
348
|
-
function loadBrowserScripts() {
|
|
349
|
-
// Detection script: prefer the skill-bundled detector, then fall back to
|
|
350
|
-
// source/npm package locations for local development and older installs.
|
|
351
|
-
// This one IS cached — detect.js rarely changes during a session.
|
|
352
|
-
const detectPaths = [
|
|
353
|
-
path.join(__dirname, 'detector', 'detect-antipatterns-browser.js'),
|
|
354
|
-
path.join(__dirname, '..', '..', 'cli', 'engine', 'detect-antipatterns-browser.js'),
|
|
355
|
-
path.join(__dirname, '..', '..', '..', '..', 'cli', 'engine', 'detect-antipatterns-browser.js'),
|
|
356
|
-
path.join(process.cwd(), 'node_modules', 'monodesign', 'cli', 'engine', 'detect-antipatterns-browser.js'),
|
|
357
|
-
];
|
|
358
|
-
let detectScript = '';
|
|
359
|
-
for (const p of detectPaths) {
|
|
360
|
-
try { detectScript = fs.readFileSync(p, 'utf-8'); break; } catch { /* try next */ }
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
// Browser script parts: DO NOT cache. Return paths so the /live.js handler
|
|
364
|
-
// can re-read every part on each request. Editing browser code during
|
|
365
|
-
// iteration should land on the next tab reload, not require a server restart.
|
|
366
|
-
const liveScriptParts = resolveLiveBrowserScriptParts(__dirname);
|
|
367
|
-
try {
|
|
368
|
-
assertLiveBrowserScriptParts(liveScriptParts);
|
|
369
|
-
} catch (err) {
|
|
370
|
-
process.stderr.write(`Error: ${err.message}\n`);
|
|
371
|
-
process.exit(1);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
return { detectScript, liveScriptParts };
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
function hasProjectContext() {
|
|
378
|
-
// PRODUCT.md carries brand voice / anti-references — that's what determines
|
|
379
|
-
// whether variants are brand-aware. DESIGN.md (visual tokens) is a separate
|
|
380
|
-
// concern, surfaced by the design panel's own empty state.
|
|
381
|
-
return !!PROJECT_CONTEXT.hasProduct;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
function statOrNull(filePath) {
|
|
385
|
-
try { return fs.statSync(filePath); } catch { return null; }
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
// Shared gate for every protected route, including /live.js (see its call
|
|
389
|
-
// site for why that one needs it too). Writes the 401 itself and returns
|
|
390
|
-
// false so callers can `if (!requireAuthQueryCred(url, res)) return;`.
|
|
391
|
-
function requireAuthQueryCred(url, res) {
|
|
392
|
-
const provided = url.searchParams.get(AUTH_QUERY_KEY);
|
|
393
|
-
const expected = state[AUTH_QUERY_KEY];
|
|
394
|
-
if (provided !== expected) {
|
|
395
|
-
res.writeHead(401);
|
|
396
|
-
res.end('Unauthorized');
|
|
397
|
-
return false;
|
|
398
|
-
}
|
|
399
|
-
return true;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// HTTP request handler
|
|
403
|
-
// ---------------------------------------------------------------------------
|
|
404
|
-
|
|
405
|
-
function createRequestHandler({ detectScript, liveScriptParts }) {
|
|
406
|
-
return (req, res) => {
|
|
407
|
-
const url = new URL(req.url, `http://localhost:${state.port}`);
|
|
408
|
-
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
409
|
-
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
|
|
410
|
-
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
|
|
411
|
-
if (req.method === 'OPTIONS') { res.writeHead(204); res.end(); return; }
|
|
412
|
-
|
|
413
|
-
const p = url.pathname;
|
|
414
|
-
|
|
415
|
-
// --- Scripts ---
|
|
416
|
-
if (p === '/live.js') {
|
|
417
|
-
// This response embeds the shared bearer credential (below) — unlike
|
|
418
|
-
// /detect.js and the vendored scripts, it must be gated the same way
|
|
419
|
-
// every OTHER protected route already is. Without this, requesting this
|
|
420
|
-
// one route defeats every other route's check: whoever fetches it walks
|
|
421
|
-
// away with the value that's supposed to distinguish the legitimate
|
|
422
|
-
// preview tab from any other page. See requireAuthQueryCred() below —
|
|
423
|
-
// callers must supply the credential the running server printed at
|
|
424
|
-
// startup (also mirrored into the live-server info file for tooling).
|
|
425
|
-
if (!requireAuthQueryCred(url, res)) return;
|
|
426
|
-
// Re-read from disk each request so edits to live-browser.js land on
|
|
427
|
-
// the next tab reload. No-store headers prevent browser caching across
|
|
428
|
-
// sessions — during iteration, a cached old script silently breaks
|
|
429
|
-
// every subsequent session.
|
|
430
|
-
let parts;
|
|
431
|
-
try {
|
|
432
|
-
parts = readLiveBrowserScriptParts(liveScriptParts);
|
|
433
|
-
} catch (err) {
|
|
434
|
-
res.writeHead(500, { 'Content-Type': 'text/plain' });
|
|
435
|
-
res.end(`Error reading live browser scripts: ${err.message}`);
|
|
436
|
-
return;
|
|
437
|
-
}
|
|
438
|
-
const body = assembleLiveBrowserScript({
|
|
439
|
-
token: state.token,
|
|
440
|
-
port: state.port,
|
|
441
|
-
vocabulary: LIVE_COMMANDS,
|
|
442
|
-
commandPrefix: MONODESIGN_COMMAND_PREFIX,
|
|
443
|
-
parts,
|
|
444
|
-
});
|
|
445
|
-
res.writeHead(200, {
|
|
446
|
-
'Content-Type': 'application/javascript',
|
|
447
|
-
'Cache-Control': 'no-store, no-cache, must-revalidate, max-age=0',
|
|
448
|
-
'Pragma': 'no-cache',
|
|
449
|
-
});
|
|
450
|
-
res.end(body);
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
if (p === '/detect.js' || p === '/') {
|
|
454
|
-
if (!detectScript) { res.writeHead(404); res.end('Not available'); return; }
|
|
455
|
-
res.writeHead(200, { 'Content-Type': 'application/javascript' });
|
|
456
|
-
res.end(detectScript);
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
// --- Vendored modern-screenshot (UMD build) ---
|
|
461
|
-
// Lazy-loaded by live.js when the user clicks Go; exposes
|
|
462
|
-
// window.modernScreenshot.domToBlob(...) for capture.
|
|
463
|
-
if (p === '/modern-screenshot.js') {
|
|
464
|
-
const vendorPath = path.join(__dirname, 'modern-screenshot.umd.js');
|
|
465
|
-
try {
|
|
466
|
-
res.writeHead(200, {
|
|
467
|
-
'Content-Type': 'application/javascript',
|
|
468
|
-
'Cache-Control': 'public, max-age=31536000, immutable',
|
|
469
|
-
});
|
|
470
|
-
res.end(fs.readFileSync(vendorPath));
|
|
471
|
-
} catch {
|
|
472
|
-
res.writeHead(404); res.end('Vendor script not found');
|
|
473
|
-
}
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// --- Annotation upload (browser → server, raw PNG body) ---
|
|
478
|
-
// Client generates the eventId, POSTs the PNG, then POSTs the generate
|
|
479
|
-
// event with screenshotPath already set. Keeps bytes out of the SSE/poll
|
|
480
|
-
// bridge and preserves the "one shot from the user's POV" UX.
|
|
481
|
-
if (p === '/annotation' && req.method === 'POST') {
|
|
482
|
-
const token = url.searchParams.get('token');
|
|
483
|
-
if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
|
|
484
|
-
const eventId = url.searchParams.get('eventId');
|
|
485
|
-
if (!eventId || !/^[A-Za-z0-9_-]{1,64}$/.test(eventId)) {
|
|
486
|
-
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
487
|
-
res.end(JSON.stringify({ error: 'Invalid eventId' }));
|
|
488
|
-
return;
|
|
489
|
-
}
|
|
490
|
-
if ((req.headers['content-type'] || '').toLowerCase() !== 'image/png') {
|
|
491
|
-
res.writeHead(415, { 'Content-Type': 'application/json' });
|
|
492
|
-
res.end(JSON.stringify({ error: 'Content-Type must be image/png' }));
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
if (!state.sessionDir) {
|
|
496
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
497
|
-
res.end(JSON.stringify({ error: 'Session dir unavailable' }));
|
|
498
|
-
return;
|
|
499
|
-
}
|
|
500
|
-
const chunks = [];
|
|
501
|
-
let total = 0;
|
|
502
|
-
let aborted = false;
|
|
503
|
-
req.on('data', (c) => {
|
|
504
|
-
if (aborted) return;
|
|
505
|
-
total += c.length;
|
|
506
|
-
if (total > MAX_ANNOTATION_BYTES) {
|
|
507
|
-
aborted = true;
|
|
508
|
-
res.writeHead(413, { 'Content-Type': 'application/json' });
|
|
509
|
-
res.end(JSON.stringify({ error: 'Payload too large' }));
|
|
510
|
-
req.destroy();
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
chunks.push(c);
|
|
514
|
-
});
|
|
515
|
-
req.on('end', () => {
|
|
516
|
-
if (aborted) return;
|
|
517
|
-
const absPath = path.join(state.sessionDir, `${eventId}.png`);
|
|
518
|
-
try {
|
|
519
|
-
fs.writeFileSync(absPath, Buffer.concat(chunks));
|
|
520
|
-
} catch (err) {
|
|
521
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
522
|
-
res.end(JSON.stringify({ error: `Write failed: ${err.message}` }));
|
|
523
|
-
return;
|
|
524
|
-
}
|
|
525
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
526
|
-
res.end(JSON.stringify({ ok: true, path: absPath }));
|
|
527
|
-
});
|
|
528
|
-
req.on('error', () => {
|
|
529
|
-
if (!aborted) {
|
|
530
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
531
|
-
res.end(JSON.stringify({ error: 'Upload failed' }));
|
|
532
|
-
}
|
|
533
|
-
});
|
|
534
|
-
return;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
// --- Health ---
|
|
538
|
-
if (p === '/status') {
|
|
539
|
-
const token = url.searchParams.get('token');
|
|
540
|
-
if (token !== state.token) { res.writeHead(401, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ error: 'Unauthorized' })); return; }
|
|
541
|
-
const sessions = activeSessionSummaries();
|
|
542
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
543
|
-
res.end(JSON.stringify({
|
|
544
|
-
status: 'ok',
|
|
545
|
-
port: state.port,
|
|
546
|
-
connectedClients: state.sseClients.size,
|
|
547
|
-
pendingEvents: state.pendingEvents.map((entry) => summarizePendingEventForStatus(entry)),
|
|
548
|
-
agentPolling: agentPollingConnected(),
|
|
549
|
-
activeSessions: sessions,
|
|
550
|
-
manualEdits: getManualEditStatus(),
|
|
551
|
-
}));
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
if (p === '/health') {
|
|
556
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
557
|
-
res.end(JSON.stringify({
|
|
558
|
-
status: 'ok', port: state.port, mode: 'variant',
|
|
559
|
-
hasProjectContext: hasProjectContext(),
|
|
560
|
-
connectedClients: state.sseClients.size,
|
|
561
|
-
}));
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
// --- Design system (unified v2 response) + raw ---
|
|
566
|
-
// /design-system.json returns both parsed DESIGN.md and .monodesign/design.json
|
|
567
|
-
// sidecar when present. Panel merges them:
|
|
568
|
-
// { present, parsed, sidecar, hasMd, hasSidecar,
|
|
569
|
-
// mdNewerThanJson, parseError?, sidecarError? }
|
|
570
|
-
// - parsed: output of parseDesignMd (frontmatter
|
|
571
|
-
// + six canonical sections) when DESIGN.md exists.
|
|
572
|
-
// - sidecar: .monodesign/design.json contents when present.
|
|
573
|
-
// Expected shape: schemaVersion 2, carrying
|
|
574
|
-
// extensions + components + narrative.
|
|
575
|
-
// /design-system/raw returns DESIGN.md markdown verbatim
|
|
576
|
-
if (p === '/design-system.json' || p === '/design-system/raw') {
|
|
577
|
-
const token = url.searchParams.get('token');
|
|
578
|
-
if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
|
|
579
|
-
|
|
580
|
-
const mdPath = DESIGN_MD_PATH;
|
|
581
|
-
const jsonPath = resolveDesignSidecarPath(process.cwd(), PROJECT_CONTEXT.designContextDir || CONTEXT_DIR) || getDesignSidecarPath(process.cwd());
|
|
582
|
-
const mdStat = statOrNull(mdPath);
|
|
583
|
-
const jsonStat = statOrNull(jsonPath);
|
|
584
|
-
|
|
585
|
-
if (p === '/design-system/raw') {
|
|
586
|
-
if (!mdStat) { res.writeHead(404); res.end('Not found'); return; }
|
|
587
|
-
res.writeHead(200, { 'Content-Type': 'text/markdown; charset=utf-8' });
|
|
588
|
-
res.end(fs.readFileSync(mdPath, 'utf-8'));
|
|
589
|
-
return;
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
if (!mdStat && !jsonStat) {
|
|
593
|
-
res.writeHead(404, { 'Content-Type': 'application/json' });
|
|
594
|
-
res.end(JSON.stringify({ present: false }));
|
|
595
|
-
return;
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
const response = {
|
|
599
|
-
present: true,
|
|
600
|
-
hasMd: !!mdStat,
|
|
601
|
-
hasSidecar: !!jsonStat,
|
|
602
|
-
mdNewerThanJson: !!(mdStat && jsonStat && mdStat.mtimeMs > jsonStat.mtimeMs + 1000),
|
|
603
|
-
};
|
|
604
|
-
|
|
605
|
-
if (mdStat) {
|
|
606
|
-
try {
|
|
607
|
-
response.parsed = parseDesignMd(fs.readFileSync(mdPath, 'utf-8'));
|
|
608
|
-
} catch (err) {
|
|
609
|
-
response.parseError = err.message;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
if (jsonStat) {
|
|
614
|
-
try {
|
|
615
|
-
response.sidecar = JSON.parse(fs.readFileSync(jsonPath, 'utf-8'));
|
|
616
|
-
} catch (err) {
|
|
617
|
-
response.sidecarError = `Failed to parse .monodesign/design.json: ${err.message}`;
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
622
|
-
res.end(JSON.stringify(response));
|
|
623
|
-
return;
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
// --- Source file (no-HMR fallback) ---
|
|
627
|
-
if (p === '/source') {
|
|
628
|
-
const token = url.searchParams.get('token');
|
|
629
|
-
if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
|
|
630
|
-
const filePath = url.searchParams.get('path');
|
|
631
|
-
if (!filePath || filePath.includes('..')) { res.writeHead(400); res.end('Bad path'); return; }
|
|
632
|
-
// Resolve symlinks on BOTH sides before comparing: a lexical prefix check
|
|
633
|
-
// (path.resolve + startsWith) can't tell a symlink that lexically resolves
|
|
634
|
-
// inside cwd from one that physically points outside it, and startsWith on
|
|
635
|
-
// its own also has no path-boundary — "/proj-evil" lexically "starts with"
|
|
636
|
-
// "/proj". realpath + path.relative closes both gaps (the same pattern
|
|
637
|
-
// already used correctly elsewhere in this package).
|
|
638
|
-
let root, absPath;
|
|
639
|
-
try {
|
|
640
|
-
root = fs.realpathSync(process.cwd());
|
|
641
|
-
absPath = fs.realpathSync(path.resolve(process.cwd(), filePath));
|
|
642
|
-
} catch { res.writeHead(404); res.end('File not found'); return; }
|
|
643
|
-
const rel = path.relative(root, absPath);
|
|
644
|
-
if (rel.startsWith('..') || path.isAbsolute(rel)) { res.writeHead(403); res.end('Forbidden'); return; }
|
|
645
|
-
let content;
|
|
646
|
-
try { content = fs.readFileSync(absPath, 'utf-8'); }
|
|
647
|
-
catch { res.writeHead(404); res.end('File not found'); return; }
|
|
648
|
-
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
|
|
649
|
-
res.end(content);
|
|
650
|
-
return;
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
// --- SSE: server→browser push (replaces WebSocket) ---
|
|
654
|
-
if (p === '/events' && req.method === 'GET') {
|
|
655
|
-
const token = url.searchParams.get('token');
|
|
656
|
-
if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
|
|
657
|
-
clearTimeout(state.exitTimer);
|
|
658
|
-
state.exitTimer = null;
|
|
659
|
-
cancelQueuedAnonymousExitEvents();
|
|
660
|
-
res.writeHead(200, {
|
|
661
|
-
'Content-Type': 'text/event-stream',
|
|
662
|
-
'Cache-Control': 'no-cache',
|
|
663
|
-
'Connection': 'keep-alive',
|
|
664
|
-
});
|
|
665
|
-
res.write(`data: ${JSON.stringify({
|
|
666
|
-
type: 'connected',
|
|
667
|
-
hasProjectContext: hasProjectContext(),
|
|
668
|
-
agentPolling: agentPollingConnected(),
|
|
669
|
-
activeSessions: activeSessionSummaries(),
|
|
670
|
-
})}\n\n`);
|
|
671
|
-
|
|
672
|
-
state.sseClients.add(res);
|
|
673
|
-
|
|
674
|
-
// Keepalive: SSE comment every 30s prevents silent connection drops.
|
|
675
|
-
const heartbeat = setInterval(() => {
|
|
676
|
-
try { res.write(': keepalive\n\n'); } catch { clearInterval(heartbeat); }
|
|
677
|
-
}, SSE_HEARTBEAT_INTERVAL);
|
|
678
|
-
|
|
679
|
-
req.on('close', () => {
|
|
680
|
-
clearInterval(heartbeat);
|
|
681
|
-
state.sseClients.delete(res);
|
|
682
|
-
if (state.sseClients.size === 0) {
|
|
683
|
-
clearTimeout(state.exitTimer);
|
|
684
|
-
state.exitTimer = setTimeout(() => {
|
|
685
|
-
if (state.sseClients.size === 0) enqueueEvent({ type: 'exit' });
|
|
686
|
-
}, 8000);
|
|
687
|
-
}
|
|
688
|
-
});
|
|
689
|
-
return;
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
if (manualEditRoutes(req, res, url)) return;
|
|
693
|
-
|
|
694
|
-
// --- Browser→server events (replaces WebSocket messages) ---
|
|
695
|
-
if (p === '/events' && req.method === 'POST') {
|
|
696
|
-
let body = '';
|
|
697
|
-
req.on('data', (c) => { body += c; });
|
|
698
|
-
req.on('end', () => {
|
|
699
|
-
let msg;
|
|
700
|
-
try { msg = JSON.parse(body); } catch {
|
|
701
|
-
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
702
|
-
res.end(JSON.stringify({ error: 'Invalid JSON' }));
|
|
703
|
-
return;
|
|
704
|
-
}
|
|
705
|
-
if (msg.token !== state.token) {
|
|
706
|
-
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
707
|
-
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
// Defense in depth: manual copy edits must use the staged stash/apply
|
|
711
|
-
// endpoints. The direct Save event path is disabled in the browser.
|
|
712
|
-
if (msg.type === 'manual_edits') {
|
|
713
|
-
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
714
|
-
res.end(JSON.stringify({ error: 'manual_edits must POST to /manual-edit-stash, not /events' }));
|
|
715
|
-
return;
|
|
716
|
-
}
|
|
717
|
-
if (msg.type === 'manual_edit_apply') {
|
|
718
|
-
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
719
|
-
res.end(JSON.stringify({ error: 'manual_edit_apply is disabled; use /manual-edit-stash then /manual-edit-commit' }));
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
const error = validateEvent(msg);
|
|
723
|
-
if (error) {
|
|
724
|
-
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
725
|
-
res.end(JSON.stringify({ error }));
|
|
726
|
-
return;
|
|
727
|
-
}
|
|
728
|
-
if (state.sessionStore && msg.id) {
|
|
729
|
-
try {
|
|
730
|
-
state.sessionStore.appendEvent(msg);
|
|
731
|
-
} catch (err) {
|
|
732
|
-
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
733
|
-
res.end(JSON.stringify({ error: 'session_store_append_failed', message: err.message }));
|
|
734
|
-
return;
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
if (msg.type === 'exit') {
|
|
738
|
-
cleanupSvelteComponentSessionsBeforeExit();
|
|
739
|
-
}
|
|
740
|
-
if (msg.type !== 'checkpoint') {
|
|
741
|
-
enqueueEvent(msg);
|
|
742
|
-
}
|
|
743
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
744
|
-
res.end(JSON.stringify({ ok: true }));
|
|
745
|
-
});
|
|
746
|
-
return;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
// --- Stop ---
|
|
750
|
-
if (p === '/stop') {
|
|
751
|
-
const token = url.searchParams.get('token');
|
|
752
|
-
if (token !== state.token) { res.writeHead(401); res.end('Unauthorized'); return; }
|
|
753
|
-
res.writeHead(200, { 'Content-Type': 'text/plain' });
|
|
754
|
-
res.end('stopping');
|
|
755
|
-
shutdown();
|
|
756
|
-
return;
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
// --- Agent poll ---
|
|
760
|
-
if (p === '/poll' && req.method === 'GET') {
|
|
761
|
-
handlePollGet(req, res, url);
|
|
762
|
-
return;
|
|
763
|
-
}
|
|
764
|
-
if (p === '/poll' && req.method === 'POST') {
|
|
765
|
-
handlePollPost(req, res);
|
|
766
|
-
return;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
res.writeHead(404); res.end('Not found');
|
|
770
|
-
};
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
// ---------------------------------------------------------------------------
|
|
774
|
-
// Agent poll endpoints (unchanged from WS version)
|
|
775
|
-
// ---------------------------------------------------------------------------
|
|
776
|
-
|
|
777
|
-
function handlePollGet(req, res, url) {
|
|
778
|
-
const token = url.searchParams.get('token');
|
|
779
|
-
if (token !== state.token) {
|
|
780
|
-
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
781
|
-
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
782
|
-
return;
|
|
783
|
-
}
|
|
784
|
-
state.lastPollAt = Date.now();
|
|
785
|
-
const timeout = parseInt(url.searchParams.get('timeout') || DEFAULT_POLL_TIMEOUT, 10);
|
|
786
|
-
const leaseMs = parseInt(url.searchParams.get('leaseMs') || '30000', 10);
|
|
787
|
-
const available = findAvailablePendingEvent();
|
|
788
|
-
if (available) {
|
|
789
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
790
|
-
res.end(JSON.stringify(leaseEvent(available, leaseMs)));
|
|
791
|
-
return;
|
|
792
|
-
}
|
|
793
|
-
const poll = { resolve, leaseMs };
|
|
794
|
-
const timer = setTimeout(() => {
|
|
795
|
-
const idx = state.pendingPolls.indexOf(poll);
|
|
796
|
-
if (idx !== -1) state.pendingPolls.splice(idx, 1);
|
|
797
|
-
broadcastAgentPollingIfChanged();
|
|
798
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
799
|
-
res.end(JSON.stringify({ type: 'timeout' }));
|
|
800
|
-
}, timeout);
|
|
801
|
-
function resolve(event) {
|
|
802
|
-
clearTimeout(timer);
|
|
803
|
-
state.lastPollAt = Date.now();
|
|
804
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
805
|
-
res.end(JSON.stringify(event));
|
|
806
|
-
}
|
|
807
|
-
state.pendingPolls.push(poll);
|
|
808
|
-
broadcastAgentPollingIfChanged();
|
|
809
|
-
scheduleLeaseFlush();
|
|
810
|
-
req.on('close', () => {
|
|
811
|
-
clearTimeout(timer);
|
|
812
|
-
const idx = state.pendingPolls.indexOf(poll);
|
|
813
|
-
if (idx !== -1) state.pendingPolls.splice(idx, 1);
|
|
814
|
-
broadcastAgentPollingIfChanged();
|
|
815
|
-
});
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
function sessionFileMetadataFromPollReply(file) {
|
|
819
|
-
if (!file || typeof file !== 'string') return { file };
|
|
820
|
-
const normalized = file.split(path.sep).join('/');
|
|
821
|
-
const base = { file: normalized };
|
|
822
|
-
if (!normalized.endsWith('/manifest.json') && normalized !== 'manifest.json') return base;
|
|
823
|
-
if (!normalized.includes('node_modules/.monodesign-live/') && !normalized.includes('src/lib/monodesign/')) return base;
|
|
824
|
-
|
|
825
|
-
let full;
|
|
826
|
-
try {
|
|
827
|
-
full = path.resolve(process.cwd(), normalized);
|
|
828
|
-
const rel = path.relative(process.cwd(), full).split(path.sep).join('/');
|
|
829
|
-
if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) return base;
|
|
830
|
-
} catch {
|
|
831
|
-
return base;
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
try {
|
|
835
|
-
const manifest = JSON.parse(fs.readFileSync(full, 'utf-8'));
|
|
836
|
-
if (manifest?.previewMode !== 'svelte-component' || !manifest.sourceFile) return base;
|
|
837
|
-
return {
|
|
838
|
-
file: String(manifest.sourceFile).split(path.sep).join('/'),
|
|
839
|
-
sourceFile: String(manifest.sourceFile).split(path.sep).join('/'),
|
|
840
|
-
previewFile: normalized,
|
|
841
|
-
previewMode: 'svelte-component',
|
|
842
|
-
};
|
|
843
|
-
} catch {
|
|
844
|
-
return base;
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
function handlePollPost(req, res) {
|
|
849
|
-
let body = '';
|
|
850
|
-
req.on('data', (c) => { body += c; });
|
|
851
|
-
req.on('end', () => {
|
|
852
|
-
let msg;
|
|
853
|
-
try { msg = JSON.parse(body); } catch {
|
|
854
|
-
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
855
|
-
res.end(JSON.stringify({ error: 'Invalid JSON' }));
|
|
856
|
-
return;
|
|
857
|
-
}
|
|
858
|
-
if (msg.token !== state.token) {
|
|
859
|
-
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
860
|
-
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
861
|
-
return;
|
|
862
|
-
}
|
|
863
|
-
const pendingApplyDeferred = manualApply.getDeferred(msg.id);
|
|
864
|
-
if (pendingApplyDeferred) {
|
|
865
|
-
const validation = manualApply.validateResultMessage(msg, pendingApplyDeferred);
|
|
866
|
-
if (!validation.ok) {
|
|
867
|
-
recordManualEditActivity('manual_edit_apply_reply_invalid', {
|
|
868
|
-
id: msg.id,
|
|
869
|
-
pageUrl: pendingApplyDeferred.pageUrl,
|
|
870
|
-
chunk: pendingApplyDeferred.event?.chunk || null,
|
|
871
|
-
repair: pendingApplyDeferred.event?.repair || null,
|
|
872
|
-
reason: validation.body?.reason || validation.body?.error || 'invalid_manual_apply_result',
|
|
873
|
-
status: msg.data?.status || null,
|
|
874
|
-
});
|
|
875
|
-
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
876
|
-
res.end(JSON.stringify(validation.body));
|
|
877
|
-
return;
|
|
878
|
-
}
|
|
879
|
-
recordManualEditActivity('manual_edit_apply_reply_received', {
|
|
880
|
-
id: msg.id,
|
|
881
|
-
pageUrl: pendingApplyDeferred.pageUrl,
|
|
882
|
-
chunk: pendingApplyDeferred.event?.chunk || null,
|
|
883
|
-
repair: pendingApplyDeferred.event?.repair || null,
|
|
884
|
-
status: validation.result.status,
|
|
885
|
-
appliedCount: validation.result.appliedEntryIds.length,
|
|
886
|
-
failed: summarizeManualApplyFailures(validation.result.failed),
|
|
887
|
-
fileCount: validation.result.files.length,
|
|
888
|
-
noteCount: validation.result.notes.length,
|
|
889
|
-
});
|
|
890
|
-
manualApply.resolveDeferred(msg.id, validation.result);
|
|
891
|
-
acknowledgePendingEvent(msg.id);
|
|
892
|
-
flushPendingPolls();
|
|
893
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
894
|
-
res.end(JSON.stringify({ ok: true }));
|
|
895
|
-
return;
|
|
896
|
-
}
|
|
897
|
-
if (manualApply.hasTimedOutId(msg.id)) {
|
|
898
|
-
const rollback = manualApply.rollbackTimedOutReply(msg);
|
|
899
|
-
recordManualEditActivity('manual_edit_apply_stale_reply_rejected', {
|
|
900
|
-
id: msg.id,
|
|
901
|
-
rolledBackFileCount: rollback.rolledBackFiles?.length || 0,
|
|
902
|
-
rollbackFailureCount: rollback.rollbackFailures?.length || 0,
|
|
903
|
-
});
|
|
904
|
-
res.writeHead(409, { 'Content-Type': 'application/json' });
|
|
905
|
-
res.end(JSON.stringify({ error: 'stale_manual_edit_apply_reply', ...rollback }));
|
|
906
|
-
return;
|
|
907
|
-
}
|
|
908
|
-
const pendingEventBeforeAck = findPendingEventById(msg.id);
|
|
909
|
-
if (pendingEventBeforeAck?.type === 'steer' && msg.type === 'steer_done'
|
|
910
|
-
&& !msg.file && !(typeof msg.message === 'string' && msg.message.trim())) {
|
|
911
|
-
res.writeHead(400, { 'Content-Type': 'application/json' });
|
|
912
|
-
res.end(JSON.stringify({
|
|
913
|
-
error: 'steer_done_requires_file_or_message',
|
|
914
|
-
hint: 'Reply with --file after writing source, or include a message explaining an intentional no-op.',
|
|
915
|
-
}));
|
|
916
|
-
return;
|
|
917
|
-
}
|
|
918
|
-
const acknowledgedEvent = acknowledgePendingEvent(msg.id);
|
|
919
|
-
let skipJournalReply = false;
|
|
920
|
-
let existingSession = null;
|
|
921
|
-
if (!acknowledgedEvent && state.sessionStore && msg.id) {
|
|
922
|
-
try {
|
|
923
|
-
existingSession = state.sessionStore.getSnapshot(msg.id, { includeCompleted: true });
|
|
924
|
-
if (!existingSession?.updatedAt) existingSession = null;
|
|
925
|
-
skipJournalReply = existingSession?.phase === 'completed' || existingSession?.phase === 'discarded';
|
|
926
|
-
} catch { /* fall through and record the reply normally */ }
|
|
927
|
-
}
|
|
928
|
-
if (!acknowledgedEvent && !existingSession) {
|
|
929
|
-
recordManualEditActivity('manual_edit_poll_reply_unknown', {
|
|
930
|
-
id: msg.id || null,
|
|
931
|
-
type: msg.type || null,
|
|
932
|
-
});
|
|
933
|
-
res.writeHead(msg.id ? 404 : 400, { 'Content-Type': 'application/json' });
|
|
934
|
-
res.end(JSON.stringify({
|
|
935
|
-
error: msg.id ? 'unknown_poll_reply_id' : 'missing_poll_reply_id',
|
|
936
|
-
id: msg.id,
|
|
937
|
-
}));
|
|
938
|
-
return;
|
|
939
|
-
}
|
|
940
|
-
const replyFileMeta = sessionFileMetadataFromPollReply(msg.file);
|
|
941
|
-
if (state.sessionStore && msg.id && !skipJournalReply) {
|
|
942
|
-
try {
|
|
943
|
-
const eventType = msg.type === 'steer_done'
|
|
944
|
-
? 'steer_done'
|
|
945
|
-
: msg.type === 'discard' || msg.type === 'discarded'
|
|
946
|
-
? 'discarded'
|
|
947
|
-
: msg.type === 'complete'
|
|
948
|
-
? 'complete'
|
|
949
|
-
: msg.type === 'error'
|
|
950
|
-
? 'agent_error'
|
|
951
|
-
: 'agent_done';
|
|
952
|
-
state.sessionStore.appendEvent({
|
|
953
|
-
type: eventType,
|
|
954
|
-
id: msg.id,
|
|
955
|
-
file: replyFileMeta.file,
|
|
956
|
-
sourceFile: replyFileMeta.sourceFile,
|
|
957
|
-
previewFile: replyFileMeta.previewFile,
|
|
958
|
-
previewMode: replyFileMeta.previewMode,
|
|
959
|
-
message: msg.message,
|
|
960
|
-
sourceEventType: acknowledgedEvent?.type,
|
|
961
|
-
carbonize: msg.data?.carbonize === true,
|
|
962
|
-
});
|
|
963
|
-
} catch { /* keep reply path best-effort; browser still needs SSE */ }
|
|
964
|
-
}
|
|
965
|
-
flushPendingPolls();
|
|
966
|
-
// Forward the reply to the browser via SSE
|
|
967
|
-
broadcast({
|
|
968
|
-
type: msg.type || 'done',
|
|
969
|
-
id: msg.id,
|
|
970
|
-
message: msg.message,
|
|
971
|
-
file: msg.file,
|
|
972
|
-
sourceFile: replyFileMeta.sourceFile,
|
|
973
|
-
previewFile: replyFileMeta.previewFile,
|
|
974
|
-
previewMode: replyFileMeta.previewMode,
|
|
975
|
-
data: msg.data,
|
|
976
|
-
});
|
|
977
|
-
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
978
|
-
res.end(JSON.stringify({ ok: true }));
|
|
979
|
-
});
|
|
980
|
-
}
|
|
981
|
-
|
|
982
|
-
// ---------------------------------------------------------------------------
|
|
983
|
-
// Lifecycle
|
|
984
|
-
// ---------------------------------------------------------------------------
|
|
985
|
-
|
|
986
|
-
let httpServer = null;
|
|
987
|
-
|
|
988
|
-
function shutdown() {
|
|
989
|
-
cleanupSvelteComponentSessionsBeforeExit();
|
|
990
|
-
removeLiveServerInfo(process.cwd());
|
|
991
|
-
if (state.leaseTimer) clearTimeout(state.leaseTimer);
|
|
992
|
-
state.leaseTimer = null;
|
|
993
|
-
if (state.sessionDir) {
|
|
994
|
-
try { fs.rmSync(state.sessionDir, { recursive: true, force: true }); } catch {}
|
|
995
|
-
}
|
|
996
|
-
for (const res of state.sseClients) { try { res.end(); } catch {} }
|
|
997
|
-
state.sseClients.clear();
|
|
998
|
-
for (const poll of state.pendingPolls) poll.resolve({ type: 'exit' });
|
|
999
|
-
state.pendingPolls.length = 0;
|
|
1000
|
-
if (httpServer) httpServer.close();
|
|
1001
|
-
process.exit(0);
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
|
-
function cleanupSvelteComponentSessionsBeforeExit() {
|
|
1005
|
-
try {
|
|
1006
|
-
removeAllSvelteComponentSessions(process.cwd());
|
|
1007
|
-
} catch (err) {
|
|
1008
|
-
console.warn('[monodesign] Svelte component session cleanup failed:', err.message);
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
function applyLegacyDeferredAcceptsOnStartup() {
|
|
1013
|
-
try {
|
|
1014
|
-
const result = applyDeferredSvelteComponentAccepts(process.cwd());
|
|
1015
|
-
if (result.applied > 0 || result.failed > 0) {
|
|
1016
|
-
console.log('[monodesign] applied legacy deferred Svelte component accepts:', JSON.stringify(result));
|
|
1017
|
-
}
|
|
1018
|
-
} catch (err) {
|
|
1019
|
-
console.warn('[monodesign] legacy deferred Svelte component accept apply failed:', err.message);
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
// ---------------------------------------------------------------------------
|
|
1024
|
-
// Main
|
|
1025
|
-
// ---------------------------------------------------------------------------
|
|
1026
|
-
|
|
1027
|
-
const args = process.argv.slice(2);
|
|
1028
|
-
|
|
1029
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
1030
|
-
console.log(`Usage: node live-server.mjs [options]
|
|
1031
|
-
|
|
1032
|
-
Start the live variant mode server (zero dependencies).
|
|
1033
|
-
|
|
1034
|
-
Commands:
|
|
1035
|
-
(default) Start the server (foreground)
|
|
1036
|
-
stop Stop the server and remove the injected live.js script tag
|
|
1037
|
-
stop --keep-inject Stop the server only (leave the script tag in the HTML entry)
|
|
1038
|
-
|
|
1039
|
-
Options:
|
|
1040
|
-
--background Start detached, print connection JSON to stdout, then exit
|
|
1041
|
-
--port=PORT Use a specific port (default: auto-detect starting at 8400)
|
|
1042
|
-
--keep-inject Only with stop: skip live-inject.mjs --remove
|
|
1043
|
-
--help Show this help
|
|
1044
|
-
|
|
1045
|
-
Endpoints:
|
|
1046
|
-
/live.js Browser script (element picker + variant cycling)
|
|
1047
|
-
/detect.js Detection overlay (backwards compatible)
|
|
1048
|
-
/modern-screenshot.js Vendored modern-screenshot UMD build (lazy-loaded by live.js)
|
|
1049
|
-
/annotation POST raw image/png to stage a variant screenshot
|
|
1050
|
-
/events SSE stream (server→browser) + POST (browser→server)
|
|
1051
|
-
/poll Long-poll for agent CLI
|
|
1052
|
-
/manual-edit-stash Stage browser copy edits
|
|
1053
|
-
/manual-edit-commit Apply staged browser copy edits
|
|
1054
|
-
/manual-edit-discard Discard staged browser copy edits
|
|
1055
|
-
/source Raw source file reader (no-HMR fallback)
|
|
1056
|
-
/status Durable recovery status (token-protected)
|
|
1057
|
-
/health Health check`);
|
|
1058
|
-
process.exit(0);
|
|
1059
|
-
}
|
|
1060
|
-
|
|
1061
|
-
if (args.includes('stop')) {
|
|
1062
|
-
const keepInject = args.includes('--keep-inject');
|
|
1063
|
-
try {
|
|
1064
|
-
const { info } = readLiveServerInfo(process.cwd()) || {};
|
|
1065
|
-
const res = await fetch(`http://localhost:${info.port}/stop?token=${info.token}`);
|
|
1066
|
-
if (res.ok) console.log(`Stopped live server on port ${info.port}.`);
|
|
1067
|
-
} catch {
|
|
1068
|
-
console.log('No running live server found.');
|
|
1069
|
-
}
|
|
1070
|
-
if (!keepInject) {
|
|
1071
|
-
const injectPath = path.join(__dirname, 'live-inject.mjs');
|
|
1072
|
-
try {
|
|
1073
|
-
const out = execFileSync(process.execPath, [injectPath, '--remove'], {
|
|
1074
|
-
encoding: 'utf-8',
|
|
1075
|
-
cwd: process.cwd(),
|
|
1076
|
-
});
|
|
1077
|
-
const line = out.trim().split('\n').filter(Boolean).pop();
|
|
1078
|
-
if (line) {
|
|
1079
|
-
try {
|
|
1080
|
-
const j = JSON.parse(line);
|
|
1081
|
-
if (j.removed === true) {
|
|
1082
|
-
console.log(`Removed live script tag from ${j.file}.`);
|
|
1083
|
-
}
|
|
1084
|
-
} catch {
|
|
1085
|
-
/* ignore non-JSON lines */
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
} catch (err) {
|
|
1089
|
-
const detail = err.stderr?.toString?.().trim?.()
|
|
1090
|
-
|| err.stdout?.toString?.().trim?.()
|
|
1091
|
-
|| err.message
|
|
1092
|
-
|| String(err);
|
|
1093
|
-
console.warn(`Note: could not remove live script tag (${detail.split('\n')[0]})`);
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
process.exit(0);
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
// --background: spawn a detached child server, wait for it to be ready,
|
|
1100
|
-
// print the connection JSON, then exit. This keeps the startup command
|
|
1101
|
-
// simple (no shell backgrounding or chained commands).
|
|
1102
|
-
if (args.includes('--background')) {
|
|
1103
|
-
const childArgs = args.filter(a => a !== '--background');
|
|
1104
|
-
const child = spawn(process.execPath, [fileURLToPath(import.meta.url), ...childArgs], {
|
|
1105
|
-
detached: true,
|
|
1106
|
-
stdio: 'ignore',
|
|
1107
|
-
cwd: process.cwd(),
|
|
1108
|
-
});
|
|
1109
|
-
child.unref();
|
|
1110
|
-
|
|
1111
|
-
// Poll for the PID file (the child writes it once the HTTP server is listening).
|
|
1112
|
-
const deadline = Date.now() + 10_000;
|
|
1113
|
-
while (Date.now() < deadline) {
|
|
1114
|
-
try {
|
|
1115
|
-
const { info } = readLiveServerInfo(process.cwd()) || {};
|
|
1116
|
-
if (info.pid !== process.pid) {
|
|
1117
|
-
// Output JSON so the agent can read port + token from stdout.
|
|
1118
|
-
console.log(JSON.stringify(info));
|
|
1119
|
-
process.exit(0);
|
|
1120
|
-
}
|
|
1121
|
-
} catch { /* not ready yet */ }
|
|
1122
|
-
await new Promise(r => setTimeout(r, 200));
|
|
1123
|
-
}
|
|
1124
|
-
console.error('Timed out waiting for live server to start.');
|
|
1125
|
-
process.exit(1);
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
// Check for existing session
|
|
1129
|
-
const existingRecord = readLiveServerInfo(process.cwd());
|
|
1130
|
-
if (existingRecord?.info) {
|
|
1131
|
-
const existing = existingRecord.info;
|
|
1132
|
-
try {
|
|
1133
|
-
process.kill(existing.pid, 0);
|
|
1134
|
-
console.error(`Live server already running on port ${existing.port} (pid ${existing.pid}).`);
|
|
1135
|
-
console.error(`Stop it first with: node ${path.basename(fileURLToPath(import.meta.url))} stop`);
|
|
1136
|
-
process.exit(1);
|
|
1137
|
-
} catch {
|
|
1138
|
-
try { fs.unlinkSync(existingRecord.path); } catch {}
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
state.token = randomUUID();
|
|
1143
|
-
state.sessionStore = createLiveSessionStore({ cwd: process.cwd() });
|
|
1144
|
-
manualApply.rollbackTransaction({
|
|
1145
|
-
reason: 'manual_edit_server_start_recovered_abandoned_transaction',
|
|
1146
|
-
});
|
|
1147
|
-
applyLegacyDeferredAcceptsOnStartup();
|
|
1148
|
-
restorePendingEventsFromStore();
|
|
1149
|
-
manualApply.pruneStaleEvidence();
|
|
1150
|
-
const portArg = args.find(a => a.startsWith('--port='));
|
|
1151
|
-
const explicitPort = portArg ? parseInt(portArg.split('=')[1], 10) : null;
|
|
1152
|
-
state.port = explicitPort ?? await findOpenPort();
|
|
1153
|
-
// Annotation screenshots live in the project root so the agent's Read tool
|
|
1154
|
-
// doesn't trip a per-file permission prompt. Sessioned by token so concurrent
|
|
1155
|
-
// projects (or quick restarts) don't collide.
|
|
1156
|
-
const annotRoot = getLiveAnnotationsDir(process.cwd());
|
|
1157
|
-
fs.mkdirSync(annotRoot, { recursive: true });
|
|
1158
|
-
state.sessionDir = fs.mkdtempSync(path.join(annotRoot, 'session-'));
|
|
1159
|
-
|
|
1160
|
-
const { detectScript, liveScriptParts } = loadBrowserScripts();
|
|
1161
|
-
httpServer = http.createServer(createRequestHandler({ detectScript, liveScriptParts }));
|
|
1162
|
-
|
|
1163
|
-
// findOpenPort() probes a port, closes the probe socket, and only then does the
|
|
1164
|
-
// real server bind it. Another process scanning the same range can take the
|
|
1165
|
-
// port inside that gap, which surfaced as an intermittent
|
|
1166
|
-
// "EADDRINUSE 127.0.0.1:8405" — about one run in five of the test suite, where
|
|
1167
|
-
// several server-starting test files run in parallel.
|
|
1168
|
-
//
|
|
1169
|
-
// Retry on the next port when we picked it ourselves. An explicit --port is
|
|
1170
|
-
// never silently moved: the caller asked for that port, so a conflict there
|
|
1171
|
-
// must be an error they can see.
|
|
1172
|
-
const MAX_PORT_RETRIES = 25;
|
|
1173
|
-
let portRetries = 0;
|
|
1174
|
-
|
|
1175
|
-
httpServer.on('error', (err) => {
|
|
1176
|
-
if (err?.code !== 'EADDRINUSE') throw err;
|
|
1177
|
-
|
|
1178
|
-
if (explicitPort !== null) {
|
|
1179
|
-
console.error(`\nPort ${state.port} is already in use.`);
|
|
1180
|
-
console.error('Another live server may be running — stop it, or pass a different --port.');
|
|
1181
|
-
process.exit(1);
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
|
-
if (portRetries >= MAX_PORT_RETRIES) {
|
|
1185
|
-
console.error(`\nCould not find a free port after ${MAX_PORT_RETRIES} attempts (last tried ${state.port}).`);
|
|
1186
|
-
process.exit(1);
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
portRetries++;
|
|
1190
|
-
state.port++;
|
|
1191
|
-
httpServer.listen(state.port, '127.0.0.1');
|
|
1192
|
-
});
|
|
1193
|
-
|
|
1194
|
-
httpServer.listen(state.port, '127.0.0.1', () => {
|
|
1195
|
-
// Trust the address the OS actually bound over the one we asked for — after
|
|
1196
|
-
// a retry above, state.port and the bound port must not drift apart.
|
|
1197
|
-
const boundAddr = httpServer.address();
|
|
1198
|
-
if (boundAddr && typeof boundAddr === 'object') state.port = boundAddr.port;
|
|
1199
|
-
|
|
1200
|
-
writeLiveServerInfo(process.cwd(), { pid: process.pid, port: state.port, token: state.token });
|
|
1201
|
-
const url = `http://localhost:${state.port}`;
|
|
1202
|
-
console.log(`\nMonodesign live server running on ${url}`);
|
|
1203
|
-
console.log(`Token: ${state.token}\n`);
|
|
1204
|
-
console.log(`Script: ${url}/live.js`);
|
|
1205
|
-
console.log('Inject: managed by live-inject.mjs; Astro source tags use is:inline automatically.');
|
|
1206
|
-
console.log(`Stop: node ${path.basename(fileURLToPath(import.meta.url))} stop`);
|
|
1207
|
-
});
|
|
1208
|
-
|
|
1209
|
-
process.on('SIGINT', shutdown);
|
|
1210
|
-
process.on('SIGTERM', shutdown);
|