@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
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
isKillSwitchSet,
|
|
29
29
|
listAppliedMigrations,
|
|
30
30
|
openTeamDb,
|
|
31
|
+
readNewerSchemaModule,
|
|
31
32
|
readSchemaMeta,
|
|
32
33
|
readSearchMode,
|
|
33
34
|
readUserVersion,
|
|
@@ -51,6 +52,13 @@ import {
|
|
|
51
52
|
TASK_STATES,
|
|
52
53
|
serializeOpenApiDocument,
|
|
53
54
|
} from './team-db-openapi.mjs';
|
|
55
|
+
import {
|
|
56
|
+
ACTION_INTENTS,
|
|
57
|
+
SIGNAL_SEVERITIES,
|
|
58
|
+
compareSignals,
|
|
59
|
+
evaluateSignals,
|
|
60
|
+
summaryOf,
|
|
61
|
+
} from './action-signals.mjs';
|
|
54
62
|
import {
|
|
55
63
|
DEFAULT_LOG_LIMIT,
|
|
56
64
|
JOB_ID_RE,
|
|
@@ -69,6 +77,7 @@ import {
|
|
|
69
77
|
import {
|
|
70
78
|
EFFECTIVE_ENTRY_STATUSES,
|
|
71
79
|
EFFECTIVE_ITEM_STATUSES,
|
|
80
|
+
HOLDING_TASK_STATES,
|
|
72
81
|
countActiveTasks,
|
|
73
82
|
deriveTrackerOrdering,
|
|
74
83
|
effectiveEntryStatus,
|
|
@@ -205,6 +214,34 @@ const EVENT_ORDER = `
|
|
|
205
214
|
CASE ?5 WHEN 'asc' THEN e.at END ASC NULLS LAST,
|
|
206
215
|
e.seq ASC`;
|
|
207
216
|
|
|
217
|
+
// The window and task cut, shared by both action routes; `/actions` adds the
|
|
218
|
+
// intent/agent clauses it declares, `/signals` does not declare them.
|
|
219
|
+
const ACTION_WINDOW_FILTER = `
|
|
220
|
+
day >= ?1 AND day <= ?2
|
|
221
|
+
AND (?3 = '' OR task_slug = ?3)
|
|
222
|
+
AND (?4 = 1 OR task_slug IS NOT NULL)`;
|
|
223
|
+
|
|
224
|
+
const ACTION_FILTER = `${ACTION_WINDOW_FILTER}
|
|
225
|
+
AND (json_array_length(?5) = 0 OR intent IN (SELECT value FROM json_each(?5)))
|
|
226
|
+
AND (?6 = '' OR agent = ?6)`;
|
|
227
|
+
|
|
228
|
+
const ACTION_TOTALS_SELECT = `SELECT count(*) AS actions,
|
|
229
|
+
COALESCE(SUM(CASE WHEN error_class IS NOT NULL THEN 1 ELSE 0 END), 0) AS errors,
|
|
230
|
+
COALESCE(SUM(CASE WHEN repeat_index IS NOT NULL THEN 1 ELSE 0 END), 0) AS repeats,
|
|
231
|
+
COALESCE(SUM(replaced), 0) AS guard_hits,
|
|
232
|
+
COALESCE(SUM(CASE WHEN duration_ms IS NOT NULL THEN duration_ms ELSE 0 END), 0) AS busy_ms,
|
|
233
|
+
COUNT(DISTINCT CASE WHEN intent = 'mutate' THEN target_key END) AS changed_files,
|
|
234
|
+
MIN(observed_at) AS first_at,
|
|
235
|
+
MAX(observed_at) AS last_at,
|
|
236
|
+
COALESCE(SUM(CASE WHEN attribution = 'lease' THEN 1 ELSE 0 END), 0) AS rung_lease,
|
|
237
|
+
COALESCE(SUM(CASE WHEN attribution = 'window' THEN 1 ELSE 0 END), 0) AS rung_window,
|
|
238
|
+
COALESCE(SUM(CASE WHEN attribution = 'dir-mtime' THEN 1 ELSE 0 END), 0) AS rung_dir_mtime,
|
|
239
|
+
COALESCE(SUM(CASE WHEN attribution = 'unmapped' THEN 1 ELSE 0 END), 0) AS rung_unmapped`;
|
|
240
|
+
|
|
241
|
+
const ACTION_SESSIONS_SELECT = `SELECT count(DISTINCT session_id) AS sessions,
|
|
242
|
+
count(DISTINCT CASE WHEN task_slug IS NOT NULL THEN session_id END) AS mapped_sessions
|
|
243
|
+
FROM tool_calls`;
|
|
244
|
+
|
|
208
245
|
const SQL = {
|
|
209
246
|
listTasks: `SELECT
|
|
210
247
|
t.slug, t.title, t.intent, t.profile, t.spec_mode, t.state, t.phase,
|
|
@@ -455,6 +492,33 @@ const SQL = {
|
|
|
455
492
|
FROM attempts WHERE task_slug = ?1 GROUP BY step_index ORDER BY step_index ASC`,
|
|
456
493
|
efficiencyGates: `SELECT start_event_id, duration_ms, outcome FROM gates
|
|
457
494
|
WHERE task_slug = ?1 ORDER BY started_at ASC, start_event_id ASC`,
|
|
495
|
+
// The action routes aggregate the base rows directly: the per-task views have
|
|
496
|
+
// no window parameter, and a route that answers a `from`/`to` question cannot
|
|
497
|
+
// read an all-time rollup. The views stay the per-task report's source.
|
|
498
|
+
actionTotals: `${ACTION_TOTALS_SELECT} FROM tool_calls WHERE ${ACTION_FILTER}`,
|
|
499
|
+
// The same aggregates over the window+task cut alone, for `/signals`, which
|
|
500
|
+
// declares no intent and no agent.
|
|
501
|
+
actionTotalsWindow: `${ACTION_TOTALS_SELECT} FROM tool_calls WHERE ${ACTION_WINDOW_FILTER}`,
|
|
502
|
+
actionTurns: `SELECT count(*) AS turns,
|
|
503
|
+
COALESCE(SUM(input_tokens + output_tokens + reasoning_tokens), 0) AS tokens
|
|
504
|
+
FROM usage_turns WHERE day >= ?1 AND day <= ?2 AND (?3 = '' OR task_slug = ?3) AND (?4 = 1 OR task_slug IS NOT NULL)`,
|
|
505
|
+
actionSessions: `${ACTION_SESSIONS_SELECT} WHERE ${ACTION_FILTER}`,
|
|
506
|
+
actionSessionsWindow: `${ACTION_SESSIONS_SELECT} WHERE ${ACTION_WINDOW_FILTER}`,
|
|
507
|
+
actionUnmappedTurns: `SELECT count(*) AS n FROM usage_turns
|
|
508
|
+
WHERE day >= ?1 AND day <= ?2 AND (?3 = '' OR task_slug = ?3) AND (?4 = 1 OR task_slug IS NOT NULL)
|
|
509
|
+
AND attribution = 'unmapped'`,
|
|
510
|
+
actionByIntent: `SELECT intent, count(*) AS actions FROM tool_calls WHERE ${ACTION_FILTER}
|
|
511
|
+
GROUP BY intent ORDER BY actions DESC, intent ASC`,
|
|
512
|
+
actionByAgent: `SELECT COALESCE(agent, '') AS agent, count(*) AS actions FROM tool_calls WHERE ${ACTION_FILTER}
|
|
513
|
+
GROUP BY agent ORDER BY actions DESC, agent ASC`,
|
|
514
|
+
countActions: `SELECT count(*) AS total FROM tool_calls WHERE ${ACTION_FILTER}`,
|
|
515
|
+
listActions: `SELECT observed_at, task_slug, call_id, tool, intent, agent, error_class, duration_ms, gap_ms,
|
|
516
|
+
exit_code, repeat_index, attribution
|
|
517
|
+
FROM tool_calls WHERE ${ACTION_FILTER}
|
|
518
|
+
ORDER BY observed_at DESC, call_id DESC LIMIT ?7 OFFSET ?8`,
|
|
519
|
+
listActionSummaries: `SELECT * FROM task_action_summary
|
|
520
|
+
WHERE (?1 = '' OR task_slug = ?1) AND (?2 = '' OR last_at >= ?2) AND (?3 = '' OR last_at <= ?3)
|
|
521
|
+
ORDER BY actions DESC, task_slug ASC`,
|
|
458
522
|
latestContextSnapshot: 'SELECT max(snapshot_at) AS snapshot_at FROM context_cost_hosts',
|
|
459
523
|
listContextHosts: `SELECT host, rule, always_on_files, always_on_bytes, estimated_tokens
|
|
460
524
|
FROM context_cost_hosts WHERE snapshot_at = ?1 ORDER BY host ASC`,
|
|
@@ -505,7 +569,8 @@ const SQL = {
|
|
|
505
569
|
WHERE item_id = ?1 AND absent_at IS NULL AND parse_error IS NULL ORDER BY created_at, link_id`,
|
|
506
570
|
listTrackerLinksForTask: `SELECT * FROM tracker_item_tasks
|
|
507
571
|
WHERE task_slug = ?1 AND absent_at IS NULL AND parse_error IS NULL ORDER BY created_at, link_id`,
|
|
508
|
-
listTrackerTaskRows:
|
|
572
|
+
listTrackerTaskRows:
|
|
573
|
+
'SELECT slug, title, state, start_at, end_at, updated_at FROM tasks WHERE absent_at IS NULL',
|
|
509
574
|
getTrackerTaskRow: 'SELECT state, start_at, end_at FROM tasks WHERE slug = ?1 AND absent_at IS NULL',
|
|
510
575
|
};
|
|
511
576
|
|
|
@@ -1492,8 +1557,205 @@ const getEfficiencyContextCost = (db) => {
|
|
|
1492
1557
|
};
|
|
1493
1558
|
};
|
|
1494
1559
|
|
|
1495
|
-
|
|
1496
|
-
|
|
1560
|
+
/* ---------------------------- action telemetry ---------------------------- */
|
|
1561
|
+
|
|
1562
|
+
const ACTION_INTENT_SET = new Set(ACTION_INTENTS);
|
|
1563
|
+
const ACTION_SEVERITY_SET = new Set(SIGNAL_SEVERITIES);
|
|
1564
|
+
const ACTION_DEFAULT_LIMIT = 50;
|
|
1565
|
+
const ACTION_MAX_LIMIT = 200;
|
|
1566
|
+
const EMPTY_RUNG_SPLIT = { lease: 0, window: 0, 'dir-mtime': 0, unmapped: 0 };
|
|
1567
|
+
|
|
1568
|
+
/**
|
|
1569
|
+
* The filter of `/actions`.
|
|
1570
|
+
*
|
|
1571
|
+
* `task` narrows a window-wide read; `from`/`to` keep the shipped 30-day
|
|
1572
|
+
* default; `intent` is a repeated closed enum and `agent` an exact identifier.
|
|
1573
|
+
*/
|
|
1574
|
+
const actionFilter = (query) => {
|
|
1575
|
+
const { from, to, fromDay, toDay } = efficiencyWindow(query);
|
|
1576
|
+
const { task, includeAbsent } = efficiencyFilter(query);
|
|
1577
|
+
const intents = parseCsv(query.get('intent'), 'intent', ACTION_INTENT_SET);
|
|
1578
|
+
const agent = parsePattern(query.get('agent'), 'agent', agentPattern, 64);
|
|
1579
|
+
const limit = parseInteger(query.get('limit'), 'limit', {
|
|
1580
|
+
min: 1,
|
|
1581
|
+
max: ACTION_MAX_LIMIT,
|
|
1582
|
+
fallback: ACTION_DEFAULT_LIMIT,
|
|
1583
|
+
});
|
|
1584
|
+
const offset = parseInteger(query.get('offset'), 'offset', { min: 0, max: MAX_OFFSET, fallback: 0 });
|
|
1585
|
+
return {
|
|
1586
|
+
from,
|
|
1587
|
+
to,
|
|
1588
|
+
task,
|
|
1589
|
+
limit,
|
|
1590
|
+
offset,
|
|
1591
|
+
params: [fromDay, toDay, task, includeAbsent, JSON.stringify(intents), agent],
|
|
1592
|
+
};
|
|
1593
|
+
};
|
|
1594
|
+
|
|
1595
|
+
/**
|
|
1596
|
+
* The filter of `/signals`.
|
|
1597
|
+
*
|
|
1598
|
+
* Narrower than `actionFilter` on purpose: the route declares `task`, `from`,
|
|
1599
|
+
* `to`, `severity`, `limit` and `offset`, so the three parameters that would
|
|
1600
|
+
* otherwise bind half of the `attribution` block are refused by name instead of
|
|
1601
|
+
* silently narrowing one half. `includeAbsent` stays at its default, which keeps
|
|
1602
|
+
* every row the block counts a task row.
|
|
1603
|
+
*/
|
|
1604
|
+
const signalsFilter = (query) => {
|
|
1605
|
+
for (const name of ['intent', 'agent', 'includeAbsent']) {
|
|
1606
|
+
if (query.get(name) !== null) {
|
|
1607
|
+
fail('E_VALIDATION', 422, `${name} is not a parameter of this route`, { parameter: name });
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
const { from, to, fromDay, toDay } = efficiencyWindow(query);
|
|
1611
|
+
const { task } = efficiencyFilter(query);
|
|
1612
|
+
const severities = parseCsv(query.get('severity'), 'severity', ACTION_SEVERITY_SET);
|
|
1613
|
+
const limit = parseInteger(query.get('limit'), 'limit', {
|
|
1614
|
+
min: 1,
|
|
1615
|
+
max: ACTION_MAX_LIMIT,
|
|
1616
|
+
fallback: ACTION_DEFAULT_LIMIT,
|
|
1617
|
+
});
|
|
1618
|
+
const offset = parseInteger(query.get('offset'), 'offset', { min: 0, max: MAX_OFFSET, fallback: 0 });
|
|
1619
|
+
return { from, to, task, severities, limit, offset, params: [fromDay, toDay, task, 0] };
|
|
1620
|
+
};
|
|
1621
|
+
|
|
1622
|
+
const rungOf = (totalsRow) => ({
|
|
1623
|
+
lease: Number(totalsRow.rung_lease),
|
|
1624
|
+
window: Number(totalsRow.rung_window),
|
|
1625
|
+
'dir-mtime': Number(totalsRow.rung_dir_mtime),
|
|
1626
|
+
unmapped: Number(totalsRow.rung_unmapped),
|
|
1627
|
+
});
|
|
1628
|
+
|
|
1629
|
+
/**
|
|
1630
|
+
* The `attribution` block, assembled from one filter tuple's three reads.
|
|
1631
|
+
*
|
|
1632
|
+
* Passing the rows rather than the filter keeps every `prepare()` argument a
|
|
1633
|
+
* frozen constant, and it makes the "one block, one filter set" property visible:
|
|
1634
|
+
* a caller cannot hand in a sessions row read through a different cut.
|
|
1635
|
+
* `unmappedTurns` is window+task only — a turn carries neither an intent nor an
|
|
1636
|
+
* agent — and `coverage` is null at a zero denominator, never a confident `0`.
|
|
1637
|
+
*/
|
|
1638
|
+
const actionAttribution = (totalsRow, sessions, unmappedTurns) => {
|
|
1639
|
+
const byRung = rungOf(totalsRow);
|
|
1640
|
+
const total = Object.values(byRung).reduce((sum, value) => sum + value, 0);
|
|
1641
|
+
return {
|
|
1642
|
+
sessions: Number(sessions.sessions),
|
|
1643
|
+
mappedSessions: Number(sessions.mapped_sessions),
|
|
1644
|
+
unmappedCalls: byRung.unmapped,
|
|
1645
|
+
unmappedTurns: Number(unmappedTurns.n),
|
|
1646
|
+
byRung,
|
|
1647
|
+
coverage: total === 0 ? null : (total - byRung.unmapped) / total,
|
|
1648
|
+
};
|
|
1649
|
+
};
|
|
1650
|
+
|
|
1651
|
+
const actionRow = (row) => ({
|
|
1652
|
+
at: row.observed_at,
|
|
1653
|
+
task: row.task_slug,
|
|
1654
|
+
tool: row.tool,
|
|
1655
|
+
intent: row.intent ?? 'meta',
|
|
1656
|
+
agent: row.agent ?? null,
|
|
1657
|
+
errorClass: row.error_class ?? null,
|
|
1658
|
+
durationMs: row.duration_ms === null ? null : Number(row.duration_ms),
|
|
1659
|
+
gapMs: row.gap_ms === null ? null : Number(row.gap_ms),
|
|
1660
|
+
exitCode: row.exit_code === null ? null : Number(row.exit_code),
|
|
1661
|
+
repeatIndex: row.repeat_index === null ? null : Number(row.repeat_index),
|
|
1662
|
+
});
|
|
1663
|
+
|
|
1664
|
+
/** The rung split of one page of items (B-6: the chip reads `attribution.byRung`). */
|
|
1665
|
+
const rungSplitOf = (rows) => {
|
|
1666
|
+
const counts = { ...EMPTY_RUNG_SPLIT };
|
|
1667
|
+
for (const row of rows) {
|
|
1668
|
+
if (row.attribution in counts) counts[row.attribution] += 1;
|
|
1669
|
+
}
|
|
1670
|
+
return Object.entries(counts).map(([rung, actions]) => ({ rung, actions }));
|
|
1671
|
+
};
|
|
1672
|
+
|
|
1673
|
+
const getEfficiencyActions = (db, query) => {
|
|
1674
|
+
const filter = actionFilter(query);
|
|
1675
|
+
if (filter.task !== '') requireTask(db, filter.task);
|
|
1676
|
+
const totalsRow = db.prepare(SQL.actionTotals).get(...filter.params);
|
|
1677
|
+
const sessions = db.prepare(SQL.actionSessions).get(...filter.params);
|
|
1678
|
+
// The turns tables carry no intent and no agent, so the block's fifth key
|
|
1679
|
+
// reads the first four parameters of the same tuple.
|
|
1680
|
+
const unmappedTurns = db.prepare(SQL.actionUnmappedTurns).get(
|
|
1681
|
+
filter.params[0],
|
|
1682
|
+
filter.params[1],
|
|
1683
|
+
filter.params[2],
|
|
1684
|
+
filter.params[3],
|
|
1685
|
+
);
|
|
1686
|
+
const turns = db.prepare(SQL.actionTurns).get(
|
|
1687
|
+
filter.params[0],
|
|
1688
|
+
filter.params[1],
|
|
1689
|
+
filter.params[2],
|
|
1690
|
+
filter.params[3],
|
|
1691
|
+
);
|
|
1692
|
+
const actions = Number(totalsRow.actions);
|
|
1693
|
+
const errorActions = Number(totalsRow.errors);
|
|
1694
|
+
const repeatActions = Number(totalsRow.repeats);
|
|
1695
|
+
const firstAt = totalsRow.first_at ?? null;
|
|
1696
|
+
const lastAt = totalsRow.last_at ?? null;
|
|
1697
|
+
const first = firstAt === null ? Number.NaN : Date.parse(firstAt);
|
|
1698
|
+
const last = lastAt === null ? Number.NaN : Date.parse(lastAt);
|
|
1699
|
+
const byIntentRows = db.prepare(SQL.actionByIntent).all(...filter.params);
|
|
1700
|
+
const byAgentRows = db.prepare(SQL.actionByAgent).all(...filter.params);
|
|
1701
|
+
const total = Number(db.prepare(SQL.countActions).get(...filter.params).total);
|
|
1702
|
+
const rows = db.prepare(SQL.listActions).all(...filter.params, filter.limit, filter.offset);
|
|
1703
|
+
return {
|
|
1704
|
+
window: { from: filter.from, to: filter.to },
|
|
1705
|
+
task: filter.task === '' ? null : filter.task,
|
|
1706
|
+
// B-1: `actions` and `turns` are the two sample sizes a reader needs; a
|
|
1707
|
+
// ratio whose sample is below its floor is muted by the consumer.
|
|
1708
|
+
totals: {
|
|
1709
|
+
actions,
|
|
1710
|
+
turns: Number(turns.turns),
|
|
1711
|
+
changedFiles: Number(totalsRow.changed_files),
|
|
1712
|
+
errorRate: actions === 0 ? null : errorActions / actions,
|
|
1713
|
+
repeatRatio: actions === 0 ? null : repeatActions / actions,
|
|
1714
|
+
guardHits: Number(totalsRow.guard_hits),
|
|
1715
|
+
wallMs: Number.isFinite(first) && Number.isFinite(last) ? Math.max(0, last - first) : null,
|
|
1716
|
+
// Only the actions whose duration was observed contribute to `busyMs`.
|
|
1717
|
+
busyMs: Number(totalsRow.busy_ms),
|
|
1718
|
+
},
|
|
1719
|
+
byIntent: byIntentRows.map((row) => ({ intent: row.intent ?? 'meta', actions: Number(row.actions) })),
|
|
1720
|
+
byAgent: byAgentRows.map((row) => ({ agent: row.agent === '' ? null : row.agent, actions: Number(row.actions) })),
|
|
1721
|
+
// B-6: defined as the page's rung split; the chip reads `attribution.byRung`.
|
|
1722
|
+
coverage: rungSplitOf(rows),
|
|
1723
|
+
...page(rows.map(actionRow), total, filter.limit, filter.offset),
|
|
1724
|
+
attribution: actionAttribution(totalsRow, sessions, unmappedTurns),
|
|
1725
|
+
generatedAt: new Date().toISOString(),
|
|
1726
|
+
};
|
|
1727
|
+
};
|
|
1728
|
+
|
|
1729
|
+
const getEfficiencySignals = (db, query) => {
|
|
1730
|
+
const filter = signalsFilter(query);
|
|
1731
|
+
if (filter.task !== '') requireTask(db, filter.task);
|
|
1732
|
+
// The rollup is per task, so the window selects tasks by their last action:
|
|
1733
|
+
// a task whose last action is older than `from` is not answered for.
|
|
1734
|
+
const rows = db.prepare(SQL.listActionSummaries).all(filter.task, filter.from, filter.to);
|
|
1735
|
+
const fired = [];
|
|
1736
|
+
for (const row of rows) {
|
|
1737
|
+
for (const signal of evaluateSignals(summaryOf(row))) {
|
|
1738
|
+
if (filter.severities.length > 0 && !filter.severities.includes(signal.severity)) continue;
|
|
1739
|
+
fired.push({ task: row.task_slug, ...signal });
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
// The array order is the contract: worst severity, then the signal name, then
|
|
1743
|
+
// the task, so a window-wide read is ordered like a single task's.
|
|
1744
|
+
fired.sort((left, right) => compareSignals(left, right) || left.task.localeCompare(right.task));
|
|
1745
|
+
const total = fired.length;
|
|
1746
|
+
const totalsRow = db.prepare(SQL.actionTotalsWindow).get(...filter.params);
|
|
1747
|
+
const sessions = db.prepare(SQL.actionSessionsWindow).get(...filter.params);
|
|
1748
|
+
const unmappedTurns = db.prepare(SQL.actionUnmappedTurns).get(...filter.params);
|
|
1749
|
+
return {
|
|
1750
|
+
window: { from: filter.from, to: filter.to },
|
|
1751
|
+
task: filter.task === '' ? null : filter.task,
|
|
1752
|
+
...page(fired.slice(filter.offset, filter.offset + filter.limit), total, filter.limit, filter.offset),
|
|
1753
|
+
attribution: actionAttribution(totalsRow, sessions, unmappedTurns),
|
|
1754
|
+
generatedAt: new Date().toISOString(),
|
|
1755
|
+
};
|
|
1756
|
+
};
|
|
1757
|
+
|
|
1758
|
+
const listSyncRuns = (db, query) => { const limit = parseInteger(query.get('limit'), 'limit', { min: 1, max: MAX_LIMIT, fallback: DEFAULT_LIMIT });
|
|
1497
1759
|
const offset = parseInteger(query.get('offset'), 'offset', { min: 0, max: MAX_OFFSET, fallback: 0 });
|
|
1498
1760
|
const total = Number(db.prepare(SQL.countSyncRuns).get().total);
|
|
1499
1761
|
const rows = db.prepare(SQL.listSyncRuns).all(limit, offset);
|
|
@@ -2077,7 +2339,13 @@ const readTrackerSnapshotRows = (db) => {
|
|
|
2077
2339
|
const links = new Map();
|
|
2078
2340
|
const taskRows = new Map();
|
|
2079
2341
|
for (const row of db.prepare(SQL.listTrackerTaskRows).all()) {
|
|
2080
|
-
taskRows.set(row.slug, {
|
|
2342
|
+
taskRows.set(row.slug, {
|
|
2343
|
+
state: row.state ?? null,
|
|
2344
|
+
title: row.title ?? null,
|
|
2345
|
+
startAt: row.start_at ?? null,
|
|
2346
|
+
endAt: row.end_at ?? null,
|
|
2347
|
+
updatedAt: row.updated_at ?? null,
|
|
2348
|
+
});
|
|
2081
2349
|
}
|
|
2082
2350
|
const depsByItem = new Map();
|
|
2083
2351
|
for (const dep of db.prepare(SQL.listTrackerDeps).all()) {
|
|
@@ -2295,9 +2563,12 @@ const trackerItemDetail = (db, id, teamRoot = null) => {
|
|
|
2295
2563
|
};
|
|
2296
2564
|
})
|
|
2297
2565
|
.sort((left, right) => left.createdAt.localeCompare(right.createdAt) || left.linkId.localeCompare(right.linkId));
|
|
2298
|
-
const queue = [
|
|
2299
|
-
.filter((entry) => entry.itemId === id)
|
|
2300
|
-
|
|
2566
|
+
const queue = [
|
|
2567
|
+
...liveHoldingTaskRows(snapshot).filter((entry) => entry.itemId === id),
|
|
2568
|
+
...[...snapshot.entries.values()]
|
|
2569
|
+
.filter((entry) => entry.itemId === id)
|
|
2570
|
+
.map((entry) => trackerQueueEntryJson(entry, snapshot.taskRows, annotated.item.title)),
|
|
2571
|
+
];
|
|
2301
2572
|
return {
|
|
2302
2573
|
item: trackerItemJson(annotated),
|
|
2303
2574
|
dependencies,
|
|
@@ -2308,19 +2579,81 @@ const trackerItemDetail = (db, id, teamRoot = null) => {
|
|
|
2308
2579
|
};
|
|
2309
2580
|
};
|
|
2310
2581
|
|
|
2582
|
+
/**
|
|
2583
|
+
* A holding task occupies a launch slot even when no tracker item is linked
|
|
2584
|
+
* and no queue file exists. The row is derived: `entryId` stays null so cancel
|
|
2585
|
+
* cannot target it, and a non-terminal queue entry for the same slug wins.
|
|
2586
|
+
*/
|
|
2587
|
+
const liveHoldingTaskRows = (snapshot) => {
|
|
2588
|
+
const covered = new Set();
|
|
2589
|
+
for (const entry of snapshot.entries.values()) {
|
|
2590
|
+
const taskSlug = entry.taskSlug ?? `tracker-${entry.itemId}`;
|
|
2591
|
+
const taskState = snapshot.taskRows.get(taskSlug)?.state ?? null;
|
|
2592
|
+
if (!['cancelled', 'expired', 'done'].includes(effectiveEntryStatus(entry, taskState))) {
|
|
2593
|
+
covered.add(taskSlug);
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
const linksBySlug = new Map();
|
|
2597
|
+
for (const link of snapshot.links.values()) {
|
|
2598
|
+
if (link.decision === 'unlinked') continue;
|
|
2599
|
+
const list = linksBySlug.get(link.taskSlug) ?? [];
|
|
2600
|
+
list.push(link);
|
|
2601
|
+
linksBySlug.set(link.taskSlug, list);
|
|
2602
|
+
}
|
|
2603
|
+
const rows = [];
|
|
2604
|
+
for (const [taskSlug, taskRow] of snapshot.taskRows) {
|
|
2605
|
+
if (!HOLDING_TASK_STATES.has(taskRow.state)) continue;
|
|
2606
|
+
if (covered.has(taskSlug)) continue;
|
|
2607
|
+
const links = linksBySlug.get(taskSlug) ?? [];
|
|
2608
|
+
links.sort((left, right) => {
|
|
2609
|
+
if (left.role === 'primary' && right.role !== 'primary') return -1;
|
|
2610
|
+
if (right.role === 'primary' && left.role !== 'primary') return 1;
|
|
2611
|
+
return String(left.linkId).localeCompare(String(right.linkId));
|
|
2612
|
+
});
|
|
2613
|
+
const link = links[0] ?? null;
|
|
2614
|
+
let item = link === null ? null : (snapshot.items.get(link.itemId) ?? null);
|
|
2615
|
+
if (item === null && link === null && /^[1-9][0-9]*$/.test(taskSlug)) {
|
|
2616
|
+
item = snapshot.items.get(Number(taskSlug)) ?? null;
|
|
2617
|
+
}
|
|
2618
|
+
rows.push({
|
|
2619
|
+
entryId: null,
|
|
2620
|
+
itemId: link?.itemId ?? item?.id ?? null,
|
|
2621
|
+
taskSlug,
|
|
2622
|
+
linkId: link?.linkId ?? null,
|
|
2623
|
+
status: 'active',
|
|
2624
|
+
reason: 'current task',
|
|
2625
|
+
requestedBy: 'task',
|
|
2626
|
+
command: null,
|
|
2627
|
+
revision: 1,
|
|
2628
|
+
requestedAt: taskRow.startAt ?? taskRow.updatedAt ?? '1970-01-01T00:00:00.000Z',
|
|
2629
|
+
claimedAt: null,
|
|
2630
|
+
finishedAt: null,
|
|
2631
|
+
history: [],
|
|
2632
|
+
itemTitle: item?.title ?? taskRow.title ?? taskSlug,
|
|
2633
|
+
taskState: taskRow.state,
|
|
2634
|
+
taskStartAt: taskRow.startAt ?? null,
|
|
2635
|
+
taskEndAt: taskRow.endAt ?? null,
|
|
2636
|
+
});
|
|
2637
|
+
}
|
|
2638
|
+
rows.sort((left, right) => left.taskSlug.localeCompare(right.taskSlug));
|
|
2639
|
+
return rows;
|
|
2640
|
+
};
|
|
2641
|
+
|
|
2311
2642
|
const listTrackerQueue = (db, query) => {
|
|
2312
2643
|
const limit = parseInteger(query.get('limit'), 'limit', { min: 1, max: TRACKER_MAX_LIMIT, fallback: TRACKER_DEFAULT_LIMIT });
|
|
2313
2644
|
const offset = parseInteger(query.get('offset'), 'offset', { min: 0, max: MAX_OFFSET, fallback: 0 });
|
|
2314
2645
|
const statuses = parseCsv(query.get('status'), 'status', TRACKER_EFFECTIVE_ENTRY_SET);
|
|
2315
2646
|
const itemId = query.get('itemId') === null ? null : parseItemId(query.get('itemId'), 'itemId');
|
|
2316
2647
|
const snapshot = readTrackerSnapshotRows(db);
|
|
2317
|
-
|
|
2648
|
+
const stored = [...snapshot.entries.values()]
|
|
2318
2649
|
.filter((entry) => itemId === null || entry.itemId === itemId)
|
|
2319
2650
|
.map((entry) => trackerQueueEntryJson(entry, snapshot.taskRows, snapshot.items.get(entry.itemId)?.title ?? String(entry.itemId)));
|
|
2651
|
+
const live = liveHoldingTaskRows(snapshot).filter((entry) => itemId === null || entry.itemId === itemId);
|
|
2652
|
+
let items = [...live, ...stored];
|
|
2320
2653
|
if (statuses.length > 0) items = items.filter((entry) => statuses.includes(entry.status));
|
|
2321
2654
|
const total = items.length;
|
|
2322
2655
|
const pageItems = items.slice(offset, offset + limit);
|
|
2323
|
-
const activeEntryId = items.find((entry) => entry.status === 'active')?.entryId ?? null;
|
|
2656
|
+
const activeEntryId = items.find((entry) => entry.status === 'active' && entry.entryId !== null)?.entryId ?? null;
|
|
2324
2657
|
return {
|
|
2325
2658
|
items: pageItems,
|
|
2326
2659
|
total,
|
|
@@ -2754,6 +3087,12 @@ export const ROUTES = [
|
|
|
2754
3087
|
route('GET', '/api/v1/efficiency/context-cost', 'getEfficiencyContextCost', (context) => ({
|
|
2755
3088
|
json: getEfficiencyContextCost(context.db()),
|
|
2756
3089
|
})),
|
|
3090
|
+
route('GET', '/api/v1/efficiency/actions', 'getEfficiencyActions', (context) => ({
|
|
3091
|
+
json: getEfficiencyActions(context.db(), context.query),
|
|
3092
|
+
})),
|
|
3093
|
+
route('GET', '/api/v1/efficiency/signals', 'getEfficiencySignals', (context) => ({
|
|
3094
|
+
json: getEfficiencySignals(context.db(), context.query),
|
|
3095
|
+
})),
|
|
2757
3096
|
route('GET', '/api/v1/sync-runs', 'listSyncRuns', (context) => ({ json: listSyncRuns(context.db(), context.query) })),
|
|
2758
3097
|
route('POST', '/api/v1/sync', 'triggerSync', async (context) => {
|
|
2759
3098
|
const text = context.body.toString('utf8').trim();
|
|
@@ -3005,11 +3344,15 @@ const handle = async (req, res, settings) => {
|
|
|
3005
3344
|
if (params.slug !== undefined) params.slug = parseSlug(params.slug);
|
|
3006
3345
|
|
|
3007
3346
|
// The handler opens the connection lazily and the caller closes it, so a
|
|
3008
|
-
// static route never touches the database.
|
|
3347
|
+
// static route never touches the database. A schema file newer than the
|
|
3348
|
+
// module this process loaded is opened with that file, not the cached one.
|
|
3349
|
+
const freshSchema = await readNewerSchemaModule();
|
|
3009
3350
|
let opened = null;
|
|
3010
3351
|
const handleOnce = () => {
|
|
3011
3352
|
if (!opened) {
|
|
3012
|
-
opened =
|
|
3353
|
+
opened = freshSchema
|
|
3354
|
+
? freshSchema.openTeamDb({ teamRoot: settings.teamRoot, dbPath: settings.dbPath, readOnly: true })
|
|
3355
|
+
: (settings.services.openDb?.(settings) ?? openTeamDb({ teamRoot: settings.teamRoot, dbPath: settings.dbPath, readOnly: true }));
|
|
3013
3356
|
}
|
|
3014
3357
|
return opened;
|
|
3015
3358
|
};
|