@bonesofspring/ai-rules 0.2.86 → 0.2.90
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 +60 -0
- package/README.md +9 -1
- package/bin/lib/engine-scripts.js +11 -0
- package/bin/lib/seed-ai-local-team.js +79 -2
- package/bin/opencode-install.js +14 -12
- package/docs/OPENCODE-COMPATIBILITY.md +6 -4
- package/docs/OPENCODE.md +15 -8
- package/docs/PRESET-CONTRIBUTION.md +6 -6
- package/docs/TOKEN-ECONOMY.md +20 -0
- package/docs/openapi/team-db.v1.json +2 -2
- package/package.json +1 -1
- package/presets/_shared/ai-local/env.example +54 -0
- package/presets/_shared/ai-local/scripts/aggregate-agent-task-metrics.mjs +34 -5
- package/presets/_shared/ai-local/scripts/check-task-repositories.mjs +25 -22
- package/presets/_shared/ai-local/scripts/process-lease.mjs +3 -2
- package/presets/_shared/ai-local/scripts/processes.mjs +52 -20
- package/presets/_shared/ai-local/scripts/report-step-cost.mjs +544 -0
- package/presets/_shared/ai-local/scripts/run.mjs +38 -6
- package/presets/_shared/ai-local/scripts/settings.mjs +246 -0
- package/presets/_shared/ai-local/scripts/task-worktree.mjs +364 -0
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +2 -2
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +87 -14
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +102 -12
- package/presets/_shared/ai-local/scripts/team-db-tracker.mjs +35 -0
- package/presets/_shared/ai-local/scripts/tracker-planned-drain.mjs +10 -1
- package/presets/_shared/ai-local/scripts/verification.mjs +106 -11
- package/presets/_shared/assets/model-tiers.json +6 -0
- package/presets/_shared/core/agent-team/agent-task-metrics.md +10 -2
- package/presets/_shared/core/agent-team/agent-team-intake.md +2 -0
- package/presets/_shared/core/agent-team/agent-team-orchestrator.md +5 -5
- package/presets/_shared/core/meta/preset-writing-style.md +8 -0
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +541 -61
- package/presets/_shared/hooks/guard-shell-command.mjs.tmpl +841 -97
- package/presets/_shared/hooks/prompt-autoroute.mjs.tmpl +153 -0
- package/presets/claude/android-kotlin/CLAUDE.md +2 -4
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/android-kotlin/hooks/guard-shell-command.mjs +841 -97
- package/presets/claude/android-kotlin/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/android-kotlin/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/android-kotlin/settings.json +15 -5
- package/presets/claude/go/CLAUDE.md +2 -4
- package/presets/claude/go/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/go/hooks/guard-shell-command.mjs +841 -97
- package/presets/claude/go/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/go/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/go/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/go/settings.json +15 -5
- package/presets/claude/ios-swift/CLAUDE.md +2 -4
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/ios-swift/hooks/guard-shell-command.mjs +841 -97
- package/presets/claude/ios-swift/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/ios-swift/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/ios-swift/settings.json +15 -5
- package/presets/claude/java/CLAUDE.md +2 -4
- package/presets/claude/java/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/java/hooks/guard-shell-command.mjs +841 -97
- package/presets/claude/java/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/java/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/java/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/java/settings.json +15 -5
- package/presets/claude/mcp-ts/CLAUDE.md +2 -4
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/mcp-ts/hooks/guard-shell-command.mjs +841 -97
- package/presets/claude/mcp-ts/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/mcp-ts/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/mcp-ts/settings.json +15 -5
- package/presets/claude/mol/CLAUDE.md +2 -4
- package/presets/claude/mol/agents/feature-developer.md +1 -1
- package/presets/claude/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/claude/mol/commands/task-evil.md +8 -0
- package/presets/claude/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/mol/hooks/guard-shell-command.mjs +841 -97
- package/presets/claude/mol/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/mol/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/mol/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/mol/settings.json +15 -4
- package/presets/claude/next/CLAUDE.md +2 -4
- package/presets/claude/next/REPO_AGENTS.md +2 -0
- package/presets/claude/next/agents/feature-developer.md +1 -1
- package/presets/claude/next/agents/task-analyst.md +1 -7
- package/presets/claude/next/agents/task-router.md +1 -1
- package/presets/claude/next/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/claude/next/commands/spec-start.md +3 -4
- package/presets/claude/next/commands/task-continue.md +9 -8
- package/presets/claude/next/commands/task-evil.md +8 -0
- package/presets/claude/next/commands/task.md +1 -1
- package/presets/claude/next/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/next/hooks/guard-shell-command.mjs +841 -97
- package/presets/claude/next/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/next/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/next/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/next/settings.json +15 -4
- package/presets/claude/next/team/README.md +1 -1
- package/presets/claude/nuxt/CLAUDE.md +2 -4
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/nuxt/hooks/guard-shell-command.mjs +841 -97
- package/presets/claude/nuxt/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/nuxt/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/nuxt/settings.json +15 -4
- package/presets/claude/php-hexagonal/CLAUDE.md +2 -4
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/php-hexagonal/hooks/guard-shell-command.mjs +841 -97
- package/presets/claude/php-hexagonal/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/php-hexagonal/settings.json +15 -5
- package/presets/claude/php-laravel/CLAUDE.md +2 -4
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/php-laravel/hooks/guard-shell-command.mjs +841 -97
- package/presets/claude/php-laravel/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/php-laravel/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/php-laravel/settings.json +15 -5
- package/presets/claude/svelte/CLAUDE.md +2 -4
- package/presets/claude/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/svelte/hooks/guard-shell-command.mjs +841 -97
- package/presets/claude/svelte/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +5 -5
- package/presets/claude/svelte/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/svelte/settings.json +15 -4
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/android-kotlin/hooks/guard-shell-command.mjs +841 -97
- package/presets/cursor/android-kotlin/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +4 -4
- package/presets/cursor/android-kotlin/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/go/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/go/hooks/guard-shell-command.mjs +841 -97
- package/presets/cursor/go/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/go/rules/agent-team-orchestrator.mdc +4 -4
- package/presets/cursor/go/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/ios-swift/hooks/guard-shell-command.mjs +841 -97
- package/presets/cursor/ios-swift/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +4 -4
- package/presets/cursor/ios-swift/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/java/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/java/hooks/guard-shell-command.mjs +841 -97
- package/presets/cursor/java/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/java/rules/agent-team-orchestrator.mdc +4 -4
- package/presets/cursor/java/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/mcp-ts/hooks/guard-shell-command.mjs +841 -97
- package/presets/cursor/mcp-ts/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +4 -4
- package/presets/cursor/mcp-ts/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/mol/agents/feature-developer.md +1 -1
- package/presets/cursor/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/cursor/mol/commands/task-evil.md +8 -0
- package/presets/cursor/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/mol/hooks/guard-shell-command.mjs +841 -97
- package/presets/cursor/mol/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +4 -4
- package/presets/cursor/mol/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/next/REPO_AGENTS.md +2 -0
- package/presets/cursor/next/agents/feature-developer.md +1 -1
- package/presets/cursor/next/agents/task-analyst.md +1 -7
- package/presets/cursor/next/agents/task-router.md +1 -1
- package/presets/cursor/next/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/cursor/next/commands/spec-start.md +3 -4
- package/presets/cursor/next/commands/task-continue.md +9 -8
- package/presets/cursor/next/commands/task-evil.md +8 -0
- package/presets/cursor/next/commands/task.md +1 -1
- package/presets/cursor/next/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/next/hooks/guard-shell-command.mjs +841 -97
- package/presets/cursor/next/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/next/rules/agent-team-orchestrator.mdc +5 -5
- package/presets/cursor/next/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/next/team/README.md +1 -1
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/nuxt/hooks/guard-shell-command.mjs +841 -97
- package/presets/cursor/nuxt/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +4 -4
- package/presets/cursor/nuxt/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/php-hexagonal/hooks/guard-shell-command.mjs +841 -97
- package/presets/cursor/php-hexagonal/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +4 -4
- package/presets/cursor/php-hexagonal/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/php-laravel/hooks/guard-shell-command.mjs +841 -97
- package/presets/cursor/php-laravel/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +4 -4
- package/presets/cursor/php-laravel/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/svelte/hooks/guard-shell-command.mjs +841 -97
- package/presets/cursor/svelte/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +4 -4
- package/presets/cursor/svelte/rules/preset-writing-style.mdc +8 -0
- package/presets/mavis/android-kotlin/MAVIS.md +1 -1
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/android-kotlin/rules/agent-team-intake.md +2 -0
- package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/android-kotlin/rules/preset-writing-style.md +8 -0
- package/presets/mavis/go/MAVIS.md +1 -1
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/go/rules/agent-team-intake.md +2 -0
- package/presets/mavis/go/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/go/rules/preset-writing-style.md +8 -0
- package/presets/mavis/ios-swift/MAVIS.md +1 -1
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/ios-swift/rules/agent-team-intake.md +2 -0
- package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/ios-swift/rules/preset-writing-style.md +8 -0
- package/presets/mavis/java/MAVIS.md +1 -1
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/java/rules/agent-team-intake.md +2 -0
- package/presets/mavis/java/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/java/rules/preset-writing-style.md +8 -0
- package/presets/mavis/mcp-ts/MAVIS.md +1 -1
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/mcp-ts/rules/agent-team-intake.md +2 -0
- package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/mcp-ts/rules/preset-writing-style.md +8 -0
- package/presets/mavis/mol/MAVIS.md +1 -1
- package/presets/mavis/mol/adapter-map.json +1 -1
- package/presets/mavis/mol/agents/feature-developer.md +1 -1
- package/presets/mavis/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/mavis/mol/commands/task-evil.md +8 -0
- package/presets/mavis/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/mol/native-skills/task-evil/SKILL.md +8 -0
- package/presets/mavis/mol/rules/agent-team-intake.md +2 -0
- package/presets/mavis/mol/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/mol/rules/preset-writing-style.md +8 -0
- package/presets/mavis/next/MAVIS.md +1 -1
- package/presets/mavis/next/REPO_AGENTS.md +2 -0
- package/presets/mavis/next/adapter-map.json +1 -1
- package/presets/mavis/next/agents/feature-developer.md +1 -1
- package/presets/mavis/next/agents/task-analyst.md +1 -7
- package/presets/mavis/next/agents/task-router.md +1 -1
- package/presets/mavis/next/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/mavis/next/commands/spec-start.md +3 -4
- package/presets/mavis/next/commands/task-continue.md +9 -8
- package/presets/mavis/next/commands/task-evil.md +8 -0
- package/presets/mavis/next/commands/task.md +1 -1
- package/presets/mavis/next/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/next/native-skills/spec-start/SKILL.md +3 -4
- package/presets/mavis/next/native-skills/task/SKILL.md +1 -1
- package/presets/mavis/next/native-skills/task-continue/SKILL.md +9 -8
- package/presets/mavis/next/native-skills/task-evil/SKILL.md +8 -0
- package/presets/mavis/next/rules/agent-team-intake.md +2 -0
- package/presets/mavis/next/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/next/rules/preset-writing-style.md +8 -0
- package/presets/mavis/next/team/README.md +1 -1
- package/presets/mavis/nuxt/MAVIS.md +1 -1
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/nuxt/rules/agent-team-intake.md +2 -0
- package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/nuxt/rules/preset-writing-style.md +8 -0
- package/presets/mavis/php-hexagonal/MAVIS.md +1 -1
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/php-hexagonal/rules/agent-team-intake.md +2 -0
- package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/php-hexagonal/rules/preset-writing-style.md +8 -0
- package/presets/mavis/php-laravel/MAVIS.md +1 -1
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/php-laravel/rules/agent-team-intake.md +2 -0
- package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/php-laravel/rules/preset-writing-style.md +8 -0
- package/presets/mavis/svelte/MAVIS.md +1 -1
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/svelte/rules/agent-team-intake.md +2 -0
- package/presets/mavis/svelte/rules/agent-team-orchestrator.md +5 -5
- package/presets/mavis/svelte/rules/preset-writing-style.md +8 -0
- package/presets/opencode/android-kotlin/OPENCODE.md +5 -66
- package/presets/opencode/android-kotlin/adapter-map.json +42 -42
- package/presets/opencode/android-kotlin/agents/accessibility-reviewer.md +1 -1
- package/presets/opencode/android-kotlin/agents/api-contract-reviewer.md +1 -1
- package/presets/opencode/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/opencode/android-kotlin/agents/ci-investigator.md +1 -1
- package/presets/opencode/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/opencode/android-kotlin/agents/codebase-analyzer.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/instrumentation-test-generator.md +1 -1
- package/presets/opencode/android-kotlin/agents/instrumentation-test-healer.md +1 -1
- package/presets/opencode/android-kotlin/agents/instrumentation-test-planner.md +1 -1
- package/presets/opencode/android-kotlin/agents/migration-specialist.md +1 -1
- package/presets/opencode/android-kotlin/agents/mockup-reviewer.md +1 -1
- package/presets/opencode/android-kotlin/agents/openspec-author.md +1 -1
- package/presets/opencode/android-kotlin/agents/performance-auditor.md +1 -1
- package/presets/opencode/android-kotlin/agents/qa-tester.md +1 -1
- package/presets/opencode/android-kotlin/agents/security-reviewer.md +1 -1
- package/presets/opencode/android-kotlin/agents/solution-architect.md +1 -1
- package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/opencode/android-kotlin/agents/task-router.md +1 -1
- package/presets/opencode/android-kotlin/agents/tech-writer.md +1 -1
- package/presets/opencode/android-kotlin/agents/unit-test-generator.md +1 -1
- package/presets/opencode/android-kotlin/agents/unit-test-healer.md +1 -1
- package/presets/opencode/android-kotlin/agents/unit-test-planner.md +1 -1
- package/presets/opencode/android-kotlin/commands/task-continue.md +1 -1
- package/presets/opencode/android-kotlin/hooks/README.md +12 -1
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/android-kotlin/hooks/guard-shell-command.mjs +879 -0
- package/presets/opencode/android-kotlin/opencode.json +4 -4
- package/presets/opencode/android-kotlin/plugins/rule-attach/globs.json +167 -0
- package/presets/opencode/android-kotlin/rules/agent-team-intake.md +2 -0
- package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +7 -7
- package/presets/opencode/android-kotlin/rules/preset-writing-style.md +8 -0
- package/presets/opencode/go/OPENCODE.md +5 -51
- package/presets/opencode/go/adapter-map.json +45 -45
- package/presets/opencode/go/agents/api-contract-reviewer.md +1 -1
- package/presets/opencode/go/agents/build-verifier.md +1 -1
- package/presets/opencode/go/agents/ci-investigator.md +1 -1
- package/presets/opencode/go/agents/code-reviewer.md +1 -1
- package/presets/opencode/go/agents/codebase-analyzer.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/integration-test-generator.md +1 -1
- package/presets/opencode/go/agents/integration-test-healer.md +1 -1
- package/presets/opencode/go/agents/integration-test-planner.md +1 -1
- package/presets/opencode/go/agents/migration-specialist.md +1 -1
- package/presets/opencode/go/agents/openspec-author.md +1 -1
- package/presets/opencode/go/agents/performance-auditor.md +1 -1
- package/presets/opencode/go/agents/qa-tester.md +1 -1
- package/presets/opencode/go/agents/security-reviewer.md +1 -1
- package/presets/opencode/go/agents/solution-architect.md +1 -1
- package/presets/opencode/go/agents/task-analyst.md +1 -1
- package/presets/opencode/go/agents/task-router.md +1 -1
- package/presets/opencode/go/agents/tech-writer.md +1 -1
- package/presets/opencode/go/agents/unit-test-generator.md +1 -1
- package/presets/opencode/go/agents/unit-test-healer.md +1 -1
- package/presets/opencode/go/agents/unit-test-planner.md +1 -1
- package/presets/opencode/go/commands/task-continue.md +1 -1
- package/presets/opencode/go/hooks/README.md +12 -1
- package/presets/opencode/go/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/go/hooks/guard-shell-command.mjs +878 -0
- package/presets/opencode/go/opencode.json +4 -4
- package/presets/opencode/go/plugins/rule-attach/globs.json +198 -0
- package/presets/opencode/go/rules/agent-team-intake.md +2 -0
- package/presets/opencode/go/rules/agent-team-orchestrator.md +7 -7
- package/presets/opencode/go/rules/preset-writing-style.md +8 -0
- package/presets/opencode/ios-swift/OPENCODE.md +5 -66
- package/presets/opencode/ios-swift/adapter-map.json +41 -41
- package/presets/opencode/ios-swift/agents/accessibility-reviewer.md +1 -1
- package/presets/opencode/ios-swift/agents/api-contract-reviewer.md +1 -1
- package/presets/opencode/ios-swift/agents/build-verifier.md +1 -1
- package/presets/opencode/ios-swift/agents/ci-investigator.md +1 -1
- package/presets/opencode/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/opencode/ios-swift/agents/codebase-analyzer.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/migration-specialist.md +1 -1
- package/presets/opencode/ios-swift/agents/mockup-reviewer.md +1 -1
- package/presets/opencode/ios-swift/agents/openspec-author.md +1 -1
- package/presets/opencode/ios-swift/agents/performance-auditor.md +1 -1
- package/presets/opencode/ios-swift/agents/qa-tester.md +1 -1
- package/presets/opencode/ios-swift/agents/security-reviewer.md +1 -1
- package/presets/opencode/ios-swift/agents/solution-architect.md +1 -1
- package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/opencode/ios-swift/agents/task-router.md +1 -1
- package/presets/opencode/ios-swift/agents/tech-writer.md +1 -1
- package/presets/opencode/ios-swift/agents/unit-test-generator.md +1 -1
- package/presets/opencode/ios-swift/agents/unit-test-healer.md +1 -1
- package/presets/opencode/ios-swift/agents/unit-test-planner.md +1 -1
- package/presets/opencode/ios-swift/agents/xcuitest-test-generator.md +1 -1
- package/presets/opencode/ios-swift/agents/xcuitest-test-healer.md +1 -1
- package/presets/opencode/ios-swift/agents/xcuitest-test-planner.md +1 -1
- package/presets/opencode/ios-swift/commands/task-continue.md +1 -1
- package/presets/opencode/ios-swift/hooks/README.md +12 -1
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/ios-swift/hooks/guard-shell-command.mjs +878 -0
- package/presets/opencode/ios-swift/opencode.json +4 -4
- package/presets/opencode/ios-swift/plugins/rule-attach/globs.json +160 -0
- package/presets/opencode/ios-swift/rules/agent-team-intake.md +2 -0
- package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +7 -7
- package/presets/opencode/ios-swift/rules/preset-writing-style.md +8 -0
- package/presets/opencode/java/OPENCODE.md +5 -58
- package/presets/opencode/java/adapter-map.json +45 -45
- package/presets/opencode/java/agents/api-contract-reviewer.md +1 -1
- package/presets/opencode/java/agents/build-verifier.md +1 -1
- package/presets/opencode/java/agents/ci-investigator.md +1 -1
- package/presets/opencode/java/agents/code-reviewer.md +1 -1
- package/presets/opencode/java/agents/codebase-analyzer.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/integration-test-generator.md +1 -1
- package/presets/opencode/java/agents/integration-test-healer.md +1 -1
- package/presets/opencode/java/agents/integration-test-planner.md +1 -1
- package/presets/opencode/java/agents/migration-specialist.md +1 -1
- package/presets/opencode/java/agents/openspec-author.md +1 -1
- package/presets/opencode/java/agents/performance-auditor.md +1 -1
- package/presets/opencode/java/agents/qa-tester.md +1 -1
- package/presets/opencode/java/agents/security-reviewer.md +1 -1
- package/presets/opencode/java/agents/solution-architect.md +1 -1
- package/presets/opencode/java/agents/task-analyst.md +1 -1
- package/presets/opencode/java/agents/task-router.md +1 -1
- package/presets/opencode/java/agents/tech-writer.md +1 -1
- package/presets/opencode/java/agents/unit-test-generator.md +1 -1
- package/presets/opencode/java/agents/unit-test-healer.md +1 -1
- package/presets/opencode/java/agents/unit-test-planner.md +1 -1
- package/presets/opencode/java/commands/task-continue.md +1 -1
- package/presets/opencode/java/hooks/README.md +12 -1
- package/presets/opencode/java/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/java/hooks/guard-shell-command.mjs +879 -0
- package/presets/opencode/java/opencode.json +4 -4
- package/presets/opencode/java/plugins/rule-attach/globs.json +230 -0
- package/presets/opencode/java/rules/agent-team-intake.md +2 -0
- package/presets/opencode/java/rules/agent-team-orchestrator.md +7 -7
- package/presets/opencode/java/rules/preset-writing-style.md +8 -0
- package/presets/opencode/mcp-ts/OPENCODE.md +5 -48
- package/presets/opencode/mcp-ts/adapter-map.json +36 -36
- 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/security-reviewer.md +1 -1
- package/presets/opencode/mcp-ts/agents/solution-architect.md +1 -1
- package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/opencode/mcp-ts/agents/task-router.md +1 -1
- package/presets/opencode/mcp-ts/commands/task-continue.md +1 -1
- package/presets/opencode/mcp-ts/hooks/README.md +12 -1
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/mcp-ts/hooks/guard-shell-command.mjs +878 -0
- package/presets/opencode/mcp-ts/opencode.json +4 -4
- package/presets/opencode/mcp-ts/plugins/rule-attach/globs.json +151 -0
- package/presets/opencode/mcp-ts/rules/agent-team-intake.md +2 -0
- package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +7 -7
- package/presets/opencode/mcp-ts/rules/preset-writing-style.md +8 -0
- package/presets/opencode/mol/OPENCODE.md +5 -56
- package/presets/opencode/mol/adapter-map.json +31 -31
- package/presets/opencode/mol/agents/accessibility-reviewer.md +1 -1
- package/presets/opencode/mol/agents/api-contract-reviewer.md +1 -1
- package/presets/opencode/mol/agents/build-verifier.md +1 -1
- package/presets/opencode/mol/agents/ci-investigator.md +1 -1
- package/presets/opencode/mol/agents/code-reviewer.md +1 -1
- package/presets/opencode/mol/agents/codebase-analyzer.md +1 -1
- package/presets/opencode/mol/agents/debugger.md +1 -1
- package/presets/opencode/mol/agents/feature-developer.md +2 -2
- package/presets/opencode/mol/agents/migration-specialist.md +1 -1
- package/presets/opencode/mol/agents/mockup-reviewer.md +1 -1
- package/presets/opencode/mol/agents/openspec-author.md +1 -1
- package/presets/opencode/mol/agents/performance-auditor.md +1 -1
- package/presets/opencode/mol/agents/playwright-test-generator.md +1 -1
- package/presets/opencode/mol/agents/playwright-test-healer.md +1 -1
- package/presets/opencode/mol/agents/playwright-test-planner.md +1 -1
- package/presets/opencode/mol/agents/qa-tester.md +1 -1
- package/presets/opencode/mol/agents/security-reviewer.md +1 -1
- package/presets/opencode/mol/agents/solution-architect.md +1 -1
- package/presets/opencode/mol/agents/task-analyst.md +1 -1
- package/presets/opencode/mol/agents/task-router.md +1 -1
- package/presets/opencode/mol/agents/tech-writer.md +1 -1
- package/presets/opencode/mol/agents/unit-test-generator.md +1 -1
- package/presets/opencode/mol/agents/unit-test-healer.md +1 -1
- package/presets/opencode/mol/agents/unit-test-planner.md +1 -1
- package/presets/opencode/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/opencode/mol/commands/task-continue.md +1 -1
- package/presets/opencode/mol/commands/task-evil.md +8 -0
- package/presets/opencode/mol/hooks/README.md +12 -1
- package/presets/opencode/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/mol/hooks/guard-shell-command.mjs +877 -0
- package/presets/opencode/mol/opencode.json +4 -4
- package/presets/opencode/mol/plugins/rule-attach/globs.json +112 -0
- package/presets/opencode/mol/rules/agent-team-intake.md +2 -0
- package/presets/opencode/mol/rules/agent-team-orchestrator.md +7 -7
- package/presets/opencode/mol/rules/preset-writing-style.md +8 -0
- package/presets/opencode/next/OPENCODE.md +5 -55
- package/presets/opencode/next/REPO_AGENTS.md +2 -0
- package/presets/opencode/next/adapter-map.json +56 -56
- package/presets/opencode/next/agents/accessibility-reviewer.md +1 -1
- package/presets/opencode/next/agents/api-contract-reviewer.md +1 -1
- package/presets/opencode/next/agents/build-verifier.md +1 -1
- package/presets/opencode/next/agents/ci-investigator.md +1 -1
- package/presets/opencode/next/agents/code-reviewer.md +1 -1
- package/presets/opencode/next/agents/codebase-analyzer.md +1 -1
- package/presets/opencode/next/agents/debugger.md +1 -1
- package/presets/opencode/next/agents/feature-developer.md +2 -2
- package/presets/opencode/next/agents/migration-specialist.md +1 -1
- package/presets/opencode/next/agents/mockup-reviewer.md +1 -1
- package/presets/opencode/next/agents/openspec-author.md +1 -1
- package/presets/opencode/next/agents/performance-auditor.md +1 -1
- package/presets/opencode/next/agents/playwright-test-generator.md +1 -1
- package/presets/opencode/next/agents/playwright-test-healer.md +1 -1
- package/presets/opencode/next/agents/playwright-test-planner.md +1 -1
- package/presets/opencode/next/agents/qa-tester.md +1 -1
- package/presets/opencode/next/agents/security-reviewer.md +1 -1
- package/presets/opencode/next/agents/solution-architect.md +1 -1
- package/presets/opencode/next/agents/task-analyst.md +2 -8
- package/presets/opencode/next/agents/task-router.md +2 -2
- package/presets/opencode/next/agents/tech-writer.md +1 -1
- package/presets/opencode/next/agents/unit-test-generator.md +1 -1
- package/presets/opencode/next/agents/unit-test-healer.md +1 -1
- package/presets/opencode/next/agents/unit-test-planner.md +1 -1
- package/presets/opencode/next/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/opencode/next/commands/spec-start.md +3 -4
- package/presets/opencode/next/commands/task-continue.md +10 -9
- package/presets/opencode/next/commands/task-evil.md +8 -0
- package/presets/opencode/next/commands/task.md +1 -1
- package/presets/opencode/next/hooks/README.md +12 -1
- package/presets/opencode/next/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/next/hooks/guard-shell-command.mjs +877 -0
- package/presets/opencode/next/opencode.json +4 -4
- package/presets/opencode/next/plugins/rule-attach/globs.json +276 -0
- package/presets/opencode/next/rules/agent-team-intake.md +2 -0
- package/presets/opencode/next/rules/agent-team-orchestrator.md +7 -7
- package/presets/opencode/next/rules/preset-writing-style.md +8 -0
- package/presets/opencode/next/team/README.md +1 -1
- package/presets/opencode/nuxt/OPENCODE.md +5 -54
- package/presets/opencode/nuxt/adapter-map.json +51 -51
- package/presets/opencode/nuxt/agents/accessibility-reviewer.md +1 -1
- package/presets/opencode/nuxt/agents/api-contract-reviewer.md +1 -1
- package/presets/opencode/nuxt/agents/build-verifier.md +1 -1
- package/presets/opencode/nuxt/agents/ci-investigator.md +1 -1
- package/presets/opencode/nuxt/agents/code-reviewer.md +1 -1
- package/presets/opencode/nuxt/agents/codebase-analyzer.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/migration-specialist.md +1 -1
- package/presets/opencode/nuxt/agents/mockup-reviewer.md +1 -1
- package/presets/opencode/nuxt/agents/openspec-author.md +1 -1
- package/presets/opencode/nuxt/agents/performance-auditor.md +1 -1
- package/presets/opencode/nuxt/agents/playwright-test-generator.md +1 -1
- package/presets/opencode/nuxt/agents/playwright-test-healer.md +1 -1
- package/presets/opencode/nuxt/agents/playwright-test-planner.md +1 -1
- package/presets/opencode/nuxt/agents/qa-tester.md +1 -1
- package/presets/opencode/nuxt/agents/security-reviewer.md +1 -1
- package/presets/opencode/nuxt/agents/solution-architect.md +1 -1
- package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
- package/presets/opencode/nuxt/agents/task-router.md +1 -1
- package/presets/opencode/nuxt/agents/tech-writer.md +1 -1
- package/presets/opencode/nuxt/agents/unit-test-generator.md +1 -1
- package/presets/opencode/nuxt/agents/unit-test-healer.md +1 -1
- package/presets/opencode/nuxt/agents/unit-test-planner.md +1 -1
- package/presets/opencode/nuxt/commands/task-continue.md +1 -1
- package/presets/opencode/nuxt/hooks/README.md +12 -1
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/nuxt/hooks/guard-shell-command.mjs +877 -0
- package/presets/opencode/nuxt/opencode.json +4 -4
- package/presets/opencode/nuxt/plugins/rule-attach/globs.json +266 -0
- package/presets/opencode/nuxt/rules/agent-team-intake.md +2 -0
- package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +7 -7
- package/presets/opencode/nuxt/rules/preset-writing-style.md +8 -0
- package/presets/opencode/php-hexagonal/OPENCODE.md +5 -60
- package/presets/opencode/php-hexagonal/adapter-map.json +45 -45
- package/presets/opencode/php-hexagonal/agents/api-contract-reviewer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/opencode/php-hexagonal/agents/ci-investigator.md +1 -1
- package/presets/opencode/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/codebase-analyzer.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/integration-test-generator.md +1 -1
- package/presets/opencode/php-hexagonal/agents/integration-test-healer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/integration-test-planner.md +1 -1
- package/presets/opencode/php-hexagonal/agents/migration-specialist.md +1 -1
- package/presets/opencode/php-hexagonal/agents/openspec-author.md +1 -1
- package/presets/opencode/php-hexagonal/agents/performance-auditor.md +1 -1
- package/presets/opencode/php-hexagonal/agents/qa-tester.md +1 -1
- package/presets/opencode/php-hexagonal/agents/security-reviewer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/solution-architect.md +1 -1
- package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/opencode/php-hexagonal/agents/task-router.md +1 -1
- package/presets/opencode/php-hexagonal/agents/tech-writer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/unit-test-generator.md +1 -1
- package/presets/opencode/php-hexagonal/agents/unit-test-healer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/unit-test-planner.md +1 -1
- package/presets/opencode/php-hexagonal/commands/task-continue.md +1 -1
- package/presets/opencode/php-hexagonal/hooks/README.md +12 -1
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/php-hexagonal/hooks/guard-shell-command.mjs +879 -0
- package/presets/opencode/php-hexagonal/opencode.json +4 -4
- package/presets/opencode/php-hexagonal/plugins/rule-attach/globs.json +242 -0
- package/presets/opencode/php-hexagonal/rules/agent-team-intake.md +2 -0
- package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +7 -7
- package/presets/opencode/php-hexagonal/rules/preset-writing-style.md +8 -0
- package/presets/opencode/php-laravel/OPENCODE.md +5 -60
- package/presets/opencode/php-laravel/adapter-map.json +45 -45
- package/presets/opencode/php-laravel/agents/api-contract-reviewer.md +1 -1
- package/presets/opencode/php-laravel/agents/build-verifier.md +1 -1
- package/presets/opencode/php-laravel/agents/ci-investigator.md +1 -1
- package/presets/opencode/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/opencode/php-laravel/agents/codebase-analyzer.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/integration-test-generator.md +1 -1
- package/presets/opencode/php-laravel/agents/integration-test-healer.md +1 -1
- package/presets/opencode/php-laravel/agents/integration-test-planner.md +1 -1
- package/presets/opencode/php-laravel/agents/migration-specialist.md +1 -1
- package/presets/opencode/php-laravel/agents/openspec-author.md +1 -1
- package/presets/opencode/php-laravel/agents/performance-auditor.md +1 -1
- package/presets/opencode/php-laravel/agents/qa-tester.md +1 -1
- package/presets/opencode/php-laravel/agents/security-reviewer.md +1 -1
- package/presets/opencode/php-laravel/agents/solution-architect.md +1 -1
- package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/opencode/php-laravel/agents/task-router.md +1 -1
- package/presets/opencode/php-laravel/agents/tech-writer.md +1 -1
- package/presets/opencode/php-laravel/agents/unit-test-generator.md +1 -1
- package/presets/opencode/php-laravel/agents/unit-test-healer.md +1 -1
- package/presets/opencode/php-laravel/agents/unit-test-planner.md +1 -1
- package/presets/opencode/php-laravel/commands/task-continue.md +1 -1
- package/presets/opencode/php-laravel/hooks/README.md +12 -1
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/php-laravel/hooks/guard-shell-command.mjs +879 -0
- package/presets/opencode/php-laravel/opencode.json +4 -4
- package/presets/opencode/php-laravel/plugins/rule-attach/globs.json +232 -0
- package/presets/opencode/php-laravel/rules/agent-team-intake.md +2 -0
- package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +7 -7
- package/presets/opencode/php-laravel/rules/preset-writing-style.md +8 -0
- package/presets/opencode/platform-contract.json +4 -0
- package/presets/opencode/plugins/output-guard/README.md +1 -1
- package/presets/opencode/plugins/output-guard/index.ts +8 -2
- package/presets/opencode/plugins/output-guard/rewrite.ts +37 -0
- package/presets/opencode/plugins/rule-attach/README.md +34 -0
- package/presets/opencode/plugins/rule-attach/attach.ts +224 -0
- package/presets/opencode/plugins/rule-attach/index.ts +169 -0
- package/presets/opencode/plugins/rule-attach/package.json +9 -0
- package/presets/opencode/plugins/settings-guard/README.md +25 -0
- package/presets/opencode/plugins/settings-guard/index.ts +114 -0
- package/presets/opencode/plugins/settings-guard/package.json +9 -0
- package/presets/opencode/plugins/settings-guard/policy.mjs +85 -0
- package/presets/opencode/plugins/settings-guard/prompt-face.mjs +153 -0
- package/presets/opencode/plugins/task-status/README.md +9 -4
- package/presets/opencode/plugins/task-status/eta.ts +20 -7
- package/presets/opencode/plugins/task-status/index.ts +14 -1
- package/presets/opencode/plugins/task-status/task-view.ts +160 -5
- package/presets/opencode/plugins/task-status/timing.ts +244 -0
- package/presets/opencode/plugins/task-status/types.ts +6 -0
- package/presets/opencode/svelte/OPENCODE.md +5 -54
- package/presets/opencode/svelte/adapter-map.json +51 -51
- package/presets/opencode/svelte/agents/accessibility-reviewer.md +1 -1
- package/presets/opencode/svelte/agents/api-contract-reviewer.md +1 -1
- package/presets/opencode/svelte/agents/build-verifier.md +1 -1
- package/presets/opencode/svelte/agents/ci-investigator.md +1 -1
- package/presets/opencode/svelte/agents/code-reviewer.md +1 -1
- package/presets/opencode/svelte/agents/codebase-analyzer.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/migration-specialist.md +1 -1
- package/presets/opencode/svelte/agents/mockup-reviewer.md +1 -1
- package/presets/opencode/svelte/agents/openspec-author.md +1 -1
- package/presets/opencode/svelte/agents/performance-auditor.md +1 -1
- package/presets/opencode/svelte/agents/playwright-test-generator.md +1 -1
- package/presets/opencode/svelte/agents/playwright-test-healer.md +1 -1
- package/presets/opencode/svelte/agents/playwright-test-planner.md +1 -1
- package/presets/opencode/svelte/agents/qa-tester.md +1 -1
- package/presets/opencode/svelte/agents/security-reviewer.md +1 -1
- package/presets/opencode/svelte/agents/solution-architect.md +1 -1
- package/presets/opencode/svelte/agents/task-analyst.md +1 -1
- package/presets/opencode/svelte/agents/task-router.md +1 -1
- package/presets/opencode/svelte/agents/tech-writer.md +1 -1
- package/presets/opencode/svelte/agents/unit-test-generator.md +1 -1
- package/presets/opencode/svelte/agents/unit-test-healer.md +1 -1
- package/presets/opencode/svelte/agents/unit-test-planner.md +1 -1
- package/presets/opencode/svelte/commands/task-continue.md +1 -1
- package/presets/opencode/svelte/hooks/README.md +12 -1
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/svelte/hooks/guard-shell-command.mjs +877 -0
- package/presets/opencode/svelte/opencode.json +4 -4
- package/presets/opencode/svelte/plugins/rule-attach/globs.json +245 -0
- package/presets/opencode/svelte/rules/agent-team-intake.md +2 -0
- package/presets/opencode/svelte/rules/agent-team-orchestrator.md +7 -7
- package/presets/opencode/svelte/rules/preset-writing-style.md +8 -0
- package/presets/zcode/android-kotlin/adapter-map.json +1 -1
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/android-kotlin/rules/agent-team-intake.md +2 -0
- package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/android-kotlin/rules/preset-writing-style.md +8 -0
- package/presets/zcode/go/adapter-map.json +1 -1
- package/presets/zcode/go/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/go/rules/agent-team-intake.md +2 -0
- package/presets/zcode/go/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/go/rules/preset-writing-style.md +8 -0
- package/presets/zcode/ios-swift/adapter-map.json +1 -1
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/ios-swift/rules/agent-team-intake.md +2 -0
- package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/ios-swift/rules/preset-writing-style.md +8 -0
- package/presets/zcode/java/adapter-map.json +1 -1
- package/presets/zcode/java/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/java/rules/agent-team-intake.md +2 -0
- package/presets/zcode/java/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/java/rules/preset-writing-style.md +8 -0
- package/presets/zcode/mcp-ts/adapter-map.json +1 -1
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/mcp-ts/rules/agent-team-intake.md +2 -0
- package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/mcp-ts/rules/preset-writing-style.md +8 -0
- package/presets/zcode/mol/adapter-map.json +1 -1
- package/presets/zcode/mol/agents/feature-developer.md +1 -1
- package/presets/zcode/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/zcode/mol/commands/task-evil.md +8 -0
- package/presets/zcode/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/mol/rules/agent-team-intake.md +2 -0
- package/presets/zcode/mol/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/mol/rules/preset-writing-style.md +8 -0
- package/presets/zcode/next/REPO_AGENTS.md +2 -0
- package/presets/zcode/next/adapter-map.json +1 -1
- package/presets/zcode/next/agents/feature-developer.md +1 -1
- package/presets/zcode/next/agents/task-analyst.md +1 -7
- package/presets/zcode/next/agents/task-router.md +1 -1
- package/presets/zcode/next/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/zcode/next/commands/spec-start.md +3 -4
- package/presets/zcode/next/commands/task-continue.md +9 -8
- package/presets/zcode/next/commands/task-evil.md +8 -0
- package/presets/zcode/next/commands/task.md +1 -1
- package/presets/zcode/next/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/next/rules/agent-team-intake.md +2 -0
- package/presets/zcode/next/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/next/rules/preset-writing-style.md +8 -0
- package/presets/zcode/next/team/README.md +1 -1
- package/presets/zcode/nuxt/adapter-map.json +1 -1
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/nuxt/rules/agent-team-intake.md +2 -0
- package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/nuxt/rules/preset-writing-style.md +8 -0
- package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/php-hexagonal/rules/agent-team-intake.md +2 -0
- package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/php-hexagonal/rules/preset-writing-style.md +8 -0
- package/presets/zcode/php-laravel/adapter-map.json +1 -1
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/php-laravel/rules/agent-team-intake.md +2 -0
- package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/php-laravel/rules/preset-writing-style.md +8 -0
- package/presets/zcode/svelte/adapter-map.json +1 -1
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/svelte/rules/agent-team-intake.md +2 -0
- package/presets/zcode/svelte/rules/agent-team-orchestrator.md +5 -5
- package/presets/zcode/svelte/rules/preset-writing-style.md +8 -0
- package/scripts/report-context-cost.mjs +1 -20
|
@@ -11,7 +11,10 @@ const fs = require('fs');
|
|
|
11
11
|
const path = require('path');
|
|
12
12
|
const crypto = require('crypto');
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
// Worktree hooks set AI_RULES_TEAM_ROOT so cwd does not open a second store.
|
|
15
|
+
const TEAM_ROOT = process.env.AI_RULES_TEAM_ROOT
|
|
16
|
+
? path.resolve(process.env.AI_RULES_TEAM_ROOT)
|
|
17
|
+
: path.join(process.cwd(), '.ai.local', 'team');
|
|
15
18
|
|
|
16
19
|
const inputRaw = process.env.INPUT || '';
|
|
17
20
|
let hookInput;
|
|
@@ -34,11 +37,15 @@ if (hookInput.status !== 'completed') {
|
|
|
34
37
|
// Slug resolution, strongest first:
|
|
35
38
|
// 1. TEAM_TASK_SLUG — the orchestrator's explicit binding for this call.
|
|
36
39
|
// 2. the per-session lease `.ai.local/team/.session-leases/<session>.json`,
|
|
37
|
-
// written by an earlier call that carried (1)
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
//
|
|
40
|
+
// written by an earlier call that carried (1), or by the OpenCode
|
|
41
|
+
// task-status plugin when it pinned this tab.
|
|
42
|
+
// 3. active-task.json — a UI projection of the live slugs (rebuilt by
|
|
43
|
+
// `team-db sync`), read only as a fallback for older hosts; when more
|
|
44
|
+
// than one slug is live the resolution is ambiguous and refused below.
|
|
45
|
+
// Only (1) writes the lease from this hook. The OpenCode task-status plugin
|
|
46
|
+
// writes the same file when it pins a tab, and `shell.env` injects the session
|
|
47
|
+
// id so this lookup sees that pin. A pointer fallback never writes a lease:
|
|
48
|
+
// that would let one session inherit another's task.
|
|
42
49
|
const SESSION_ID_RE = /^[A-Za-z0-9_-]{1,128}$/;
|
|
43
50
|
const LEASE_ROOT = path.join(TEAM_ROOT, '.session-leases');
|
|
44
51
|
const LEASE_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
|
@@ -102,21 +109,24 @@ if (!slug && sessionId) {
|
|
|
102
109
|
}
|
|
103
110
|
}
|
|
104
111
|
if (!slug) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (!fs.existsSync(activePath)) {
|
|
108
|
-
process.stdout.write('{}');
|
|
109
|
-
process.exit(0);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
let active;
|
|
112
|
+
let active = null;
|
|
113
113
|
try {
|
|
114
|
-
active = JSON.parse(fs.readFileSync(
|
|
114
|
+
active = JSON.parse(fs.readFileSync(path.join(TEAM_ROOT, 'active-task.json'), 'utf8'));
|
|
115
115
|
} catch {
|
|
116
|
+
active = null;
|
|
117
|
+
}
|
|
118
|
+
// Back-compat reader: the projection shape `{"slugs": [...]}` (rebuilt by
|
|
119
|
+
// `team-db sync`) and the legacy single-slot `{"slug"}` shape are accepted
|
|
120
|
+
// forever. An empty or unreadable projection is identical to a missing
|
|
121
|
+
// file: a `{}` no-op.
|
|
122
|
+
const pointerSlugs = active && Array.isArray(active.slugs)
|
|
123
|
+
? active.slugs
|
|
124
|
+
: (active && typeof active.slug === 'string' && active.slug ? [active.slug] : []);
|
|
125
|
+
if (pointerSlugs.length === 0) {
|
|
116
126
|
process.stdout.write('{}');
|
|
117
127
|
process.exit(0);
|
|
118
128
|
}
|
|
119
|
-
slug =
|
|
129
|
+
slug = pointerSlugs[0];
|
|
120
130
|
slugSource = 'active-task.json';
|
|
121
131
|
}
|
|
122
132
|
// Reject non-kebab / traversal slugs: the runtime writes status.json and
|
|
@@ -126,6 +136,44 @@ if (typeof slug !== 'string' || slug.length > 48 || !SLUG_RE.test(slug)) {
|
|
|
126
136
|
process.stdout.write('{}');
|
|
127
137
|
process.exit(0);
|
|
128
138
|
}
|
|
139
|
+
// Canonical live-slug scan over the task store, never the pointer: a slug is
|
|
140
|
+
// live when `tasks/<name>/status.json` parses and its state is not terminal.
|
|
141
|
+
const TERMINAL_STATES = new Set(['completed', 'blocked', 'changes_requested', 'validation_failed']);
|
|
142
|
+
function liveSlugs() {
|
|
143
|
+
const tasksDir = path.join(TEAM_ROOT, 'tasks');
|
|
144
|
+
let entries;
|
|
145
|
+
try {
|
|
146
|
+
entries = fs.readdirSync(tasksDir, { withFileTypes: true });
|
|
147
|
+
} catch {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
const live = [];
|
|
151
|
+
for (const entry of entries) {
|
|
152
|
+
if (!entry.isDirectory()) continue;
|
|
153
|
+
try {
|
|
154
|
+
const status = JSON.parse(fs.readFileSync(path.join(tasksDir, entry.name, 'status.json'), 'utf8'));
|
|
155
|
+
if (status && typeof status.state === 'string' && !TERMINAL_STATES.has(status.state)) live.push(entry.name);
|
|
156
|
+
} catch {}
|
|
157
|
+
}
|
|
158
|
+
return live.sort();
|
|
159
|
+
}
|
|
160
|
+
// Level-3 (pointer) resolution guard: when the slug came from
|
|
161
|
+
// active-task.json and any other live slug exists, the pointer cannot say
|
|
162
|
+
// which task this call belongs to. Refuse loudly — `ok:false` with exit 0,
|
|
163
|
+
// the hook's refusal convention (a non-zero exit would be read as a blocking
|
|
164
|
+
// platform error by Stop-class hook consumers) — so the caller re-runs with
|
|
165
|
+
// `TEAM_TASK_SLUG=<slug>` instead of silently acting on the wrong task.
|
|
166
|
+
// Exactly one live slug keeps today's warning-only behaviour, so older hosts
|
|
167
|
+
// keep working until they pass the env.
|
|
168
|
+
if (slugSource === 'active-task.json') {
|
|
169
|
+
const live = liveSlugs();
|
|
170
|
+
if (live.some((name) => name !== slug)) {
|
|
171
|
+
const shown = live.slice(0, 5).join(', ');
|
|
172
|
+
process.stderr.write(`ERROR: ${slug}: active-task.json is ambiguous — ${live.length} live slugs (${shown}${live.length > 5 ? ', max 5 shown' : ''}); pass TEAM_TASK_SLUG=<slug> on every hook call.\n`);
|
|
173
|
+
process.stdout.write(JSON.stringify({ ok: false, reason: 'active-task-pointer-ambiguous', slug, liveSlugs: live }));
|
|
174
|
+
process.exit(0);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
129
177
|
if (slugSource !== 'TEAM_TASK_SLUG') {
|
|
130
178
|
process.stderr.write(`WARNING: ${slug}: chain hook resolved the slug from ${slugSource}; pass TEAM_TASK_SLUG=<slug> on every hook call so parallel sessions cannot no-op each other.\n`);
|
|
131
179
|
}
|
|
@@ -316,6 +364,86 @@ function attemptStaleMs() {
|
|
|
316
364
|
const value = Number(raw);
|
|
317
365
|
return Number.isFinite(value) && value >= MIN_ATTEMPT_STALE_MS ? value : DEFAULT_ATTEMPT_STALE_MS;
|
|
318
366
|
}
|
|
367
|
+
// Work a single attempt may claim. Wall time beyond it is suspension, a hang, or
|
|
368
|
+
// a stop that arrived days after the agent died, and it is recorded as idle.
|
|
369
|
+
const DEFAULT_ATTEMPT_MAX_MS = 4 * 60 * 60 * 1000;
|
|
370
|
+
const MIN_ATTEMPT_MAX_MS = 10 * 60 * 1000;
|
|
371
|
+
function attemptMaxMs() {
|
|
372
|
+
const raw = process.env.AI_RULES_ATTEMPT_MAX_MS;
|
|
373
|
+
if (typeof raw !== 'string' || raw.trim() === '') return DEFAULT_ATTEMPT_MAX_MS;
|
|
374
|
+
const value = Number(raw);
|
|
375
|
+
return Number.isFinite(value) && value >= MIN_ATTEMPT_MAX_MS ? value : DEFAULT_ATTEMPT_MAX_MS;
|
|
376
|
+
}
|
|
377
|
+
// Intervals appended by the sidebar's suspend detector: the host did not run, so
|
|
378
|
+
// the attempt did not work. Written as JSONL, one { from, to } per line.
|
|
379
|
+
function readSuspendIntervals() {
|
|
380
|
+
const file = path.join(taskDir, '.suspend.jsonl');
|
|
381
|
+
let raw;
|
|
382
|
+
try { raw = fs.readFileSync(file, 'utf8'); } catch { return []; }
|
|
383
|
+
const intervals = [];
|
|
384
|
+
for (const line of raw.split('\n')) {
|
|
385
|
+
const trimmed = line.trim();
|
|
386
|
+
if (trimmed === '') continue;
|
|
387
|
+
try {
|
|
388
|
+
const row = JSON.parse(trimmed);
|
|
389
|
+
const from = Date.parse(row && row.from);
|
|
390
|
+
const to = Date.parse(row && row.to);
|
|
391
|
+
if (Number.isFinite(from) && Number.isFinite(to) && to > from) intervals.push([from, to]);
|
|
392
|
+
} catch { /* a torn last line is re-read when the file grows */ }
|
|
393
|
+
}
|
|
394
|
+
return intervals;
|
|
395
|
+
}
|
|
396
|
+
function unionOverlapMs(intervals, from, to) {
|
|
397
|
+
if (!Number.isFinite(from) || !Number.isFinite(to) || to <= from) return 0;
|
|
398
|
+
const sorted = intervals
|
|
399
|
+
.filter((pair) => Array.isArray(pair) && Number.isFinite(pair[0]) && Number.isFinite(pair[1]) && pair[1] > pair[0])
|
|
400
|
+
.sort((left, right) => left[0] - right[0]);
|
|
401
|
+
let total = 0;
|
|
402
|
+
let cursor = from;
|
|
403
|
+
for (const [start, end] of sorted) {
|
|
404
|
+
const overlapStart = Math.max(start, from, cursor);
|
|
405
|
+
const overlapEnd = Math.min(end, to);
|
|
406
|
+
if (overlapEnd <= overlapStart) continue;
|
|
407
|
+
total += overlapEnd - overlapStart;
|
|
408
|
+
cursor = overlapEnd;
|
|
409
|
+
}
|
|
410
|
+
return total;
|
|
411
|
+
}
|
|
412
|
+
// Everything the ledger can prove was not work: a gate, an operator pause, a
|
|
413
|
+
// host suspension. Attempt wall time minus this is the attempt's active time.
|
|
414
|
+
function attemptIdleMs(startedAtMs, endedAtMs, events) {
|
|
415
|
+
const intervals = readSuspendIntervals();
|
|
416
|
+
// The sentinel is the control plane: it is engaged before `task_paused` is
|
|
417
|
+
// written, so a stop that notices it must still charge the wait as idle.
|
|
418
|
+
const livePause = readPauseSentinel();
|
|
419
|
+
if (livePause.engaged && livePause.at) {
|
|
420
|
+
intervals.push([Date.parse(livePause.at), endedAtMs]);
|
|
421
|
+
}
|
|
422
|
+
const gates = new Map();
|
|
423
|
+
for (const event of events) {
|
|
424
|
+
if (event && event.type === 'human_gate_started' && event.eventId) gates.set(event.eventId, Date.parse(event.at));
|
|
425
|
+
}
|
|
426
|
+
for (const event of events) {
|
|
427
|
+
if (!event) continue;
|
|
428
|
+
if (event.type === 'human_gate_ended' && event.gateStartedEventId) {
|
|
429
|
+
const start = gates.get(event.gateStartedEventId);
|
|
430
|
+
const end = Date.parse(event.at);
|
|
431
|
+
if (Number.isFinite(start) && Number.isFinite(end)) intervals.push([start, end]);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
let openPause = null;
|
|
435
|
+
for (const event of events) {
|
|
436
|
+
if (!event) continue;
|
|
437
|
+
if (event.type === 'task_paused') openPause = Date.parse(event.at);
|
|
438
|
+
if (event.type === 'task_resumed' && openPause !== null) {
|
|
439
|
+
const end = Date.parse(event.at);
|
|
440
|
+
if (Number.isFinite(end) && end > openPause) intervals.push([openPause, end]);
|
|
441
|
+
openPause = null;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
if (openPause !== null && Number.isFinite(openPause)) intervals.push([openPause, endedAtMs]);
|
|
445
|
+
return unionOverlapMs(intervals, startedAtMs, endedAtMs);
|
|
446
|
+
}
|
|
319
447
|
function hasTerminalReceipt(attemptId, entry) {
|
|
320
448
|
const manifestPath = path.join(taskDir, 'artifact-manifest.json');
|
|
321
449
|
if (!fs.existsSync(manifestPath)) return false;
|
|
@@ -373,6 +501,9 @@ function reclaimStaleAttempts(scope) {
|
|
|
373
501
|
role: roleFor(entry.agent),
|
|
374
502
|
outcome: 'stale',
|
|
375
503
|
durationMs: ageMs,
|
|
504
|
+
wallMs: ageMs,
|
|
505
|
+
activeMs: Math.min(ageMs, attemptMaxMs()),
|
|
506
|
+
idleMs: Math.max(0, ageMs - Math.min(ageMs, attemptMaxMs())),
|
|
376
507
|
retryAfterFix: status.retryAfterFix || null,
|
|
377
508
|
source: 'hook',
|
|
378
509
|
attributionConfidence: 'high',
|
|
@@ -1221,7 +1352,33 @@ function sanitizeUsage(value) {
|
|
|
1221
1352
|
/**
|
|
1222
1353
|
* Freshness of a persisted verification snapshot against the current worktree.
|
|
1223
1354
|
* Read-only: closure warns, it never blocks on a stale snapshot.
|
|
1355
|
+
*
|
|
1356
|
+
* Task scoping: with the slug's write-scope step baselines
|
|
1357
|
+
* (`.write-scope/<slug>/*.json`) the evidence hash covers the union of the
|
|
1358
|
+
* baselines' recorded paths only, so another live slug's uncommitted work
|
|
1359
|
+
* cannot stale this task's evidence. Known limit: a file created after baseline
|
|
1360
|
+
* activation outside the claimed path set is invisible to `scopeHash`; the
|
|
1361
|
+
* write-scope audit and `check:task` still attribute such files at gate time
|
|
1362
|
+
* (content-hash delta). The scoped hash is a change detector, not an
|
|
1363
|
+
* attribution tool. `environmentHash` (renamed from `worktreeHash`) keeps the
|
|
1364
|
+
* whole-tree capture as diagnostics only.
|
|
1224
1365
|
*/
|
|
1366
|
+
function writeScopeBaselinePaths(dir) {
|
|
1367
|
+
let entries;
|
|
1368
|
+
try { entries = fs.readdirSync(dir); } catch { return null; }
|
|
1369
|
+
const paths = new Set();
|
|
1370
|
+
for (const entry of entries) {
|
|
1371
|
+
if (!entry.endsWith('.json')) continue;
|
|
1372
|
+
let parsed = null;
|
|
1373
|
+
try { parsed = JSON.parse(fs.readFileSync(path.join(dir, entry), 'utf8')); } catch { parsed = null; }
|
|
1374
|
+
const record = parsed && typeof parsed === 'object' && parsed.paths && typeof parsed.paths === 'object' && !Array.isArray(parsed.paths) ? parsed.paths : null;
|
|
1375
|
+
if (!record) continue;
|
|
1376
|
+
for (const key of Object.keys(record)) {
|
|
1377
|
+
if (typeof key === 'string' && key !== '') paths.add(key.split(path.sep).join('/'));
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
return paths.size > 0 ? [...paths].sort() : null;
|
|
1381
|
+
}
|
|
1225
1382
|
function gitSnapshot() {
|
|
1226
1383
|
const { spawnSync } = require('child_process');
|
|
1227
1384
|
const git = (args) => {
|
|
@@ -1235,11 +1392,30 @@ function gitSnapshot() {
|
|
|
1235
1392
|
const statusText = git(['status', '--porcelain=v1', ...exclude]) || '';
|
|
1236
1393
|
const diffText = git(['diff', '--binary', 'HEAD', ...exclude]) || '';
|
|
1237
1394
|
const untracked = git(['ls-files', '--others', '--exclude-standard', ...exclude]) || '';
|
|
1395
|
+
const baselinePaths = typeof slug === 'string' && slug !== '' && SLUG_RE.test(slug)
|
|
1396
|
+
? writeScopeBaselinePaths(path.join(TEAM_ROOT, '.write-scope', slug))
|
|
1397
|
+
: null;
|
|
1398
|
+
const liveCount = liveSlugs().length;
|
|
1399
|
+
let scopeBasis = 'none';
|
|
1400
|
+
let scopeHash = null;
|
|
1401
|
+
if (baselinePaths !== null) {
|
|
1402
|
+
scopeBasis = 'write-scope';
|
|
1403
|
+
const spec = ['--', ...baselinePaths];
|
|
1404
|
+
const scopedStatus = git(['status', '--porcelain=v1', ...spec]) || '';
|
|
1405
|
+
const scopedDiff = git(['diff', '--binary', 'HEAD', ...spec]) || '';
|
|
1406
|
+
const scopedUntracked = git(['ls-files', '--others', '--exclude-standard', ...spec]) || '';
|
|
1407
|
+
scopeHash = crypto.createHash('sha256').update(`${scopedStatus}\u0000${scopedDiff}\u0000${scopedUntracked}`).digest('hex');
|
|
1408
|
+
} else if (liveCount <= 1) {
|
|
1409
|
+
scopeBasis = 'whole-tree';
|
|
1410
|
+
}
|
|
1238
1411
|
return {
|
|
1239
1412
|
head: head.trim(),
|
|
1240
1413
|
branch: branch === null ? null : branch.trim(),
|
|
1241
1414
|
dirtyFiles: statusText === '' ? 0 : statusText.split('\n').filter((line) => line !== '').length,
|
|
1242
|
-
|
|
1415
|
+
environmentHash: crypto.createHash('sha256').update(`${statusText}\u0000${diffText}\u0000${untracked}`).digest('hex'),
|
|
1416
|
+
scopeBasis,
|
|
1417
|
+
scopePaths: baselinePaths === null ? 0 : baselinePaths.length,
|
|
1418
|
+
scopeHash,
|
|
1243
1419
|
capturedAt: now,
|
|
1244
1420
|
};
|
|
1245
1421
|
}
|
|
@@ -1328,7 +1504,7 @@ function ensureVerificationSnapshot(dir, agent) {
|
|
|
1328
1504
|
fs.writeFileSync(temporary, JSON.stringify(verification, null, 2) + '\n');
|
|
1329
1505
|
fs.renameSync(temporary, file);
|
|
1330
1506
|
});
|
|
1331
|
-
appendMetric({ type: 'verification_recorded', at: now, kind: 'snapshot-only', agent: agent || null, head: snapshot.head,
|
|
1507
|
+
appendMetric({ type: 'verification_recorded', at: now, kind: 'snapshot-only', agent: agent || null, head: snapshot.head, environmentHash: snapshot.environmentHash, source: 'hook', attributionConfidence: 'high' });
|
|
1332
1508
|
}
|
|
1333
1509
|
|
|
1334
1510
|
function verificationFreshness(dir) {
|
|
@@ -1343,15 +1519,34 @@ function verificationFreshness(dir) {
|
|
|
1343
1519
|
// Judge the report the gate judges: its `tree:` header, not the wider worktree
|
|
1344
1520
|
// hash. A later edit inside the same report generation moved the hash while the
|
|
1345
1521
|
// gate still accepted the report, so the same fresh evidence warned twice.
|
|
1522
|
+
// The head comparison stays global (HEAD is shared across live slugs); the
|
|
1523
|
+
// dirty/hash dimension binds to the task's `scopeHash` when the evidence was
|
|
1524
|
+
// captured on a `write-scope` basis — the header's dirty count is a whole-tree
|
|
1525
|
+
// number and is not comparable to a scoped one, so the scoped hash is the
|
|
1526
|
+
// binding check for that basis, and a scope that can no longer be recomputed
|
|
1527
|
+
// reports `scope-unbound` (loud not-fresh, never a false fresh). Legacy
|
|
1528
|
+
// snapshots (no `scopeBasis`) and `whole-tree` snapshots keep today's
|
|
1529
|
+
// whole-tree comparison, reading the renamed field as
|
|
1530
|
+
// `environmentHash ?? worktreeHash`.
|
|
1346
1531
|
const found = evidenceReportText(dir);
|
|
1347
1532
|
const header = found === null ? null : found.text.match(REPORT_TREE_RE);
|
|
1348
1533
|
const reasons = [];
|
|
1349
1534
|
if (header) {
|
|
1350
1535
|
if (!current.head.startsWith(header[1])) reasons.push('head-changed');
|
|
1351
|
-
if (Number(header[2]) !== current.dirtyFiles) reasons.push('worktree-changed');
|
|
1352
1536
|
} else {
|
|
1353
1537
|
if (current.head !== snapshot.head) reasons.push('head-changed');
|
|
1354
|
-
|
|
1538
|
+
}
|
|
1539
|
+
const basis = typeof snapshot.scopeBasis === 'string' ? snapshot.scopeBasis : 'legacy';
|
|
1540
|
+
if (basis === 'write-scope') {
|
|
1541
|
+
if (current.scopeBasis !== 'write-scope') reasons.push('scope-unbound');
|
|
1542
|
+
else if (current.scopeHash !== snapshot.scopeHash) reasons.push('worktree-changed');
|
|
1543
|
+
} else if (basis === 'none') {
|
|
1544
|
+
reasons.push('scope-unbound');
|
|
1545
|
+
} else if (header) {
|
|
1546
|
+
if (Number(header[2]) !== current.dirtyFiles) reasons.push('worktree-changed');
|
|
1547
|
+
} else {
|
|
1548
|
+
const recorded = typeof snapshot.environmentHash === 'string' ? snapshot.environmentHash : snapshot.worktreeHash;
|
|
1549
|
+
if (current.environmentHash !== recorded) reasons.push('worktree-changed');
|
|
1355
1550
|
}
|
|
1356
1551
|
return { present: true, fresh: reasons.length === 0, reasons };
|
|
1357
1552
|
}
|
|
@@ -1370,10 +1565,32 @@ function noteVerificationFreshness(dir, agent) {
|
|
|
1370
1565
|
|
|
1371
1566
|
function finishActiveAttempt(forced) {
|
|
1372
1567
|
const resolved = forced || resolvedAttempt(); if (!resolved) return null;
|
|
1373
|
-
const
|
|
1568
|
+
const startedAtMs = Date.parse(resolved.entry.startedAt);
|
|
1569
|
+
const endedAtMs = Date.parse(now);
|
|
1570
|
+
const wallMs = Number.isFinite(startedAtMs) && Number.isFinite(endedAtMs) ? Math.max(0, endedAtMs - startedAtMs) : null;
|
|
1571
|
+
// Suspension, a gate or an operator pause inside the attempt is not work.
|
|
1572
|
+
const nonWorkMs = wallMs === null ? null : attemptIdleMs(startedAtMs, endedAtMs, readMetricsEvents());
|
|
1573
|
+
// `idleMs` is the remainder, not only the proven intervals: wall = active + idle.
|
|
1574
|
+
const activeMs = wallMs === null ? null : Math.min(Math.max(0, wallMs - nonWorkMs), attemptMaxMs());
|
|
1575
|
+
const idleMs = wallMs === null ? null : Math.max(0, wallMs - (activeMs ?? 0));
|
|
1374
1576
|
const outcome = ['completed', 'blocked', 'changes_requested', 'validation_failed'].includes(status.state) ? status.state : 'unknown';
|
|
1375
1577
|
const usage = sanitizeUsage(hookInput.usage);
|
|
1376
|
-
appendMetric({
|
|
1578
|
+
appendMetric({
|
|
1579
|
+
type: 'attempt_finished',
|
|
1580
|
+
at: now,
|
|
1581
|
+
attemptId: resolved.attemptId,
|
|
1582
|
+
stepIndex: typeof resolved.entry.stepIndex === 'number' ? resolved.entry.stepIndex : null,
|
|
1583
|
+
agent: resolved.entry.agent || null,
|
|
1584
|
+
outcome,
|
|
1585
|
+
durationMs: wallMs,
|
|
1586
|
+
wallMs,
|
|
1587
|
+
activeMs,
|
|
1588
|
+
idleMs,
|
|
1589
|
+
retryAfterFix: status.retryAfterFix || null,
|
|
1590
|
+
source: resolved.source || 'hook',
|
|
1591
|
+
attributionConfidence: resolved.confidence,
|
|
1592
|
+
...(usage ? { usage } : {}),
|
|
1593
|
+
});
|
|
1377
1594
|
if (resolved.entry && resolved.entry.agent === 'build-verifier') { ensureVerificationSnapshot(taskDir, resolved.entry.agent); noteVerificationFreshness(taskDir, resolved.entry.agent); }
|
|
1378
1595
|
const active = { ...(status.activeAttempts || {}) }; delete active[resolved.attemptId]; status.activeAttempts = active; status.lastCompletedAttempt = { attemptId: resolved.attemptId, completedAt: now }; return { ...resolved, outcome };
|
|
1379
1596
|
}
|
|
@@ -1450,10 +1667,38 @@ function completePipeline(statusPatch) {
|
|
|
1450
1667
|
out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
|
|
1451
1668
|
process.exit(0);
|
|
1452
1669
|
}
|
|
1453
|
-
function beginHumanGate() {
|
|
1670
|
+
function beginHumanGate() {
|
|
1671
|
+
// A second stop for the same gate must not open a parallel one: the wait
|
|
1672
|
+
// would be counted twice and the pairing lost.
|
|
1673
|
+
if (status.activeHumanGateEventId && status.awaitingHumanGate) return;
|
|
1674
|
+
const eventId = `${status.metricsRunId || slug}:gate:${Date.now()}`;
|
|
1675
|
+
appendMetric({
|
|
1676
|
+
eventId,
|
|
1677
|
+
type: 'human_gate_started',
|
|
1678
|
+
at: now,
|
|
1679
|
+
stepIndex: typeof status.pipelineIndex === 'number' ? status.pipelineIndex : null,
|
|
1680
|
+
agent: status.currentAgent || null,
|
|
1681
|
+
source: 'hook',
|
|
1682
|
+
attributionConfidence: 'high',
|
|
1683
|
+
});
|
|
1684
|
+
status.activeHumanGateEventId = eventId;
|
|
1685
|
+
}
|
|
1454
1686
|
function endHumanGateIfResumed() {
|
|
1455
1687
|
if (!status.activeHumanGateEventId || status.awaitingHumanGate || status.state === 'awaiting_approval') return;
|
|
1456
|
-
|
|
1688
|
+
const events = readMetricsEvents();
|
|
1689
|
+
const started = events.find((event) => event && event.type === 'human_gate_started' && event.eventId === status.activeHumanGateEventId);
|
|
1690
|
+
const startedAt = started ? Date.parse(started.at) : NaN;
|
|
1691
|
+
// The gate ends when work resumed, not when a later stop noticed it.
|
|
1692
|
+
const resumed = Number.isFinite(startedAt)
|
|
1693
|
+
? events.find((event) => event && event.type === 'attempt_started' && Date.parse(event.at) > startedAt)
|
|
1694
|
+
: null;
|
|
1695
|
+
appendMetric({
|
|
1696
|
+
type: 'human_gate_ended',
|
|
1697
|
+
at: resumed ? resumed.at : now,
|
|
1698
|
+
gateStartedEventId: status.activeHumanGateEventId,
|
|
1699
|
+
source: 'hook',
|
|
1700
|
+
attributionConfidence: 'high',
|
|
1701
|
+
});
|
|
1457
1702
|
delete status.activeHumanGateEventId;
|
|
1458
1703
|
}
|
|
1459
1704
|
function completeTaskMetrics() {
|
|
@@ -1818,21 +2063,22 @@ function writeStatus(next) {
|
|
|
1818
2063
|
// attempt is finished before this check runs. An empty or unreadable file still
|
|
1819
2064
|
// counts as engaged (fail safe).
|
|
1820
2065
|
const PAUSE_SENTINELS = [
|
|
1821
|
-
path.join(process.cwd(), '.ai.local', 'STOP'),
|
|
1822
|
-
path.join(process.cwd(), '.ai.local', 'ESTOP'),
|
|
2066
|
+
{ file: path.join(process.cwd(), '.ai.local', 'STOP'), scope: 'repo' },
|
|
2067
|
+
{ file: path.join(process.cwd(), '.ai.local', 'ESTOP'), scope: 'repo-emergency' },
|
|
1823
2068
|
];
|
|
1824
2069
|
function readPauseSentinel() {
|
|
1825
2070
|
const sentinels = [...PAUSE_SENTINELS];
|
|
1826
2071
|
if (typeof slug === 'string' && slug !== '') {
|
|
1827
|
-
sentinels.push(path.join(process.cwd(), '.ai.local', 'team', 'tasks', slug, 'STOP'));
|
|
2072
|
+
sentinels.push({ file: path.join(process.cwd(), '.ai.local', 'team', 'tasks', slug, 'STOP'), scope: 'task' });
|
|
1828
2073
|
}
|
|
1829
|
-
for (const
|
|
2074
|
+
for (const sentinel of sentinels) {
|
|
2075
|
+
const file = sentinel.file;
|
|
1830
2076
|
let stat = null;
|
|
1831
2077
|
try { stat = fs.statSync(file); } catch (error) {
|
|
1832
2078
|
if (error && error.code === 'ENOENT') continue;
|
|
1833
2079
|
// A permission or I/O error is not proof of absence: fail safe and say so.
|
|
1834
2080
|
process.stderr.write(`WARNING: ${slug}: cannot stat pause sentinel ${path.relative(process.cwd(), file).split(path.sep).join('/')} (${error && error.message ? error.message : String(error)}); treating it as engaged.\n`);
|
|
1835
|
-
return { engaged: true, file: path.relative(process.cwd(), file).split(path.sep).join('/'), reason: 'sentinel stat failed' };
|
|
2081
|
+
return { engaged: true, file: path.relative(process.cwd(), file).split(path.sep).join('/'), scope: sentinel.scope, at: null, reason: 'sentinel stat failed' };
|
|
1836
2082
|
}
|
|
1837
2083
|
if (!stat || !stat.isFile()) continue;
|
|
1838
2084
|
let reason = '';
|
|
@@ -1850,19 +2096,52 @@ function readPauseSentinel() {
|
|
|
1850
2096
|
return {
|
|
1851
2097
|
engaged: true,
|
|
1852
2098
|
file: path.relative(process.cwd(), file).split(path.sep).join('/'),
|
|
2099
|
+
scope: sentinel.scope,
|
|
2100
|
+
// The pause started when the sentinel was written, not when a hook noticed it.
|
|
2101
|
+
at: new Date(stat.mtimeMs).toISOString(),
|
|
1853
2102
|
reason: reason.replace(/\s+/g, ' ').slice(0, 160),
|
|
1854
2103
|
};
|
|
1855
2104
|
}
|
|
1856
|
-
return { engaged: false, file: null, reason: '' };
|
|
2105
|
+
return { engaged: false, file: null, scope: null, at: null, reason: '' };
|
|
1857
2106
|
}
|
|
1858
2107
|
function pausedNotice(pause) {
|
|
1859
2108
|
const where = pause && pause.file ? pause.file : '.ai.local/STOP';
|
|
1860
2109
|
const because = pause && pause.reason ? ` (${pause.reason})` : '';
|
|
1861
2110
|
return `[chain-team-phases] ${slug}: paused — operator sentinel ${where} is engaged${because}. No step advanced and no handoff was emitted. Remove the sentinel and run /task-continue ${slug}.`;
|
|
1862
2111
|
}
|
|
2112
|
+
// A pause is a duration in the ledger, not only a file. One `task_paused` per
|
|
2113
|
+
// engagement and one `task_resumed` when the sentinel is gone.
|
|
2114
|
+
function recordPauseEngaged(pause) {
|
|
2115
|
+
if (openPauseIndex(readMetricsEvents()) !== -1) return;
|
|
2116
|
+
appendMetric({
|
|
2117
|
+
type: 'task_paused',
|
|
2118
|
+
at: pause.at || now,
|
|
2119
|
+
scope: pause.scope || 'repo',
|
|
2120
|
+
file: pause.file || null,
|
|
2121
|
+
reason: pause.reason || null,
|
|
2122
|
+
source: 'hook',
|
|
2123
|
+
attributionConfidence: 'high',
|
|
2124
|
+
});
|
|
2125
|
+
}
|
|
2126
|
+
function recordPauseResumed() {
|
|
2127
|
+
const events = readMetricsEvents();
|
|
2128
|
+
const index = openPauseIndex(events);
|
|
2129
|
+
if (index === -1) return;
|
|
2130
|
+
appendMetric({
|
|
2131
|
+
type: 'task_resumed',
|
|
2132
|
+
at: now,
|
|
2133
|
+
pausedSince: events[index].at || null,
|
|
2134
|
+
source: 'hook',
|
|
2135
|
+
attributionConfidence: 'high',
|
|
2136
|
+
});
|
|
2137
|
+
}
|
|
1863
2138
|
function pauseBlocksAdvance() {
|
|
1864
2139
|
const pause = readPauseSentinel();
|
|
1865
|
-
if (!pause.engaged)
|
|
2140
|
+
if (!pause.engaged) {
|
|
2141
|
+
recordPauseResumed();
|
|
2142
|
+
return null;
|
|
2143
|
+
}
|
|
2144
|
+
recordPauseEngaged(pause);
|
|
1866
2145
|
writeStatus({ state: 'paused', phase: 'paused' });
|
|
1867
2146
|
out(pausedNotice(pause));
|
|
1868
2147
|
return pause;
|
|
@@ -2299,6 +2578,96 @@ function countDebugImplementationRetries() {
|
|
|
2299
2578
|
return 0;
|
|
2300
2579
|
}
|
|
2301
2580
|
}
|
|
2581
|
+
function replanDecisionCount() {
|
|
2582
|
+
try {
|
|
2583
|
+
const text = fs.readFileSync(path.join(taskDir, '.memlog.md'), 'utf8');
|
|
2584
|
+
const matches = text.match(/replan rev\s+\d+\s*(?:→|->)\s*\d+/g);
|
|
2585
|
+
return matches ? matches.length : 0;
|
|
2586
|
+
} catch {
|
|
2587
|
+
return 0;
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
function changesRequestedCount(agent) {
|
|
2591
|
+
if (typeof agent !== 'string' || agent === '') return 0;
|
|
2592
|
+
try {
|
|
2593
|
+
const metrics = JSON.parse(fs.readFileSync(METRICS_PATH, 'utf8'));
|
|
2594
|
+
const events = Array.isArray(metrics.events) ? metrics.events : [];
|
|
2595
|
+
const needle = `:${agent}:`;
|
|
2596
|
+
return events.filter((event) => event && event.type === 'attempt_finished' && event.outcome === 'changes_requested' && typeof event.attemptId === 'string' && event.attemptId.includes(needle)).length;
|
|
2597
|
+
} catch {
|
|
2598
|
+
return 0;
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
function holdDesignEscalation(agent, mode, reviewerStepIndex) {
|
|
2602
|
+
if (changesRequestedCount(agent) < 2) return false;
|
|
2603
|
+
beginHumanGate();
|
|
2604
|
+
writeStatus({
|
|
2605
|
+
awaitingHumanGate: true,
|
|
2606
|
+
state: 'awaiting_approval',
|
|
2607
|
+
currentAgent: agent,
|
|
2608
|
+
phase: 'human_gate',
|
|
2609
|
+
designEscalation: {
|
|
2610
|
+
agent,
|
|
2611
|
+
mode,
|
|
2612
|
+
reviewerStepIndex: Number.isInteger(reviewerStepIndex) ? reviewerStepIndex : null,
|
|
2613
|
+
priorReplanCount: replanDecisionCount(),
|
|
2614
|
+
},
|
|
2615
|
+
parallelCompleted: [],
|
|
2616
|
+
parallelOutcomes: {},
|
|
2617
|
+
waveSteps: [],
|
|
2618
|
+
waveId: null,
|
|
2619
|
+
retryAfterFix: null,
|
|
2620
|
+
retryAfterFixStepIndex: null,
|
|
2621
|
+
});
|
|
2622
|
+
out(`${agent} requested changes for slug "${slug}" a second time in this task. Append a \`.memlog.md\` line \`decision: replan rev N → N+1\` that changes the model, then resume via /task-continue. The next attempt is not dispatched until that line exists.`);
|
|
2623
|
+
process.exit(0);
|
|
2624
|
+
}
|
|
2625
|
+
function resumeDesignEscalation(escalation, resumeSteps) {
|
|
2626
|
+
steps = resumeSteps;
|
|
2627
|
+
const reviewer = escalation.agent;
|
|
2628
|
+
const reviewerStepIndex = Number.isInteger(escalation.reviewerStepIndex)
|
|
2629
|
+
? escalation.reviewerStepIndex
|
|
2630
|
+
: (typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0);
|
|
2631
|
+
status.pipelineIndex = reviewerStepIndex;
|
|
2632
|
+
delete status.designEscalation;
|
|
2633
|
+
if (escalation.mode === 'graph') {
|
|
2634
|
+
const producerIndex = resolveProducerStepIndex('feature-developer', reviewerStepIndex);
|
|
2635
|
+
if (producerIndex < 0) {
|
|
2636
|
+
out(`${reviewer} requested changes for slug "${slug}" but no graph ancestor authors fixes. Read the review artifact. Resume only via /task-continue.`);
|
|
2637
|
+
process.exit(0);
|
|
2638
|
+
}
|
|
2639
|
+
appendMetric({ type: 'retry_scheduled', at: now, attemptId: status.lastCompletedAttempt?.attemptId || null, nextAgent: 'feature-developer', retryAfterFix: reviewer, source: 'hook', attributionConfidence: 'high' });
|
|
2640
|
+
invalidateFrom(producerIndex, reviewerStepIndex);
|
|
2641
|
+
writeStatus({ state: 'in_progress', phase: 'executing', awaitingHumanGate: false, waveSteps: [], waveId: null, retryAfterFix: null, retryAfterFixStepIndex: null, parallelCompleted: [], parallelOutcomes: {} });
|
|
2642
|
+
if (!dispatchReadyWave(`Design escalation for ${reviewer} accepted; re-dispatching unsatisfied steps.`)) out(noProgressNotice());
|
|
2643
|
+
process.exit(0);
|
|
2644
|
+
}
|
|
2645
|
+
let verifierStepIndex = -1;
|
|
2646
|
+
for (let index = reviewerStepIndex - 1; index >= 0; index -= 1) {
|
|
2647
|
+
if (getStepAgents(steps[index]).includes('build-verifier')) {
|
|
2648
|
+
verifierStepIndex = index;
|
|
2649
|
+
break;
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
const retryGate = verifierStepIndex >= 0 ? 'build-verifier' : reviewer;
|
|
2653
|
+
const retryAfterFixStepIndex = verifierStepIndex >= 0 ? verifierStepIndex : reviewerStepIndex;
|
|
2654
|
+
const developerIndex = scheduleRetry('feature-developer', reviewer, status.lastCompletedAttempt);
|
|
2655
|
+
if (developerIndex < 0) {
|
|
2656
|
+
out(`${reviewer} requested changes for slug "${slug}" but this pipeline has no feature-developer step. Read the review artifact. Resume only via /task-continue.`);
|
|
2657
|
+
process.exit(0);
|
|
2658
|
+
}
|
|
2659
|
+
writeStatus({
|
|
2660
|
+
pipelineIndex: developerIndex,
|
|
2661
|
+
currentAgent: 'feature-developer',
|
|
2662
|
+
state: 'in_progress',
|
|
2663
|
+
phase: 'executing',
|
|
2664
|
+
awaitingHumanGate: false,
|
|
2665
|
+
retryAfterFix: retryGate,
|
|
2666
|
+
retryAfterFixStepIndex,
|
|
2667
|
+
});
|
|
2668
|
+
out(handoffForAgent('feature-developer', steps[developerIndex]?.scope, steps[developerIndex]) + ` After fixes, re-run ${retryGate}.`);
|
|
2669
|
+
process.exit(0);
|
|
2670
|
+
}
|
|
2302
2671
|
function featureDeveloperAlreadyStarted() {
|
|
2303
2672
|
try {
|
|
2304
2673
|
const metrics = JSON.parse(fs.readFileSync(METRICS_PATH, 'utf8'));
|
|
@@ -2731,6 +3100,19 @@ if (hookInput.action === 'bootstrap') {
|
|
|
2731
3100
|
function readMetricsLedger() {
|
|
2732
3101
|
try { return JSON.parse(fs.readFileSync(METRICS_PATH, 'utf8')); } catch { return null; }
|
|
2733
3102
|
}
|
|
3103
|
+
function readMetricsEvents() {
|
|
3104
|
+
const ledger = readMetricsLedger();
|
|
3105
|
+
return ledger && Array.isArray(ledger.events) ? ledger.events : [];
|
|
3106
|
+
}
|
|
3107
|
+
/** Index of the `task_paused` that no `task_resumed` closed, or -1. */
|
|
3108
|
+
function openPauseIndex(events) {
|
|
3109
|
+
for (let index = events.length - 1; index >= 0; index -= 1) {
|
|
3110
|
+
const type = events[index] && events[index].type;
|
|
3111
|
+
if (type === 'task_resumed') return -1;
|
|
3112
|
+
if (type === 'task_paused') return index;
|
|
3113
|
+
}
|
|
3114
|
+
return -1;
|
|
3115
|
+
}
|
|
2734
3116
|
|
|
2735
3117
|
if (hookInput.action === 'out_of_band_start') {
|
|
2736
3118
|
if (pauseBlocksAdvance()) process.exit(0);
|
|
@@ -2797,6 +3179,11 @@ if (hookInput.action === 'out_of_band_end') {
|
|
|
2797
3179
|
|
|
2798
3180
|
if (hookInput.action === 'end_human_gate') {
|
|
2799
3181
|
if (pauseBlocksAdvance()) process.exit(0);
|
|
3182
|
+
const designEscalation = status.designEscalation && typeof status.designEscalation === 'object' ? status.designEscalation : null;
|
|
3183
|
+
if (designEscalation && replanDecisionCount() <= (Number(designEscalation.priorReplanCount) || 0)) {
|
|
3184
|
+
out(`Design escalation for slug "${slug}" is still open. Append a \`.memlog.md\` line \`decision: replan rev N → N+1\` that changes the model, then resume via /task-continue.`);
|
|
3185
|
+
process.exit(0);
|
|
3186
|
+
}
|
|
2800
3187
|
// Only advance when a gate was actually open. A duplicate or retried
|
|
2801
3188
|
// end_human_gate must be a no-op, not a silent pipeline skip.
|
|
2802
3189
|
const gateWasOpen = Boolean(status.activeHumanGateEventId) || status.awaitingHumanGate === true;
|
|
@@ -2828,6 +3215,12 @@ if (hookInput.action === 'end_human_gate') {
|
|
|
2828
3215
|
});
|
|
2829
3216
|
delete status.activeHumanGateEventId;
|
|
2830
3217
|
}
|
|
3218
|
+
if (designEscalation && hookInput.activateNext && fs.existsSync(pipelinePath)) {
|
|
3219
|
+
let designPipeline = null;
|
|
3220
|
+
try { designPipeline = JSON.parse(fs.readFileSync(pipelinePath, 'utf8')); } catch {}
|
|
3221
|
+
const designSteps = designPipeline && Array.isArray(designPipeline.steps) ? designPipeline.steps : [];
|
|
3222
|
+
resumeDesignEscalation(designEscalation, designSteps);
|
|
3223
|
+
}
|
|
2831
3224
|
if (gateWasOpen && hookInput.activateNext && fs.existsSync(pipelinePath)) {
|
|
2832
3225
|
let resumePipeline = null;
|
|
2833
3226
|
try { resumePipeline = JSON.parse(fs.readFileSync(pipelinePath, 'utf8')); } catch {}
|
|
@@ -2967,10 +3360,12 @@ if (status.state === 'awaiting_artifact_receipt') {
|
|
|
2967
3360
|
const pause = readPauseSentinel();
|
|
2968
3361
|
if (pause.engaged) {
|
|
2969
3362
|
if (artifactStallMessage) process.stderr.write(artifactStallMessage + '\n');
|
|
3363
|
+
recordPauseEngaged(pause);
|
|
2970
3364
|
writeStatus({ state: 'paused', phase: 'paused' });
|
|
2971
3365
|
out(pausedNotice(pause));
|
|
2972
3366
|
process.exit(0);
|
|
2973
3367
|
}
|
|
3368
|
+
recordPauseResumed();
|
|
2974
3369
|
writeStatus({});
|
|
2975
3370
|
emitArtifactStall(artifactStallMessage, !wasWaitingForReceipt);
|
|
2976
3371
|
process.exit(0);
|
|
@@ -3194,6 +3589,7 @@ if (waveIndexes) {
|
|
|
3194
3589
|
out(`${retryReviewer} requested changes for slug "${slug}" but no graph ancestor authors fixes. Read the review artifact. Resume only via /task-continue.`);
|
|
3195
3590
|
process.exit(0);
|
|
3196
3591
|
}
|
|
3592
|
+
holdDesignEscalation(retryReviewer, 'graph', reviewerStepIndex);
|
|
3197
3593
|
const graphPredecessor = outcomes[retryReviewer]
|
|
3198
3594
|
? { attemptId: outcomes[retryReviewer].attemptId, confidence: outcomes[retryReviewer].confidence }
|
|
3199
3595
|
: finishedAttempt;
|
|
@@ -3206,6 +3602,7 @@ if (waveIndexes) {
|
|
|
3206
3602
|
if (!dispatchReadyWave(`Step ${reviewerStepIndex} (${retryReviewer}) requested changes; re-dispatching unsatisfied steps.`)) out(noProgressNotice());
|
|
3207
3603
|
process.exit(0);
|
|
3208
3604
|
}
|
|
3605
|
+
holdDesignEscalation(retryReviewer, 'linear', idx);
|
|
3209
3606
|
const retryAfterFixStepIndex = idx;
|
|
3210
3607
|
const predecessor = outcomes[retryReviewer]
|
|
3211
3608
|
? {
|
|
@@ -3305,6 +3702,7 @@ if (status.state === 'changes_requested') {
|
|
|
3305
3702
|
process.exit(0);
|
|
3306
3703
|
}
|
|
3307
3704
|
const reviewerStepIndex = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
|
|
3705
|
+
holdDesignEscalation(reviewer, 'linear', reviewerStepIndex);
|
|
3308
3706
|
let verifierStepIndex = -1;
|
|
3309
3707
|
for (let index = reviewerStepIndex - 1; index >= 0; index -= 1) {
|
|
3310
3708
|
if (getStepAgents(steps[index]).includes('build-verifier')) {
|
|
@@ -3438,26 +3836,21 @@ const fs = require('fs');
|
|
|
3438
3836
|
const path = require('path');
|
|
3439
3837
|
const { spawnSync } = require('child_process');
|
|
3440
3838
|
|
|
3839
|
+
// Slug binding for the seams below is inside the projection markers. The
|
|
3840
|
+
// dualwrite harness executes that region alone, so the resolver has to live
|
|
3841
|
+
// there or a fresh store is never created.
|
|
3842
|
+
|
|
3441
3843
|
// Dev-server cleanup: terminal task state only. `processes.mjs` proves
|
|
3442
3844
|
// ownership from `.ai.local/.processes/leases/<name>.json` before any signal,
|
|
3443
3845
|
// so a foreign process is never touched. A refusal or timeout is a warning,
|
|
3444
|
-
// never a hook failure.
|
|
3846
|
+
// never a hook failure. The slug is the env binding only — no pointer
|
|
3847
|
+
// fallback: cleanup matters only on terminal state, and the main hook always
|
|
3848
|
+
// knows the slug it resolved.
|
|
3445
3849
|
function stopOwnedDevServers() {
|
|
3446
3850
|
const processes = path.join(process.cwd(), '.ai.local', 'scripts', 'processes.mjs');
|
|
3447
3851
|
if (!fs.existsSync(processes)) return;
|
|
3448
|
-
const
|
|
3449
|
-
|
|
3450
|
-
if (!slug) {
|
|
3451
|
-
try {
|
|
3452
|
-
const active = JSON.parse(
|
|
3453
|
-
fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'active-task.json'), 'utf8'),
|
|
3454
|
-
);
|
|
3455
|
-
slug = typeof active.slug === 'string' ? active.slug : '';
|
|
3456
|
-
} catch {
|
|
3457
|
-
return;
|
|
3458
|
-
}
|
|
3459
|
-
}
|
|
3460
|
-
if (slug.length === 0 || slug.length > 48 || !SLUG_RE.test(slug)) return;
|
|
3852
|
+
const slug = typeof process.env.TEAM_TASK_SLUG === 'string' ? process.env.TEAM_TASK_SLUG : '';
|
|
3853
|
+
if (slug.length === 0 || slug.length > 48 || !POSTFLIGHT_SLUG_RE.test(slug)) return;
|
|
3461
3854
|
let state = '';
|
|
3462
3855
|
try {
|
|
3463
3856
|
const status = JSON.parse(
|
|
@@ -3685,6 +4078,95 @@ if (!input || input.status !== 'completed') {
|
|
|
3685
4078
|
// This is a plain region marker, not a `hook-slot`: the block is identical in
|
|
3686
4079
|
// all 40 rendered bodies and needs no per-stack fragment.
|
|
3687
4080
|
// <<<team-db-projection>>>
|
|
4081
|
+
// Postflight slug binding, shared by the seams below: the env slug first,
|
|
4082
|
+
// then the per-session lease (the same file the main hook and the OpenCode
|
|
4083
|
+
// task-status plugin write), and the active-task.json projection only as a
|
|
4084
|
+
// last resort. Containment comes from validating every derivation point with
|
|
4085
|
+
// the slug grammar (the same pattern as the hook's SLUG_RE), so `tasks/<slug>`
|
|
4086
|
+
// cannot escape the tree on any postflight path. This region is extracted and
|
|
4087
|
+
// executed alone by the dualwrite harness, so the resolver stays inside the
|
|
4088
|
+
// markers.
|
|
4089
|
+
const TERMINAL_STATES = new Set(['completed', 'blocked', 'changes_requested', 'validation_failed']);
|
|
4090
|
+
const POSTFLIGHT_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
4091
|
+
function postflightLiveSlugs() {
|
|
4092
|
+
const tasksDir = path.join(process.cwd(), '.ai.local', 'team', 'tasks');
|
|
4093
|
+
let entries;
|
|
4094
|
+
try {
|
|
4095
|
+
entries = fs.readdirSync(tasksDir, { withFileTypes: true });
|
|
4096
|
+
} catch (error) {
|
|
4097
|
+
return [];
|
|
4098
|
+
}
|
|
4099
|
+
const live = [];
|
|
4100
|
+
for (const entry of entries) {
|
|
4101
|
+
if (!entry.isDirectory()) continue;
|
|
4102
|
+
try {
|
|
4103
|
+
const status = JSON.parse(fs.readFileSync(path.join(tasksDir, entry.name, 'status.json'), 'utf8'));
|
|
4104
|
+
if (status && typeof status.state === 'string' && !TERMINAL_STATES.has(status.state)) live.push(entry.name);
|
|
4105
|
+
} catch (error) {
|
|
4106
|
+
/* an unreadable status is not a live slug */
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
return live.sort();
|
|
4110
|
+
}
|
|
4111
|
+
function postflightPointerSlug() {
|
|
4112
|
+
// Last-resort read of the UI projection; both the projection shape
|
|
4113
|
+
// `{"slugs": [...]}` and the legacy single-slot `{"slug"}` are accepted
|
|
4114
|
+
// forever. A multi-slug projection resolves to its first entry; the
|
|
4115
|
+
// live-scan guard in postflightResolveSlug decides whether that
|
|
4116
|
+
// resolution is safe to act on.
|
|
4117
|
+
try {
|
|
4118
|
+
const active = JSON.parse(
|
|
4119
|
+
fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'active-task.json'), 'utf8'),
|
|
4120
|
+
);
|
|
4121
|
+
const slugs = Array.isArray(active.slugs)
|
|
4122
|
+
? active.slugs
|
|
4123
|
+
: (typeof active.slug === 'string' && active.slug ? [active.slug] : []);
|
|
4124
|
+
const candidate = typeof slugs[0] === 'string' ? slugs[0] : '';
|
|
4125
|
+
if (candidate.length > 48 || !POSTFLIGHT_SLUG_RE.test(candidate)) return '';
|
|
4126
|
+
return candidate;
|
|
4127
|
+
} catch (error) {
|
|
4128
|
+
return '';
|
|
4129
|
+
}
|
|
4130
|
+
}
|
|
4131
|
+
function postflightSessionId() {
|
|
4132
|
+
const raw = process.env.OPENCODE_SESSION_ID || process.env.AI_RULES_SESSION_ID || '';
|
|
4133
|
+
return /^[A-Za-z0-9_-]{1,128}$/.test(raw) ? raw : '';
|
|
4134
|
+
}
|
|
4135
|
+
function postflightLeaseSlug() {
|
|
4136
|
+
// Same file and TTL as the main hook. A pointer fallback must not win while
|
|
4137
|
+
// this session already has a pin.
|
|
4138
|
+
const id = postflightSessionId();
|
|
4139
|
+
if (!id) return '';
|
|
4140
|
+
try {
|
|
4141
|
+
const file = path.join(process.cwd(), '.ai.local', 'team', '.session-leases', `${id}.json`);
|
|
4142
|
+
if (Date.now() - fs.statSync(file).mtimeMs > 7 * 24 * 60 * 60 * 1000) return '';
|
|
4143
|
+
const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
4144
|
+
const slug = parsed && typeof parsed.slug === 'string' ? parsed.slug : '';
|
|
4145
|
+
if (slug.length > 48 || !POSTFLIGHT_SLUG_RE.test(slug)) return '';
|
|
4146
|
+
return slug;
|
|
4147
|
+
} catch (error) {
|
|
4148
|
+
return '';
|
|
4149
|
+
}
|
|
4150
|
+
}
|
|
4151
|
+
function postflightResolveSlug() {
|
|
4152
|
+
// An env slug present but invalid is a stop, not a fallback: the projection
|
|
4153
|
+
// must never route around a bad explicit binding.
|
|
4154
|
+
const envSlug = typeof process.env.TEAM_TASK_SLUG === 'string' ? process.env.TEAM_TASK_SLUG : '';
|
|
4155
|
+
if (envSlug !== '') {
|
|
4156
|
+
if (envSlug.length <= 48 && POSTFLIGHT_SLUG_RE.test(envSlug)) return { slug: envSlug };
|
|
4157
|
+
return { slug: '' };
|
|
4158
|
+
}
|
|
4159
|
+
const leaseSlug = postflightLeaseSlug();
|
|
4160
|
+
if (leaseSlug) return { slug: leaseSlug };
|
|
4161
|
+
const pointerSlug = postflightPointerSlug();
|
|
4162
|
+
if (!pointerSlug) return { slug: '' };
|
|
4163
|
+
const live = postflightLiveSlugs();
|
|
4164
|
+
for (let index = 0; index < live.length; index += 1) {
|
|
4165
|
+
if (live[index] !== pointerSlug) return { slug: '', pointerLiveSlugs: live.length };
|
|
4166
|
+
}
|
|
4167
|
+
return { slug: pointerSlug };
|
|
4168
|
+
}
|
|
4169
|
+
|
|
3688
4170
|
function teamDbTruthy(value) {
|
|
3689
4171
|
if (typeof value !== 'string') return false;
|
|
3690
4172
|
const normalized = value.trim().toLowerCase();
|
|
@@ -3741,17 +4223,17 @@ function teamDbProject() {
|
|
|
3741
4223
|
try {
|
|
3742
4224
|
const env = process.env;
|
|
3743
4225
|
if (teamDbTruthy(env.AI_RULES_TEAM_DB_DISABLE)) return;
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
} catch (error) {
|
|
4226
|
+
const resolved = postflightResolveSlug();
|
|
4227
|
+
if (resolved.pointerLiveSlugs) {
|
|
4228
|
+
// A pointer-resolved projection under other live slugs cannot say
|
|
4229
|
+
// which task this stop belongs to. Skipping is safe: the projection
|
|
4230
|
+
// converges on the next `team-db sync`, and the files stay
|
|
4231
|
+
// authoritative.
|
|
4232
|
+
process.stderr.write(`WARNING: pointer-resolved projection skipped; ${resolved.pointerLiveSlugs} live slugs\n`);
|
|
3752
4233
|
return;
|
|
3753
4234
|
}
|
|
3754
|
-
|
|
4235
|
+
const slug = resolved.slug;
|
|
4236
|
+
if (!slug) return;
|
|
3755
4237
|
const taskDir = path.join(process.cwd(), '.ai.local', 'team', 'tasks', slug);
|
|
3756
4238
|
if (!fs.existsSync(path.join(taskDir, 'status.json'))) return;
|
|
3757
4239
|
const script = path.join(process.cwd(), '.ai.local', 'scripts', 'team-db.mjs');
|
|
@@ -3897,13 +4379,11 @@ teamDbTrackerDrain();
|
|
|
3897
4379
|
let pipeline = null;
|
|
3898
4380
|
try {
|
|
3899
4381
|
const teamRoot = path.join(process.cwd(), '.ai.local', 'team');
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
//
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
const POSTFLIGHT_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
3906
|
-
if (pipelineSlug.length <= 48 && POSTFLIGHT_SLUG_RE.test(pipelineSlug)) {
|
|
4382
|
+
// Same binding as the seams above: env slug first, projection last resort.
|
|
4383
|
+
// A pointer resolution refused by the live-scan guard is a silent policy
|
|
4384
|
+
// skip here — the ratchet is already silent-by-design for light/spike.
|
|
4385
|
+
const pipelineSlug = postflightResolveSlug().slug;
|
|
4386
|
+
if (pipelineSlug) {
|
|
3907
4387
|
pipeline = JSON.parse(fs.readFileSync(path.join(teamRoot, 'tasks', pipelineSlug, 'pipeline.json'), 'utf8'));
|
|
3908
4388
|
}
|
|
3909
4389
|
} catch {
|