@bonesofspring/ai-rules 0.2.87 → 0.2.91
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 +83 -0
- package/README.md +9 -1
- package/bin/lib/engine-scripts.js +7 -0
- package/bin/lib/seed-ai-local-team.js +40 -0
- package/bin/opencode-install.js +11 -10
- package/docs/OPENCODE-COMPATIBILITY.md +2 -1
- package/docs/OPENCODE.md +27 -5
- 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/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/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 +2 -2
- 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 +733 -9
- 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 +733 -9
- 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 +2 -2
- 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 +733 -9
- 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 +2 -2
- 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 +733 -9
- 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 +2 -2
- 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 +733 -9
- 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 +2 -2
- 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 +733 -9
- 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 +2 -2
- 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 +733 -9
- 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 +2 -2
- 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 +733 -9
- 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 +2 -2
- 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 +733 -9
- 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 +2 -2
- 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 +733 -9
- 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 +2 -2
- 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 +733 -9
- 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 +2 -2
- 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 +733 -9
- 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 +2 -2
- 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 +733 -9
- package/presets/cursor/android-kotlin/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +1 -1
- 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 +733 -9
- package/presets/cursor/go/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/go/rules/agent-team-orchestrator.mdc +1 -1
- 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 +733 -9
- package/presets/cursor/ios-swift/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +1 -1
- 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 +733 -9
- package/presets/cursor/java/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/java/rules/agent-team-orchestrator.mdc +1 -1
- 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 +733 -9
- package/presets/cursor/mcp-ts/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +1 -1
- 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 +733 -9
- package/presets/cursor/mol/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +1 -1
- 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 +733 -9
- package/presets/cursor/next/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/next/rules/agent-team-orchestrator.mdc +2 -2
- 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 +733 -9
- package/presets/cursor/nuxt/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
- 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 +733 -9
- package/presets/cursor/php-hexagonal/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +1 -1
- 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 +733 -9
- package/presets/cursor/php-laravel/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +1 -1
- 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 +733 -9
- package/presets/cursor/svelte/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/presets/mavis/svelte/rules/preset-writing-style.md +8 -0
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/hooks/README.md +6 -5
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/android-kotlin/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/android-kotlin/opencode.json +4 -4
- package/presets/opencode/android-kotlin/rules/agent-team-intake.md +2 -0
- package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/android-kotlin/rules/preset-writing-style.md +8 -0
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/hooks/README.md +6 -5
- package/presets/opencode/go/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/go/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/go/opencode.json +4 -4
- package/presets/opencode/go/rules/agent-team-intake.md +2 -0
- package/presets/opencode/go/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/go/rules/preset-writing-style.md +8 -0
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/hooks/README.md +6 -5
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/ios-swift/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/ios-swift/opencode.json +4 -4
- package/presets/opencode/ios-swift/rules/agent-team-intake.md +2 -0
- package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/ios-swift/rules/preset-writing-style.md +8 -0
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/hooks/README.md +6 -5
- package/presets/opencode/java/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/java/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/java/opencode.json +4 -4
- package/presets/opencode/java/rules/agent-team-intake.md +2 -0
- package/presets/opencode/java/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/java/rules/preset-writing-style.md +8 -0
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- package/presets/opencode/mcp-ts/hooks/README.md +6 -5
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/mcp-ts/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/mcp-ts/opencode.json +4 -4
- package/presets/opencode/mcp-ts/rules/agent-team-intake.md +2 -0
- package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/mcp-ts/rules/preset-writing-style.md +8 -0
- package/presets/opencode/mol/adapter-map.json +1 -1
- package/presets/opencode/mol/agents/feature-developer.md +1 -1
- package/presets/opencode/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/opencode/mol/commands/task-evil.md +8 -0
- package/presets/opencode/mol/hooks/README.md +6 -5
- package/presets/opencode/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/mol/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/mol/opencode.json +4 -4
- package/presets/opencode/mol/rules/agent-team-intake.md +2 -0
- package/presets/opencode/mol/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/mol/rules/preset-writing-style.md +8 -0
- package/presets/opencode/next/REPO_AGENTS.md +2 -0
- package/presets/opencode/next/adapter-map.json +1 -1
- package/presets/opencode/next/agents/feature-developer.md +1 -1
- package/presets/opencode/next/agents/task-analyst.md +1 -7
- package/presets/opencode/next/agents/task-router.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 +9 -8
- 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 +6 -5
- package/presets/opencode/next/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/next/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/next/opencode.json +4 -4
- package/presets/opencode/next/rules/agent-team-intake.md +2 -0
- package/presets/opencode/next/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/next/rules/preset-writing-style.md +8 -0
- package/presets/opencode/next/team/README.md +1 -1
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/hooks/README.md +6 -5
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/nuxt/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/nuxt/opencode.json +4 -4
- package/presets/opencode/nuxt/rules/agent-team-intake.md +2 -0
- package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/nuxt/rules/preset-writing-style.md +8 -0
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/hooks/README.md +6 -5
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/php-hexagonal/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/php-hexagonal/opencode.json +4 -4
- package/presets/opencode/php-hexagonal/rules/agent-team-intake.md +2 -0
- package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/php-hexagonal/rules/preset-writing-style.md +8 -0
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/hooks/README.md +6 -5
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/php-laravel/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/php-laravel/opencode.json +4 -4
- package/presets/opencode/php-laravel/rules/agent-team-intake.md +2 -0
- package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/php-laravel/rules/preset-writing-style.md +8 -0
- package/presets/opencode/plugins/output-guard/README.md +4 -3
- package/presets/opencode/plugins/output-guard/index.ts +4 -3
- package/presets/opencode/plugins/output-guard/rewrite.ts +1 -2
- package/presets/opencode/plugins/rule-attach/README.md +1 -1
- package/presets/opencode/plugins/rule-attach/index.ts +23 -4
- package/presets/opencode/plugins/settings-guard/README.md +28 -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 +13 -8
- package/presets/opencode/plugins/task-status/deepseek.ts +23 -8
- 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 +168 -9
- package/presets/opencode/plugins/task-status/timing.ts +244 -0
- package/presets/opencode/plugins/task-status/tui.tsx +12 -3
- package/presets/opencode/plugins/task-status/types.ts +6 -0
- package/presets/opencode/svelte/adapter-map.json +1 -1
- package/presets/opencode/svelte/hooks/README.md +6 -5
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/svelte/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/svelte/opencode.json +4 -4
- package/presets/opencode/svelte/rules/agent-team-intake.md +2 -0
- package/presets/opencode/svelte/rules/agent-team-orchestrator.md +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/presets/zcode/svelte/rules/preset-writing-style.md +8 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Per-task git worktree bound to the one main team store.
|
|
4
|
+
*
|
|
5
|
+
* node .ai.local/scripts/task-worktree.mjs create <slug>
|
|
6
|
+
* node .ai.local/scripts/task-worktree.mjs list
|
|
7
|
+
* node .ai.local/scripts/task-worktree.mjs remove <slug> [--force]
|
|
8
|
+
*
|
|
9
|
+
* `create` checks the slug, refuses a missing task, an existing
|
|
10
|
+
* `.ai.local/worktrees/<slug>` directory, or an existing `task/<slug>` branch,
|
|
11
|
+
* then runs `git worktree add` from the repo root. It copies `scripts/`,
|
|
12
|
+
* `rules/`, `conventions.md`, and `.env` read-only and best-effort symlinks
|
|
13
|
+
* `.ai.local/team` at the main store. A refused symlink warns and continues
|
|
14
|
+
* env-only. The activation line names `AI_RULES_TEAM_ROOT=<abs main team root>`.
|
|
15
|
+
* A complete pair prints that line again and exits 0. Git failures are printed
|
|
16
|
+
* verbatim and left in place (`git worktree prune` is the remedy, not this script).
|
|
17
|
+
*
|
|
18
|
+
* `remove` refuses a live slug. An unmerged branch is refused unless `--force`,
|
|
19
|
+
* which says it is deleting that branch and uses `git branch -D`. An
|
|
20
|
+
* already-removed pair exits 0.
|
|
21
|
+
*
|
|
22
|
+
* Hold the create through the process manager so two creates cannot race:
|
|
23
|
+
* node .ai.local/scripts/processes.mjs run --name worktree --task <slug> -- node .ai.local/scripts/task-worktree.mjs create <slug>
|
|
24
|
+
*
|
|
25
|
+
* Exit 1 on refusal, usage, or git failure. Exit 0 on success, including the no-ops.
|
|
26
|
+
*/
|
|
27
|
+
import { spawnSync } from 'node:child_process';
|
|
28
|
+
import fs from 'node:fs';
|
|
29
|
+
import path from 'node:path';
|
|
30
|
+
import { pathToFileURL } from 'node:url';
|
|
31
|
+
|
|
32
|
+
const invokedDirectly = () =>
|
|
33
|
+
process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href;
|
|
34
|
+
|
|
35
|
+
const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
36
|
+
const SLUG_MAX = 48;
|
|
37
|
+
const TERMINAL_STATES = new Set(['completed', 'blocked', 'changes_requested', 'validation_failed']);
|
|
38
|
+
const SEED_DIRS = ['scripts', 'rules'];
|
|
39
|
+
const SEED_FILES = ['conventions.md', '.env'];
|
|
40
|
+
const USAGE = 'usage: create <slug> | list | remove <slug> [--force]';
|
|
41
|
+
|
|
42
|
+
const fail = (message) => {
|
|
43
|
+
process.stderr.write(`task-worktree: ${message}\n`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const warn = (message) => {
|
|
48
|
+
process.stderr.write(`task-worktree: warning: ${message}\n`);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const git = (cwd, args) => spawnSync('git', args, { cwd, encoding: 'utf8' });
|
|
52
|
+
|
|
53
|
+
const failGit = (result) => {
|
|
54
|
+
const text = `${result.stderr || ''}${result.stdout || ''}`;
|
|
55
|
+
if (text !== '') process.stderr.write(text.endsWith('\n') ? text : `${text}\n`);
|
|
56
|
+
if (result.error) process.stderr.write(`${result.error.message}\n`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const repoRootOf = (cwd) => {
|
|
61
|
+
const result = git(cwd, ['rev-parse', '--show-toplevel']);
|
|
62
|
+
if (result.status !== 0) failGit(result);
|
|
63
|
+
return result.stdout.trim();
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const validSlug = (slug) =>
|
|
67
|
+
typeof slug === 'string' && slug.length > 0 && slug.length <= SLUG_MAX && SLUG_RE.test(slug);
|
|
68
|
+
|
|
69
|
+
const mainTeamRoot = (repoRoot, env) => {
|
|
70
|
+
if (env.AI_RULES_TEAM_ROOT) return path.resolve(env.AI_RULES_TEAM_ROOT);
|
|
71
|
+
if (env.AI_RULES_TEAM_DB_ROOT) return path.resolve(env.AI_RULES_TEAM_DB_ROOT);
|
|
72
|
+
return path.join(repoRoot, '.ai.local', 'team');
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const worktreeDir = (repoRoot, slug) => path.join(repoRoot, '.ai.local', 'worktrees', slug);
|
|
76
|
+
|
|
77
|
+
const branchName = (slug) => `task/${slug}`;
|
|
78
|
+
|
|
79
|
+
const branchExists = (repoRoot, slug) => {
|
|
80
|
+
const result = git(repoRoot, ['show-ref', '--verify', '--quiet', `refs/heads/${branchName(slug)}`]);
|
|
81
|
+
if (result.status === 0) return true;
|
|
82
|
+
if (result.status === 1) return false;
|
|
83
|
+
failGit(result);
|
|
84
|
+
return false;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const worktreeEntries = (repoRoot) => {
|
|
88
|
+
const result = git(repoRoot, ['worktree', 'list', '--porcelain']);
|
|
89
|
+
if (result.status !== 0) failGit(result);
|
|
90
|
+
const entries = [];
|
|
91
|
+
let current = {};
|
|
92
|
+
const flush = () => {
|
|
93
|
+
if (current.worktree) entries.push(current);
|
|
94
|
+
current = {};
|
|
95
|
+
};
|
|
96
|
+
for (const line of String(result.stdout || '').split('\n')) {
|
|
97
|
+
if (line === '') {
|
|
98
|
+
flush();
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const space = line.indexOf(' ');
|
|
102
|
+
const key = space === -1 ? line : line.slice(0, space);
|
|
103
|
+
const value = space === -1 ? '' : line.slice(space + 1);
|
|
104
|
+
if (key === 'worktree') current.worktree = value;
|
|
105
|
+
else if (key === 'branch') current.branch = value;
|
|
106
|
+
}
|
|
107
|
+
flush();
|
|
108
|
+
return entries;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const samePath = (left, right) => {
|
|
112
|
+
try {
|
|
113
|
+
return fs.realpathSync(left) === fs.realpathSync(right);
|
|
114
|
+
} catch {
|
|
115
|
+
return path.resolve(left) === path.resolve(right);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const completePair = (repoRoot, slug) => {
|
|
120
|
+
const dir = worktreeDir(repoRoot, slug);
|
|
121
|
+
if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) return false;
|
|
122
|
+
const branch = `refs/heads/${branchName(slug)}`;
|
|
123
|
+
return worktreeEntries(repoRoot).some((entry) => entry.branch === branch && samePath(entry.worktree, dir));
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const taskLiveness = (teamRoot, slug) => {
|
|
127
|
+
let status;
|
|
128
|
+
try {
|
|
129
|
+
status = JSON.parse(fs.readFileSync(path.join(teamRoot, 'tasks', slug, 'status.json'), 'utf8'));
|
|
130
|
+
} catch {
|
|
131
|
+
return { kind: 'missing', state: '' };
|
|
132
|
+
}
|
|
133
|
+
if (!status || typeof status.state !== 'string' || status.state === '') return { kind: 'missing', state: '' };
|
|
134
|
+
return {
|
|
135
|
+
kind: TERMINAL_STATES.has(status.state) ? 'terminal' : 'live',
|
|
136
|
+
state: status.state,
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const resolvedStore = (dir, env) => {
|
|
141
|
+
if (env.AI_RULES_TEAM_ROOT) return path.resolve(env.AI_RULES_TEAM_ROOT);
|
|
142
|
+
if (env.AI_RULES_TEAM_DB_ROOT) return path.resolve(env.AI_RULES_TEAM_DB_ROOT);
|
|
143
|
+
const local = path.join(dir, '.ai.local', 'team');
|
|
144
|
+
try {
|
|
145
|
+
return fs.realpathSync(local);
|
|
146
|
+
} catch {
|
|
147
|
+
return local;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const printActivation = (repoRoot, slug, teamRoot) => {
|
|
152
|
+
const dir = worktreeDir(repoRoot, slug);
|
|
153
|
+
process.stdout.write(`AI_RULES_TEAM_ROOT=${teamRoot}\n`);
|
|
154
|
+
process.stdout.write(`worktree=${dir} branch=${branchName(slug)}\n`);
|
|
155
|
+
process.stdout.write(
|
|
156
|
+
`hook: cd ${dir} && TEAM_TASK_SLUG=${slug} AI_RULES_TEAM_ROOT=${teamRoot} bash .cursor/hooks/chain-team-phases.sh\n`,
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const chmodTree = (target, writable) => {
|
|
161
|
+
let stat;
|
|
162
|
+
try {
|
|
163
|
+
stat = fs.lstatSync(target);
|
|
164
|
+
} catch {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (stat.isSymbolicLink()) return;
|
|
168
|
+
fs.chmodSync(target, stat.isDirectory() ? (writable ? 0o755 : 0o555) : writable ? 0o644 : 0o444);
|
|
169
|
+
if (!stat.isDirectory()) return;
|
|
170
|
+
for (const name of fs.readdirSync(target)) chmodTree(path.join(target, name), writable);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const copyReadOnly = (source, dest) => {
|
|
174
|
+
const stat = fs.lstatSync(source);
|
|
175
|
+
if (stat.isSymbolicLink()) {
|
|
176
|
+
warn(`skipped symlink seed ${source}`);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (stat.isDirectory()) {
|
|
180
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
181
|
+
for (const name of fs.readdirSync(source)) copyReadOnly(path.join(source, name), path.join(dest, name));
|
|
182
|
+
fs.chmodSync(dest, 0o555);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
186
|
+
fs.copyFileSync(source, dest);
|
|
187
|
+
fs.chmodSync(dest, 0o444);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const seedOverlay = (repoRoot, dir, teamRoot) => {
|
|
191
|
+
const sourceRoot = path.join(repoRoot, '.ai.local');
|
|
192
|
+
const destRoot = path.join(dir, '.ai.local');
|
|
193
|
+
fs.mkdirSync(destRoot, { recursive: true });
|
|
194
|
+
for (const name of [...SEED_DIRS, ...SEED_FILES]) {
|
|
195
|
+
const source = path.join(sourceRoot, name);
|
|
196
|
+
if (!fs.existsSync(source)) {
|
|
197
|
+
warn(`missing ${source}; skipped`);
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
copyReadOnly(source, path.join(destRoot, name));
|
|
201
|
+
}
|
|
202
|
+
const link = path.join(destRoot, 'team');
|
|
203
|
+
try {
|
|
204
|
+
fs.symlinkSync(teamRoot, link, 'dir');
|
|
205
|
+
} catch (error) {
|
|
206
|
+
warn(`team symlink refused (${error.code || error.message}); degrading to env-only`);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
const listedPaths = (worktree, args) => {
|
|
211
|
+
const result = git(worktree, args);
|
|
212
|
+
if (result.status !== 0) return [];
|
|
213
|
+
return String(result.stdout || '')
|
|
214
|
+
.split('\n')
|
|
215
|
+
.map((line) => line.trim())
|
|
216
|
+
.filter(Boolean);
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
const clearOneSeed = (worktree, rel) => {
|
|
220
|
+
const abs = path.join(worktree, rel);
|
|
221
|
+
let stat;
|
|
222
|
+
try {
|
|
223
|
+
stat = fs.lstatSync(abs);
|
|
224
|
+
} catch {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (stat.isSymbolicLink()) {
|
|
228
|
+
fs.unlinkSync(abs);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
chmodTree(abs, true);
|
|
232
|
+
const tracked = listedPaths(worktree, ['ls-files', '--', rel]);
|
|
233
|
+
if (tracked.length === 0) {
|
|
234
|
+
fs.rmSync(abs, { recursive: true, force: true });
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
const restored = git(worktree, ['checkout', '--', rel]);
|
|
238
|
+
if (restored.status !== 0) failGit(restored);
|
|
239
|
+
for (const extra of listedPaths(worktree, ['ls-files', '--others', '--exclude-standard', '--', rel])) {
|
|
240
|
+
fs.rmSync(path.join(worktree, extra), { recursive: true, force: true });
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const clearSeeds = (dir) => {
|
|
245
|
+
const inside = git(dir, ['rev-parse', '--is-inside-work-tree']);
|
|
246
|
+
if (inside.status !== 0) return;
|
|
247
|
+
const link = path.join(dir, '.ai.local', 'team');
|
|
248
|
+
try {
|
|
249
|
+
if (fs.lstatSync(link).isSymbolicLink()) fs.unlinkSync(link);
|
|
250
|
+
} catch {
|
|
251
|
+
// No seed link. A real team directory is not a seed and is left alone.
|
|
252
|
+
}
|
|
253
|
+
for (const name of [...SEED_DIRS, ...SEED_FILES]) clearOneSeed(dir, path.join('.ai.local', name));
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const branchMerged = (repoRoot, slug) => {
|
|
257
|
+
const result = git(repoRoot, ['merge-base', '--is-ancestor', branchName(slug), 'HEAD']);
|
|
258
|
+
if (result.status === 0) return true;
|
|
259
|
+
if (result.status === 1) return false;
|
|
260
|
+
failGit(result);
|
|
261
|
+
return false;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
const requireTask = (teamRoot, slug) => {
|
|
265
|
+
const statusFile = path.join(teamRoot, 'tasks', slug, 'status.json');
|
|
266
|
+
if (!fs.existsSync(statusFile)) fail(`missing task ${slug}: ${statusFile} does not exist`);
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const create = (repoRoot, slug, env) => {
|
|
270
|
+
const teamRoot = mainTeamRoot(repoRoot, env);
|
|
271
|
+
requireTask(teamRoot, slug);
|
|
272
|
+
if (completePair(repoRoot, slug)) {
|
|
273
|
+
process.stdout.write(`task-worktree: ${slug} already exists\n`);
|
|
274
|
+
printActivation(repoRoot, slug, teamRoot);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const dir = worktreeDir(repoRoot, slug);
|
|
278
|
+
if (fs.existsSync(dir)) fail(`worktree directory already exists: ${dir}`);
|
|
279
|
+
if (branchExists(repoRoot, slug)) fail(`branch already exists: ${branchName(slug)}`);
|
|
280
|
+
const added = git(repoRoot, ['worktree', 'add', '-b', branchName(slug), '--', path.relative(repoRoot, dir)]);
|
|
281
|
+
if (added.status !== 0) failGit(added);
|
|
282
|
+
try {
|
|
283
|
+
seedOverlay(repoRoot, dir, teamRoot);
|
|
284
|
+
} catch (error) {
|
|
285
|
+
process.stderr.write(`task-worktree: seed failed (${error.message}); left for git worktree prune\n`);
|
|
286
|
+
process.exit(1);
|
|
287
|
+
}
|
|
288
|
+
printActivation(repoRoot, slug, teamRoot);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
const list = (repoRoot, env) => {
|
|
292
|
+
const teamRoot = mainTeamRoot(repoRoot, env);
|
|
293
|
+
const root = path.join(repoRoot, '.ai.local', 'worktrees');
|
|
294
|
+
let names = [];
|
|
295
|
+
try {
|
|
296
|
+
names = fs
|
|
297
|
+
.readdirSync(root, { withFileTypes: true })
|
|
298
|
+
.filter((entry) => entry.isDirectory() && validSlug(entry.name))
|
|
299
|
+
.map((entry) => entry.name)
|
|
300
|
+
.sort();
|
|
301
|
+
} catch {
|
|
302
|
+
names = [];
|
|
303
|
+
}
|
|
304
|
+
for (const slug of names) {
|
|
305
|
+
const dir = worktreeDir(repoRoot, slug);
|
|
306
|
+
const branch = branchExists(repoRoot, slug) ? branchName(slug) : 'missing';
|
|
307
|
+
const liveness = taskLiveness(teamRoot, slug);
|
|
308
|
+
process.stdout.write(
|
|
309
|
+
`slug=${slug} branch=${branch} path=${dir} state=${liveness.kind} store=${resolvedStore(dir, env)}\n`,
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
const remove = (repoRoot, slug, force, env) => {
|
|
315
|
+
const teamRoot = mainTeamRoot(repoRoot, env);
|
|
316
|
+
const dir = worktreeDir(repoRoot, slug);
|
|
317
|
+
const dirExists = fs.existsSync(dir);
|
|
318
|
+
const hasBranch = branchExists(repoRoot, slug);
|
|
319
|
+
if (!dirExists && !hasBranch) {
|
|
320
|
+
process.stdout.write(`task-worktree: ${slug} already removed\n`);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const liveness = taskLiveness(teamRoot, slug);
|
|
324
|
+
if (liveness.kind === 'live') fail(`refuse: slug ${slug} is live (${liveness.state})`);
|
|
325
|
+
const unmerged = hasBranch && !branchMerged(repoRoot, slug);
|
|
326
|
+
if (unmerged && !force) fail(`refuse: branch ${branchName(slug)} is unmerged; pass --force to delete it`);
|
|
327
|
+
if (unmerged && force) {
|
|
328
|
+
process.stdout.write(`task-worktree: --force: deleting unmerged branch ${branchName(slug)}\n`);
|
|
329
|
+
}
|
|
330
|
+
if (dirExists) {
|
|
331
|
+
clearSeeds(dir);
|
|
332
|
+
const removed = git(repoRoot, ['worktree', 'remove', dir]);
|
|
333
|
+
if (removed.status !== 0) failGit(removed);
|
|
334
|
+
}
|
|
335
|
+
if (hasBranch) {
|
|
336
|
+
const deleted = git(repoRoot, ['branch', unmerged ? '-D' : '-d', branchName(slug)]);
|
|
337
|
+
if (deleted.status !== 0) failGit(deleted);
|
|
338
|
+
}
|
|
339
|
+
process.stdout.write(`task-worktree: removed ${slug}\n`);
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
const parseArgs = (argv) => {
|
|
343
|
+
const force = argv.includes('--force');
|
|
344
|
+
const positionals = argv.filter((arg) => arg !== '--force');
|
|
345
|
+
return { command: positionals[0], slug: positionals[1], extra: positionals[2], force };
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
const main = () => {
|
|
349
|
+
const { command, slug, extra, force } = parseArgs(process.argv.slice(2));
|
|
350
|
+
if (!command || extra !== undefined) fail(USAGE);
|
|
351
|
+
if (force && command !== 'remove') fail(USAGE);
|
|
352
|
+
if (command === 'list') {
|
|
353
|
+
if (slug !== undefined) fail(USAGE);
|
|
354
|
+
list(repoRootOf(process.cwd()), process.env);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
if (command !== 'create' && command !== 'remove') fail(USAGE);
|
|
358
|
+
if (!validSlug(slug)) fail(`invalid slug "${slug ?? ''}"`);
|
|
359
|
+
const repoRoot = repoRootOf(process.cwd());
|
|
360
|
+
if (command === 'create') create(repoRoot, slug, process.env);
|
|
361
|
+
else remove(repoRoot, slug, force, process.env);
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
if (invokedDirectly()) main();
|
|
@@ -3751,7 +3751,7 @@ export const OPENAPI_DOCUMENT = {
|
|
|
3751
3751
|
tags: ['tasks'],
|
|
3752
3752
|
summary: 'Delete one task: the task folder first, then its projection rows',
|
|
3753
3753
|
description:
|
|
3754
|
-
'Confirmed, destructive and irreversible. The task folder `.ai.local/team/tasks/{slug}` is removed before the database rows, so a crash between the two legs converges toward deleted on the next rescan and never resurrects content. The row delete is one transaction: the task row plus every child row by cascade, plus the task\'s search rows.
|
|
3754
|
+
'Confirmed, destructive and irreversible. The task folder `.ai.local/team/tasks/{slug}` is removed before the database rows, so a crash between the two legs converges toward deleted on the next rescan and never resurrects content. The row delete is one transaction: the task row plus every child row by cascade, plus the task\'s search rows. A slug whose own `status.json` state is live (not one of the terminal states) is refused with 409 `E_ACTIVE_TASK` — the guard reads the requested slug\'s status, never the `active-task.json` pointer. An unknown slug answers 404 `E_NOT_FOUND` and touches nothing. The request body is ignored and no query parameters are declared. Executed as a bounded child process; `AI_RULES_TEAM_DB_DISABLE=1` answers 503 `E_DISABLED` before anything runs.',
|
|
3755
3755
|
operationId: 'deleteTask',
|
|
3756
3756
|
parameters: [slugParameter],
|
|
3757
3757
|
responses: {
|
|
@@ -3760,7 +3760,7 @@ export const OPENAPI_DOCUMENT = {
|
|
|
3760
3760
|
403: errorResponse('A non-loopback Host or Origin was rejected before routing'),
|
|
3761
3761
|
404: errorResponse('The task does not exist in the projection or on disk'),
|
|
3762
3762
|
405: methodNotAllowedResponse,
|
|
3763
|
-
409: errorResponse('The slug is
|
|
3763
|
+
409: errorResponse('The slug is live (its own `status.json` state is not terminal); the delete is refused with `details.activeSlug` naming it'),
|
|
3764
3764
|
503: errorResponse('The projection is disabled, the database is missing, unusable, busy, or the child exceeded its time bound'),
|
|
3765
3765
|
},
|
|
3766
3766
|
}),
|
|
@@ -747,6 +747,70 @@ export function listTaskDirectories(teamRoot) {
|
|
|
747
747
|
.sort();
|
|
748
748
|
}
|
|
749
749
|
|
|
750
|
+
/**
|
|
751
|
+
* Terminal `status.json` states — the exact set the hook and autoroute
|
|
752
|
+
* templates pin (`prompt-autoroute.mjs.tmpl`, `chain-team-phases.sh.tmpl`).
|
|
753
|
+
* A slug whose state is in this set is closed and is not live.
|
|
754
|
+
*/
|
|
755
|
+
export const TERMINAL_STATES = new Set(['completed', 'blocked', 'changes_requested', 'validation_failed']);
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* The live slugs in the team root: every task directory whose `status.json`
|
|
759
|
+
* parses to a non-terminal `state`. This is the canonical live-slug predicate
|
|
760
|
+
* — computed from the task store, never from `active-task.json`. A missing or
|
|
761
|
+
* unreadable status is not a live slug.
|
|
762
|
+
*
|
|
763
|
+
* @param {string} teamRoot
|
|
764
|
+
* @returns {string[]} sorted live slugs
|
|
765
|
+
*/
|
|
766
|
+
export function liveTaskSlugs(teamRoot) {
|
|
767
|
+
const live = [];
|
|
768
|
+
for (const slug of listTaskDirectories(teamRoot)) {
|
|
769
|
+
try {
|
|
770
|
+
const status = parseStatusJson(readTextFile(path.join(teamRoot, 'tasks', slug, KNOWN_FILES.status)));
|
|
771
|
+
const state = status && typeof status.state === 'string' ? status.state : null;
|
|
772
|
+
if (state !== null && !TERMINAL_STATES.has(state)) live.push(slug);
|
|
773
|
+
} catch {
|
|
774
|
+
/* an unreadable status is not a live slug */
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
return live;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Rebuild `active-task.json` as the UI projection of the live slugs:
|
|
782
|
+
* `{"schemaVersion":1,"slugs":[...],"updatedAt"}` — sorted, deduped, live
|
|
783
|
+
* slugs only; an empty array means "no pointer" for every reader. `team-db
|
|
784
|
+
* sync` (both faces) and `delete` are the only writers, so the projection
|
|
785
|
+
* self-heals on every projection run; readers accept the legacy single-slot
|
|
786
|
+
* `{"slug"}` shape forever. Atomic tmp + rename, best-effort: a failure is a
|
|
787
|
+
* logged finding, never a failed sync or delete.
|
|
788
|
+
*
|
|
789
|
+
* @param {string} teamRoot
|
|
790
|
+
* @param {{ env?: Record<string, string | undefined> }} [options]
|
|
791
|
+
* @returns {boolean} whether the file was (re)written
|
|
792
|
+
*/
|
|
793
|
+
export function rebuildActiveTaskPointer(teamRoot, options = {}) {
|
|
794
|
+
try {
|
|
795
|
+
const slugs = liveTaskSlugs(teamRoot);
|
|
796
|
+
const file = path.join(teamRoot, 'active-task.json');
|
|
797
|
+
const content = `${JSON.stringify({ schemaVersion: 1, slugs, updatedAt: new Date().toISOString() })}\n`;
|
|
798
|
+
try {
|
|
799
|
+
if (fs.readFileSync(file, 'utf8') === content) return false;
|
|
800
|
+
} catch {
|
|
801
|
+
/* absent or unreadable: write it */
|
|
802
|
+
}
|
|
803
|
+
fs.mkdirSync(teamRoot, { recursive: true });
|
|
804
|
+
const temporary = `${file}.tmp`;
|
|
805
|
+
fs.writeFileSync(temporary, content, { encoding: 'utf8', mode: 0o600 });
|
|
806
|
+
fs.renameSync(temporary, file);
|
|
807
|
+
return true;
|
|
808
|
+
} catch (error) {
|
|
809
|
+
logProjectionFailure('E_POINTER_REBUILD', error.message, options.env);
|
|
810
|
+
return false;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
|
|
750
814
|
const hashFile = (absolute) => {
|
|
751
815
|
const hash = crypto.createHash('sha256');
|
|
752
816
|
const fd = fs.openSync(absolute, 'r');
|
|
@@ -4963,6 +5027,10 @@ export function syncProjection(options = {}) {
|
|
|
4963
5027
|
result.error = result.errors[0] ? `${result.errors[0].path}: ${result.errors[0].reason}` : null;
|
|
4964
5028
|
updateRun(db, runId, result);
|
|
4965
5029
|
chmodDatabaseFiles(handle.dbPath);
|
|
5030
|
+
// The active-task pointer is a UI projection: rebuild it on every sync
|
|
5031
|
+
// face (slug and full) so it self-heals. Best-effort — a rebuild failure
|
|
5032
|
+
// is a logged finding, never a failed sync.
|
|
5033
|
+
rebuildActiveTaskPointer(handle.teamRoot, { env: options.env });
|
|
4966
5034
|
return result;
|
|
4967
5035
|
} catch (error) {
|
|
4968
5036
|
result.exitCode = error instanceof TeamDbError ? error.exitCode : 2;
|
|
@@ -4988,16 +5056,17 @@ export function syncProjection(options = {}) {
|
|
|
4988
5056
|
* The two legs converge prior partial states: a folder without rows loses
|
|
4989
5057
|
* only the folder; rows without a folder lose only the rows. The row leg is
|
|
4990
5058
|
* one transaction — the task row plus every child row by foreign-key cascade,
|
|
4991
|
-
* plus the task's standalone search rows. The
|
|
5059
|
+
* plus the task's standalone search rows. The live-status guard and the slug
|
|
4992
5060
|
* confinement run before any leg, and a symlink at `tasks/<slug>` is refused,
|
|
4993
5061
|
* never followed or removed.
|
|
4994
5062
|
*
|
|
4995
5063
|
* Returns the one-line result the CLI prints and the API child parses:
|
|
4996
5064
|
* `{ ok: true, slug, folderRemoved, rowsDeleted }`. Throws `TeamDbError`:
|
|
4997
5065
|
* `E_DISABLED` (kill switch, exit 1), `E_USAGE` (bad slug, exit 3),
|
|
4998
|
-
* `E_NOT_FOUND` (nothing to delete, exit 1), `E_ACTIVE_TASK` (the
|
|
4999
|
-
* exit 1), `E_INTERNAL` (the folder leg
|
|
5000
|
-
* database-level `E_DB_BUSY` (exit 4) /
|
|
5066
|
+
* `E_NOT_FOUND` (nothing to delete, exit 1), `E_ACTIVE_TASK` (the requested
|
|
5067
|
+
* slug's own `status.json` is live, exit 1), `E_INTERNAL` (the folder leg
|
|
5068
|
+
* failed, exit 1), and the database-level `E_DB_BUSY` (exit 4) /
|
|
5069
|
+
* `E_DB_CORRUPT` (exit 2).
|
|
5001
5070
|
*/
|
|
5002
5071
|
export function deleteTaskProjection(options = {}) {
|
|
5003
5072
|
const slug = typeof options.slug === 'string' ? options.slug : '';
|
|
@@ -5011,21 +5080,22 @@ export function deleteTaskProjection(options = {}) {
|
|
|
5011
5080
|
const tasksRoot = path.join(teamRoot, 'tasks');
|
|
5012
5081
|
const taskDir = path.join(tasksRoot, slug);
|
|
5013
5082
|
|
|
5014
|
-
// The guard reads the
|
|
5015
|
-
//
|
|
5016
|
-
//
|
|
5017
|
-
//
|
|
5018
|
-
|
|
5083
|
+
// The guard reads the requested slug's own `status.json` — not the pointer,
|
|
5084
|
+
// not the database — and runs before any leg. The parse stays inside the
|
|
5085
|
+
// try; the refusal lives outside it, so a live-state refusal is never
|
|
5086
|
+
// mistaken for an unreadable status. A missing or unreadable status does
|
|
5087
|
+
// not block the delete.
|
|
5088
|
+
let liveState = null;
|
|
5019
5089
|
try {
|
|
5020
|
-
const
|
|
5021
|
-
|
|
5090
|
+
const status = parseStatusJson(readTextFile(path.join(taskDir, KNOWN_FILES.status)));
|
|
5091
|
+
liveState = typeof status.state === 'string' ? status.state : null;
|
|
5022
5092
|
} catch {
|
|
5023
|
-
|
|
5093
|
+
liveState = null;
|
|
5024
5094
|
}
|
|
5025
|
-
if (
|
|
5095
|
+
if (liveState !== null && !TERMINAL_STATES.has(liveState)) {
|
|
5026
5096
|
teamDbFail(
|
|
5027
5097
|
'E_ACTIVE_TASK',
|
|
5028
|
-
`${slug} is
|
|
5098
|
+
`${slug} is live (state ${liveState}); deletion is blocked until the task reaches a terminal state`,
|
|
5029
5099
|
1,
|
|
5030
5100
|
);
|
|
5031
5101
|
}
|
|
@@ -5108,6 +5178,9 @@ export function deleteTaskProjection(options = {}) {
|
|
|
5108
5178
|
}
|
|
5109
5179
|
|
|
5110
5180
|
chmodDatabaseFiles(handle.dbPath);
|
|
5181
|
+
// The deleted slug leaves the UI projection on this delete; best-effort,
|
|
5182
|
+
// like every pointer rebuild.
|
|
5183
|
+
rebuildActiveTaskPointer(teamRoot, { env: options.env });
|
|
5111
5184
|
return { ok: true, slug, folderRemoved: dirState === 'present', rowsDeleted };
|
|
5112
5185
|
} finally {
|
|
5113
5186
|
try {
|