@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
|
@@ -9,127 +9,871 @@ const SERVER_COMMAND = new RegExp("bootRun|spring-boot:run");
|
|
|
9
9
|
const SERVER_PORTS = [8080];
|
|
10
10
|
import fs from 'node:fs';
|
|
11
11
|
import net from 'node:net';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
12
14
|
|
|
13
|
-
const
|
|
15
|
+
const allowed = () => ({ permission: 'allow' });
|
|
14
16
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const ask = (userMessage, agentMessage) => ({
|
|
18
|
+
permission: 'ask',
|
|
19
|
+
user_message: userMessage,
|
|
20
|
+
agent_message: agentMessage || userMessage,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const portIsOpen = (port) =>
|
|
24
|
+
new Promise((resolve) => {
|
|
25
|
+
const socket = net.createConnection({ host: '127.0.0.1', port });
|
|
26
|
+
const done = (open) => {
|
|
27
|
+
socket.destroy();
|
|
28
|
+
resolve(open);
|
|
29
|
+
};
|
|
30
|
+
socket.once('connect', () => done(true));
|
|
31
|
+
socket.once('error', () => done(false));
|
|
32
|
+
socket.setTimeout(400, () => done(false));
|
|
33
|
+
});
|
|
19
34
|
|
|
20
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Default settings resolver: a dynamic import of the seeded parser under the
|
|
37
|
+
* project root. A missing, unreadable or unimportable module yields `null`, so
|
|
38
|
+
* the guard answers without a parser instead of carrying a copy of one.
|
|
39
|
+
*
|
|
40
|
+
* @returns {Promise<((key: string) => boolean) | null>} `get(key)`, or `null`
|
|
41
|
+
*/
|
|
42
|
+
const importSettings = async ({ root, exists, readText }) => {
|
|
43
|
+
const file = path.join(root, '.ai.local', 'scripts', 'settings.mjs');
|
|
44
|
+
if (!exists(file)) return null;
|
|
21
45
|
try {
|
|
22
|
-
const
|
|
23
|
-
|
|
46
|
+
const module = await import(pathToFileURL(file).href);
|
|
47
|
+
if (typeof module.readSetting !== 'function') return null;
|
|
48
|
+
return (key) => module.readSetting(key, { root, exists, readText }).value === true;
|
|
24
49
|
} catch {
|
|
25
50
|
return null;
|
|
26
51
|
}
|
|
27
52
|
};
|
|
28
53
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
54
|
+
/**
|
|
55
|
+
* `git` global options that take the next token as their value. Every other
|
|
56
|
+
* option is skipped as a flag, so an undocumented flag cannot hide the
|
|
57
|
+
* subcommand; an undocumented value-taking option surfaces as an unresolved
|
|
58
|
+
* subcommand and is asked, never allowed.
|
|
59
|
+
*/
|
|
60
|
+
const GIT_VALUE_GLOBALS = new Set([
|
|
61
|
+
'-c',
|
|
62
|
+
'-C',
|
|
63
|
+
'--git-dir',
|
|
64
|
+
'--work-tree',
|
|
65
|
+
'--namespace',
|
|
66
|
+
'--config-env',
|
|
67
|
+
'--super-prefix',
|
|
68
|
+
'--exec-path',
|
|
69
|
+
]);
|
|
33
70
|
|
|
34
|
-
|
|
35
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Join backslash line continuations, then split on shell separators outside
|
|
73
|
+
* quotes. Command substitution is split too, so `$(git push --force)` is a
|
|
74
|
+
* segment the classifier sees rather than an opaque token.
|
|
75
|
+
*/
|
|
76
|
+
const splitShellSegments = (command) => {
|
|
77
|
+
const text = String(command).replace(/\\\r?\n/g, '');
|
|
78
|
+
const segments = [];
|
|
79
|
+
let current = '';
|
|
80
|
+
let quote = null;
|
|
81
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
82
|
+
const char = text[index];
|
|
83
|
+
if (quote !== null) {
|
|
84
|
+
current += char;
|
|
85
|
+
if (char === '\\' && quote === '"' && index + 1 < text.length) {
|
|
86
|
+
index += 1;
|
|
87
|
+
current += text[index];
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (char === quote) quote = null;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (char === "'" || char === '"') {
|
|
94
|
+
quote = char;
|
|
95
|
+
current += char;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (
|
|
99
|
+
char === ';' ||
|
|
100
|
+
char === '\n' ||
|
|
101
|
+
char === '\r' ||
|
|
102
|
+
char === '|' ||
|
|
103
|
+
char === '&' ||
|
|
104
|
+
char === '(' ||
|
|
105
|
+
char === ')' ||
|
|
106
|
+
char === '`'
|
|
107
|
+
) {
|
|
108
|
+
if ((char === '|' || char === '&') && text[index + 1] === char) index += 1;
|
|
109
|
+
segments.push(current);
|
|
110
|
+
current = '';
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
current += char;
|
|
114
|
+
}
|
|
115
|
+
segments.push(current);
|
|
116
|
+
return segments.filter((segment) => segment.trim() !== '');
|
|
117
|
+
};
|
|
36
118
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
hookSpecificOutput.permissionDecisionReason = userMessage;
|
|
119
|
+
/** Decode the escapes of a `$'…'` ANSI-C quoted span. */
|
|
120
|
+
const decodeAnsiC = (text) => {
|
|
121
|
+
let output = '';
|
|
122
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
123
|
+
const char = text[index];
|
|
124
|
+
if (char !== '\\') {
|
|
125
|
+
output += char;
|
|
126
|
+
continue;
|
|
46
127
|
}
|
|
47
|
-
|
|
128
|
+
const next = text[index + 1];
|
|
129
|
+
if (next === undefined) {
|
|
130
|
+
output += '\\';
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
index += 1;
|
|
134
|
+
if (next === 'n') output += '\n';
|
|
135
|
+
else if (next === 'r') output += '\r';
|
|
136
|
+
else if (next === 't') output += '\t';
|
|
137
|
+
else if (next === '\\' || next === "'" || next === '"' || next === '?') output += next;
|
|
138
|
+
else if (next === 'x') {
|
|
139
|
+
const hex = text.slice(index + 1, index + 3);
|
|
140
|
+
if (/^[0-9a-fA-F]{2}$/.test(hex)) {
|
|
141
|
+
output += String.fromCharCode(parseInt(hex, 16));
|
|
142
|
+
index += 2;
|
|
143
|
+
} else output += '\\x';
|
|
144
|
+
} else if (next === 'u') {
|
|
145
|
+
const hex = text.slice(index + 1, index + 5);
|
|
146
|
+
if (/^[0-9a-fA-F]{4}$/.test(hex)) {
|
|
147
|
+
output += String.fromCharCode(parseInt(hex, 16));
|
|
148
|
+
index += 4;
|
|
149
|
+
} else output += '\\u';
|
|
150
|
+
} else if (/[0-7]/.test(next)) {
|
|
151
|
+
const octal = text.slice(index, index + 3).match(/^[0-7]{1,3}/)?.[0] ?? next;
|
|
152
|
+
output += String.fromCharCode(parseInt(octal, 8));
|
|
153
|
+
index += octal.length - 1;
|
|
154
|
+
} else output += next;
|
|
48
155
|
}
|
|
49
|
-
|
|
50
|
-
permission,
|
|
51
|
-
user_message: userMessage,
|
|
52
|
-
agent_message: agentMessage || userMessage,
|
|
53
|
-
});
|
|
156
|
+
return output;
|
|
54
157
|
};
|
|
55
158
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
159
|
+
/**
|
|
160
|
+
* Shell-word tokenizer: quotes and escapes concatenate into the token value,
|
|
161
|
+
* and `quoted` records that the token carried quoting. A quoted `git`/`push`/
|
|
162
|
+
* `--force` is therefore as visible as an unquoted one; an unterminated quote
|
|
163
|
+
* is reported so the caller asks.
|
|
164
|
+
*/
|
|
165
|
+
const tokenizeSegment = (segment) => {
|
|
166
|
+
const tokens = [];
|
|
167
|
+
let value = '';
|
|
168
|
+
let quoted = false;
|
|
169
|
+
let started = false;
|
|
170
|
+
let quote = null;
|
|
171
|
+
let unterminated = false;
|
|
172
|
+
let index = 0;
|
|
173
|
+
const push = () => {
|
|
174
|
+
if (started) tokens.push({ value, quoted });
|
|
175
|
+
value = '';
|
|
176
|
+
quoted = false;
|
|
177
|
+
started = false;
|
|
178
|
+
};
|
|
179
|
+
while (index < segment.length) {
|
|
180
|
+
const char = segment[index];
|
|
181
|
+
if (quote === null && /\s/.test(char)) {
|
|
182
|
+
push();
|
|
183
|
+
index += 1;
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (quote === "'") {
|
|
187
|
+
if (char === "'") {
|
|
188
|
+
quote = null;
|
|
189
|
+
index += 1;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
value += char;
|
|
193
|
+
started = true;
|
|
194
|
+
index += 1;
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (quote === '"') {
|
|
198
|
+
if (char === '"') {
|
|
199
|
+
quote = null;
|
|
200
|
+
index += 1;
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (char === '\\' && index + 1 < segment.length) {
|
|
204
|
+
const next = segment[index + 1];
|
|
205
|
+
if ('"\\$`\n'.includes(next)) {
|
|
206
|
+
if (next !== '\n') value += next;
|
|
207
|
+
index += 2;
|
|
208
|
+
started = true;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
value += char;
|
|
213
|
+
started = true;
|
|
214
|
+
index += 1;
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (quote === 'ansi') {
|
|
218
|
+
let raw = '';
|
|
219
|
+
let cursor = index;
|
|
220
|
+
while (cursor < segment.length) {
|
|
221
|
+
if (segment[cursor] === '\\' && cursor + 1 < segment.length) {
|
|
222
|
+
raw += segment[cursor] + segment[cursor + 1];
|
|
223
|
+
cursor += 2;
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if (segment[cursor] === "'") break;
|
|
227
|
+
raw += segment[cursor];
|
|
228
|
+
cursor += 1;
|
|
229
|
+
}
|
|
230
|
+
value += decodeAnsiC(raw);
|
|
231
|
+
started = true;
|
|
232
|
+
if (cursor < segment.length && segment[cursor] === "'") {
|
|
233
|
+
quote = null;
|
|
234
|
+
cursor += 1;
|
|
235
|
+
} else {
|
|
236
|
+
unterminated = true;
|
|
237
|
+
quote = null;
|
|
238
|
+
}
|
|
239
|
+
index = cursor;
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (char === "'") {
|
|
243
|
+
quote = "'";
|
|
244
|
+
quoted = true;
|
|
245
|
+
started = true;
|
|
246
|
+
index += 1;
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (char === '"') {
|
|
250
|
+
quote = '"';
|
|
251
|
+
quoted = true;
|
|
252
|
+
started = true;
|
|
253
|
+
index += 1;
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
if (char === '$' && segment[index + 1] === "'") {
|
|
257
|
+
quote = 'ansi';
|
|
258
|
+
quoted = true;
|
|
259
|
+
started = true;
|
|
260
|
+
index += 2;
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (char === '\\' && index + 1 < segment.length) {
|
|
264
|
+
value += segment[index + 1];
|
|
265
|
+
quoted = true;
|
|
266
|
+
started = true;
|
|
267
|
+
index += 2;
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
value += char;
|
|
271
|
+
started = true;
|
|
272
|
+
index += 1;
|
|
273
|
+
}
|
|
274
|
+
push();
|
|
275
|
+
return { tokens, unterminated: unterminated || quote !== null };
|
|
276
|
+
};
|
|
59
277
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
278
|
+
/**
|
|
279
|
+
* Benign option allowlist per git verb. Anything not on the list — including
|
|
280
|
+
* every abbreviation git would resolve — asks. `--amend` is deliberately absent
|
|
281
|
+
* (it rewrites a commit), so `commit --amend` asks.
|
|
282
|
+
*/
|
|
283
|
+
const OPTION_SPECS = {
|
|
284
|
+
push: {
|
|
285
|
+
long: new Set([
|
|
286
|
+
'--set-upstream',
|
|
287
|
+
'--follow-tags',
|
|
288
|
+
'--dry-run',
|
|
289
|
+
'--no-verify',
|
|
290
|
+
'--porcelain',
|
|
291
|
+
'--progress',
|
|
292
|
+
'--no-progress',
|
|
293
|
+
'--quiet',
|
|
294
|
+
'--verbose',
|
|
295
|
+
'--atomic',
|
|
296
|
+
'--no-atomic',
|
|
297
|
+
'--thin',
|
|
298
|
+
'--no-thin',
|
|
299
|
+
'--ipv4',
|
|
300
|
+
'--ipv6',
|
|
301
|
+
'--signed',
|
|
302
|
+
'--no-signed',
|
|
303
|
+
'--recurse-submodules',
|
|
304
|
+
'--no-recurse-submodules',
|
|
305
|
+
]),
|
|
306
|
+
longValue: new Set([
|
|
307
|
+
'--repo',
|
|
308
|
+
'--push-option',
|
|
309
|
+
'--recurse-submodules',
|
|
310
|
+
]),
|
|
311
|
+
short: new Set(['u', 'v', 'q', 'n', '4', '6']),
|
|
312
|
+
shortValue: new Set(['o']),
|
|
313
|
+
},
|
|
314
|
+
commit: {
|
|
315
|
+
long: new Set([
|
|
316
|
+
'--message',
|
|
317
|
+
'--file',
|
|
318
|
+
'--author',
|
|
319
|
+
'--date',
|
|
320
|
+
'--signoff',
|
|
321
|
+
'--quiet',
|
|
322
|
+
'--verbose',
|
|
323
|
+
'--dry-run',
|
|
324
|
+
'--no-verify',
|
|
325
|
+
'--allow-empty',
|
|
326
|
+
'--allow-empty-message',
|
|
327
|
+
'--fixup',
|
|
328
|
+
'--squash',
|
|
329
|
+
'--reset-author',
|
|
330
|
+
'--include',
|
|
331
|
+
'--only',
|
|
332
|
+
'--pathspec-file-nul',
|
|
333
|
+
'--cleanup',
|
|
334
|
+
'--template',
|
|
335
|
+
'--edit',
|
|
336
|
+
'--no-edit',
|
|
337
|
+
'--reuse-message',
|
|
338
|
+
'--reedit-message',
|
|
339
|
+
'--gpg-sign',
|
|
340
|
+
'--no-gpg-sign',
|
|
341
|
+
'--all',
|
|
342
|
+
'--patch',
|
|
343
|
+
'--short',
|
|
344
|
+
'--branch',
|
|
345
|
+
'--long',
|
|
346
|
+
'--status',
|
|
347
|
+
'--no-status',
|
|
348
|
+
'--trailer',
|
|
349
|
+
]),
|
|
350
|
+
longValue: new Set([
|
|
351
|
+
'--message',
|
|
352
|
+
'--file',
|
|
353
|
+
'--author',
|
|
354
|
+
'--date',
|
|
355
|
+
'--fixup',
|
|
356
|
+
'--squash',
|
|
357
|
+
'--pathspec-from-file',
|
|
358
|
+
'--cleanup',
|
|
359
|
+
'--template',
|
|
360
|
+
'--reuse-message',
|
|
361
|
+
'--reedit-message',
|
|
362
|
+
'--trailer',
|
|
363
|
+
]),
|
|
364
|
+
short: new Set(['a', 'm', 's', 'q', 'v', 'n', 'e', 'i', 'p', 'o', 'F', 'C', 'c', 't', 'S']),
|
|
365
|
+
shortValue: new Set(['m', 'F', 'C', 'c', 't']),
|
|
366
|
+
shortOptionalValue: new Set(['S']),
|
|
367
|
+
},
|
|
368
|
+
clean: {
|
|
369
|
+
long: new Set([
|
|
370
|
+
'--dry-run',
|
|
371
|
+
'--quiet',
|
|
372
|
+
'--interactive',
|
|
373
|
+
'--ignored',
|
|
374
|
+
'--no-ignored',
|
|
375
|
+
'--pathspec-file-nul',
|
|
376
|
+
'--verbose',
|
|
377
|
+
]),
|
|
378
|
+
longValue: new Set(['--exclude']),
|
|
379
|
+
short: new Set(['d', 'x', 'n', 'q', 'i', 'e', 'X', 'v']),
|
|
380
|
+
shortValue: new Set(['e']),
|
|
381
|
+
},
|
|
382
|
+
reset: {
|
|
383
|
+
long: new Set([
|
|
384
|
+
'--quiet',
|
|
385
|
+
'--no-refresh',
|
|
386
|
+
'--refresh',
|
|
387
|
+
'--mixed',
|
|
388
|
+
'--soft',
|
|
389
|
+
'--merge',
|
|
390
|
+
'--keep',
|
|
391
|
+
'--pathspec-file-nul',
|
|
392
|
+
'--patch',
|
|
393
|
+
]),
|
|
394
|
+
longValue: new Set(['--pathspec-from-file']),
|
|
395
|
+
short: new Set(['q', 'p', 'h']),
|
|
396
|
+
shortValue: new Set(),
|
|
397
|
+
},
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
/** `null` when every option token is allowlisted, otherwise the unknown reason. */
|
|
401
|
+
const optionVerdict = (subcommand, tokens, startIndex) => {
|
|
402
|
+
const spec = OPTION_SPECS[subcommand];
|
|
403
|
+
if (!spec) return { unknown: false };
|
|
404
|
+
let unknown = false;
|
|
405
|
+
for (let index = startIndex; index < tokens.length; index += 1) {
|
|
406
|
+
const value = tokens[index].value;
|
|
407
|
+
if (value === '--') break;
|
|
408
|
+
if (!value.startsWith('-')) continue;
|
|
409
|
+
if (value.startsWith('--')) {
|
|
410
|
+
const name = value.split('=')[0];
|
|
411
|
+
if (spec.long.has(name) || spec.longValue.has(name)) {
|
|
412
|
+
if (!value.includes('=') && spec.longValue.has(name)) index += 1;
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
unknown = true;
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
const letters = value.slice(1);
|
|
419
|
+
for (let letterIndex = 0; letterIndex < letters.length; letterIndex += 1) {
|
|
420
|
+
const letter = letters[letterIndex];
|
|
421
|
+
if (!spec.short.has(letter)) {
|
|
422
|
+
unknown = true;
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
if (spec.shortValue.has(letter)) {
|
|
426
|
+
if (letterIndex === letters.length - 1) index += 1;
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
if (spec.shortOptionalValue?.has(letter)) {
|
|
430
|
+
if (letterIndex < letters.length - 1) break;
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return { unknown };
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* `clean` needs its own decoded parse: `e` takes a value, so `-en` is the
|
|
440
|
+
* exclude pattern `n` (no dry-run), while `-ne foo` is `-n -e foo`. Only an
|
|
441
|
+
* explicit dry-run flag may allow; everything else asks.
|
|
442
|
+
*/
|
|
443
|
+
const parseCleanOptions = (tokens, startIndex) => {
|
|
444
|
+
const spec = OPTION_SPECS.clean;
|
|
445
|
+
let unknown = false;
|
|
446
|
+
let dryRun = false;
|
|
447
|
+
for (let index = startIndex; index < tokens.length; index += 1) {
|
|
448
|
+
const value = tokens[index].value;
|
|
449
|
+
if (value === '--') break;
|
|
450
|
+
if (!value.startsWith('-')) continue;
|
|
451
|
+
if (value.startsWith('--')) {
|
|
452
|
+
if (value === '--dry-run') {
|
|
453
|
+
dryRun = true;
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
if (value === '--exclude') {
|
|
457
|
+
index += 1;
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
if (value.startsWith('--exclude=')) continue;
|
|
461
|
+
const name = value.split('=')[0];
|
|
462
|
+
if (spec.long.has(name)) continue;
|
|
463
|
+
unknown = true;
|
|
464
|
+
continue;
|
|
465
|
+
}
|
|
466
|
+
const letters = value.slice(1);
|
|
467
|
+
for (let letterIndex = 0; letterIndex < letters.length; letterIndex += 1) {
|
|
468
|
+
const letter = letters[letterIndex];
|
|
469
|
+
if (!spec.short.has(letter)) {
|
|
470
|
+
unknown = true;
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
if (letter === 'e') {
|
|
474
|
+
if (letterIndex === letters.length - 1) index += 1;
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
if (letter === 'n') dryRun = true;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return { unknown, dryRun };
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
const isDestructiveRefspec = (value) =>
|
|
484
|
+
/^\+/.test(value) || /^:/.test(value) || /^[^\s:]+:$/.test(value);
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Classify one shell segment from its tokens. `write` is true when the segment
|
|
488
|
+
* may commit or push; `destructive`, `unresolved`, `alias`, `destructiveState`
|
|
489
|
+
* and `unknownOption` are the fail-closed reasons. The `-m` / `--message` value
|
|
490
|
+
* is not scanned as a command, so a quoted commit message stays inert.
|
|
491
|
+
*/
|
|
492
|
+
const classifyGitSegment = (segment) => {
|
|
493
|
+
const { tokens, unterminated } = tokenizeSegment(segment.trim());
|
|
494
|
+
const gitIndex = tokens.findIndex(
|
|
495
|
+
(token) => token.value === 'git' || token.value.endsWith('/git'),
|
|
66
496
|
);
|
|
67
|
-
|
|
497
|
+
if (gitIndex < 0) {
|
|
498
|
+
return {
|
|
499
|
+
write: false,
|
|
500
|
+
destructive: false,
|
|
501
|
+
unresolved: false,
|
|
502
|
+
alias: false,
|
|
503
|
+
destructiveState: false,
|
|
504
|
+
unknownOption: false,
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
let subcommand = null;
|
|
509
|
+
let subcommandIndex = -1;
|
|
510
|
+
for (let index = gitIndex + 1; index < tokens.length; index += 1) {
|
|
511
|
+
const value = tokens[index].value;
|
|
512
|
+
if (GIT_VALUE_GLOBALS.has(value)) {
|
|
513
|
+
index += 1;
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
if (value.startsWith('-')) continue;
|
|
517
|
+
subcommand = value;
|
|
518
|
+
subcommandIndex = index;
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
68
521
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
522
|
+
const known = subcommand === 'commit' || subcommand === 'push';
|
|
523
|
+
const valueIndexes = new Set();
|
|
524
|
+
if (subcommand === 'commit') {
|
|
525
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
526
|
+
const value = tokens[index].value;
|
|
527
|
+
if (
|
|
528
|
+
value === '-m' ||
|
|
529
|
+
value === '--message' ||
|
|
530
|
+
(/^-[^-]+$/.test(value) && value.endsWith('m'))
|
|
531
|
+
) {
|
|
532
|
+
valueIndexes.add(index + 1);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
const alias = tokens.some(
|
|
537
|
+
(token, index) => !valueIndexes.has(index) && /^alias\.[A-Za-z0-9_-]+=/.test(token.value),
|
|
74
538
|
);
|
|
75
|
-
|
|
539
|
+
const writeToken = tokens.some(
|
|
540
|
+
(token, index) =>
|
|
541
|
+
index !== subcommandIndex &&
|
|
542
|
+
!valueIndexes.has(index) &&
|
|
543
|
+
(token.value === 'push' || token.value === 'commit'),
|
|
544
|
+
);
|
|
545
|
+
const write = known || alias || writeToken || unterminated;
|
|
546
|
+
const destructiveRefspec =
|
|
547
|
+
subcommand === 'push' &&
|
|
548
|
+
tokens.some((token, index) => {
|
|
549
|
+
if (index <= subcommandIndex) return false;
|
|
550
|
+
if (token.value.startsWith('-')) return false;
|
|
551
|
+
return isDestructiveRefspec(token.value);
|
|
552
|
+
});
|
|
553
|
+
const destructiveState =
|
|
554
|
+
subcommand === 'checkout' && tokens.some((token) => token.value === '--');
|
|
555
|
+
const cleanCheck =
|
|
556
|
+
subcommand === 'clean' ? parseCleanOptions(tokens, subcommandIndex + 1) : null;
|
|
557
|
+
const optionCheck = cleanCheck ?? optionVerdict(subcommand, tokens, subcommandIndex + 1);
|
|
558
|
+
return {
|
|
559
|
+
write,
|
|
560
|
+
destructive: write && destructiveRefspec,
|
|
561
|
+
unresolved: write && (!known || unterminated),
|
|
562
|
+
alias,
|
|
563
|
+
destructiveState,
|
|
564
|
+
unknownOption: optionCheck.unknown,
|
|
565
|
+
cleanAsk: subcommand === 'clean' && !cleanCheck.dryRun,
|
|
566
|
+
};
|
|
567
|
+
};
|
|
76
568
|
|
|
77
|
-
const
|
|
78
|
-
['yarn.lock', 'yarn'],
|
|
79
|
-
['pnpm-lock.yaml', 'pnpm'],
|
|
80
|
-
['package-lock.json', 'npm'],
|
|
81
|
-
].find(([file]) => fs.existsSync(file));
|
|
569
|
+
const MAX_SCAN_DEPTH = 3;
|
|
82
570
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
571
|
+
const mergeResults = (left, right) => ({
|
|
572
|
+
verdict: Math.max(left.verdict, right.verdict),
|
|
573
|
+
destructive: left.destructive || right.destructive,
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
const directSegmentResult = (segment) => {
|
|
577
|
+
const classified = classifyGitSegment(segment);
|
|
578
|
+
if (classified.destructiveState) return { verdict: 2, destructive: true };
|
|
579
|
+
if (classified.unknownOption || classified.cleanAsk) {
|
|
580
|
+
return { verdict: 2, destructive: false };
|
|
91
581
|
}
|
|
92
|
-
}
|
|
582
|
+
if (!classified.write) return { verdict: 0, destructive: false };
|
|
583
|
+
if (classified.destructive) return { verdict: 2, destructive: true };
|
|
584
|
+
if (classified.unresolved || classified.alias) return { verdict: 2, destructive: false };
|
|
585
|
+
return { verdict: 1, destructive: false };
|
|
586
|
+
};
|
|
93
587
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
588
|
+
/** Every quoted span with its content and the index of its opening quote. */
|
|
589
|
+
const extractQuotedSpans = (segment) => {
|
|
590
|
+
const spans = [];
|
|
591
|
+
let quote = null;
|
|
592
|
+
let start = -1;
|
|
593
|
+
let content = '';
|
|
594
|
+
for (let index = 0; index < segment.length; index += 1) {
|
|
595
|
+
const char = segment[index];
|
|
596
|
+
if (quote !== null) {
|
|
597
|
+
if (char === '\\' && quote === '"' && index + 1 < segment.length) {
|
|
598
|
+
index += 1;
|
|
599
|
+
content += segment[index];
|
|
600
|
+
continue;
|
|
601
|
+
}
|
|
602
|
+
if (char === quote) {
|
|
603
|
+
spans.push({ content, index: start });
|
|
604
|
+
quote = null;
|
|
605
|
+
content = '';
|
|
606
|
+
start = -1;
|
|
607
|
+
continue;
|
|
608
|
+
}
|
|
609
|
+
content += char;
|
|
610
|
+
continue;
|
|
611
|
+
}
|
|
612
|
+
if (char === "'" || char === '"') {
|
|
613
|
+
quote = char;
|
|
614
|
+
start = index;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
return { spans, unterminated: quote !== null };
|
|
618
|
+
};
|
|
97
619
|
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
`This repository appears to use ${expected}, but the command uses ${used}. Confirm before continuing.`,
|
|
103
|
-
`Use ${expected} for package scripts and installs unless the user explicitly approves ${used}.`,
|
|
104
|
-
);
|
|
105
|
-
}
|
|
620
|
+
const isEvalPayload = (segment, quoteIndex) => {
|
|
621
|
+
const before = segment.slice(0, quoteIndex).trim();
|
|
622
|
+
return /\beval(?:\s+--)?\s*$/.test(before);
|
|
623
|
+
};
|
|
106
624
|
|
|
107
|
-
const
|
|
108
|
-
new Promise((resolve) => {
|
|
109
|
-
const socket = net.createConnection({ host: '127.0.0.1', port });
|
|
110
|
-
const done = (open) => {
|
|
111
|
-
socket.destroy();
|
|
112
|
-
resolve(open);
|
|
113
|
-
};
|
|
114
|
-
socket.once('connect', () => done(true));
|
|
115
|
-
socket.once('error', () => done(false));
|
|
116
|
-
socket.setTimeout(400, () => done(false));
|
|
117
|
-
});
|
|
625
|
+
const SHELL_TOKEN = /(?:^|\/)(?:sh|bash|zsh|dash|ksh)$/;
|
|
118
626
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
627
|
+
const isShellCPayload = (segment, quoteIndex) => {
|
|
628
|
+
const before = segment.slice(0, quoteIndex).trim();
|
|
629
|
+
const tokens = before.split(/\s+/).filter(Boolean);
|
|
630
|
+
let shellIndex = -1;
|
|
631
|
+
for (let index = tokens.length - 1; index >= 0; index -= 1) {
|
|
632
|
+
if (SHELL_TOKEN.test(tokens[index])) {
|
|
633
|
+
shellIndex = index;
|
|
634
|
+
break;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
if (shellIndex < 0) return false;
|
|
638
|
+
return tokens
|
|
639
|
+
.slice(shellIndex + 1)
|
|
640
|
+
.some((token) => token === '-c' || /^-[^-]*c/.test(token));
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
const nestedShellResult = (content, depth) => {
|
|
644
|
+
if (depth >= MAX_SCAN_DEPTH) return { verdict: 2, destructive: false };
|
|
645
|
+
const nested = scanGitCommand(content, depth + 1);
|
|
646
|
+
if (nested.verdict === 0) return { verdict: 0, destructive: false };
|
|
647
|
+
return { verdict: 2, destructive: nested.destructive };
|
|
648
|
+
};
|
|
649
|
+
|
|
650
|
+
const quotedSegmentResult = (segment, depth) => {
|
|
651
|
+
const { spans, unterminated } = extractQuotedSpans(segment);
|
|
652
|
+
if (unterminated) return { verdict: 2, destructive: false };
|
|
653
|
+
let result = { verdict: 0, destructive: false };
|
|
654
|
+
for (const span of spans) {
|
|
655
|
+
const trigger =
|
|
656
|
+
/\bgit\b/.test(span.content) ||
|
|
657
|
+
isEvalPayload(segment, span.index) ||
|
|
658
|
+
isShellCPayload(segment, span.index);
|
|
659
|
+
if (!trigger) continue;
|
|
660
|
+
result = mergeResults(result, nestedShellResult(span.content, depth));
|
|
661
|
+
}
|
|
662
|
+
return result;
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* `-c` / `--config-env` values are executed by git (pager, sshCommand,
|
|
667
|
+
* diff.external, hooks). Scan the value after the first `=`: a git write or a
|
|
668
|
+
* destructive token there asks. `-C`, `--git-dir`, `--work-tree`, `--namespace`,
|
|
669
|
+
* `--super-prefix` and `--exec-path` are paths/namespaces and stay inert.
|
|
670
|
+
*/
|
|
671
|
+
const configSegmentResult = (segment, depth) => {
|
|
672
|
+
const { tokens } = tokenizeSegment(segment);
|
|
673
|
+
let result = { verdict: 0, destructive: false };
|
|
674
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
675
|
+
const value = tokens[index].value;
|
|
676
|
+
let configValue = null;
|
|
677
|
+
if (value === '-c' || value === '--config-env') {
|
|
678
|
+
configValue = tokens[index + 1]?.value ?? null;
|
|
679
|
+
index += 1;
|
|
680
|
+
} else if (value.startsWith('--config-env=')) {
|
|
681
|
+
configValue = value.slice('--config-env='.length);
|
|
682
|
+
} else if (value.startsWith('-c') && value.length > 2) {
|
|
683
|
+
configValue = value.slice(2);
|
|
684
|
+
}
|
|
685
|
+
if (configValue === null) continue;
|
|
686
|
+
const separator = configValue.indexOf('=');
|
|
687
|
+
if (separator < 0) continue;
|
|
688
|
+
let payload = configValue.slice(separator + 1);
|
|
689
|
+
// Git strips a leading `!` (and whitespace around it) from an executed
|
|
690
|
+
// config value and shell-runs the rest; classify that remainder as a
|
|
691
|
+
// command. `!gh …` has no git write and stays inert.
|
|
692
|
+
payload = payload.replace(/^[\s!]+/, '');
|
|
693
|
+
if (!payload.trim()) continue;
|
|
694
|
+
result = mergeResults(result, nestedShellResult(payload, depth));
|
|
695
|
+
}
|
|
696
|
+
return result;
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
/** A quoted payload on the left of `| sh` / `| bash` is executed too. */
|
|
700
|
+
const pipeQuotedResult = (command, depth) => {
|
|
701
|
+
const text = String(command).replace(/\\\r?\n/g, '');
|
|
702
|
+
const pattern = /("(?:[^"\\]|\\.)*"|'[^']*')\s*\|\s*(?:sh|bash|zsh|dash|ksh)\b/g;
|
|
703
|
+
let result = { verdict: 0, destructive: false };
|
|
704
|
+
for (const match of text.matchAll(pattern)) {
|
|
705
|
+
const content = match[1].slice(1, -1);
|
|
706
|
+
if (!content.trim()) continue;
|
|
707
|
+
result = mergeResults(result, nestedShellResult(content, depth));
|
|
708
|
+
}
|
|
709
|
+
return result;
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Recursive unwrap: every quoted span that can execute a git write is rescanned
|
|
714
|
+
* (depth ≤ 3) and any nested write is asked. The strictest verdict wins.
|
|
715
|
+
*/
|
|
716
|
+
const scanGitCommand = (command, depth = 0) => {
|
|
717
|
+
if (depth > MAX_SCAN_DEPTH) return { verdict: 2, destructive: false };
|
|
718
|
+
let result = { verdict: 0, destructive: false };
|
|
719
|
+
for (const segment of splitShellSegments(command)) {
|
|
720
|
+
result = mergeResults(result, directSegmentResult(segment));
|
|
721
|
+
result = mergeResults(result, quotedSegmentResult(segment, depth));
|
|
722
|
+
result = mergeResults(result, configSegmentResult(segment, depth));
|
|
723
|
+
}
|
|
724
|
+
return mergeResults(result, pipeQuotedResult(command, depth));
|
|
725
|
+
};
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* The decision for one shell event: `{ permission, user_message, agent_message }`.
|
|
729
|
+
*
|
|
730
|
+
* Shared by the CLI below and any host that can import the rendered file, so
|
|
731
|
+
* the verdict cannot drift between them. Three effects are injected — a project
|
|
732
|
+
* file read, a TCP probe and the settings resolver — because a plugin has no
|
|
733
|
+
* stdin to read and no guaranteed working directory. Never throws: an
|
|
734
|
+
* unreadable event is an allow, the same fail-open the hook always had.
|
|
735
|
+
*/
|
|
736
|
+
export const evaluate = async (event, options = {}) => {
|
|
737
|
+
const {
|
|
738
|
+
root = process.cwd(),
|
|
739
|
+
exists = (file) => fs.existsSync(file),
|
|
740
|
+
readText = (file) => fs.readFileSync(file, 'utf8'),
|
|
741
|
+
canConnect = portIsOpen,
|
|
742
|
+
settings = importSettings,
|
|
743
|
+
} = options;
|
|
744
|
+
const at = (file) => path.join(root, file);
|
|
745
|
+
if (!event || typeof event !== 'object') return allowed();
|
|
134
746
|
|
|
135
|
-
|
|
747
|
+
const command = String(event.command || event.input?.command || event.tool_input?.command || '');
|
|
748
|
+
if (!command.trim()) return allowed();
|
|
749
|
+
|
|
750
|
+
// Recursively unwrap quoted inner shells before deciding: a quoted span that
|
|
751
|
+
// contains `git` (or is an `eval` / shell `-c` / pipe-to-shell payload) is
|
|
752
|
+
// rescanned at depth + 1, and any nested write asks. The strictest verdict
|
|
753
|
+
// across all segments and levels wins; the flag may only lift a positively
|
|
754
|
+
// recognised plain `commit`/`push`.
|
|
755
|
+
const gitScan = scanGitCommand(command, 0);
|
|
756
|
+
if (gitScan.verdict > 0) {
|
|
757
|
+
// An autonomous `/task-evil` run writes this marker before its first action;
|
|
758
|
+
// no human is attached, so the flag's `allow` must not reach it.
|
|
759
|
+
if (exists(at('.ai.local/team/.task-evil'))) {
|
|
760
|
+
return ask(
|
|
761
|
+
'An autonomous /task-evil run cannot commit or push. Remove .ai.local/team/.task-evil only after the run ends.',
|
|
762
|
+
'Do not commit or push in an autonomous run. Return a Human commits block; a human removes the marker and commits.',
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
if (gitScan.verdict === 2) {
|
|
766
|
+
return ask(
|
|
767
|
+
gitScan.destructive
|
|
768
|
+
? 'This command looks destructive for git state. Review it before continuing.'
|
|
769
|
+
: 'This command wraps a git write in a quoted or indirect shell; confirm before running it.',
|
|
770
|
+
gitScan.destructive
|
|
771
|
+
? 'A project hook flagged a destructive git command. Ask the user before running it.'
|
|
772
|
+
: 'A quoted or indirect shell command contains a git write. Ask the user before running it.',
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
let gitWritesAllowed = false;
|
|
776
|
+
try {
|
|
777
|
+
const getSetting = await settings({ root, exists, readText });
|
|
778
|
+
gitWritesAllowed = typeof getSetting === 'function' && getSetting('AI_RULES_ALLOW_GIT_WRITES') === true;
|
|
779
|
+
} catch {
|
|
780
|
+
gitWritesAllowed = false;
|
|
781
|
+
}
|
|
782
|
+
if (gitWritesAllowed) return allowed();
|
|
783
|
+
return ask(
|
|
784
|
+
'Commits and pushes are gated. Set AI_RULES_ALLOW_GIT_WRITES=true in .ai.local/.env to allow them.',
|
|
785
|
+
'Do not commit or push while AI_RULES_ALLOW_GIT_WRITES is not true. Return a Human commits block instead.',
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
if (/\b(?:pkill|killall)\b|\bxargs\s+kill\b/.test(command)) {
|
|
790
|
+
return ask(
|
|
791
|
+
'This command can stop processes the task does not own. Name the process you started, or use `node .ai.local/scripts/processes.mjs stop`.',
|
|
792
|
+
'Never mass-kill processes. Stop the recorded pid through processes.mjs; ask before pkill, killall, or xargs kill.',
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
const managerByFile = [
|
|
797
|
+
['yarn.lock', 'yarn'],
|
|
798
|
+
['pnpm-lock.yaml', 'pnpm'],
|
|
799
|
+
['package-lock.json', 'npm'],
|
|
800
|
+
].find(([file]) => exists(at(file)));
|
|
801
|
+
|
|
802
|
+
let expected = managerByFile?.[1];
|
|
803
|
+
if (!expected && exists(at('package.json'))) {
|
|
804
|
+
try {
|
|
805
|
+
const pkg = JSON.parse(readText(at('package.json')));
|
|
806
|
+
const pm = typeof pkg.packageManager === 'string' ? pkg.packageManager : '';
|
|
807
|
+
expected = pm.split('@')[0] || undefined;
|
|
808
|
+
} catch {
|
|
809
|
+
// Ignore invalid package.json in the hook; the agent can diagnose it later.
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
const used = expected ? command.match(/(^|[;&|]\s*)(npm|yarn|pnpm)\s+/)?.[2] : undefined;
|
|
814
|
+
if (used && used !== expected) {
|
|
815
|
+
return ask(
|
|
816
|
+
`This repository appears to use ${expected}, but the command uses ${used}. Confirm before continuing.`,
|
|
817
|
+
`Use ${expected} for package scripts and installs unless the user explicitly approves ${used}.`,
|
|
818
|
+
);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
// Only a server-start shaped command is worth probing: the hook must not slow
|
|
822
|
+
// down or interrogate every shell call.
|
|
823
|
+
const explicitPortMatch = command.match(/--port[=\s]+(\d{2,5})|\bPORT=(\d{2,5})/);
|
|
824
|
+
const explicitPort = Number(explicitPortMatch?.[1] || explicitPortMatch?.[2] || 0) || null;
|
|
825
|
+
const startsServer = SERVER_COMMAND ? SERVER_COMMAND.test(command) : false;
|
|
826
|
+
const portsToProbe = startsServer ? (explicitPort ? [explicitPort] : SERVER_PORTS) : [];
|
|
827
|
+
|
|
828
|
+
for (const port of portsToProbe) {
|
|
829
|
+
if (!(await canConnect(port))) continue;
|
|
830
|
+
return ask(
|
|
831
|
+
`Port ${port} is already listening. Reuse the running server, or stop the recorded process before starting another.`,
|
|
832
|
+
`A server may already serve port ${port}. Probe it first, reuse it, or stop it with \`node .ai.local/scripts/processes.mjs stop\`; never start a duplicate.`,
|
|
833
|
+
);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
return allowed();
|
|
837
|
+
};
|
|
838
|
+
|
|
839
|
+
/** The host answers: Claude's `PreToolUse` envelope, or the neutral decision. */
|
|
840
|
+
const answer = (event, decision) => {
|
|
841
|
+
const claudePreTool = event !== null && event.hook_event_name === 'PreToolUse';
|
|
842
|
+
if (!claudePreTool) {
|
|
843
|
+
process.stdout.write(JSON.stringify(decision));
|
|
844
|
+
} else {
|
|
845
|
+
const verdict = decision.permission === 'ask' || decision.permission === 'deny' ? decision.permission : 'allow';
|
|
846
|
+
const hookSpecificOutput = { hookEventName: 'PreToolUse', permissionDecision: verdict };
|
|
847
|
+
if (decision.user_message && verdict !== 'allow') {
|
|
848
|
+
hookSpecificOutput.permissionDecisionReason = decision.user_message;
|
|
849
|
+
}
|
|
850
|
+
process.stdout.write(JSON.stringify({ hookSpecificOutput }));
|
|
851
|
+
}
|
|
852
|
+
process.exit(0);
|
|
853
|
+
};
|
|
854
|
+
|
|
855
|
+
const main = async () => {
|
|
856
|
+
let event = null;
|
|
857
|
+
try {
|
|
858
|
+
const parsed = JSON.parse(fs.readFileSync(0, 'utf8'));
|
|
859
|
+
event = parsed && typeof parsed === 'object' ? parsed : null;
|
|
860
|
+
} catch {
|
|
861
|
+
event = null;
|
|
862
|
+
}
|
|
863
|
+
answer(event, await evaluate(event));
|
|
864
|
+
};
|
|
865
|
+
|
|
866
|
+
const invokedDirectly = (() => {
|
|
867
|
+
if (process.argv[1] === undefined) return false;
|
|
868
|
+
// Realpath on both sides: `os.tmpdir()` and `/tmp` are symlinks on macOS, so a
|
|
869
|
+
// plain resolve marks a script it cannot start.
|
|
870
|
+
try {
|
|
871
|
+
return fs.realpathSync(process.argv[1]) === fs.realpathSync(fileURLToPath(import.meta.url));
|
|
872
|
+
} catch {
|
|
873
|
+
return path.resolve(process.argv[1]) === path.resolve(fileURLToPath(import.meta.url));
|
|
874
|
+
}
|
|
875
|
+
})();
|
|
876
|
+
|
|
877
|
+
if (invokedDirectly) {
|
|
878
|
+
await main();
|
|
879
|
+
}
|