@bonesofspring/ai-rules 0.2.87 → 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 +50 -0
- package/README.md +9 -1
- package/bin/lib/engine-scripts.js +7 -0
- package/bin/lib/seed-ai-local-team.js +40 -0
- package/bin/opencode-install.js +11 -10
- package/docs/OPENCODE.md +8 -4
- package/docs/openapi/team-db.v1.json +2 -2
- package/package.json +1 -1
- package/presets/_shared/ai-local/env.example +54 -0
- package/presets/_shared/ai-local/scripts/aggregate-agent-task-metrics.mjs +34 -5
- package/presets/_shared/ai-local/scripts/check-task-repositories.mjs +25 -22
- package/presets/_shared/ai-local/scripts/process-lease.mjs +3 -2
- package/presets/_shared/ai-local/scripts/processes.mjs +52 -20
- package/presets/_shared/ai-local/scripts/run.mjs +38 -6
- package/presets/_shared/ai-local/scripts/settings.mjs +246 -0
- package/presets/_shared/ai-local/scripts/task-worktree.mjs +364 -0
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +2 -2
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +87 -14
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +102 -12
- package/presets/_shared/ai-local/scripts/team-db-tracker.mjs +35 -0
- package/presets/_shared/ai-local/scripts/tracker-planned-drain.mjs +10 -1
- package/presets/_shared/ai-local/scripts/verification.mjs +106 -11
- package/presets/_shared/core/agent-team/agent-task-metrics.md +10 -2
- package/presets/_shared/core/agent-team/agent-team-intake.md +2 -0
- package/presets/_shared/core/agent-team/agent-team-orchestrator.md +2 -2
- package/presets/_shared/core/meta/preset-writing-style.md +8 -0
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +541 -61
- package/presets/_shared/hooks/guard-shell-command.mjs.tmpl +733 -9
- package/presets/_shared/hooks/prompt-autoroute.mjs.tmpl +153 -0
- package/presets/claude/android-kotlin/CLAUDE.md +2 -4
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/android-kotlin/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/android-kotlin/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/android-kotlin/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/android-kotlin/settings.json +15 -5
- package/presets/claude/go/CLAUDE.md +2 -4
- package/presets/claude/go/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/go/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/go/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/go/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/go/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/go/settings.json +15 -5
- package/presets/claude/ios-swift/CLAUDE.md +2 -4
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/ios-swift/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/ios-swift/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/ios-swift/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/ios-swift/settings.json +15 -5
- package/presets/claude/java/CLAUDE.md +2 -4
- package/presets/claude/java/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/java/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/java/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/java/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/java/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/java/settings.json +15 -5
- package/presets/claude/mcp-ts/CLAUDE.md +2 -4
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/mcp-ts/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/mcp-ts/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/mcp-ts/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/mcp-ts/settings.json +15 -5
- package/presets/claude/mol/CLAUDE.md +2 -4
- package/presets/claude/mol/agents/feature-developer.md +1 -1
- package/presets/claude/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/claude/mol/commands/task-evil.md +8 -0
- package/presets/claude/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/mol/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/mol/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/mol/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/mol/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/mol/settings.json +15 -4
- package/presets/claude/next/CLAUDE.md +2 -4
- package/presets/claude/next/REPO_AGENTS.md +2 -0
- package/presets/claude/next/agents/feature-developer.md +1 -1
- package/presets/claude/next/agents/task-analyst.md +1 -7
- package/presets/claude/next/agents/task-router.md +1 -1
- package/presets/claude/next/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/claude/next/commands/spec-start.md +3 -4
- package/presets/claude/next/commands/task-continue.md +9 -8
- package/presets/claude/next/commands/task-evil.md +8 -0
- package/presets/claude/next/commands/task.md +1 -1
- package/presets/claude/next/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/next/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/next/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/next/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/next/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/next/settings.json +15 -4
- package/presets/claude/next/team/README.md +1 -1
- package/presets/claude/nuxt/CLAUDE.md +2 -4
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/nuxt/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/nuxt/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/nuxt/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/nuxt/settings.json +15 -4
- package/presets/claude/php-hexagonal/CLAUDE.md +2 -4
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/php-hexagonal/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/php-hexagonal/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/php-hexagonal/settings.json +15 -5
- package/presets/claude/php-laravel/CLAUDE.md +2 -4
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/php-laravel/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/php-laravel/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/php-laravel/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/php-laravel/settings.json +15 -5
- package/presets/claude/svelte/CLAUDE.md +2 -4
- package/presets/claude/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/claude/svelte/hooks/guard-shell-command.mjs +733 -9
- package/presets/claude/svelte/hooks/prompt-autoroute.mjs +153 -0
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-intake.md +2 -0
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +2 -2
- package/presets/claude/svelte/rules/tooling-and-review/preset-writing-style.md +8 -0
- package/presets/claude/svelte/settings.json +15 -4
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/android-kotlin/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/android-kotlin/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/android-kotlin/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/go/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/go/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/go/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/go/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/go/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/ios-swift/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/ios-swift/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/ios-swift/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/java/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/java/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/java/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/java/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/java/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/mcp-ts/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/mcp-ts/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mcp-ts/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/mol/agents/feature-developer.md +1 -1
- package/presets/cursor/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/cursor/mol/commands/task-evil.md +8 -0
- package/presets/cursor/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/mol/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/mol/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mol/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/next/REPO_AGENTS.md +2 -0
- package/presets/cursor/next/agents/feature-developer.md +1 -1
- package/presets/cursor/next/agents/task-analyst.md +1 -7
- package/presets/cursor/next/agents/task-router.md +1 -1
- package/presets/cursor/next/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/cursor/next/commands/spec-start.md +3 -4
- package/presets/cursor/next/commands/task-continue.md +9 -8
- package/presets/cursor/next/commands/task-evil.md +8 -0
- package/presets/cursor/next/commands/task.md +1 -1
- package/presets/cursor/next/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/next/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/next/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/next/rules/agent-team-orchestrator.mdc +2 -2
- package/presets/cursor/next/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/next/team/README.md +1 -1
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/nuxt/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/nuxt/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/nuxt/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/php-hexagonal/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/php-hexagonal/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-hexagonal/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/php-laravel/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/php-laravel/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-laravel/rules/preset-writing-style.mdc +8 -0
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/cursor/svelte/hooks/guard-shell-command.mjs +733 -9
- package/presets/cursor/svelte/rules/agent-team-intake.mdc +2 -0
- package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/svelte/rules/preset-writing-style.mdc +8 -0
- package/presets/mavis/android-kotlin/MAVIS.md +1 -1
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/android-kotlin/rules/agent-team-intake.md +2 -0
- package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/android-kotlin/rules/preset-writing-style.md +8 -0
- package/presets/mavis/go/MAVIS.md +1 -1
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/go/rules/agent-team-intake.md +2 -0
- package/presets/mavis/go/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/go/rules/preset-writing-style.md +8 -0
- package/presets/mavis/ios-swift/MAVIS.md +1 -1
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/ios-swift/rules/agent-team-intake.md +2 -0
- package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/ios-swift/rules/preset-writing-style.md +8 -0
- package/presets/mavis/java/MAVIS.md +1 -1
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/java/rules/agent-team-intake.md +2 -0
- package/presets/mavis/java/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/java/rules/preset-writing-style.md +8 -0
- package/presets/mavis/mcp-ts/MAVIS.md +1 -1
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/mcp-ts/rules/agent-team-intake.md +2 -0
- package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/mcp-ts/rules/preset-writing-style.md +8 -0
- package/presets/mavis/mol/MAVIS.md +1 -1
- package/presets/mavis/mol/adapter-map.json +1 -1
- package/presets/mavis/mol/agents/feature-developer.md +1 -1
- package/presets/mavis/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/mavis/mol/commands/task-evil.md +8 -0
- package/presets/mavis/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/mol/native-skills/task-evil/SKILL.md +8 -0
- package/presets/mavis/mol/rules/agent-team-intake.md +2 -0
- package/presets/mavis/mol/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/mol/rules/preset-writing-style.md +8 -0
- package/presets/mavis/next/MAVIS.md +1 -1
- package/presets/mavis/next/REPO_AGENTS.md +2 -0
- package/presets/mavis/next/adapter-map.json +1 -1
- package/presets/mavis/next/agents/feature-developer.md +1 -1
- package/presets/mavis/next/agents/task-analyst.md +1 -7
- package/presets/mavis/next/agents/task-router.md +1 -1
- package/presets/mavis/next/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/mavis/next/commands/spec-start.md +3 -4
- package/presets/mavis/next/commands/task-continue.md +9 -8
- package/presets/mavis/next/commands/task-evil.md +8 -0
- package/presets/mavis/next/commands/task.md +1 -1
- package/presets/mavis/next/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/next/native-skills/spec-start/SKILL.md +3 -4
- package/presets/mavis/next/native-skills/task/SKILL.md +1 -1
- package/presets/mavis/next/native-skills/task-continue/SKILL.md +9 -8
- package/presets/mavis/next/native-skills/task-evil/SKILL.md +8 -0
- package/presets/mavis/next/rules/agent-team-intake.md +2 -0
- package/presets/mavis/next/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/next/rules/preset-writing-style.md +8 -0
- package/presets/mavis/next/team/README.md +1 -1
- package/presets/mavis/nuxt/MAVIS.md +1 -1
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/nuxt/rules/agent-team-intake.md +2 -0
- package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/nuxt/rules/preset-writing-style.md +8 -0
- package/presets/mavis/php-hexagonal/MAVIS.md +1 -1
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/php-hexagonal/rules/agent-team-intake.md +2 -0
- package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/php-hexagonal/rules/preset-writing-style.md +8 -0
- package/presets/mavis/php-laravel/MAVIS.md +1 -1
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/php-laravel/rules/agent-team-intake.md +2 -0
- package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/php-laravel/rules/preset-writing-style.md +8 -0
- package/presets/mavis/svelte/MAVIS.md +1 -1
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/mavis/svelte/rules/agent-team-intake.md +2 -0
- package/presets/mavis/svelte/rules/agent-team-orchestrator.md +2 -2
- package/presets/mavis/svelte/rules/preset-writing-style.md +8 -0
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/hooks/README.md +6 -5
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/android-kotlin/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/android-kotlin/opencode.json +4 -4
- package/presets/opencode/android-kotlin/rules/agent-team-intake.md +2 -0
- package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/android-kotlin/rules/preset-writing-style.md +8 -0
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/hooks/README.md +6 -5
- package/presets/opencode/go/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/go/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/go/opencode.json +4 -4
- package/presets/opencode/go/rules/agent-team-intake.md +2 -0
- package/presets/opencode/go/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/go/rules/preset-writing-style.md +8 -0
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/hooks/README.md +6 -5
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/ios-swift/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/ios-swift/opencode.json +4 -4
- package/presets/opencode/ios-swift/rules/agent-team-intake.md +2 -0
- package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/ios-swift/rules/preset-writing-style.md +8 -0
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/hooks/README.md +6 -5
- package/presets/opencode/java/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/java/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/java/opencode.json +4 -4
- package/presets/opencode/java/rules/agent-team-intake.md +2 -0
- package/presets/opencode/java/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/java/rules/preset-writing-style.md +8 -0
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- package/presets/opencode/mcp-ts/hooks/README.md +6 -5
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/mcp-ts/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/mcp-ts/opencode.json +4 -4
- package/presets/opencode/mcp-ts/rules/agent-team-intake.md +2 -0
- package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/mcp-ts/rules/preset-writing-style.md +8 -0
- package/presets/opencode/mol/adapter-map.json +1 -1
- package/presets/opencode/mol/agents/feature-developer.md +1 -1
- package/presets/opencode/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/opencode/mol/commands/task-evil.md +8 -0
- package/presets/opencode/mol/hooks/README.md +6 -5
- package/presets/opencode/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/mol/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/mol/opencode.json +4 -4
- package/presets/opencode/mol/rules/agent-team-intake.md +2 -0
- package/presets/opencode/mol/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/mol/rules/preset-writing-style.md +8 -0
- package/presets/opencode/next/REPO_AGENTS.md +2 -0
- package/presets/opencode/next/adapter-map.json +1 -1
- package/presets/opencode/next/agents/feature-developer.md +1 -1
- package/presets/opencode/next/agents/task-analyst.md +1 -7
- package/presets/opencode/next/agents/task-router.md +1 -1
- package/presets/opencode/next/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/opencode/next/commands/spec-start.md +3 -4
- package/presets/opencode/next/commands/task-continue.md +9 -8
- package/presets/opencode/next/commands/task-evil.md +8 -0
- package/presets/opencode/next/commands/task.md +1 -1
- package/presets/opencode/next/hooks/README.md +6 -5
- package/presets/opencode/next/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/next/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/next/opencode.json +4 -4
- package/presets/opencode/next/rules/agent-team-intake.md +2 -0
- package/presets/opencode/next/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/next/rules/preset-writing-style.md +8 -0
- package/presets/opencode/next/team/README.md +1 -1
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/hooks/README.md +6 -5
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/nuxt/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/nuxt/opencode.json +4 -4
- package/presets/opencode/nuxt/rules/agent-team-intake.md +2 -0
- package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/nuxt/rules/preset-writing-style.md +8 -0
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/hooks/README.md +6 -5
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/php-hexagonal/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/php-hexagonal/opencode.json +4 -4
- package/presets/opencode/php-hexagonal/rules/agent-team-intake.md +2 -0
- package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/php-hexagonal/rules/preset-writing-style.md +8 -0
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/hooks/README.md +6 -5
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/php-laravel/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/php-laravel/opencode.json +4 -4
- package/presets/opencode/php-laravel/rules/agent-team-intake.md +2 -0
- package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/php-laravel/rules/preset-writing-style.md +8 -0
- package/presets/opencode/plugins/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/adapter-map.json +1 -1
- package/presets/opencode/svelte/hooks/README.md +6 -5
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/opencode/svelte/hooks/guard-shell-command.mjs +733 -9
- package/presets/opencode/svelte/opencode.json +4 -4
- package/presets/opencode/svelte/rules/agent-team-intake.md +2 -0
- package/presets/opencode/svelte/rules/agent-team-orchestrator.md +2 -2
- package/presets/opencode/svelte/rules/preset-writing-style.md +8 -0
- package/presets/zcode/android-kotlin/adapter-map.json +1 -1
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/android-kotlin/rules/agent-team-intake.md +2 -0
- package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/android-kotlin/rules/preset-writing-style.md +8 -0
- package/presets/zcode/go/adapter-map.json +1 -1
- package/presets/zcode/go/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/go/rules/agent-team-intake.md +2 -0
- package/presets/zcode/go/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/go/rules/preset-writing-style.md +8 -0
- package/presets/zcode/ios-swift/adapter-map.json +1 -1
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/ios-swift/rules/agent-team-intake.md +2 -0
- package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/ios-swift/rules/preset-writing-style.md +8 -0
- package/presets/zcode/java/adapter-map.json +1 -1
- package/presets/zcode/java/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/java/rules/agent-team-intake.md +2 -0
- package/presets/zcode/java/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/java/rules/preset-writing-style.md +8 -0
- package/presets/zcode/mcp-ts/adapter-map.json +1 -1
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/mcp-ts/rules/agent-team-intake.md +2 -0
- package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/mcp-ts/rules/preset-writing-style.md +8 -0
- package/presets/zcode/mol/adapter-map.json +1 -1
- package/presets/zcode/mol/agents/feature-developer.md +1 -1
- package/presets/zcode/mol/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/zcode/mol/commands/task-evil.md +8 -0
- package/presets/zcode/mol/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/mol/rules/agent-team-intake.md +2 -0
- package/presets/zcode/mol/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/mol/rules/preset-writing-style.md +8 -0
- package/presets/zcode/next/REPO_AGENTS.md +2 -0
- package/presets/zcode/next/adapter-map.json +1 -1
- package/presets/zcode/next/agents/feature-developer.md +1 -1
- package/presets/zcode/next/agents/task-analyst.md +1 -7
- package/presets/zcode/next/agents/task-router.md +1 -1
- package/presets/zcode/next/ai-local/rules-library/commit-hygiene.md +1 -1
- package/presets/zcode/next/commands/spec-start.md +3 -4
- package/presets/zcode/next/commands/task-continue.md +9 -8
- package/presets/zcode/next/commands/task-evil.md +8 -0
- package/presets/zcode/next/commands/task.md +1 -1
- package/presets/zcode/next/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/next/rules/agent-team-intake.md +2 -0
- package/presets/zcode/next/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/next/rules/preset-writing-style.md +8 -0
- package/presets/zcode/next/team/README.md +1 -1
- package/presets/zcode/nuxt/adapter-map.json +1 -1
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/nuxt/rules/agent-team-intake.md +2 -0
- package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/nuxt/rules/preset-writing-style.md +8 -0
- package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/php-hexagonal/rules/agent-team-intake.md +2 -0
- package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/php-hexagonal/rules/preset-writing-style.md +8 -0
- package/presets/zcode/php-laravel/adapter-map.json +1 -1
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/php-laravel/rules/agent-team-intake.md +2 -0
- package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/php-laravel/rules/preset-writing-style.md +8 -0
- package/presets/zcode/svelte/adapter-map.json +1 -1
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +541 -61
- package/presets/zcode/svelte/rules/agent-team-intake.md +2 -0
- package/presets/zcode/svelte/rules/agent-team-orchestrator.md +2 -2
- package/presets/zcode/svelte/rules/preset-writing-style.md +8 -0
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* [--allow-unlocked] [--json] [--root <dir>]
|
|
8
8
|
* release --name <res> --token <t> [--root <dir>] [--json]
|
|
9
9
|
* run --name <res> [acquire flags] -- <command> [args…]
|
|
10
|
-
* list [--json] [--task <slug>] [--live] [--root <dir>]
|
|
10
|
+
* list [--json] [--name <res>] [--task <slug>] [--live] [--root <dir>]
|
|
11
11
|
* status --name <res> [--json]
|
|
12
12
|
* watch [--interval 1s] [--json] [--once] [--no-color]
|
|
13
13
|
* scan [--json] [--known-only | --all]
|
|
@@ -98,7 +98,7 @@ const VERB_FLAGS = {
|
|
|
98
98
|
'name', 'kind', 'port', 'label', 'task', 'agent', 'wait', 'ttl', 'allow-unlocked',
|
|
99
99
|
'root', 'pid', 'token', 'cwd', 'command',
|
|
100
100
|
]),
|
|
101
|
-
list: new Set(['json', 'root', 'task', 'live']),
|
|
101
|
+
list: new Set(['json', 'root', 'task', 'live', 'name']),
|
|
102
102
|
status: new Set(['name', 'json', 'root']),
|
|
103
103
|
watch: new Set(['interval', 'json', 'once', 'no-color', 'root', 'task']),
|
|
104
104
|
scan: new Set(['json', 'known-only', 'all', 'root']),
|
|
@@ -771,12 +771,15 @@ export function buildSnapshot(roots) {
|
|
|
771
771
|
}
|
|
772
772
|
|
|
773
773
|
const filterSnapshot = (snapshot, flags) => {
|
|
774
|
-
if (!flags.task && !flags.live) return snapshot;
|
|
774
|
+
if (!flags.task && !flags.live && !flags.name) return snapshot;
|
|
775
775
|
return {
|
|
776
776
|
...snapshot,
|
|
777
|
-
processes: snapshot.processes.filter(
|
|
778
|
-
|
|
779
|
-
|
|
777
|
+
processes: snapshot.processes.filter((item) => {
|
|
778
|
+
if (flags.task && item.task !== flags.task) return false;
|
|
779
|
+
if (flags.live && item.state !== 'live') return false;
|
|
780
|
+
if (flags.name && item.name !== flags.name && !item.name.startsWith(`${flags.name}#`)) return false;
|
|
781
|
+
return true;
|
|
782
|
+
}),
|
|
780
783
|
};
|
|
781
784
|
};
|
|
782
785
|
|
|
@@ -927,7 +930,7 @@ const parseFlags = (verb, argv) => {
|
|
|
927
930
|
const requireName = (flags) => {
|
|
928
931
|
if (!flags.name) fail('--name is required');
|
|
929
932
|
if (!isValidLeaseName(flags.name)) {
|
|
930
|
-
fail(`--name must be a lowercase resource name (a-z, 0-9, ".", "_", "-"), got "${flags.name}"`);
|
|
933
|
+
fail(`--name must be a lowercase resource name (a-z, 0-9, ".", "_", "#", "-"), got "${flags.name}"`);
|
|
931
934
|
}
|
|
932
935
|
return flags.name;
|
|
933
936
|
};
|
|
@@ -981,11 +984,32 @@ const requireLiveOwner = (flags, fallback) => {
|
|
|
981
984
|
return pid;
|
|
982
985
|
};
|
|
983
986
|
|
|
984
|
-
|
|
987
|
+
/**
|
|
988
|
+
* `start` / `run` / `acquire` with `--task <slug>` record `leases/<name>#<slug>.json`.
|
|
989
|
+
* The JSON `name` stays the requested resource; `owner.task` stays the slug.
|
|
990
|
+
*/
|
|
991
|
+
const leaseIdentity = (flags) => {
|
|
992
|
+
const requested = requireName(flags);
|
|
993
|
+
const task = typeof flags.task === 'string' ? flags.task : '';
|
|
994
|
+
if (task === '') return { requested, effective: requested };
|
|
995
|
+
const effective = `${requested}#${task}`;
|
|
996
|
+
if (!isValidLeaseName(effective)) {
|
|
997
|
+
fail(`effective lease name "${effective}" must be a lowercase lease name of at most 64 characters`);
|
|
998
|
+
}
|
|
999
|
+
return { requested, effective };
|
|
1000
|
+
};
|
|
1001
|
+
|
|
1002
|
+
const namesMatching = (aiLocalRoot, requested) =>
|
|
1003
|
+
listLeases(aiLocalRoot)
|
|
1004
|
+
.map((entry) => entry.name)
|
|
1005
|
+
.filter((name) => name === requested || name.startsWith(`${requested}#`));
|
|
1006
|
+
|
|
1007
|
+
const leaseOptions = (flags, roots, identity, pid) => {
|
|
985
1008
|
const port = parsePort(flags, null);
|
|
986
1009
|
return {
|
|
987
1010
|
aiLocalRoot: roots.aiLocalRoot,
|
|
988
|
-
name,
|
|
1011
|
+
name: identity.effective,
|
|
1012
|
+
storedName: identity.requested,
|
|
989
1013
|
kind: flags.kind ? parseKind(flags) : port === null ? 'exclusive' : 'port',
|
|
990
1014
|
port,
|
|
991
1015
|
label: flags.label ?? null,
|
|
@@ -1018,8 +1042,8 @@ const describeAcquire = (result) => {
|
|
|
1018
1042
|
|
|
1019
1043
|
const acquireVerb = (flags) => {
|
|
1020
1044
|
const roots = resolveRoots(flags);
|
|
1021
|
-
const
|
|
1022
|
-
const result = acquireLease(leaseOptions(flags, roots,
|
|
1045
|
+
const identity = leaseIdentity(flags);
|
|
1046
|
+
const result = acquireLease(leaseOptions(flags, roots, identity, requireLiveOwner(flags, process.ppid)));
|
|
1023
1047
|
if (flags.json) {
|
|
1024
1048
|
out(renderJson(result));
|
|
1025
1049
|
return result.acquired || (result.fatal && result.skipped) ? 0 : result.fatal ? 3 : 1;
|
|
@@ -1064,10 +1088,11 @@ const releaseVerb = (flags) => {
|
|
|
1064
1088
|
const runVerb = async (flags, tail) => {
|
|
1065
1089
|
if (!tail || tail.length === 0) fail('run needs a command after --');
|
|
1066
1090
|
const roots = resolveRoots(flags);
|
|
1067
|
-
const
|
|
1091
|
+
const identity = leaseIdentity(flags);
|
|
1092
|
+
const name = identity.effective;
|
|
1068
1093
|
// `run` owns the lease for the child's lifetime, so the manager — not the
|
|
1069
1094
|
// parent shell — is the recorded holder.
|
|
1070
|
-
const options = leaseOptions(flags, roots,
|
|
1095
|
+
const options = leaseOptions(flags, roots, identity, flags.pid ? positiveInt(flags.pid, '--pid') : process.pid);
|
|
1071
1096
|
const command = flags.command ?? tail.join(' ');
|
|
1072
1097
|
const acquired = acquireLease({ ...options, command });
|
|
1073
1098
|
if (!acquired.acquired) {
|
|
@@ -1161,6 +1186,7 @@ const runVerb = async (flags, tail) => {
|
|
|
1161
1186
|
|
|
1162
1187
|
const listVerb = (flags) => {
|
|
1163
1188
|
const roots = resolveRoots(flags);
|
|
1189
|
+
if (flags.name) requireName(flags);
|
|
1164
1190
|
const snapshot = filterSnapshot(buildSnapshot(roots), flags);
|
|
1165
1191
|
if (flags.json) {
|
|
1166
1192
|
out(renderJson(snapshot));
|
|
@@ -1172,14 +1198,16 @@ const listVerb = (flags) => {
|
|
|
1172
1198
|
|
|
1173
1199
|
const statusVerb = (flags) => {
|
|
1174
1200
|
const roots = resolveRoots(flags);
|
|
1175
|
-
const
|
|
1201
|
+
const requested = requireName(flags);
|
|
1202
|
+
const matched = namesMatching(roots.aiLocalRoot, requested);
|
|
1203
|
+
const name = matched.includes(requested) || matched.length !== 1 ? requested : matched[0];
|
|
1176
1204
|
const record = readLease(roots.aiLocalRoot, name);
|
|
1177
1205
|
const state = record === null ? null : leaseState(record);
|
|
1178
1206
|
const payload = {
|
|
1179
1207
|
schemaVersion: SNAPSHOT_SCHEMA_VERSION,
|
|
1180
1208
|
generatedAt: new Date().toISOString(),
|
|
1181
1209
|
root: roots.repoRoot,
|
|
1182
|
-
name,
|
|
1210
|
+
name: requested,
|
|
1183
1211
|
path: leasePath(roots.aiLocalRoot, name),
|
|
1184
1212
|
present: record !== null,
|
|
1185
1213
|
state: state?.state ?? 'absent',
|
|
@@ -1191,10 +1219,10 @@ const statusVerb = (flags) => {
|
|
|
1191
1219
|
return 0;
|
|
1192
1220
|
}
|
|
1193
1221
|
if (record === null) {
|
|
1194
|
-
out(`processes: ${
|
|
1222
|
+
out(`processes: ${requested} is not recorded`);
|
|
1195
1223
|
return 0;
|
|
1196
1224
|
}
|
|
1197
|
-
out(`processes: ${
|
|
1225
|
+
out(`processes: ${requested} is ${payload.state} (${payload.why}), pid ${payload.owner?.pid ?? '?'}`);
|
|
1198
1226
|
return 0;
|
|
1199
1227
|
};
|
|
1200
1228
|
|
|
@@ -1449,7 +1477,9 @@ const stopVerb = async (flags) => {
|
|
|
1449
1477
|
}
|
|
1450
1478
|
} else {
|
|
1451
1479
|
if (!flags.name) fail('stop needs --name <res> or --task <slug>');
|
|
1452
|
-
|
|
1480
|
+
const requested = requireName(flags);
|
|
1481
|
+
const matched = namesMatching(roots.aiLocalRoot, requested);
|
|
1482
|
+
names.push(...(matched.length > 0 ? matched : [requested]));
|
|
1453
1483
|
}
|
|
1454
1484
|
if (names.length === 0) {
|
|
1455
1485
|
if (flags.json) {
|
|
@@ -1676,7 +1706,8 @@ const terminateDetached = async (pid) => {
|
|
|
1676
1706
|
|
|
1677
1707
|
const startVerb = async (flags) => {
|
|
1678
1708
|
const roots = resolveRoots(flags);
|
|
1679
|
-
const
|
|
1709
|
+
const identity = leaseIdentity(flags);
|
|
1710
|
+
const name = identity.effective;
|
|
1680
1711
|
if (!flags.command) fail('start needs --command');
|
|
1681
1712
|
const port = flags.port === undefined ? 0 : positiveInt(flags.port, '--port', { max: 65535, allowZero: true });
|
|
1682
1713
|
const waitMs = parseReadyWait(flags);
|
|
@@ -1757,6 +1788,7 @@ const startVerb = async (flags) => {
|
|
|
1757
1788
|
const lease = acquireLease({
|
|
1758
1789
|
aiLocalRoot: roots.aiLocalRoot,
|
|
1759
1790
|
name,
|
|
1791
|
+
storedName: identity.requested,
|
|
1760
1792
|
kind: 'port',
|
|
1761
1793
|
port: port > 0 ? port : null,
|
|
1762
1794
|
label: flags.label ?? 'dev-server',
|
|
@@ -1979,7 +2011,7 @@ const USAGE = [
|
|
|
1979
2011
|
' the owner is the parent shell (--pid $$ overrides); use run for a command',
|
|
1980
2012
|
' release --name <res> --token <t> [--root <dir>] [--json]',
|
|
1981
2013
|
' run --name <res> [acquire flags] -- <command> [args…]',
|
|
1982
|
-
' list [--json] [--task <slug>] [--live] [--root <dir>]',
|
|
2014
|
+
' list [--json] [--name <res>] [--task <slug>] [--live] [--root <dir>]',
|
|
1983
2015
|
' status --name <res> [--json] [--root <dir>]',
|
|
1984
2016
|
' watch [--interval 1s] [--json] [--once] [--no-color] [--root <dir>]',
|
|
1985
2017
|
' scan [--json] [--known-only | --all] [--root <dir>]',
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
* 4. print a combined report (derive summary + improver report + a read-only
|
|
10
10
|
* seed-tracker notice when staged seeds ≥ SEED_TRACKER_THRESHOLD).
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
* `
|
|
14
|
-
* `
|
|
12
|
+
* The chain itself is one fail-fast mkdir lock (`.self-learning.lock`,
|
|
13
|
+
* `timeoutMs: 0`). A contender prints the skip line and does not interleave.
|
|
14
|
+
* The loop never writes `status.json` / `metrics.json`; the seed report is
|
|
15
|
+
* read-only over `rules-library/`.
|
|
15
16
|
*
|
|
16
17
|
* Two read-only modes inspect capture without running it:
|
|
17
18
|
* `node run.mjs --status` — per signature: distinct slugs, tier + next
|
|
@@ -47,6 +48,7 @@ import {
|
|
|
47
48
|
} from './rule-improver.mjs';
|
|
48
49
|
import { deriveGateSignals } from './derive-gate-signals.mjs';
|
|
49
50
|
import { MIN_COHORT_SIZE, oracle, readAllTasks } from './efficacy-oracle.mjs';
|
|
51
|
+
import { acquireLock, releaseLock } from './lock.mjs';
|
|
50
52
|
|
|
51
53
|
export const DEFAULT_BASE_DIR = path.join(process.cwd(), '.ai.local');
|
|
52
54
|
export const SEED_TRACKER_THRESHOLD = 20;
|
|
@@ -105,12 +107,42 @@ export function renderReport({ derived, appended, appendErrors, improver, seedCo
|
|
|
105
107
|
return `${lines.join('\n')}\n`;
|
|
106
108
|
}
|
|
107
109
|
|
|
110
|
+
const SELF_LEARNING_LOCK = '.self-learning.lock';
|
|
111
|
+
const SELF_LEARNING_BUSY = 'self-learning loop busy';
|
|
112
|
+
|
|
113
|
+
const skippedLoop = () => ({
|
|
114
|
+
skipped: true,
|
|
115
|
+
reason: SELF_LEARNING_BUSY,
|
|
116
|
+
derived: { signals: [], skipped: [], errors: [] },
|
|
117
|
+
appended: [],
|
|
118
|
+
appendErrors: [],
|
|
119
|
+
improver: { applied: [], staged: [], rejected: [], errors: [], report: '' },
|
|
120
|
+
seedCount: 0,
|
|
121
|
+
report: `WARNING: self-learning loop skipped: ${SELF_LEARNING_BUSY}\n`,
|
|
122
|
+
});
|
|
123
|
+
|
|
108
124
|
/**
|
|
109
|
-
* Run the full loop
|
|
110
|
-
*
|
|
111
|
-
*
|
|
125
|
+
* Run the full loop under one fail-fast lock. Each `appendSignal` and
|
|
126
|
+
* `runImprover` still takes its own lock inside the chain. A contender
|
|
127
|
+
* returns the skip line and does not derive, append, or improve.
|
|
112
128
|
*/
|
|
113
129
|
export function runLoop({ baseDir = DEFAULT_BASE_DIR } = {}) {
|
|
130
|
+
const lockPath = path.join(baseDir, SELF_LEARNING_LOCK);
|
|
131
|
+
let token;
|
|
132
|
+
try {
|
|
133
|
+
token = acquireLock(lockPath, { timeoutMs: 0 });
|
|
134
|
+
} catch (error) {
|
|
135
|
+
if (error instanceof Error && error.message === 'lock timeout') return skippedLoop();
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
return runLoopBody(baseDir);
|
|
140
|
+
} finally {
|
|
141
|
+
releaseLock(lockPath, token);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function runLoopBody(baseDir) {
|
|
114
146
|
const signalsPath = path.join(baseDir, 'signals.jsonl');
|
|
115
147
|
const libraryDir = path.join(baseDir, 'rules-library');
|
|
116
148
|
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `.ai.local/.env` settings: two booleans, both `false` by default, and one
|
|
3
|
+
* non-negative integer.
|
|
4
|
+
*
|
|
5
|
+
* `AI_RULES_ALLOW_GIT_WRITES` lifts the shell guard's git-write stop;
|
|
6
|
+
* `AI_RULES_AUTOROUTE_UNCHAINED_PROMPTS` switches the autoroute prompt face on;
|
|
7
|
+
* `AI_RULES_MAX_PARALLEL_TASKS` caps how many live slugs the autoroute wraps in
|
|
8
|
+
* parallel (default 4; `0` = unlimited).
|
|
9
|
+
* This module is the only reader of the file: importing it has no effect, and
|
|
10
|
+
* `readSetting` is a pure function of the file's bytes plus injected `exists` /
|
|
11
|
+
* `readText` effects, so a hook can import it with its own root and a test can
|
|
12
|
+
* resolve a fixture without touching the disk.
|
|
13
|
+
*
|
|
14
|
+
* Invocation: settings.mjs get <key> | list [--json] [--root <dir>]
|
|
15
|
+
*
|
|
16
|
+
* Exit code is always 0. An absent, unreadable or malformed file resolves to
|
|
17
|
+
* `false` (booleans) or the default (the numeric cap). A boolean that is not
|
|
18
|
+
* `true`/`1` or `false`/`0` warns and stays `false`, so no failure path can
|
|
19
|
+
* resolve to `true`.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import fs from 'node:fs';
|
|
23
|
+
import path from 'node:path';
|
|
24
|
+
import { fileURLToPath } from 'node:url';
|
|
25
|
+
|
|
26
|
+
/** The keys this module resolves; every other name is unknown. */
|
|
27
|
+
const SETTING_KEYS = [
|
|
28
|
+
'AI_RULES_ALLOW_GIT_WRITES',
|
|
29
|
+
'AI_RULES_AUTOROUTE_UNCHAINED_PROMPTS',
|
|
30
|
+
'AI_RULES_MAX_PARALLEL_TASKS',
|
|
31
|
+
];
|
|
32
|
+
/** Keys resolved as non-negative integers instead of booleans. */
|
|
33
|
+
const NUMERIC_KEYS = new Set(['AI_RULES_MAX_PARALLEL_TASKS']);
|
|
34
|
+
/** The cap value when the key is absent or rejected. */
|
|
35
|
+
const DEFAULT_MAX_PARALLEL_TASKS = 4;
|
|
36
|
+
|
|
37
|
+
const ENV_REL = path.join('.ai.local', '.env');
|
|
38
|
+
const TRUE_VALUES = new Set(['true', '1']);
|
|
39
|
+
/** Accepted off spellings. Anything else warns and still resolves to false. */
|
|
40
|
+
const FALSE_VALUES = new Set(['false', '0']);
|
|
41
|
+
const USAGE = 'usage: node .ai.local/scripts/settings.mjs get <key> | list [--json] [--root <dir>]';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Parse `.env` text into the known values that appear in it, plus one warning
|
|
45
|
+
* per anomaly. The last occurrence of a duplicated key wins.
|
|
46
|
+
*
|
|
47
|
+
* @param {string} text
|
|
48
|
+
* @returns {{ values: Map<string, string>, warnings: string[] }}
|
|
49
|
+
*/
|
|
50
|
+
const parseEnv = (text) => {
|
|
51
|
+
const values = new Map();
|
|
52
|
+
const warnings = [];
|
|
53
|
+
const lines = String(text).split(/\r?\n/);
|
|
54
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
55
|
+
const line = lines[index].trim();
|
|
56
|
+
if (!line || line.startsWith('#')) continue;
|
|
57
|
+
const separator = line.indexOf('=');
|
|
58
|
+
if (separator < 0) {
|
|
59
|
+
warnings.push(`line ${index + 1} has no "="; skipped`);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const key = line.slice(0, separator).trim();
|
|
63
|
+
if (!SETTING_KEYS.includes(key)) {
|
|
64
|
+
warnings.push(`unknown key "${key}" on line ${index + 1}; skipped`);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (values.has(key)) {
|
|
68
|
+
warnings.push(`duplicate key "${key}" on line ${index + 1}; the last value wins`);
|
|
69
|
+
}
|
|
70
|
+
values.set(key, line.slice(separator + 1).trim());
|
|
71
|
+
}
|
|
72
|
+
return { values, warnings };
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* A boolean setting. `true` / `1` enable it. `false` / `0` stay off without a
|
|
77
|
+
* warning. Every other spelling warns and stays off, so a typo cannot enable it.
|
|
78
|
+
*
|
|
79
|
+
* @param {string} key
|
|
80
|
+
* @param {string} raw
|
|
81
|
+
* @param {string[]} warnings
|
|
82
|
+
* @returns {boolean}
|
|
83
|
+
*/
|
|
84
|
+
const resolveBoolean = (key, raw, warnings) => {
|
|
85
|
+
const normalized = raw.toLowerCase();
|
|
86
|
+
if (TRUE_VALUES.has(normalized)) return true;
|
|
87
|
+
if (!FALSE_VALUES.has(normalized)) {
|
|
88
|
+
warnings.push(`"${key}" = "${raw}" is not true or false; treating it as false`);
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Read and parse the settings file once. Absent is silent; an unreadable path
|
|
95
|
+
* (permission error, a directory) is one warning and no values.
|
|
96
|
+
*
|
|
97
|
+
* @param {{ root?: string, exists?: (file: string) => boolean, readText?: (file: string) => string }} options
|
|
98
|
+
* @returns {{ parsed: { values: Map<string, string>, warnings: string[] }, warning: string | null }}
|
|
99
|
+
*/
|
|
100
|
+
const readEnv = (options) => {
|
|
101
|
+
const {
|
|
102
|
+
root = process.cwd(),
|
|
103
|
+
exists = (file) => fs.existsSync(file),
|
|
104
|
+
readText = (file) => fs.readFileSync(file, 'utf8'),
|
|
105
|
+
} = options;
|
|
106
|
+
const file = path.join(root, ENV_REL);
|
|
107
|
+
if (!exists(file)) {
|
|
108
|
+
return { parsed: { values: new Map(), warnings: [] }, warning: null };
|
|
109
|
+
}
|
|
110
|
+
try {
|
|
111
|
+
return { parsed: parseEnv(readText(file)), warning: null };
|
|
112
|
+
} catch (error) {
|
|
113
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
114
|
+
return { parsed: { values: new Map(), warnings: [] }, warning: `cannot read ${ENV_REL}: ${message}` };
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* All keys with their resolved value and whether the file supplied it, plus
|
|
120
|
+
* every file-level warning (duplicate key, unknown key, line without `=`).
|
|
121
|
+
* Booleans resolve through `TRUE_VALUES`; the numeric cap resolves through
|
|
122
|
+
* `readSetting`'s integer rule.
|
|
123
|
+
*
|
|
124
|
+
* @param {{ root?: string, exists?: (file: string) => boolean, readText?: (file: string) => string }} [options]
|
|
125
|
+
* @returns {{ keys: Array<{ key: string, value: boolean | number, source: 'file' | 'default' }>, warnings: string[] }}
|
|
126
|
+
*/
|
|
127
|
+
export const listSettings = (options = {}) => {
|
|
128
|
+
const { parsed, warning } = readEnv(options);
|
|
129
|
+
const warnings = warning === null ? [...parsed.warnings] : [warning];
|
|
130
|
+
const keys = SETTING_KEYS.map((key) => {
|
|
131
|
+
if (!parsed.values.has(key)) {
|
|
132
|
+
return { key, value: NUMERIC_KEYS.has(key) ? DEFAULT_MAX_PARALLEL_TASKS : false, source: 'default' };
|
|
133
|
+
}
|
|
134
|
+
const raw = parsed.values.get(key);
|
|
135
|
+
if (NUMERIC_KEYS.has(key)) {
|
|
136
|
+
if (!/^\d+$/.test(raw)) {
|
|
137
|
+
warnings.push(`"${key}" = "${raw}" is not a non-negative integer; using the default ${DEFAULT_MAX_PARALLEL_TASKS}`);
|
|
138
|
+
return { key, value: DEFAULT_MAX_PARALLEL_TASKS, source: 'default' };
|
|
139
|
+
}
|
|
140
|
+
return { key, value: Number(raw), source: 'file' };
|
|
141
|
+
}
|
|
142
|
+
return { key, value: resolveBoolean(key, raw, warnings), source: 'file' };
|
|
143
|
+
});
|
|
144
|
+
return { keys, warnings };
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Resolve one key. Never throws: a missing key, a missing file, an unreadable
|
|
149
|
+
* file and a rejected value all resolve to `false` (booleans) or to the
|
|
150
|
+
* default `4` (the numeric cap, which also accepts `0` = unlimited). A cap
|
|
151
|
+
* value that is not a non-negative integer warns and resolves to the default.
|
|
152
|
+
* Warnings carry every file-level anomaly (duplicate, unknown, no `=`) plus a
|
|
153
|
+
* rejected value, so `get` and `list` report the same states.
|
|
154
|
+
*
|
|
155
|
+
* @param {string} key
|
|
156
|
+
* @param {{ root?: string, exists?: (file: string) => boolean, readText?: (file: string) => string }} [options]
|
|
157
|
+
* @returns {{ value: boolean | number, source: 'file' | 'default', warnings: string[] }}
|
|
158
|
+
*/
|
|
159
|
+
export const readSetting = (key, options = {}) => {
|
|
160
|
+
if (!SETTING_KEYS.includes(key)) {
|
|
161
|
+
return { value: false, source: 'default', warnings: [`unknown key "${key}"`] };
|
|
162
|
+
}
|
|
163
|
+
const { parsed, warning } = readEnv(options);
|
|
164
|
+
if (warning !== null) {
|
|
165
|
+
return NUMERIC_KEYS.has(key)
|
|
166
|
+
? { value: DEFAULT_MAX_PARALLEL_TASKS, source: 'default', warnings: [warning] }
|
|
167
|
+
: { value: false, source: 'default', warnings: [warning] };
|
|
168
|
+
}
|
|
169
|
+
const warnings = [...parsed.warnings];
|
|
170
|
+
if (!parsed.values.has(key)) {
|
|
171
|
+
return NUMERIC_KEYS.has(key)
|
|
172
|
+
? { value: DEFAULT_MAX_PARALLEL_TASKS, source: 'default', warnings }
|
|
173
|
+
: { value: false, source: 'default', warnings };
|
|
174
|
+
}
|
|
175
|
+
const raw = parsed.values.get(key);
|
|
176
|
+
if (NUMERIC_KEYS.has(key)) {
|
|
177
|
+
if (/^\d+$/.test(raw)) {
|
|
178
|
+
return { value: Number(raw), source: 'file', warnings };
|
|
179
|
+
}
|
|
180
|
+
warnings.push(`"${key}" = "${raw}" is not a non-negative integer; using the default ${DEFAULT_MAX_PARALLEL_TASKS}`);
|
|
181
|
+
return { value: DEFAULT_MAX_PARALLEL_TASKS, source: 'default', warnings };
|
|
182
|
+
}
|
|
183
|
+
return { value: resolveBoolean(key, raw, warnings), source: 'file', warnings };
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/** Resolved options from `--root <dir>`; no flag keeps the working directory. */
|
|
187
|
+
const parseArgs = (argv) => {
|
|
188
|
+
const args = { command: argv[0] ?? null, key: null, json: false, root: undefined };
|
|
189
|
+
const rest = [];
|
|
190
|
+
for (let index = 1; index < argv.length; index += 1) {
|
|
191
|
+
if (argv[index] === '--json') {
|
|
192
|
+
args.json = true;
|
|
193
|
+
} else if (argv[index] === '--root') {
|
|
194
|
+
args.root = argv[index + 1];
|
|
195
|
+
index += 1;
|
|
196
|
+
} else {
|
|
197
|
+
rest.push(argv[index]);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
args.key = rest[0] ?? null;
|
|
201
|
+
return args;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
const warnLines = (warnings) => {
|
|
205
|
+
for (const message of warnings) process.stderr.write(`warn: ${message}\n`);
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const main = (argv) => {
|
|
209
|
+
const args = parseArgs(argv);
|
|
210
|
+
const options = args.root === undefined ? {} : { root: args.root };
|
|
211
|
+
|
|
212
|
+
if (args.command === 'get' && args.key !== null) {
|
|
213
|
+
const resolved = readSetting(args.key, options);
|
|
214
|
+
process.stdout.write(`${resolved.value}\n`);
|
|
215
|
+
warnLines(resolved.warnings);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (args.command === 'list') {
|
|
220
|
+
const report = listSettings(options);
|
|
221
|
+
warnLines(report.warnings);
|
|
222
|
+
if (args.json) {
|
|
223
|
+
process.stdout.write(`${JSON.stringify(report)}\n`);
|
|
224
|
+
} else {
|
|
225
|
+
for (const row of report.keys) {
|
|
226
|
+
process.stdout.write(`${row.key}=${row.value} (${row.source})\n`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
process.stderr.write(`${USAGE}\n`);
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
const invokedDirectly = (() => {
|
|
236
|
+
if (process.argv[1] === undefined) return false;
|
|
237
|
+
try {
|
|
238
|
+
return fs.realpathSync(process.argv[1]) === fs.realpathSync(fileURLToPath(import.meta.url));
|
|
239
|
+
} catch {
|
|
240
|
+
return path.resolve(process.argv[1]) === path.resolve(fileURLToPath(import.meta.url));
|
|
241
|
+
}
|
|
242
|
+
})();
|
|
243
|
+
|
|
244
|
+
if (invokedDirectly) {
|
|
245
|
+
main(process.argv.slice(2));
|
|
246
|
+
}
|