@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
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode rule attach: the pure half.
|
|
3
|
+
*
|
|
4
|
+
* The host has no path-glob rule delivery, so a rule only reaches the model if
|
|
5
|
+
* the agent spends a `Read` on it. This module decides *which* rule bodies a
|
|
6
|
+
* session earns from the files it touched, and the adapter in `index.ts` reads
|
|
7
|
+
* the bytes and asks the host to carry them.
|
|
8
|
+
*
|
|
9
|
+
* Three invariants, each pinned by `scripts/test-rule-attach.mjs`:
|
|
10
|
+
* - a stem is attached only when one of its globs matches a touched path;
|
|
11
|
+
* - a stem is attached at most once per session;
|
|
12
|
+
* - the attached bodies stay inside the `MAX_ATTACH_LINES` budget — the same
|
|
13
|
+
* unit and ceiling `check-next-attached-budget.mjs` caps Cursor with.
|
|
14
|
+
*
|
|
15
|
+
* The glob engine is a port of that gate's matcher (`**` crosses directories,
|
|
16
|
+
* `*` does not, one `{a,b}` group expands), never an import: the gate lives in
|
|
17
|
+
* the package, this file ships into a consumer's `.opencode/plugins/`.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export type RuleGlob = { stem: string; globs: string[] }
|
|
21
|
+
|
|
22
|
+
export type RuleCatalog = {
|
|
23
|
+
schemaVersion: number
|
|
24
|
+
source?: string
|
|
25
|
+
rules: RuleGlob[]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const MARKER = "[ai-rules rule-attach]"
|
|
29
|
+
|
|
30
|
+
/** `check-next-attached-budget.mjs` FIXTURES: UI 420 / STORE 400 / API 400 / APP 261 / E2E 258 / UNIT 218 / CONFIG 135. */
|
|
31
|
+
export const MAX_ATTACH_LINES = 420
|
|
32
|
+
|
|
33
|
+
export const RULE_ATTACH_ENV = "AI_RULES_RULE_ATTACH"
|
|
34
|
+
|
|
35
|
+
/** Kill switch, same contract as the output guard's `AI_RULES_OUTPUT_GUARD=0`. */
|
|
36
|
+
export const ruleAttachEnabled = (env: Record<string, string | undefined> = process.env): boolean =>
|
|
37
|
+
env[RULE_ATTACH_ENV] !== "0"
|
|
38
|
+
|
|
39
|
+
const expandBraces = (glob: string): string[] => {
|
|
40
|
+
const match = glob.match(/\{([^{}]+)\}/)
|
|
41
|
+
if (!match || match.index === undefined) return [glob]
|
|
42
|
+
const prefix = glob.slice(0, match.index)
|
|
43
|
+
const suffix = glob.slice(match.index + match[0].length)
|
|
44
|
+
return match[1].split(",").map((alternative) => `${prefix}${alternative}${suffix}`)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const globToRegExp = (glob: string): RegExp => {
|
|
48
|
+
let source = "^"
|
|
49
|
+
for (let index = 0; index < glob.length; index += 1) {
|
|
50
|
+
if (glob.startsWith("**/", index)) {
|
|
51
|
+
source += "(?:.*/)?"
|
|
52
|
+
index += 2
|
|
53
|
+
continue
|
|
54
|
+
}
|
|
55
|
+
if (glob.startsWith("**", index)) {
|
|
56
|
+
source += ".*"
|
|
57
|
+
index += 1
|
|
58
|
+
continue
|
|
59
|
+
}
|
|
60
|
+
if (glob[index] === "*") {
|
|
61
|
+
source += "[^/]*"
|
|
62
|
+
continue
|
|
63
|
+
}
|
|
64
|
+
if ("\\^$+?.()|[]{}".includes(glob[index])) source += `\\${glob[index]}`
|
|
65
|
+
else source += glob[index]
|
|
66
|
+
}
|
|
67
|
+
return new RegExp(`${source}$`)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const matchGlobs = (globs: string[], file: string): boolean =>
|
|
71
|
+
globs.some((glob) => expandBraces(glob).some((expanded) => globToRegExp(expanded).test(file)))
|
|
72
|
+
|
|
73
|
+
/** Stems whose glob table matches a repo-relative path, in catalog order. */
|
|
74
|
+
export const matchStems = (rules: RuleGlob[], file: string): string[] =>
|
|
75
|
+
rules.filter((rule) => rule.globs.length > 0 && matchGlobs(rule.globs, file)).map((rule) => rule.stem)
|
|
76
|
+
|
|
77
|
+
/** Non-empty lines, the unit `check-next-attached-budget.mjs` charges. */
|
|
78
|
+
export const nonemptyLines = (text: string): number =>
|
|
79
|
+
text.split("\n").filter((line) => line.trim() !== "").length
|
|
80
|
+
|
|
81
|
+
/** One attached body: the marker names the file so a later turn can see it. */
|
|
82
|
+
export const renderRule = (stem: string, body: string): string =>
|
|
83
|
+
`${MARKER} .opencode/rules/${stem}.md\n\n${body.trimEnd()}\n`
|
|
84
|
+
|
|
85
|
+
const PATH_EXTENSION = /\.[A-Za-z0-9]{1,8}$/
|
|
86
|
+
|
|
87
|
+
/** Quoted or bare shell tokens. A quoted sentence stays one token. */
|
|
88
|
+
export function shellTokens(command: string): string[] {
|
|
89
|
+
const tokens: string[] = []
|
|
90
|
+
const pattern = /"([^"]*)"|'([^']*)'|`([^`]*)`|(\S+)/g
|
|
91
|
+
for (let match = pattern.exec(command); match !== null; match = pattern.exec(command)) {
|
|
92
|
+
const token = match[1] ?? match[2] ?? match[3] ?? match[4] ?? ""
|
|
93
|
+
if (token !== "") tokens.push(token)
|
|
94
|
+
}
|
|
95
|
+
return tokens
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Path-like tokens in a shell command. No process is spawned. A token counts
|
|
100
|
+
* when it contains `/` or a short extension. A quoted sentence that contains
|
|
101
|
+
* spaces does not. Flags, URLs, and `$vars` do not, including the value of
|
|
102
|
+
* `NAME=$var`.
|
|
103
|
+
*/
|
|
104
|
+
export function shellPaths(command: string): string[] {
|
|
105
|
+
const paths: string[] = []
|
|
106
|
+
for (const token of shellTokens(command)) {
|
|
107
|
+
if (token.startsWith("-") || token.includes("://") || token.startsWith("$")) continue
|
|
108
|
+
const value = /^[A-Za-z_][A-Za-z0-9_]*=/.test(token) ? token.slice(token.indexOf("=") + 1) : token
|
|
109
|
+
if (value === "" || value.startsWith("-") || value.startsWith("$") || value.includes("://") || /\s/.test(value)) continue
|
|
110
|
+
if (!value.includes("/") && !PATH_EXTENSION.test(value)) continue
|
|
111
|
+
paths.push(value.replace(/^\.\//, ""))
|
|
112
|
+
}
|
|
113
|
+
return paths
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* A repo-relative path for a tool target. An absolute path outside the project
|
|
118
|
+
* root reads as `null`: a glob never matches a file the glob table cannot name.
|
|
119
|
+
*/
|
|
120
|
+
export function toRepoPath(target: unknown, root: string): string | null {
|
|
121
|
+
if (typeof target !== "string" || target.trim() === "") return null
|
|
122
|
+
const normalized = target.replace(/\\/g, "/")
|
|
123
|
+
const base = root.replace(/\\/g, "/").replace(/\/+$/, "")
|
|
124
|
+
if (normalized === base) return ""
|
|
125
|
+
if (normalized.startsWith(`${base}/`)) return normalized.slice(base.length + 1)
|
|
126
|
+
if (normalized.startsWith("/")) return null
|
|
127
|
+
return normalized.replace(/^\.\//, "")
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export type SkippedRule = { stem: string; reason: "attached" | "unreadable" | "cap" }
|
|
131
|
+
|
|
132
|
+
export type AttachPlan = {
|
|
133
|
+
inject: Array<{ stem: string; text: string; lines: number }>
|
|
134
|
+
skipped: SkippedRule[]
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The attach decision for one turn: candidates from every touched path, minus
|
|
139
|
+
* the stems this session already carries, stopping at the line budget.
|
|
140
|
+
*
|
|
141
|
+
* A stem that does not fit the remaining budget is skipped, never truncated —
|
|
142
|
+
* half a rule is the failure mode the output guard was fixed for.
|
|
143
|
+
*/
|
|
144
|
+
export function planAttachment({
|
|
145
|
+
paths,
|
|
146
|
+
catalog,
|
|
147
|
+
attached,
|
|
148
|
+
readRule,
|
|
149
|
+
maxLines = MAX_ATTACH_LINES,
|
|
150
|
+
}: {
|
|
151
|
+
paths: readonly string[]
|
|
152
|
+
catalog: RuleCatalog
|
|
153
|
+
attached: ReadonlySet<string>
|
|
154
|
+
readRule: (stem: string) => string | null
|
|
155
|
+
maxLines?: number
|
|
156
|
+
}): AttachPlan {
|
|
157
|
+
const inject: AttachPlan["inject"] = []
|
|
158
|
+
const skipped: SkippedRule[] = []
|
|
159
|
+
const seen = new Set<string>()
|
|
160
|
+
let used = 0
|
|
161
|
+
for (const file of paths) {
|
|
162
|
+
for (const stem of matchStems(catalog.rules, file)) {
|
|
163
|
+
if (seen.has(stem)) continue
|
|
164
|
+
seen.add(stem)
|
|
165
|
+
if (attached.has(stem)) {
|
|
166
|
+
skipped.push({ stem, reason: "attached" })
|
|
167
|
+
continue
|
|
168
|
+
}
|
|
169
|
+
const body = readRule(stem)
|
|
170
|
+
if (body === null) {
|
|
171
|
+
skipped.push({ stem, reason: "unreadable" })
|
|
172
|
+
continue
|
|
173
|
+
}
|
|
174
|
+
const lines = nonemptyLines(body)
|
|
175
|
+
if (lines === 0) {
|
|
176
|
+
skipped.push({ stem, reason: "unreadable" })
|
|
177
|
+
continue
|
|
178
|
+
}
|
|
179
|
+
if (used + lines > maxLines) {
|
|
180
|
+
skipped.push({ stem, reason: "cap" })
|
|
181
|
+
continue
|
|
182
|
+
}
|
|
183
|
+
used += lines
|
|
184
|
+
inject.push({ stem, text: renderRule(stem, body), lines })
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return { inject, skipped }
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** A stem is a file name, never a path: `path.join(rulesDir, stem + ".md")` must stay inside it. */
|
|
191
|
+
export const RULE_STEM_PATTERN = /^[a-z0-9][a-z0-9-]*$/
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Parse the shipped catalog; a malformed file yields an empty table, never a
|
|
195
|
+
* throw. A stem that is not a plain rule name is dropped, because it would
|
|
196
|
+
* otherwise resolve a rule body outside `rules/`.
|
|
197
|
+
*/
|
|
198
|
+
export function parseCatalog(text: string, onInvalidStem?: (stem: string) => void): RuleCatalog {
|
|
199
|
+
let parsed: unknown
|
|
200
|
+
try {
|
|
201
|
+
parsed = JSON.parse(text)
|
|
202
|
+
} catch {
|
|
203
|
+
return { schemaVersion: 0, rules: [] }
|
|
204
|
+
}
|
|
205
|
+
const record = (parsed ?? {}) as { schemaVersion?: unknown; source?: unknown; rules?: unknown }
|
|
206
|
+
const rules: RuleGlob[] = []
|
|
207
|
+
for (const entry of Array.isArray(record.rules) ? record.rules : []) {
|
|
208
|
+
const row = (entry ?? {}) as { stem?: unknown; globs?: unknown }
|
|
209
|
+
if (typeof row.stem !== "string" || row.stem === "") continue
|
|
210
|
+
if (!RULE_STEM_PATTERN.test(row.stem)) {
|
|
211
|
+
onInvalidStem?.(row.stem)
|
|
212
|
+
continue
|
|
213
|
+
}
|
|
214
|
+
const globs = (Array.isArray(row.globs) ? row.globs : []).filter(
|
|
215
|
+
(glob): glob is string => typeof glob === "string" && glob !== "",
|
|
216
|
+
)
|
|
217
|
+
rules.push({ stem: row.stem, globs })
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
schemaVersion: typeof record.schemaVersion === "number" ? record.schemaVersion : 0,
|
|
221
|
+
...(typeof record.source === "string" ? { source: record.source } : {}),
|
|
222
|
+
rules,
|
|
223
|
+
}
|
|
224
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode rule attach: the host adapter.
|
|
3
|
+
*
|
|
4
|
+
* The host dispatches `ctx.session.hook("context")` with the assembled messages
|
|
5
|
+
* before dispatch. That payload already carries the session's tool calls, so the
|
|
6
|
+
* adapter walks it for a target path instead of registering an event the bridge
|
|
7
|
+
* never fires (`tool.execute.after` is internal-only on v2.4.1).
|
|
8
|
+
*
|
|
9
|
+
* Three bounds, all in `attach.ts`: only a stem whose glob matches a touched
|
|
10
|
+
* path is attached, each stem once per session, and the bodies stay inside the
|
|
11
|
+
* line budget. `AI_RULES_RULE_ATTACH=0` disables the plugin; debug output goes
|
|
12
|
+
* to `.ai.local/team/output-guard/debug.log` through `AI_RULES_RULE_ATTACH_DEBUG=1`.
|
|
13
|
+
*
|
|
14
|
+
* Injected text is a trailing user message carrying `[ai-rules rule-attach]`
|
|
15
|
+
* and the rule body. It carries text only — no shell, no `child_process`, and
|
|
16
|
+
* nothing the model wrote is executed. A host without `ctx.session.hook` no-ops,
|
|
17
|
+
* the same degradation contract as the output guard.
|
|
18
|
+
*/
|
|
19
|
+
import fs from "node:fs"
|
|
20
|
+
import path from "node:path"
|
|
21
|
+
import { Plugin } from "@opencode/plugin"
|
|
22
|
+
import {
|
|
23
|
+
MARKER,
|
|
24
|
+
parseCatalog,
|
|
25
|
+
planAttachment,
|
|
26
|
+
ruleAttachEnabled,
|
|
27
|
+
shellPaths,
|
|
28
|
+
toRepoPath,
|
|
29
|
+
type RuleCatalog,
|
|
30
|
+
} from "./attach.ts"
|
|
31
|
+
|
|
32
|
+
const TOOL_TARGET_KEYS = ["filePath", "path", "file"] as const
|
|
33
|
+
const TARGET_TOOLS = new Set(["read", "edit", "write", "grep", "glob"])
|
|
34
|
+
|
|
35
|
+
const recordOf = (value: unknown): Record<string, unknown> =>
|
|
36
|
+
value !== null && typeof value === "object" ? (value as Record<string, unknown>) : {}
|
|
37
|
+
|
|
38
|
+
const targetOf = (input: Record<string, unknown>): string | null => {
|
|
39
|
+
for (const key of TOOL_TARGET_KEYS) {
|
|
40
|
+
const value = input[key]
|
|
41
|
+
if (typeof value === "string" && value !== "") return value
|
|
42
|
+
}
|
|
43
|
+
return null
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const SHELL_TOOLS = new Set(["bash", "shell", "sh"])
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The repo-relative targets of this request's `tool-call` parts. A `tool-call`
|
|
50
|
+
* carries `{ type: "tool-call", name, input }`. File tools contribute their
|
|
51
|
+
* path field. `bash` / `shell` / `sh` contribute path tokens from the command
|
|
52
|
+
* string; the command is not executed.
|
|
53
|
+
*/
|
|
54
|
+
const touchedPaths = (messages: unknown, projectRoot: string): string[] => {
|
|
55
|
+
const paths = new Set<string>()
|
|
56
|
+
if (!Array.isArray(messages)) return []
|
|
57
|
+
const add = (target: string) => {
|
|
58
|
+
const rel = toRepoPath(target, projectRoot)
|
|
59
|
+
if (rel !== null && rel !== "") paths.add(rel)
|
|
60
|
+
}
|
|
61
|
+
for (const message of messages) {
|
|
62
|
+
const content = recordOf(message).content
|
|
63
|
+
if (!Array.isArray(content)) continue
|
|
64
|
+
for (const item of content) {
|
|
65
|
+
const call = recordOf(item)
|
|
66
|
+
if (call.type !== "tool-call") continue
|
|
67
|
+
const tool = typeof call.name === "string" ? call.name : ""
|
|
68
|
+
const input = recordOf(call.input)
|
|
69
|
+
if (SHELL_TOOLS.has(tool)) {
|
|
70
|
+
const command = typeof input.command === "string" ? input.command : ""
|
|
71
|
+
for (const token of shellPaths(command)) add(token)
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
74
|
+
if (!TARGET_TOOLS.has(tool)) continue
|
|
75
|
+
const target = targetOf(input)
|
|
76
|
+
if (target === null) continue
|
|
77
|
+
add(target)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return [...paths]
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** A message text part that already carries this stem's marker. */
|
|
84
|
+
const carries = (messages: unknown, stem: string): boolean => {
|
|
85
|
+
const needle = `${MARKER} .opencode/rules/${stem}.md`
|
|
86
|
+
if (!Array.isArray(messages)) return false
|
|
87
|
+
for (const message of messages) {
|
|
88
|
+
const content = recordOf(message).content
|
|
89
|
+
if (!Array.isArray(content)) continue
|
|
90
|
+
for (const part of content) {
|
|
91
|
+
const text = recordOf(part).text
|
|
92
|
+
if (typeof text === "string" && text.includes(needle)) return true
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return false
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const debugLog = (projectRoot: string, message: string): void => {
|
|
99
|
+
if (process.env.AI_RULES_RULE_ATTACH_DEBUG !== "1") return
|
|
100
|
+
try {
|
|
101
|
+
const dir = path.join(projectRoot, ".ai.local", "team", "output-guard")
|
|
102
|
+
fs.mkdirSync(dir, { recursive: true })
|
|
103
|
+
fs.appendFileSync(path.join(dir, "debug.log"), `${new Date().toISOString()} rule-attach ${message}\n`)
|
|
104
|
+
} catch {
|
|
105
|
+
/* an unlogged attach is still a correct attach */
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export default Plugin.define({
|
|
110
|
+
id: "ai-rules.rule-attach",
|
|
111
|
+
async setup(ctx) {
|
|
112
|
+
try {
|
|
113
|
+
if (!ruleAttachEnabled()) return
|
|
114
|
+
if (typeof ctx.session?.hook !== "function") return
|
|
115
|
+
const projectRoot = path.resolve(ctx.location.directory)
|
|
116
|
+
const catalogFile = path.join(projectRoot, ".opencode", "plugins", "rule-attach", "globs.json")
|
|
117
|
+
let catalog: RuleCatalog
|
|
118
|
+
try {
|
|
119
|
+
catalog = parseCatalog(fs.readFileSync(catalogFile, "utf8"), (stem) =>
|
|
120
|
+
debugLog(projectRoot, `skipped catalog stem ${JSON.stringify(stem)}: not a rule name`),
|
|
121
|
+
)
|
|
122
|
+
} catch {
|
|
123
|
+
return
|
|
124
|
+
}
|
|
125
|
+
if (catalog.rules.length === 0) return
|
|
126
|
+
const rulesDir = path.join(projectRoot, ".opencode", "rules")
|
|
127
|
+
const attached = new Map<string, Set<string>>()
|
|
128
|
+
|
|
129
|
+
const readRule = (stem: string): string | null => {
|
|
130
|
+
try {
|
|
131
|
+
return fs.readFileSync(path.join(rulesDir, `${stem}.md`), "utf8")
|
|
132
|
+
} catch {
|
|
133
|
+
return null
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
await ctx.session.hook("context", async (event: unknown) => {
|
|
138
|
+
try {
|
|
139
|
+
const record = recordOf(event)
|
|
140
|
+
const sessionID = typeof record.sessionID === "string" ? record.sessionID : "session"
|
|
141
|
+
const paths = touchedPaths(record.messages, projectRoot)
|
|
142
|
+
if (paths.length === 0) return
|
|
143
|
+
const already = attached.get(sessionID) ?? new Set<string>()
|
|
144
|
+
const plan = planAttachment({
|
|
145
|
+
paths,
|
|
146
|
+
catalog,
|
|
147
|
+
attached: already,
|
|
148
|
+
readRule,
|
|
149
|
+
})
|
|
150
|
+
const fresh = plan.inject.filter((entry) => !carries(record.messages, entry.stem))
|
|
151
|
+
if (fresh.length === 0) return
|
|
152
|
+
for (const entry of fresh) already.add(entry.stem)
|
|
153
|
+
attached.set(sessionID, already)
|
|
154
|
+
const messages = record.messages
|
|
155
|
+
if (!Array.isArray(messages)) return
|
|
156
|
+
messages.push({
|
|
157
|
+
role: "user",
|
|
158
|
+
content: [{ type: "text", text: fresh.map((entry) => entry.text).join("\n") }],
|
|
159
|
+
})
|
|
160
|
+
debugLog(projectRoot, `attached ${fresh.map((entry) => entry.stem).join(",")} (session ${sessionID})`)
|
|
161
|
+
} catch (error) {
|
|
162
|
+
debugLog(projectRoot, `attach failed: ${error instanceof Error ? error.message : String(error)}`)
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
} catch {
|
|
166
|
+
/* a host that rejects the hook names keeps working without attach */
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Settings guard (OpenCode plugin)
|
|
2
|
+
|
|
3
|
+
Applies `.ai.local/.env` on OpenCode. The static `permission.bash` rows stay the floor. A configured `deny`, including the `task-evil` agent, is final and this plugin never sees it.
|
|
4
|
+
|
|
5
|
+
## Git writes — `AI_RULES_ALLOW_GIT_WRITES`
|
|
6
|
+
|
|
7
|
+
The plugin imports `evaluate` from `.opencode/hooks/guard-shell-command.mjs`.
|
|
8
|
+
|
|
9
|
+
| Guard verdict | Permission hook | Tool hook, only when the permission hook is absent |
|
|
10
|
+
|---|---|---|
|
|
11
|
+
| `allow` on a plain `git commit` / `git push` | effect `allow` (the static ask is lifted) | no throw; the static ask remains |
|
|
12
|
+
| `ask` | effect `ask`, with the guard's message | throw, so the command does not run |
|
|
13
|
+
| `allow` on anything else | unchanged | unchanged |
|
|
14
|
+
|
|
15
|
+
`false`, a missing file, and a broken file stay `ask`. `true` allows only a plain commit or push. Destructive, alias, and indirect shapes stay `ask`.
|
|
16
|
+
|
|
17
|
+
## Autoroute — `AI_RULES_AUTOROUTE_UNCHAINED_PROMPTS`
|
|
18
|
+
|
|
19
|
+
The `prompt` session hook appends the same directive as Claude's `UserPromptSubmit` when the flag is `true` and the live-slug count is below `AI_RULES_MAX_PARALLEL_TASKS`. `false` appends nothing. A host that does not dispatch `prompt` leaves the entry-prose check in place.
|
|
20
|
+
|
|
21
|
+
## Files
|
|
22
|
+
|
|
23
|
+
- `index.ts` — host adapter.
|
|
24
|
+
- `policy.mjs` — pure command and prompt shaping. No host import.
|
|
25
|
+
- `prompt-face.mjs` — the shared autoroute evaluator. `generate-opencode` rewrites it from the template.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode settings guard.
|
|
3
|
+
*
|
|
4
|
+
* Reads `.ai.local/.env` through the shared shell guard and the prompt face.
|
|
5
|
+
* `ctx.permission.hook("evaluate")` maps the guard's `allow` / `ask` onto the
|
|
6
|
+
* permission effect, so a plain commit or push is allowed only when the git-write
|
|
7
|
+
* flag is on. A configured `deny` never reaches this hook. When the permission
|
|
8
|
+
* hook is missing, `ctx.tool.hook("execute.before")` throws on `ask`, which
|
|
9
|
+
* stops the command. The `prompt` session hook appends the autoroute directive
|
|
10
|
+
* when that flag is on and the live-slug cap allows it.
|
|
11
|
+
*
|
|
12
|
+
* A host without these hooks no-ops. The static `permission.bash` rows stay the floor.
|
|
13
|
+
*/
|
|
14
|
+
import path from "node:path"
|
|
15
|
+
import { fileURLToPath, pathToFileURL } from "node:url"
|
|
16
|
+
import { Plugin } from "@opencode/plugin"
|
|
17
|
+
import {
|
|
18
|
+
appendPromptContext,
|
|
19
|
+
commandFromPermission,
|
|
20
|
+
commandFromTool,
|
|
21
|
+
promptText,
|
|
22
|
+
shouldApply,
|
|
23
|
+
} from "./policy.mjs"
|
|
24
|
+
|
|
25
|
+
type GuardDecision = { permission: string; user_message?: string; agent_message?: string }
|
|
26
|
+
type Evaluate = (event: unknown, options: { root: string }) => Promise<GuardDecision | null>
|
|
27
|
+
|
|
28
|
+
const recordOf = (value: unknown): Record<string, unknown> =>
|
|
29
|
+
value !== null && typeof value === "object" ? (value as Record<string, unknown>) : {}
|
|
30
|
+
|
|
31
|
+
const importEvaluate = async (file: string): Promise<Evaluate | null> => {
|
|
32
|
+
try {
|
|
33
|
+
const loaded = (await import(pathToFileURL(file).href)) as { evaluate?: Evaluate }
|
|
34
|
+
return typeof loaded.evaluate === "function" ? loaded.evaluate : null
|
|
35
|
+
} catch {
|
|
36
|
+
return null
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default Plugin.define({
|
|
41
|
+
id: "ai-rules.settings-guard",
|
|
42
|
+
async setup(ctx) {
|
|
43
|
+
try {
|
|
44
|
+
const projectRoot = path.resolve(ctx.location.directory)
|
|
45
|
+
const guard = await importEvaluate(
|
|
46
|
+
path.join(projectRoot, ".opencode", "hooks", "guard-shell-command.mjs"),
|
|
47
|
+
)
|
|
48
|
+
const promptFace = await importEvaluate(path.join(path.dirname(fileURLToPath(import.meta.url)), "prompt-face.mjs"))
|
|
49
|
+
|
|
50
|
+
const shellDecision = async (command: string): Promise<GuardDecision | null> => {
|
|
51
|
+
if (guard === null) return null
|
|
52
|
+
try {
|
|
53
|
+
const decision = await guard({ command }, { root: projectRoot })
|
|
54
|
+
return decision && typeof decision.permission === "string" ? decision : null
|
|
55
|
+
} catch {
|
|
56
|
+
return null
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let permissionBound = false
|
|
61
|
+
const permission = recordOf(ctx.permission)
|
|
62
|
+
if (typeof permission.hook === "function" && guard !== null) {
|
|
63
|
+
try {
|
|
64
|
+
await permission.hook("evaluate", async (event: unknown) => {
|
|
65
|
+
const command = commandFromPermission(event)
|
|
66
|
+
if (command === null) return
|
|
67
|
+
const decision = await shellDecision(command)
|
|
68
|
+
if (decision === null || !shouldApply(command, decision.permission)) return
|
|
69
|
+
const record = recordOf(event)
|
|
70
|
+
record.effect = decision.permission
|
|
71
|
+
if (decision.permission === "ask") {
|
|
72
|
+
const message = decision.user_message || decision.agent_message
|
|
73
|
+
if (message) record.message = message
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
permissionBound = true
|
|
77
|
+
} catch {
|
|
78
|
+
permissionBound = false
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const tool = recordOf(ctx.tool)
|
|
83
|
+
if (!permissionBound && typeof tool.hook === "function" && guard !== null) {
|
|
84
|
+
try {
|
|
85
|
+
await tool.hook("execute.before", async (event: unknown, output: unknown) => {
|
|
86
|
+
const command = commandFromTool(event, output)
|
|
87
|
+
if (command === null) return
|
|
88
|
+
const decision = await shellDecision(command)
|
|
89
|
+
if (decision === null || decision.permission !== "ask" || !shouldApply(command, "ask")) return
|
|
90
|
+
throw new Error(decision.user_message || decision.agent_message || "blocked by the shell guard")
|
|
91
|
+
})
|
|
92
|
+
} catch {
|
|
93
|
+
/* a host that rejects the hook name keeps the static permission floor */
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const session = recordOf(ctx.session)
|
|
98
|
+
if (typeof session.hook === "function" && promptFace !== null) {
|
|
99
|
+
try {
|
|
100
|
+
await session.hook("prompt", async (event: unknown) => {
|
|
101
|
+
const envelope = await promptFace({ prompt: promptText(event) }, { root: projectRoot })
|
|
102
|
+
const output = recordOf(recordOf(envelope).hookSpecificOutput)
|
|
103
|
+
const text = typeof output.additionalContext === "string" ? output.additionalContext : ""
|
|
104
|
+
if (text !== "") appendPromptContext(event, text)
|
|
105
|
+
})
|
|
106
|
+
} catch {
|
|
107
|
+
/* autoroute stays off when the prompt hook is rejected */
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} catch {
|
|
111
|
+
/* the static permission rows remain the floor */
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
})
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure decisions for the OpenCode settings guard. No host import.
|
|
3
|
+
*
|
|
4
|
+
* `ask` from the shell guard always applies. `allow` applies only to a git
|
|
5
|
+
* commit or push the guard already classified as plain, so a user's other
|
|
6
|
+
* ask rules are left alone.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const SHELL_TOOLS = new Set(['bash', 'shell', 'sh']);
|
|
10
|
+
|
|
11
|
+
const recordOf = (value) =>
|
|
12
|
+
value !== null && typeof value === 'object' ? value : {};
|
|
13
|
+
|
|
14
|
+
export const shouldApply = (command, permission) => {
|
|
15
|
+
if (permission === 'ask') return true;
|
|
16
|
+
if (permission !== 'allow') return false;
|
|
17
|
+
return /\bgit\b/.test(command) && /\b(?:commit|push)\b/.test(command);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const firstText = (values) => {
|
|
21
|
+
if (!Array.isArray(values)) return null;
|
|
22
|
+
const found = values.find((item) => typeof item === 'string' && item.trim() !== '');
|
|
23
|
+
return typeof found === 'string' ? found : null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** The shell command on a permission-evaluate event, or null when it is not a shell check. */
|
|
27
|
+
export const commandFromPermission = (event) => {
|
|
28
|
+
const record = recordOf(event);
|
|
29
|
+
const action = typeof record.action === 'string' ? record.action : '';
|
|
30
|
+
if (action !== '' && action !== 'shell' && action !== 'bash') return null;
|
|
31
|
+
const fromResources = firstText(record.resources);
|
|
32
|
+
if (fromResources !== null) return fromResources;
|
|
33
|
+
const metadata = recordOf(record.metadata);
|
|
34
|
+
if (typeof metadata.command === 'string' && metadata.command.trim() !== '') return metadata.command;
|
|
35
|
+
const input = recordOf(record.input);
|
|
36
|
+
if (typeof input.command === 'string' && input.command.trim() !== '') return input.command;
|
|
37
|
+
return null;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The shell command on a tool-execute event. `output` is the v1 second argument
|
|
42
|
+
* (`{ args: { command } }`); v2 carries the command on `event.input.command`.
|
|
43
|
+
*/
|
|
44
|
+
export const commandFromTool = (event, output) => {
|
|
45
|
+
const record = recordOf(event);
|
|
46
|
+
const tool = typeof record.tool === 'string' ? record.tool : '';
|
|
47
|
+
if (!SHELL_TOOLS.has(tool)) return null;
|
|
48
|
+
const input = recordOf(record.input);
|
|
49
|
+
if (typeof input.command === 'string') return input.command;
|
|
50
|
+
const args = recordOf(recordOf(output).args);
|
|
51
|
+
if (typeof args.command === 'string') return args.command;
|
|
52
|
+
const nested = recordOf(recordOf(record.output).args);
|
|
53
|
+
if (typeof nested.command === 'string') return nested.command;
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** The user prompt text, from `prompt` or from text parts. */
|
|
58
|
+
export const promptText = (event) => {
|
|
59
|
+
const record = recordOf(event);
|
|
60
|
+
if (typeof record.prompt === 'string') return record.prompt;
|
|
61
|
+
if (!Array.isArray(record.parts)) return '';
|
|
62
|
+
return record.parts
|
|
63
|
+
.map((part) => (typeof recordOf(part).text === 'string' ? recordOf(part).text : ''))
|
|
64
|
+
.filter((text) => text !== '')
|
|
65
|
+
.join('\n');
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Append the autoroute directive. A `parts` array gains a text part; a string
|
|
70
|
+
* `prompt` is extended. Any other shape is left untouched.
|
|
71
|
+
*
|
|
72
|
+
* @returns {boolean} whether the event was changed
|
|
73
|
+
*/
|
|
74
|
+
export const appendPromptContext = (event, text) => {
|
|
75
|
+
const record = recordOf(event);
|
|
76
|
+
if (Array.isArray(record.parts)) {
|
|
77
|
+
record.parts.push({ type: 'text', text });
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
if (typeof record.prompt === 'string') {
|
|
81
|
+
record.prompt = record.prompt.trim() === '' ? text : `${record.prompt}\n\n${text}`;
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
};
|