@bonesofspring/ai-rules 0.2.73 → 0.2.76
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 +88 -0
- package/README.md +2 -2
- package/bin/lib/engine-scripts.js +12 -0
- package/docs/TEAM-DB.md +96 -5
- package/docs/TOKEN-ECONOMY.md +18 -5
- package/docs/openapi/team-db.v1.json +1164 -224
- package/package.json +2 -2
- package/presets/_shared/ai-local/scripts/action-signals.mjs +225 -0
- package/presets/_shared/ai-local/scripts/actions-report.mjs +210 -0
- package/presets/_shared/ai-local/scripts/check-write-scope.mjs +56 -26
- package/presets/_shared/ai-local/scripts/lock.mjs +103 -30
- package/presets/_shared/ai-local/scripts/processes.mjs +5 -4
- package/presets/_shared/ai-local/scripts/rr-scheduler-start.mjs +161 -0
- package/presets/_shared/ai-local/scripts/rule-improver.mjs +4 -0
- package/presets/_shared/ai-local/scripts/run-compact.mjs +132 -0
- package/presets/_shared/ai-local/scripts/signals.mjs +3 -1
- package/presets/_shared/ai-local/scripts/team-db-api.mjs +354 -11
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +309 -4
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +515 -26
- package/presets/_shared/ai-local/scripts/team-db-scheduler.mjs +32 -2
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +185 -1
- package/presets/_shared/ai-local/scripts/team-db-task-runner.mjs +3 -1
- package/presets/_shared/core/agent-team/agent-task-metrics.md +29 -0
- package/presets/_shared/core/agent-team/agent-team-orchestrator.md +1 -1
- package/presets/_shared/core/meta/preset-pr-checklist.md +2 -2
- package/presets/_shared/core/quality/context-and-iteration.md +1 -1
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +18 -1
- package/presets/_shared/hooks/compact-shell-output.mjs +68 -0
- package/presets/claude/android-kotlin/commands/README.md +4 -0
- package/presets/claude/android-kotlin/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +18 -1
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/android-kotlin/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/android-kotlin/team/README.md +1 -1
- package/presets/claude/go/commands/README.md +4 -0
- package/presets/claude/go/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/go/hooks/chain-team-phases.sh +18 -1
- package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/go/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/go/team/README.md +1 -1
- package/presets/claude/ios-swift/commands/README.md +4 -0
- package/presets/claude/ios-swift/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +18 -1
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/ios-swift/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/ios-swift/team/README.md +1 -1
- package/presets/claude/java/commands/README.md +4 -0
- package/presets/claude/java/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/java/hooks/chain-team-phases.sh +18 -1
- package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/java/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/java/team/README.md +1 -1
- package/presets/claude/mcp-ts/commands/README.md +4 -0
- package/presets/claude/mcp-ts/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +18 -1
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/mcp-ts/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/mcp-ts/team/README.md +1 -1
- package/presets/claude/mol/commands/README.md +4 -0
- package/presets/claude/mol/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/mol/hooks/chain-team-phases.sh +18 -1
- package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/mol/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/mol/team/README.md +1 -1
- package/presets/claude/next/agents/build-verifier.md +1 -1
- package/presets/claude/next/agents/code-reviewer.md +2 -0
- package/presets/claude/next/commands/README.md +4 -0
- package/presets/claude/next/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/next/hooks/chain-team-phases.sh +18 -1
- package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/next/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/next/team/README.md +1 -1
- package/presets/claude/nuxt/commands/README.md +4 -0
- package/presets/claude/nuxt/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +18 -1
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/nuxt/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/nuxt/team/README.md +1 -1
- package/presets/claude/php-hexagonal/commands/README.md +4 -0
- package/presets/claude/php-hexagonal/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +18 -1
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/php-hexagonal/team/README.md +1 -1
- package/presets/claude/php-laravel/commands/README.md +4 -0
- package/presets/claude/php-laravel/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +18 -1
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/php-laravel/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/php-laravel/team/README.md +1 -1
- package/presets/claude/svelte/commands/README.md +4 -0
- package/presets/claude/svelte/commands/rr-scheduler-start.md +32 -0
- package/presets/claude/svelte/hooks/chain-team-phases.sh +18 -1
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/svelte/rules/tooling-and-review/preset-pr-checklist.md +2 -2
- package/presets/claude/svelte/team/README.md +1 -1
- package/presets/cursor/android-kotlin/commands/README.md +4 -0
- package/presets/cursor/android-kotlin/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +18 -1
- package/presets/cursor/android-kotlin/hooks/compact-shell-output.mjs +68 -0
- package/presets/cursor/android-kotlin/hooks.json +7 -0
- package/presets/cursor/android-kotlin/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/android-kotlin/team/README.md +1 -1
- package/presets/cursor/go/commands/README.md +4 -0
- package/presets/cursor/go/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/go/hooks/chain-team-phases.sh +18 -1
- package/presets/cursor/go/hooks/compact-shell-output.mjs +68 -0
- package/presets/cursor/go/hooks.json +7 -0
- package/presets/cursor/go/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/go/team/README.md +1 -1
- package/presets/cursor/ios-swift/commands/README.md +4 -0
- package/presets/cursor/ios-swift/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +18 -1
- package/presets/cursor/ios-swift/hooks/compact-shell-output.mjs +68 -0
- package/presets/cursor/ios-swift/hooks.json +7 -0
- package/presets/cursor/ios-swift/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/ios-swift/team/README.md +1 -1
- package/presets/cursor/java/commands/README.md +4 -0
- package/presets/cursor/java/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/java/hooks/chain-team-phases.sh +18 -1
- package/presets/cursor/java/hooks/compact-shell-output.mjs +68 -0
- package/presets/cursor/java/hooks.json +7 -0
- package/presets/cursor/java/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/java/team/README.md +1 -1
- package/presets/cursor/mcp-ts/commands/README.md +4 -0
- package/presets/cursor/mcp-ts/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +18 -1
- package/presets/cursor/mcp-ts/hooks/compact-shell-output.mjs +68 -0
- package/presets/cursor/mcp-ts/hooks.json +7 -0
- package/presets/cursor/mcp-ts/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/mcp-ts/team/README.md +1 -1
- package/presets/cursor/mol/commands/README.md +4 -0
- package/presets/cursor/mol/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/mol/hooks/chain-team-phases.sh +18 -1
- package/presets/cursor/mol/hooks/compact-shell-output.mjs +68 -0
- package/presets/cursor/mol/hooks.json +7 -0
- package/presets/cursor/mol/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/mol/team/README.md +1 -1
- package/presets/cursor/next/agents/build-verifier.md +1 -1
- package/presets/cursor/next/agents/code-reviewer.md +2 -0
- package/presets/cursor/next/commands/README.md +4 -0
- package/presets/cursor/next/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/next/hooks/chain-team-phases.sh +18 -1
- package/presets/cursor/next/hooks/compact-shell-output.mjs +68 -0
- package/presets/cursor/next/hooks.json +7 -0
- package/presets/cursor/next/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/next/team/README.md +1 -1
- package/presets/cursor/nuxt/commands/README.md +4 -0
- package/presets/cursor/nuxt/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +18 -1
- package/presets/cursor/nuxt/hooks/compact-shell-output.mjs +68 -0
- package/presets/cursor/nuxt/hooks.json +7 -0
- package/presets/cursor/nuxt/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/nuxt/team/README.md +1 -1
- package/presets/cursor/php-hexagonal/commands/README.md +4 -0
- package/presets/cursor/php-hexagonal/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +18 -1
- package/presets/cursor/php-hexagonal/hooks/compact-shell-output.mjs +68 -0
- package/presets/cursor/php-hexagonal/hooks.json +7 -0
- package/presets/cursor/php-hexagonal/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/php-hexagonal/team/README.md +1 -1
- package/presets/cursor/php-laravel/commands/README.md +4 -0
- package/presets/cursor/php-laravel/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +18 -1
- package/presets/cursor/php-laravel/hooks/compact-shell-output.mjs +68 -0
- package/presets/cursor/php-laravel/hooks.json +7 -0
- package/presets/cursor/php-laravel/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/php-laravel/team/README.md +1 -1
- package/presets/cursor/svelte/commands/README.md +4 -0
- package/presets/cursor/svelte/commands/rr-scheduler-start.md +32 -0
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +18 -1
- package/presets/cursor/svelte/hooks/compact-shell-output.mjs +68 -0
- package/presets/cursor/svelte/hooks.json +7 -0
- package/presets/cursor/svelte/rules/preset-pr-checklist.mdc +2 -2
- package/presets/cursor/svelte/team/README.md +1 -1
- package/presets/mavis/android-kotlin/adapter-map.json +17 -1
- package/presets/mavis/android-kotlin/commands/README.md +4 -0
- package/presets/mavis/android-kotlin/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +18 -1
- package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/android-kotlin/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/android-kotlin/team/README.md +1 -1
- package/presets/mavis/go/adapter-map.json +17 -1
- package/presets/mavis/go/commands/README.md +4 -0
- package/presets/mavis/go/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/go/hooks/chain-team-phases.sh +18 -1
- package/presets/mavis/go/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/go/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/go/team/README.md +1 -1
- package/presets/mavis/ios-swift/adapter-map.json +17 -1
- package/presets/mavis/ios-swift/commands/README.md +4 -0
- package/presets/mavis/ios-swift/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +18 -1
- package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/ios-swift/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/ios-swift/team/README.md +1 -1
- package/presets/mavis/java/adapter-map.json +17 -1
- package/presets/mavis/java/commands/README.md +4 -0
- package/presets/mavis/java/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/java/hooks/chain-team-phases.sh +18 -1
- package/presets/mavis/java/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/java/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/java/team/README.md +1 -1
- package/presets/mavis/mcp-ts/adapter-map.json +17 -1
- package/presets/mavis/mcp-ts/commands/README.md +4 -0
- package/presets/mavis/mcp-ts/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +18 -1
- package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/mcp-ts/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/mcp-ts/team/README.md +1 -1
- package/presets/mavis/mol/adapter-map.json +17 -1
- package/presets/mavis/mol/commands/README.md +4 -0
- package/presets/mavis/mol/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/mol/hooks/chain-team-phases.sh +18 -1
- package/presets/mavis/mol/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/mol/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/mol/team/README.md +1 -1
- package/presets/mavis/next/adapter-map.json +17 -1
- package/presets/mavis/next/agents/build-verifier.md +1 -1
- package/presets/mavis/next/agents/code-reviewer.md +2 -0
- package/presets/mavis/next/commands/README.md +4 -0
- package/presets/mavis/next/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/next/hooks/chain-team-phases.sh +18 -1
- package/presets/mavis/next/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/next/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/next/team/README.md +1 -1
- package/presets/mavis/nuxt/adapter-map.json +17 -1
- package/presets/mavis/nuxt/commands/README.md +4 -0
- package/presets/mavis/nuxt/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +18 -1
- package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/nuxt/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/nuxt/team/README.md +1 -1
- package/presets/mavis/php-hexagonal/adapter-map.json +17 -1
- package/presets/mavis/php-hexagonal/commands/README.md +4 -0
- package/presets/mavis/php-hexagonal/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +18 -1
- package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/php-hexagonal/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/php-hexagonal/team/README.md +1 -1
- package/presets/mavis/php-laravel/adapter-map.json +17 -1
- package/presets/mavis/php-laravel/commands/README.md +4 -0
- package/presets/mavis/php-laravel/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +18 -1
- package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/php-laravel/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/php-laravel/team/README.md +1 -1
- package/presets/mavis/svelte/adapter-map.json +17 -1
- package/presets/mavis/svelte/commands/README.md +4 -0
- package/presets/mavis/svelte/commands/rr-scheduler-start.md +27 -0
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +18 -1
- package/presets/mavis/svelte/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/svelte/rules/preset-pr-checklist.md +2 -2
- package/presets/mavis/svelte/team/README.md +1 -1
- package/presets/opencode/android-kotlin/adapter-map.json +17 -1
- package/presets/opencode/android-kotlin/commands/README.md +4 -0
- package/presets/opencode/android-kotlin/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +18 -1
- package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/android-kotlin/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/android-kotlin/team/README.md +1 -1
- package/presets/opencode/go/adapter-map.json +17 -1
- package/presets/opencode/go/commands/README.md +4 -0
- package/presets/opencode/go/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/go/hooks/chain-team-phases.sh +18 -1
- package/presets/opencode/go/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/go/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/go/team/README.md +1 -1
- package/presets/opencode/ios-swift/adapter-map.json +17 -1
- package/presets/opencode/ios-swift/commands/README.md +4 -0
- package/presets/opencode/ios-swift/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +18 -1
- package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/ios-swift/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/ios-swift/team/README.md +1 -1
- package/presets/opencode/java/adapter-map.json +17 -1
- package/presets/opencode/java/commands/README.md +4 -0
- package/presets/opencode/java/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/java/hooks/chain-team-phases.sh +18 -1
- package/presets/opencode/java/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/java/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/java/team/README.md +1 -1
- package/presets/opencode/mcp-ts/adapter-map.json +17 -1
- package/presets/opencode/mcp-ts/commands/README.md +4 -0
- package/presets/opencode/mcp-ts/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +18 -1
- package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/mcp-ts/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/mcp-ts/team/README.md +1 -1
- package/presets/opencode/mol/adapter-map.json +17 -1
- package/presets/opencode/mol/commands/README.md +4 -0
- package/presets/opencode/mol/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/mol/hooks/chain-team-phases.sh +18 -1
- package/presets/opencode/mol/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/mol/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/mol/team/README.md +1 -1
- package/presets/opencode/next/adapter-map.json +17 -1
- package/presets/opencode/next/agents/build-verifier.md +1 -1
- package/presets/opencode/next/agents/code-reviewer.md +2 -0
- package/presets/opencode/next/commands/README.md +4 -0
- package/presets/opencode/next/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/next/hooks/chain-team-phases.sh +18 -1
- package/presets/opencode/next/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/next/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/next/team/README.md +1 -1
- package/presets/opencode/nuxt/adapter-map.json +17 -1
- package/presets/opencode/nuxt/commands/README.md +4 -0
- package/presets/opencode/nuxt/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +18 -1
- package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/nuxt/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/nuxt/team/README.md +1 -1
- package/presets/opencode/php-hexagonal/adapter-map.json +17 -1
- package/presets/opencode/php-hexagonal/commands/README.md +4 -0
- package/presets/opencode/php-hexagonal/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +18 -1
- package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/php-hexagonal/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/php-hexagonal/team/README.md +1 -1
- package/presets/opencode/php-laravel/adapter-map.json +17 -1
- package/presets/opencode/php-laravel/commands/README.md +4 -0
- package/presets/opencode/php-laravel/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +18 -1
- package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/php-laravel/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/php-laravel/team/README.md +1 -1
- package/presets/opencode/plugins/output-guard/README.md +45 -3
- package/presets/opencode/plugins/output-guard/actions.ts +201 -0
- package/presets/opencode/plugins/output-guard/index.ts +147 -6
- package/presets/opencode/plugins/output-guard/rewrite.ts +10 -1
- package/presets/opencode/svelte/adapter-map.json +17 -1
- package/presets/opencode/svelte/commands/README.md +4 -0
- package/presets/opencode/svelte/commands/rr-scheduler-start.md +35 -0
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +18 -1
- package/presets/opencode/svelte/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/svelte/rules/preset-pr-checklist.md +2 -2
- package/presets/opencode/svelte/team/README.md +1 -1
- package/presets/zcode/android-kotlin/adapter-map.json +17 -1
- package/presets/zcode/android-kotlin/commands/README.md +4 -0
- package/presets/zcode/android-kotlin/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +18 -1
- package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/android-kotlin/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/android-kotlin/team/README.md +1 -1
- package/presets/zcode/go/adapter-map.json +17 -1
- package/presets/zcode/go/commands/README.md +4 -0
- package/presets/zcode/go/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/go/hooks/chain-team-phases.sh +18 -1
- package/presets/zcode/go/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/go/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/go/team/README.md +1 -1
- package/presets/zcode/ios-swift/adapter-map.json +17 -1
- package/presets/zcode/ios-swift/commands/README.md +4 -0
- package/presets/zcode/ios-swift/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +18 -1
- package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/ios-swift/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/ios-swift/team/README.md +1 -1
- package/presets/zcode/java/adapter-map.json +17 -1
- package/presets/zcode/java/commands/README.md +4 -0
- package/presets/zcode/java/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/java/hooks/chain-team-phases.sh +18 -1
- package/presets/zcode/java/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/java/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/java/team/README.md +1 -1
- package/presets/zcode/mcp-ts/adapter-map.json +17 -1
- package/presets/zcode/mcp-ts/commands/README.md +4 -0
- package/presets/zcode/mcp-ts/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +18 -1
- package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/mcp-ts/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/mcp-ts/team/README.md +1 -1
- package/presets/zcode/mol/adapter-map.json +17 -1
- package/presets/zcode/mol/commands/README.md +4 -0
- package/presets/zcode/mol/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/mol/hooks/chain-team-phases.sh +18 -1
- package/presets/zcode/mol/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/mol/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/mol/team/README.md +1 -1
- package/presets/zcode/next/adapter-map.json +17 -1
- package/presets/zcode/next/agents/build-verifier.md +1 -1
- package/presets/zcode/next/agents/code-reviewer.md +2 -0
- package/presets/zcode/next/commands/README.md +4 -0
- package/presets/zcode/next/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/next/hooks/chain-team-phases.sh +18 -1
- package/presets/zcode/next/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/next/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/next/team/README.md +1 -1
- package/presets/zcode/nuxt/adapter-map.json +17 -1
- package/presets/zcode/nuxt/commands/README.md +4 -0
- package/presets/zcode/nuxt/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +18 -1
- package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/nuxt/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/nuxt/team/README.md +1 -1
- package/presets/zcode/php-hexagonal/adapter-map.json +17 -1
- package/presets/zcode/php-hexagonal/commands/README.md +4 -0
- package/presets/zcode/php-hexagonal/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +18 -1
- package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/php-hexagonal/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/php-hexagonal/team/README.md +1 -1
- package/presets/zcode/php-laravel/adapter-map.json +17 -1
- package/presets/zcode/php-laravel/commands/README.md +4 -0
- package/presets/zcode/php-laravel/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +18 -1
- package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/php-laravel/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/php-laravel/team/README.md +1 -1
- package/presets/zcode/svelte/adapter-map.json +17 -1
- package/presets/zcode/svelte/commands/README.md +4 -0
- package/presets/zcode/svelte/commands/rr-scheduler-start.md +35 -0
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +18 -1
- package/presets/zcode/svelte/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/svelte/rules/preset-pr-checklist.md +2 -2
- package/presets/zcode/svelte/team/README.md +1 -1
- package/scripts/close-agent-task-human-gate.mjs +3 -3
- package/scripts/report-context-cost.mjs +10 -3
- package/scripts/aggregate-agent-task-metrics.mjs +0 -480
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
isKillSwitchSet,
|
|
33
33
|
isSqliteAvailable,
|
|
34
34
|
openTeamDb,
|
|
35
|
+
readNewerSchemaModule,
|
|
35
36
|
teamDbFail,
|
|
36
37
|
} from './team-db-schema.mjs';
|
|
37
38
|
|
|
@@ -2223,8 +2224,9 @@ export async function runScheduler(options = {}) {
|
|
|
2223
2224
|
}
|
|
2224
2225
|
fs.mkdirSync(schedulerPaths(teamRoot).runs, { recursive: true, mode: 0o700 });
|
|
2225
2226
|
|
|
2226
|
-
|
|
2227
|
-
|
|
2227
|
+
let handle = openTeamDb({ teamRoot });
|
|
2228
|
+
let db = handle.db;
|
|
2229
|
+
let loadedSchemaMtime = 0;
|
|
2228
2230
|
let draining = false;
|
|
2229
2231
|
const inFlight = new Set();
|
|
2230
2232
|
|
|
@@ -2258,7 +2260,35 @@ export async function runScheduler(options = {}) {
|
|
|
2258
2260
|
process.once('SIGINT', shutdown);
|
|
2259
2261
|
process.once('SIGTERM', shutdown);
|
|
2260
2262
|
|
|
2263
|
+
const reloadSchema = async () => {
|
|
2264
|
+
if (inFlight.size > 0) return;
|
|
2265
|
+
let fresh = null;
|
|
2266
|
+
try {
|
|
2267
|
+
fresh = await readNewerSchemaModule();
|
|
2268
|
+
} catch (error) {
|
|
2269
|
+
err(`schedule: schema reload failed: ${error.message}\n`);
|
|
2270
|
+
return;
|
|
2271
|
+
}
|
|
2272
|
+
if (!fresh || fresh.mtimeMs === loadedSchemaMtime) return;
|
|
2273
|
+
try {
|
|
2274
|
+
const next = fresh.openTeamDb({ teamRoot });
|
|
2275
|
+
try {
|
|
2276
|
+
handle.db.close();
|
|
2277
|
+
} catch {
|
|
2278
|
+
/* the replacement connection is the one the next tick uses */
|
|
2279
|
+
}
|
|
2280
|
+
handle = next;
|
|
2281
|
+
db = next.db;
|
|
2282
|
+
loadedSchemaMtime = fresh.mtimeMs;
|
|
2283
|
+
if (!options.quiet) out(`schedule: reloaded schema v${fresh.SCHEMA_VERSION}\n`);
|
|
2284
|
+
} catch (error) {
|
|
2285
|
+
loadedSchemaMtime = fresh.mtimeMs;
|
|
2286
|
+
err(`schedule: schema reload failed: ${error.message}\n`);
|
|
2287
|
+
}
|
|
2288
|
+
};
|
|
2289
|
+
|
|
2261
2290
|
const tick = async () => {
|
|
2291
|
+
await reloadSchema();
|
|
2262
2292
|
const now = Date.now();
|
|
2263
2293
|
const nowIso = new Date(now).toISOString();
|
|
2264
2294
|
let file;
|
|
@@ -18,6 +18,7 @@ import crypto from 'node:crypto';
|
|
|
18
18
|
import fs from 'node:fs';
|
|
19
19
|
import { createRequire } from 'node:module';
|
|
20
20
|
import path from 'node:path';
|
|
21
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
21
22
|
|
|
22
23
|
/** Node floor for the unflagged `node:sqlite` module. */
|
|
23
24
|
export const MIN_NODE = '22.13.0';
|
|
@@ -711,8 +712,140 @@ CREATE TABLE context_cost_hosts (
|
|
|
711
712
|
) STRICT;
|
|
712
713
|
`;
|
|
713
714
|
|
|
714
|
-
|
|
715
|
+
/**
|
|
716
|
+
* Migration 6: the action plane. Ten `tool_calls` columns, six `usage_turns`
|
|
717
|
+
* columns, one index and the two read-time views.
|
|
718
|
+
*
|
|
719
|
+
* Every column is nullable so a version-5 file migrates in place with no row
|
|
720
|
+
* copy. The views stay thin on purpose: a ratio whose denominator can be zero
|
|
721
|
+
* is left to the reader, because a threshold or a `NULLIF` literal in the view
|
|
722
|
+
* would need a new migration to recalibrate.
|
|
723
|
+
*/
|
|
724
|
+
export const ACTION_TELEMETRY_SQL = SQL`-- The action row: identity, timing and outcome, no text and no absolute path.
|
|
725
|
+
ALTER TABLE tool_calls ADD COLUMN intent TEXT; -- explore|mutate|execute|delegate|ask|meta|web
|
|
726
|
+
ALTER TABLE tool_calls ADD COLUMN agent TEXT;
|
|
727
|
+
ALTER TABLE tool_calls ADD COLUMN parent_session_id TEXT;
|
|
728
|
+
ALTER TABLE tool_calls ADD COLUMN duration_ms INTEGER;
|
|
729
|
+
ALTER TABLE tool_calls ADD COLUMN gap_ms INTEGER;
|
|
730
|
+
ALTER TABLE tool_calls ADD COLUMN target_key TEXT; -- sha256 of the normalised target
|
|
731
|
+
ALTER TABLE tool_calls ADD COLUMN repeat_of TEXT; -- the call id of the first hit on the key
|
|
732
|
+
ALTER TABLE tool_calls ADD COLUMN repeat_index INTEGER;
|
|
733
|
+
ALTER TABLE tool_calls ADD COLUMN exit_code INTEGER;
|
|
734
|
+
ALTER TABLE tool_calls ADD COLUMN error_class TEXT; -- validation|notfound|permission|timeout|upstream
|
|
735
|
+
|
|
736
|
+
ALTER TABLE usage_turns ADD COLUMN reasoning_parts INTEGER;
|
|
737
|
+
ALTER TABLE usage_turns ADD COLUMN reasoning_chars INTEGER;
|
|
738
|
+
ALTER TABLE usage_turns ADD COLUMN reasoning_ms INTEGER;
|
|
739
|
+
ALTER TABLE usage_turns ADD COLUMN text_chars INTEGER;
|
|
740
|
+
ALTER TABLE usage_turns ADD COLUMN tool_calls INTEGER;
|
|
741
|
+
ALTER TABLE usage_turns ADD COLUMN compactions INTEGER;
|
|
742
|
+
|
|
743
|
+
CREATE INDEX idx_tool_calls_task_observed ON tool_calls(task_slug, observed_at);
|
|
744
|
+
|
|
745
|
+
-- One row per task with actions. Counts, numerators and the two window edges;
|
|
746
|
+
-- every ratio is derived by the reader (D-6).
|
|
747
|
+
CREATE VIEW task_action_summary AS
|
|
748
|
+
SELECT
|
|
749
|
+
c.task_slug,
|
|
750
|
+
count(*) AS actions,
|
|
751
|
+
COALESCE(SUM(CASE WHEN c.intent = 'explore' THEN 1 ELSE 0 END), 0) AS explore,
|
|
752
|
+
COALESCE(SUM(CASE WHEN c.intent = 'mutate' THEN 1 ELSE 0 END), 0) AS mutate,
|
|
753
|
+
COALESCE(SUM(CASE WHEN c.intent = 'execute' THEN 1 ELSE 0 END), 0) AS execute,
|
|
754
|
+
COALESCE(SUM(CASE WHEN c.intent = 'delegate' THEN 1 ELSE 0 END), 0) AS delegate,
|
|
755
|
+
COALESCE(SUM(CASE WHEN c.intent = 'ask' THEN 1 ELSE 0 END), 0) AS ask,
|
|
756
|
+
COALESCE(SUM(CASE WHEN c.intent = 'meta' THEN 1 ELSE 0 END), 0) AS meta,
|
|
757
|
+
COALESCE(SUM(CASE WHEN c.intent = 'web' THEN 1 ELSE 0 END), 0) AS web,
|
|
758
|
+
COALESCE(SUM(CASE WHEN c.error_class IS NOT NULL THEN 1 ELSE 0 END), 0) AS error_actions,
|
|
759
|
+
COALESCE(SUM(CASE WHEN c.repeat_index IS NOT NULL THEN 1 ELSE 0 END), 0) AS repeat_actions,
|
|
760
|
+
COALESCE(SUM(c.replaced), 0) AS guard_hits,
|
|
761
|
+
COALESCE(SUM(CASE WHEN c.duration_ms IS NOT NULL THEN c.duration_ms ELSE 0 END), 0) AS busy_ms,
|
|
762
|
+
COALESCE(SUM(CASE WHEN c.duration_ms IS NOT NULL THEN 1 ELSE 0 END), 0) AS measured_actions,
|
|
763
|
+
COUNT(DISTINCT CASE WHEN c.intent = 'mutate' THEN c.target_key END) AS changed_files,
|
|
764
|
+
MIN(c.observed_at) AS first_at,
|
|
765
|
+
MAX(c.observed_at) AS last_at,
|
|
766
|
+
COALESCE(SUM(CASE WHEN c.attribution = 'lease' THEN 1 ELSE 0 END), 0) AS rung_lease,
|
|
767
|
+
COALESCE(SUM(CASE WHEN c.attribution = 'window' THEN 1 ELSE 0 END), 0) AS rung_window,
|
|
768
|
+
COALESCE(SUM(CASE WHEN c.attribution = 'dir-mtime' THEN 1 ELSE 0 END), 0) AS rung_dir_mtime,
|
|
769
|
+
COALESCE(SUM(CASE WHEN c.attribution = 'unmapped' THEN 1 ELSE 0 END), 0) AS rung_unmapped,
|
|
770
|
+
(SELECT count(*) FROM usage_turns u WHERE u.task_slug = c.task_slug) AS turns,
|
|
771
|
+
(SELECT COALESCE(SUM(u.input_tokens + u.output_tokens + u.reasoning_tokens), 0)
|
|
772
|
+
FROM usage_turns u WHERE u.task_slug = c.task_slug) AS tokens,
|
|
773
|
+
(SELECT COALESCE(SUM(u.reasoning_parts), 0) FROM usage_turns u WHERE u.task_slug = c.task_slug) AS reasoning_parts,
|
|
774
|
+
(SELECT COALESCE(SUM(u.compactions), 0) FROM usage_turns u WHERE u.task_slug = c.task_slug) AS compactions,
|
|
775
|
+
(SELECT COALESCE(SUM(u.tool_calls), 0) FROM usage_turns u WHERE u.task_slug = c.task_slug) AS turn_tool_calls
|
|
776
|
+
FROM tool_calls c
|
|
777
|
+
WHERE c.task_slug IS NOT NULL AND c.task_slug <> ''
|
|
778
|
+
GROUP BY c.task_slug;
|
|
779
|
+
|
|
780
|
+
-- One row per signal with a non-zero numerator. No threshold, no severity and no
|
|
781
|
+
-- rule text live here: the reader pins all three, so recalibrating a signal is a
|
|
782
|
+
-- code change with no migration and no backfill.
|
|
783
|
+
CREATE VIEW action_signals AS
|
|
784
|
+
SELECT task_slug, signal, value FROM (
|
|
785
|
+
SELECT task_slug, 'error_rate' AS signal, error_actions AS value FROM task_action_summary
|
|
786
|
+
UNION ALL SELECT task_slug, 'repeat_churn', repeat_actions FROM task_action_summary
|
|
787
|
+
UNION ALL SELECT task_slug, 'guard_pressure', guard_hits FROM task_action_summary
|
|
788
|
+
UNION ALL SELECT task_slug, 'context_thrash', compactions FROM task_action_summary
|
|
789
|
+
UNION ALL SELECT task_slug, 'weak_attribution', rung_window + rung_dir_mtime FROM task_action_summary
|
|
790
|
+
UNION ALL SELECT task_slug, 'noop_actions', CASE WHEN changed_files = 0 THEN actions ELSE 0 END FROM task_action_summary
|
|
791
|
+
UNION ALL SELECT task_slug, 'explore_without_mutate', CASE WHEN mutate = 0 THEN explore ELSE 0 END FROM task_action_summary
|
|
792
|
+
) WHERE value > 0;
|
|
793
|
+
`;
|
|
794
|
+
|
|
795
|
+
/**
|
|
796
|
+
* Migration 7: the research join. `attempt_id` on a call, one capped episode
|
|
797
|
+
* per attempt, and a closed task-quality label. Every new column is nullable
|
|
798
|
+
* and the episode table starts empty, so a version-6 file migrates in place.
|
|
799
|
+
*/
|
|
800
|
+
export const BEHAVIOR_RESEARCH_SQL = SQL`-- The call belongs to the attempt whose window contains it. Nullable:
|
|
801
|
+
-- a dir-mtime or unmapped row stays unbound.
|
|
802
|
+
ALTER TABLE tool_calls ADD COLUMN attempt_id TEXT;
|
|
715
803
|
|
|
804
|
+
CREATE INDEX idx_tool_calls_attempt ON tool_calls(attempt_id, observed_at);
|
|
805
|
+
|
|
806
|
+
-- Ordered (intent, target hash, error class) for one attempt. No command
|
|
807
|
+
-- text and no path. Rebuilt by the projector; ordinal is the only order.
|
|
808
|
+
CREATE TABLE attempt_episodes (
|
|
809
|
+
attempt_id TEXT NOT NULL,
|
|
810
|
+
ordinal INTEGER NOT NULL,
|
|
811
|
+
intent TEXT,
|
|
812
|
+
target_key TEXT,
|
|
813
|
+
error_class TEXT,
|
|
814
|
+
observed_at TEXT NOT NULL,
|
|
815
|
+
PRIMARY KEY (attempt_id, ordinal)
|
|
816
|
+
) STRICT;
|
|
817
|
+
|
|
818
|
+
-- One closed label per task. Step outcome stays on attempts; this is the
|
|
819
|
+
-- research cohort key. A task still in progress stays NULL.
|
|
820
|
+
CREATE VIEW task_quality AS
|
|
821
|
+
SELECT
|
|
822
|
+
t.slug AS task_slug,
|
|
823
|
+
CASE
|
|
824
|
+
WHEN NOT EXISTS (
|
|
825
|
+
SELECT 1 FROM events e WHERE e.task_slug = t.slug AND e.type = 'task_completed'
|
|
826
|
+
) AND EXISTS (
|
|
827
|
+
SELECT 1 FROM attempts a
|
|
828
|
+
WHERE a.task_slug = t.slug AND a.outcome IN ('blocked', 'validation_failed')
|
|
829
|
+
) THEN 'failed'
|
|
830
|
+
WHEN EXISTS (
|
|
831
|
+
SELECT 1 FROM attempts a WHERE a.task_slug = t.slug AND a.outcome = 'changes_requested'
|
|
832
|
+
) THEN 'rework'
|
|
833
|
+
WHEN EXISTS (
|
|
834
|
+
SELECT 1 FROM events e WHERE e.task_slug = t.slug AND e.type = 'task_completed'
|
|
835
|
+
) AND EXISTS (
|
|
836
|
+
SELECT 1 FROM events e WHERE e.task_slug = t.slug AND e.type = 'verification_recorded'
|
|
837
|
+
) AND NOT EXISTS (
|
|
838
|
+
SELECT 1 FROM events e WHERE e.task_slug = t.slug AND e.type = 'verification_stale'
|
|
839
|
+
) THEN 'met'
|
|
840
|
+
WHEN EXISTS (
|
|
841
|
+
SELECT 1 FROM events e WHERE e.task_slug = t.slug AND e.type = 'task_completed'
|
|
842
|
+
) THEN 'unverified'
|
|
843
|
+
ELSE NULL
|
|
844
|
+
END AS quality
|
|
845
|
+
FROM tasks t;
|
|
846
|
+
`;
|
|
847
|
+
|
|
848
|
+
const sha256 = (value) => crypto.createHash('sha256').update(value).digest('hex');
|
|
716
849
|
/**
|
|
717
850
|
* Ordered, immutable migrations. The literal checksum is verified before any
|
|
718
851
|
* DDL runs; a mismatch means the SQL changed without a new migration.
|
|
@@ -748,6 +881,18 @@ export const MIGRATIONS = [
|
|
|
748
881
|
sql: EFFICIENCY_SQL,
|
|
749
882
|
checksum: '7ae3d8509a88c77bc0ed225601b83d9a0a26748551b3e420167ea6d038ec14b1',
|
|
750
883
|
},
|
|
884
|
+
{
|
|
885
|
+
version: 6,
|
|
886
|
+
name: '0006-action-telemetry',
|
|
887
|
+
sql: ACTION_TELEMETRY_SQL,
|
|
888
|
+
checksum: 'f250814d462f1d6085ff56a1cc233179002dd5b5d97c200ed28104e4e42fbbfe',
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
version: 7,
|
|
892
|
+
name: '0007-behavior-research',
|
|
893
|
+
sql: BEHAVIOR_RESEARCH_SQL,
|
|
894
|
+
checksum: '5a64fd028118ef7b3831006a13e5ca9ac6bd17ee5ce3dfa5441d7946cf4694e0',
|
|
895
|
+
},
|
|
751
896
|
];
|
|
752
897
|
|
|
753
898
|
/** Highest migration version shipped by this module. */
|
|
@@ -1162,6 +1307,45 @@ export function moveDatabaseAside(dbPath, reason) {
|
|
|
1162
1307
|
return suffix;
|
|
1163
1308
|
}
|
|
1164
1309
|
|
|
1310
|
+
const schemaModuleUrl = new URL(import.meta.url);
|
|
1311
|
+
schemaModuleUrl.search = '';
|
|
1312
|
+
schemaModuleUrl.hash = '';
|
|
1313
|
+
const schemaModulePath = fileURLToPath(schemaModuleUrl);
|
|
1314
|
+
const schemaModuleMtimeMs = fs.statSync(schemaModulePath).mtimeMs;
|
|
1315
|
+
let newerSchemaLoad = null;
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* The schema module a long-lived process loaded at startup.
|
|
1319
|
+
*
|
|
1320
|
+
* `serve` and `schedule` keep this module in memory. A later edit that raises
|
|
1321
|
+
* `SCHEMA_VERSION`, applied by another process, makes every cached open fail
|
|
1322
|
+
* with `E_SCHEMA_NEWER`. Re-importing the file picks up that version. A
|
|
1323
|
+
* database newer than the file on disk still fails closed: the result is
|
|
1324
|
+
* `null` when the file is unchanged or its version is not higher.
|
|
1325
|
+
*
|
|
1326
|
+
* @returns {Promise<{ mtimeMs: number, SCHEMA_VERSION: number, openTeamDb: typeof openTeamDb } | null>}
|
|
1327
|
+
*/
|
|
1328
|
+
export async function readNewerSchemaModule() {
|
|
1329
|
+
let mtimeMs;
|
|
1330
|
+
try {
|
|
1331
|
+
mtimeMs = fs.statSync(schemaModulePath).mtimeMs;
|
|
1332
|
+
} catch {
|
|
1333
|
+
return null;
|
|
1334
|
+
}
|
|
1335
|
+
if (!(mtimeMs > schemaModuleMtimeMs)) return null;
|
|
1336
|
+
if (!newerSchemaLoad || newerSchemaLoad.mtimeMs !== mtimeMs) {
|
|
1337
|
+
const stamp = mtimeMs;
|
|
1338
|
+
newerSchemaLoad = {
|
|
1339
|
+
mtimeMs: stamp,
|
|
1340
|
+
promise: import(`${pathToFileURL(schemaModulePath).href}?mtime=${stamp}`).then((fresh) => {
|
|
1341
|
+
if (!(fresh.SCHEMA_VERSION > SCHEMA_VERSION)) return null;
|
|
1342
|
+
return { mtimeMs: stamp, SCHEMA_VERSION: fresh.SCHEMA_VERSION, openTeamDb: fresh.openTeamDb };
|
|
1343
|
+
}),
|
|
1344
|
+
};
|
|
1345
|
+
}
|
|
1346
|
+
return newerSchemaLoad.promise;
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1165
1349
|
/**
|
|
1166
1350
|
* Open, migrate, verify and return a connection handle.
|
|
1167
1351
|
*
|
|
@@ -158,7 +158,9 @@ const repoRootOf = (teamRoot) => path.resolve(teamRoot, '..', '..');
|
|
|
158
158
|
|
|
159
159
|
const resolveConfigCwd = (teamRoot, config) => {
|
|
160
160
|
const root = repoRootOf(teamRoot);
|
|
161
|
-
|
|
161
|
+
// A relative cwd belongs to the file that declares it, so it resolves
|
|
162
|
+
// against the team root and the seeded "../.." is the repository root.
|
|
163
|
+
const resolved = path.isAbsolute(config.cwd) ? config.cwd : path.resolve(teamRoot, config.cwd);
|
|
162
164
|
const relative = path.relative(root, resolved);
|
|
163
165
|
if (relative.startsWith('..') || path.isAbsolute(relative)) {
|
|
164
166
|
reject('E_VALIDATION', 'runner.json: cwd must stay inside the repository root');
|
|
@@ -88,6 +88,35 @@ Two write paths exist, in precedence order:
|
|
|
88
88
|
level with an explicit coverage ratio (`reportedAttempts / attempts`). Read a
|
|
89
89
|
partial coverage as "some turns were observable", never as a cost baseline.
|
|
90
90
|
|
|
91
|
+
A third source, `usage_source: session`, is filled by the projector when neither
|
|
92
|
+
path above wrote a count: it sums `usage_turns` that the lease or window rung
|
|
93
|
+
already mapped onto that attempt. It never adds to a host or CLI rollup. A
|
|
94
|
+
missing session match stays `null`.
|
|
95
|
+
|
|
96
|
+
## Research projection
|
|
97
|
+
|
|
98
|
+
The projector, not the agent, writes the research join. None of it goes into
|
|
99
|
+
`metrics.json`.
|
|
100
|
+
|
|
101
|
+
- `tool_calls.attempt_id` is set only for `lease` and `window` rows whose time
|
|
102
|
+
falls inside an attempt of that task. `dir-mtime` and `unmapped` stay unbound.
|
|
103
|
+
- `attempt_episodes` keeps at most 40 ordered `(intent, target_key, error_class)`
|
|
104
|
+
steps for that attempt. The target is the existing hash, never a path.
|
|
105
|
+
- `task_quality` is `failed`, `rework`, `met`, or `unverified`. `met` requires
|
|
106
|
+
`task_completed` plus `verification_recorded` and no `verification_stale`.
|
|
107
|
+
`rework` is any `changes_requested`. A task with no terminal event stays null.
|
|
108
|
+
- An instant session lease (no `firstSeenAt` yet) is stretched to the attempt
|
|
109
|
+
span of its slug, at most seven days either side, then clipped by the next
|
|
110
|
+
lease of that session. A stored row is re-attributed only when the new rung
|
|
111
|
+
is stronger.
|
|
112
|
+
- `gap_ms`, when the capture left it empty, is the gap to the previous call in
|
|
113
|
+
the same session, and only when that gap is under 30 minutes. `duration_ms`
|
|
114
|
+
stays null unless the host measured it.
|
|
115
|
+
- `retry_scheduled` with `nextAgent` and no `agent` projects `nextAgent` as the
|
|
116
|
+
agent. The hook does not grow a second id.
|
|
117
|
+
- A learning-ledger kind `exemplar` names a clean path. The rule improver does
|
|
118
|
+
not turn it into a rule.
|
|
119
|
+
|
|
91
120
|
## Verification evidence
|
|
92
121
|
|
|
93
122
|
`validation-report.md` stays the human-readable narrative. The machine-checkable
|
|
@@ -227,7 +227,7 @@ On each `subagentStop`, the hook reconciles `status.state` from the completing p
|
|
|
227
227
|
| `scope` | e.g. `unit-in-dev`, `e2e-only` — passed to developer/qa |
|
|
228
228
|
| `model` | `cheap` \| `standard` \| `strong` — optional tier override |
|
|
229
229
|
|
|
230
|
-
`writeScopes` are reconciled after the step, never in the hook: `node .ai.local/scripts/check-write-scope.mjs --slug <slug> --step <step-id> --json` labels every changed path `declared`, `derived`, or `out-of-scope`. The orchestrator writes the step baseline (`--step <step-id> --save-baseline`) before the step writes, so the audit sees this step's paths and not the earlier ones. Exit `3` is a skip, not a failure: a pipeline that predates step ids or `writeScopes` is not auditable, and the reason goes under `## Soft notes`. `build-verifier` hard-fails an out-of-scope implementation write; `code-reviewer` reports a reviewer-step path as advisory.
|
|
230
|
+
`writeScopes` are reconciled after the step, never in the hook: `node .ai.local/scripts/check-write-scope.mjs --slug <slug> --step <step-id> --json` labels every changed path `declared`, `derived`, or `out-of-scope`. The orchestrator writes the step baseline (`--step <step-id> --save-baseline`) before the step writes, so the audit sees this step's paths and not the earlier ones. Automatic selection only considers steps with an `id`, because the baseline file is keyed by it. Exit `3` is a skip, not a failure: a pipeline that predates step ids or `writeScopes` is not auditable, and the reason goes under `## Soft notes`. Exit `2` is a usage error (unknown `--step`, unreadable `pipeline.json`, failed git ref): the audit did not run and the result is neither a pass nor a finding — fix the invocation and re-run. A `no-baseline` skip is an orchestration defect: the step wrote without its baseline, so no path can be attributed to it — save the baseline and re-run the audit instead of reading the skip as a pass. `build-verifier` hard-fails an out-of-scope implementation write; `code-reviewer` reports a reviewer-step path as advisory.
|
|
231
231
|
|
|
232
232
|
## Rules (strict)
|
|
233
233
|
|
|
@@ -21,7 +21,7 @@ Checklist for PRs that touch `packages/ai-rules/presets/**` (and dogfood `.curso
|
|
|
21
21
|
- [ ] **README:** stack `rules/README.md` core→stack mapping / catalog updated if stems added
|
|
22
22
|
- [ ] **CHANGELOG / package README:** note when public preset paths or install surface change
|
|
23
23
|
- [ ] **i18n anchors:** kept-marked Cyrillic fragments in `tests-unit.md(c)` stay consistent with their English counterparts. Run `packages/ai-rules/scripts/check-preset-i18n.sh`.
|
|
24
|
-
- [ ] **Dogfood:** run `packages/ai-rules/scripts/sync-dogfood-cursor.sh`, `sync-dogfood-claude.sh`, `sync-dogfood-mavis.sh`, and `sync-dogfood-
|
|
24
|
+
- [ ] **Dogfood:** run `packages/ai-rules/scripts/sync-dogfood-cursor.sh`, `sync-dogfood-claude.sh`, `sync-dogfood-mavis.sh`, `sync-dogfood-opencode.sh`, and `sync-dogfood-zcode.sh` when those platforms changed, or document an intentional skip, when maintaining this monorepo
|
|
25
25
|
- [ ] **shared-core drift:** for embed-mode stems, run `packages/ai-rules/scripts/check-shared-core-drift.sh` (or document intentional fork)
|
|
26
26
|
- [ ] **Packaging:** every installable preset ships `REPO_AGENTS.md`; default `hooks.json` does not reference `hooks/examples/`; `_shared/assets/docs-specs/` ships `INDEX.md` + `_templates/{page,feature}.md`; `product-specs` / `product-specs-authoring` stay requestable
|
|
27
27
|
- [ ] **UI-only surfaces:** `mockup-reviewer`, `accessibility-reviewer`, `ux-design`, and the stack performance skill ship only on UI stacks (`check-preset-leakage.sh`)
|
|
@@ -38,6 +38,6 @@ Checklist for PRs that touch `packages/ai-rules/presets/**` (and dogfood `.curso
|
|
|
38
38
|
- Budget: `preset-token-budget`
|
|
39
39
|
- Leakage: `preset-no-cross-stack-leakage`
|
|
40
40
|
- Validation: same `check:task` / `check:changed` loop; `yarn release:gate` before a release (`packages/ai-rules/scripts/release-gate.sh`)
|
|
41
|
-
- Dogfood scripts: `packages/ai-rules/scripts/sync-dogfood-cursor.sh`, `sync-dogfood-claude.sh`, `sync-dogfood-mavis.sh`, `sync-dogfood-opencode.sh`
|
|
41
|
+
- Dogfood scripts: `packages/ai-rules/scripts/sync-dogfood-cursor.sh`, `sync-dogfood-claude.sh`, `sync-dogfood-mavis.sh`, `sync-dogfood-opencode.sh`, `sync-dogfood-zcode.sh`
|
|
42
42
|
- Drift script: `packages/ai-rules/scripts/check-shared-core-drift.sh`
|
|
43
43
|
- Orchestrator: when editing presets, load this checklist + twin-sync
|
|
@@ -6,7 +6,7 @@ Stack-agnostic. Keep each run inside a bounded context, checkpoint progress to d
|
|
|
6
6
|
|
|
7
7
|
- Work in **bounded waves** (one artifact class across the target surface) rather than one target across all classes; a wave must fit comfortably in context.
|
|
8
8
|
- **Mechanical waves** (generation, embed sync, drift re-checks) are delegated to **repo scripts** — spend tokens reading the gate output, not re-deriving the transformation.
|
|
9
|
-
- A large command output (log, diff, test run, `git log`) is piped through `.ai.local/scripts/dump-output.mjs` instead of being read whole: take its ≤40-line head, then `grep -n` the stored file or find it with `team-db.mjs search "<term>"`.
|
|
9
|
+
- A large command output (log, diff, test run, `git log`) is piped through `.ai.local/scripts/dump-output.mjs` instead of being read whole: take its ≤40-line head, then `grep -n` the stored file or find it with `team-db.mjs search "<term>"`. On Cursor, an eligible simple `test`, `lint`, `git log`, or `git diff` is rewritten into `run-compact.mjs` when `TEAM_TASK_SLUG` is set: the full output is that `outputs/` file, and the model reads the printed failure lines.
|
|
10
10
|
- Split work before the context overflows; do not carry state in the chat that belongs on disk.
|
|
11
11
|
|
|
12
12
|
## Checkpoint & resume
|
|
@@ -59,12 +59,29 @@ function readSessionLease(id) {
|
|
|
59
59
|
return null;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
// The lease carries the window the projector attributes rows with — never one
|
|
63
|
+
// instant. `firstSeenAt` survives every later write of the same (session, slug)
|
|
64
|
+
// pair; a different slug starts a new window, and a lease older than the TTL
|
|
65
|
+
// starts over instead of claiming an ancient first sighting.
|
|
66
|
+
function firstSeenAtOf(file, value, now) {
|
|
67
|
+
try {
|
|
68
|
+
if (Date.now() - fs.statSync(file).mtimeMs > LEASE_TTL_MS) return now;
|
|
69
|
+
const previous = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
70
|
+
if (previous && previous.slug === value) {
|
|
71
|
+
if (typeof previous.firstSeenAt === 'string') return previous.firstSeenAt;
|
|
72
|
+
if (typeof previous.updatedAt === 'string') return previous.updatedAt;
|
|
73
|
+
}
|
|
74
|
+
} catch {}
|
|
75
|
+
return now;
|
|
76
|
+
}
|
|
62
77
|
function writeSessionLease(id, value) {
|
|
63
78
|
try {
|
|
64
79
|
fs.mkdirSync(LEASE_ROOT, { recursive: true });
|
|
65
80
|
const file = sessionLeasePath(id);
|
|
66
81
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
67
|
-
|
|
82
|
+
const now = new Date().toISOString();
|
|
83
|
+
const firstSeenAt = firstSeenAtOf(file, value, now);
|
|
84
|
+
fs.writeFileSync(temporary, `${JSON.stringify({ slug: value, sessionId: id, firstSeenAt, updatedAt: now })}\n`);
|
|
68
85
|
fs.renameSync(temporary, file);
|
|
69
86
|
for (const name of fs.readdirSync(LEASE_ROOT)) {
|
|
70
87
|
if (!name.endsWith('.json')) continue;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Cursor preToolUse: rewrite an eligible simple command so its output is stored
|
|
3
|
+
// and only the short view reaches the model. Fail open. Edit this shared source;
|
|
4
|
+
// the generator copies it into each Cursor stack.
|
|
5
|
+
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
|
|
9
|
+
const SLUG_MAX = 48;
|
|
10
|
+
const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
11
|
+
const ELIGIBLE =
|
|
12
|
+
/^(?:(?:yarn|pnpm|npm|npx|bun)\s+(?:run\s+)?(?:test|lint)(?::\S+)?|git\s+(?:log|diff)|go\s+test|cargo\s+test|pytest|phpunit)\b/;
|
|
13
|
+
const META = /[|&;<>()\n`]|\$\(/;
|
|
14
|
+
|
|
15
|
+
const slugOf = (env) => {
|
|
16
|
+
const value = typeof env?.TEAM_TASK_SLUG === 'string' ? env.TEAM_TASK_SLUG : '';
|
|
17
|
+
if (value.length === 0 || value.length > SLUG_MAX || !SLUG_RE.test(value)) return '';
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** Return the rewritten shell string, or null to leave the command unchanged. */
|
|
22
|
+
export const rewriteCommand = (command, env) => {
|
|
23
|
+
const slug = slugOf(env);
|
|
24
|
+
if (slug === '') return null;
|
|
25
|
+
const text = typeof command === 'string' ? command.trim() : '';
|
|
26
|
+
if (text === '' || META.test(text)) return null;
|
|
27
|
+
if (text.split(/\s+/).some((token) => token.includes("'") || token.includes('"'))) return null;
|
|
28
|
+
if (text.includes('dump-output.mjs') || text.includes('run-compact.mjs')) return null;
|
|
29
|
+
if (!ELIGIBLE.test(text)) return null;
|
|
30
|
+
return `node .ai.local/scripts/run-compact.mjs --task ${slug} -- ${text}`;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const allow = () => {
|
|
34
|
+
process.stdout.write('{"permission":"allow"}');
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const commandOf = (event) => {
|
|
38
|
+
if (typeof event.command === 'string') return event.command;
|
|
39
|
+
if (typeof event.input?.command === 'string') return event.input.command;
|
|
40
|
+
if (typeof event.tool_input?.command === 'string') return event.tool_input.command;
|
|
41
|
+
return '';
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const invokedDirectly = (() => {
|
|
45
|
+
if (!process.argv[1]) return false;
|
|
46
|
+
try {
|
|
47
|
+
return fs.realpathSync(process.argv[1]) === fs.realpathSync(fileURLToPath(import.meta.url));
|
|
48
|
+
} catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
})();
|
|
52
|
+
|
|
53
|
+
if (invokedDirectly) {
|
|
54
|
+
try {
|
|
55
|
+
const parsed = JSON.parse(fs.readFileSync(0, 'utf8'));
|
|
56
|
+
const event = parsed && typeof parsed === 'object' ? parsed : null;
|
|
57
|
+
const rewritten = event ? rewriteCommand(commandOf(event), process.env) : null;
|
|
58
|
+
if (rewritten === null) {
|
|
59
|
+
allow();
|
|
60
|
+
} else {
|
|
61
|
+
process.stdout.write(
|
|
62
|
+
JSON.stringify({ permission: 'allow', updated_input: { command: rewritten } }),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
} catch {
|
|
66
|
+
allow();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -49,3 +49,7 @@ Slash commands are copied to `.claude/commands/` on `ai-rules init claude --pres
|
|
|
49
49
|
- Hooks: `../hooks/chain-team-phases.sh` (no `hooks.json` on Claude)
|
|
50
50
|
|
|
51
51
|
Create and edit commands in this preset folder (Claude Code slash commands).
|
|
52
|
+
|
|
53
|
+
## Scheduler
|
|
54
|
+
|
|
55
|
+
- **`/rr-scheduler-start`** — start the team-db scheduler, or restart it when one already holds the lease. `init` seeds `.ai.local/scripts/rr-scheduler-start.mjs`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rr-scheduler-start
|
|
3
|
+
description: Start the team-db scheduler, or restart it when one is already running.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Start or restart the scheduler
|
|
7
|
+
|
|
8
|
+
Bring up `team-db.mjs schedule` for this repository. When a scheduler already holds the lease, stop that process and start a new one.
|
|
9
|
+
|
|
10
|
+
## What to do
|
|
11
|
+
|
|
12
|
+
1. From the repository root, run:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
node .ai.local/scripts/rr-scheduler-start.mjs
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. Quote the stdout verbatim. A start prints `scheduler: started pid <pid>`. A restart prints `scheduler: restarted pid <pid> (stopped <previous>)`, plus the `processes:` lines from the manager.
|
|
19
|
+
3. On a non-zero exit, quote the `error:` line verbatim and stop. Do not start `team-db.mjs schedule` by hand and do not signal a pid the script did not name.
|
|
20
|
+
|
|
21
|
+
## What the script does
|
|
22
|
+
|
|
23
|
+
- Stops a scheduler this repository recorded, via `processes.mjs stop --name scheduler`.
|
|
24
|
+
- Signals a scheduler that was started outside the manager only when `scheduler.lock` names a live pid whose command line is `team-db.mjs schedule`. `SIGTERM`, then `SIGKILL` if it is still alive after 8 seconds. An in-flight child can outlive that kill.
|
|
25
|
+
- Removes `scheduler.lock` when its pid is already dead, so a crash does not block the next start for 90 seconds.
|
|
26
|
+
- Starts the timer through `processes.mjs start --name scheduler` with `exec node .ai.local/scripts/team-db.mjs schedule`, then waits until the new lease is fresh.
|
|
27
|
+
|
|
28
|
+
## Do not
|
|
29
|
+
|
|
30
|
+
- Write `status.json`, `metrics.json`, or any task or lifecycle file.
|
|
31
|
+
- Run `pkill`, `killall`, or `kill` against a pid the script did not print.
|
|
32
|
+
- Start a second `team-db.mjs schedule` after a non-zero exit.
|
|
@@ -75,12 +75,29 @@ function readSessionLease(id) {
|
|
|
75
75
|
return null;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
+
// The lease carries the window the projector attributes rows with — never one
|
|
79
|
+
// instant. `firstSeenAt` survives every later write of the same (session, slug)
|
|
80
|
+
// pair; a different slug starts a new window, and a lease older than the TTL
|
|
81
|
+
// starts over instead of claiming an ancient first sighting.
|
|
82
|
+
function firstSeenAtOf(file, value, now) {
|
|
83
|
+
try {
|
|
84
|
+
if (Date.now() - fs.statSync(file).mtimeMs > LEASE_TTL_MS) return now;
|
|
85
|
+
const previous = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
86
|
+
if (previous && previous.slug === value) {
|
|
87
|
+
if (typeof previous.firstSeenAt === 'string') return previous.firstSeenAt;
|
|
88
|
+
if (typeof previous.updatedAt === 'string') return previous.updatedAt;
|
|
89
|
+
}
|
|
90
|
+
} catch {}
|
|
91
|
+
return now;
|
|
92
|
+
}
|
|
78
93
|
function writeSessionLease(id, value) {
|
|
79
94
|
try {
|
|
80
95
|
fs.mkdirSync(LEASE_ROOT, { recursive: true });
|
|
81
96
|
const file = sessionLeasePath(id);
|
|
82
97
|
const temporary = `${file}.${process.pid}.tmp`;
|
|
83
|
-
|
|
98
|
+
const now = new Date().toISOString();
|
|
99
|
+
const firstSeenAt = firstSeenAtOf(file, value, now);
|
|
100
|
+
fs.writeFileSync(temporary, `${JSON.stringify({ slug: value, sessionId: id, firstSeenAt, updatedAt: now })}\n`);
|
|
84
101
|
fs.renameSync(temporary, file);
|
|
85
102
|
for (const name of fs.readdirSync(LEASE_ROOT)) {
|
|
86
103
|
if (!name.endsWith('.json')) continue;
|
|
@@ -238,7 +238,7 @@ On each `subagentStop`, the hook reconciles `status.state` from the completing p
|
|
|
238
238
|
| `scope` | e.g. `unit-in-dev`, `e2e-only` — passed to developer/qa |
|
|
239
239
|
| `model` | `cheap` \| `standard` \| `strong` — optional tier override |
|
|
240
240
|
|
|
241
|
-
`writeScopes` are reconciled after the step, never in the hook: `node .ai.local/scripts/check-write-scope.mjs --slug <slug> --step <step-id> --json` labels every changed path `declared`, `derived`, or `out-of-scope`. The orchestrator writes the step baseline (`--step <step-id> --save-baseline`) before the step writes, so the audit sees this step's paths and not the earlier ones. Exit `3` is a skip, not a failure: a pipeline that predates step ids or `writeScopes` is not auditable, and the reason goes under `## Soft notes`. `build-verifier` hard-fails an out-of-scope implementation write; `code-reviewer` reports a reviewer-step path as advisory.
|
|
241
|
+
`writeScopes` are reconciled after the step, never in the hook: `node .ai.local/scripts/check-write-scope.mjs --slug <slug> --step <step-id> --json` labels every changed path `declared`, `derived`, or `out-of-scope`. The orchestrator writes the step baseline (`--step <step-id> --save-baseline`) before the step writes, so the audit sees this step's paths and not the earlier ones. Automatic selection only considers steps with an `id`, because the baseline file is keyed by it. Exit `3` is a skip, not a failure: a pipeline that predates step ids or `writeScopes` is not auditable, and the reason goes under `## Soft notes`. Exit `2` is a usage error (unknown `--step`, unreadable `pipeline.json`, failed git ref): the audit did not run and the result is neither a pass nor a finding — fix the invocation and re-run. A `no-baseline` skip is an orchestration defect: the step wrote without its baseline, so no path can be attributed to it — save the baseline and re-run the audit instead of reading the skip as a pass. `build-verifier` hard-fails an out-of-scope implementation write; `code-reviewer` reports a reviewer-step path as advisory.
|
|
242
242
|
|
|
243
243
|
## Rules (strict)
|
|
244
244
|
|
|
@@ -31,7 +31,7 @@ Checklist for PRs that touch `packages/ai-rules/presets/**` (and dogfood `.curso
|
|
|
31
31
|
- [ ] **README:** stack `rules/README.md` core→stack mapping / catalog updated if stems added
|
|
32
32
|
- [ ] **CHANGELOG / package README:** note when public preset paths or install surface change
|
|
33
33
|
- [ ] **i18n anchors:** kept-marked Cyrillic fragments in `tests-unit.md(c)` stay consistent with their English counterparts. Run `packages/ai-rules/scripts/check-preset-i18n.sh`.
|
|
34
|
-
- [ ] **Dogfood:** run `packages/ai-rules/scripts/sync-dogfood-cursor.sh`, `sync-dogfood-claude.sh`, `sync-dogfood-mavis.sh`, and `sync-dogfood-
|
|
34
|
+
- [ ] **Dogfood:** run `packages/ai-rules/scripts/sync-dogfood-cursor.sh`, `sync-dogfood-claude.sh`, `sync-dogfood-mavis.sh`, `sync-dogfood-opencode.sh`, and `sync-dogfood-zcode.sh` when those platforms changed, or document an intentional skip, when maintaining this monorepo
|
|
35
35
|
- [ ] **shared-core drift:** for embed-mode stems, run `packages/ai-rules/scripts/check-shared-core-drift.sh` (or document intentional fork)
|
|
36
36
|
- [ ] **Packaging:** every installable preset ships `REPO_AGENTS.md`; default `hooks.json` does not reference `hooks/examples/`; `_shared/assets/docs-specs/` ships `INDEX.md` + `_templates/{page,feature}.md`; `product-specs` / `product-specs-authoring` stay requestable
|
|
37
37
|
- [ ] **UI-only surfaces:** `mockup-reviewer`, `accessibility-reviewer`, `ux-design`, and the stack performance skill ship only on UI stacks (`check-preset-leakage.sh`)
|
|
@@ -48,6 +48,6 @@ Checklist for PRs that touch `packages/ai-rules/presets/**` (and dogfood `.curso
|
|
|
48
48
|
- Budget: `preset-token-budget`
|
|
49
49
|
- Leakage: `preset-no-cross-stack-leakage`
|
|
50
50
|
- Validation: same `check:task` / `check:changed` loop; `yarn release:gate` before a release (`packages/ai-rules/scripts/release-gate.sh`)
|
|
51
|
-
- Dogfood scripts: `packages/ai-rules/scripts/sync-dogfood-cursor.sh`, `sync-dogfood-claude.sh`, `sync-dogfood-mavis.sh`, `sync-dogfood-opencode.sh`
|
|
51
|
+
- Dogfood scripts: `packages/ai-rules/scripts/sync-dogfood-cursor.sh`, `sync-dogfood-claude.sh`, `sync-dogfood-mavis.sh`, `sync-dogfood-opencode.sh`, `sync-dogfood-zcode.sh`
|
|
52
52
|
- Drift script: `packages/ai-rules/scripts/check-shared-core-drift.sh`
|
|
53
53
|
- Orchestrator: when editing presets, load this checklist + twin-sync
|
|
@@ -112,7 +112,7 @@ Use the hook path for the platform that installed the tree: `.cursor`, `.claude`
|
|
|
112
112
|
- **Manifest field name:** receipts go in `artifacts[]`. Anything written under `entries` is ignored — the hook reads only `artifacts` and prints a dual-read warning naming the file. See `agent-team/agent-artifact-contracts.md` § Schema field name.
|
|
113
113
|
- **Evidence paths:** `authoritativePaths[]` is relative to the task directory (`brief.md`). A repo-root path (`.ai.local/team/tasks/<slug>/brief.md`) is rejected. Put anything outside the task directory — e.g. `openspec/changes/**` — in `evidencePaths[]`.
|
|
114
114
|
- Manifest schema: shared core `agent-team/agent-artifact-contracts.md`. Read it first; producers upsert only their IDs.
|
|
115
|
-
- Metrics: append-only allowlisted events — `agent-team/agent-task-metrics.md`. Aggregate: `node node_modules/@bonesofspring/ai-rules/scripts/aggregate-agent-task-metrics.mjs --team-root .ai.local/team`.
|
|
115
|
+
- Metrics: append-only allowlisted events — `agent-team/agent-task-metrics.md`. Aggregate: `node node_modules/@bonesofspring/ai-rules/presets/_shared/ai-local/scripts/aggregate-agent-task-metrics.mjs --team-root .ai.local/team`.
|
|
116
116
|
- Commit `.ai.local/team/` templates (and slugs if you want them in clones).
|
|
117
117
|
|
|
118
118
|
## Plan graph & checkpoint (optional)
|
|
@@ -11,3 +11,7 @@ Slash-command and on-demand scenario definitions. Copied to `.claude/commands/`
|
|
|
11
11
|
| `migrate-tasks.md` | Create or reconcile `.ai.local/team/team.db`; writes only the delta |
|
|
12
12
|
|
|
13
13
|
See also the preset root `README.md`. Artifacts: `.ai.local/team/README.md`.
|
|
14
|
+
|
|
15
|
+
## Scheduler
|
|
16
|
+
|
|
17
|
+
- **`/rr-scheduler-start`** — start the team-db scheduler, or restart it when one already holds the lease. `init` seeds `.ai.local/scripts/rr-scheduler-start.mjs`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rr-scheduler-start
|
|
3
|
+
description: Start the team-db scheduler, or restart it when one is already running.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Start or restart the scheduler
|
|
7
|
+
|
|
8
|
+
Bring up `team-db.mjs schedule` for this repository. When a scheduler already holds the lease, stop that process and start a new one.
|
|
9
|
+
|
|
10
|
+
## What to do
|
|
11
|
+
|
|
12
|
+
1. From the repository root, run:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
node .ai.local/scripts/rr-scheduler-start.mjs
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
2. Quote the stdout verbatim. A start prints `scheduler: started pid <pid>`. A restart prints `scheduler: restarted pid <pid> (stopped <previous>)`, plus the `processes:` lines from the manager.
|
|
19
|
+
3. On a non-zero exit, quote the `error:` line verbatim and stop. Do not start `team-db.mjs schedule` by hand and do not signal a pid the script did not name.
|
|
20
|
+
|
|
21
|
+
## What the script does
|
|
22
|
+
|
|
23
|
+
- Stops a scheduler this repository recorded, via `processes.mjs stop --name scheduler`.
|
|
24
|
+
- Signals a scheduler that was started outside the manager only when `scheduler.lock` names a live pid whose command line is `team-db.mjs schedule`. `SIGTERM`, then `SIGKILL` if it is still alive after 8 seconds. An in-flight child can outlive that kill.
|
|
25
|
+
- Removes `scheduler.lock` when its pid is already dead, so a crash does not block the next start for 90 seconds.
|
|
26
|
+
- Starts the timer through `processes.mjs start --name scheduler` with `exec node .ai.local/scripts/team-db.mjs schedule`, then waits until the new lease is fresh.
|
|
27
|
+
|
|
28
|
+
## Do not
|
|
29
|
+
|
|
30
|
+
- Write `status.json`, `metrics.json`, or any task or lifecycle file.
|
|
31
|
+
- Run `pkill`, `killall`, or `kill` against a pid the script did not print.
|
|
32
|
+
- Start a second `team-db.mjs schedule` after a non-zero exit.
|