@bonesofspring/ai-rules 0.2.67 → 0.2.68
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/CHANGELOG.md +50 -0
- package/README.md +4 -4
- package/bin/lib/engine-scripts.js +3 -6
- package/bin/lib/seed-ai-local-team.js +1 -1
- package/docs/PRESET-CONTRIBUTION.md +15 -8
- package/docs/TEAM-DB.md +105 -105
- package/docs/TOKEN-ECONOMY.md +4 -2
- package/docs/openapi/team-db.v1.json +3905 -1466
- package/package.json +4 -4
- package/presets/_shared/ai-local/scripts/processes.mjs +467 -55
- package/presets/_shared/ai-local/scripts/team-db-api.mjs +564 -10
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +816 -47
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +659 -5
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +135 -0
- package/presets/_shared/ai-local/scripts/team-db-task-runner.mjs +11 -6
- package/presets/_shared/ai-local/scripts/team-db.mjs +16 -54
- package/presets/_shared/core/agent-team/agent-team-orchestrator.md +5 -5
- package/presets/_shared/core/architecture/feature-delivery-workflow.md +3 -7
- package/presets/_shared/core/meta/preset-pr-checklist.md +2 -2
- package/presets/_shared/core/quality/code-quality-and-refactoring.md +2 -6
- package/presets/_shared/core/quality/verification-before-completion.md +20 -3
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +12 -3
- package/presets/claude/android-kotlin/REPO_AGENTS.md +7 -47
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +12 -3
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/android-kotlin/rules/tooling-and-review/code-quality.md +2 -6
- package/presets/claude/android-kotlin/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/go/REPO_AGENTS.md +7 -47
- package/presets/claude/go/hooks/chain-team-phases.sh +12 -3
- package/presets/claude/go/rules/architecture/feature-delivery.md +3 -7
- package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/go/rules/tooling-and-review/code-quality.md +2 -6
- package/presets/claude/go/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/ios-swift/REPO_AGENTS.md +7 -47
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +12 -3
- package/presets/claude/ios-swift/rules/architecture/feature-delivery.md +3 -7
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/ios-swift/rules/tooling-and-review/code-quality.md +2 -6
- package/presets/claude/ios-swift/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/java/REPO_AGENTS.md +7 -47
- package/presets/claude/java/hooks/chain-team-phases.sh +12 -3
- package/presets/claude/java/rules/architecture/feature-delivery.md +3 -7
- package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/java/rules/tooling-and-review/code-quality.md +2 -6
- package/presets/claude/java/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/mcp-ts/REPO_AGENTS.md +7 -47
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +12 -3
- package/presets/claude/mcp-ts/rules/architecture/feature-delivery.md +3 -7
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/mcp-ts/rules/tooling-and-review/code-quality.md +2 -6
- package/presets/claude/mcp-ts/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/mol/REPO_AGENTS.md +9 -49
- package/presets/claude/mol/hooks/chain-team-phases.sh +12 -3
- package/presets/claude/mol/rules/architecture/feature-delivery-workflow.md +3 -7
- package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/mol/rules/tooling-and-review/code-quality.md +2 -6
- package/presets/claude/mol/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/next/REPO_AGENTS.md +10 -50
- package/presets/claude/next/agents/accessibility-reviewer.md +0 -1
- package/presets/claude/next/agents/api-contract-reviewer.md +0 -1
- package/presets/claude/next/agents/build-verifier.md +12 -8
- package/presets/claude/next/agents/code-reviewer.md +1 -1
- package/presets/claude/next/agents/codebase-analyzer.md +0 -1
- package/presets/claude/next/agents/feature-developer.md +6 -6
- package/presets/claude/next/agents/migration-specialist.md +0 -1
- package/presets/claude/next/agents/mockup-reviewer.md +0 -1
- package/presets/claude/next/agents/openspec-author.md +0 -1
- package/presets/claude/next/agents/performance-auditor.md +0 -1
- package/presets/claude/next/agents/playwright-test-generator.md +0 -1
- package/presets/claude/next/agents/playwright-test-healer.md +0 -1
- package/presets/claude/next/agents/playwright-test-planner.md +0 -1
- package/presets/claude/next/agents/qa-tester.md +3 -3
- package/presets/claude/next/agents/security-reviewer.md +0 -1
- package/presets/claude/next/agents/solution-architect.md +0 -1
- package/presets/claude/next/agents/task-analyst.md +0 -1
- package/presets/claude/next/agents/task-router.md +8 -7
- package/presets/claude/next/agents/tech-writer.md +0 -1
- package/presets/claude/next/agents/unit-test-generator.md +0 -1
- package/presets/claude/next/agents/unit-test-healer.md +0 -1
- package/presets/claude/next/agents/unit-test-planner.md +0 -1
- package/presets/claude/next/commands/README.md +0 -6
- package/presets/claude/next/hooks/chain-team-phases.sh +12 -3
- package/presets/claude/next/rules/architecture/feature-delivery-workflow.md +5 -9
- package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/next/rules/tooling-and-review/code-quality.md +2 -6
- package/presets/claude/next/rules/tooling-and-review/post-change-lint.md +12 -16
- package/presets/claude/next/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/next/skills/feature-delivery/SKILL.md +1 -1
- package/presets/claude/next/skills/playwright-e2e/SKILL.md +1 -1
- package/presets/claude/next/skills/unit-testing/SKILL.md +1 -1
- package/presets/claude/nuxt/REPO_AGENTS.md +8 -48
- package/presets/claude/nuxt/agents/accessibility-reviewer.md +0 -1
- package/presets/claude/nuxt/agents/api-contract-reviewer.md +0 -1
- package/presets/claude/nuxt/agents/build-verifier.md +5 -3
- package/presets/claude/nuxt/agents/ci-investigator.md +1 -1
- package/presets/claude/nuxt/agents/code-reviewer.md +0 -1
- package/presets/claude/nuxt/agents/codebase-analyzer.md +0 -1
- package/presets/claude/nuxt/agents/debugger.md +1 -1
- package/presets/claude/nuxt/agents/feature-developer.md +6 -6
- package/presets/claude/nuxt/agents/migration-specialist.md +0 -1
- package/presets/claude/nuxt/agents/mockup-reviewer.md +0 -1
- package/presets/claude/nuxt/agents/openspec-author.md +0 -1
- package/presets/claude/nuxt/agents/performance-auditor.md +0 -1
- package/presets/claude/nuxt/agents/playwright-test-generator.md +0 -1
- package/presets/claude/nuxt/agents/playwright-test-healer.md +0 -1
- package/presets/claude/nuxt/agents/playwright-test-planner.md +0 -1
- package/presets/claude/nuxt/agents/qa-tester.md +3 -3
- package/presets/claude/nuxt/agents/security-reviewer.md +0 -1
- package/presets/claude/nuxt/agents/solution-architect.md +0 -1
- package/presets/claude/nuxt/agents/task-analyst.md +0 -1
- package/presets/claude/nuxt/agents/task-router.md +8 -7
- package/presets/claude/nuxt/agents/tech-writer.md +0 -1
- package/presets/claude/nuxt/agents/unit-test-generator.md +0 -1
- package/presets/claude/nuxt/agents/unit-test-healer.md +0 -1
- package/presets/claude/nuxt/agents/unit-test-planner.md +0 -1
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +12 -3
- package/presets/claude/nuxt/rules/architecture/feature-delivery-workflow.md +3 -7
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/nuxt/rules/tooling-and-review/code-quality.md +2 -6
- package/presets/claude/nuxt/rules/tooling-and-review/post-change-lint.md +14 -14
- package/presets/claude/nuxt/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/nuxt/skills/feature-delivery/SKILL.md +1 -1
- package/presets/claude/nuxt/skills/playwright-e2e/SKILL.md +1 -1
- package/presets/claude/nuxt/skills/unit-testing/SKILL.md +1 -1
- package/presets/claude/php-hexagonal/REPO_AGENTS.md +7 -47
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +12 -3
- package/presets/claude/php-hexagonal/rules/architecture/feature-delivery.md +3 -7
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/php-hexagonal/rules/tooling-and-review/code-quality.md +2 -6
- package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/php-laravel/REPO_AGENTS.md +7 -47
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +12 -3
- package/presets/claude/php-laravel/rules/architecture/feature-delivery.md +3 -7
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/php-laravel/rules/tooling-and-review/code-quality.md +2 -6
- package/presets/claude/php-laravel/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/svelte/REPO_AGENTS.md +8 -48
- package/presets/claude/svelte/agents/accessibility-reviewer.md +0 -1
- package/presets/claude/svelte/agents/api-contract-reviewer.md +0 -1
- package/presets/claude/svelte/agents/build-verifier.md +5 -3
- package/presets/claude/svelte/agents/ci-investigator.md +1 -1
- package/presets/claude/svelte/agents/code-reviewer.md +0 -1
- package/presets/claude/svelte/agents/codebase-analyzer.md +0 -1
- package/presets/claude/svelte/agents/debugger.md +1 -1
- package/presets/claude/svelte/agents/feature-developer.md +6 -6
- package/presets/claude/svelte/agents/migration-specialist.md +0 -1
- package/presets/claude/svelte/agents/mockup-reviewer.md +0 -1
- package/presets/claude/svelte/agents/openspec-author.md +0 -1
- package/presets/claude/svelte/agents/performance-auditor.md +0 -1
- package/presets/claude/svelte/agents/playwright-test-generator.md +0 -1
- package/presets/claude/svelte/agents/playwright-test-healer.md +0 -1
- package/presets/claude/svelte/agents/playwright-test-planner.md +0 -1
- package/presets/claude/svelte/agents/qa-tester.md +3 -3
- package/presets/claude/svelte/agents/security-reviewer.md +0 -1
- package/presets/claude/svelte/agents/solution-architect.md +0 -1
- package/presets/claude/svelte/agents/task-analyst.md +0 -1
- package/presets/claude/svelte/agents/task-router.md +8 -7
- package/presets/claude/svelte/agents/tech-writer.md +0 -1
- package/presets/claude/svelte/agents/unit-test-generator.md +0 -1
- package/presets/claude/svelte/agents/unit-test-healer.md +0 -1
- package/presets/claude/svelte/agents/unit-test-planner.md +0 -1
- package/presets/claude/svelte/hooks/chain-team-phases.sh +12 -3
- package/presets/claude/svelte/rules/architecture/feature-delivery-workflow.md +3 -7
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/svelte/rules/tooling-and-review/code-quality.md +2 -6
- package/presets/claude/svelte/rules/tooling-and-review/post-change-lint.md +14 -14
- package/presets/claude/svelte/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/svelte/skills/feature-delivery/SKILL.md +1 -1
- package/presets/claude/svelte/skills/playwright-e2e/SKILL.md +1 -1
- package/presets/claude/svelte/skills/unit-testing/SKILL.md +1 -1
- package/presets/cursor/android-kotlin/AGENTS.md +0 -10
- package/presets/cursor/android-kotlin/REPO_AGENTS.md +7 -47
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +12 -3
- package/presets/cursor/android-kotlin/rules/code-quality-and-refactoring.mdc +2 -6
- package/presets/cursor/android-kotlin/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/go/AGENTS.md +0 -8
- package/presets/cursor/go/REPO_AGENTS.md +7 -47
- package/presets/cursor/go/hooks/chain-team-phases.sh +12 -3
- package/presets/cursor/go/rules/code-quality-and-refactoring.mdc +2 -6
- package/presets/cursor/go/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/ios-swift/AGENTS.md +0 -10
- package/presets/cursor/ios-swift/REPO_AGENTS.md +7 -47
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +12 -3
- package/presets/cursor/ios-swift/rules/code-quality-and-refactoring.mdc +2 -6
- package/presets/cursor/ios-swift/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/java/AGENTS.md +0 -8
- package/presets/cursor/java/REPO_AGENTS.md +7 -47
- package/presets/cursor/java/hooks/chain-team-phases.sh +12 -3
- package/presets/cursor/java/rules/code-quality-and-refactoring.mdc +2 -6
- package/presets/cursor/java/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/mcp-ts/AGENTS.md +0 -6
- package/presets/cursor/mcp-ts/REPO_AGENTS.md +7 -47
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +12 -3
- package/presets/cursor/mcp-ts/rules/code-quality-and-refactoring.mdc +2 -6
- package/presets/cursor/mcp-ts/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/mol/AGENTS.md +0 -11
- package/presets/cursor/mol/REPO_AGENTS.md +9 -49
- package/presets/cursor/mol/hooks/chain-team-phases.sh +12 -3
- package/presets/cursor/mol/rules/code-quality-and-refactoring.mdc +2 -6
- package/presets/cursor/mol/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/next/AGENTS.md +1 -12
- package/presets/cursor/next/REPO_AGENTS.md +10 -50
- package/presets/cursor/next/agents/build-verifier.md +11 -7
- package/presets/cursor/next/agents/code-reviewer.md +1 -0
- package/presets/cursor/next/agents/feature-developer.md +6 -6
- package/presets/cursor/next/agents/qa-tester.md +3 -2
- package/presets/cursor/next/agents/task-router.md +8 -6
- package/presets/cursor/next/commands/README.md +0 -6
- package/presets/cursor/next/hooks/chain-team-phases.sh +12 -3
- package/presets/cursor/next/rules/agent-team-orchestrator.mdc +4 -4
- package/presets/cursor/next/rules/code-quality-and-refactoring.mdc +2 -6
- package/presets/cursor/next/rules/feature-delivery-workflow.mdc +2 -2
- package/presets/cursor/next/rules/post-change-lint.mdc +12 -16
- package/presets/cursor/next/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/next/skills/feature-delivery/SKILL.md +1 -1
- package/presets/cursor/next/skills/playwright-e2e/SKILL.md +1 -1
- package/presets/cursor/next/skills/unit-testing/SKILL.md +1 -1
- package/presets/cursor/nuxt/AGENTS.md +1 -12
- package/presets/cursor/nuxt/REPO_AGENTS.md +8 -48
- package/presets/cursor/nuxt/agents/build-verifier.md +1 -1
- package/presets/cursor/nuxt/agents/feature-developer.md +2 -2
- package/presets/cursor/nuxt/agents/qa-tester.md +3 -2
- package/presets/cursor/nuxt/agents/task-router.md +8 -6
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +12 -3
- package/presets/cursor/nuxt/rules/code-quality-and-refactoring.mdc +2 -6
- package/presets/cursor/nuxt/rules/post-change-lint.mdc +14 -14
- package/presets/cursor/nuxt/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/nuxt/skills/feature-delivery/SKILL.md +1 -1
- package/presets/cursor/nuxt/skills/playwright-e2e/SKILL.md +1 -1
- package/presets/cursor/nuxt/skills/unit-testing/SKILL.md +1 -1
- package/presets/cursor/php-hexagonal/AGENTS.md +0 -8
- package/presets/cursor/php-hexagonal/REPO_AGENTS.md +7 -47
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +12 -3
- package/presets/cursor/php-hexagonal/rules/code-quality-and-refactoring.mdc +2 -6
- package/presets/cursor/php-hexagonal/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/php-laravel/AGENTS.md +0 -8
- package/presets/cursor/php-laravel/REPO_AGENTS.md +7 -47
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +12 -3
- package/presets/cursor/php-laravel/rules/code-quality-and-refactoring.mdc +2 -6
- package/presets/cursor/php-laravel/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/svelte/AGENTS.md +1 -12
- package/presets/cursor/svelte/REPO_AGENTS.md +8 -48
- package/presets/cursor/svelte/agents/build-verifier.md +1 -1
- package/presets/cursor/svelte/agents/feature-developer.md +2 -2
- package/presets/cursor/svelte/agents/qa-tester.md +3 -2
- package/presets/cursor/svelte/agents/task-router.md +8 -6
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +12 -3
- package/presets/cursor/svelte/rules/code-quality-and-refactoring.mdc +2 -6
- package/presets/cursor/svelte/rules/post-change-lint.mdc +14 -14
- package/presets/cursor/svelte/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/svelte/skills/feature-delivery/SKILL.md +1 -1
- package/presets/cursor/svelte/skills/playwright-e2e/SKILL.md +1 -1
- package/presets/cursor/svelte/skills/unit-testing/SKILL.md +1 -1
- package/presets/mavis/android-kotlin/MAVIS.md +0 -2
- package/presets/mavis/android-kotlin/REPO_AGENTS.md +7 -47
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +12 -3
- package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/android-kotlin/rules/code-quality-and-refactoring.md +2 -6
- package/presets/mavis/android-kotlin/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/go/MAVIS.md +8 -0
- package/presets/mavis/go/REPO_AGENTS.md +7 -47
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/hooks/chain-team-phases.sh +12 -3
- package/presets/mavis/go/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/go/rules/code-quality-and-refactoring.md +2 -6
- package/presets/mavis/go/rules/feature-delivery-workflow.md +3 -7
- package/presets/mavis/go/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/ios-swift/MAVIS.md +0 -2
- package/presets/mavis/ios-swift/REPO_AGENTS.md +7 -47
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +12 -3
- package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/ios-swift/rules/code-quality-and-refactoring.md +2 -6
- package/presets/mavis/ios-swift/rules/feature-delivery-workflow.md +3 -7
- package/presets/mavis/ios-swift/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/java/MAVIS.md +14 -0
- package/presets/mavis/java/REPO_AGENTS.md +7 -47
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/hooks/chain-team-phases.sh +12 -3
- package/presets/mavis/java/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/java/rules/code-quality-and-refactoring.md +2 -6
- package/presets/mavis/java/rules/feature-delivery-workflow.md +3 -7
- package/presets/mavis/java/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/mcp-ts/MAVIS.md +6 -0
- package/presets/mavis/mcp-ts/REPO_AGENTS.md +7 -47
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +12 -3
- package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/mcp-ts/rules/code-quality-and-refactoring.md +2 -6
- package/presets/mavis/mcp-ts/rules/feature-delivery-workflow.md +3 -7
- package/presets/mavis/mcp-ts/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/mol/MAVIS.md +1 -5
- package/presets/mavis/mol/REPO_AGENTS.md +9 -49
- package/presets/mavis/mol/adapter-map.json +1 -1
- package/presets/mavis/mol/hooks/chain-team-phases.sh +12 -3
- package/presets/mavis/mol/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/mol/rules/code-quality-and-refactoring.md +2 -6
- package/presets/mavis/mol/rules/feature-delivery-workflow.md +3 -7
- package/presets/mavis/mol/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/next/MAVIS.md +2 -6
- package/presets/mavis/next/REPO_AGENTS.md +10 -50
- package/presets/mavis/next/adapter-map.json +1 -17
- package/presets/mavis/next/agents/accessibility-reviewer.md +0 -1
- package/presets/mavis/next/agents/api-contract-reviewer.md +0 -1
- package/presets/mavis/next/agents/build-verifier.md +12 -8
- package/presets/mavis/next/agents/code-reviewer.md +1 -1
- package/presets/mavis/next/agents/codebase-analyzer.md +0 -1
- package/presets/mavis/next/agents/feature-developer.md +6 -6
- package/presets/mavis/next/agents/migration-specialist.md +0 -1
- package/presets/mavis/next/agents/mockup-reviewer.md +0 -1
- package/presets/mavis/next/agents/openspec-author.md +0 -1
- package/presets/mavis/next/agents/performance-auditor.md +0 -1
- package/presets/mavis/next/agents/playwright-test-generator.md +0 -1
- package/presets/mavis/next/agents/playwright-test-healer.md +0 -1
- package/presets/mavis/next/agents/playwright-test-planner.md +0 -1
- package/presets/mavis/next/agents/qa-tester.md +3 -3
- package/presets/mavis/next/agents/security-reviewer.md +0 -1
- package/presets/mavis/next/agents/solution-architect.md +0 -1
- package/presets/mavis/next/agents/task-analyst.md +0 -1
- package/presets/mavis/next/agents/task-router.md +8 -7
- package/presets/mavis/next/agents/tech-writer.md +0 -1
- package/presets/mavis/next/agents/unit-test-generator.md +0 -1
- package/presets/mavis/next/agents/unit-test-healer.md +0 -1
- package/presets/mavis/next/agents/unit-test-planner.md +0 -1
- package/presets/mavis/next/commands/README.md +0 -6
- package/presets/mavis/next/hooks/chain-team-phases.sh +12 -3
- package/presets/mavis/next/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/next/rules/code-quality-and-refactoring.md +2 -6
- package/presets/mavis/next/rules/feature-delivery-workflow.md +5 -9
- package/presets/mavis/next/rules/post-change-lint.md +11 -15
- package/presets/mavis/next/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/next/skills/feature-delivery/SKILL.md +1 -1
- package/presets/mavis/next/skills/playwright-e2e/SKILL.md +1 -1
- package/presets/mavis/next/skills/unit-testing/SKILL.md +1 -1
- package/presets/mavis/nuxt/MAVIS.md +2 -6
- package/presets/mavis/nuxt/REPO_AGENTS.md +8 -48
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/agents/accessibility-reviewer.md +0 -1
- package/presets/mavis/nuxt/agents/api-contract-reviewer.md +0 -1
- package/presets/mavis/nuxt/agents/build-verifier.md +2 -2
- package/presets/mavis/nuxt/agents/ci-investigator.md +1 -1
- package/presets/mavis/nuxt/agents/code-reviewer.md +0 -1
- package/presets/mavis/nuxt/agents/codebase-analyzer.md +0 -1
- package/presets/mavis/nuxt/agents/debugger.md +1 -1
- package/presets/mavis/nuxt/agents/feature-developer.md +3 -3
- package/presets/mavis/nuxt/agents/migration-specialist.md +0 -1
- package/presets/mavis/nuxt/agents/mockup-reviewer.md +0 -1
- package/presets/mavis/nuxt/agents/openspec-author.md +0 -1
- package/presets/mavis/nuxt/agents/performance-auditor.md +0 -1
- package/presets/mavis/nuxt/agents/playwright-test-generator.md +0 -1
- package/presets/mavis/nuxt/agents/playwright-test-healer.md +0 -1
- package/presets/mavis/nuxt/agents/playwright-test-planner.md +0 -1
- package/presets/mavis/nuxt/agents/qa-tester.md +3 -3
- package/presets/mavis/nuxt/agents/security-reviewer.md +0 -1
- package/presets/mavis/nuxt/agents/solution-architect.md +0 -1
- package/presets/mavis/nuxt/agents/task-analyst.md +0 -1
- package/presets/mavis/nuxt/agents/task-router.md +8 -7
- package/presets/mavis/nuxt/agents/tech-writer.md +0 -1
- package/presets/mavis/nuxt/agents/unit-test-generator.md +0 -1
- package/presets/mavis/nuxt/agents/unit-test-healer.md +0 -1
- package/presets/mavis/nuxt/agents/unit-test-planner.md +0 -1
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +12 -3
- package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/nuxt/rules/code-quality-and-refactoring.md +2 -6
- package/presets/mavis/nuxt/rules/feature-delivery-workflow.md +3 -7
- package/presets/mavis/nuxt/rules/post-change-lint.md +13 -13
- package/presets/mavis/nuxt/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/nuxt/skills/feature-delivery/SKILL.md +1 -1
- package/presets/mavis/nuxt/skills/playwright-e2e/SKILL.md +1 -1
- package/presets/mavis/nuxt/skills/unit-testing/SKILL.md +1 -1
- package/presets/mavis/php-hexagonal/MAVIS.md +16 -0
- package/presets/mavis/php-hexagonal/REPO_AGENTS.md +7 -47
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +12 -3
- package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/php-hexagonal/rules/code-quality-and-refactoring.md +2 -6
- package/presets/mavis/php-hexagonal/rules/feature-delivery-workflow.md +3 -7
- package/presets/mavis/php-hexagonal/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/php-laravel/MAVIS.md +16 -0
- package/presets/mavis/php-laravel/REPO_AGENTS.md +7 -47
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +12 -3
- package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/php-laravel/rules/code-quality-and-refactoring.md +2 -6
- package/presets/mavis/php-laravel/rules/feature-delivery-workflow.md +3 -7
- package/presets/mavis/php-laravel/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/svelte/MAVIS.md +2 -6
- package/presets/mavis/svelte/REPO_AGENTS.md +8 -48
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/agents/accessibility-reviewer.md +0 -1
- package/presets/mavis/svelte/agents/api-contract-reviewer.md +0 -1
- package/presets/mavis/svelte/agents/build-verifier.md +2 -2
- package/presets/mavis/svelte/agents/ci-investigator.md +1 -1
- package/presets/mavis/svelte/agents/code-reviewer.md +0 -1
- package/presets/mavis/svelte/agents/codebase-analyzer.md +0 -1
- package/presets/mavis/svelte/agents/debugger.md +1 -1
- package/presets/mavis/svelte/agents/feature-developer.md +3 -3
- package/presets/mavis/svelte/agents/migration-specialist.md +0 -1
- package/presets/mavis/svelte/agents/mockup-reviewer.md +0 -1
- package/presets/mavis/svelte/agents/openspec-author.md +0 -1
- package/presets/mavis/svelte/agents/performance-auditor.md +0 -1
- package/presets/mavis/svelte/agents/playwright-test-generator.md +0 -1
- package/presets/mavis/svelte/agents/playwright-test-healer.md +0 -1
- package/presets/mavis/svelte/agents/playwright-test-planner.md +0 -1
- package/presets/mavis/svelte/agents/qa-tester.md +3 -3
- package/presets/mavis/svelte/agents/security-reviewer.md +0 -1
- package/presets/mavis/svelte/agents/solution-architect.md +0 -1
- package/presets/mavis/svelte/agents/task-analyst.md +0 -1
- package/presets/mavis/svelte/agents/task-router.md +8 -7
- package/presets/mavis/svelte/agents/tech-writer.md +0 -1
- package/presets/mavis/svelte/agents/unit-test-generator.md +0 -1
- package/presets/mavis/svelte/agents/unit-test-healer.md +0 -1
- package/presets/mavis/svelte/agents/unit-test-planner.md +0 -1
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +12 -3
- package/presets/mavis/svelte/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/svelte/rules/code-quality-and-refactoring.md +2 -6
- package/presets/mavis/svelte/rules/feature-delivery-workflow.md +3 -7
- package/presets/mavis/svelte/rules/post-change-lint.md +13 -13
- package/presets/mavis/svelte/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/svelte/skills/feature-delivery/SKILL.md +1 -1
- package/presets/mavis/svelte/skills/playwright-e2e/SKILL.md +1 -1
- package/presets/mavis/svelte/skills/unit-testing/SKILL.md +1 -1
- package/presets/opencode/android-kotlin/OPENCODE.md +1 -43
- package/presets/opencode/android-kotlin/REPO_AGENTS.md +7 -47
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +12 -3
- package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +5 -5
- package/presets/opencode/android-kotlin/rules/code-quality-and-refactoring.md +2 -6
- package/presets/opencode/android-kotlin/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/go/OPENCODE.md +7 -39
- package/presets/opencode/go/REPO_AGENTS.md +7 -47
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/hooks/chain-team-phases.sh +12 -3
- package/presets/opencode/go/rules/agent-team-orchestrator.md +5 -5
- package/presets/opencode/go/rules/code-quality-and-refactoring.md +2 -6
- package/presets/opencode/go/rules/feature-delivery-workflow.md +3 -7
- package/presets/opencode/go/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/ios-swift/OPENCODE.md +1 -43
- package/presets/opencode/ios-swift/REPO_AGENTS.md +7 -47
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +12 -3
- package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +5 -5
- package/presets/opencode/ios-swift/rules/code-quality-and-refactoring.md +2 -6
- package/presets/opencode/ios-swift/rules/feature-delivery-workflow.md +3 -7
- package/presets/opencode/ios-swift/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/java/OPENCODE.md +12 -38
- package/presets/opencode/java/REPO_AGENTS.md +7 -47
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/hooks/chain-team-phases.sh +12 -3
- package/presets/opencode/java/rules/agent-team-orchestrator.md +5 -5
- package/presets/opencode/java/rules/code-quality-and-refactoring.md +2 -6
- package/presets/opencode/java/rules/feature-delivery-workflow.md +3 -7
- package/presets/opencode/java/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/mcp-ts/OPENCODE.md +5 -39
- package/presets/opencode/mcp-ts/REPO_AGENTS.md +7 -47
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +12 -3
- package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +5 -5
- package/presets/opencode/mcp-ts/rules/code-quality-and-refactoring.md +2 -6
- package/presets/opencode/mcp-ts/rules/feature-delivery-workflow.md +3 -7
- package/presets/opencode/mcp-ts/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/mol/OPENCODE.md +1 -44
- package/presets/opencode/mol/REPO_AGENTS.md +9 -49
- package/presets/opencode/mol/adapter-map.json +1 -1
- package/presets/opencode/mol/hooks/chain-team-phases.sh +12 -3
- package/presets/opencode/mol/rules/agent-team-orchestrator.md +5 -5
- package/presets/opencode/mol/rules/code-quality-and-refactoring.md +2 -6
- package/presets/opencode/mol/rules/feature-delivery-workflow.md +3 -7
- package/presets/opencode/mol/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/next/OPENCODE.md +2 -45
- package/presets/opencode/next/REPO_AGENTS.md +10 -50
- package/presets/opencode/next/adapter-map.json +1 -17
- package/presets/opencode/next/agents/accessibility-reviewer.md +0 -1
- package/presets/opencode/next/agents/api-contract-reviewer.md +0 -1
- package/presets/opencode/next/agents/build-verifier.md +12 -8
- package/presets/opencode/next/agents/code-reviewer.md +1 -1
- package/presets/opencode/next/agents/codebase-analyzer.md +0 -1
- package/presets/opencode/next/agents/feature-developer.md +6 -6
- package/presets/opencode/next/agents/migration-specialist.md +0 -1
- package/presets/opencode/next/agents/mockup-reviewer.md +0 -1
- package/presets/opencode/next/agents/openspec-author.md +0 -1
- package/presets/opencode/next/agents/performance-auditor.md +0 -1
- package/presets/opencode/next/agents/playwright-test-generator.md +0 -1
- package/presets/opencode/next/agents/playwright-test-healer.md +0 -1
- package/presets/opencode/next/agents/playwright-test-planner.md +0 -1
- package/presets/opencode/next/agents/qa-tester.md +3 -3
- package/presets/opencode/next/agents/security-reviewer.md +0 -1
- package/presets/opencode/next/agents/solution-architect.md +0 -1
- package/presets/opencode/next/agents/task-analyst.md +0 -1
- package/presets/opencode/next/agents/task-router.md +8 -7
- package/presets/opencode/next/agents/tech-writer.md +0 -1
- package/presets/opencode/next/agents/unit-test-generator.md +0 -1
- package/presets/opencode/next/agents/unit-test-healer.md +0 -1
- package/presets/opencode/next/agents/unit-test-planner.md +0 -1
- package/presets/opencode/next/commands/README.md +0 -6
- package/presets/opencode/next/hooks/chain-team-phases.sh +12 -3
- package/presets/opencode/next/rules/agent-team-orchestrator.md +5 -5
- package/presets/opencode/next/rules/code-quality-and-refactoring.md +2 -6
- package/presets/opencode/next/rules/feature-delivery-workflow.md +5 -9
- package/presets/opencode/next/rules/post-change-lint.md +11 -15
- package/presets/opencode/next/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/next/skills/feature-delivery/SKILL.md +1 -1
- package/presets/opencode/next/skills/playwright-e2e/SKILL.md +1 -1
- package/presets/opencode/next/skills/unit-testing/SKILL.md +1 -1
- package/presets/opencode/nuxt/OPENCODE.md +2 -45
- package/presets/opencode/nuxt/REPO_AGENTS.md +8 -48
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/agents/accessibility-reviewer.md +0 -1
- package/presets/opencode/nuxt/agents/api-contract-reviewer.md +0 -1
- package/presets/opencode/nuxt/agents/build-verifier.md +2 -2
- package/presets/opencode/nuxt/agents/ci-investigator.md +1 -1
- package/presets/opencode/nuxt/agents/code-reviewer.md +0 -1
- package/presets/opencode/nuxt/agents/codebase-analyzer.md +0 -1
- package/presets/opencode/nuxt/agents/debugger.md +1 -1
- package/presets/opencode/nuxt/agents/feature-developer.md +3 -3
- package/presets/opencode/nuxt/agents/migration-specialist.md +0 -1
- package/presets/opencode/nuxt/agents/mockup-reviewer.md +0 -1
- package/presets/opencode/nuxt/agents/openspec-author.md +0 -1
- package/presets/opencode/nuxt/agents/performance-auditor.md +0 -1
- package/presets/opencode/nuxt/agents/playwright-test-generator.md +0 -1
- package/presets/opencode/nuxt/agents/playwright-test-healer.md +0 -1
- package/presets/opencode/nuxt/agents/playwright-test-planner.md +0 -1
- package/presets/opencode/nuxt/agents/qa-tester.md +3 -3
- package/presets/opencode/nuxt/agents/security-reviewer.md +0 -1
- package/presets/opencode/nuxt/agents/solution-architect.md +0 -1
- package/presets/opencode/nuxt/agents/task-analyst.md +0 -1
- package/presets/opencode/nuxt/agents/task-router.md +8 -7
- package/presets/opencode/nuxt/agents/tech-writer.md +0 -1
- package/presets/opencode/nuxt/agents/unit-test-generator.md +0 -1
- package/presets/opencode/nuxt/agents/unit-test-healer.md +0 -1
- package/presets/opencode/nuxt/agents/unit-test-planner.md +0 -1
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +12 -3
- package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +5 -5
- package/presets/opencode/nuxt/rules/code-quality-and-refactoring.md +2 -6
- package/presets/opencode/nuxt/rules/feature-delivery-workflow.md +3 -7
- package/presets/opencode/nuxt/rules/post-change-lint.md +13 -13
- package/presets/opencode/nuxt/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/nuxt/skills/feature-delivery/SKILL.md +1 -1
- package/presets/opencode/nuxt/skills/playwright-e2e/SKILL.md +1 -1
- package/presets/opencode/nuxt/skills/unit-testing/SKILL.md +1 -1
- package/presets/opencode/php-hexagonal/OPENCODE.md +14 -38
- package/presets/opencode/php-hexagonal/REPO_AGENTS.md +7 -47
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +12 -3
- package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +5 -5
- package/presets/opencode/php-hexagonal/rules/code-quality-and-refactoring.md +2 -6
- package/presets/opencode/php-hexagonal/rules/feature-delivery-workflow.md +3 -7
- package/presets/opencode/php-hexagonal/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/php-laravel/OPENCODE.md +14 -38
- package/presets/opencode/php-laravel/REPO_AGENTS.md +7 -47
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +12 -3
- package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +5 -5
- package/presets/opencode/php-laravel/rules/code-quality-and-refactoring.md +2 -6
- package/presets/opencode/php-laravel/rules/feature-delivery-workflow.md +3 -7
- package/presets/opencode/php-laravel/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/plugins/output-guard/index.ts +7 -1
- package/presets/opencode/plugins/output-guard/ledger.ts +43 -0
- package/presets/opencode/plugins/task-status/economy.ts +112 -0
- package/presets/opencode/plugins/task-status/task-view.ts +28 -0
- package/presets/opencode/plugins/task-status/tui.tsx +14 -2
- package/presets/opencode/plugins/task-status/types.ts +3 -1
- package/presets/opencode/svelte/OPENCODE.md +2 -45
- package/presets/opencode/svelte/REPO_AGENTS.md +8 -48
- package/presets/opencode/svelte/adapter-map.json +1 -1
- package/presets/opencode/svelte/agents/accessibility-reviewer.md +0 -1
- package/presets/opencode/svelte/agents/api-contract-reviewer.md +0 -1
- package/presets/opencode/svelte/agents/build-verifier.md +2 -2
- package/presets/opencode/svelte/agents/ci-investigator.md +1 -1
- package/presets/opencode/svelte/agents/code-reviewer.md +0 -1
- package/presets/opencode/svelte/agents/codebase-analyzer.md +0 -1
- package/presets/opencode/svelte/agents/debugger.md +1 -1
- package/presets/opencode/svelte/agents/feature-developer.md +3 -3
- package/presets/opencode/svelte/agents/migration-specialist.md +0 -1
- package/presets/opencode/svelte/agents/mockup-reviewer.md +0 -1
- package/presets/opencode/svelte/agents/openspec-author.md +0 -1
- package/presets/opencode/svelte/agents/performance-auditor.md +0 -1
- package/presets/opencode/svelte/agents/playwright-test-generator.md +0 -1
- package/presets/opencode/svelte/agents/playwright-test-healer.md +0 -1
- package/presets/opencode/svelte/agents/playwright-test-planner.md +0 -1
- package/presets/opencode/svelte/agents/qa-tester.md +3 -3
- package/presets/opencode/svelte/agents/security-reviewer.md +0 -1
- package/presets/opencode/svelte/agents/solution-architect.md +0 -1
- package/presets/opencode/svelte/agents/task-analyst.md +0 -1
- package/presets/opencode/svelte/agents/task-router.md +8 -7
- package/presets/opencode/svelte/agents/tech-writer.md +0 -1
- package/presets/opencode/svelte/agents/unit-test-generator.md +0 -1
- package/presets/opencode/svelte/agents/unit-test-healer.md +0 -1
- package/presets/opencode/svelte/agents/unit-test-planner.md +0 -1
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +12 -3
- package/presets/opencode/svelte/rules/agent-team-orchestrator.md +5 -5
- package/presets/opencode/svelte/rules/code-quality-and-refactoring.md +2 -6
- package/presets/opencode/svelte/rules/feature-delivery-workflow.md +3 -7
- package/presets/opencode/svelte/rules/post-change-lint.md +13 -13
- package/presets/opencode/svelte/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/svelte/skills/feature-delivery/SKILL.md +1 -1
- package/presets/opencode/svelte/skills/playwright-e2e/SKILL.md +1 -1
- package/presets/opencode/svelte/skills/unit-testing/SKILL.md +1 -1
- package/presets/zcode/android-kotlin/REPO_AGENTS.md +7 -47
- package/presets/zcode/android-kotlin/adapter-map.json +1 -1
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +12 -3
- package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/android-kotlin/rules/code-quality-and-refactoring.md +2 -6
- package/presets/zcode/android-kotlin/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/go/REPO_AGENTS.md +7 -47
- package/presets/zcode/go/adapter-map.json +1 -1
- package/presets/zcode/go/hooks/chain-team-phases.sh +12 -3
- package/presets/zcode/go/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/go/rules/code-quality-and-refactoring.md +2 -6
- package/presets/zcode/go/rules/feature-delivery-workflow.md +3 -7
- package/presets/zcode/go/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/ios-swift/REPO_AGENTS.md +7 -47
- package/presets/zcode/ios-swift/adapter-map.json +1 -1
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +12 -3
- package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/ios-swift/rules/code-quality-and-refactoring.md +2 -6
- package/presets/zcode/ios-swift/rules/feature-delivery-workflow.md +3 -7
- package/presets/zcode/ios-swift/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/java/REPO_AGENTS.md +7 -47
- package/presets/zcode/java/adapter-map.json +1 -1
- package/presets/zcode/java/hooks/chain-team-phases.sh +12 -3
- package/presets/zcode/java/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/java/rules/code-quality-and-refactoring.md +2 -6
- package/presets/zcode/java/rules/feature-delivery-workflow.md +3 -7
- package/presets/zcode/java/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/mcp-ts/REPO_AGENTS.md +7 -47
- package/presets/zcode/mcp-ts/adapter-map.json +1 -1
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +12 -3
- package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/mcp-ts/rules/code-quality-and-refactoring.md +2 -6
- package/presets/zcode/mcp-ts/rules/feature-delivery-workflow.md +3 -7
- package/presets/zcode/mcp-ts/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/mol/REPO_AGENTS.md +9 -49
- package/presets/zcode/mol/adapter-map.json +1 -1
- package/presets/zcode/mol/hooks/chain-team-phases.sh +12 -3
- package/presets/zcode/mol/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/mol/rules/code-quality-and-refactoring.md +2 -6
- package/presets/zcode/mol/rules/feature-delivery-workflow.md +3 -7
- package/presets/zcode/mol/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/next/REPO_AGENTS.md +10 -50
- package/presets/zcode/next/adapter-map.json +1 -17
- package/presets/zcode/next/agents/accessibility-reviewer.md +0 -1
- package/presets/zcode/next/agents/api-contract-reviewer.md +0 -1
- package/presets/zcode/next/agents/build-verifier.md +12 -8
- package/presets/zcode/next/agents/code-reviewer.md +1 -1
- package/presets/zcode/next/agents/codebase-analyzer.md +0 -1
- package/presets/zcode/next/agents/feature-developer.md +6 -6
- package/presets/zcode/next/agents/migration-specialist.md +0 -1
- package/presets/zcode/next/agents/mockup-reviewer.md +0 -1
- package/presets/zcode/next/agents/openspec-author.md +0 -1
- package/presets/zcode/next/agents/performance-auditor.md +0 -1
- package/presets/zcode/next/agents/playwright-test-generator.md +0 -1
- package/presets/zcode/next/agents/playwright-test-healer.md +0 -1
- package/presets/zcode/next/agents/playwright-test-planner.md +0 -1
- package/presets/zcode/next/agents/qa-tester.md +3 -3
- package/presets/zcode/next/agents/security-reviewer.md +0 -1
- package/presets/zcode/next/agents/solution-architect.md +0 -1
- package/presets/zcode/next/agents/task-analyst.md +0 -1
- package/presets/zcode/next/agents/task-router.md +8 -7
- package/presets/zcode/next/agents/tech-writer.md +0 -1
- package/presets/zcode/next/agents/unit-test-generator.md +0 -1
- package/presets/zcode/next/agents/unit-test-healer.md +0 -1
- package/presets/zcode/next/agents/unit-test-planner.md +0 -1
- package/presets/zcode/next/commands/README.md +0 -6
- package/presets/zcode/next/hooks/chain-team-phases.sh +12 -3
- package/presets/zcode/next/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/next/rules/code-quality-and-refactoring.md +2 -6
- package/presets/zcode/next/rules/feature-delivery-workflow.md +5 -9
- package/presets/zcode/next/rules/post-change-lint.md +11 -15
- package/presets/zcode/next/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/next/skills/feature-delivery/SKILL.md +1 -1
- package/presets/zcode/next/skills/playwright-e2e/SKILL.md +1 -1
- package/presets/zcode/next/skills/unit-testing/SKILL.md +1 -1
- package/presets/zcode/nuxt/REPO_AGENTS.md +8 -48
- package/presets/zcode/nuxt/adapter-map.json +1 -1
- package/presets/zcode/nuxt/agents/accessibility-reviewer.md +0 -1
- package/presets/zcode/nuxt/agents/api-contract-reviewer.md +0 -1
- package/presets/zcode/nuxt/agents/build-verifier.md +2 -2
- package/presets/zcode/nuxt/agents/ci-investigator.md +1 -1
- package/presets/zcode/nuxt/agents/code-reviewer.md +0 -1
- package/presets/zcode/nuxt/agents/codebase-analyzer.md +0 -1
- package/presets/zcode/nuxt/agents/debugger.md +1 -1
- package/presets/zcode/nuxt/agents/feature-developer.md +3 -3
- package/presets/zcode/nuxt/agents/migration-specialist.md +0 -1
- package/presets/zcode/nuxt/agents/mockup-reviewer.md +0 -1
- package/presets/zcode/nuxt/agents/openspec-author.md +0 -1
- package/presets/zcode/nuxt/agents/performance-auditor.md +0 -1
- package/presets/zcode/nuxt/agents/playwright-test-generator.md +0 -1
- package/presets/zcode/nuxt/agents/playwright-test-healer.md +0 -1
- package/presets/zcode/nuxt/agents/playwright-test-planner.md +0 -1
- package/presets/zcode/nuxt/agents/qa-tester.md +3 -3
- package/presets/zcode/nuxt/agents/security-reviewer.md +0 -1
- package/presets/zcode/nuxt/agents/solution-architect.md +0 -1
- package/presets/zcode/nuxt/agents/task-analyst.md +0 -1
- package/presets/zcode/nuxt/agents/task-router.md +8 -7
- package/presets/zcode/nuxt/agents/tech-writer.md +0 -1
- package/presets/zcode/nuxt/agents/unit-test-generator.md +0 -1
- package/presets/zcode/nuxt/agents/unit-test-healer.md +0 -1
- package/presets/zcode/nuxt/agents/unit-test-planner.md +0 -1
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +12 -3
- package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/nuxt/rules/code-quality-and-refactoring.md +2 -6
- package/presets/zcode/nuxt/rules/feature-delivery-workflow.md +3 -7
- package/presets/zcode/nuxt/rules/post-change-lint.md +13 -13
- package/presets/zcode/nuxt/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/nuxt/skills/feature-delivery/SKILL.md +1 -1
- package/presets/zcode/nuxt/skills/playwright-e2e/SKILL.md +1 -1
- package/presets/zcode/nuxt/skills/unit-testing/SKILL.md +1 -1
- package/presets/zcode/php-hexagonal/REPO_AGENTS.md +7 -47
- package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +12 -3
- package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/php-hexagonal/rules/code-quality-and-refactoring.md +2 -6
- package/presets/zcode/php-hexagonal/rules/feature-delivery-workflow.md +3 -7
- package/presets/zcode/php-hexagonal/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/php-laravel/REPO_AGENTS.md +7 -47
- package/presets/zcode/php-laravel/adapter-map.json +1 -1
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +12 -3
- package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/php-laravel/rules/code-quality-and-refactoring.md +2 -6
- package/presets/zcode/php-laravel/rules/feature-delivery-workflow.md +3 -7
- package/presets/zcode/php-laravel/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/svelte/REPO_AGENTS.md +8 -48
- package/presets/zcode/svelte/adapter-map.json +1 -1
- package/presets/zcode/svelte/agents/accessibility-reviewer.md +0 -1
- package/presets/zcode/svelte/agents/api-contract-reviewer.md +0 -1
- package/presets/zcode/svelte/agents/build-verifier.md +2 -2
- package/presets/zcode/svelte/agents/ci-investigator.md +1 -1
- package/presets/zcode/svelte/agents/code-reviewer.md +0 -1
- package/presets/zcode/svelte/agents/codebase-analyzer.md +0 -1
- package/presets/zcode/svelte/agents/debugger.md +1 -1
- package/presets/zcode/svelte/agents/feature-developer.md +3 -3
- package/presets/zcode/svelte/agents/migration-specialist.md +0 -1
- package/presets/zcode/svelte/agents/mockup-reviewer.md +0 -1
- package/presets/zcode/svelte/agents/openspec-author.md +0 -1
- package/presets/zcode/svelte/agents/performance-auditor.md +0 -1
- package/presets/zcode/svelte/agents/playwright-test-generator.md +0 -1
- package/presets/zcode/svelte/agents/playwright-test-healer.md +0 -1
- package/presets/zcode/svelte/agents/playwright-test-planner.md +0 -1
- package/presets/zcode/svelte/agents/qa-tester.md +3 -3
- package/presets/zcode/svelte/agents/security-reviewer.md +0 -1
- package/presets/zcode/svelte/agents/solution-architect.md +0 -1
- package/presets/zcode/svelte/agents/task-analyst.md +0 -1
- package/presets/zcode/svelte/agents/task-router.md +8 -7
- package/presets/zcode/svelte/agents/tech-writer.md +0 -1
- package/presets/zcode/svelte/agents/unit-test-generator.md +0 -1
- package/presets/zcode/svelte/agents/unit-test-healer.md +0 -1
- package/presets/zcode/svelte/agents/unit-test-planner.md +0 -1
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +12 -3
- package/presets/zcode/svelte/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/svelte/rules/code-quality-and-refactoring.md +2 -6
- package/presets/zcode/svelte/rules/feature-delivery-workflow.md +3 -7
- package/presets/zcode/svelte/rules/post-change-lint.md +13 -13
- package/presets/zcode/svelte/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/svelte/skills/feature-delivery/SKILL.md +1 -1
- package/presets/zcode/svelte/skills/playwright-e2e/SKILL.md +1 -1
- package/presets/zcode/svelte/skills/unit-testing/SKILL.md +1 -1
- package/presets/_shared/ai-local/scripts/team-db-dashboard.mjs +0 -2103
- package/presets/_shared/ai-local/scripts/team-db-ui.mjs +0 -750
- package/presets/claude/next/commands/ui-start.md +0 -78
- package/presets/claude/next/commands/ui-stop.md +0 -71
- package/presets/cursor/next/commands/ui-start.md +0 -78
- package/presets/cursor/next/commands/ui-stop.md +0 -71
- package/presets/mavis/next/commands/ui-start.md +0 -73
- package/presets/mavis/next/commands/ui-stop.md +0 -66
- package/presets/opencode/next/commands/ui-start.md +0 -81
- package/presets/opencode/next/commands/ui-stop.md +0 -74
- package/presets/zcode/next/commands/ui-start.md +0 -81
- package/presets/zcode/next/commands/ui-stop.md +0 -74
|
@@ -1,750 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `ui` lifecycle for the shipped team-db dashboard.
|
|
3
|
-
*
|
|
4
|
-
* `start` is probe-first: a healthy server for this root is a no-op with the
|
|
5
|
-
* same pid and an untouched marker, so only a free port leads to a detached
|
|
6
|
-
* `serve` plus `<aiLocalRoot>/.ui/api.json`. `start` writes the marker and at
|
|
7
|
-
* most one bounded `sync` (the missing-projection repair) and nothing else;
|
|
8
|
-
* `restart` is the explicit owned-stop-then-start verb. `stop` re-proves
|
|
9
|
-
* ownership from the live command line, signals the leader pid only and keeps
|
|
10
|
-
* the marker when the process survives. `status` reports the marker, the health
|
|
11
|
-
* block and a stale-engine warning.
|
|
12
|
-
*
|
|
13
|
-
* Ownership is a live pid AND `ps -p <pid> -o command=` matching
|
|
14
|
-
* `/team-db\.mjs\s+serve\b/`: the marker alone never authorizes a signal. Only
|
|
15
|
-
* the leader pid is signalled, never the process group — `serve` spawns bounded
|
|
16
|
-
* delete children and a group kill could truncate a delete between its folder
|
|
17
|
-
* and row legs. The timer stays separate: `ui start` reports
|
|
18
|
-
* `/health.scheduler` and never starts `team-db.mjs schedule`.
|
|
19
|
-
*
|
|
20
|
-
* POSIX only: the ownership probe reads `ps`. `win32` has no equivalent
|
|
21
|
-
* command-line reader, so no ownership can be proven there and no signal is
|
|
22
|
-
* ever sent — use the foreground `serve` on Windows.
|
|
23
|
-
*
|
|
24
|
-
* Exit codes: 0 ok or no-op, 1 refusal, 2 start failure, 3 usage.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
import { spawn, spawnSync } from 'node:child_process';
|
|
28
|
-
import fs from 'node:fs';
|
|
29
|
-
import path from 'node:path';
|
|
30
|
-
import { fileURLToPath } from 'node:url';
|
|
31
|
-
|
|
32
|
-
import { DEFAULT_HOST, DEFAULT_PORT, LOOPBACK_HOSTS } from './team-db-api.mjs';
|
|
33
|
-
import {
|
|
34
|
-
DEFAULT_TEAM_ROOT,
|
|
35
|
-
INDEX_UNAVAILABLE_LINE,
|
|
36
|
-
isKillSwitchSet,
|
|
37
|
-
isSqliteAvailable,
|
|
38
|
-
teamRootId,
|
|
39
|
-
} from './team-db-schema.mjs';
|
|
40
|
-
|
|
41
|
-
const MARKER_DIR_NAME = '.ui';
|
|
42
|
-
const MARKER_FILE_NAME = 'api.json';
|
|
43
|
-
const MARKER_SCHEMA_VERSION = 1;
|
|
44
|
-
const MARKER_FILE_MODE = 0o600;
|
|
45
|
-
const MARKER_COMMAND = 'node .ai.local/scripts/team-db.mjs serve';
|
|
46
|
-
const OWNED_COMMAND = /team-db\.mjs\s+serve\b/;
|
|
47
|
-
const PROBE_TIMEOUT_MS = 2000;
|
|
48
|
-
const START_TIMEOUT_MS = 30000;
|
|
49
|
-
const SYNC_TIMEOUT_MS = 30000;
|
|
50
|
-
const HEALTH_POLL_INTERVAL_MS = 250;
|
|
51
|
-
const TERMINATE_WAIT_MS = 5000;
|
|
52
|
-
const TERMINATE_POLL_INTERVAL_MS = 100;
|
|
53
|
-
const KILL_WAIT_MS = 2000;
|
|
54
|
-
const OWNER_STARTED = 'started by this repository';
|
|
55
|
-
const OWNER_PRE_EXISTING = 'pre-existing';
|
|
56
|
-
|
|
57
|
-
const VERB_FLAGS = {
|
|
58
|
-
start: new Set(['root', 'json', 'quiet', 'host', 'port', 'open']),
|
|
59
|
-
stop: new Set(['root', 'json', 'quiet']),
|
|
60
|
-
status: new Set(['root', 'json', 'quiet']),
|
|
61
|
-
restart: new Set(['root', 'json', 'quiet', 'host', 'port', 'open']),
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
class UiError extends Error {
|
|
65
|
-
constructor(code, message, exitCode) {
|
|
66
|
-
super(message);
|
|
67
|
-
this.name = 'UiError';
|
|
68
|
-
this.code = code;
|
|
69
|
-
this.exitCode = exitCode;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const uiFail = (code, message, exitCode) => {
|
|
74
|
-
throw new UiError(code, message, exitCode);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const sleep = (ms) =>
|
|
78
|
-
new Promise((resolve) => {
|
|
79
|
-
setTimeout(resolve, ms);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
const cliPath = () => fileURLToPath(new URL('./team-db.mjs', import.meta.url));
|
|
83
|
-
|
|
84
|
-
const urlHost = (host) => (host.includes(':') ? `[${host}]` : host);
|
|
85
|
-
|
|
86
|
-
const describeTarget = (target) => `http://${urlHost(target.host)}:${target.port}`;
|
|
87
|
-
|
|
88
|
-
const resolveRoots = (flags) => {
|
|
89
|
-
// Same precedence as the projection layers (`team-db-schema.mjs`): an explicit
|
|
90
|
-
// `--root`, else `AI_RULES_TEAM_DB_ROOT`, else `<cwd>/.ai.local/team`. The ui
|
|
91
|
-
// verbs must find a server started through the environment override.
|
|
92
|
-
const teamRoot = path.resolve(flags.root || process.env.AI_RULES_TEAM_DB_ROOT || DEFAULT_TEAM_ROOT);
|
|
93
|
-
const markerDir = path.join(path.dirname(teamRoot), MARKER_DIR_NAME);
|
|
94
|
-
return {
|
|
95
|
-
teamRoot,
|
|
96
|
-
markerDir,
|
|
97
|
-
markerPath: path.join(markerDir, MARKER_FILE_NAME),
|
|
98
|
-
rootId: teamRootId(teamRoot),
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
/* --------------------------------- process -------------------------------- */
|
|
103
|
-
|
|
104
|
-
const isAlive = (pid) => {
|
|
105
|
-
try {
|
|
106
|
-
process.kill(pid, 0);
|
|
107
|
-
} catch (error) {
|
|
108
|
-
return error.code === 'EPERM';
|
|
109
|
-
}
|
|
110
|
-
// A killed child stays a zombie until its parent reaps it; it holds a pid
|
|
111
|
-
// slot but no longer runs, so `stop` must not wait on it forever.
|
|
112
|
-
const state = spawnSync('ps', ['-p', String(pid), '-o', 'stat='], { encoding: 'utf8' }).stdout.trim();
|
|
113
|
-
return state !== '' && !state.startsWith('Z');
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const signalPid = (pid, signal) => {
|
|
117
|
-
try {
|
|
118
|
-
process.kill(pid, signal);
|
|
119
|
-
return true;
|
|
120
|
-
} catch {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
const liveCommand = (pid) => {
|
|
126
|
-
const result = spawnSync('ps', ['-p', String(pid), '-o', 'command='], { encoding: 'utf8' });
|
|
127
|
-
if (result.status !== 0) return null;
|
|
128
|
-
return result.stdout.trim();
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const ownsPid = (pid) => {
|
|
132
|
-
if (!isAlive(pid)) return false;
|
|
133
|
-
const command = liveCommand(pid);
|
|
134
|
-
return command !== null && OWNED_COMMAND.test(command);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const terminate = async (pid) => {
|
|
138
|
-
// Ownership is re-proved here rather than trusted from the caller's earlier
|
|
139
|
-
// read: a pid can be reused between the two calls.
|
|
140
|
-
if (!ownsPid(pid)) return !isAlive(pid);
|
|
141
|
-
if (!signalPid(pid, 'SIGTERM')) {
|
|
142
|
-
// ESRCH means it is already gone; EPERM means no signal can ever land, so
|
|
143
|
-
// the grace period could not change the outcome either.
|
|
144
|
-
return !isAlive(pid);
|
|
145
|
-
}
|
|
146
|
-
const deadline = Date.now() + TERMINATE_WAIT_MS;
|
|
147
|
-
while (Date.now() < deadline) {
|
|
148
|
-
if (!isAlive(pid)) return true;
|
|
149
|
-
await sleep(TERMINATE_POLL_INTERVAL_MS);
|
|
150
|
-
}
|
|
151
|
-
if (!isAlive(pid)) return true;
|
|
152
|
-
// A reused pid must not receive the escalation either.
|
|
153
|
-
if (ownsPid(pid)) signalPid(pid, 'SIGKILL');
|
|
154
|
-
const killDeadline = Date.now() + KILL_WAIT_MS;
|
|
155
|
-
while (Date.now() < killDeadline) {
|
|
156
|
-
if (!isAlive(pid)) return true;
|
|
157
|
-
await sleep(TERMINATE_POLL_INTERVAL_MS);
|
|
158
|
-
}
|
|
159
|
-
return !isAlive(pid);
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
/* ---------------------------------- marker -------------------------------- */
|
|
163
|
-
|
|
164
|
-
const readMarker = (roots) => {
|
|
165
|
-
if (!fs.existsSync(roots.markerPath)) return { marker: null, present: false };
|
|
166
|
-
try {
|
|
167
|
-
const marker = JSON.parse(fs.readFileSync(roots.markerPath, 'utf8'));
|
|
168
|
-
const valid =
|
|
169
|
-
Number.isInteger(marker?.pid) &&
|
|
170
|
-
marker.pid > 0 &&
|
|
171
|
-
typeof marker.host === 'string' &&
|
|
172
|
-
LOOPBACK_HOSTS.includes(marker.host) &&
|
|
173
|
-
Number.isInteger(marker.port) &&
|
|
174
|
-
marker.port >= 0 &&
|
|
175
|
-
marker.port <= 65535;
|
|
176
|
-
return { marker: valid ? marker : null, present: true };
|
|
177
|
-
} catch {
|
|
178
|
-
return { marker: null, present: true };
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const removeMarker = (roots) => {
|
|
183
|
-
try {
|
|
184
|
-
fs.rmSync(roots.markerPath, { force: true });
|
|
185
|
-
} catch {
|
|
186
|
-
/* a marker that cannot be removed is reported by the next start probe */
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
const writeMarker = (roots, marker) => {
|
|
191
|
-
fs.mkdirSync(roots.markerDir, { recursive: true });
|
|
192
|
-
const temporary = `${roots.markerPath}.tmp`;
|
|
193
|
-
fs.writeFileSync(temporary, `${JSON.stringify(marker, null, 2)}\n`, { mode: MARKER_FILE_MODE });
|
|
194
|
-
// `mode` only applies on creation: a `.tmp` left by an earlier crash must not
|
|
195
|
-
// donate its permissions to the rename.
|
|
196
|
-
fs.chmodSync(temporary, MARKER_FILE_MODE);
|
|
197
|
-
fs.renameSync(temporary, roots.markerPath);
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
/* ---------------------------------- health -------------------------------- */
|
|
201
|
-
|
|
202
|
-
const isHealthDocument = (body) =>
|
|
203
|
-
body !== null &&
|
|
204
|
-
typeof body === 'object' &&
|
|
205
|
-
typeof body.status === 'string' &&
|
|
206
|
-
typeof body.db === 'object' &&
|
|
207
|
-
body.db !== null &&
|
|
208
|
-
typeof body.tasks === 'object' &&
|
|
209
|
-
body.tasks !== null;
|
|
210
|
-
|
|
211
|
-
const probeHealth = async (host, port) => {
|
|
212
|
-
if (port === 0) return { kind: 'free' };
|
|
213
|
-
try {
|
|
214
|
-
const response = await fetch(`${describeTarget({ host, port })}/health`, {
|
|
215
|
-
signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),
|
|
216
|
-
});
|
|
217
|
-
let body = null;
|
|
218
|
-
try {
|
|
219
|
-
body = await response.json();
|
|
220
|
-
} catch {
|
|
221
|
-
body = null;
|
|
222
|
-
}
|
|
223
|
-
return { kind: 'response', status: response.status, body };
|
|
224
|
-
} catch (error) {
|
|
225
|
-
if (error?.name === 'TimeoutError') return { kind: 'timeout' };
|
|
226
|
-
if (error?.cause?.code === 'ECONNREFUSED' || error?.cause?.code === 'ECONNRESET') return { kind: 'refused' };
|
|
227
|
-
return { kind: 'error', reason: error?.cause?.message ?? error?.message };
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* `free` covers a refusal, a timeout and any other transport error: the only
|
|
233
|
-
* safe reading of "no health document came back" is "no known server", and the
|
|
234
|
-
* spawn decides the port race with its own bind (`EADDRINUSE`).
|
|
235
|
-
*/
|
|
236
|
-
const classifyProbe = (probe) => {
|
|
237
|
-
if (probe.kind !== 'response') return { kind: 'free' };
|
|
238
|
-
if (probe.status === 200 && isHealthDocument(probe.body)) return { kind: 'health', body: probe.body };
|
|
239
|
-
if (probe.status === 503 && probe.body?.error?.code === 'E_DB_MISSING') return { kind: 'missing-db' };
|
|
240
|
-
return { kind: 'foreign', status: probe.status };
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
const repairProjection = (roots) => {
|
|
244
|
-
const result = spawnSync(process.execPath, [cliPath(), 'sync', '--root', roots.teamRoot, '--quiet'], {
|
|
245
|
-
encoding: 'utf8',
|
|
246
|
-
env: process.env,
|
|
247
|
-
timeout: SYNC_TIMEOUT_MS,
|
|
248
|
-
});
|
|
249
|
-
if (!result.error && result.status === 0) return;
|
|
250
|
-
const lastLine = result.stderr.trim().split('\n').filter(Boolean).slice(-1)[0];
|
|
251
|
-
const detail = result.error?.message ?? lastLine ?? `sync exited ${result.status}`;
|
|
252
|
-
uiFail('E_UI_DB_MISSING', `the projection is still missing and team-db.mjs sync failed: ${detail}`, 1);
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
/* ---------------------------------- spawn --------------------------------- */
|
|
256
|
-
|
|
257
|
-
const spawnServe = (roots, target) =>
|
|
258
|
-
spawn(
|
|
259
|
-
process.execPath,
|
|
260
|
-
[cliPath(), 'serve', '--root', roots.teamRoot, '--host', target.host, '--port', String(target.port)],
|
|
261
|
-
{ cwd: process.cwd(), detached: true, stdio: ['ignore', 'pipe', 'pipe'] },
|
|
262
|
-
);
|
|
263
|
-
|
|
264
|
-
const readServingLine = (child) =>
|
|
265
|
-
new Promise((resolve, reject) => {
|
|
266
|
-
let stdout = '';
|
|
267
|
-
let stderr = '';
|
|
268
|
-
let settled = false;
|
|
269
|
-
const settle = (fn, value) => {
|
|
270
|
-
if (settled) return;
|
|
271
|
-
settled = true;
|
|
272
|
-
clearTimeout(timer);
|
|
273
|
-
fn(value);
|
|
274
|
-
};
|
|
275
|
-
const timer = setTimeout(
|
|
276
|
-
() =>
|
|
277
|
-
settle(
|
|
278
|
-
reject,
|
|
279
|
-
new UiError('E_UI_START_TIMEOUT', `serve did not report its URL within ${START_TIMEOUT_MS} ms`, 2),
|
|
280
|
-
),
|
|
281
|
-
START_TIMEOUT_MS,
|
|
282
|
-
);
|
|
283
|
-
child.stdout.setEncoding('utf8');
|
|
284
|
-
child.stderr.setEncoding('utf8');
|
|
285
|
-
child.stdout.on('data', (chunk) => {
|
|
286
|
-
stdout += chunk;
|
|
287
|
-
const match = /^team-db: serving (\S+)/m.exec(stdout);
|
|
288
|
-
if (match) settle(resolve, { url: match[1] });
|
|
289
|
-
});
|
|
290
|
-
child.stderr.on('data', (chunk) => {
|
|
291
|
-
stderr += chunk;
|
|
292
|
-
});
|
|
293
|
-
child.once('error', (error) => settle(reject, new UiError('E_UI_CHILD_EXIT', error.message, 2)));
|
|
294
|
-
child.once('exit', (code, signal) => {
|
|
295
|
-
const lastLine = stderr.trim().split('\n').filter(Boolean).slice(-1)[0];
|
|
296
|
-
const failureCode = /EADDRINUSE/.test(`${stdout}\n${stderr}`) ? 'E_UI_PORT_IN_USE' : 'E_UI_CHILD_EXIT';
|
|
297
|
-
const reason = signal === null ? `code ${code}` : signal;
|
|
298
|
-
settle(
|
|
299
|
-
reject,
|
|
300
|
-
new UiError(failureCode, `serve exited (${reason})${lastLine ? `: ${lastLine}` : ''}`, 2),
|
|
301
|
-
);
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* The parent must exit while the server keeps running, so both pipes are
|
|
307
|
-
* destroyed rather than drained — draining would hold the event loop open. The
|
|
308
|
-
* child therefore gets EPIPE on its next diagnostic write after the serving
|
|
309
|
-
* line; `team-db.mjs serve` installs a no-op `error` handler for exactly that.
|
|
310
|
-
*/
|
|
311
|
-
const detachChild = (child) => {
|
|
312
|
-
child.unref();
|
|
313
|
-
for (const stream of [child.stdout, child.stderr]) {
|
|
314
|
-
if (stream) stream.destroy();
|
|
315
|
-
}
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
const terminateSpawned = async (pid) => {
|
|
319
|
-
if (pid !== undefined && isAlive(pid)) await terminate(pid);
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
/* --------------------------------- results -------------------------------- */
|
|
323
|
-
|
|
324
|
-
const engineChangedSince = (startedAt) => {
|
|
325
|
-
const since = Date.parse(startedAt);
|
|
326
|
-
if (Number.isNaN(since)) return false;
|
|
327
|
-
try {
|
|
328
|
-
return fs.statSync(cliPath()).mtimeMs > since;
|
|
329
|
-
} catch {
|
|
330
|
-
return false;
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
const staleWarning = 'stale: the engine changed after the server started; run ui restart';
|
|
335
|
-
|
|
336
|
-
const runningResult = ({ verb, owner, pid, target, startedAt, rootId, marker, health, stale, spawned }) => ({
|
|
337
|
-
ok: true,
|
|
338
|
-
verb,
|
|
339
|
-
running: true,
|
|
340
|
-
spawned: Boolean(spawned),
|
|
341
|
-
owner,
|
|
342
|
-
pid: pid ?? null,
|
|
343
|
-
host: target.host,
|
|
344
|
-
port: target.port,
|
|
345
|
-
url: describeTarget(target),
|
|
346
|
-
startedAt: startedAt ?? null,
|
|
347
|
-
rootId,
|
|
348
|
-
marker,
|
|
349
|
-
health,
|
|
350
|
-
stale,
|
|
351
|
-
staleWarning: stale ? staleWarning : null,
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
const schedulerLine = (health) => {
|
|
355
|
-
const scheduler = health?.scheduler;
|
|
356
|
-
if (!scheduler || typeof scheduler.state !== 'string') return null;
|
|
357
|
-
return `scheduler: ${scheduler.state}${Number.isInteger(scheduler.pid) ? ` (pid ${scheduler.pid})` : ''}`;
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
const pidLabel = (pid) => (Number.isInteger(pid) ? `pid ${pid}, ` : '');
|
|
361
|
-
|
|
362
|
-
/* ---------------------------------- start --------------------------------- */
|
|
363
|
-
|
|
364
|
-
const settleRunning = (roots, marker, health, target) => {
|
|
365
|
-
const healthRootId = typeof health.rootId === 'string' ? health.rootId : null;
|
|
366
|
-
if (healthRootId !== null && healthRootId !== roots.rootId) {
|
|
367
|
-
uiFail(
|
|
368
|
-
'E_UI_OTHER_ROOT',
|
|
369
|
-
`${describeTarget(target)} serves team root ${healthRootId}; this repository is ${roots.rootId}`,
|
|
370
|
-
1,
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
const markerOwned = marker !== null && ownsPid(marker.pid);
|
|
374
|
-
const owned = markerOwned && marker.rootId === roots.rootId;
|
|
375
|
-
const startedAt = owned ? marker.startedAt : null;
|
|
376
|
-
return runningResult({
|
|
377
|
-
verb: 'start',
|
|
378
|
-
owner: owned ? OWNER_STARTED : OWNER_PRE_EXISTING,
|
|
379
|
-
pid: markerOwned ? marker.pid : null,
|
|
380
|
-
target,
|
|
381
|
-
startedAt,
|
|
382
|
-
rootId: roots.rootId,
|
|
383
|
-
marker,
|
|
384
|
-
health,
|
|
385
|
-
stale: owned && engineChangedSince(startedAt),
|
|
386
|
-
});
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Probe with the one repair the lifecycle owns: a `503 E_DB_MISSING` answer buys
|
|
391
|
-
* exactly one bounded `sync` and one re-probe.
|
|
392
|
-
*/
|
|
393
|
-
const probeView = async (roots, target) => {
|
|
394
|
-
const view = classifyProbe(await probeHealth(target.host, target.port));
|
|
395
|
-
if (view.kind === 'foreign') {
|
|
396
|
-
uiFail(
|
|
397
|
-
'E_UI_PORT_FOREIGN',
|
|
398
|
-
`${describeTarget(target)} answered (HTTP ${view.status}) but not with a team-db health document`,
|
|
399
|
-
1,
|
|
400
|
-
);
|
|
401
|
-
}
|
|
402
|
-
if (view.kind !== 'missing-db') return view;
|
|
403
|
-
repairProjection(roots);
|
|
404
|
-
const again = classifyProbe(await probeHealth(target.host, target.port));
|
|
405
|
-
if (again.kind !== 'health') {
|
|
406
|
-
uiFail('E_UI_DB_MISSING', `${describeTarget(target)} still reports a missing projection after one sync`, 1);
|
|
407
|
-
}
|
|
408
|
-
return again;
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
const awaitHealth = async (roots, target, deadline) => {
|
|
412
|
-
while (Date.now() < deadline) {
|
|
413
|
-
const view = classifyProbe(await probeHealth(target.host, target.port));
|
|
414
|
-
if (view.kind === 'health') return view.body;
|
|
415
|
-
if (view.kind === 'missing-db') {
|
|
416
|
-
repairProjection(roots);
|
|
417
|
-
const again = classifyProbe(await probeHealth(target.host, target.port));
|
|
418
|
-
if (again.kind === 'health') return again.body;
|
|
419
|
-
uiFail('E_UI_DB_MISSING', 'the projection is still missing after one sync; run team-db.mjs sync and retry', 1);
|
|
420
|
-
}
|
|
421
|
-
await sleep(HEALTH_POLL_INTERVAL_MS);
|
|
422
|
-
}
|
|
423
|
-
uiFail('E_UI_START_TIMEOUT', `no healthy answer on ${describeTarget(target)} within ${START_TIMEOUT_MS} ms`, 2);
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
const startUi = async (roots, target) => {
|
|
427
|
-
const marker = readMarker(roots).marker;
|
|
428
|
-
const ownedMarker = marker !== null && marker.rootId === roots.rootId && ownsPid(marker.pid) ? marker : null;
|
|
429
|
-
|
|
430
|
-
// A marker that names a live owned server on another target is the same
|
|
431
|
-
// "already running" no-op: one repository never runs two dashboards. A probe
|
|
432
|
-
// that answers anything else falls through to the requested target.
|
|
433
|
-
if (ownedMarker !== null && (ownedMarker.host !== target.host || ownedMarker.port !== target.port)) {
|
|
434
|
-
const own = classifyProbe(await probeHealth(ownedMarker.host, ownedMarker.port));
|
|
435
|
-
if (own.kind === 'health' && own.body.rootId === roots.rootId) {
|
|
436
|
-
return settleRunning(roots, ownedMarker, own.body, { host: ownedMarker.host, port: ownedMarker.port });
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
// Probe first: a server that already answers 200 for this root is the no-op
|
|
441
|
-
// the contract pins (same pid, unchanged `startedAt`). `restart` is the verb
|
|
442
|
-
// that stops and replaces it, so this path never stops or spawns.
|
|
443
|
-
const view = await probeView(roots, target);
|
|
444
|
-
if (view.kind === 'health') return settleRunning(roots, marker, view.body, target);
|
|
445
|
-
|
|
446
|
-
// The port is free: a marker whose pid is gone or not ours is stale.
|
|
447
|
-
if (readMarker(roots).present && ownedMarker === null) removeMarker(roots);
|
|
448
|
-
|
|
449
|
-
const startedAt = new Date().toISOString();
|
|
450
|
-
const deadline = Date.now() + START_TIMEOUT_MS;
|
|
451
|
-
let child;
|
|
452
|
-
try {
|
|
453
|
-
child = spawnServe(roots, target);
|
|
454
|
-
} catch (error) {
|
|
455
|
-
uiFail('E_UI_CHILD_EXIT', `serve could not start: ${error.message}`, 2);
|
|
456
|
-
}
|
|
457
|
-
let serving;
|
|
458
|
-
try {
|
|
459
|
-
serving = await readServingLine(child);
|
|
460
|
-
} catch (error) {
|
|
461
|
-
await terminateSpawned(child.pid);
|
|
462
|
-
if (error.code === 'E_UI_PORT_IN_USE') {
|
|
463
|
-
const raced = classifyProbe(await probeHealth(target.host, target.port));
|
|
464
|
-
if (raced.kind === 'health') return settleRunning(roots, marker, raced.body, target);
|
|
465
|
-
uiFail('E_UI_PORT_IN_USE', `port ${target.port} was taken between the probe and the spawn`, 2);
|
|
466
|
-
}
|
|
467
|
-
throw error;
|
|
468
|
-
}
|
|
469
|
-
detachChild(child);
|
|
470
|
-
const url = new URL(serving.url);
|
|
471
|
-
const boundPort = Number(url.port);
|
|
472
|
-
const nextMarker = {
|
|
473
|
-
schemaVersion: MARKER_SCHEMA_VERSION,
|
|
474
|
-
pid: child.pid,
|
|
475
|
-
host: target.host,
|
|
476
|
-
port: boundPort,
|
|
477
|
-
root: roots.teamRoot,
|
|
478
|
-
rootId: roots.rootId,
|
|
479
|
-
startedAt,
|
|
480
|
-
command: MARKER_COMMAND,
|
|
481
|
-
};
|
|
482
|
-
// Every throw after the spawn leaves neither the marker nor the child behind.
|
|
483
|
-
const cleanup = async () => {
|
|
484
|
-
try {
|
|
485
|
-
fs.rmSync(`${roots.markerPath}.tmp`, { force: true });
|
|
486
|
-
} catch {
|
|
487
|
-
/* the directory itself may be unwritable */
|
|
488
|
-
}
|
|
489
|
-
removeMarker(roots);
|
|
490
|
-
await terminateSpawned(child.pid);
|
|
491
|
-
};
|
|
492
|
-
try {
|
|
493
|
-
writeMarker(roots, nextMarker);
|
|
494
|
-
} catch (error) {
|
|
495
|
-
await cleanup();
|
|
496
|
-
uiFail('E_UI_MARKER_UNWRITABLE', `${roots.markerPath} could not be written: ${error.message}`, 2);
|
|
497
|
-
}
|
|
498
|
-
let health;
|
|
499
|
-
try {
|
|
500
|
-
health = await awaitHealth(roots, { host: target.host, port: boundPort }, deadline);
|
|
501
|
-
} catch (error) {
|
|
502
|
-
await cleanup();
|
|
503
|
-
if (error instanceof UiError) throw error;
|
|
504
|
-
uiFail('E_UI_CHILD_EXIT', `serve failed after it reported its URL: ${error.message}`, 2);
|
|
505
|
-
}
|
|
506
|
-
return runningResult({
|
|
507
|
-
verb: 'start',
|
|
508
|
-
spawned: true,
|
|
509
|
-
owner: OWNER_STARTED,
|
|
510
|
-
pid: child.pid,
|
|
511
|
-
target: { host: target.host, port: boundPort },
|
|
512
|
-
startedAt,
|
|
513
|
-
rootId: roots.rootId,
|
|
514
|
-
marker: nextMarker,
|
|
515
|
-
health,
|
|
516
|
-
stale: false,
|
|
517
|
-
});
|
|
518
|
-
};
|
|
519
|
-
|
|
520
|
-
/* ---------------------------------- stop ---------------------------------- */
|
|
521
|
-
|
|
522
|
-
const stopUi = async (roots) => {
|
|
523
|
-
const { marker, present } = readMarker(roots);
|
|
524
|
-
if (marker === null) {
|
|
525
|
-
if (!present) return { state: 'nothing', pid: null };
|
|
526
|
-
removeMarker(roots);
|
|
527
|
-
return { state: 'stale', pid: null };
|
|
528
|
-
}
|
|
529
|
-
if (!isAlive(marker.pid)) {
|
|
530
|
-
removeMarker(roots);
|
|
531
|
-
return { state: 'stale', pid: marker.pid };
|
|
532
|
-
}
|
|
533
|
-
const command = liveCommand(marker.pid);
|
|
534
|
-
if (command === null || !OWNED_COMMAND.test(command)) {
|
|
535
|
-
return { state: 'unowned', pid: marker.pid };
|
|
536
|
-
}
|
|
537
|
-
const gone = await terminate(marker.pid);
|
|
538
|
-
// A process that outlived SIGKILL keeps its marker: the next call must still
|
|
539
|
-
// find it instead of reporting a clean stop that never happened.
|
|
540
|
-
if (!gone) return { state: 'survived', pid: marker.pid };
|
|
541
|
-
removeMarker(roots);
|
|
542
|
-
return { state: 'stopped', pid: marker.pid };
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
/* --------------------------------- status --------------------------------- */
|
|
546
|
-
|
|
547
|
-
const statusUi = async (roots) => {
|
|
548
|
-
const { marker } = readMarker(roots);
|
|
549
|
-
const owned = marker !== null && ownsPid(marker.pid);
|
|
550
|
-
const target = {
|
|
551
|
-
host: marker?.host ?? DEFAULT_HOST,
|
|
552
|
-
port: marker?.port ?? DEFAULT_PORT,
|
|
553
|
-
};
|
|
554
|
-
const view = classifyProbe(await probeHealth(target.host, target.port));
|
|
555
|
-
if (view.kind !== 'health') {
|
|
556
|
-
return {
|
|
557
|
-
ok: true,
|
|
558
|
-
verb: 'status',
|
|
559
|
-
running: false,
|
|
560
|
-
owner: null,
|
|
561
|
-
pid: null,
|
|
562
|
-
host: target.host,
|
|
563
|
-
port: target.port,
|
|
564
|
-
url: describeTarget(target),
|
|
565
|
-
startedAt: null,
|
|
566
|
-
rootId: roots.rootId,
|
|
567
|
-
marker,
|
|
568
|
-
health: null,
|
|
569
|
-
stale: false,
|
|
570
|
-
staleWarning: null,
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
const startedAt = owned ? marker.startedAt : null;
|
|
574
|
-
return runningResult({
|
|
575
|
-
verb: 'status',
|
|
576
|
-
owner: owned ? OWNER_STARTED : OWNER_PRE_EXISTING,
|
|
577
|
-
pid: owned ? marker.pid : null,
|
|
578
|
-
target,
|
|
579
|
-
startedAt,
|
|
580
|
-
rootId: roots.rootId,
|
|
581
|
-
marker,
|
|
582
|
-
health: view.body,
|
|
583
|
-
stale: owned && engineChangedSince(startedAt),
|
|
584
|
-
});
|
|
585
|
-
};
|
|
586
|
-
|
|
587
|
-
/* -------------------------------- reporting ------------------------------- */
|
|
588
|
-
|
|
589
|
-
const createReporter = (flags) => {
|
|
590
|
-
const json = Boolean(flags.json);
|
|
591
|
-
const quiet = Boolean(flags.quiet);
|
|
592
|
-
return {
|
|
593
|
-
info: (line) => {
|
|
594
|
-
if (!json && !quiet) process.stdout.write(`${line}\n`);
|
|
595
|
-
},
|
|
596
|
-
warn: (line) => process.stderr.write(`${line}\n`),
|
|
597
|
-
result: (value) => {
|
|
598
|
-
if (json) process.stdout.write(`${JSON.stringify(value)}\n`);
|
|
599
|
-
},
|
|
600
|
-
};
|
|
601
|
-
};
|
|
602
|
-
|
|
603
|
-
const announceStart = (out, result) => {
|
|
604
|
-
out.info(`ui: already running (${pidLabel(result.pid)}owner: ${result.owner})`);
|
|
605
|
-
const scheduler = schedulerLine(result.health);
|
|
606
|
-
if (scheduler) out.info(scheduler);
|
|
607
|
-
if (result.stale) out.warn(`ui: ${result.staleWarning}`);
|
|
608
|
-
};
|
|
609
|
-
|
|
610
|
-
const announceFreshStart = (out, result) => {
|
|
611
|
-
out.info(`ui: ${result.url} (pid ${result.pid})`);
|
|
612
|
-
const scheduler = schedulerLine(result.health);
|
|
613
|
-
if (scheduler) out.info(scheduler);
|
|
614
|
-
};
|
|
615
|
-
|
|
616
|
-
const announceStatus = (out, result) => {
|
|
617
|
-
if (!result.running) {
|
|
618
|
-
out.info('ui: nothing running');
|
|
619
|
-
return;
|
|
620
|
-
}
|
|
621
|
-
out.info(`ui: running ${result.url} (${pidLabel(result.pid)}owner: ${result.owner})`);
|
|
622
|
-
const scheduler = schedulerLine(result.health);
|
|
623
|
-
if (scheduler) out.info(scheduler);
|
|
624
|
-
if (result.stale) out.warn(`ui: ${result.staleWarning}`);
|
|
625
|
-
};
|
|
626
|
-
|
|
627
|
-
const announceStop = (out, result) => {
|
|
628
|
-
if (result.state === 'stopped') out.info(`ui: stopped (pid ${result.pid})`);
|
|
629
|
-
else if (result.state === 'stale') out.info('ui: nothing running (stale marker removed)');
|
|
630
|
-
else if (result.state === 'unowned') out.info(`ui: marker pid ${result.pid} is not team-db.mjs serve; left running`);
|
|
631
|
-
else if (result.state === 'survived') {
|
|
632
|
-
out.warn(`ui: pid ${result.pid} is still running after the 5 s grace and SIGKILL; the marker is kept`);
|
|
633
|
-
} else out.info('ui: nothing running');
|
|
634
|
-
};
|
|
635
|
-
|
|
636
|
-
/* ---------------------------------- verbs --------------------------------- */
|
|
637
|
-
|
|
638
|
-
const parseTarget = (flags) => {
|
|
639
|
-
const host = typeof flags.host === 'string' ? flags.host.trim() : DEFAULT_HOST;
|
|
640
|
-
if (!LOOPBACK_HOSTS.includes(host)) {
|
|
641
|
-
uiFail('E_USAGE', `--host ${host || '(empty)'} is not loopback; a ui verb never binds a remote host`, 3);
|
|
642
|
-
}
|
|
643
|
-
const port = flags.port === undefined ? DEFAULT_PORT : Number(flags.port);
|
|
644
|
-
if (!Number.isInteger(port) || port < 0 || port > 65535) {
|
|
645
|
-
uiFail('E_USAGE', '--port must be an integer between 0 and 65535', 3);
|
|
646
|
-
}
|
|
647
|
-
return { host, port };
|
|
648
|
-
};
|
|
649
|
-
|
|
650
|
-
/**
|
|
651
|
-
* The two environment refusals every start-shaped verb shares. Both must land
|
|
652
|
-
* before the first write or probe: a disabled runtime must not stop a live
|
|
653
|
-
* server, write a marker or run the repair sync.
|
|
654
|
-
*/
|
|
655
|
-
const assertStartAllowed = () => {
|
|
656
|
-
if (isKillSwitchSet(process.env)) uiFail('E_DISABLED', 'disabled by AI_RULES_TEAM_DB_DISABLE', 1);
|
|
657
|
-
if (!isSqliteAvailable(process.env)) uiFail('E_UI_UNAVAILABLE', INDEX_UNAVAILABLE_LINE, 1);
|
|
658
|
-
};
|
|
659
|
-
|
|
660
|
-
const openDashboard = (url) => {
|
|
661
|
-
try {
|
|
662
|
-
const command = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'explorer' : 'xdg-open';
|
|
663
|
-
const child = spawn(command, [url], { detached: true, stdio: 'ignore' });
|
|
664
|
-
child.on('error', (error) => {
|
|
665
|
-
process.stderr.write(`ui: could not open ${url} (${error.code ?? error.message}); open it manually\n`);
|
|
666
|
-
});
|
|
667
|
-
child.unref();
|
|
668
|
-
} catch {
|
|
669
|
-
/* opening a browser is a convenience, never a failure */
|
|
670
|
-
}
|
|
671
|
-
};
|
|
672
|
-
|
|
673
|
-
const runStart = async (flags, out) => {
|
|
674
|
-
const roots = resolveRoots(flags);
|
|
675
|
-
const target = parseTarget(flags);
|
|
676
|
-
assertStartAllowed();
|
|
677
|
-
// Probe-first no-op; the only writes are the marker and at most one sync.
|
|
678
|
-
const result = await startUi(roots, target);
|
|
679
|
-
if (result.spawned) announceFreshStart(out, result);
|
|
680
|
-
else announceStart(out, result);
|
|
681
|
-
if (flags.open) openDashboard(result.url);
|
|
682
|
-
out.result(result);
|
|
683
|
-
return 0;
|
|
684
|
-
};
|
|
685
|
-
|
|
686
|
-
const runRestart = async (flags, out) => {
|
|
687
|
-
// `restart` is the explicit stop+start verb; `start` never stops anything.
|
|
688
|
-
const roots = resolveRoots(flags);
|
|
689
|
-
const target = parseTarget(flags);
|
|
690
|
-
assertStartAllowed();
|
|
691
|
-
const stopped = await stopUi(roots);
|
|
692
|
-
if (stopped.state === 'survived') {
|
|
693
|
-
announceStop(out, stopped);
|
|
694
|
-
out.result({ ok: false, verb: 'restart', state: stopped.state, pid: stopped.pid });
|
|
695
|
-
return 1;
|
|
696
|
-
}
|
|
697
|
-
if (stopped.state !== 'nothing') announceStop(out, stopped);
|
|
698
|
-
const result = await startUi(roots, target);
|
|
699
|
-
if (result.spawned) announceFreshStart(out, result);
|
|
700
|
-
else announceStart(out, result);
|
|
701
|
-
if (flags.open) openDashboard(result.url);
|
|
702
|
-
out.result(result);
|
|
703
|
-
return 0;
|
|
704
|
-
};
|
|
705
|
-
|
|
706
|
-
const runStop = async (flags, out) => {
|
|
707
|
-
const result = await stopUi(resolveRoots(flags));
|
|
708
|
-
announceStop(out, result);
|
|
709
|
-
out.result({ ok: result.state !== 'survived', verb: 'stop', state: result.state, pid: result.pid });
|
|
710
|
-
return result.state === 'survived' ? 1 : 0;
|
|
711
|
-
};
|
|
712
|
-
|
|
713
|
-
const runStatus = async (flags, out) => {
|
|
714
|
-
const result = await statusUi(resolveRoots(flags));
|
|
715
|
-
announceStatus(out, result);
|
|
716
|
-
out.result(result);
|
|
717
|
-
return 0;
|
|
718
|
-
};
|
|
719
|
-
|
|
720
|
-
const runVerb = async (verb, flags, out) => {
|
|
721
|
-
if (verb === 'stop') return runStop(flags, out);
|
|
722
|
-
if (verb === 'status') return runStatus(flags, out);
|
|
723
|
-
if (verb === 'restart') return runRestart(flags, out);
|
|
724
|
-
return runStart(flags, out);
|
|
725
|
-
};
|
|
726
|
-
|
|
727
|
-
/* ---------------------------------- entry --------------------------------- */
|
|
728
|
-
|
|
729
|
-
/**
|
|
730
|
-
* One `ui` dispatch: `positionals[0]` is the verb, and the flags already passed
|
|
731
|
-
* the CLI's union allow-list, so this layer owns the per-verb reach table.
|
|
732
|
-
*/
|
|
733
|
-
export async function runUiCommand({ flags, positionals }) {
|
|
734
|
-
const out = createReporter(flags);
|
|
735
|
-
try {
|
|
736
|
-
const [verb, ...rest] = positionals;
|
|
737
|
-
if (verb === undefined) uiFail('E_USAGE', 'ui needs a verb: start, stop, status or restart', 3);
|
|
738
|
-
if (rest.length > 0) uiFail('E_USAGE', `ui ${verb} takes no further arguments`, 3);
|
|
739
|
-
if (!VERB_FLAGS[verb]) uiFail('E_USAGE', `unknown ui verb "${verb}"; expected start, stop, status or restart`, 3);
|
|
740
|
-
for (const name of Object.keys(flags)) {
|
|
741
|
-
if (!VERB_FLAGS[verb].has(name)) uiFail('E_USAGE', `flag --${name} does not apply to ui ${verb}`, 3);
|
|
742
|
-
}
|
|
743
|
-
return await runVerb(verb, flags, out);
|
|
744
|
-
} catch (error) {
|
|
745
|
-
if (!(error instanceof UiError)) throw error;
|
|
746
|
-
out.result({ ok: false, code: error.code, message: error.message });
|
|
747
|
-
out.warn(`ui: ${error.code}: ${error.message}`);
|
|
748
|
-
return error.exitCode;
|
|
749
|
-
}
|
|
750
|
-
}
|