@bonesofspring/ai-rules 0.2.55 → 0.2.57
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 +80 -0
- package/README.md +27 -0
- package/docs/PRESET-CONTRIBUTION.md +13 -1
- package/docs/TEAM-DB.md +82 -13
- package/docs/openapi/team-db.v1.json +139 -4
- package/package.json +2 -1
- package/presets/_shared/ai-local/scripts/rule-improver.mjs +333 -26
- package/presets/_shared/ai-local/scripts/run.mjs +21 -6
- package/presets/_shared/ai-local/scripts/team-db-api.mjs +71 -4
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +35 -4
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +143 -2
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +79 -9
- package/presets/_shared/ai-local/scripts/team-db.mjs +50 -6
- package/presets/_shared/core/agent-team/agent-team-orchestrator.md +17 -6
- package/presets/_shared/core/quality/self-review-and-context-hygiene.md +3 -1
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +20 -15
- package/presets/claude/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/claude/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/claude/android-kotlin/agents/debugger.md +1 -1
- package/presets/claude/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/claude/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +20 -15
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +17 -6
- package/presets/claude/go/agents/build-verifier.md +1 -1
- package/presets/claude/go/agents/code-reviewer.md +1 -1
- package/presets/claude/go/agents/debugger.md +1 -1
- package/presets/claude/go/agents/feature-developer.md +1 -1
- package/presets/claude/go/agents/task-analyst.md +1 -1
- package/presets/claude/go/hooks/chain-team-phases.sh +20 -15
- package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +17 -6
- package/presets/claude/ios-swift/agents/build-verifier.md +1 -1
- package/presets/claude/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/claude/ios-swift/agents/debugger.md +1 -1
- package/presets/claude/ios-swift/agents/feature-developer.md +1 -1
- package/presets/claude/ios-swift/agents/task-analyst.md +1 -1
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +20 -15
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +17 -6
- package/presets/claude/java/agents/build-verifier.md +1 -1
- package/presets/claude/java/agents/code-reviewer.md +1 -1
- package/presets/claude/java/agents/debugger.md +1 -1
- package/presets/claude/java/agents/feature-developer.md +1 -1
- package/presets/claude/java/agents/task-analyst.md +1 -1
- package/presets/claude/java/hooks/chain-team-phases.sh +20 -15
- package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +17 -6
- package/presets/claude/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/claude/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/claude/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +20 -15
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +17 -6
- package/presets/claude/mol/agents/build-verifier.md +1 -1
- package/presets/claude/mol/agents/code-reviewer.md +1 -1
- package/presets/claude/mol/agents/debugger.md +1 -1
- package/presets/claude/mol/agents/feature-developer.md +1 -1
- package/presets/claude/mol/agents/task-analyst.md +1 -1
- package/presets/claude/mol/hooks/chain-team-phases.sh +20 -15
- package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +17 -6
- package/presets/claude/next/agents/build-verifier.md +16 -1
- package/presets/claude/next/agents/code-reviewer.md +1 -1
- package/presets/claude/next/agents/debugger.md +1 -1
- package/presets/claude/next/agents/feature-developer.md +13 -1
- package/presets/claude/next/agents/task-analyst.md +1 -1
- package/presets/claude/next/agents/task-router.md +10 -0
- package/presets/claude/next/hooks/chain-team-phases.sh +20 -15
- package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +17 -6
- package/presets/claude/next/rules/tooling-and-review/code-review-mr.md +2 -1
- package/presets/claude/nuxt/agents/build-verifier.md +1 -1
- package/presets/claude/nuxt/agents/code-reviewer.md +1 -1
- package/presets/claude/nuxt/agents/debugger.md +1 -1
- package/presets/claude/nuxt/agents/feature-developer.md +1 -1
- package/presets/claude/nuxt/agents/task-analyst.md +1 -1
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +20 -15
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +17 -6
- package/presets/claude/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/claude/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/claude/php-hexagonal/agents/debugger.md +1 -1
- package/presets/claude/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/claude/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +20 -15
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +17 -6
- package/presets/claude/php-laravel/agents/build-verifier.md +1 -1
- package/presets/claude/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/claude/php-laravel/agents/debugger.md +1 -1
- package/presets/claude/php-laravel/agents/feature-developer.md +1 -1
- package/presets/claude/php-laravel/agents/task-analyst.md +1 -1
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +20 -15
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +17 -6
- package/presets/claude/svelte/agents/build-verifier.md +1 -1
- package/presets/claude/svelte/agents/code-reviewer.md +1 -1
- package/presets/claude/svelte/agents/debugger.md +1 -1
- package/presets/claude/svelte/agents/feature-developer.md +1 -1
- package/presets/claude/svelte/agents/task-analyst.md +1 -1
- package/presets/claude/svelte/hooks/chain-team-phases.sh +20 -15
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +17 -6
- package/presets/cursor/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/cursor/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/cursor/android-kotlin/agents/debugger.md +1 -1
- package/presets/cursor/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/cursor/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +20 -15
- package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/go/agents/build-verifier.md +1 -1
- package/presets/cursor/go/agents/code-reviewer.md +1 -1
- package/presets/cursor/go/agents/debugger.md +1 -1
- package/presets/cursor/go/agents/feature-developer.md +1 -1
- package/presets/cursor/go/agents/task-analyst.md +1 -1
- package/presets/cursor/go/hooks/chain-team-phases.sh +20 -15
- package/presets/cursor/go/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/ios-swift/agents/build-verifier.md +1 -1
- package/presets/cursor/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/cursor/ios-swift/agents/debugger.md +1 -1
- package/presets/cursor/ios-swift/agents/feature-developer.md +1 -1
- package/presets/cursor/ios-swift/agents/task-analyst.md +1 -1
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +20 -15
- package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/java/agents/build-verifier.md +1 -1
- package/presets/cursor/java/agents/code-reviewer.md +1 -1
- package/presets/cursor/java/agents/debugger.md +1 -1
- package/presets/cursor/java/agents/feature-developer.md +1 -1
- package/presets/cursor/java/agents/task-analyst.md +1 -1
- package/presets/cursor/java/hooks/chain-team-phases.sh +20 -15
- package/presets/cursor/java/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/cursor/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/cursor/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +20 -15
- package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mol/agents/build-verifier.md +1 -1
- package/presets/cursor/mol/agents/code-reviewer.md +1 -1
- package/presets/cursor/mol/agents/debugger.md +1 -1
- package/presets/cursor/mol/agents/feature-developer.md +1 -1
- package/presets/cursor/mol/agents/task-analyst.md +1 -1
- package/presets/cursor/mol/hooks/chain-team-phases.sh +20 -15
- package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/next/agents/README.md +2 -0
- package/presets/cursor/next/agents/build-verifier.md +16 -1
- package/presets/cursor/next/agents/code-reviewer.md +1 -1
- package/presets/cursor/next/agents/debugger.md +1 -1
- package/presets/cursor/next/agents/feature-developer.md +13 -1
- package/presets/cursor/next/agents/task-analyst.md +1 -1
- package/presets/cursor/next/agents/task-router.md +10 -0
- package/presets/cursor/next/hooks/chain-team-phases.sh +20 -15
- package/presets/cursor/next/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/next/rules/code-review-mr.mdc +2 -1
- package/presets/cursor/next/team/fixtures/feature-l2-lite.json +27 -0
- package/presets/cursor/nuxt/agents/build-verifier.md +1 -1
- package/presets/cursor/nuxt/agents/code-reviewer.md +1 -1
- package/presets/cursor/nuxt/agents/debugger.md +1 -1
- package/presets/cursor/nuxt/agents/feature-developer.md +1 -1
- package/presets/cursor/nuxt/agents/task-analyst.md +1 -1
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +20 -15
- package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/cursor/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/cursor/php-hexagonal/agents/debugger.md +1 -1
- package/presets/cursor/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/cursor/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +20 -15
- package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-laravel/agents/build-verifier.md +1 -1
- package/presets/cursor/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/cursor/php-laravel/agents/debugger.md +1 -1
- package/presets/cursor/php-laravel/agents/feature-developer.md +1 -1
- package/presets/cursor/php-laravel/agents/task-analyst.md +1 -1
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +20 -15
- package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/svelte/agents/build-verifier.md +1 -1
- package/presets/cursor/svelte/agents/code-reviewer.md +1 -1
- package/presets/cursor/svelte/agents/debugger.md +1 -1
- package/presets/cursor/svelte/agents/feature-developer.md +1 -1
- package/presets/cursor/svelte/agents/task-analyst.md +1 -1
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +20 -15
- package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/mavis/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/mavis/android-kotlin/agents/debugger.md +1 -1
- package/presets/mavis/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/mavis/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +20 -15
- package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +17 -6
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/agents/build-verifier.md +1 -1
- package/presets/mavis/go/agents/code-reviewer.md +1 -1
- package/presets/mavis/go/agents/debugger.md +1 -1
- package/presets/mavis/go/agents/feature-developer.md +1 -1
- package/presets/mavis/go/agents/task-analyst.md +1 -1
- package/presets/mavis/go/hooks/chain-team-phases.sh +20 -15
- package/presets/mavis/go/rules/agent-team-orchestrator.md +17 -6
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/agents/build-verifier.md +1 -1
- package/presets/mavis/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/mavis/ios-swift/agents/debugger.md +1 -1
- package/presets/mavis/ios-swift/agents/feature-developer.md +1 -1
- package/presets/mavis/ios-swift/agents/task-analyst.md +1 -1
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +20 -15
- package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +17 -6
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/agents/build-verifier.md +1 -1
- package/presets/mavis/java/agents/code-reviewer.md +1 -1
- package/presets/mavis/java/agents/debugger.md +1 -1
- package/presets/mavis/java/agents/feature-developer.md +1 -1
- package/presets/mavis/java/agents/task-analyst.md +1 -1
- package/presets/mavis/java/hooks/chain-team-phases.sh +20 -15
- package/presets/mavis/java/rules/agent-team-orchestrator.md +17 -6
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/mavis/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/mavis/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +20 -15
- package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +17 -6
- package/presets/mavis/mol/adapter-map.json +1 -1
- package/presets/mavis/mol/agents/build-verifier.md +1 -1
- package/presets/mavis/mol/agents/code-reviewer.md +1 -1
- package/presets/mavis/mol/agents/debugger.md +1 -1
- package/presets/mavis/mol/agents/feature-developer.md +1 -1
- package/presets/mavis/mol/agents/task-analyst.md +1 -1
- package/presets/mavis/mol/hooks/chain-team-phases.sh +20 -15
- package/presets/mavis/mol/rules/agent-team-orchestrator.md +17 -6
- package/presets/mavis/next/adapter-map.json +9 -1
- package/presets/mavis/next/agents/build-verifier.md +16 -1
- package/presets/mavis/next/agents/code-reviewer.md +1 -1
- package/presets/mavis/next/agents/debugger.md +1 -1
- package/presets/mavis/next/agents/feature-developer.md +13 -1
- package/presets/mavis/next/agents/task-analyst.md +1 -1
- package/presets/mavis/next/agents/task-router.md +10 -0
- package/presets/mavis/next/hooks/chain-team-phases.sh +20 -15
- package/presets/mavis/next/rules/agent-team-orchestrator.md +17 -6
- package/presets/mavis/next/rules/code-review-mr.md +2 -1
- package/presets/mavis/next/team/fixtures/feature-l2-lite.json +27 -0
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/agents/build-verifier.md +1 -1
- package/presets/mavis/nuxt/agents/code-reviewer.md +1 -1
- package/presets/mavis/nuxt/agents/debugger.md +1 -1
- package/presets/mavis/nuxt/agents/feature-developer.md +1 -1
- package/presets/mavis/nuxt/agents/task-analyst.md +1 -1
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +20 -15
- package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +17 -6
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/mavis/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/mavis/php-hexagonal/agents/debugger.md +1 -1
- package/presets/mavis/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/mavis/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +20 -15
- package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +17 -6
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/agents/build-verifier.md +1 -1
- package/presets/mavis/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/mavis/php-laravel/agents/debugger.md +1 -1
- package/presets/mavis/php-laravel/agents/feature-developer.md +1 -1
- package/presets/mavis/php-laravel/agents/task-analyst.md +1 -1
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +20 -15
- package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +17 -6
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/agents/build-verifier.md +1 -1
- package/presets/mavis/svelte/agents/code-reviewer.md +1 -1
- package/presets/mavis/svelte/agents/debugger.md +1 -1
- package/presets/mavis/svelte/agents/feature-developer.md +1 -1
- package/presets/mavis/svelte/agents/task-analyst.md +1 -1
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +20 -15
- package/presets/mavis/svelte/rules/agent-team-orchestrator.md +17 -6
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/opencode/android-kotlin/agents/code-reviewer.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/task-analyst.md +1 -1
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +20 -15
- package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +17 -6
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/agents/build-verifier.md +1 -1
- package/presets/opencode/go/agents/code-reviewer.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/task-analyst.md +1 -1
- package/presets/opencode/go/hooks/chain-team-phases.sh +20 -15
- package/presets/opencode/go/rules/agent-team-orchestrator.md +17 -6
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/agents/build-verifier.md +1 -1
- package/presets/opencode/ios-swift/agents/code-reviewer.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/task-analyst.md +1 -1
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +20 -15
- package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +17 -6
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/agents/build-verifier.md +1 -1
- package/presets/opencode/java/agents/code-reviewer.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/task-analyst.md +1 -1
- package/presets/opencode/java/hooks/chain-team-phases.sh +20 -15
- package/presets/opencode/java/rules/agent-team-orchestrator.md +17 -6
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- 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/task-analyst.md +1 -1
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +20 -15
- package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +17 -6
- package/presets/opencode/mol/adapter-map.json +1 -1
- package/presets/opencode/mol/agents/build-verifier.md +1 -1
- package/presets/opencode/mol/agents/code-reviewer.md +1 -1
- package/presets/opencode/mol/agents/debugger.md +1 -1
- package/presets/opencode/mol/agents/feature-developer.md +1 -1
- package/presets/opencode/mol/agents/task-analyst.md +1 -1
- package/presets/opencode/mol/hooks/chain-team-phases.sh +20 -15
- package/presets/opencode/mol/rules/agent-team-orchestrator.md +17 -6
- package/presets/opencode/next/adapter-map.json +9 -1
- package/presets/opencode/next/agents/build-verifier.md +16 -1
- package/presets/opencode/next/agents/code-reviewer.md +1 -1
- package/presets/opencode/next/agents/debugger.md +1 -1
- package/presets/opencode/next/agents/feature-developer.md +13 -1
- package/presets/opencode/next/agents/task-analyst.md +1 -1
- package/presets/opencode/next/agents/task-router.md +10 -0
- package/presets/opencode/next/hooks/chain-team-phases.sh +20 -15
- package/presets/opencode/next/rules/agent-team-orchestrator.md +17 -6
- package/presets/opencode/next/rules/code-review-mr.md +2 -1
- package/presets/opencode/next/team/fixtures/feature-l2-lite.json +27 -0
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/agents/build-verifier.md +1 -1
- package/presets/opencode/nuxt/agents/code-reviewer.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/task-analyst.md +1 -1
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +20 -15
- package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +17 -6
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/opencode/php-hexagonal/agents/code-reviewer.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/task-analyst.md +1 -1
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +20 -15
- package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +17 -6
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/agents/build-verifier.md +1 -1
- package/presets/opencode/php-laravel/agents/code-reviewer.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/task-analyst.md +1 -1
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +20 -15
- package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +17 -6
- package/presets/opencode/svelte/adapter-map.json +1 -1
- package/presets/opencode/svelte/agents/build-verifier.md +1 -1
- package/presets/opencode/svelte/agents/code-reviewer.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/task-analyst.md +1 -1
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +20 -15
- package/presets/opencode/svelte/rules/agent-team-orchestrator.md +17 -6
- package/presets/zcode/android-kotlin/adapter-map.json +1 -1
- package/presets/zcode/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/zcode/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/zcode/android-kotlin/agents/debugger.md +1 -1
- package/presets/zcode/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/zcode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +20 -15
- package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +17 -6
- package/presets/zcode/go/adapter-map.json +1 -1
- package/presets/zcode/go/agents/build-verifier.md +1 -1
- package/presets/zcode/go/agents/code-reviewer.md +1 -1
- package/presets/zcode/go/agents/debugger.md +1 -1
- package/presets/zcode/go/agents/feature-developer.md +1 -1
- package/presets/zcode/go/agents/task-analyst.md +1 -1
- package/presets/zcode/go/hooks/chain-team-phases.sh +20 -15
- package/presets/zcode/go/rules/agent-team-orchestrator.md +17 -6
- package/presets/zcode/ios-swift/adapter-map.json +1 -1
- package/presets/zcode/ios-swift/agents/build-verifier.md +1 -1
- package/presets/zcode/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/zcode/ios-swift/agents/debugger.md +1 -1
- package/presets/zcode/ios-swift/agents/feature-developer.md +1 -1
- package/presets/zcode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +20 -15
- package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +17 -6
- package/presets/zcode/java/adapter-map.json +1 -1
- package/presets/zcode/java/agents/build-verifier.md +1 -1
- package/presets/zcode/java/agents/code-reviewer.md +1 -1
- package/presets/zcode/java/agents/debugger.md +1 -1
- package/presets/zcode/java/agents/feature-developer.md +1 -1
- package/presets/zcode/java/agents/task-analyst.md +1 -1
- package/presets/zcode/java/hooks/chain-team-phases.sh +20 -15
- package/presets/zcode/java/rules/agent-team-orchestrator.md +17 -6
- package/presets/zcode/mcp-ts/adapter-map.json +1 -1
- package/presets/zcode/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/zcode/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/zcode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +20 -15
- package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +17 -6
- package/presets/zcode/mol/adapter-map.json +1 -1
- package/presets/zcode/mol/agents/build-verifier.md +1 -1
- package/presets/zcode/mol/agents/code-reviewer.md +1 -1
- package/presets/zcode/mol/agents/debugger.md +1 -1
- package/presets/zcode/mol/agents/feature-developer.md +1 -1
- package/presets/zcode/mol/agents/task-analyst.md +1 -1
- package/presets/zcode/mol/hooks/chain-team-phases.sh +20 -15
- package/presets/zcode/mol/rules/agent-team-orchestrator.md +17 -6
- package/presets/zcode/next/adapter-map.json +9 -1
- package/presets/zcode/next/agents/build-verifier.md +16 -1
- package/presets/zcode/next/agents/code-reviewer.md +1 -1
- package/presets/zcode/next/agents/debugger.md +1 -1
- package/presets/zcode/next/agents/feature-developer.md +13 -1
- package/presets/zcode/next/agents/task-analyst.md +1 -1
- package/presets/zcode/next/agents/task-router.md +10 -0
- package/presets/zcode/next/hooks/chain-team-phases.sh +20 -15
- package/presets/zcode/next/rules/agent-team-orchestrator.md +17 -6
- package/presets/zcode/next/rules/code-review-mr.md +2 -1
- package/presets/zcode/next/team/fixtures/feature-l2-lite.json +27 -0
- package/presets/zcode/nuxt/adapter-map.json +1 -1
- package/presets/zcode/nuxt/agents/build-verifier.md +1 -1
- package/presets/zcode/nuxt/agents/code-reviewer.md +1 -1
- package/presets/zcode/nuxt/agents/debugger.md +1 -1
- package/presets/zcode/nuxt/agents/feature-developer.md +1 -1
- package/presets/zcode/nuxt/agents/task-analyst.md +1 -1
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +20 -15
- package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +17 -6
- package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
- package/presets/zcode/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/zcode/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/zcode/php-hexagonal/agents/debugger.md +1 -1
- package/presets/zcode/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/zcode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +20 -15
- package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +17 -6
- package/presets/zcode/php-laravel/adapter-map.json +1 -1
- package/presets/zcode/php-laravel/agents/build-verifier.md +1 -1
- package/presets/zcode/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/zcode/php-laravel/agents/debugger.md +1 -1
- package/presets/zcode/php-laravel/agents/feature-developer.md +1 -1
- package/presets/zcode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +20 -15
- package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +17 -6
- package/presets/zcode/svelte/adapter-map.json +1 -1
- package/presets/zcode/svelte/agents/build-verifier.md +1 -1
- package/presets/zcode/svelte/agents/code-reviewer.md +1 -1
- package/presets/zcode/svelte/agents/debugger.md +1 -1
- package/presets/zcode/svelte/agents/feature-developer.md +1 -1
- package/presets/zcode/svelte/agents/task-analyst.md +1 -1
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +20 -15
- package/presets/zcode/svelte/rules/agent-team-orchestrator.md +17 -6
|
@@ -28,9 +28,28 @@ import {
|
|
|
28
28
|
} from './signals.mjs';
|
|
29
29
|
import { acquireLock, releaseLock } from './lock.mjs';
|
|
30
30
|
|
|
31
|
-
// --- Envelope caps (architecture.md §3)
|
|
31
|
+
// --- Envelope caps (architecture.md §3, ADR 0001 guard 2) --------------------
|
|
32
|
+
// Two stores, two budgets:
|
|
33
|
+
// human store — `.ai.local/rules/**` ≤ MAX_ACTIVE_RULES files, ≤ MAX_RULE_LINES lines
|
|
34
|
+
// machine store — `.ai.local/conventions.md` ≤ MAX_CONVENTION_LINES lines
|
|
35
|
+
// The combined envelope stays 200 non-empty lines; only its distribution moves.
|
|
36
|
+
// A saturated store refuses its own writes and never another store's.
|
|
32
37
|
export const MAX_ACTIVE_RULES = 5;
|
|
33
|
-
export const
|
|
38
|
+
export const MAX_RULE_LINES = 170;
|
|
39
|
+
export const MAX_CONVENTION_LINES = 30;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Back-compat alias for the pre-split single-pool engine.
|
|
43
|
+
*
|
|
44
|
+
* A consumer seeded before the per-store split keeps its old `run.mjs`
|
|
45
|
+
* (seeding is skip-if-exists), and that module imports `MAX_TOTAL_LINES`.
|
|
46
|
+
* The alias keeps the import resolvable, so a stale sibling module still
|
|
47
|
+
* loads instead of dying with a `SyntaxError`.
|
|
48
|
+
*
|
|
49
|
+
* @deprecated Use MAX_RULE_LINES / MAX_CONVENTION_LINES. The per-store caps
|
|
50
|
+
* are the single source of truth; this alias is derived from them.
|
|
51
|
+
*/
|
|
52
|
+
export const MAX_TOTAL_LINES = MAX_RULE_LINES + MAX_CONVENTION_LINES;
|
|
34
53
|
|
|
35
54
|
// --- Denylist (architecture.md §5.3) ----------------------------------------
|
|
36
55
|
export const DENYLIST = [
|
|
@@ -249,12 +268,21 @@ export function recoverPendingCommit(ledgerPath, roots) {
|
|
|
249
268
|
const current = target == null ? null : readExisting(target);
|
|
250
269
|
const landed = content === null ? current === null : current === content;
|
|
251
270
|
if (landed && entry.action) {
|
|
271
|
+
// A promotion intent carries the ledger row separately: the row's `before`
|
|
272
|
+
// is the reviewed snapshot, while the intent's `before` is the rule file's
|
|
273
|
+
// previous content.
|
|
274
|
+
const row = payload.ledgerEntry ?? entry;
|
|
252
275
|
const existing = parseLedger(readExisting(ledgerPath) ?? '');
|
|
253
|
-
const recorded = existing.some((
|
|
254
|
-
&&
|
|
255
|
-
&&
|
|
256
|
-
&&
|
|
257
|
-
if (!recorded) appendLedgerLine(ledgerPath,
|
|
276
|
+
const recorded = existing.some((item) => item
|
|
277
|
+
&& item.action === row.action
|
|
278
|
+
&& item.signature === row.signature
|
|
279
|
+
&& item.at === row.at);
|
|
280
|
+
if (!recorded) appendLedgerLine(ledgerPath, row, resolved);
|
|
281
|
+
for (const removal of payload.removeTargets ?? []) {
|
|
282
|
+
try { fs.unlinkSync(removal); } catch (error) {
|
|
283
|
+
if (!error || error.code !== 'ENOENT') throw error;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
258
286
|
clearIntent(ledgerPath);
|
|
259
287
|
return { recovered: 'committed', entry };
|
|
260
288
|
}
|
|
@@ -314,6 +342,37 @@ function commitWrite({ ledgerPath, target, content, entry, roots }) {
|
|
|
314
342
|
clearIntent(ledgerPath);
|
|
315
343
|
}
|
|
316
344
|
|
|
345
|
+
/**
|
|
346
|
+
* Promotion commit: the rule file, then the seed removal, then the ledger row.
|
|
347
|
+
*
|
|
348
|
+
* The intent carries the ledger row separately. The row's `before` is the
|
|
349
|
+
* reviewed snapshot (the contract's binding); the intent's `before` is the rule
|
|
350
|
+
* file's previous content (null — a promotion creates the rule). A failure
|
|
351
|
+
* leaves the intent in place: `recoverPendingCommit` finishes a landed rule or
|
|
352
|
+
* drops an attempt that never wrote it, so a ledger error cannot silently lose
|
|
353
|
+
* the seed or leave an unrecorded rule.
|
|
354
|
+
*/
|
|
355
|
+
function commitPromotion({ ledgerPath, ruleTarget, ruleContent, seedTarget, entry, roots }) {
|
|
356
|
+
const resolved = typeof roots === 'string' ? { project: roots, repo: roots } : roots;
|
|
357
|
+
const ledgerRow = {
|
|
358
|
+
...entry,
|
|
359
|
+
target: entry.target == null ? null : toLedgerTarget(entry.target, resolved.repo),
|
|
360
|
+
};
|
|
361
|
+
writeIntent(ledgerPath, {
|
|
362
|
+
entry: { ...ledgerRow, before: null },
|
|
363
|
+
ledgerEntry: ledgerRow,
|
|
364
|
+
content: ruleContent,
|
|
365
|
+
removeTargets: [seedTarget],
|
|
366
|
+
roots: resolved,
|
|
367
|
+
});
|
|
368
|
+
writeFileAtomic(ruleTarget, ruleContent);
|
|
369
|
+
try { fs.unlinkSync(seedTarget); } catch (error) {
|
|
370
|
+
if (!error || error.code !== 'ENOENT') throw error;
|
|
371
|
+
}
|
|
372
|
+
appendLedgerLine(ledgerPath, ledgerRow, resolved);
|
|
373
|
+
clearIntent(ledgerPath);
|
|
374
|
+
}
|
|
375
|
+
|
|
317
376
|
// --- Signature parsing + template re-derivation ------------------------------
|
|
318
377
|
|
|
319
378
|
export function parseSignature(signature) {
|
|
@@ -610,6 +669,56 @@ function deriveSeedText({ stem, kind, issue, paths, command }) {
|
|
|
610
669
|
return `glob: always\n\n## Body\n\n${deriveRuleText({ stem, kind, issue, paths, command })}`;
|
|
611
670
|
}
|
|
612
671
|
|
|
672
|
+
// --- Provenance footer (ADR 0001 guard 1) -------------------------------------
|
|
673
|
+
|
|
674
|
+
// The footer states the authorship of a staged seed. Its four fields are all
|
|
675
|
+
// machine-derived and bounded — a validated signature, a timestamp, a validated
|
|
676
|
+
// slug and a fixed state token — so no task or spec prose can reach it (guard 1:
|
|
677
|
+
// rule text is re-derived from the signature, never copied from prose).
|
|
678
|
+
export const PROVENANCE_STATE = 'awaiting-human-promotion';
|
|
679
|
+
const PROVENANCE_RE = /^<!--\s*ai-local-provenance:\s*(\{.*\})\s*-->$/;
|
|
680
|
+
const KEBAB_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
681
|
+
|
|
682
|
+
/** The footer line for a staged seed. */
|
|
683
|
+
export function provenanceFooter({ signature, stagedAt, sourceSlug }) {
|
|
684
|
+
if (!SIGNATURE_RE.test(signature)) {
|
|
685
|
+
throw new Error(`invalid signature "${signature}"`);
|
|
686
|
+
}
|
|
687
|
+
if (!KEBAB_SLUG_RE.test(sourceSlug)) {
|
|
688
|
+
throw new Error(`invalid source slug "${sourceSlug}"`);
|
|
689
|
+
}
|
|
690
|
+
const payload = { signature, stagedAt, sourceSlug, state: PROVENANCE_STATE };
|
|
691
|
+
return `<!-- ai-local-provenance: ${JSON.stringify(payload)} -->`;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/** The seed file content: the reviewed body plus the trailing provenance line. */
|
|
695
|
+
export function withProvenanceFooter(body, provenance) {
|
|
696
|
+
return `${body.replace(/\n+$/, '')}\n${provenanceFooter(provenance)}\n`;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/** The parsed footer of a seed file, or null when it carries none. */
|
|
700
|
+
export function parseProvenanceFooter(content) {
|
|
701
|
+
const lines = content.split('\n');
|
|
702
|
+
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
703
|
+
const match = PROVENANCE_RE.exec(lines[i].trim());
|
|
704
|
+
if (!match) continue;
|
|
705
|
+
try {
|
|
706
|
+
return { payload: JSON.parse(match[1]), index: i };
|
|
707
|
+
} catch {
|
|
708
|
+
return null;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/** The reviewed content: the seed body without every provenance line. */
|
|
715
|
+
export function stripProvenanceFooter(content) {
|
|
716
|
+
const lines = content.split('\n');
|
|
717
|
+
const kept = lines.filter((line) => !PROVENANCE_RE.test(line.trim()));
|
|
718
|
+
if (kept.length === lines.length) return content;
|
|
719
|
+
return `${kept.join('\n').replace(/\n+$/, '')}\n`;
|
|
720
|
+
}
|
|
721
|
+
|
|
613
722
|
/** Read-only `--status` lesson line: `lesson: pending` or `lesson: app/src [lint:js]`. */
|
|
614
723
|
export function formatLessonStatus(lesson) {
|
|
615
724
|
if (lesson === null) return 'lesson: pending';
|
|
@@ -692,21 +801,46 @@ export function thresholdAction(distinctSlugCount) {
|
|
|
692
801
|
|
|
693
802
|
// --- Authoring envelope ------------------------------------------------------
|
|
694
803
|
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
804
|
+
/**
|
|
805
|
+
* One store's envelope. Each store is checked against its own caps, so a
|
|
806
|
+
* saturated `rules/` store never blocks a `conventions.md` write and a
|
|
807
|
+
* saturated `conventions.md` never blocks a promotion.
|
|
808
|
+
*/
|
|
809
|
+
export function evaluateEnvelope({
|
|
810
|
+
store = 'rules',
|
|
811
|
+
ruleCount = 0,
|
|
812
|
+
lineCount = 0,
|
|
813
|
+
newRuleCount = 0,
|
|
814
|
+
newLineCount = 0,
|
|
815
|
+
}) {
|
|
816
|
+
if (store === 'rules') {
|
|
817
|
+
const nextRules = ruleCount + newRuleCount;
|
|
818
|
+
const nextLines = lineCount + newLineCount;
|
|
819
|
+
if (nextRules > MAX_ACTIVE_RULES) {
|
|
820
|
+
return { ok: false, reason: `rule cap: ${nextRules} active rules would exceed ${MAX_ACTIVE_RULES}` };
|
|
821
|
+
}
|
|
822
|
+
if (nextLines > MAX_RULE_LINES) {
|
|
823
|
+
return { ok: false, reason: `rule line cap: ${nextLines} nonempty lines would exceed ${MAX_RULE_LINES}` };
|
|
824
|
+
}
|
|
825
|
+
return { ok: true, reason: 'within envelope' };
|
|
700
826
|
}
|
|
701
|
-
if (
|
|
702
|
-
|
|
827
|
+
if (store === 'conventions') {
|
|
828
|
+
const nextLines = lineCount + newLineCount;
|
|
829
|
+
if (nextLines > MAX_CONVENTION_LINES) {
|
|
830
|
+
return { ok: false, reason: `conventions line cap: ${nextLines} nonempty lines would exceed ${MAX_CONVENTION_LINES}` };
|
|
831
|
+
}
|
|
832
|
+
return { ok: true, reason: 'within envelope' };
|
|
703
833
|
}
|
|
704
|
-
|
|
834
|
+
throw new Error(`unknown envelope store "${store}"`);
|
|
705
835
|
}
|
|
706
836
|
|
|
837
|
+
/**
|
|
838
|
+
* The two stores, counted separately: the human-promoted `rules/` files and
|
|
839
|
+
* the machine-written `conventions.md` bullets.
|
|
840
|
+
*/
|
|
707
841
|
export function countRulesAndLines({ rulesDir, conventionsPath }) {
|
|
708
842
|
let ruleCount = 0;
|
|
709
|
-
let
|
|
843
|
+
let ruleLineCount = 0;
|
|
710
844
|
let names = [];
|
|
711
845
|
try { names = fs.readdirSync(rulesDir); } catch (error) {
|
|
712
846
|
if (!error || error.code !== 'ENOENT') throw error;
|
|
@@ -715,23 +849,27 @@ export function countRulesAndLines({ rulesDir, conventionsPath }) {
|
|
|
715
849
|
if (!name.endsWith('.md')) continue;
|
|
716
850
|
ruleCount += 1;
|
|
717
851
|
try {
|
|
718
|
-
|
|
852
|
+
ruleLineCount += countNonEmptyLines(fs.readFileSync(path.join(rulesDir, name), 'utf8'));
|
|
719
853
|
} catch (error) {
|
|
720
854
|
if (!error || error.code !== 'ENOENT') {
|
|
721
855
|
throw new Error(`unreadable rule ${name}: ${error.message}`);
|
|
722
856
|
}
|
|
723
857
|
}
|
|
724
858
|
}
|
|
859
|
+
let conventionLineCount = 0;
|
|
725
860
|
if (conventionsPath) {
|
|
726
861
|
try {
|
|
727
|
-
|
|
862
|
+
conventionLineCount = countNonEmptyLines(fs.readFileSync(conventionsPath, 'utf8'));
|
|
728
863
|
} catch (error) {
|
|
729
864
|
if (!error || error.code !== 'ENOENT') {
|
|
730
865
|
throw new Error(`unreadable conventions: ${error.message}`);
|
|
731
866
|
}
|
|
732
867
|
}
|
|
733
868
|
}
|
|
734
|
-
return {
|
|
869
|
+
return {
|
|
870
|
+
rules: { ruleCount, lineCount: ruleLineCount },
|
|
871
|
+
conventions: { lineCount: conventionLineCount },
|
|
872
|
+
};
|
|
735
873
|
}
|
|
736
874
|
|
|
737
875
|
// --- Conventions edit --------------------------------------------------------
|
|
@@ -1038,8 +1176,8 @@ function planConventions(ctx, decision) {
|
|
|
1038
1176
|
};
|
|
1039
1177
|
}
|
|
1040
1178
|
const envelope = evaluateEnvelope({
|
|
1041
|
-
|
|
1042
|
-
lineCount: ctx.envelope.lineCount,
|
|
1179
|
+
store: 'conventions',
|
|
1180
|
+
lineCount: ctx.envelope.conventions.lineCount,
|
|
1043
1181
|
newLineCount: addedLines,
|
|
1044
1182
|
});
|
|
1045
1183
|
if (!envelope.ok) return { type: 'blocked', reason: envelope.reason, action: 'conventions-added' };
|
|
@@ -1091,6 +1229,7 @@ function hasOpenStage(entries, signature) {
|
|
|
1091
1229
|
|| entry.action === 'rule-created'
|
|
1092
1230
|
|| entry.action === 'applied'
|
|
1093
1231
|
|| entry.action === 'rejected'
|
|
1232
|
+
|| entry.action === 'seed-promoted'
|
|
1094
1233
|
) open = false;
|
|
1095
1234
|
}
|
|
1096
1235
|
return open;
|
|
@@ -1146,6 +1285,12 @@ function stageNewRule({ decision, ctx, prior, ledgerPath, now, staged, rulesDir,
|
|
|
1146
1285
|
const seed = planSeed(ctx, decision);
|
|
1147
1286
|
const existing = readExisting(seed.target);
|
|
1148
1287
|
if (existing !== null) {
|
|
1288
|
+
// The reviewed snapshot is the seed body without its provenance line, so
|
|
1289
|
+
// the ledger row and the file never disagree about what was reviewed.
|
|
1290
|
+
// An existing seed is left byte-for-byte alone: a file the engine never
|
|
1291
|
+
// wrote (an `init`-seeded template copy) must not carry a machine-authorship
|
|
1292
|
+
// claim.
|
|
1293
|
+
const reviewed = stripProvenanceFooter(existing);
|
|
1149
1294
|
appendStage({
|
|
1150
1295
|
prior,
|
|
1151
1296
|
ledgerPath,
|
|
@@ -1153,7 +1298,7 @@ function stageNewRule({ decision, ctx, prior, ledgerPath, now, staged, rulesDir,
|
|
|
1153
1298
|
action: 'seed-staged',
|
|
1154
1299
|
target: seed.target,
|
|
1155
1300
|
before: existing,
|
|
1156
|
-
after:
|
|
1301
|
+
after: reviewed,
|
|
1157
1302
|
now,
|
|
1158
1303
|
staged,
|
|
1159
1304
|
reason: 'seed already staged',
|
|
@@ -1162,12 +1307,32 @@ function stageNewRule({ decision, ctx, prior, ledgerPath, now, staged, rulesDir,
|
|
|
1162
1307
|
return;
|
|
1163
1308
|
}
|
|
1164
1309
|
const reason = decision.compliance ?? (band.verdict === 'stage' ? band.reason : 'new rule staged for human promote');
|
|
1310
|
+
// The engine writes the provenance footer; the ledger row keeps the reviewed
|
|
1311
|
+
// body, so the footer can never make the row and the file disagree.
|
|
1312
|
+
const stagedAt = now();
|
|
1313
|
+
const seedFile = withProvenanceFooter(seed.content, {
|
|
1314
|
+
signature: decision.signature,
|
|
1315
|
+
stagedAt,
|
|
1316
|
+
sourceSlug: sourceSlugFor(decision),
|
|
1317
|
+
});
|
|
1165
1318
|
const entry = ledgerEntry(decision, 'seed-staged', seed.target, null, seed.content, now);
|
|
1166
|
-
commitWrite({ ledgerPath, target: seed.target, content:
|
|
1319
|
+
commitWrite({ ledgerPath, target: seed.target, content: seedFile, entry, roots });
|
|
1167
1320
|
prior.push(entry);
|
|
1168
1321
|
staged.push({ signature: decision.signature, target: seed.target, reason });
|
|
1169
1322
|
}
|
|
1170
1323
|
|
|
1324
|
+
/**
|
|
1325
|
+
* The task slug the seed came from. The signal store validates it as
|
|
1326
|
+
* kebab-case, so the footer's slug field stays bounded (guard 1).
|
|
1327
|
+
*/
|
|
1328
|
+
function sourceSlugFor(decision) {
|
|
1329
|
+
for (const slug of decision.slugs ?? []) {
|
|
1330
|
+
if (typeof slug === 'string' && KEBAB_SLUG_RE.test(slug)) return slug;
|
|
1331
|
+
}
|
|
1332
|
+
if (KEBAB_SLUG_RE.test(decision.slug)) return decision.slug;
|
|
1333
|
+
return decision.stem;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1171
1336
|
function entrySlugs(entry) {
|
|
1172
1337
|
const slugs = [];
|
|
1173
1338
|
if (Array.isArray(entry?.slugs)) {
|
|
@@ -1216,6 +1381,7 @@ function hasOpenPendingLesson(entries, signature) {
|
|
|
1216
1381
|
else if (
|
|
1217
1382
|
entry.action === 'staged'
|
|
1218
1383
|
|| entry.action === 'seed-staged'
|
|
1384
|
+
|| entry.action === 'seed-promoted'
|
|
1219
1385
|
|| entry.action === 'conventions-added'
|
|
1220
1386
|
|| entry.action === 'rollback'
|
|
1221
1387
|
) open = false;
|
|
@@ -1502,7 +1668,7 @@ export function runImprover(options = {}) {
|
|
|
1502
1668
|
let applySkipped = [];
|
|
1503
1669
|
let unloaded = [];
|
|
1504
1670
|
let applyErrors = [];
|
|
1505
|
-
let envelope = { ruleCount: 0, lineCount: 0 };
|
|
1671
|
+
let envelope = { rules: { ruleCount: 0, lineCount: 0 }, conventions: { lineCount: 0 } };
|
|
1506
1672
|
try {
|
|
1507
1673
|
({ applied, staged, skipped: applySkipped, unloaded, envelope, errors: applyErrors } = applyDecisionsUnderLock({
|
|
1508
1674
|
decisions,
|
|
@@ -1559,6 +1725,138 @@ function renderTarget(target, roots) {
|
|
|
1559
1725
|
}
|
|
1560
1726
|
}
|
|
1561
1727
|
|
|
1728
|
+
/**
|
|
1729
|
+
* The open `seed-staged` row of a staged seed, or null when the seed has no
|
|
1730
|
+
* open stage row (a seed without a row was never reviewed by the engine).
|
|
1731
|
+
*/
|
|
1732
|
+
function findOpenSeedStage(entries, seedPath, roots) {
|
|
1733
|
+
const wanted = toLedgerTarget(seedPath, roots.repo);
|
|
1734
|
+
let found = null;
|
|
1735
|
+
for (const entry of entries) {
|
|
1736
|
+
if (!entry || entry.action !== 'seed-staged') continue;
|
|
1737
|
+
if (entry.target !== wanted) continue;
|
|
1738
|
+
found = entry;
|
|
1739
|
+
}
|
|
1740
|
+
if (!found) return null;
|
|
1741
|
+
if (!hasOpenStage(entries, found.signature)) return null;
|
|
1742
|
+
return found;
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
/**
|
|
1746
|
+
* Promote a staged seed into `.ai.local/rules/`.
|
|
1747
|
+
*
|
|
1748
|
+
* The promotion is one auditable operation: locate the seed and its open
|
|
1749
|
+
* `seed-staged` row, strip the provenance footer, write the rule, remove the
|
|
1750
|
+
* seed and append the `seed-promoted` row. The row binds the promoted file to
|
|
1751
|
+
* the reviewed snapshot (the `seed-staged` row's `after`); a seed edited
|
|
1752
|
+
* between staging and promotion is recorded as a divergence, not refused.
|
|
1753
|
+
*/
|
|
1754
|
+
export function runPromotion(options = {}) {
|
|
1755
|
+
const stem = options.stem;
|
|
1756
|
+
const baseDir = options.baseDir ?? path.join(process.cwd(), '.ai.local');
|
|
1757
|
+
const rulesDir = options.rulesDir ?? path.join(baseDir, 'rules');
|
|
1758
|
+
const libraryDir = options.libraryDir ?? path.join(baseDir, 'rules-library');
|
|
1759
|
+
const ledgerPath = options.ledgerPath ?? path.join(baseDir, 'rule-changes.jsonl');
|
|
1760
|
+
const lockPath = options.lockPath ?? path.join(baseDir, '.rules.lock');
|
|
1761
|
+
const now = options.now ?? (() => new Date().toISOString());
|
|
1762
|
+
const roots = resolveRoots(ledgerPath, options);
|
|
1763
|
+
|
|
1764
|
+
const refuse = (reason) => ({
|
|
1765
|
+
ok: false,
|
|
1766
|
+
stem,
|
|
1767
|
+
reason,
|
|
1768
|
+
report: `Seed promotion\nstem: ${stem}\nrefused: ${reason}\n`,
|
|
1769
|
+
});
|
|
1770
|
+
|
|
1771
|
+
if (typeof stem !== 'string' || stem === '') return refuse('no stem given');
|
|
1772
|
+
try {
|
|
1773
|
+
validateStem(stem);
|
|
1774
|
+
} catch (error) {
|
|
1775
|
+
return refuse(error instanceof Error ? error.message : String(error));
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
const seedPath = path.join(libraryDir, `${stem}.md`);
|
|
1779
|
+
const rulePath = path.join(rulesDir, `${stem}.md`);
|
|
1780
|
+
const token = acquireLock(lockPath);
|
|
1781
|
+
try {
|
|
1782
|
+
const recovery = recoverPendingCommit(ledgerPath, roots);
|
|
1783
|
+
if (recovery?.recovered === 'conflict') {
|
|
1784
|
+
return refuse('a previous commit intent matches neither the previous nor the written file');
|
|
1785
|
+
}
|
|
1786
|
+
const seedContent = readExisting(seedPath);
|
|
1787
|
+
if (seedContent === null) return refuse(`no staged seed at ${renderTarget(seedPath, roots)}`);
|
|
1788
|
+
const promoted = stripProvenanceFooter(seedContent);
|
|
1789
|
+
const prior = parseLedger(readExisting(ledgerPath) ?? '');
|
|
1790
|
+
const stageRow = findOpenSeedStage(prior, seedPath, roots);
|
|
1791
|
+
if (!stageRow) return refuse(`no open seed-staged ledger row for "${stem}"`);
|
|
1792
|
+
if (readExisting(rulePath) !== null) return refuse(`a rule named "${stem}" is already active`);
|
|
1793
|
+
|
|
1794
|
+
const counts = countRulesAndLines({ rulesDir, conventionsPath: null });
|
|
1795
|
+
const envelope = evaluateEnvelope({
|
|
1796
|
+
store: 'rules',
|
|
1797
|
+
ruleCount: counts.rules.ruleCount,
|
|
1798
|
+
lineCount: counts.rules.lineCount,
|
|
1799
|
+
newRuleCount: 1,
|
|
1800
|
+
newLineCount: countNonEmptyLines(promoted),
|
|
1801
|
+
});
|
|
1802
|
+
if (!envelope.ok) return refuse(envelope.reason);
|
|
1803
|
+
|
|
1804
|
+
const reviewed = typeof stageRow.after === 'string' ? stageRow.after : promoted;
|
|
1805
|
+
const divergence = reviewed !== promoted;
|
|
1806
|
+
const entry = {
|
|
1807
|
+
signature: stageRow.signature,
|
|
1808
|
+
action: 'seed-promoted',
|
|
1809
|
+
target: rulePath,
|
|
1810
|
+
before: reviewed,
|
|
1811
|
+
after: promoted,
|
|
1812
|
+
at: now(),
|
|
1813
|
+
agent: stageRow.agent,
|
|
1814
|
+
slug: stageRow.slug,
|
|
1815
|
+
slugs: Array.isArray(stageRow.slugs) ? [...stageRow.slugs] : [],
|
|
1816
|
+
};
|
|
1817
|
+
try {
|
|
1818
|
+
commitPromotion({
|
|
1819
|
+
ledgerPath,
|
|
1820
|
+
ruleTarget: rulePath,
|
|
1821
|
+
ruleContent: promoted,
|
|
1822
|
+
seedTarget: seedPath,
|
|
1823
|
+
entry,
|
|
1824
|
+
roots,
|
|
1825
|
+
});
|
|
1826
|
+
} catch (error) {
|
|
1827
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
1828
|
+
return refuse(
|
|
1829
|
+
`the promotion write failed: ${reason}. The commit intent is retained; ` +
|
|
1830
|
+
'run `node .ai.local/scripts/run.mjs` to finish or drop it',
|
|
1831
|
+
);
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
const lines = [
|
|
1835
|
+
'Seed promotion',
|
|
1836
|
+
`stem: ${stem}`,
|
|
1837
|
+
`promoted: ${renderTarget(rulePath, roots)}`,
|
|
1838
|
+
`seed removed: ${renderTarget(seedPath, roots)}`,
|
|
1839
|
+
`ledger: seed-promoted (${stageRow.signature})`,
|
|
1840
|
+
divergence
|
|
1841
|
+
? 'divergence: the seed changed between staging and promotion — recorded in the ledger row'
|
|
1842
|
+
: 'divergence: none',
|
|
1843
|
+
];
|
|
1844
|
+
return {
|
|
1845
|
+
ok: true,
|
|
1846
|
+
stem,
|
|
1847
|
+
signature: stageRow.signature,
|
|
1848
|
+
target: rulePath,
|
|
1849
|
+
seedTarget: seedPath,
|
|
1850
|
+
reviewed,
|
|
1851
|
+
promoted,
|
|
1852
|
+
divergence,
|
|
1853
|
+
report: `${lines.join('\n')}\n`,
|
|
1854
|
+
};
|
|
1855
|
+
} finally {
|
|
1856
|
+
releaseLock(lockPath, token);
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1562
1860
|
function appendSkipGroup(lines, items, heading) {
|
|
1563
1861
|
if (items.length === 0) return;
|
|
1564
1862
|
lines.push('', heading);
|
|
@@ -1568,7 +1866,8 @@ function appendSkipGroup(lines, items, heading) {
|
|
|
1568
1866
|
function renderReport({ applied, staged, skipped, rejected, unloaded = [], errors, envelope, roots }) {
|
|
1569
1867
|
const lines = [
|
|
1570
1868
|
'Self-learning rule improver',
|
|
1571
|
-
`envelope: ${envelope.
|
|
1869
|
+
`rules envelope: ${envelope.rules.lineCount}/${MAX_RULE_LINES} lines, ${envelope.rules.ruleCount}/${MAX_ACTIVE_RULES} rules`,
|
|
1870
|
+
`conventions envelope: ${envelope.conventions.lineCount}/${MAX_CONVENTION_LINES} lines`,
|
|
1572
1871
|
'',
|
|
1573
1872
|
`applied (${applied.length}) — auto, low-risk, reversible`,
|
|
1574
1873
|
];
|
|
@@ -1598,6 +1897,14 @@ function renderReport({ applied, staged, skipped, rejected, unloaded = [], error
|
|
|
1598
1897
|
}
|
|
1599
1898
|
|
|
1600
1899
|
// CLI entry: run directly (node rule-improver.mjs) and print the report.
|
|
1900
|
+
// `--promote <stem>` promotes a staged seed into `.ai.local/rules/`.
|
|
1601
1901
|
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
1602
|
-
process.
|
|
1902
|
+
const promoteIndex = process.argv.indexOf('--promote');
|
|
1903
|
+
if (promoteIndex !== -1) {
|
|
1904
|
+
const result = runPromotion({ stem: process.argv[promoteIndex + 1] });
|
|
1905
|
+
process.stdout.write(result.report);
|
|
1906
|
+
if (!result.ok) process.exitCode = 1;
|
|
1907
|
+
} else {
|
|
1908
|
+
process.stdout.write(runImprover().report);
|
|
1909
|
+
}
|
|
1603
1910
|
}
|
|
@@ -29,7 +29,8 @@ import { pathToFileURL } from 'node:url';
|
|
|
29
29
|
import { appendSignal, groupSignatures, isSignalRecord } from './signals.mjs';
|
|
30
30
|
import {
|
|
31
31
|
MAX_ACTIVE_RULES,
|
|
32
|
-
|
|
32
|
+
MAX_RULE_LINES,
|
|
33
|
+
MAX_CONVENTION_LINES,
|
|
33
34
|
canonicalSignature,
|
|
34
35
|
collectScriptReport,
|
|
35
36
|
countRulesAndLines,
|
|
@@ -236,14 +237,27 @@ export function statusReport({ baseDir = DEFAULT_BASE_DIR } = {}) {
|
|
|
236
237
|
|
|
237
238
|
// The engine fails closed on an unreadable rule; the read-only report must
|
|
238
239
|
// still print, so the envelope degrades to `unreadable` instead of throwing.
|
|
240
|
+
// Two stores, two envelopes: the human `rules/` store and the machine
|
|
241
|
+
// `conventions.md` store each carry their own cap.
|
|
239
242
|
let envelope;
|
|
240
|
-
let
|
|
243
|
+
let rulesState;
|
|
244
|
+
let conventionsState;
|
|
241
245
|
try {
|
|
242
246
|
envelope = countRulesAndLines({ rulesDir, conventionsPath });
|
|
243
|
-
|
|
247
|
+
rulesState = evaluateEnvelope({
|
|
248
|
+
store: 'rules',
|
|
249
|
+
ruleCount: envelope.rules.ruleCount,
|
|
250
|
+
lineCount: envelope.rules.lineCount,
|
|
251
|
+
});
|
|
252
|
+
conventionsState = evaluateEnvelope({
|
|
253
|
+
store: 'conventions',
|
|
254
|
+
lineCount: envelope.conventions.lineCount,
|
|
255
|
+
});
|
|
244
256
|
} catch (error) {
|
|
245
|
-
envelope = { ruleCount: 0, lineCount: 0 };
|
|
246
|
-
|
|
257
|
+
envelope = { rules: { ruleCount: 0, lineCount: 0 }, conventions: { lineCount: 0 } };
|
|
258
|
+
const reason = `unreadable — ${error instanceof Error ? error.message : String(error)}`;
|
|
259
|
+
rulesState = { reason };
|
|
260
|
+
conventionsState = { reason };
|
|
247
261
|
}
|
|
248
262
|
const pending = deriveGateSignals({ baseDir }).signals.length;
|
|
249
263
|
|
|
@@ -251,7 +265,8 @@ export function statusReport({ baseDir = DEFAULT_BASE_DIR } = {}) {
|
|
|
251
265
|
lines.push(`store: ${storeState}`);
|
|
252
266
|
lines.push(`pending derivations: ${pending}` + (pending > 0 ? ' (evidence not captured yet)' : ''));
|
|
253
267
|
lines.push(
|
|
254
|
-
`envelope: ${envelope.
|
|
268
|
+
`rules envelope: ${envelope.rules.lineCount}/${MAX_RULE_LINES} lines, ${envelope.rules.ruleCount}/${MAX_ACTIVE_RULES} rules — ${rulesState.reason}`,
|
|
269
|
+
`conventions envelope: ${envelope.conventions.lineCount}/${MAX_CONVENTION_LINES} lines — ${conventionsState.reason}`,
|
|
255
270
|
);
|
|
256
271
|
for (const error of errors) {
|
|
257
272
|
lines.push(` - malformed store line ${error.line}: ${error.reason}`);
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* HTTP API and dashboard host for the `.ai.local/team` projection.
|
|
3
3
|
*
|
|
4
4
|
* `node:http` only. The surface is loopback-only by default, sends no CORS
|
|
5
|
-
* header, reads files through SQLite rows (never through a request path)
|
|
6
|
-
*
|
|
5
|
+
* header, and reads files through SQLite rows (never through a request path).
|
|
6
|
+
* The two mutating operations — the idempotent rescan and the confirmed task
|
|
7
|
+
* delete — each run one bounded child process; the server itself never opens a
|
|
8
|
+
* writable connection and the kill switch stops both mutations before a child
|
|
9
|
+
* is spawned.
|
|
7
10
|
*
|
|
8
11
|
* Every SQL statement in this module is a static string with bound parameters.
|
|
9
12
|
* The only interpolated fragments are the module-level constants `TASK_FILTER`,
|
|
@@ -83,6 +86,7 @@ const CODE_STATUS_ROWS = [
|
|
|
83
86
|
['E_DOC_NOT_FOUND', 404],
|
|
84
87
|
['E_DOC_BINARY', 410],
|
|
85
88
|
['E_DOC_CONTENT_OMITTED', 409],
|
|
89
|
+
['E_ACTIVE_TASK', 409],
|
|
86
90
|
['E_RANGE', 416],
|
|
87
91
|
['E_DISABLED', 503],
|
|
88
92
|
['E_DB_MISSING', 503],
|
|
@@ -899,6 +903,7 @@ const getHealth = (handle, settings) => {
|
|
|
899
903
|
},
|
|
900
904
|
tasks: { total: Number(totals.total), absent: Number(totals.absent) },
|
|
901
905
|
projectedAt: totals.projected_at ?? null,
|
|
906
|
+
capabilities: ['sync', 'delete'],
|
|
902
907
|
};
|
|
903
908
|
};
|
|
904
909
|
|
|
@@ -974,6 +979,56 @@ const runSyncChild = (db, settings) => {
|
|
|
974
979
|
};
|
|
975
980
|
};
|
|
976
981
|
|
|
982
|
+
/* --------------------------------- delete ---------------------------------- */
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* Delete one task through the canonical CLI implementation in a bounded child.
|
|
986
|
+
*
|
|
987
|
+
* The kill switch is checked before anything runs; the server process never
|
|
988
|
+
* opens a writable connection. The child prints exactly one JSON line: the
|
|
989
|
+
* result on success, `{ ok: false, code, message }` on a refusal — and every
|
|
990
|
+
* refusal code is mapped back into the one documented envelope, so no
|
|
991
|
+
* unspecified code ever leaks. The 30 s `SIGKILL` bound and the sanitized
|
|
992
|
+
* one-line stderr detail are the rescan child's own.
|
|
993
|
+
*/
|
|
994
|
+
const runDeleteChild = (slug, settings) => {
|
|
995
|
+
if (isKillSwitchSet()) fail('E_DISABLED', 503, 'the projection is disabled by AI_RULES_TEAM_DB_DISABLE');
|
|
996
|
+
const script = path.join(moduleDirectory, 'team-db.mjs');
|
|
997
|
+
if (!fs.existsSync(script)) fail('E_DB_MISSING', 503, 'team-db.mjs is not installed next to the server');
|
|
998
|
+
const child = spawnSync(
|
|
999
|
+
process.execPath,
|
|
1000
|
+
[script, 'delete', '--slug', slug, '--json', '--root', settings.teamRoot],
|
|
1001
|
+
{ cwd: settings.cwd, env: { ...process.env, AI_RULES_TEAM_DB_PATH: settings.dbPath }, encoding: 'utf8', timeout: SYNC_CHILD_TIMEOUT_MS, killSignal: 'SIGKILL', stdio: ['ignore', 'pipe', 'pipe'] },
|
|
1002
|
+
);
|
|
1003
|
+
if (child.error && child.error.code === 'ETIMEDOUT') fail('E_BUSY', 503, `the delete of ${slug} exceeded 30 s and was killed`);
|
|
1004
|
+
if (child.error) fail('E_INTERNAL', 500, 'the delete child could not start');
|
|
1005
|
+
let parsed = null;
|
|
1006
|
+
try {
|
|
1007
|
+
parsed = JSON.parse(String(child.stdout || '').trim());
|
|
1008
|
+
} catch {
|
|
1009
|
+
parsed = null;
|
|
1010
|
+
}
|
|
1011
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
1012
|
+
// One `path: reason` line, never prompt content, so an operator can act.
|
|
1013
|
+
const detail = String(child.stderr || '')
|
|
1014
|
+
.split('\n')
|
|
1015
|
+
.map((line) => line.trim())
|
|
1016
|
+
.find((line) => line.length > 0);
|
|
1017
|
+
fail('E_INTERNAL', 500, `the delete exited ${child.status} without a parseable result${detail ? ` (${detail.slice(0, 300)})` : ''}`);
|
|
1018
|
+
}
|
|
1019
|
+
if (parsed.ok === false) {
|
|
1020
|
+
const code = typeof parsed.code === 'string' ? parsed.code : 'E_INTERNAL';
|
|
1021
|
+
// The guard fires only when the target is the active slug, so the detail
|
|
1022
|
+
// names it exactly; the message the child printed names it too.
|
|
1023
|
+
const details = code === 'E_ACTIVE_TASK' ? { activeSlug: slug } : undefined;
|
|
1024
|
+
fail(mapTeamDbCode(code), mapTeamDbCode(code, true), String(parsed.message ?? `the delete of ${slug} was refused`), details);
|
|
1025
|
+
}
|
|
1026
|
+
if (parsed.ok !== true || typeof parsed.slug !== 'string') {
|
|
1027
|
+
fail('E_INTERNAL', 500, `the delete of ${slug} reported neither a success nor a documented refusal`);
|
|
1028
|
+
}
|
|
1029
|
+
return { slug: parsed.slug };
|
|
1030
|
+
};
|
|
1031
|
+
|
|
977
1032
|
/* --------------------------------- routing -------------------------------- */
|
|
978
1033
|
|
|
979
1034
|
const route = (method, routePath, operationId, handler) => ({
|
|
@@ -1016,6 +1071,13 @@ export const ROUTES = [
|
|
|
1016
1071
|
route('GET', '/api/v1/tasks/{slug}', 'getTask', (context) => ({
|
|
1017
1072
|
json: getTaskDetail(context.db(), context.params.slug),
|
|
1018
1073
|
})),
|
|
1074
|
+
route('DELETE', '/api/v1/tasks/{slug}', 'deleteTask', (context) => {
|
|
1075
|
+
// The kill switch answers before any read or child spawn; the existence
|
|
1076
|
+
// pre-read fast-fails an unknown slug through the read-only handle.
|
|
1077
|
+
if (isKillSwitchSet()) fail('E_DISABLED', 503, 'the projection is disabled by AI_RULES_TEAM_DB_DISABLE');
|
|
1078
|
+
requireTask(context.db(), context.params.slug);
|
|
1079
|
+
return { json: runDeleteChild(context.params.slug, context.settings) };
|
|
1080
|
+
}),
|
|
1019
1081
|
taskRoute('getTaskPipeline', { path: 'pipeline', handler: getPipeline }),
|
|
1020
1082
|
taskRoute('listTaskAttempts', { path: 'attempts', handler: listAttempts }),
|
|
1021
1083
|
taskRoute('listTaskEvents', { path: 'events', handler: listEvents }),
|
|
@@ -1155,7 +1217,12 @@ const handle = async (req, res, settings) => {
|
|
|
1155
1217
|
if (!entry) {
|
|
1156
1218
|
const allowed = methodsFor(pathname);
|
|
1157
1219
|
if (allowed.length > 0) {
|
|
1158
|
-
|
|
1220
|
+
// HEAD rides the GET entry, so a path that serves GET advertises it;
|
|
1221
|
+
// the shared task path advertises `GET, HEAD, DELETE`, never a
|
|
1222
|
+
// GET-biased list that hides DELETE.
|
|
1223
|
+
const allow = allowed.includes('GET')
|
|
1224
|
+
? ['GET', 'HEAD', ...allowed.filter((candidate) => candidate !== 'GET')].join(', ')
|
|
1225
|
+
: allowed.join(', ');
|
|
1159
1226
|
sendJson(req, res, 405, { error: { code: 'E_METHOD_NOT_ALLOWED', message: `${method} is not allowed on ${pathname}` } }, { Allow: allow });
|
|
1160
1227
|
return;
|
|
1161
1228
|
}
|