@bonesofspring/ai-rules 0.2.71 → 0.2.73
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 +44 -0
- package/README.md +7 -6
- package/bin/lib/ai-local-drift.js +4 -4
- package/bin/lib/engine-scripts.js +11 -0
- package/bin/lib/seed-ai-local-team.js +9 -5
- package/docs/OPENCODE.md +4 -2
- package/docs/TEAM-DB.md +27 -9
- package/package.json +1 -1
- package/presets/_shared/ai-local/scripts/aggregate-agent-task-metrics.mjs +201 -0
- package/presets/_shared/ai-local/scripts/incidents.mjs +452 -0
- package/presets/_shared/ai-local/scripts/manifest.mjs +19 -1
- package/presets/_shared/ai-local/scripts/record-usage.mjs +163 -0
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +75 -11
- package/presets/_shared/ai-local/scripts/team-db.mjs +125 -40
- package/presets/_shared/ai-local/scripts/tracker-planned-drain.mjs +335 -0
- package/presets/_shared/ai-local/scripts/verification.mjs +374 -0
- package/presets/_shared/core/agent-team/agent-artifact-contracts.md +9 -0
- package/presets/_shared/core/agent-team/agent-task-metrics.md +61 -1
- package/presets/_shared/core/agent-team/agent-team-intake.md +2 -2
- package/presets/_shared/core/agent-team/agent-team-orchestrator.md +5 -4
- package/presets/_shared/core/agent-team/incident-registry.md +47 -0
- package/presets/_shared/core/architecture/feature-delivery-workflow.md +1 -1
- package/presets/_shared/core/quality/self-review-and-context-hygiene.md +1 -0
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +108 -1
- package/presets/claude/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/claude/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/claude/android-kotlin/agents/debugger.md +1 -1
- package/presets/claude/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/claude/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +108 -1
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
- package/presets/claude/go/agents/build-verifier.md +1 -1
- package/presets/claude/go/agents/code-reviewer.md +1 -1
- package/presets/claude/go/agents/debugger.md +1 -1
- package/presets/claude/go/agents/feature-developer.md +1 -1
- package/presets/claude/go/agents/task-analyst.md +1 -1
- package/presets/claude/go/hooks/chain-team-phases.sh +108 -1
- package/presets/claude/go/rules/architecture/feature-delivery.md +1 -1
- package/presets/claude/go/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
- package/presets/claude/ios-swift/agents/build-verifier.md +1 -1
- package/presets/claude/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/claude/ios-swift/agents/debugger.md +1 -1
- package/presets/claude/ios-swift/agents/feature-developer.md +1 -1
- package/presets/claude/ios-swift/agents/task-analyst.md +1 -1
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +108 -1
- package/presets/claude/ios-swift/rules/architecture/feature-delivery.md +1 -1
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
- package/presets/claude/java/agents/build-verifier.md +1 -1
- package/presets/claude/java/agents/code-reviewer.md +1 -1
- package/presets/claude/java/agents/debugger.md +1 -1
- package/presets/claude/java/agents/feature-developer.md +1 -1
- package/presets/claude/java/agents/task-analyst.md +1 -1
- package/presets/claude/java/hooks/chain-team-phases.sh +108 -1
- package/presets/claude/java/rules/architecture/feature-delivery.md +1 -1
- package/presets/claude/java/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
- package/presets/claude/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/claude/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/claude/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +108 -1
- package/presets/claude/mcp-ts/rules/architecture/feature-delivery.md +1 -1
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
- package/presets/claude/mol/agents/build-verifier.md +1 -1
- package/presets/claude/mol/agents/code-reviewer.md +1 -1
- package/presets/claude/mol/agents/debugger.md +1 -1
- package/presets/claude/mol/agents/feature-developer.md +1 -1
- package/presets/claude/mol/agents/task-analyst.md +1 -1
- package/presets/claude/mol/hooks/chain-team-phases.sh +108 -1
- package/presets/claude/mol/rules/architecture/feature-delivery-workflow.md +1 -1
- package/presets/claude/mol/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
- package/presets/claude/next/REPO_AGENTS.md +16 -0
- package/presets/claude/next/agents/README.md +4 -3
- package/presets/claude/next/agents/accessibility-reviewer.md +4 -1
- package/presets/claude/next/agents/api-contract-reviewer.md +6 -3
- package/presets/claude/next/agents/build-verifier.md +6 -3
- package/presets/claude/next/agents/ci-investigator.md +1 -1
- package/presets/claude/next/agents/code-reviewer.md +7 -4
- package/presets/claude/next/agents/codebase-analyzer.md +4 -1
- package/presets/claude/next/agents/debugger.md +2 -2
- package/presets/claude/next/agents/feature-developer.md +2 -2
- package/presets/claude/next/agents/migration-specialist.md +4 -1
- package/presets/claude/next/agents/mockup-reviewer.md +5 -2
- package/presets/claude/next/agents/openspec-author.md +4 -1
- package/presets/claude/next/agents/performance-auditor.md +4 -1
- package/presets/claude/next/agents/playwright-test-generator.md +5 -2
- package/presets/claude/next/agents/playwright-test-healer.md +5 -2
- package/presets/claude/next/agents/playwright-test-planner.md +5 -2
- package/presets/claude/next/agents/qa-tester.md +5 -2
- package/presets/claude/next/agents/security-reviewer.md +4 -1
- package/presets/claude/next/agents/solution-architect.md +4 -1
- package/presets/claude/next/agents/task-analyst.md +5 -2
- package/presets/claude/next/agents/task-router.md +8 -5
- package/presets/claude/next/agents/tech-writer.md +4 -1
- package/presets/claude/next/agents/unit-test-generator.md +5 -2
- package/presets/claude/next/agents/unit-test-healer.md +5 -2
- package/presets/claude/next/agents/unit-test-planner.md +5 -2
- package/presets/claude/next/ai-local/conventions.md +26 -1
- package/presets/claude/next/hooks/chain-team-phases.sh +108 -1
- package/presets/claude/next/rules/architecture/feature-delivery-workflow.md +2 -2
- package/presets/claude/next/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
- package/presets/claude/nuxt/agents/build-verifier.md +1 -1
- package/presets/claude/nuxt/agents/code-reviewer.md +1 -1
- package/presets/claude/nuxt/agents/debugger.md +1 -1
- package/presets/claude/nuxt/agents/feature-developer.md +1 -1
- package/presets/claude/nuxt/agents/task-analyst.md +1 -1
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +108 -1
- package/presets/claude/nuxt/rules/architecture/feature-delivery-workflow.md +1 -1
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
- package/presets/claude/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/claude/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/claude/php-hexagonal/agents/debugger.md +1 -1
- package/presets/claude/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/claude/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +108 -1
- package/presets/claude/php-hexagonal/rules/architecture/feature-delivery.md +1 -1
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
- package/presets/claude/php-laravel/agents/build-verifier.md +1 -1
- package/presets/claude/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/claude/php-laravel/agents/debugger.md +1 -1
- package/presets/claude/php-laravel/agents/feature-developer.md +1 -1
- package/presets/claude/php-laravel/agents/task-analyst.md +1 -1
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +108 -1
- package/presets/claude/php-laravel/rules/architecture/feature-delivery.md +1 -1
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
- package/presets/claude/svelte/agents/build-verifier.md +1 -1
- package/presets/claude/svelte/agents/code-reviewer.md +1 -1
- package/presets/claude/svelte/agents/debugger.md +1 -1
- package/presets/claude/svelte/agents/feature-developer.md +1 -1
- package/presets/claude/svelte/agents/task-analyst.md +1 -1
- package/presets/claude/svelte/hooks/chain-team-phases.sh +108 -1
- package/presets/claude/svelte/rules/architecture/feature-delivery-workflow.md +1 -1
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +5 -4
- package/presets/cursor/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/cursor/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/cursor/android-kotlin/agents/debugger.md +1 -1
- package/presets/cursor/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/cursor/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +108 -1
- package/presets/cursor/android-kotlin/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/go/agents/build-verifier.md +1 -1
- package/presets/cursor/go/agents/code-reviewer.md +1 -1
- package/presets/cursor/go/agents/debugger.md +1 -1
- package/presets/cursor/go/agents/feature-developer.md +1 -1
- package/presets/cursor/go/agents/task-analyst.md +1 -1
- package/presets/cursor/go/hooks/chain-team-phases.sh +108 -1
- package/presets/cursor/go/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/go/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/ios-swift/agents/build-verifier.md +1 -1
- package/presets/cursor/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/cursor/ios-swift/agents/debugger.md +1 -1
- package/presets/cursor/ios-swift/agents/feature-developer.md +1 -1
- package/presets/cursor/ios-swift/agents/task-analyst.md +1 -1
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +108 -1
- package/presets/cursor/ios-swift/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/java/agents/build-verifier.md +1 -1
- package/presets/cursor/java/agents/code-reviewer.md +1 -1
- package/presets/cursor/java/agents/debugger.md +1 -1
- package/presets/cursor/java/agents/feature-developer.md +1 -1
- package/presets/cursor/java/agents/task-analyst.md +1 -1
- package/presets/cursor/java/hooks/chain-team-phases.sh +108 -1
- package/presets/cursor/java/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/java/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/cursor/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/cursor/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +108 -1
- package/presets/cursor/mcp-ts/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mol/agents/build-verifier.md +1 -1
- package/presets/cursor/mol/agents/code-reviewer.md +1 -1
- package/presets/cursor/mol/agents/debugger.md +1 -1
- package/presets/cursor/mol/agents/feature-developer.md +1 -1
- package/presets/cursor/mol/agents/task-analyst.md +1 -1
- package/presets/cursor/mol/hooks/chain-team-phases.sh +108 -1
- package/presets/cursor/mol/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/next/AGENTS.md +2 -1
- package/presets/cursor/next/REPO_AGENTS.md +16 -0
- package/presets/cursor/next/agents/README.md +4 -3
- package/presets/cursor/next/agents/api-contract-reviewer.md +1 -1
- package/presets/cursor/next/agents/build-verifier.md +1 -1
- package/presets/cursor/next/agents/code-reviewer.md +1 -1
- package/presets/cursor/next/agents/debugger.md +1 -1
- package/presets/cursor/next/agents/feature-developer.md +1 -1
- package/presets/cursor/next/agents/mockup-reviewer.md +1 -1
- package/presets/cursor/next/agents/task-analyst.md +1 -1
- package/presets/cursor/next/agents/task-router.md +4 -4
- package/presets/cursor/next/ai-local/conventions.md +6 -1
- package/presets/cursor/next/hooks/chain-team-phases.sh +108 -1
- package/presets/cursor/next/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/next/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/next/rules/feature-delivery-workflow.mdc +1 -1
- package/presets/cursor/nuxt/agents/build-verifier.md +1 -1
- package/presets/cursor/nuxt/agents/code-reviewer.md +1 -1
- package/presets/cursor/nuxt/agents/debugger.md +1 -1
- package/presets/cursor/nuxt/agents/feature-developer.md +1 -1
- package/presets/cursor/nuxt/agents/task-analyst.md +1 -1
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +108 -1
- package/presets/cursor/nuxt/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/cursor/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/cursor/php-hexagonal/agents/debugger.md +1 -1
- package/presets/cursor/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/cursor/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +108 -1
- package/presets/cursor/php-hexagonal/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-laravel/agents/build-verifier.md +1 -1
- package/presets/cursor/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/cursor/php-laravel/agents/debugger.md +1 -1
- package/presets/cursor/php-laravel/agents/feature-developer.md +1 -1
- package/presets/cursor/php-laravel/agents/task-analyst.md +1 -1
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +108 -1
- package/presets/cursor/php-laravel/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/svelte/agents/build-verifier.md +1 -1
- package/presets/cursor/svelte/agents/code-reviewer.md +1 -1
- package/presets/cursor/svelte/agents/debugger.md +1 -1
- package/presets/cursor/svelte/agents/feature-developer.md +1 -1
- package/presets/cursor/svelte/agents/task-analyst.md +1 -1
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +108 -1
- package/presets/cursor/svelte/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/agents/README.md +3 -3
- package/presets/mavis/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/mavis/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/mavis/android-kotlin/agents/debugger.md +1 -1
- package/presets/mavis/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/mavis/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +108 -1
- package/presets/mavis/android-kotlin/rules/agent-team-intake.md +2 -2
- package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +5 -4
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/agents/README.md +2 -2
- package/presets/mavis/go/agents/build-verifier.md +1 -1
- package/presets/mavis/go/agents/code-reviewer.md +1 -1
- package/presets/mavis/go/agents/debugger.md +1 -1
- package/presets/mavis/go/agents/feature-developer.md +1 -1
- package/presets/mavis/go/agents/task-analyst.md +1 -1
- package/presets/mavis/go/hooks/chain-team-phases.sh +108 -1
- package/presets/mavis/go/rules/agent-team-intake.md +2 -2
- package/presets/mavis/go/rules/agent-team-orchestrator.md +5 -4
- package/presets/mavis/go/rules/feature-delivery-workflow.md +1 -1
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/agents/README.md +3 -3
- package/presets/mavis/ios-swift/agents/build-verifier.md +1 -1
- package/presets/mavis/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/mavis/ios-swift/agents/debugger.md +1 -1
- package/presets/mavis/ios-swift/agents/feature-developer.md +1 -1
- package/presets/mavis/ios-swift/agents/task-analyst.md +1 -1
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +108 -1
- package/presets/mavis/ios-swift/rules/agent-team-intake.md +2 -2
- package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +5 -4
- package/presets/mavis/ios-swift/rules/feature-delivery-workflow.md +1 -1
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/agents/README.md +2 -2
- package/presets/mavis/java/agents/build-verifier.md +1 -1
- package/presets/mavis/java/agents/code-reviewer.md +1 -1
- package/presets/mavis/java/agents/debugger.md +1 -1
- package/presets/mavis/java/agents/feature-developer.md +1 -1
- package/presets/mavis/java/agents/task-analyst.md +1 -1
- package/presets/mavis/java/hooks/chain-team-phases.sh +108 -1
- package/presets/mavis/java/rules/agent-team-intake.md +2 -2
- package/presets/mavis/java/rules/agent-team-orchestrator.md +5 -4
- package/presets/mavis/java/rules/feature-delivery-workflow.md +1 -1
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/agents/README.md +1 -1
- package/presets/mavis/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/mavis/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/mavis/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +108 -1
- package/presets/mavis/mcp-ts/rules/agent-team-intake.md +2 -2
- package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +5 -4
- package/presets/mavis/mcp-ts/rules/feature-delivery-workflow.md +1 -1
- package/presets/mavis/mol/adapter-map.json +1 -1
- package/presets/mavis/mol/agents/README.md +3 -3
- package/presets/mavis/mol/agents/build-verifier.md +1 -1
- package/presets/mavis/mol/agents/code-reviewer.md +1 -1
- package/presets/mavis/mol/agents/debugger.md +1 -1
- package/presets/mavis/mol/agents/feature-developer.md +1 -1
- package/presets/mavis/mol/agents/task-analyst.md +1 -1
- package/presets/mavis/mol/hooks/chain-team-phases.sh +108 -1
- package/presets/mavis/mol/rules/agent-team-intake.md +2 -2
- package/presets/mavis/mol/rules/agent-team-orchestrator.md +5 -4
- package/presets/mavis/mol/rules/feature-delivery-workflow.md +1 -1
- package/presets/mavis/next/MAVIS.md +2 -1
- package/presets/mavis/next/REPO_AGENTS.md +16 -0
- package/presets/mavis/next/adapter-map.json +1 -1
- package/presets/mavis/next/agents/README.md +3 -3
- package/presets/mavis/next/agents/accessibility-reviewer.md +4 -1
- package/presets/mavis/next/agents/api-contract-reviewer.md +5 -2
- package/presets/mavis/next/agents/build-verifier.md +6 -3
- package/presets/mavis/next/agents/ci-investigator.md +1 -1
- package/presets/mavis/next/agents/code-reviewer.md +7 -4
- package/presets/mavis/next/agents/codebase-analyzer.md +4 -1
- package/presets/mavis/next/agents/debugger.md +2 -2
- package/presets/mavis/next/agents/feature-developer.md +2 -2
- package/presets/mavis/next/agents/migration-specialist.md +4 -1
- package/presets/mavis/next/agents/mockup-reviewer.md +4 -1
- package/presets/mavis/next/agents/openspec-author.md +4 -1
- package/presets/mavis/next/agents/performance-auditor.md +4 -1
- package/presets/mavis/next/agents/playwright-test-generator.md +5 -2
- package/presets/mavis/next/agents/playwright-test-healer.md +5 -2
- package/presets/mavis/next/agents/playwright-test-planner.md +5 -2
- package/presets/mavis/next/agents/qa-tester.md +5 -2
- package/presets/mavis/next/agents/security-reviewer.md +4 -1
- package/presets/mavis/next/agents/solution-architect.md +4 -1
- package/presets/mavis/next/agents/task-analyst.md +5 -2
- package/presets/mavis/next/agents/task-router.md +8 -5
- package/presets/mavis/next/agents/tech-writer.md +4 -1
- package/presets/mavis/next/agents/unit-test-generator.md +5 -2
- package/presets/mavis/next/agents/unit-test-healer.md +5 -2
- package/presets/mavis/next/agents/unit-test-planner.md +5 -2
- package/presets/mavis/next/ai-local/conventions.md +6 -1
- package/presets/mavis/next/hooks/chain-team-phases.sh +108 -1
- package/presets/mavis/next/rules/agent-team-intake.md +2 -2
- package/presets/mavis/next/rules/agent-team-orchestrator.md +5 -4
- package/presets/mavis/next/rules/feature-delivery-workflow.md +2 -2
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/agents/README.md +3 -3
- package/presets/mavis/nuxt/agents/build-verifier.md +1 -1
- package/presets/mavis/nuxt/agents/code-reviewer.md +1 -1
- package/presets/mavis/nuxt/agents/debugger.md +1 -1
- package/presets/mavis/nuxt/agents/feature-developer.md +1 -1
- package/presets/mavis/nuxt/agents/task-analyst.md +1 -1
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +108 -1
- package/presets/mavis/nuxt/rules/agent-team-intake.md +2 -2
- package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +5 -4
- package/presets/mavis/nuxt/rules/feature-delivery-workflow.md +1 -1
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/agents/README.md +2 -2
- package/presets/mavis/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/mavis/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/mavis/php-hexagonal/agents/debugger.md +1 -1
- package/presets/mavis/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/mavis/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +108 -1
- package/presets/mavis/php-hexagonal/rules/agent-team-intake.md +2 -2
- package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +5 -4
- package/presets/mavis/php-hexagonal/rules/feature-delivery-workflow.md +1 -1
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/agents/README.md +2 -2
- package/presets/mavis/php-laravel/agents/build-verifier.md +1 -1
- package/presets/mavis/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/mavis/php-laravel/agents/debugger.md +1 -1
- package/presets/mavis/php-laravel/agents/feature-developer.md +1 -1
- package/presets/mavis/php-laravel/agents/task-analyst.md +1 -1
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +108 -1
- package/presets/mavis/php-laravel/rules/agent-team-intake.md +2 -2
- package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +5 -4
- package/presets/mavis/php-laravel/rules/feature-delivery-workflow.md +1 -1
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/agents/README.md +3 -3
- package/presets/mavis/svelte/agents/build-verifier.md +1 -1
- package/presets/mavis/svelte/agents/code-reviewer.md +1 -1
- package/presets/mavis/svelte/agents/debugger.md +1 -1
- package/presets/mavis/svelte/agents/feature-developer.md +1 -1
- package/presets/mavis/svelte/agents/task-analyst.md +1 -1
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +108 -1
- package/presets/mavis/svelte/rules/agent-team-intake.md +2 -2
- package/presets/mavis/svelte/rules/agent-team-orchestrator.md +5 -4
- package/presets/mavis/svelte/rules/feature-delivery-workflow.md +1 -1
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/agents/README.md +4 -4
- package/presets/opencode/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/opencode/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/opencode/android-kotlin/agents/debugger.md +1 -1
- package/presets/opencode/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +108 -1
- package/presets/opencode/android-kotlin/rules/agent-team-intake.md +2 -2
- package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +5 -4
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/agents/README.md +3 -3
- package/presets/opencode/go/agents/build-verifier.md +1 -1
- package/presets/opencode/go/agents/code-reviewer.md +1 -1
- package/presets/opencode/go/agents/debugger.md +1 -1
- package/presets/opencode/go/agents/feature-developer.md +1 -1
- package/presets/opencode/go/agents/task-analyst.md +1 -1
- package/presets/opencode/go/hooks/chain-team-phases.sh +108 -1
- package/presets/opencode/go/rules/agent-team-intake.md +2 -2
- package/presets/opencode/go/rules/agent-team-orchestrator.md +5 -4
- package/presets/opencode/go/rules/feature-delivery-workflow.md +1 -1
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/agents/README.md +4 -4
- package/presets/opencode/ios-swift/agents/build-verifier.md +1 -1
- package/presets/opencode/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/opencode/ios-swift/agents/debugger.md +1 -1
- package/presets/opencode/ios-swift/agents/feature-developer.md +1 -1
- package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +108 -1
- package/presets/opencode/ios-swift/rules/agent-team-intake.md +2 -2
- package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +5 -4
- package/presets/opencode/ios-swift/rules/feature-delivery-workflow.md +1 -1
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/agents/README.md +3 -3
- package/presets/opencode/java/agents/build-verifier.md +1 -1
- package/presets/opencode/java/agents/code-reviewer.md +1 -1
- package/presets/opencode/java/agents/debugger.md +1 -1
- package/presets/opencode/java/agents/feature-developer.md +1 -1
- package/presets/opencode/java/agents/task-analyst.md +1 -1
- package/presets/opencode/java/hooks/chain-team-phases.sh +108 -1
- package/presets/opencode/java/rules/agent-team-intake.md +2 -2
- package/presets/opencode/java/rules/agent-team-orchestrator.md +5 -4
- package/presets/opencode/java/rules/feature-delivery-workflow.md +1 -1
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- package/presets/opencode/mcp-ts/agents/README.md +2 -2
- package/presets/opencode/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/opencode/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +108 -1
- package/presets/opencode/mcp-ts/rules/agent-team-intake.md +2 -2
- package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +5 -4
- package/presets/opencode/mcp-ts/rules/feature-delivery-workflow.md +1 -1
- package/presets/opencode/mol/adapter-map.json +1 -1
- package/presets/opencode/mol/agents/README.md +4 -4
- package/presets/opencode/mol/agents/build-verifier.md +1 -1
- package/presets/opencode/mol/agents/code-reviewer.md +1 -1
- package/presets/opencode/mol/agents/debugger.md +1 -1
- package/presets/opencode/mol/agents/feature-developer.md +1 -1
- package/presets/opencode/mol/agents/task-analyst.md +1 -1
- package/presets/opencode/mol/hooks/chain-team-phases.sh +108 -1
- package/presets/opencode/mol/rules/agent-team-intake.md +2 -2
- package/presets/opencode/mol/rules/agent-team-orchestrator.md +5 -4
- package/presets/opencode/mol/rules/feature-delivery-workflow.md +1 -1
- package/presets/opencode/next/OPENCODE.md +2 -1
- package/presets/opencode/next/REPO_AGENTS.md +16 -0
- package/presets/opencode/next/adapter-map.json +1 -1
- package/presets/opencode/next/agents/README.md +4 -4
- package/presets/opencode/next/agents/accessibility-reviewer.md +4 -1
- package/presets/opencode/next/agents/api-contract-reviewer.md +5 -2
- package/presets/opencode/next/agents/build-verifier.md +6 -3
- package/presets/opencode/next/agents/ci-investigator.md +1 -1
- package/presets/opencode/next/agents/code-reviewer.md +7 -4
- package/presets/opencode/next/agents/codebase-analyzer.md +4 -1
- package/presets/opencode/next/agents/debugger.md +2 -2
- package/presets/opencode/next/agents/feature-developer.md +2 -2
- package/presets/opencode/next/agents/migration-specialist.md +4 -1
- package/presets/opencode/next/agents/mockup-reviewer.md +4 -1
- package/presets/opencode/next/agents/openspec-author.md +4 -1
- package/presets/opencode/next/agents/performance-auditor.md +4 -1
- package/presets/opencode/next/agents/playwright-test-generator.md +5 -2
- package/presets/opencode/next/agents/playwright-test-healer.md +5 -2
- package/presets/opencode/next/agents/playwright-test-planner.md +5 -2
- package/presets/opencode/next/agents/qa-tester.md +5 -2
- package/presets/opencode/next/agents/security-reviewer.md +4 -1
- package/presets/opencode/next/agents/solution-architect.md +4 -1
- package/presets/opencode/next/agents/task-analyst.md +5 -2
- package/presets/opencode/next/agents/task-router.md +8 -5
- package/presets/opencode/next/agents/tech-writer.md +4 -1
- package/presets/opencode/next/agents/unit-test-generator.md +5 -2
- package/presets/opencode/next/agents/unit-test-healer.md +5 -2
- package/presets/opencode/next/agents/unit-test-planner.md +5 -2
- package/presets/opencode/next/ai-local/conventions.md +6 -1
- package/presets/opencode/next/hooks/chain-team-phases.sh +108 -1
- package/presets/opencode/next/rules/agent-team-intake.md +2 -2
- package/presets/opencode/next/rules/agent-team-orchestrator.md +5 -4
- package/presets/opencode/next/rules/feature-delivery-workflow.md +2 -2
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/agents/README.md +4 -4
- package/presets/opencode/nuxt/agents/build-verifier.md +1 -1
- package/presets/opencode/nuxt/agents/code-reviewer.md +1 -1
- package/presets/opencode/nuxt/agents/debugger.md +1 -1
- package/presets/opencode/nuxt/agents/feature-developer.md +1 -1
- package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +108 -1
- package/presets/opencode/nuxt/rules/agent-team-intake.md +2 -2
- package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +5 -4
- package/presets/opencode/nuxt/rules/feature-delivery-workflow.md +1 -1
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/agents/README.md +3 -3
- package/presets/opencode/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/opencode/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/debugger.md +1 -1
- package/presets/opencode/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +108 -1
- package/presets/opencode/php-hexagonal/rules/agent-team-intake.md +2 -2
- package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +5 -4
- package/presets/opencode/php-hexagonal/rules/feature-delivery-workflow.md +1 -1
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/agents/README.md +3 -3
- package/presets/opencode/php-laravel/agents/build-verifier.md +1 -1
- package/presets/opencode/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/opencode/php-laravel/agents/debugger.md +1 -1
- package/presets/opencode/php-laravel/agents/feature-developer.md +1 -1
- package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +108 -1
- package/presets/opencode/php-laravel/rules/agent-team-intake.md +2 -2
- package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +5 -4
- package/presets/opencode/php-laravel/rules/feature-delivery-workflow.md +1 -1
- package/presets/opencode/plugins/output-guard/README.md +25 -6
- package/presets/opencode/plugins/output-guard/index.ts +27 -9
- package/presets/opencode/plugins/output-guard/rewrite.ts +113 -4
- package/presets/opencode/svelte/adapter-map.json +1 -1
- package/presets/opencode/svelte/agents/README.md +4 -4
- package/presets/opencode/svelte/agents/build-verifier.md +1 -1
- package/presets/opencode/svelte/agents/code-reviewer.md +1 -1
- package/presets/opencode/svelte/agents/debugger.md +1 -1
- package/presets/opencode/svelte/agents/feature-developer.md +1 -1
- package/presets/opencode/svelte/agents/task-analyst.md +1 -1
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +108 -1
- package/presets/opencode/svelte/rules/agent-team-intake.md +2 -2
- package/presets/opencode/svelte/rules/agent-team-orchestrator.md +5 -4
- package/presets/opencode/svelte/rules/feature-delivery-workflow.md +1 -1
- package/presets/zcode/android-kotlin/adapter-map.json +1 -1
- package/presets/zcode/android-kotlin/agents/README.md +3 -3
- package/presets/zcode/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/zcode/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/zcode/android-kotlin/agents/debugger.md +1 -1
- package/presets/zcode/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/zcode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +108 -1
- package/presets/zcode/android-kotlin/rules/agent-team-intake.md +2 -2
- package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +5 -4
- package/presets/zcode/go/adapter-map.json +1 -1
- package/presets/zcode/go/agents/README.md +2 -2
- package/presets/zcode/go/agents/build-verifier.md +1 -1
- package/presets/zcode/go/agents/code-reviewer.md +1 -1
- package/presets/zcode/go/agents/debugger.md +1 -1
- package/presets/zcode/go/agents/feature-developer.md +1 -1
- package/presets/zcode/go/agents/task-analyst.md +1 -1
- package/presets/zcode/go/hooks/chain-team-phases.sh +108 -1
- package/presets/zcode/go/rules/agent-team-intake.md +2 -2
- package/presets/zcode/go/rules/agent-team-orchestrator.md +5 -4
- package/presets/zcode/go/rules/feature-delivery-workflow.md +1 -1
- package/presets/zcode/ios-swift/adapter-map.json +1 -1
- package/presets/zcode/ios-swift/agents/README.md +3 -3
- package/presets/zcode/ios-swift/agents/build-verifier.md +1 -1
- package/presets/zcode/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/zcode/ios-swift/agents/debugger.md +1 -1
- package/presets/zcode/ios-swift/agents/feature-developer.md +1 -1
- package/presets/zcode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +108 -1
- package/presets/zcode/ios-swift/rules/agent-team-intake.md +2 -2
- package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +5 -4
- package/presets/zcode/ios-swift/rules/feature-delivery-workflow.md +1 -1
- package/presets/zcode/java/adapter-map.json +1 -1
- package/presets/zcode/java/agents/README.md +2 -2
- package/presets/zcode/java/agents/build-verifier.md +1 -1
- package/presets/zcode/java/agents/code-reviewer.md +1 -1
- package/presets/zcode/java/agents/debugger.md +1 -1
- package/presets/zcode/java/agents/feature-developer.md +1 -1
- package/presets/zcode/java/agents/task-analyst.md +1 -1
- package/presets/zcode/java/hooks/chain-team-phases.sh +108 -1
- package/presets/zcode/java/rules/agent-team-intake.md +2 -2
- package/presets/zcode/java/rules/agent-team-orchestrator.md +5 -4
- package/presets/zcode/java/rules/feature-delivery-workflow.md +1 -1
- package/presets/zcode/mcp-ts/adapter-map.json +1 -1
- package/presets/zcode/mcp-ts/agents/README.md +1 -1
- package/presets/zcode/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/zcode/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/zcode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +108 -1
- package/presets/zcode/mcp-ts/rules/agent-team-intake.md +2 -2
- package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +5 -4
- package/presets/zcode/mcp-ts/rules/feature-delivery-workflow.md +1 -1
- package/presets/zcode/mol/adapter-map.json +1 -1
- package/presets/zcode/mol/agents/README.md +3 -3
- package/presets/zcode/mol/agents/build-verifier.md +1 -1
- package/presets/zcode/mol/agents/code-reviewer.md +1 -1
- package/presets/zcode/mol/agents/debugger.md +1 -1
- package/presets/zcode/mol/agents/feature-developer.md +1 -1
- package/presets/zcode/mol/agents/task-analyst.md +1 -1
- package/presets/zcode/mol/hooks/chain-team-phases.sh +108 -1
- package/presets/zcode/mol/rules/agent-team-intake.md +2 -2
- package/presets/zcode/mol/rules/agent-team-orchestrator.md +5 -4
- package/presets/zcode/mol/rules/feature-delivery-workflow.md +1 -1
- package/presets/zcode/next/REPO_AGENTS.md +16 -0
- package/presets/zcode/next/adapter-map.json +1 -1
- package/presets/zcode/next/agents/README.md +3 -3
- package/presets/zcode/next/agents/accessibility-reviewer.md +4 -1
- package/presets/zcode/next/agents/api-contract-reviewer.md +5 -2
- package/presets/zcode/next/agents/build-verifier.md +6 -3
- package/presets/zcode/next/agents/ci-investigator.md +1 -1
- package/presets/zcode/next/agents/code-reviewer.md +7 -4
- package/presets/zcode/next/agents/codebase-analyzer.md +4 -1
- package/presets/zcode/next/agents/debugger.md +2 -2
- package/presets/zcode/next/agents/feature-developer.md +2 -2
- package/presets/zcode/next/agents/migration-specialist.md +4 -1
- package/presets/zcode/next/agents/mockup-reviewer.md +4 -1
- package/presets/zcode/next/agents/openspec-author.md +4 -1
- package/presets/zcode/next/agents/performance-auditor.md +4 -1
- package/presets/zcode/next/agents/playwright-test-generator.md +5 -2
- package/presets/zcode/next/agents/playwright-test-healer.md +5 -2
- package/presets/zcode/next/agents/playwright-test-planner.md +5 -2
- package/presets/zcode/next/agents/qa-tester.md +5 -2
- package/presets/zcode/next/agents/security-reviewer.md +4 -1
- package/presets/zcode/next/agents/solution-architect.md +4 -1
- package/presets/zcode/next/agents/task-analyst.md +5 -2
- package/presets/zcode/next/agents/task-router.md +8 -5
- package/presets/zcode/next/agents/tech-writer.md +4 -1
- package/presets/zcode/next/agents/unit-test-generator.md +5 -2
- package/presets/zcode/next/agents/unit-test-healer.md +5 -2
- package/presets/zcode/next/agents/unit-test-planner.md +5 -2
- package/presets/zcode/next/ai-local/conventions.md +6 -1
- package/presets/zcode/next/hooks/chain-team-phases.sh +108 -1
- package/presets/zcode/next/rules/agent-team-intake.md +2 -2
- package/presets/zcode/next/rules/agent-team-orchestrator.md +5 -4
- package/presets/zcode/next/rules/feature-delivery-workflow.md +2 -2
- package/presets/zcode/nuxt/adapter-map.json +1 -1
- package/presets/zcode/nuxt/agents/README.md +3 -3
- package/presets/zcode/nuxt/agents/build-verifier.md +1 -1
- package/presets/zcode/nuxt/agents/code-reviewer.md +1 -1
- package/presets/zcode/nuxt/agents/debugger.md +1 -1
- package/presets/zcode/nuxt/agents/feature-developer.md +1 -1
- package/presets/zcode/nuxt/agents/task-analyst.md +1 -1
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +108 -1
- package/presets/zcode/nuxt/rules/agent-team-intake.md +2 -2
- package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +5 -4
- package/presets/zcode/nuxt/rules/feature-delivery-workflow.md +1 -1
- package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
- package/presets/zcode/php-hexagonal/agents/README.md +2 -2
- package/presets/zcode/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/zcode/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/zcode/php-hexagonal/agents/debugger.md +1 -1
- package/presets/zcode/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/zcode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +108 -1
- package/presets/zcode/php-hexagonal/rules/agent-team-intake.md +2 -2
- package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +5 -4
- package/presets/zcode/php-hexagonal/rules/feature-delivery-workflow.md +1 -1
- package/presets/zcode/php-laravel/adapter-map.json +1 -1
- package/presets/zcode/php-laravel/agents/README.md +2 -2
- package/presets/zcode/php-laravel/agents/build-verifier.md +1 -1
- package/presets/zcode/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/zcode/php-laravel/agents/debugger.md +1 -1
- package/presets/zcode/php-laravel/agents/feature-developer.md +1 -1
- package/presets/zcode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +108 -1
- package/presets/zcode/php-laravel/rules/agent-team-intake.md +2 -2
- package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +5 -4
- package/presets/zcode/php-laravel/rules/feature-delivery-workflow.md +1 -1
- package/presets/zcode/svelte/adapter-map.json +1 -1
- package/presets/zcode/svelte/agents/README.md +3 -3
- package/presets/zcode/svelte/agents/build-verifier.md +1 -1
- package/presets/zcode/svelte/agents/code-reviewer.md +1 -1
- package/presets/zcode/svelte/agents/debugger.md +1 -1
- package/presets/zcode/svelte/agents/feature-developer.md +1 -1
- package/presets/zcode/svelte/agents/task-analyst.md +1 -1
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +108 -1
- package/presets/zcode/svelte/rules/agent-team-intake.md +2 -2
- package/presets/zcode/svelte/rules/agent-team-orchestrator.md +5 -4
- package/presets/zcode/svelte/rules/feature-delivery-workflow.md +1 -1
- package/scripts/aggregate-agent-task-metrics.mjs +201 -0
- package/scripts/report-context-cost.mjs +126 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scheduler child for job `tracker-planned-drain`.
|
|
3
|
+
*
|
|
4
|
+
* One tick uses the existing launch queue (no second queue): if the tracker
|
|
5
|
+
* slot is not claimable, exit without enqueue. Otherwise the head ready
|
|
6
|
+
* stored-`planned` item that has no open queue entry is enqueued, then
|
|
7
|
+
* `drain --claim` grants one entry, the task folder is bootstrapped the way
|
|
8
|
+
* the chain-hook stop seam does, and exactly one `task-run start` runs.
|
|
9
|
+
* The process then polls until the linked team task and the tracker item are
|
|
10
|
+
* both terminal, so scheduler `concurrency: skip` holds the next tick.
|
|
11
|
+
*
|
|
12
|
+
* The child never writes `status.json` or `metrics.json`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import fs from 'node:fs';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import { fileURLToPath } from 'node:url';
|
|
18
|
+
|
|
19
|
+
import { isKillSwitchSet } from './team-db-schema.mjs';
|
|
20
|
+
import { ensureRunnerConfig, startTaskRun } from './team-db-task-runner.mjs';
|
|
21
|
+
import {
|
|
22
|
+
deriveTrackerOrdering,
|
|
23
|
+
drainTracker,
|
|
24
|
+
enqueueTrackerItem,
|
|
25
|
+
rankCompare,
|
|
26
|
+
readTrackerSnapshot,
|
|
27
|
+
setTrackerItem,
|
|
28
|
+
} from './team-db-tracker.mjs';
|
|
29
|
+
|
|
30
|
+
export const JOB_ID = 'tracker-planned-drain';
|
|
31
|
+
|
|
32
|
+
/** Preset template. The consumer `scheduler/jobs.json` row matches these fields. */
|
|
33
|
+
export const PLANNED_DRAIN_JOB = {
|
|
34
|
+
id: JOB_ID,
|
|
35
|
+
title: 'Drain one planned tracker item into /task',
|
|
36
|
+
enabled: true,
|
|
37
|
+
schedule: { kind: 'interval', everySeconds: 300, timezone: 'Europe/Moscow' },
|
|
38
|
+
payload: {
|
|
39
|
+
kind: 'command',
|
|
40
|
+
argv: ['node', '../scripts/tracker-planned-drain.mjs', '--team-root', '.'],
|
|
41
|
+
},
|
|
42
|
+
cwd: '.',
|
|
43
|
+
envPassthrough: [],
|
|
44
|
+
timeoutMs: 14400000,
|
|
45
|
+
concurrency: 'skip',
|
|
46
|
+
misfire: 'run-once',
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const ACTOR = JOB_ID;
|
|
50
|
+
const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
51
|
+
const TERMINAL_ITEM_STATUSES = new Set(['completed', 'cancelled', 'superseded']);
|
|
52
|
+
const TERMINAL_TASK_STATES = new Set(['completed', 'changes_requested', 'validation_failed']);
|
|
53
|
+
|
|
54
|
+
const idle = (reason, extra = {}) => ({
|
|
55
|
+
ok: true,
|
|
56
|
+
action: 'idle',
|
|
57
|
+
reason,
|
|
58
|
+
enqueued: false,
|
|
59
|
+
claim: null,
|
|
60
|
+
starts: 0,
|
|
61
|
+
taskSlug: null,
|
|
62
|
+
taskState: null,
|
|
63
|
+
effectiveStatus: null,
|
|
64
|
+
storedStatus: null,
|
|
65
|
+
...extra,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Head ready stored-`planned` item with no open queue entry, in drain rank order.
|
|
70
|
+
* A task row at `tracker-<id>` is already launched: the tracker's effective
|
|
71
|
+
* status only sees a link or the legacy `<id>` folder, so this job checks the
|
|
72
|
+
* slug it bootstraps itself.
|
|
73
|
+
*/
|
|
74
|
+
export const selectPlannedHead = (ordering, taskStates = new Map()) => {
|
|
75
|
+
const ranked = [...ordering.byId.values()].sort((left, right) => rankCompare(left.item, right.item));
|
|
76
|
+
return (
|
|
77
|
+
ranked.find((annotated) => {
|
|
78
|
+
const id = annotated.item.id;
|
|
79
|
+
return (
|
|
80
|
+
annotated.item.status === 'planned' &&
|
|
81
|
+
annotated.effectiveStatus === 'planned' &&
|
|
82
|
+
annotated.ready === true &&
|
|
83
|
+
annotated.openEntry == null &&
|
|
84
|
+
!taskStates.has(`tracker-${id}`) &&
|
|
85
|
+
!taskStates.has(String(id))
|
|
86
|
+
);
|
|
87
|
+
}) ?? null
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const taskStateForItem = (item, snapshot) => {
|
|
92
|
+
const links = [...snapshot.links.values()].filter(
|
|
93
|
+
(link) => link.itemId === item.id && link.decision !== 'unlinked',
|
|
94
|
+
);
|
|
95
|
+
if (links.length > 0) {
|
|
96
|
+
const states = links.map((link) => snapshot.taskStates.get(link.taskSlug) ?? null);
|
|
97
|
+
if (states.every((state) => state === 'completed')) return 'completed';
|
|
98
|
+
return states.find((state) => state === 'changes_requested' || state === 'validation_failed') ?? null;
|
|
99
|
+
}
|
|
100
|
+
return snapshot.taskStates.get(`tracker-${item.id}`) ?? snapshot.taskStates.get(String(item.id)) ?? null;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* A non-completed terminal team task stays effective-`launched` until the
|
|
105
|
+
* stored lattice moves, so the child records `cancelled` and can exit.
|
|
106
|
+
* `blocked` is a holding state and is left stored-`planned`.
|
|
107
|
+
*/
|
|
108
|
+
const markStoredFromTask = (teamRoot, itemId, taskState) => {
|
|
109
|
+
if (!TERMINAL_TASK_STATES.has(taskState)) return null;
|
|
110
|
+
const snapshot = readTrackerSnapshot(teamRoot);
|
|
111
|
+
const item = snapshot.items.get(itemId);
|
|
112
|
+
if (!item || item.status !== 'planned') return item?.status ?? null;
|
|
113
|
+
const at = new Date().toISOString();
|
|
114
|
+
if (taskState === 'completed') {
|
|
115
|
+
return setTrackerItem(
|
|
116
|
+
teamRoot,
|
|
117
|
+
itemId,
|
|
118
|
+
{ revision: item.revision, status: 'completed', completedAt: at },
|
|
119
|
+
{ actor: ACTOR },
|
|
120
|
+
).status;
|
|
121
|
+
}
|
|
122
|
+
return setTrackerItem(
|
|
123
|
+
teamRoot,
|
|
124
|
+
itemId,
|
|
125
|
+
{ revision: item.revision, status: 'cancelled', cancelledAt: at, cancelReason: `task ${taskState}` },
|
|
126
|
+
{ actor: ACTOR },
|
|
127
|
+
).status;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const reconcilePlannedItems = (teamRoot) => {
|
|
131
|
+
const snapshot = readTrackerSnapshot(teamRoot);
|
|
132
|
+
for (const item of snapshot.items.values()) {
|
|
133
|
+
if (item.status !== 'planned') continue;
|
|
134
|
+
const taskState = taskStateForItem(item, snapshot);
|
|
135
|
+
if (taskState !== null) markStoredFromTask(teamRoot, item.id, taskState);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const recoverableQueuedPlanned = (snapshot, ordering) =>
|
|
140
|
+
ordering.drainOrderEntryIds.some((entryId) => {
|
|
141
|
+
const entry = snapshot.entries.get(entryId);
|
|
142
|
+
const annotated = entry ? ordering.byId.get(entry.itemId) : undefined;
|
|
143
|
+
return annotated?.item.status === 'planned' && annotated.effectiveStatus === 'queued';
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const readLink = (teamRoot, linkId) => {
|
|
147
|
+
if (typeof linkId !== 'string' || linkId === '') return null;
|
|
148
|
+
try {
|
|
149
|
+
return JSON.parse(fs.readFileSync(path.join(teamRoot, 'tracker', 'links', `${linkId}.json`), 'utf8'));
|
|
150
|
+
} catch {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const linkPrompt = (teamRoot, link) => {
|
|
156
|
+
if (!link || typeof link.promptPath !== 'string') return null;
|
|
157
|
+
const root = path.resolve(teamRoot);
|
|
158
|
+
const file = path.resolve(teamRoot, link.promptPath);
|
|
159
|
+
if (file !== root && !file.startsWith(`${root}${path.sep}`)) return null;
|
|
160
|
+
try {
|
|
161
|
+
return fs.readFileSync(file, 'utf8');
|
|
162
|
+
} catch {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/** Same files as the hook stop seam. An existing `pipeline.json` is left as-is. */
|
|
168
|
+
const bootstrapTask = (teamRoot, claim) => {
|
|
169
|
+
const slug = typeof claim.taskSlug === 'string' && claim.taskSlug !== '' ? claim.taskSlug : claim.slug;
|
|
170
|
+
if (typeof slug !== 'string' || slug.length > 48 || !SLUG_RE.test(slug)) {
|
|
171
|
+
return { ok: false, reason: 'invalid slug' };
|
|
172
|
+
}
|
|
173
|
+
const taskDir = path.join(teamRoot, 'tasks', slug);
|
|
174
|
+
const pipelinePath = path.join(taskDir, 'pipeline.json');
|
|
175
|
+
if (fs.existsSync(pipelinePath)) return { ok: true, reason: null };
|
|
176
|
+
fs.mkdirSync(taskDir, { recursive: true });
|
|
177
|
+
const link = readLink(teamRoot, claim.linkId);
|
|
178
|
+
const prompt = linkPrompt(teamRoot, link) ?? `Tracker item ${claim.itemId || slug} launched from the queue drain.\n`;
|
|
179
|
+
const language = link && typeof link.language === 'string' ? link.language : '';
|
|
180
|
+
fs.writeFileSync(
|
|
181
|
+
path.join(taskDir, 'prompt.md'),
|
|
182
|
+
`${language ? `<!-- language: ${language} -->\n\n` : ''}${prompt.trim()}\n`,
|
|
183
|
+
);
|
|
184
|
+
const pipeline = {
|
|
185
|
+
slug,
|
|
186
|
+
intent: 'feature',
|
|
187
|
+
specMode: 'none',
|
|
188
|
+
profile: 'standard',
|
|
189
|
+
summary: `Tracker item ${claim.itemId || slug} launched from the queue drain.`,
|
|
190
|
+
trackerItemId: claim.itemId || slug,
|
|
191
|
+
trackerLinkId: claim.linkId || null,
|
|
192
|
+
steps: [],
|
|
193
|
+
humanGates: [],
|
|
194
|
+
autoChain: true,
|
|
195
|
+
skipped: [],
|
|
196
|
+
};
|
|
197
|
+
fs.writeFileSync(pipelinePath, `${JSON.stringify(pipeline, null, 2)}\n`);
|
|
198
|
+
return { ok: true, reason: null };
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const viewItem = (teamRoot, itemId) => {
|
|
202
|
+
const ordering = deriveTrackerOrdering(readTrackerSnapshot(teamRoot));
|
|
203
|
+
const annotated = ordering.byId.get(itemId);
|
|
204
|
+
return {
|
|
205
|
+
effectiveStatus: annotated?.effectiveStatus ?? null,
|
|
206
|
+
storedStatus: annotated?.item.status ?? null,
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const followClaim = async (teamRoot, claim, options) => {
|
|
211
|
+
const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
212
|
+
const interval = options.pollIntervalMs ?? 1000;
|
|
213
|
+
let polls = 0;
|
|
214
|
+
for (;;) {
|
|
215
|
+
const taskState = readTrackerSnapshot(teamRoot).taskStates.get(claim.taskSlug) ?? null;
|
|
216
|
+
markStoredFromTask(teamRoot, claim.itemId, taskState);
|
|
217
|
+
const view = viewItem(teamRoot, claim.itemId);
|
|
218
|
+
const taskTerminal = TERMINAL_TASK_STATES.has(taskState);
|
|
219
|
+
const itemTerminal = TERMINAL_ITEM_STATUSES.has(view.effectiveStatus);
|
|
220
|
+
if (taskTerminal && itemTerminal) {
|
|
221
|
+
return { taskSlug: claim.taskSlug, taskState, effectiveStatus: view.effectiveStatus, storedStatus: view.storedStatus };
|
|
222
|
+
}
|
|
223
|
+
polls += 1;
|
|
224
|
+
if (options.maxPolls != null && polls > options.maxPolls) {
|
|
225
|
+
return {
|
|
226
|
+
taskSlug: claim.taskSlug,
|
|
227
|
+
taskState,
|
|
228
|
+
effectiveStatus: view.effectiveStatus,
|
|
229
|
+
storedStatus: view.storedStatus,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
await sleep(interval);
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
const defaultStartRun = (teamRoot, claim) => {
|
|
237
|
+
ensureRunnerConfig(teamRoot);
|
|
238
|
+
return startTaskRun(teamRoot, {
|
|
239
|
+
taskSlug: claim.taskSlug,
|
|
240
|
+
itemId: claim.itemId,
|
|
241
|
+
linkId: claim.linkId ?? null,
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* One tick. `options.startRun` replaces `task-run start` in tests so this
|
|
247
|
+
* process never launches a real `/task`.
|
|
248
|
+
*/
|
|
249
|
+
export async function runPlannedDrain(teamRoot, options = {}) {
|
|
250
|
+
if (isKillSwitchSet(options.env ?? process.env)) return idle('disabled');
|
|
251
|
+
reconcilePlannedItems(teamRoot);
|
|
252
|
+
const preview = drainTracker(teamRoot, { claim: false, actor: ACTOR });
|
|
253
|
+
if (!preview.claimable) {
|
|
254
|
+
// `claim: true` while the slot is full writes nothing; the reason is the
|
|
255
|
+
// capacity string the tracker already returns.
|
|
256
|
+
const refused = drainTracker(teamRoot, { claim: true, actor: ACTOR });
|
|
257
|
+
return idle(refused.reason);
|
|
258
|
+
}
|
|
259
|
+
const snapshot = readTrackerSnapshot(teamRoot);
|
|
260
|
+
const ordering = deriveTrackerOrdering(snapshot);
|
|
261
|
+
const head = selectPlannedHead(ordering, snapshot.taskStates);
|
|
262
|
+
let enqueued = false;
|
|
263
|
+
if (head) {
|
|
264
|
+
enqueueTrackerItem(
|
|
265
|
+
teamRoot,
|
|
266
|
+
{
|
|
267
|
+
itemId: head.item.id,
|
|
268
|
+
taskSlug: `tracker-${head.item.id}`,
|
|
269
|
+
reason: 'planned drain',
|
|
270
|
+
requestedBy: ACTOR,
|
|
271
|
+
},
|
|
272
|
+
{ actor: ACTOR },
|
|
273
|
+
);
|
|
274
|
+
enqueued = true;
|
|
275
|
+
} else if (!recoverableQueuedPlanned(snapshot, ordering)) {
|
|
276
|
+
return idle('no planned head');
|
|
277
|
+
}
|
|
278
|
+
const claimed = drainTracker(teamRoot, { claim: true, actor: ACTOR });
|
|
279
|
+
if (!claimed.claim) return idle(claimed.reason ?? 'empty drain order', { enqueued });
|
|
280
|
+
const boot = bootstrapTask(teamRoot, claimed.claim);
|
|
281
|
+
if (!boot.ok) return idle(boot.reason, { enqueued, claim: claimed.claim });
|
|
282
|
+
const startRun = options.startRun ?? defaultStartRun;
|
|
283
|
+
await startRun(teamRoot, claimed.claim);
|
|
284
|
+
const followed = await followClaim(teamRoot, claimed.claim, options);
|
|
285
|
+
return {
|
|
286
|
+
ok: true,
|
|
287
|
+
action: 'started',
|
|
288
|
+
reason: null,
|
|
289
|
+
enqueued,
|
|
290
|
+
claim: claimed.claim,
|
|
291
|
+
starts: 1,
|
|
292
|
+
...followed,
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const parseTeamRoot = (argv, cwd) => {
|
|
297
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
298
|
+
const arg = argv[index];
|
|
299
|
+
if (arg === '--team-root' || arg === '--root') {
|
|
300
|
+
const value = argv[index + 1];
|
|
301
|
+
if (!value) {
|
|
302
|
+
process.stderr.write('missing team root\n');
|
|
303
|
+
process.exitCode = 2;
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
return path.resolve(cwd, value);
|
|
307
|
+
}
|
|
308
|
+
if (arg.startsWith('--team-root=')) return path.resolve(cwd, arg.slice('--team-root='.length));
|
|
309
|
+
}
|
|
310
|
+
return path.resolve(cwd, '.ai.local', 'team');
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
const invokedDirectly = (() => {
|
|
314
|
+
if (!process.argv[1]) return false;
|
|
315
|
+
try {
|
|
316
|
+
return fs.realpathSync(process.argv[1]) === fs.realpathSync(fileURLToPath(import.meta.url));
|
|
317
|
+
} catch {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
})();
|
|
321
|
+
|
|
322
|
+
if (invokedDirectly) {
|
|
323
|
+
const teamRoot = parseTeamRoot(process.argv.slice(2), process.cwd());
|
|
324
|
+
if (teamRoot) {
|
|
325
|
+
runPlannedDrain(teamRoot)
|
|
326
|
+
.then((result) => {
|
|
327
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
328
|
+
process.exitCode = result.ok ? 0 : 1;
|
|
329
|
+
})
|
|
330
|
+
.catch((error) => {
|
|
331
|
+
process.stderr.write(`${error.message}\n`);
|
|
332
|
+
process.exitCode = error.exitCode || 1;
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Persist verification evidence for a task: the commands a verifier ran, their
|
|
4
|
+
* exit codes, captured log tails, and the git snapshot they were verified on.
|
|
5
|
+
*
|
|
6
|
+
* `validation-report.md` stays the human-readable narrative. This module owns
|
|
7
|
+
* the machine-checkable half: `<team>/tasks/<slug>/verification.json` plus
|
|
8
|
+
* `evidence/*.log`. `check` answers one question — is the recorded evidence
|
|
9
|
+
* still bound to the current worktree? — so closure cannot silently rely on a
|
|
10
|
+
* snapshot taken before the last edit.
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* node .ai.local/scripts/verification.mjs record --task <slug|dir> \
|
|
14
|
+
* --command "<cmd>" --exit <n> [--log <file>] [--agent <id>] [--attempt <id>] [--json]
|
|
15
|
+
* node .ai.local/scripts/verification.mjs snapshot --task <slug|dir> [--json]
|
|
16
|
+
* node .ai.local/scripts/verification.mjs check --task <slug|dir> [--json] [--strict]
|
|
17
|
+
* node .ai.local/scripts/verification.mjs show --task <slug|dir> [--json]
|
|
18
|
+
*
|
|
19
|
+
* Exit codes: 0 ok, 1 stale (check --strict) or write failure, 2 usage/validation.
|
|
20
|
+
*/
|
|
21
|
+
import crypto from 'node:crypto';
|
|
22
|
+
import fs from 'node:fs';
|
|
23
|
+
import path from 'node:path';
|
|
24
|
+
import { spawnSync } from 'node:child_process';
|
|
25
|
+
import { fileURLToPath } from 'node:url';
|
|
26
|
+
|
|
27
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
28
|
+
const DEFAULT_TEAM_ROOT = path.resolve(here, '..', 'team');
|
|
29
|
+
const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
30
|
+
const MAX_COMMAND_CHARS = 500;
|
|
31
|
+
const MAX_LOG_BYTES = 64 * 1024;
|
|
32
|
+
const GIT_TIMEOUT_MS = 10_000;
|
|
33
|
+
|
|
34
|
+
const fail = (message, code = 2) => {
|
|
35
|
+
process.stderr.write(`verification: ${message}\n`);
|
|
36
|
+
process.exit(code);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const FLAGS = new Set(['--json', '--strict']);
|
|
40
|
+
const VALUED = new Set(['--task', '--command', '--exit', '--log', '--agent', '--attempt', '--team-root']);
|
|
41
|
+
|
|
42
|
+
const readArgs = (argv) => {
|
|
43
|
+
const args = {};
|
|
44
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
45
|
+
const key = argv[index];
|
|
46
|
+
if (key === '--help' || key === '-h') {
|
|
47
|
+
process.stdout.write(
|
|
48
|
+
'Usage: verification.mjs <record|snapshot|check|show> --task <slug|dir> [--json]\n',
|
|
49
|
+
);
|
|
50
|
+
process.exit(0);
|
|
51
|
+
}
|
|
52
|
+
if (FLAGS.has(key)) {
|
|
53
|
+
args[key.slice(2)] = true;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (!VALUED.has(key)) fail(`unknown argument ${key}`);
|
|
57
|
+
const value = argv[index + 1];
|
|
58
|
+
if (value === undefined) fail(`missing value for ${key}`);
|
|
59
|
+
args[key.slice(2)] = value;
|
|
60
|
+
index += 1;
|
|
61
|
+
}
|
|
62
|
+
return args;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const teamRootFor = (args) =>
|
|
66
|
+
args['team-root'] ? path.resolve(args['team-root']) : DEFAULT_TEAM_ROOT;
|
|
67
|
+
|
|
68
|
+
const taskDirFor = (args, teamRoot) => {
|
|
69
|
+
if (!args.task) fail('--task is required');
|
|
70
|
+
if (path.isAbsolute(args.task)) return args.task;
|
|
71
|
+
if (SLUG_RE.test(args.task)) return path.join(teamRoot, 'tasks', args.task);
|
|
72
|
+
return path.resolve(args.task);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const sha256 = (value) => crypto.createHash('sha256').update(value).digest('hex');
|
|
76
|
+
|
|
77
|
+
const readJson = (filePath, fallback) => {
|
|
78
|
+
try {
|
|
79
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
80
|
+
} catch {
|
|
81
|
+
return fallback;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const acquire = (lockFilePath) => {
|
|
86
|
+
for (let attempt = 0; attempt < 200; attempt += 1) {
|
|
87
|
+
try {
|
|
88
|
+
const fd = fs.openSync(lockFilePath, 'wx');
|
|
89
|
+
fs.writeSync(fd, `${process.pid}:${Date.now()}`);
|
|
90
|
+
fs.closeSync(fd);
|
|
91
|
+
return () => {
|
|
92
|
+
try {
|
|
93
|
+
fs.unlinkSync(lockFilePath);
|
|
94
|
+
} catch {
|
|
95
|
+
// another writer already released it
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
} catch (error) {
|
|
99
|
+
if (error.code !== 'EEXIST') fail(`cannot lock ${lockFilePath}: ${error.message}`, 1);
|
|
100
|
+
let stale = false;
|
|
101
|
+
try {
|
|
102
|
+
stale = Date.now() - fs.statSync(lockFilePath).mtimeMs > 30_000;
|
|
103
|
+
} catch {
|
|
104
|
+
// lock vanished; retry
|
|
105
|
+
}
|
|
106
|
+
if (stale) {
|
|
107
|
+
try {
|
|
108
|
+
fs.unlinkSync(lockFilePath);
|
|
109
|
+
} catch {
|
|
110
|
+
// another writer reclaimed it
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
fail(`lock timeout: ${lockFilePath}`, 1);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const writeJsonAtomic = (filePath, value) => {
|
|
119
|
+
const temporary = `${filePath}.${process.pid}.tmp`;
|
|
120
|
+
fs.writeFileSync(temporary, `${JSON.stringify(value, null, 2)}\n`);
|
|
121
|
+
fs.renameSync(temporary, filePath);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const git = (root, args) => {
|
|
125
|
+
const result = spawnSync('git', args, {
|
|
126
|
+
cwd: root,
|
|
127
|
+
encoding: 'utf8',
|
|
128
|
+
timeout: GIT_TIMEOUT_MS,
|
|
129
|
+
maxBuffer: 32 * 1024 * 1024,
|
|
130
|
+
env: process.env,
|
|
131
|
+
});
|
|
132
|
+
if (result.error || result.status !== 0) return null;
|
|
133
|
+
return String(result.stdout ?? '');
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Worktree snapshot. `head` and `worktreeHash` are the freshness keys: the hash
|
|
138
|
+
* covers tracked modifications and the untracked-name set, not untracked file
|
|
139
|
+
* contents (which would make the check unbounded on a dirty tree).
|
|
140
|
+
*/
|
|
141
|
+
const captureSnapshot = (root) => {
|
|
142
|
+
const head = git(root, ['rev-parse', 'HEAD']);
|
|
143
|
+
if (head === null) {
|
|
144
|
+
return { head: null, branch: null, dirtyFiles: null, worktreeHash: null, git: false, capturedAt: new Date().toISOString() };
|
|
145
|
+
}
|
|
146
|
+
const branch = git(root, ['rev-parse', '--abbrev-ref', 'HEAD']);
|
|
147
|
+
// `.ai.local/` holds the evidence this module writes; including it would make
|
|
148
|
+
// every record instantly stale against its own snapshot.
|
|
149
|
+
const exclude = ['--', '.', ':(exclude).ai.local'];
|
|
150
|
+
const statusText = git(root, ['status', '--porcelain=v1', ...exclude]) ?? '';
|
|
151
|
+
const diffText = git(root, ['diff', '--binary', 'HEAD', ...exclude]) ?? '';
|
|
152
|
+
const untrackedText = git(root, ['ls-files', '--others', '--exclude-standard', ...exclude]) ?? '';
|
|
153
|
+
const dirtyFiles = statusText === '' ? 0 : statusText.split('\n').filter((line) => line !== '').length;
|
|
154
|
+
return {
|
|
155
|
+
head: head.trim(),
|
|
156
|
+
branch: branch === null ? null : branch.trim(),
|
|
157
|
+
dirtyFiles,
|
|
158
|
+
worktreeHash: sha256(`${statusText}\u0000${diffText}\u0000${untrackedText}`),
|
|
159
|
+
git: true,
|
|
160
|
+
capturedAt: new Date().toISOString(),
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const SECRET_RE =
|
|
165
|
+
/(-----BEGIN [A-Z ]+PRIVATE KEY-----|authorization:\s*bearer\s+[A-Za-z0-9._-]{10,}|(?:api[_-]?key|token|secret|password)\s*[:=]\s*\S{8,})/i;
|
|
166
|
+
|
|
167
|
+
const redact = (text) =>
|
|
168
|
+
text
|
|
169
|
+
.replace(/(authorization:\s*bearer\s+)\S+/gi, '$1[redacted]')
|
|
170
|
+
.replace(/((?:api[_-]?key|token|secret|password)\s*[:=]\s*)\S+/gi, '$1[redacted]');
|
|
171
|
+
|
|
172
|
+
const appendMetricsEvent = (taskDir, event) => {
|
|
173
|
+
const metricsPath = path.join(taskDir, 'metrics.json');
|
|
174
|
+
if (!fs.existsSync(metricsPath)) return;
|
|
175
|
+
const release = acquire(`${metricsPath}.lock`);
|
|
176
|
+
try {
|
|
177
|
+
const metrics = readJson(metricsPath, null);
|
|
178
|
+
if (!metrics || !Array.isArray(metrics.events)) return;
|
|
179
|
+
const runId = metrics.task && typeof metrics.task.runId === 'string' ? metrics.task.runId : 'run';
|
|
180
|
+
metrics.events.push({
|
|
181
|
+
eventId: `${runId}:verification:${Date.now()}:${crypto.randomBytes(4).toString('hex')}`,
|
|
182
|
+
source: 'agent',
|
|
183
|
+
attributionConfidence: 'high',
|
|
184
|
+
...event,
|
|
185
|
+
});
|
|
186
|
+
writeJsonAtomic(metricsPath, metrics);
|
|
187
|
+
} finally {
|
|
188
|
+
release();
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const loadVerification = (taskDir) => {
|
|
193
|
+
const file = path.join(taskDir, 'verification.json');
|
|
194
|
+
const value = readJson(file, null);
|
|
195
|
+
if (!value || value.schemaVersion !== 1 || !Array.isArray(value.commands)) return null;
|
|
196
|
+
return value;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
const snapshotFile = (taskDir) => {
|
|
200
|
+
const dir = path.join(taskDir, 'evidence');
|
|
201
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
202
|
+
return dir;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Copy the tail of a command log into the task's evidence directory with
|
|
207
|
+
* secret-shaped values redacted. The stored file is capped, so a huge log never
|
|
208
|
+
* lands in the artifact tree.
|
|
209
|
+
*/
|
|
210
|
+
const captureLog = (taskDir, logPath, seq) => {
|
|
211
|
+
let raw;
|
|
212
|
+
try {
|
|
213
|
+
raw = fs.readFileSync(logPath);
|
|
214
|
+
} catch (error) {
|
|
215
|
+
fail(`cannot read --log ${logPath}: ${error.message}`);
|
|
216
|
+
}
|
|
217
|
+
const tail = raw.subarray(Math.max(0, raw.length - MAX_LOG_BYTES));
|
|
218
|
+
const text = redact(tail.toString('utf8').replace(/\u0000/g, ''));
|
|
219
|
+
const evidenceDir = snapshotFile(taskDir);
|
|
220
|
+
const name = `verification-${seq}.log`;
|
|
221
|
+
fs.writeFileSync(path.join(evidenceDir, name), text);
|
|
222
|
+
return { logRef: `evidence/${name}`, logSha256: sha256(text) };
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const formatHuman = (verification) => {
|
|
226
|
+
const commands = verification.commands
|
|
227
|
+
.map((entry) => ` ${entry.id} exit=${entry.exit} ${entry.command}`)
|
|
228
|
+
.join('\n');
|
|
229
|
+
return [
|
|
230
|
+
`verification: ${verification.task} snapshot=${verification.snapshot.head ?? 'no-git'} dirty=${verification.snapshot.dirtyFiles ?? '-'}`,
|
|
231
|
+
commands,
|
|
232
|
+
]
|
|
233
|
+
.filter(Boolean)
|
|
234
|
+
.join('\n');
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const actionRecord = (args) => {
|
|
238
|
+
const teamRoot = teamRootFor(args);
|
|
239
|
+
const taskDir = taskDirFor(args, teamRoot);
|
|
240
|
+
if (!fs.existsSync(taskDir)) fail(`task directory does not exist: ${taskDir}`, 1);
|
|
241
|
+
const command = String(args.command ?? '').trim();
|
|
242
|
+
if (command === '') fail('--command is required');
|
|
243
|
+
if (command.length > MAX_COMMAND_CHARS) fail(`--command exceeds ${MAX_COMMAND_CHARS} characters`);
|
|
244
|
+
if (SECRET_RE.test(command)) fail('--command looks like it carries a secret; pass a redacted command line');
|
|
245
|
+
const exitCode = Number(args.exit);
|
|
246
|
+
if (!Number.isInteger(exitCode) || exitCode < 0) fail('--exit must be a non-negative integer');
|
|
247
|
+
|
|
248
|
+
const file = path.join(taskDir, 'verification.json');
|
|
249
|
+
const release = acquire(`${file}.lock`);
|
|
250
|
+
let verification;
|
|
251
|
+
let entry;
|
|
252
|
+
try {
|
|
253
|
+
verification = loadVerification(taskDir) ?? {
|
|
254
|
+
schemaVersion: 1,
|
|
255
|
+
task: path.basename(taskDir),
|
|
256
|
+
snapshot: null,
|
|
257
|
+
commands: [],
|
|
258
|
+
gate: { status: 'recorded', checkedAt: null },
|
|
259
|
+
};
|
|
260
|
+
const seq = verification.commands.length + 1;
|
|
261
|
+
const log = args.log ? captureLog(taskDir, args.log, seq) : null;
|
|
262
|
+
entry = {
|
|
263
|
+
id: `cmd-${seq}`,
|
|
264
|
+
command,
|
|
265
|
+
exit: exitCode,
|
|
266
|
+
at: new Date().toISOString(),
|
|
267
|
+
agent: args.agent ?? null,
|
|
268
|
+
attempt: args.attempt ?? null,
|
|
269
|
+
...(log ?? {}),
|
|
270
|
+
};
|
|
271
|
+
verification.commands.push(entry);
|
|
272
|
+
verification.task = path.basename(taskDir);
|
|
273
|
+
verification.snapshot = captureSnapshot(path.resolve(teamRoot, '..', '..'));
|
|
274
|
+
verification.gate = { status: 'recorded', checkedAt: new Date().toISOString() };
|
|
275
|
+
writeJsonAtomic(file, verification);
|
|
276
|
+
} finally {
|
|
277
|
+
release();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
appendMetricsEvent(taskDir, {
|
|
281
|
+
type: 'verification_recorded',
|
|
282
|
+
at: entry.at,
|
|
283
|
+
commandId: entry.id,
|
|
284
|
+
exit: entry.exit,
|
|
285
|
+
agent: entry.agent,
|
|
286
|
+
attempt: entry.attempt,
|
|
287
|
+
head: verification.snapshot.head,
|
|
288
|
+
worktreeHash: verification.snapshot.worktreeHash,
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
if (args.json) {
|
|
292
|
+
process.stdout.write(`${JSON.stringify({ ok: true, task: verification.task, command: entry, snapshot: verification.snapshot })}\n`);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
process.stdout.write(`verification: recorded ${entry.id} exit=${entry.exit} for ${verification.task}\n`);
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
const actionSnapshot = (args) => {
|
|
299
|
+
const teamRoot = teamRootFor(args);
|
|
300
|
+
const taskDir = taskDirFor(args, teamRoot);
|
|
301
|
+
if (!fs.existsSync(taskDir)) fail(`task directory does not exist: ${taskDir}`, 1);
|
|
302
|
+
const file = path.join(taskDir, 'verification.json');
|
|
303
|
+
const release = acquire(`${file}.lock`);
|
|
304
|
+
let verification;
|
|
305
|
+
try {
|
|
306
|
+
verification = loadVerification(taskDir) ?? {
|
|
307
|
+
schemaVersion: 1,
|
|
308
|
+
task: path.basename(taskDir),
|
|
309
|
+
commands: [],
|
|
310
|
+
gate: { status: 'recorded', checkedAt: null },
|
|
311
|
+
};
|
|
312
|
+
verification.snapshot = captureSnapshot(path.resolve(teamRoot, '..', '..'));
|
|
313
|
+
writeJsonAtomic(file, verification);
|
|
314
|
+
} finally {
|
|
315
|
+
release();
|
|
316
|
+
}
|
|
317
|
+
if (args.json) {
|
|
318
|
+
process.stdout.write(`${JSON.stringify({ ok: true, snapshot: verification.snapshot })}\n`);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
process.stdout.write(`verification: snapshot ${verification.snapshot.head ?? 'no-git'} dirty=${verification.snapshot.dirtyFiles ?? '-'}\n`);
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
const actionCheck = (args) => {
|
|
325
|
+
const teamRoot = teamRootFor(args);
|
|
326
|
+
const taskDir = taskDirFor(args, teamRoot);
|
|
327
|
+
const verification = loadVerification(taskDir);
|
|
328
|
+
if (!verification) {
|
|
329
|
+
if (args.json) process.stdout.write(`${JSON.stringify({ fresh: false, reason: 'missing' })}\n`);
|
|
330
|
+
else process.stdout.write('verification: missing\n');
|
|
331
|
+
process.exit(args.strict ? 2 : 0);
|
|
332
|
+
}
|
|
333
|
+
const current = captureSnapshot(path.resolve(teamRoot, '..', '..'));
|
|
334
|
+
const reasons = [];
|
|
335
|
+
if (!verification.snapshot) reasons.push('no-snapshot');
|
|
336
|
+
else {
|
|
337
|
+
if (verification.snapshot.head !== current.head) reasons.push('head-changed');
|
|
338
|
+
if (verification.snapshot.worktreeHash !== current.worktreeHash) reasons.push('worktree-changed');
|
|
339
|
+
}
|
|
340
|
+
if (verification.commands.length === 0) reasons.push('no-command-evidence');
|
|
341
|
+
const fresh = reasons.length === 0;
|
|
342
|
+
const result = { fresh, reasons, recordedHead: verification.snapshot?.head ?? null, currentHead: current.head };
|
|
343
|
+
if (args.json) process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
344
|
+
else {
|
|
345
|
+
process.stdout.write(
|
|
346
|
+
fresh
|
|
347
|
+
? `verification: fresh (${verification.commands.length} command(s))\n`
|
|
348
|
+
: `verification: stale (${reasons.join(', ')})\n`,
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
if (!fresh && args.strict) process.exit(1);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
const actionShow = (args) => {
|
|
355
|
+
const teamRoot = teamRootFor(args);
|
|
356
|
+
const taskDir = taskDirFor(args, teamRoot);
|
|
357
|
+
const verification = loadVerification(taskDir);
|
|
358
|
+
if (!verification) fail(`no verification.json for ${path.basename(taskDir)}`, 1);
|
|
359
|
+
process.stdout.write(
|
|
360
|
+
args.json ? `${JSON.stringify(verification, null, 2)}\n` : `${formatHuman(verification)}\n`,
|
|
361
|
+
);
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
const main = () => {
|
|
365
|
+
const [action] = process.argv.slice(2);
|
|
366
|
+
const args = readArgs(process.argv.slice(3));
|
|
367
|
+
if (action === 'record') actionRecord(args);
|
|
368
|
+
else if (action === 'snapshot') actionSnapshot(args);
|
|
369
|
+
else if (action === 'check') actionCheck(args);
|
|
370
|
+
else if (action === 'show') actionShow(args);
|
|
371
|
+
else fail(`unknown action ${action ?? '(none)'}; use record|snapshot|check|show`);
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
main();
|