@bonesofspring/ai-rules 0.2.72 → 0.2.74
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 +43 -0
- package/README.md +7 -6
- package/bin/lib/ai-local-drift.js +4 -4
- package/bin/lib/engine-scripts.js +10 -0
- package/bin/lib/seed-ai-local-team.js +9 -5
- package/docs/TEAM-DB.md +105 -9
- package/docs/openapi/team-db.v1.json +1164 -224
- package/package.json +1 -1
- 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/manifest.mjs +19 -1
- 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/team-db-api.mjs +347 -9
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +309 -4
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +312 -36
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +86 -1
- package/presets/_shared/ai-local/scripts/team-db.mjs +125 -40
- package/presets/_shared/ai-local/scripts/tracker-planned-drain.mjs +335 -0
- package/presets/_shared/core/agent-team/agent-artifact-contracts.md +9 -0
- package/presets/_shared/core/agent-team/agent-team-intake.md +2 -2
- package/presets/_shared/core/quality/self-review-and-context-hygiene.md +1 -0
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +15 -1
- package/presets/claude/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/claude/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/claude/android-kotlin/agents/debugger.md +1 -1
- package/presets/claude/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/claude/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/claude/android-kotlin/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 +15 -1
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/go/agents/build-verifier.md +1 -1
- package/presets/claude/go/agents/code-reviewer.md +1 -1
- package/presets/claude/go/agents/debugger.md +1 -1
- package/presets/claude/go/agents/feature-developer.md +1 -1
- package/presets/claude/go/agents/task-analyst.md +1 -1
- package/presets/claude/go/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 +15 -1
- package/presets/claude/go/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/ios-swift/agents/build-verifier.md +1 -1
- package/presets/claude/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/claude/ios-swift/agents/debugger.md +1 -1
- package/presets/claude/ios-swift/agents/feature-developer.md +1 -1
- package/presets/claude/ios-swift/agents/task-analyst.md +1 -1
- package/presets/claude/ios-swift/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 +15 -1
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/java/agents/build-verifier.md +1 -1
- package/presets/claude/java/agents/code-reviewer.md +1 -1
- package/presets/claude/java/agents/debugger.md +1 -1
- package/presets/claude/java/agents/feature-developer.md +1 -1
- package/presets/claude/java/agents/task-analyst.md +1 -1
- package/presets/claude/java/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 +15 -1
- package/presets/claude/java/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/claude/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/claude/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/claude/mcp-ts/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 +15 -1
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/mol/agents/build-verifier.md +1 -1
- package/presets/claude/mol/agents/code-reviewer.md +1 -1
- package/presets/claude/mol/agents/debugger.md +1 -1
- package/presets/claude/mol/agents/feature-developer.md +1 -1
- package/presets/claude/mol/agents/task-analyst.md +1 -1
- package/presets/claude/mol/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 +15 -1
- package/presets/claude/mol/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/next/REPO_AGENTS.md +16 -0
- package/presets/claude/next/agents/accessibility-reviewer.md +4 -1
- package/presets/claude/next/agents/api-contract-reviewer.md +5 -2
- package/presets/claude/next/agents/build-verifier.md +6 -3
- package/presets/claude/next/agents/ci-investigator.md +1 -1
- package/presets/claude/next/agents/code-reviewer.md +7 -4
- package/presets/claude/next/agents/codebase-analyzer.md +4 -1
- package/presets/claude/next/agents/debugger.md +2 -2
- package/presets/claude/next/agents/feature-developer.md +2 -2
- package/presets/claude/next/agents/migration-specialist.md +4 -1
- package/presets/claude/next/agents/mockup-reviewer.md +4 -1
- package/presets/claude/next/agents/openspec-author.md +4 -1
- package/presets/claude/next/agents/performance-auditor.md +4 -1
- package/presets/claude/next/agents/playwright-test-generator.md +5 -2
- package/presets/claude/next/agents/playwright-test-healer.md +5 -2
- package/presets/claude/next/agents/playwright-test-planner.md +5 -2
- package/presets/claude/next/agents/qa-tester.md +5 -2
- package/presets/claude/next/agents/security-reviewer.md +4 -1
- package/presets/claude/next/agents/solution-architect.md +4 -1
- package/presets/claude/next/agents/task-analyst.md +5 -2
- package/presets/claude/next/agents/task-router.md +4 -1
- package/presets/claude/next/agents/tech-writer.md +4 -1
- package/presets/claude/next/agents/unit-test-generator.md +5 -2
- package/presets/claude/next/agents/unit-test-healer.md +5 -2
- package/presets/claude/next/agents/unit-test-planner.md +5 -2
- package/presets/claude/next/ai-local/conventions.md +26 -1
- 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 +15 -1
- package/presets/claude/next/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/nuxt/agents/build-verifier.md +1 -1
- package/presets/claude/nuxt/agents/code-reviewer.md +1 -1
- package/presets/claude/nuxt/agents/debugger.md +1 -1
- package/presets/claude/nuxt/agents/feature-developer.md +1 -1
- package/presets/claude/nuxt/agents/task-analyst.md +1 -1
- package/presets/claude/nuxt/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 +15 -1
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/claude/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/claude/php-hexagonal/agents/debugger.md +1 -1
- package/presets/claude/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/claude/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/claude/php-hexagonal/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 +15 -1
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/php-laravel/agents/build-verifier.md +1 -1
- package/presets/claude/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/claude/php-laravel/agents/debugger.md +1 -1
- package/presets/claude/php-laravel/agents/feature-developer.md +1 -1
- package/presets/claude/php-laravel/agents/task-analyst.md +1 -1
- package/presets/claude/php-laravel/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 +15 -1
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/claude/svelte/agents/build-verifier.md +1 -1
- package/presets/claude/svelte/agents/code-reviewer.md +1 -1
- package/presets/claude/svelte/agents/debugger.md +1 -1
- package/presets/claude/svelte/agents/feature-developer.md +1 -1
- package/presets/claude/svelte/agents/task-analyst.md +1 -1
- package/presets/claude/svelte/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 +15 -1
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-intake.md +2 -2
- package/presets/cursor/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/cursor/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/cursor/android-kotlin/agents/debugger.md +1 -1
- package/presets/cursor/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/cursor/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/cursor/android-kotlin/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 +15 -1
- package/presets/cursor/android-kotlin/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/go/agents/build-verifier.md +1 -1
- package/presets/cursor/go/agents/code-reviewer.md +1 -1
- package/presets/cursor/go/agents/debugger.md +1 -1
- package/presets/cursor/go/agents/feature-developer.md +1 -1
- package/presets/cursor/go/agents/task-analyst.md +1 -1
- package/presets/cursor/go/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 +15 -1
- package/presets/cursor/go/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/ios-swift/agents/build-verifier.md +1 -1
- package/presets/cursor/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/cursor/ios-swift/agents/debugger.md +1 -1
- package/presets/cursor/ios-swift/agents/feature-developer.md +1 -1
- package/presets/cursor/ios-swift/agents/task-analyst.md +1 -1
- package/presets/cursor/ios-swift/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 +15 -1
- package/presets/cursor/ios-swift/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/java/agents/build-verifier.md +1 -1
- package/presets/cursor/java/agents/code-reviewer.md +1 -1
- package/presets/cursor/java/agents/debugger.md +1 -1
- package/presets/cursor/java/agents/feature-developer.md +1 -1
- package/presets/cursor/java/agents/task-analyst.md +1 -1
- package/presets/cursor/java/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 +15 -1
- package/presets/cursor/java/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/cursor/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/cursor/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/cursor/mcp-ts/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 +15 -1
- package/presets/cursor/mcp-ts/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/mol/agents/build-verifier.md +1 -1
- package/presets/cursor/mol/agents/code-reviewer.md +1 -1
- package/presets/cursor/mol/agents/debugger.md +1 -1
- package/presets/cursor/mol/agents/feature-developer.md +1 -1
- package/presets/cursor/mol/agents/task-analyst.md +1 -1
- package/presets/cursor/mol/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 +15 -1
- package/presets/cursor/mol/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/next/AGENTS.md +2 -1
- package/presets/cursor/next/REPO_AGENTS.md +16 -0
- package/presets/cursor/next/agents/build-verifier.md +1 -1
- package/presets/cursor/next/agents/code-reviewer.md +1 -1
- package/presets/cursor/next/agents/debugger.md +1 -1
- package/presets/cursor/next/agents/feature-developer.md +1 -1
- package/presets/cursor/next/agents/task-analyst.md +1 -1
- package/presets/cursor/next/ai-local/conventions.md +6 -1
- 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 +15 -1
- package/presets/cursor/next/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/nuxt/agents/build-verifier.md +1 -1
- package/presets/cursor/nuxt/agents/code-reviewer.md +1 -1
- package/presets/cursor/nuxt/agents/debugger.md +1 -1
- package/presets/cursor/nuxt/agents/feature-developer.md +1 -1
- package/presets/cursor/nuxt/agents/task-analyst.md +1 -1
- package/presets/cursor/nuxt/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 +15 -1
- package/presets/cursor/nuxt/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/cursor/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/cursor/php-hexagonal/agents/debugger.md +1 -1
- package/presets/cursor/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/cursor/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/cursor/php-hexagonal/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 +15 -1
- package/presets/cursor/php-hexagonal/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/php-laravel/agents/build-verifier.md +1 -1
- package/presets/cursor/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/cursor/php-laravel/agents/debugger.md +1 -1
- package/presets/cursor/php-laravel/agents/feature-developer.md +1 -1
- package/presets/cursor/php-laravel/agents/task-analyst.md +1 -1
- package/presets/cursor/php-laravel/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 +15 -1
- package/presets/cursor/php-laravel/rules/agent-team-intake.mdc +2 -2
- package/presets/cursor/svelte/agents/build-verifier.md +1 -1
- package/presets/cursor/svelte/agents/code-reviewer.md +1 -1
- package/presets/cursor/svelte/agents/debugger.md +1 -1
- package/presets/cursor/svelte/agents/feature-developer.md +1 -1
- package/presets/cursor/svelte/agents/task-analyst.md +1 -1
- package/presets/cursor/svelte/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 +15 -1
- package/presets/cursor/svelte/rules/agent-team-intake.mdc +2 -2
- package/presets/mavis/android-kotlin/adapter-map.json +9 -1
- package/presets/mavis/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/mavis/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/mavis/android-kotlin/agents/debugger.md +1 -1
- package/presets/mavis/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/mavis/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/mavis/android-kotlin/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 +15 -1
- package/presets/mavis/android-kotlin/rules/agent-team-intake.md +2 -2
- package/presets/mavis/go/adapter-map.json +9 -1
- package/presets/mavis/go/agents/build-verifier.md +1 -1
- package/presets/mavis/go/agents/code-reviewer.md +1 -1
- package/presets/mavis/go/agents/debugger.md +1 -1
- package/presets/mavis/go/agents/feature-developer.md +1 -1
- package/presets/mavis/go/agents/task-analyst.md +1 -1
- package/presets/mavis/go/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 +15 -1
- package/presets/mavis/go/rules/agent-team-intake.md +2 -2
- package/presets/mavis/ios-swift/adapter-map.json +9 -1
- package/presets/mavis/ios-swift/agents/build-verifier.md +1 -1
- package/presets/mavis/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/mavis/ios-swift/agents/debugger.md +1 -1
- package/presets/mavis/ios-swift/agents/feature-developer.md +1 -1
- package/presets/mavis/ios-swift/agents/task-analyst.md +1 -1
- package/presets/mavis/ios-swift/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 +15 -1
- package/presets/mavis/ios-swift/rules/agent-team-intake.md +2 -2
- package/presets/mavis/java/adapter-map.json +9 -1
- package/presets/mavis/java/agents/build-verifier.md +1 -1
- package/presets/mavis/java/agents/code-reviewer.md +1 -1
- package/presets/mavis/java/agents/debugger.md +1 -1
- package/presets/mavis/java/agents/feature-developer.md +1 -1
- package/presets/mavis/java/agents/task-analyst.md +1 -1
- package/presets/mavis/java/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 +15 -1
- package/presets/mavis/java/rules/agent-team-intake.md +2 -2
- package/presets/mavis/mcp-ts/adapter-map.json +9 -1
- package/presets/mavis/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/mavis/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/mavis/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/mavis/mcp-ts/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 +15 -1
- package/presets/mavis/mcp-ts/rules/agent-team-intake.md +2 -2
- package/presets/mavis/mol/adapter-map.json +9 -1
- package/presets/mavis/mol/agents/build-verifier.md +1 -1
- package/presets/mavis/mol/agents/code-reviewer.md +1 -1
- package/presets/mavis/mol/agents/debugger.md +1 -1
- package/presets/mavis/mol/agents/feature-developer.md +1 -1
- package/presets/mavis/mol/agents/task-analyst.md +1 -1
- package/presets/mavis/mol/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 +15 -1
- package/presets/mavis/mol/rules/agent-team-intake.md +2 -2
- package/presets/mavis/next/MAVIS.md +2 -1
- package/presets/mavis/next/REPO_AGENTS.md +16 -0
- package/presets/mavis/next/adapter-map.json +9 -1
- package/presets/mavis/next/agents/accessibility-reviewer.md +4 -1
- package/presets/mavis/next/agents/api-contract-reviewer.md +5 -2
- package/presets/mavis/next/agents/build-verifier.md +6 -3
- package/presets/mavis/next/agents/ci-investigator.md +1 -1
- package/presets/mavis/next/agents/code-reviewer.md +7 -4
- package/presets/mavis/next/agents/codebase-analyzer.md +4 -1
- package/presets/mavis/next/agents/debugger.md +2 -2
- package/presets/mavis/next/agents/feature-developer.md +2 -2
- package/presets/mavis/next/agents/migration-specialist.md +4 -1
- package/presets/mavis/next/agents/mockup-reviewer.md +4 -1
- package/presets/mavis/next/agents/openspec-author.md +4 -1
- package/presets/mavis/next/agents/performance-auditor.md +4 -1
- package/presets/mavis/next/agents/playwright-test-generator.md +5 -2
- package/presets/mavis/next/agents/playwright-test-healer.md +5 -2
- package/presets/mavis/next/agents/playwright-test-planner.md +5 -2
- package/presets/mavis/next/agents/qa-tester.md +5 -2
- package/presets/mavis/next/agents/security-reviewer.md +4 -1
- package/presets/mavis/next/agents/solution-architect.md +4 -1
- package/presets/mavis/next/agents/task-analyst.md +5 -2
- package/presets/mavis/next/agents/task-router.md +4 -1
- package/presets/mavis/next/agents/tech-writer.md +4 -1
- package/presets/mavis/next/agents/unit-test-generator.md +5 -2
- package/presets/mavis/next/agents/unit-test-healer.md +5 -2
- package/presets/mavis/next/agents/unit-test-planner.md +5 -2
- package/presets/mavis/next/ai-local/conventions.md +6 -1
- 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 +15 -1
- package/presets/mavis/next/rules/agent-team-intake.md +2 -2
- package/presets/mavis/nuxt/adapter-map.json +9 -1
- package/presets/mavis/nuxt/agents/build-verifier.md +1 -1
- package/presets/mavis/nuxt/agents/code-reviewer.md +1 -1
- package/presets/mavis/nuxt/agents/debugger.md +1 -1
- package/presets/mavis/nuxt/agents/feature-developer.md +1 -1
- package/presets/mavis/nuxt/agents/task-analyst.md +1 -1
- package/presets/mavis/nuxt/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 +15 -1
- package/presets/mavis/nuxt/rules/agent-team-intake.md +2 -2
- package/presets/mavis/php-hexagonal/adapter-map.json +9 -1
- package/presets/mavis/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/mavis/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/mavis/php-hexagonal/agents/debugger.md +1 -1
- package/presets/mavis/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/mavis/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/mavis/php-hexagonal/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 +15 -1
- package/presets/mavis/php-hexagonal/rules/agent-team-intake.md +2 -2
- package/presets/mavis/php-laravel/adapter-map.json +9 -1
- package/presets/mavis/php-laravel/agents/build-verifier.md +1 -1
- package/presets/mavis/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/mavis/php-laravel/agents/debugger.md +1 -1
- package/presets/mavis/php-laravel/agents/feature-developer.md +1 -1
- package/presets/mavis/php-laravel/agents/task-analyst.md +1 -1
- package/presets/mavis/php-laravel/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 +15 -1
- package/presets/mavis/php-laravel/rules/agent-team-intake.md +2 -2
- package/presets/mavis/svelte/adapter-map.json +9 -1
- package/presets/mavis/svelte/agents/build-verifier.md +1 -1
- package/presets/mavis/svelte/agents/code-reviewer.md +1 -1
- package/presets/mavis/svelte/agents/debugger.md +1 -1
- package/presets/mavis/svelte/agents/feature-developer.md +1 -1
- package/presets/mavis/svelte/agents/task-analyst.md +1 -1
- package/presets/mavis/svelte/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 +15 -1
- package/presets/mavis/svelte/rules/agent-team-intake.md +2 -2
- package/presets/opencode/android-kotlin/adapter-map.json +9 -1
- package/presets/opencode/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/opencode/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/opencode/android-kotlin/agents/debugger.md +1 -1
- package/presets/opencode/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/opencode/android-kotlin/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 +15 -1
- package/presets/opencode/android-kotlin/rules/agent-team-intake.md +2 -2
- package/presets/opencode/go/adapter-map.json +9 -1
- package/presets/opencode/go/agents/build-verifier.md +1 -1
- package/presets/opencode/go/agents/code-reviewer.md +1 -1
- package/presets/opencode/go/agents/debugger.md +1 -1
- package/presets/opencode/go/agents/feature-developer.md +1 -1
- package/presets/opencode/go/agents/task-analyst.md +1 -1
- package/presets/opencode/go/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 +15 -1
- package/presets/opencode/go/rules/agent-team-intake.md +2 -2
- package/presets/opencode/ios-swift/adapter-map.json +9 -1
- package/presets/opencode/ios-swift/agents/build-verifier.md +1 -1
- package/presets/opencode/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/opencode/ios-swift/agents/debugger.md +1 -1
- package/presets/opencode/ios-swift/agents/feature-developer.md +1 -1
- package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/opencode/ios-swift/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 +15 -1
- package/presets/opencode/ios-swift/rules/agent-team-intake.md +2 -2
- package/presets/opencode/java/adapter-map.json +9 -1
- package/presets/opencode/java/agents/build-verifier.md +1 -1
- package/presets/opencode/java/agents/code-reviewer.md +1 -1
- package/presets/opencode/java/agents/debugger.md +1 -1
- package/presets/opencode/java/agents/feature-developer.md +1 -1
- package/presets/opencode/java/agents/task-analyst.md +1 -1
- package/presets/opencode/java/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 +15 -1
- package/presets/opencode/java/rules/agent-team-intake.md +2 -2
- package/presets/opencode/mcp-ts/adapter-map.json +9 -1
- package/presets/opencode/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/opencode/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/opencode/mcp-ts/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 +15 -1
- package/presets/opencode/mcp-ts/rules/agent-team-intake.md +2 -2
- package/presets/opencode/mol/adapter-map.json +9 -1
- package/presets/opencode/mol/agents/build-verifier.md +1 -1
- package/presets/opencode/mol/agents/code-reviewer.md +1 -1
- package/presets/opencode/mol/agents/debugger.md +1 -1
- package/presets/opencode/mol/agents/feature-developer.md +1 -1
- package/presets/opencode/mol/agents/task-analyst.md +1 -1
- package/presets/opencode/mol/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 +15 -1
- package/presets/opencode/mol/rules/agent-team-intake.md +2 -2
- package/presets/opencode/next/OPENCODE.md +2 -1
- package/presets/opencode/next/REPO_AGENTS.md +16 -0
- package/presets/opencode/next/adapter-map.json +9 -1
- package/presets/opencode/next/agents/accessibility-reviewer.md +4 -1
- package/presets/opencode/next/agents/api-contract-reviewer.md +5 -2
- package/presets/opencode/next/agents/build-verifier.md +6 -3
- package/presets/opencode/next/agents/ci-investigator.md +1 -1
- package/presets/opencode/next/agents/code-reviewer.md +7 -4
- package/presets/opencode/next/agents/codebase-analyzer.md +4 -1
- package/presets/opencode/next/agents/debugger.md +2 -2
- package/presets/opencode/next/agents/feature-developer.md +2 -2
- package/presets/opencode/next/agents/migration-specialist.md +4 -1
- package/presets/opencode/next/agents/mockup-reviewer.md +4 -1
- package/presets/opencode/next/agents/openspec-author.md +4 -1
- package/presets/opencode/next/agents/performance-auditor.md +4 -1
- package/presets/opencode/next/agents/playwright-test-generator.md +5 -2
- package/presets/opencode/next/agents/playwright-test-healer.md +5 -2
- package/presets/opencode/next/agents/playwright-test-planner.md +5 -2
- package/presets/opencode/next/agents/qa-tester.md +5 -2
- package/presets/opencode/next/agents/security-reviewer.md +4 -1
- package/presets/opencode/next/agents/solution-architect.md +4 -1
- package/presets/opencode/next/agents/task-analyst.md +5 -2
- package/presets/opencode/next/agents/task-router.md +4 -1
- package/presets/opencode/next/agents/tech-writer.md +4 -1
- package/presets/opencode/next/agents/unit-test-generator.md +5 -2
- package/presets/opencode/next/agents/unit-test-healer.md +5 -2
- package/presets/opencode/next/agents/unit-test-planner.md +5 -2
- package/presets/opencode/next/ai-local/conventions.md +6 -1
- 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 +15 -1
- package/presets/opencode/next/rules/agent-team-intake.md +2 -2
- package/presets/opencode/nuxt/adapter-map.json +9 -1
- package/presets/opencode/nuxt/agents/build-verifier.md +1 -1
- package/presets/opencode/nuxt/agents/code-reviewer.md +1 -1
- package/presets/opencode/nuxt/agents/debugger.md +1 -1
- package/presets/opencode/nuxt/agents/feature-developer.md +1 -1
- package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
- package/presets/opencode/nuxt/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 +15 -1
- package/presets/opencode/nuxt/rules/agent-team-intake.md +2 -2
- package/presets/opencode/php-hexagonal/adapter-map.json +9 -1
- package/presets/opencode/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/opencode/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/debugger.md +1 -1
- package/presets/opencode/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/opencode/php-hexagonal/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 +15 -1
- package/presets/opencode/php-hexagonal/rules/agent-team-intake.md +2 -2
- package/presets/opencode/php-laravel/adapter-map.json +9 -1
- package/presets/opencode/php-laravel/agents/build-verifier.md +1 -1
- package/presets/opencode/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/opencode/php-laravel/agents/debugger.md +1 -1
- package/presets/opencode/php-laravel/agents/feature-developer.md +1 -1
- package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/opencode/php-laravel/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 +15 -1
- package/presets/opencode/php-laravel/rules/agent-team-intake.md +2 -2
- package/presets/opencode/plugins/output-guard/README.md +56 -9
- 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 +15 -9
- package/presets/opencode/svelte/adapter-map.json +9 -1
- package/presets/opencode/svelte/agents/build-verifier.md +1 -1
- package/presets/opencode/svelte/agents/code-reviewer.md +1 -1
- package/presets/opencode/svelte/agents/debugger.md +1 -1
- package/presets/opencode/svelte/agents/feature-developer.md +1 -1
- package/presets/opencode/svelte/agents/task-analyst.md +1 -1
- package/presets/opencode/svelte/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 +15 -1
- package/presets/opencode/svelte/rules/agent-team-intake.md +2 -2
- package/presets/zcode/android-kotlin/adapter-map.json +9 -1
- package/presets/zcode/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/zcode/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/zcode/android-kotlin/agents/debugger.md +1 -1
- package/presets/zcode/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/zcode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/zcode/android-kotlin/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 +15 -1
- package/presets/zcode/android-kotlin/rules/agent-team-intake.md +2 -2
- package/presets/zcode/go/adapter-map.json +9 -1
- package/presets/zcode/go/agents/build-verifier.md +1 -1
- package/presets/zcode/go/agents/code-reviewer.md +1 -1
- package/presets/zcode/go/agents/debugger.md +1 -1
- package/presets/zcode/go/agents/feature-developer.md +1 -1
- package/presets/zcode/go/agents/task-analyst.md +1 -1
- package/presets/zcode/go/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 +15 -1
- package/presets/zcode/go/rules/agent-team-intake.md +2 -2
- package/presets/zcode/ios-swift/adapter-map.json +9 -1
- package/presets/zcode/ios-swift/agents/build-verifier.md +1 -1
- package/presets/zcode/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/zcode/ios-swift/agents/debugger.md +1 -1
- package/presets/zcode/ios-swift/agents/feature-developer.md +1 -1
- package/presets/zcode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/zcode/ios-swift/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 +15 -1
- package/presets/zcode/ios-swift/rules/agent-team-intake.md +2 -2
- package/presets/zcode/java/adapter-map.json +9 -1
- package/presets/zcode/java/agents/build-verifier.md +1 -1
- package/presets/zcode/java/agents/code-reviewer.md +1 -1
- package/presets/zcode/java/agents/debugger.md +1 -1
- package/presets/zcode/java/agents/feature-developer.md +1 -1
- package/presets/zcode/java/agents/task-analyst.md +1 -1
- package/presets/zcode/java/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 +15 -1
- package/presets/zcode/java/rules/agent-team-intake.md +2 -2
- package/presets/zcode/mcp-ts/adapter-map.json +9 -1
- package/presets/zcode/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/zcode/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/zcode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/zcode/mcp-ts/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 +15 -1
- package/presets/zcode/mcp-ts/rules/agent-team-intake.md +2 -2
- package/presets/zcode/mol/adapter-map.json +9 -1
- package/presets/zcode/mol/agents/build-verifier.md +1 -1
- package/presets/zcode/mol/agents/code-reviewer.md +1 -1
- package/presets/zcode/mol/agents/debugger.md +1 -1
- package/presets/zcode/mol/agents/feature-developer.md +1 -1
- package/presets/zcode/mol/agents/task-analyst.md +1 -1
- package/presets/zcode/mol/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 +15 -1
- package/presets/zcode/mol/rules/agent-team-intake.md +2 -2
- package/presets/zcode/next/REPO_AGENTS.md +16 -0
- package/presets/zcode/next/adapter-map.json +9 -1
- package/presets/zcode/next/agents/accessibility-reviewer.md +4 -1
- package/presets/zcode/next/agents/api-contract-reviewer.md +5 -2
- package/presets/zcode/next/agents/build-verifier.md +6 -3
- package/presets/zcode/next/agents/ci-investigator.md +1 -1
- package/presets/zcode/next/agents/code-reviewer.md +7 -4
- package/presets/zcode/next/agents/codebase-analyzer.md +4 -1
- package/presets/zcode/next/agents/debugger.md +2 -2
- package/presets/zcode/next/agents/feature-developer.md +2 -2
- package/presets/zcode/next/agents/migration-specialist.md +4 -1
- package/presets/zcode/next/agents/mockup-reviewer.md +4 -1
- package/presets/zcode/next/agents/openspec-author.md +4 -1
- package/presets/zcode/next/agents/performance-auditor.md +4 -1
- package/presets/zcode/next/agents/playwright-test-generator.md +5 -2
- package/presets/zcode/next/agents/playwright-test-healer.md +5 -2
- package/presets/zcode/next/agents/playwright-test-planner.md +5 -2
- package/presets/zcode/next/agents/qa-tester.md +5 -2
- package/presets/zcode/next/agents/security-reviewer.md +4 -1
- package/presets/zcode/next/agents/solution-architect.md +4 -1
- package/presets/zcode/next/agents/task-analyst.md +5 -2
- package/presets/zcode/next/agents/task-router.md +4 -1
- package/presets/zcode/next/agents/tech-writer.md +4 -1
- package/presets/zcode/next/agents/unit-test-generator.md +5 -2
- package/presets/zcode/next/agents/unit-test-healer.md +5 -2
- package/presets/zcode/next/agents/unit-test-planner.md +5 -2
- package/presets/zcode/next/ai-local/conventions.md +6 -1
- 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 +15 -1
- package/presets/zcode/next/rules/agent-team-intake.md +2 -2
- package/presets/zcode/nuxt/adapter-map.json +9 -1
- package/presets/zcode/nuxt/agents/build-verifier.md +1 -1
- package/presets/zcode/nuxt/agents/code-reviewer.md +1 -1
- package/presets/zcode/nuxt/agents/debugger.md +1 -1
- package/presets/zcode/nuxt/agents/feature-developer.md +1 -1
- package/presets/zcode/nuxt/agents/task-analyst.md +1 -1
- package/presets/zcode/nuxt/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 +15 -1
- package/presets/zcode/nuxt/rules/agent-team-intake.md +2 -2
- package/presets/zcode/php-hexagonal/adapter-map.json +9 -1
- package/presets/zcode/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/zcode/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/zcode/php-hexagonal/agents/debugger.md +1 -1
- package/presets/zcode/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/zcode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/zcode/php-hexagonal/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 +15 -1
- package/presets/zcode/php-hexagonal/rules/agent-team-intake.md +2 -2
- package/presets/zcode/php-laravel/adapter-map.json +9 -1
- package/presets/zcode/php-laravel/agents/build-verifier.md +1 -1
- package/presets/zcode/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/zcode/php-laravel/agents/debugger.md +1 -1
- package/presets/zcode/php-laravel/agents/feature-developer.md +1 -1
- package/presets/zcode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/zcode/php-laravel/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 +15 -1
- package/presets/zcode/php-laravel/rules/agent-team-intake.md +2 -2
- package/presets/zcode/svelte/adapter-map.json +9 -1
- package/presets/zcode/svelte/agents/build-verifier.md +1 -1
- package/presets/zcode/svelte/agents/code-reviewer.md +1 -1
- package/presets/zcode/svelte/agents/debugger.md +1 -1
- package/presets/zcode/svelte/agents/feature-developer.md +1 -1
- package/presets/zcode/svelte/agents/task-analyst.md +1 -1
- package/presets/zcode/svelte/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 +15 -1
- package/presets/zcode/svelte/rules/agent-team-intake.md +2 -2
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
readSearchMode,
|
|
33
33
|
teamDbFail,
|
|
34
34
|
} from './team-db-schema.mjs';
|
|
35
|
+
import { ACTION_ERROR_CLASSES } from './action-signals.mjs';
|
|
35
36
|
import { projectScheduler, retainRuns } from './team-db-scheduler.mjs';
|
|
36
37
|
import { validateEntrySchema, validateItemSchema, validateLinkIdentity, validateLinkSchema } from './team-db-tracker.mjs';
|
|
37
38
|
|
|
@@ -40,6 +41,10 @@ export const MAX_RAW_BYTES = 32 * 1024 * 1024;
|
|
|
40
41
|
export const RETENTION_DAYS = 90;
|
|
41
42
|
export const SYNC_RUN_RETENTION = 200;
|
|
42
43
|
export const DEFAULT_SLUG_DEADLINE_MS = 4500;
|
|
44
|
+
/** The grace a lease window keeps after its last write, in milliseconds. */
|
|
45
|
+
export const LEASE_TTL_MS = 30 * 60 * 1000;
|
|
46
|
+
/** The fuzz around the last write of `tasks/<slug>` for the weakest rung. */
|
|
47
|
+
export const DIR_WINDOW_MS = 30 * 60 * 1000;
|
|
43
48
|
|
|
44
49
|
const HASH_CHUNK = 64 * 1024;
|
|
45
50
|
const MAX_KNOWN_BYTES = 8 * 1024 * 1024;
|
|
@@ -265,6 +270,40 @@ export function parsePromptMarkdown(text) {
|
|
|
265
270
|
return { content: body.trim(), meta, error: null };
|
|
266
271
|
}
|
|
267
272
|
|
|
273
|
+
/**
|
|
274
|
+
* A prompt-log entry written before the fenced `text` block keeps the user's
|
|
275
|
+
* words in a blockquote or under a `- text: |` bullet. The words are intact and
|
|
276
|
+
* the shape is legacy, so such an entry is a valid prompt, not a parse failure.
|
|
277
|
+
*/
|
|
278
|
+
const legacyPromptText = (body) => {
|
|
279
|
+
const quoted = body
|
|
280
|
+
.split('\n')
|
|
281
|
+
.filter((line) => /^\s*>/.test(line))
|
|
282
|
+
.map((line) => line.replace(/^\s*>\s?/, ''));
|
|
283
|
+
if (quoted.length > 0) {
|
|
284
|
+
const text = quoted.join('\n').trim();
|
|
285
|
+
if (text !== '') return text;
|
|
286
|
+
}
|
|
287
|
+
const block = /^-\s*text:\s*[|>][-+]?\s*$([\s\S]*)$/m.exec(body);
|
|
288
|
+
if (!block) return null;
|
|
289
|
+
const lines = block[1].split('\n');
|
|
290
|
+
const content = [];
|
|
291
|
+
let indent = null;
|
|
292
|
+
for (const line of lines) {
|
|
293
|
+
if (line.trim() === '') {
|
|
294
|
+
if (content.length > 0) content.push('');
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
const leading = line.match(/^\s*/)[0].length;
|
|
298
|
+
if (leading === 0) break;
|
|
299
|
+
if (indent === null) indent = leading;
|
|
300
|
+
if (leading < indent) break;
|
|
301
|
+
content.push(line.slice(indent));
|
|
302
|
+
}
|
|
303
|
+
const text = content.join('\n').trim();
|
|
304
|
+
return text === '' ? null : text;
|
|
305
|
+
};
|
|
306
|
+
|
|
268
307
|
export function parsePromptLogMarkdown(text) {
|
|
269
308
|
// `## <n>` is a section only outside a fenced block: a prompt may itself
|
|
270
309
|
// contain a Markdown heading.
|
|
@@ -287,11 +326,12 @@ export function parsePromptLogMarkdown(text) {
|
|
|
287
326
|
sections.forEach((section) => {
|
|
288
327
|
const body = section.lines.join('\n');
|
|
289
328
|
const fence = FENCE_RE.exec(body);
|
|
290
|
-
|
|
291
|
-
|
|
329
|
+
const content = fence ? fence[1] : legacyPromptText(body);
|
|
330
|
+
if (content === null) {
|
|
331
|
+
errors.push(`entry ${section.label} has no prompt text block`);
|
|
292
332
|
return;
|
|
293
333
|
}
|
|
294
|
-
const meta = parsePromptMeta(body.slice(0, fence.index));
|
|
334
|
+
const meta = parsePromptMeta(fence ? body.slice(0, fence.index) : body);
|
|
295
335
|
const seq = integerOrNull(meta.seq) ?? section.label;
|
|
296
336
|
if (seen.has(seq)) {
|
|
297
337
|
errors.push(`entry ${section.label} duplicates seq ${seq}`);
|
|
@@ -302,9 +342,9 @@ export function parsePromptLogMarkdown(text) {
|
|
|
302
342
|
seq,
|
|
303
343
|
source: meta.source ?? null,
|
|
304
344
|
command: meta.command ?? null,
|
|
305
|
-
capturedAt: isoTimestamp(meta.capturedAt),
|
|
345
|
+
capturedAt: isoTimestamp(meta.capturedAt ?? meta.at),
|
|
306
346
|
language: meta.language ?? null,
|
|
307
|
-
content
|
|
347
|
+
content,
|
|
308
348
|
});
|
|
309
349
|
});
|
|
310
350
|
return { entries, errors };
|
|
@@ -360,21 +400,36 @@ const LEDGER_COLUMN_ALIASES = {
|
|
|
360
400
|
id: ['id', 'seq'],
|
|
361
401
|
at: ['at', 'date'],
|
|
362
402
|
source: ['source', 'origin'],
|
|
363
|
-
summary: ['summary', 'finding'],
|
|
403
|
+
summary: ['summary', 'finding', 'path'],
|
|
364
404
|
fair: ['fair'],
|
|
365
|
-
disposition: ['disposition', 'status'],
|
|
405
|
+
disposition: ['disposition', 'status', 'resolution'],
|
|
366
406
|
evidence: ['evidence'],
|
|
367
407
|
signature: ['signature'],
|
|
368
408
|
};
|
|
369
409
|
|
|
370
|
-
|
|
410
|
+
/**
|
|
411
|
+
* A header cell may carry a qualifier (`finding (path:line)`, `Round 2`), so the
|
|
412
|
+
* matcher reads the cell's word tokens instead of the whole cell: `finding
|
|
413
|
+
* (path:line)` maps to `summary` the way a bare `finding` does.
|
|
414
|
+
*/
|
|
415
|
+
const ledgerHeaderTokens = (cell) =>
|
|
416
|
+
cell
|
|
417
|
+
.toLowerCase()
|
|
418
|
+
.split(/[^a-z]+/)
|
|
419
|
+
.filter(Boolean);
|
|
420
|
+
|
|
421
|
+
const ledgerCellMatches = (cell, aliases) => {
|
|
422
|
+
const trimmed = cell.trim();
|
|
423
|
+
if (trimmed === '#') return aliases.includes('id');
|
|
424
|
+
return ledgerHeaderTokens(trimmed).some((token) => aliases.includes(token));
|
|
425
|
+
};
|
|
371
426
|
|
|
372
427
|
const ledgerHeaderMap = (line) => {
|
|
373
428
|
if (!line.startsWith('|')) return null;
|
|
374
429
|
const cells = splitTableRow(line);
|
|
375
430
|
const map = {};
|
|
376
431
|
for (const [column, aliases] of Object.entries(LEDGER_COLUMN_ALIASES)) {
|
|
377
|
-
const index = cells.findIndex((cell) =>
|
|
432
|
+
const index = cells.findIndex((cell) => ledgerCellMatches(cell, aliases));
|
|
378
433
|
if (index !== -1) map[column] = index;
|
|
379
434
|
}
|
|
380
435
|
if (map.summary === undefined) return null;
|
|
@@ -416,6 +471,7 @@ export function parseReviewLedgerMarkdown(text) {
|
|
|
416
471
|
const lines = text.split('\n');
|
|
417
472
|
const rows = [];
|
|
418
473
|
const errors = [];
|
|
474
|
+
const rejectedHeaders = [];
|
|
419
475
|
let section = null;
|
|
420
476
|
let rowIndex = 0;
|
|
421
477
|
let headerFound = false;
|
|
@@ -429,6 +485,8 @@ export function parseReviewLedgerMarkdown(text) {
|
|
|
429
485
|
}
|
|
430
486
|
const header = line.startsWith('|') ? ledgerHeaderMap(line) : null;
|
|
431
487
|
if (!header) {
|
|
488
|
+
const next = (lines[index + 1] ?? '').trim();
|
|
489
|
+
if (line.startsWith('|') && /^\|[\s:|-]+\|$/.test(next)) rejectedHeaders.push(line);
|
|
432
490
|
index += 1;
|
|
433
491
|
continue;
|
|
434
492
|
}
|
|
@@ -474,7 +532,11 @@ export function parseReviewLedgerMarkdown(text) {
|
|
|
474
532
|
}
|
|
475
533
|
}
|
|
476
534
|
if (!headerFound) {
|
|
477
|
-
|
|
535
|
+
const rejected = rejectedHeaders[0];
|
|
536
|
+
return {
|
|
537
|
+
rows: [],
|
|
538
|
+
error: rejected ? `unmapped ledger table header: ${rejected}` : 'no ledger table header',
|
|
539
|
+
};
|
|
478
540
|
}
|
|
479
541
|
return { rows, error: null, errors };
|
|
480
542
|
}
|
|
@@ -743,6 +805,54 @@ const numberOrNull = (value) =>
|
|
|
743
805
|
|
|
744
806
|
const realOrNull = (value) => (typeof value === 'number' && Number.isFinite(value) ? value : null);
|
|
745
807
|
|
|
808
|
+
/** A counter the plugin reported: a non-negative integer, or nothing at all. */
|
|
809
|
+
const countOrNull = (value) =>
|
|
810
|
+
typeof value === 'number' && Number.isInteger(value) && value >= 0 ? value : null;
|
|
811
|
+
|
|
812
|
+
/** A hash the capture plane is allowed to store. */
|
|
813
|
+
const HASH_RE = /^[0-9a-f]{64}$/;
|
|
814
|
+
/** An agent name: a short identifier, never a path or a sentence. */
|
|
815
|
+
const AGENT_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
816
|
+
/** A host session or call id. */
|
|
817
|
+
const HOST_ID_RE = /^[A-Za-z0-9_.:-]{1,128}$/;
|
|
818
|
+
/** The failure classes of `design.md` D-3; anything else is refused. */
|
|
819
|
+
export const ERROR_CLASSES = new Set(ACTION_ERROR_CLASSES);
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* The captured half of an action row.
|
|
823
|
+
*
|
|
824
|
+
* The projector never truncates text into the database: a value that is not a
|
|
825
|
+
* hash, an enum member or a bounded identifier is dropped to `null` and counted,
|
|
826
|
+
* so one line of `team-db-errors.log` names the refusal without ever carrying
|
|
827
|
+
* the value.
|
|
828
|
+
*/
|
|
829
|
+
const captureFields = (row, onRefuse) => {
|
|
830
|
+
const refuse = () => onRefuse();
|
|
831
|
+
const hash = typeof row.targetKey === 'string' && HASH_RE.test(row.targetKey) ? row.targetKey : null;
|
|
832
|
+
if (row.targetKey !== undefined && row.targetKey !== null && hash === null) refuse();
|
|
833
|
+
const agent = typeof row.agent === 'string' && AGENT_RE.test(row.agent) ? row.agent : null;
|
|
834
|
+
if (row.agent !== undefined && row.agent !== null && row.agent !== '' && agent === null) refuse();
|
|
835
|
+
const parentSessionId =
|
|
836
|
+
typeof row.parentSessionID === 'string' && HOST_ID_RE.test(row.parentSessionID) ? row.parentSessionID : null;
|
|
837
|
+
if (row.parentSessionID !== undefined && row.parentSessionID !== null && parentSessionId === null) refuse();
|
|
838
|
+
const repeatOf = typeof row.repeatOf === 'string' && HOST_ID_RE.test(row.repeatOf) ? row.repeatOf : null;
|
|
839
|
+
if (row.repeatOf !== undefined && row.repeatOf !== null && repeatOf === null) refuse();
|
|
840
|
+
const errorClass =
|
|
841
|
+
typeof row.errorClass === 'string' && ERROR_CLASSES.has(row.errorClass) ? row.errorClass : null;
|
|
842
|
+
if (row.errorClass !== undefined && row.errorClass !== null && errorClass === null) refuse();
|
|
843
|
+
return {
|
|
844
|
+
agent,
|
|
845
|
+
parentSessionId,
|
|
846
|
+
durationMs: countOrNull(row.durationMs),
|
|
847
|
+
gapMs: countOrNull(row.gapMs),
|
|
848
|
+
targetKey: hash,
|
|
849
|
+
repeatOf,
|
|
850
|
+
repeatIndex: countOrNull(row.repeatIndex),
|
|
851
|
+
exitCode: countOrNull(row.exit),
|
|
852
|
+
errorClass,
|
|
853
|
+
};
|
|
854
|
+
};
|
|
855
|
+
|
|
746
856
|
const usageModel = (value) => {
|
|
747
857
|
if (typeof value === 'string' && value !== '') {
|
|
748
858
|
const separator = value.indexOf('/');
|
|
@@ -1509,7 +1619,12 @@ const projectTask = ({ db, teamRoot, slug, now, searchMode, deadlineAt }) => {
|
|
|
1509
1619
|
if (artifacts) replaceArtifacts(db, slug, artifacts.artifacts);
|
|
1510
1620
|
replacePrompts(db, slug, parsed);
|
|
1511
1621
|
if (parsed.outcome || !parsed.outcomeExists) replaceOutcome(db, slug, parsed.outcome);
|
|
1512
|
-
|
|
1622
|
+
// A ledger the parser could not map keeps its projected rows: an unknown
|
|
1623
|
+
// table shape must not erase the recorded review history. The file is gone
|
|
1624
|
+
// only when the task directory no longer carries it.
|
|
1625
|
+
const ledger = parsed.reviewLedger;
|
|
1626
|
+
if (ledger && !ledger.error) replaceReviewLedger(db, slug, ledger);
|
|
1627
|
+
else if (!parsed.reviewLedgerExists) replaceReviewLedger(db, slug, null);
|
|
1513
1628
|
upsertDocuments(db, slug, files, now);
|
|
1514
1629
|
for (const error of errors) {
|
|
1515
1630
|
const relative = error.path.startsWith(`${slug}/`) ? error.path.slice(slug.length + 1) : null;
|
|
@@ -2033,7 +2148,54 @@ const classifyToolCall = (row) => {
|
|
|
2033
2148
|
return 'other';
|
|
2034
2149
|
};
|
|
2035
2150
|
|
|
2036
|
-
|
|
2151
|
+
/** The tool → intent map of `design.md` D-2; nothing outside it is a new value. */
|
|
2152
|
+
const INTENT_BY_TOOL = new Map([
|
|
2153
|
+
['read', 'explore'],
|
|
2154
|
+
['grep', 'explore'],
|
|
2155
|
+
['glob', 'explore'],
|
|
2156
|
+
['list', 'explore'],
|
|
2157
|
+
['edit', 'mutate'],
|
|
2158
|
+
['write', 'mutate'],
|
|
2159
|
+
['patch', 'mutate'],
|
|
2160
|
+
['shell', 'execute'],
|
|
2161
|
+
['bash', 'execute'],
|
|
2162
|
+
['execute', 'execute'],
|
|
2163
|
+
['subagent', 'delegate'],
|
|
2164
|
+
['task', 'delegate'],
|
|
2165
|
+
['question', 'ask'],
|
|
2166
|
+
['permission', 'ask'],
|
|
2167
|
+
['skill', 'meta'],
|
|
2168
|
+
['todowrite', 'meta'],
|
|
2169
|
+
['todoread', 'meta'],
|
|
2170
|
+
['plan', 'meta'],
|
|
2171
|
+
['webfetch', 'web'],
|
|
2172
|
+
['websearch', 'web'],
|
|
2173
|
+
]);
|
|
2174
|
+
|
|
2175
|
+
/**
|
|
2176
|
+
* The seven-value intent of one tool call.
|
|
2177
|
+
* * A sibling of `classifyToolCall` rather than a rewrite: `category` is read by
|
|
2178
|
+
* `report-efficiency.mjs` and pinned against it by a drift test, so the two
|
|
2179
|
+
* classifiers stay independent. An unknown tool lands in `meta` with its name
|
|
2180
|
+
* kept in `tool` — never back in a bucket that hides it.
|
|
2181
|
+
*/
|
|
2182
|
+
export const intentOf = (row) => {
|
|
2183
|
+
const tool = String(row?.tool ?? '').toLowerCase();
|
|
2184
|
+
if (INTENT_BY_TOOL.has(tool)) return INTENT_BY_TOOL.get(tool);
|
|
2185
|
+
// The legacy command shapes still mean what they meant; a tool outside the
|
|
2186
|
+
// map is read through its command before it falls to `meta`. A network fetch
|
|
2187
|
+
// is decided before the test/build shapes, so `curl https://host.test` stays
|
|
2188
|
+
// a `web` action.
|
|
2189
|
+
const command = String(row?.command ?? '');
|
|
2190
|
+
if (/\b(curl|wget|http)\b/i.test(command)) return 'web';
|
|
2191
|
+
if (/\b(git|test|lint|type-check|tsc|vitest|jest|playwright|eslint|build|compile|bundle)\b/i.test(command)) {
|
|
2192
|
+
return 'execute';
|
|
2193
|
+
}
|
|
2194
|
+
if (/\b(grep|rg|find|search)\b/i.test(command)) return 'explore';
|
|
2195
|
+
return 'meta';
|
|
2196
|
+
};
|
|
2197
|
+
|
|
2198
|
+
const normalizeToolCall = (row, onRefuse = () => {}) => {
|
|
2037
2199
|
if (!isRecord(row)) return null;
|
|
2038
2200
|
const sessionID = typeof row.sessionID === 'string' ? row.sessionID : '';
|
|
2039
2201
|
const callID = typeof row.callID === 'string' ? row.callID : '';
|
|
@@ -2051,12 +2213,14 @@ const normalizeToolCall = (row) => {
|
|
|
2051
2213
|
callID,
|
|
2052
2214
|
tool,
|
|
2053
2215
|
category: classifyToolCall({ tool, command: row.command }),
|
|
2216
|
+
intent: intentOf({ tool, command: row.command }),
|
|
2054
2217
|
rawBytes,
|
|
2055
2218
|
returnedBytes,
|
|
2056
2219
|
keptOutBytes: Math.max(0, rawBytes - returnedBytes),
|
|
2057
2220
|
replaced: booleanFlag(row.replaced),
|
|
2058
2221
|
observedAt,
|
|
2059
2222
|
day: observedAt.slice(0, 10),
|
|
2223
|
+
...captureFields(row, onRefuse),
|
|
2060
2224
|
};
|
|
2061
2225
|
};
|
|
2062
2226
|
|
|
@@ -2086,14 +2250,22 @@ const normalizeUsageTurn = (row) => {
|
|
|
2086
2250
|
observedAt,
|
|
2087
2251
|
eventAt: null,
|
|
2088
2252
|
day: observedAt.slice(0, 10),
|
|
2253
|
+
reasoningParts: countOrNull(row.reasoningParts),
|
|
2254
|
+
reasoningChars: countOrNull(row.reasoningChars),
|
|
2255
|
+
reasoningMs: countOrNull(row.reasoningMs),
|
|
2256
|
+
textChars: countOrNull(row.textChars),
|
|
2257
|
+
toolCalls: countOrNull(row.toolCalls),
|
|
2258
|
+
compactions: countOrNull(row.compactions),
|
|
2089
2259
|
};
|
|
2090
2260
|
};
|
|
2091
2261
|
|
|
2092
2262
|
const UPSERT_TOOL_CALL_SQL = `
|
|
2093
2263
|
INSERT INTO tool_calls (
|
|
2094
2264
|
call_key, session_id, call_id, tool, category, raw_bytes, returned_bytes, kept_out_bytes,
|
|
2095
|
-
replaced, origin, observed_at, day, task_slug, attribution
|
|
2096
|
-
|
|
2265
|
+
replaced, origin, observed_at, day, task_slug, attribution,
|
|
2266
|
+
intent, agent, parent_session_id, duration_ms, gap_ms, target_key, repeat_of, repeat_index,
|
|
2267
|
+
exit_code, error_class
|
|
2268
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 'measured', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
2097
2269
|
ON CONFLICT(call_key) DO UPDATE SET
|
|
2098
2270
|
session_id = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.session_id ELSE tool_calls.session_id END,
|
|
2099
2271
|
call_id = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.call_id ELSE tool_calls.call_id END,
|
|
@@ -2103,6 +2275,16 @@ ON CONFLICT(call_key) DO UPDATE SET
|
|
|
2103
2275
|
returned_bytes = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.returned_bytes ELSE tool_calls.returned_bytes END,
|
|
2104
2276
|
kept_out_bytes = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.kept_out_bytes ELSE tool_calls.kept_out_bytes END,
|
|
2105
2277
|
replaced = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.replaced ELSE tool_calls.replaced END,
|
|
2278
|
+
intent = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.intent ELSE tool_calls.intent END,
|
|
2279
|
+
agent = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.agent ELSE tool_calls.agent END,
|
|
2280
|
+
parent_session_id = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.parent_session_id ELSE tool_calls.parent_session_id END,
|
|
2281
|
+
duration_ms = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.duration_ms ELSE tool_calls.duration_ms END,
|
|
2282
|
+
gap_ms = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.gap_ms ELSE tool_calls.gap_ms END,
|
|
2283
|
+
target_key = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.target_key ELSE tool_calls.target_key END,
|
|
2284
|
+
repeat_of = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.repeat_of ELSE tool_calls.repeat_of END,
|
|
2285
|
+
repeat_index = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.repeat_index ELSE tool_calls.repeat_index END,
|
|
2286
|
+
exit_code = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.exit_code ELSE tool_calls.exit_code END,
|
|
2287
|
+
error_class = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.error_class ELSE tool_calls.error_class END,
|
|
2106
2288
|
observed_at = MIN(tool_calls.observed_at, excluded.observed_at),
|
|
2107
2289
|
day = MIN(tool_calls.day, excluded.day),
|
|
2108
2290
|
task_slug = CASE WHEN excluded.observed_at < tool_calls.observed_at THEN excluded.task_slug ELSE tool_calls.task_slug END,
|
|
@@ -2113,8 +2295,9 @@ const UPSERT_USAGE_TURN_SQL = `
|
|
|
2113
2295
|
INSERT INTO usage_turns (
|
|
2114
2296
|
turn_key, session_id, message_id, agent, provider_id, model_id, model_variant,
|
|
2115
2297
|
input_tokens, output_tokens, reasoning_tokens, cache_read_tokens, cache_write_tokens,
|
|
2116
|
-
cost_usd, finish, origin, observed_at, event_at, day, task_slug, attribution
|
|
2117
|
-
|
|
2298
|
+
cost_usd, finish, origin, observed_at, event_at, day, task_slug, attribution,
|
|
2299
|
+
reasoning_parts, reasoning_chars, reasoning_ms, text_chars, tool_calls, compactions
|
|
2300
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'measured', ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
2118
2301
|
ON CONFLICT(turn_key) DO UPDATE SET
|
|
2119
2302
|
session_id = CASE WHEN excluded.observed_at < usage_turns.observed_at THEN excluded.session_id ELSE usage_turns.session_id END,
|
|
2120
2303
|
message_id = CASE WHEN excluded.observed_at < usage_turns.observed_at THEN excluded.message_id ELSE usage_turns.message_id END,
|
|
@@ -2129,6 +2312,12 @@ ON CONFLICT(turn_key) DO UPDATE SET
|
|
|
2129
2312
|
cache_write_tokens = CASE WHEN excluded.observed_at < usage_turns.observed_at THEN excluded.cache_write_tokens ELSE usage_turns.cache_write_tokens END,
|
|
2130
2313
|
cost_usd = CASE WHEN excluded.observed_at < usage_turns.observed_at THEN excluded.cost_usd ELSE usage_turns.cost_usd END,
|
|
2131
2314
|
finish = CASE WHEN excluded.observed_at < usage_turns.observed_at THEN excluded.finish ELSE usage_turns.finish END,
|
|
2315
|
+
reasoning_parts = CASE WHEN excluded.observed_at < usage_turns.observed_at THEN excluded.reasoning_parts ELSE usage_turns.reasoning_parts END,
|
|
2316
|
+
reasoning_chars = CASE WHEN excluded.observed_at < usage_turns.observed_at THEN excluded.reasoning_chars ELSE usage_turns.reasoning_chars END,
|
|
2317
|
+
reasoning_ms = CASE WHEN excluded.observed_at < usage_turns.observed_at THEN excluded.reasoning_ms ELSE usage_turns.reasoning_ms END,
|
|
2318
|
+
text_chars = CASE WHEN excluded.observed_at < usage_turns.observed_at THEN excluded.text_chars ELSE usage_turns.text_chars END,
|
|
2319
|
+
tool_calls = CASE WHEN excluded.observed_at < usage_turns.observed_at THEN excluded.tool_calls ELSE usage_turns.tool_calls END,
|
|
2320
|
+
compactions = CASE WHEN excluded.observed_at < usage_turns.observed_at THEN excluded.compactions ELSE usage_turns.compactions END,
|
|
2132
2321
|
observed_at = MIN(usage_turns.observed_at, excluded.observed_at),
|
|
2133
2322
|
day = MIN(usage_turns.day, excluded.day),
|
|
2134
2323
|
task_slug = CASE WHEN excluded.observed_at < usage_turns.observed_at THEN excluded.task_slug ELSE usage_turns.task_slug END,
|
|
@@ -2173,34 +2362,97 @@ const projectSessionLeases = (db, teamRoot) => {
|
|
|
2173
2362
|
const slug = typeof value.slug === 'string' ? value.slug : '';
|
|
2174
2363
|
const at = isoTimestamp(value.updatedAt);
|
|
2175
2364
|
if (sessionID === '' || slug === '' || at === null) continue;
|
|
2176
|
-
|
|
2365
|
+
// A v5 lease carries one instant; the window then starts where it ends.
|
|
2366
|
+
const first = isoTimestamp(value.firstSeenAt) ?? at;
|
|
2367
|
+
statement.run(sessionID, slug, first < at ? first : at, at);
|
|
2177
2368
|
projected += 1;
|
|
2178
2369
|
}
|
|
2179
2370
|
return projected;
|
|
2180
2371
|
};
|
|
2181
2372
|
|
|
2373
|
+
/**
|
|
2374
|
+
* The attribution context: the lease windows of every session, the same
|
|
2375
|
+
* windows indexed by task, and the mtime of every task directory.
|
|
2376
|
+
*
|
|
2377
|
+
* A window is `[first, min(last + TTL, next lease first of that session))`, so
|
|
2378
|
+
* two leases of one session never claim the same instant and the later lease
|
|
2379
|
+
* owns the overlap.
|
|
2380
|
+
*/
|
|
2182
2381
|
const leaseWindows = (db) => {
|
|
2183
|
-
const
|
|
2382
|
+
const bySession = new Map();
|
|
2383
|
+
const byTask = new Map();
|
|
2184
2384
|
for (const row of db.prepare('SELECT session_id, task_slug, first_seen_at, last_seen_at FROM session_tasks').all()) {
|
|
2185
2385
|
const first = Date.parse(row.first_seen_at);
|
|
2186
2386
|
const last = Date.parse(row.last_seen_at);
|
|
2187
2387
|
if (!Number.isFinite(first) || !Number.isFinite(last)) continue;
|
|
2188
|
-
const
|
|
2189
|
-
|
|
2190
|
-
|
|
2388
|
+
const window = { slug: row.task_slug, first, last, end: last + LEASE_TTL_MS };
|
|
2389
|
+
const sessions = bySession.get(row.session_id) ?? [];
|
|
2390
|
+
sessions.push(window);
|
|
2391
|
+
bySession.set(row.session_id, sessions);
|
|
2392
|
+
const tasks = byTask.get(row.task_slug) ?? [];
|
|
2393
|
+
tasks.push(window);
|
|
2394
|
+
byTask.set(row.task_slug, tasks);
|
|
2395
|
+
}
|
|
2396
|
+
for (const sessions of bySession.values()) {
|
|
2397
|
+
sessions.sort((left, right) => left.first - right.first || (left.slug < right.slug ? -1 : left.slug > right.slug ? 1 : 0));
|
|
2398
|
+
for (let index = 0; index < sessions.length - 1; index += 1) {
|
|
2399
|
+
sessions[index].end = Math.min(sessions[index].end, sessions[index + 1].first);
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
return { bySession, byTask };
|
|
2403
|
+
};
|
|
2404
|
+
|
|
2405
|
+
const taskDirectoryWindows = (teamRoot) => {
|
|
2406
|
+
const directory = path.join(teamRoot, 'tasks');
|
|
2407
|
+
let names;
|
|
2408
|
+
try {
|
|
2409
|
+
names = fs.readdirSync(directory).sort();
|
|
2410
|
+
} catch {
|
|
2411
|
+
return [];
|
|
2191
2412
|
}
|
|
2192
|
-
|
|
2413
|
+
const windows = [];
|
|
2414
|
+
for (const name of names) {
|
|
2415
|
+
try {
|
|
2416
|
+
const stats = fs.statSync(path.join(directory, name));
|
|
2417
|
+
if (stats.isDirectory()) windows.push({ slug: name, mtime: stats.mtimeMs });
|
|
2418
|
+
} catch {
|
|
2419
|
+
/* a directory that vanished between the read and the stat is no window */
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
return windows;
|
|
2193
2423
|
};
|
|
2194
2424
|
|
|
2195
|
-
|
|
2196
|
-
|
|
2425
|
+
/**
|
|
2426
|
+
* The ordered ladder `lease | window | dir-mtime | unmapped`. A `lease` hit is
|
|
2427
|
+
* final: a weaker rung never outranks it.
|
|
2428
|
+
*/
|
|
2429
|
+
const resolveAttribution = (context, sessionID, observedAt) => {
|
|
2197
2430
|
const at = Date.parse(observedAt);
|
|
2198
|
-
if (!
|
|
2199
|
-
let
|
|
2200
|
-
for (const window of
|
|
2201
|
-
if (window.first <= at && at
|
|
2431
|
+
if (!Number.isFinite(at)) return { taskSlug: null, attribution: 'unmapped' };
|
|
2432
|
+
let lease = null;
|
|
2433
|
+
for (const window of context.bySession.get(sessionID) ?? []) {
|
|
2434
|
+
if (window.first <= at && at < window.end && (lease === null || window.first >= lease.first)) lease = window;
|
|
2435
|
+
}
|
|
2436
|
+
if (lease !== null) return { taskSlug: lease.slug, attribution: 'lease' };
|
|
2437
|
+
let taskLevel = null;
|
|
2438
|
+
for (const [slug, windows] of context.byTask) {
|
|
2439
|
+
for (const window of windows) {
|
|
2440
|
+
if (window.first <= at && at < window.end && (taskLevel === null || window.first > taskLevel.first)) {
|
|
2441
|
+
taskLevel = { slug, first: window.first };
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
if (taskLevel !== null) return { taskSlug: taskLevel.slug, attribution: 'window' };
|
|
2446
|
+
let nearest = null;
|
|
2447
|
+
for (const entry of context.dirs) {
|
|
2448
|
+
const distance = Math.abs(at - entry.mtime);
|
|
2449
|
+
if (distance > DIR_WINDOW_MS) continue;
|
|
2450
|
+
if (nearest === null || distance < nearest.distance || (distance === nearest.distance && entry.slug < nearest.slug)) {
|
|
2451
|
+
nearest = { slug: entry.slug, distance };
|
|
2452
|
+
}
|
|
2202
2453
|
}
|
|
2203
|
-
|
|
2454
|
+
if (nearest !== null) return { taskSlug: nearest.slug, attribution: 'dir-mtime' };
|
|
2455
|
+
return { taskSlug: null, attribution: 'unmapped' };
|
|
2204
2456
|
};
|
|
2205
2457
|
|
|
2206
2458
|
const sourcePathFor = (teamRoot, file) => {
|
|
@@ -2224,7 +2476,7 @@ const listLedgerFiles = (directory, stem) => {
|
|
|
2224
2476
|
});
|
|
2225
2477
|
};
|
|
2226
2478
|
|
|
2227
|
-
const ingestLedgerFile = ({ db, file, kind, keyOf, ingestedAt, deadlineAt,
|
|
2479
|
+
const ingestLedgerFile = ({ db, file, kind, keyOf, ingestedAt, deadlineAt, context, teamRoot }) => {
|
|
2228
2480
|
let stats;
|
|
2229
2481
|
try {
|
|
2230
2482
|
stats = fs.statSync(file);
|
|
@@ -2252,6 +2504,7 @@ const ingestLedgerFile = ({ db, file, kind, keyOf, ingestedAt, deadlineAt, windo
|
|
|
2252
2504
|
|
|
2253
2505
|
const statement = db.prepare(kind === 'results' ? UPSERT_TOOL_CALL_SQL : UPSERT_USAGE_TURN_SQL);
|
|
2254
2506
|
let invalid = 0;
|
|
2507
|
+
let refused = 0;
|
|
2255
2508
|
let rows = 0;
|
|
2256
2509
|
let lastKey = previous?.last_key ?? '';
|
|
2257
2510
|
db.exec('BEGIN IMMEDIATE');
|
|
@@ -2273,13 +2526,13 @@ const ingestLedgerFile = ({ db, file, kind, keyOf, ingestedAt, deadlineAt, windo
|
|
|
2273
2526
|
lastKey = '';
|
|
2274
2527
|
continue;
|
|
2275
2528
|
}
|
|
2276
|
-
const row = kind === 'results' ? normalizeToolCall(raw) : normalizeUsageTurn(raw);
|
|
2529
|
+
const row = kind === 'results' ? normalizeToolCall(raw, () => { refused += 1; }) : normalizeUsageTurn(raw);
|
|
2277
2530
|
if (row === null) {
|
|
2278
2531
|
invalid += 1;
|
|
2279
2532
|
lastKey = '';
|
|
2280
2533
|
continue;
|
|
2281
2534
|
}
|
|
2282
|
-
const { taskSlug, attribution } = resolveAttribution(
|
|
2535
|
+
const { taskSlug, attribution } = resolveAttribution(context, row.sessionID, row.observedAt);
|
|
2283
2536
|
if (kind === 'results') {
|
|
2284
2537
|
statement.run(
|
|
2285
2538
|
row.key,
|
|
@@ -2295,6 +2548,16 @@ const ingestLedgerFile = ({ db, file, kind, keyOf, ingestedAt, deadlineAt, windo
|
|
|
2295
2548
|
row.day,
|
|
2296
2549
|
taskSlug,
|
|
2297
2550
|
attribution,
|
|
2551
|
+
row.intent,
|
|
2552
|
+
row.agent,
|
|
2553
|
+
row.parentSessionId,
|
|
2554
|
+
row.durationMs,
|
|
2555
|
+
row.gapMs,
|
|
2556
|
+
row.targetKey,
|
|
2557
|
+
row.repeatOf,
|
|
2558
|
+
row.repeatIndex,
|
|
2559
|
+
row.exitCode,
|
|
2560
|
+
row.errorClass,
|
|
2298
2561
|
);
|
|
2299
2562
|
} else {
|
|
2300
2563
|
statement.run(
|
|
@@ -2317,6 +2580,12 @@ const ingestLedgerFile = ({ db, file, kind, keyOf, ingestedAt, deadlineAt, windo
|
|
|
2317
2580
|
row.day,
|
|
2318
2581
|
taskSlug,
|
|
2319
2582
|
attribution,
|
|
2583
|
+
row.reasoningParts,
|
|
2584
|
+
row.reasoningChars,
|
|
2585
|
+
row.reasoningMs,
|
|
2586
|
+
row.textChars,
|
|
2587
|
+
row.toolCalls,
|
|
2588
|
+
row.compactions,
|
|
2320
2589
|
);
|
|
2321
2590
|
}
|
|
2322
2591
|
rows += 1;
|
|
@@ -2332,7 +2601,7 @@ const ingestLedgerFile = ({ db, file, kind, keyOf, ingestedAt, deadlineAt, windo
|
|
|
2332
2601
|
}
|
|
2333
2602
|
throw error;
|
|
2334
2603
|
}
|
|
2335
|
-
return { rows, invalid, ingested: true };
|
|
2604
|
+
return { rows, invalid, refused, ingested: true };
|
|
2336
2605
|
};
|
|
2337
2606
|
|
|
2338
2607
|
/**
|
|
@@ -2343,10 +2612,11 @@ const ingestLedgerFile = ({ db, file, kind, keyOf, ingestedAt, deadlineAt, windo
|
|
|
2343
2612
|
export function projectTelemetry({ db, teamRoot, now, deadlineAt = Number.POSITIVE_INFINITY, env = process.env }) {
|
|
2344
2613
|
const ingestedAt = isoTimestamp(now) ?? new Date().toISOString();
|
|
2345
2614
|
projectSessionLeases(db, teamRoot);
|
|
2346
|
-
const
|
|
2615
|
+
const context = { ...leaseWindows(db), dirs: taskDirectoryWindows(teamRoot) };
|
|
2347
2616
|
const directory = telemetryDirectory(teamRoot, env);
|
|
2348
2617
|
let rows = 0;
|
|
2349
2618
|
let invalid = 0;
|
|
2619
|
+
let refused = 0;
|
|
2350
2620
|
let sources = 0;
|
|
2351
2621
|
let expired = false;
|
|
2352
2622
|
for (const [stem, kind, keyOf] of [
|
|
@@ -2358,14 +2628,20 @@ export function projectTelemetry({ db, teamRoot, now, deadlineAt = Number.POSITI
|
|
|
2358
2628
|
expired = true;
|
|
2359
2629
|
break;
|
|
2360
2630
|
}
|
|
2361
|
-
const outcome = ingestLedgerFile({ db, file, kind, keyOf, ingestedAt, deadlineAt,
|
|
2631
|
+
const outcome = ingestLedgerFile({ db, file, kind, keyOf, ingestedAt, deadlineAt, context, teamRoot });
|
|
2362
2632
|
rows += outcome.rows;
|
|
2363
2633
|
invalid += outcome.invalid;
|
|
2634
|
+
refused += outcome.refused ?? 0;
|
|
2364
2635
|
if (outcome.ingested) sources += 1;
|
|
2365
2636
|
}
|
|
2366
2637
|
if (expired) break;
|
|
2367
2638
|
}
|
|
2368
|
-
|
|
2639
|
+
// One line per run, never one per row: a refused value is dropped, and the
|
|
2640
|
+
// error log names the count without carrying the value.
|
|
2641
|
+
if (refused > 0) {
|
|
2642
|
+
logProjectionFailure('E_CAPTURE_REFUSED', `${refused} captured value(s) dropped as text, absolute or out of range`, env);
|
|
2643
|
+
}
|
|
2644
|
+
return { rows, invalid, refused, sources, expired };
|
|
2369
2645
|
}
|
|
2370
2646
|
|
|
2371
2647
|
const logProjectionFailure = (code, message, env = process.env) => {
|