@bonesofspring/ai-rules 0.2.72 → 0.2.73
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 +20 -0
- package/README.md +7 -6
- package/bin/lib/ai-local-drift.js +4 -4
- package/bin/lib/engine-scripts.js +2 -0
- package/bin/lib/seed-ai-local-team.js +9 -5
- package/docs/TEAM-DB.md +19 -4
- package/package.json +1 -1
- package/presets/_shared/ai-local/scripts/manifest.mjs +19 -1
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +73 -11
- 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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/rules/agent-team-intake.mdc +2 -2
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/mavis/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/mavis/android-kotlin/agents/debugger.md +1 -1
- package/presets/mavis/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/mavis/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/mavis/android-kotlin/rules/agent-team-intake.md +2 -2
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/agents/build-verifier.md +1 -1
- package/presets/mavis/go/agents/code-reviewer.md +1 -1
- package/presets/mavis/go/agents/debugger.md +1 -1
- package/presets/mavis/go/agents/feature-developer.md +1 -1
- package/presets/mavis/go/agents/task-analyst.md +1 -1
- package/presets/mavis/go/rules/agent-team-intake.md +2 -2
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/agents/build-verifier.md +1 -1
- package/presets/mavis/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/mavis/ios-swift/agents/debugger.md +1 -1
- package/presets/mavis/ios-swift/agents/feature-developer.md +1 -1
- package/presets/mavis/ios-swift/agents/task-analyst.md +1 -1
- package/presets/mavis/ios-swift/rules/agent-team-intake.md +2 -2
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/agents/build-verifier.md +1 -1
- package/presets/mavis/java/agents/code-reviewer.md +1 -1
- package/presets/mavis/java/agents/debugger.md +1 -1
- package/presets/mavis/java/agents/feature-developer.md +1 -1
- package/presets/mavis/java/agents/task-analyst.md +1 -1
- package/presets/mavis/java/rules/agent-team-intake.md +2 -2
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/mavis/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/mavis/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/mavis/mcp-ts/rules/agent-team-intake.md +2 -2
- package/presets/mavis/mol/adapter-map.json +1 -1
- package/presets/mavis/mol/agents/build-verifier.md +1 -1
- package/presets/mavis/mol/agents/code-reviewer.md +1 -1
- package/presets/mavis/mol/agents/debugger.md +1 -1
- package/presets/mavis/mol/agents/feature-developer.md +1 -1
- package/presets/mavis/mol/agents/task-analyst.md +1 -1
- package/presets/mavis/mol/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 +1 -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/rules/agent-team-intake.md +2 -2
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/agents/build-verifier.md +1 -1
- package/presets/mavis/nuxt/agents/code-reviewer.md +1 -1
- package/presets/mavis/nuxt/agents/debugger.md +1 -1
- package/presets/mavis/nuxt/agents/feature-developer.md +1 -1
- package/presets/mavis/nuxt/agents/task-analyst.md +1 -1
- package/presets/mavis/nuxt/rules/agent-team-intake.md +2 -2
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/mavis/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/mavis/php-hexagonal/agents/debugger.md +1 -1
- package/presets/mavis/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/mavis/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/mavis/php-hexagonal/rules/agent-team-intake.md +2 -2
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/agents/build-verifier.md +1 -1
- package/presets/mavis/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/mavis/php-laravel/agents/debugger.md +1 -1
- package/presets/mavis/php-laravel/agents/feature-developer.md +1 -1
- package/presets/mavis/php-laravel/agents/task-analyst.md +1 -1
- package/presets/mavis/php-laravel/rules/agent-team-intake.md +2 -2
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/agents/build-verifier.md +1 -1
- package/presets/mavis/svelte/agents/code-reviewer.md +1 -1
- package/presets/mavis/svelte/agents/debugger.md +1 -1
- package/presets/mavis/svelte/agents/feature-developer.md +1 -1
- package/presets/mavis/svelte/agents/task-analyst.md +1 -1
- package/presets/mavis/svelte/rules/agent-team-intake.md +2 -2
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/opencode/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/opencode/android-kotlin/agents/debugger.md +1 -1
- package/presets/opencode/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/opencode/android-kotlin/rules/agent-team-intake.md +2 -2
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/agents/build-verifier.md +1 -1
- package/presets/opencode/go/agents/code-reviewer.md +1 -1
- package/presets/opencode/go/agents/debugger.md +1 -1
- package/presets/opencode/go/agents/feature-developer.md +1 -1
- package/presets/opencode/go/agents/task-analyst.md +1 -1
- package/presets/opencode/go/rules/agent-team-intake.md +2 -2
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/agents/build-verifier.md +1 -1
- package/presets/opencode/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/opencode/ios-swift/agents/debugger.md +1 -1
- package/presets/opencode/ios-swift/agents/feature-developer.md +1 -1
- package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/opencode/ios-swift/rules/agent-team-intake.md +2 -2
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/agents/build-verifier.md +1 -1
- package/presets/opencode/java/agents/code-reviewer.md +1 -1
- package/presets/opencode/java/agents/debugger.md +1 -1
- package/presets/opencode/java/agents/feature-developer.md +1 -1
- package/presets/opencode/java/agents/task-analyst.md +1 -1
- package/presets/opencode/java/rules/agent-team-intake.md +2 -2
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- package/presets/opencode/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/opencode/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/opencode/mcp-ts/rules/agent-team-intake.md +2 -2
- package/presets/opencode/mol/adapter-map.json +1 -1
- package/presets/opencode/mol/agents/build-verifier.md +1 -1
- package/presets/opencode/mol/agents/code-reviewer.md +1 -1
- package/presets/opencode/mol/agents/debugger.md +1 -1
- package/presets/opencode/mol/agents/feature-developer.md +1 -1
- package/presets/opencode/mol/agents/task-analyst.md +1 -1
- package/presets/opencode/mol/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 +1 -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/rules/agent-team-intake.md +2 -2
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/agents/build-verifier.md +1 -1
- package/presets/opencode/nuxt/agents/code-reviewer.md +1 -1
- package/presets/opencode/nuxt/agents/debugger.md +1 -1
- package/presets/opencode/nuxt/agents/feature-developer.md +1 -1
- package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
- package/presets/opencode/nuxt/rules/agent-team-intake.md +2 -2
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/opencode/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/debugger.md +1 -1
- package/presets/opencode/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/opencode/php-hexagonal/rules/agent-team-intake.md +2 -2
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/agents/build-verifier.md +1 -1
- package/presets/opencode/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/opencode/php-laravel/agents/debugger.md +1 -1
- package/presets/opencode/php-laravel/agents/feature-developer.md +1 -1
- package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/opencode/php-laravel/rules/agent-team-intake.md +2 -2
- package/presets/opencode/plugins/output-guard/README.md +14 -8
- package/presets/opencode/plugins/output-guard/rewrite.ts +15 -9
- package/presets/opencode/svelte/adapter-map.json +1 -1
- package/presets/opencode/svelte/agents/build-verifier.md +1 -1
- package/presets/opencode/svelte/agents/code-reviewer.md +1 -1
- package/presets/opencode/svelte/agents/debugger.md +1 -1
- package/presets/opencode/svelte/agents/feature-developer.md +1 -1
- package/presets/opencode/svelte/agents/task-analyst.md +1 -1
- package/presets/opencode/svelte/rules/agent-team-intake.md +2 -2
- package/presets/zcode/android-kotlin/adapter-map.json +1 -1
- package/presets/zcode/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/zcode/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/zcode/android-kotlin/agents/debugger.md +1 -1
- package/presets/zcode/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/zcode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/zcode/android-kotlin/rules/agent-team-intake.md +2 -2
- package/presets/zcode/go/adapter-map.json +1 -1
- package/presets/zcode/go/agents/build-verifier.md +1 -1
- package/presets/zcode/go/agents/code-reviewer.md +1 -1
- package/presets/zcode/go/agents/debugger.md +1 -1
- package/presets/zcode/go/agents/feature-developer.md +1 -1
- package/presets/zcode/go/agents/task-analyst.md +1 -1
- package/presets/zcode/go/rules/agent-team-intake.md +2 -2
- package/presets/zcode/ios-swift/adapter-map.json +1 -1
- package/presets/zcode/ios-swift/agents/build-verifier.md +1 -1
- package/presets/zcode/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/zcode/ios-swift/agents/debugger.md +1 -1
- package/presets/zcode/ios-swift/agents/feature-developer.md +1 -1
- package/presets/zcode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/zcode/ios-swift/rules/agent-team-intake.md +2 -2
- package/presets/zcode/java/adapter-map.json +1 -1
- package/presets/zcode/java/agents/build-verifier.md +1 -1
- package/presets/zcode/java/agents/code-reviewer.md +1 -1
- package/presets/zcode/java/agents/debugger.md +1 -1
- package/presets/zcode/java/agents/feature-developer.md +1 -1
- package/presets/zcode/java/agents/task-analyst.md +1 -1
- package/presets/zcode/java/rules/agent-team-intake.md +2 -2
- package/presets/zcode/mcp-ts/adapter-map.json +1 -1
- package/presets/zcode/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/zcode/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/zcode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/zcode/mcp-ts/rules/agent-team-intake.md +2 -2
- package/presets/zcode/mol/adapter-map.json +1 -1
- package/presets/zcode/mol/agents/build-verifier.md +1 -1
- package/presets/zcode/mol/agents/code-reviewer.md +1 -1
- package/presets/zcode/mol/agents/debugger.md +1 -1
- package/presets/zcode/mol/agents/feature-developer.md +1 -1
- package/presets/zcode/mol/agents/task-analyst.md +1 -1
- package/presets/zcode/mol/rules/agent-team-intake.md +2 -2
- package/presets/zcode/next/REPO_AGENTS.md +16 -0
- package/presets/zcode/next/adapter-map.json +1 -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/rules/agent-team-intake.md +2 -2
- package/presets/zcode/nuxt/adapter-map.json +1 -1
- package/presets/zcode/nuxt/agents/build-verifier.md +1 -1
- package/presets/zcode/nuxt/agents/code-reviewer.md +1 -1
- package/presets/zcode/nuxt/agents/debugger.md +1 -1
- package/presets/zcode/nuxt/agents/feature-developer.md +1 -1
- package/presets/zcode/nuxt/agents/task-analyst.md +1 -1
- package/presets/zcode/nuxt/rules/agent-team-intake.md +2 -2
- package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
- package/presets/zcode/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/zcode/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/zcode/php-hexagonal/agents/debugger.md +1 -1
- package/presets/zcode/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/zcode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/zcode/php-hexagonal/rules/agent-team-intake.md +2 -2
- package/presets/zcode/php-laravel/adapter-map.json +1 -1
- package/presets/zcode/php-laravel/agents/build-verifier.md +1 -1
- package/presets/zcode/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/zcode/php-laravel/agents/debugger.md +1 -1
- package/presets/zcode/php-laravel/agents/feature-developer.md +1 -1
- package/presets/zcode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/zcode/php-laravel/rules/agent-team-intake.md +2 -2
- package/presets/zcode/svelte/adapter-map.json +1 -1
- package/presets/zcode/svelte/agents/build-verifier.md +1 -1
- package/presets/zcode/svelte/agents/code-reviewer.md +1 -1
- package/presets/zcode/svelte/agents/debugger.md +1 -1
- package/presets/zcode/svelte/agents/feature-developer.md +1 -1
- package/presets/zcode/svelte/agents/task-analyst.md +1 -1
- package/presets/zcode/svelte/rules/agent-team-intake.md +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.73
|
|
4
|
+
|
|
5
|
+
### `team` — planned tracker drain
|
|
6
|
+
|
|
7
|
+
- **Job.** `presets/cursor/next/team/upstream/jobs.json` adds `tracker-planned-drain` beside `upstream-research`: `interval`, `everySeconds` 300, `Europe/Moscow`, `concurrency: skip`, `misfire: run-once`, `timeoutMs` 14400000, argv `node ../scripts/tracker-planned-drain.mjs --team-root .`. In this repository `init`/`update` still copy that file only when `scheduler/jobs.json` is absent. The template sits under `team/upstream/`, which the published tarball excludes, so a consumer install gets no `scheduler/jobs.json`.
|
|
8
|
+
- **Published child.** `tracker-planned-drain.mjs` joins `ENGINE_SCRIPTS` (it is not in `REPO_ONLY_ENGINE_SCRIPTS`) and is mirrored into `.ai.local/scripts/`. A packed consumer seeds the module; `upstream-research.mjs` stays repository-only.
|
|
9
|
+
- **One tick.** The child uses the existing launch queue. A full tracker slot exits idle and enqueues nothing. Otherwise it enqueues the head ready stored-`planned` item that has no open queue entry and no `tracker-<id>` or `<id>` task row, claims one entry, bootstraps the task folder the way the chain-hook stop seam does (`prompt.md` plus `pipeline.json` with empty `steps`; an existing pipeline is left as-is), and runs exactly one `task-run start`. It then polls until the linked team task and the tracker item are both terminal, so `concurrency: skip` holds the next tick. The child never writes `status.json` or `metrics.json`.
|
|
10
|
+
- **Stored status.** `completed` stores the item `completed`. `changes_requested` and `validation_failed` store `cancelled` with `cancelReason` `task <state>`. `blocked` stays stored-`planned`, and the next tick does not enqueue. `backlog`, a terminal stored status, and an item that already has a task row are not selected. An empty tracker is idle (`no planned head`).
|
|
11
|
+
- **Kill switch.** `AI_RULES_TEAM_DB_DISABLE=1` returns idle `disabled` and writes nothing.
|
|
12
|
+
- **Tests.** `test-team-db-tracker-queue.mjs` covers the tick. `test-cli-init-clean.mjs` asserts a fresh repository `next` install seeds both jobs and `jobs get` accepts the drain. `test-pack-repo-only.mjs` asserts the consumer seed includes `tracker-planned-drain.mjs` and still omits the job file and `upstream-research.mjs`.
|
|
13
|
+
|
|
14
|
+
### `preset` — research gate, rebuild lock, lean subagent blocks
|
|
15
|
+
|
|
16
|
+
- **Research gate (R1–R3).** The root entry every platform installs gains one section after § Presence-based load. A request that only asks to analyze, investigate, measure, or estimate (no make / fix / add verb) **MUST** go to `codebase-analyzer` or a `spike` pipeline; the boundary is the read count — one read stays a pure question with no file. A session approaching ~50 turns **MUST** checkpoint (`focus.md` + `artifact-manifest.json` + `.memlog.md`) and hand off to a fresh session; a research fact **MUST** reach `analysis.md` with its `path:line` before the same file is read a second time. The Cursor map carries the matching MUST line under § When to use `/task`, and `agent-team-intake` points at the same boundary instead of contradicting it. No new always-on rule file, so the always-on count stays 3–10.
|
|
17
|
+
- **Output guard (R4).** The 8–20 KB band's whole-line gap hint is `grep -n '<term>' <file>`, with the term taken from the **elided** slice. When that slice holds no usable token the hint is omitted and only the `elided lines A..B` marker remains — a fabricated `grep -n 'error'` matches nothing. No `sed -n` range survives in `rewrite.ts` or its README, and one output carries one command instead of the `search:` line duplicating `read more:`.
|
|
18
|
+
- **Rebuild lock (R5).** `team-db.mjs init|sync|migrate-tasks --rebuild` takes `.ai.local/team/.rebuild.lock`, outer to the tracker lock and to SQLite's `busy_timeout`, and releases it on every error path. A second rebuild fails fast with `E_REBUILD_BUSY` (exit 4) instead of moving `team.db` aside again. Documented in `docs/TEAM-DB.md`.
|
|
19
|
+
- **Subagent read set (R6).** `getRequiredRulesForAgent` splits by Next role, not only the implementer: every Next agent's «Rules to load» required list is 5–7 paths (was 8–15) and the rest is conditional; `check-claude-agent-blocks.mjs` asserts the band. `zoneRulesByRole` keeps the full list, so the anti-hallucination floor gate still sees it.
|
|
20
|
+
- **Installed behaviour.** Generated platform trees, the dogfood `.cursor` / `.claude` / `.mavis` / `.opencode` / `.zcode` trees plus root `AGENTS.md`, `.ai.local/scripts/**`, and the CLI goldens are regenerated. `test-output-guard.mjs` asserts the grep hint and both team-db suites cover the rebuild lock, including a release-on-failure case and `init` / `sync --rebuild` contention.
|
|
21
|
+
- **Aside-file ignore lines.** The seeded `.ai.local/.gitignore` gains `team.db.corrupt-*` and `team.db.mismatch-*`: a `sync --rebuild` moves `team.db` with both companions aside under those names, so an untouched pattern let a ~140 MB database copy reach the index. `update` appends both lines to an existing ignore file, `test-cli-init-clean.mjs` asserts them, and `docs/TEAM-DB.md` lists them.
|
|
22
|
+
|
|
3
23
|
## 0.2.72
|
|
4
24
|
|
|
5
25
|
### `team` — usage ledger, verification evidence, incident registry
|
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ Run `init` from the **app root** (`--cwd` if needed). Default `--preset` is `nex
|
|
|
25
25
|
| Root agents | `REPO_AGENTS.md` → `AGENTS.md` (same file on all five; ZCode loads it natively) | | | | |
|
|
26
26
|
| `/task` artifacts | **`.ai.local/team/`** (shared; templates refreshed; `tasks/<slug>/` never overwritten) | | | |
|
|
27
27
|
| Template drift | **`.ai.local/.template-base.json`** (shared; one record per tree of files that hold a shipped template byte; `update` prints one drift line, `update --merge-ai-local` fast-forwards a file only when its recorded base still matches and reports the rest) | | | |
|
|
28
|
-
| Self-learning engine | **`.ai.local/scripts/`** (shared; twenty-
|
|
28
|
+
| Self-learning engine | **`.ai.local/scripts/`** (shared; twenty-four published scripts — the six self-learning engine modules, `manifest.mjs`, `dump-output.mjs`, the eight `team-db*.mjs` modules, `check-write-scope.mjs`, `aggregate-agent-task-metrics.mjs`, `record-usage.mjs`, `verification.mjs`, `incidents.mjs`, `processes.mjs`, `process-lease.mjs`, and `tracker-planned-drain.mjs`; existing files never overwritten. The repository-only `upstream-research.mjs` is not published) | | | |
|
|
29
29
|
| Specs seed | `docs/specs/` copied only if the directory is **absent** | | | |
|
|
30
30
|
|
|
31
31
|
OpenCode also ships **`.opencode/plugins/task-status/`**, a TUI sidebar for the active `/task` run (slug, state, elapsed time, step, remaining-time estimate, soft-stop). OpenCode auto-loads it; it needs no `opencode.json` entry, is refreshed by `update`, and is a viewer only — the chain hook stays manual.
|
|
@@ -61,8 +61,8 @@ node .ai.local/scripts/run.mjs --dry-run # read-only preview: decision, target,
|
|
|
61
61
|
`init` seeds the engine with **skip-if-exists** — a modified `run.mjs` stays yours and is reported as kept; there is no
|
|
62
62
|
`--force`. The seeded tree is byte-identical to `presets/_shared/ai-local/scripts/`, and `.ai.local/.gitignore` (created
|
|
63
63
|
when absent, missing required lines appended to an existing file) ignores `*.lock`, `*.tmp`, `.rollback/`, `STOP`,
|
|
64
|
-
`ESTOP`, `team.db`, `team.db-wal`, `team.db-shm`, `team-db-errors.log`, `team
|
|
65
|
-
`team/scheduler/state.json`; the root `.gitignore` is never edited.
|
|
64
|
+
`ESTOP`, `team.db`, `team.db-wal`, `team.db-shm`, `team-db-errors.log`, `team.db.corrupt-*`,
|
|
65
|
+
`team.db.mismatch-*`, `team/scheduler/runs/`, and `team/scheduler/state.json`; the root `.gitignore` is never edited.
|
|
66
66
|
|
|
67
67
|
Upgrade a seeded module with `update --fix`: it writes a module only when its current bytes still match the shipped digest
|
|
68
68
|
recorded in `.ai.local/.template-base.json`. A module you edited is reported `kept modified` and stays byte-identical; a
|
|
@@ -175,10 +175,11 @@ pre-v2 database is rebuilt from the files on the next `sync`.
|
|
|
175
175
|
the published npm package; they are used only in the `@bonesofspring/ai-rules` repository
|
|
176
176
|
itself. A consumer install seeds no job and no runner.
|
|
177
177
|
|
|
178
|
-
In this repository the `next` preset carries a weekly `upstream-research` job
|
|
179
|
-
`
|
|
178
|
+
In this repository the `next` preset carries a weekly `upstream-research` job, the
|
|
179
|
+
`tracker-planned-drain` interval job (300 seconds, `concurrency: skip`), and a read-only
|
|
180
|
+
`opencode` agent for the weekly review. `init`/`update` seed that jobs file into
|
|
180
181
|
`.ai.local/team/scheduler/jobs.json` when the file is absent; an operator-edited definition is
|
|
181
|
-
never overwritten. The runner probes `opencode`, loads `upstream/projects.json` and
|
|
182
|
+
never overwritten. The weekly runner probes `opencode`, loads `upstream/projects.json` and
|
|
182
183
|
`upstream/config.json`, fetches each due clone with `git fetch --depth 1`, labels the window
|
|
183
184
|
(`range`, `baseline`, `unprovable`, `no-change`), validates the agent's marked JSON, re-checks
|
|
184
185
|
every citation inside the clone, dedupes by mechanism against the committed
|
|
@@ -94,10 +94,10 @@ function digestFile(filePath) {
|
|
|
94
94
|
* move would silently overwrite it.
|
|
95
95
|
*
|
|
96
96
|
* `source` stays part of the decision rather than becoming a label: per-tool
|
|
97
|
-
* template trees differ (`presets/claude/next/ai-local/
|
|
98
|
-
* fewer sections than `cursor/next`), so a foreign pass must not rewrite a
|
|
99
|
-
* another tool seeded. Every pass classifies, so the writing tool's own pass
|
|
100
|
-
* the one that decides — a foreign source no longer disables the feature.
|
|
97
|
+
* template trees may differ (`presets/claude/next/ai-local/rules/task-levels.md`
|
|
98
|
+
* ships fewer sections than `cursor/next`), so a foreign pass must not rewrite a
|
|
99
|
+
* rel another tool seeded. Every pass classifies, so the writing tool's own pass
|
|
100
|
+
* is the one that decides — a foreign source no longer disables the feature.
|
|
101
101
|
*
|
|
102
102
|
* @param {{ consumer?: Digest | null, base?: BaseEntry | null, template?: Digest | null, source: string }} input
|
|
103
103
|
* @returns {'noop' | 'adopt' | 'fast-forward' | 'drift'}
|
|
@@ -49,6 +49,8 @@ const ENGINE_SCRIPTS = [
|
|
|
49
49
|
'team-db-api.mjs',
|
|
50
50
|
'team-db-openapi.mjs',
|
|
51
51
|
'team-db-scheduler.mjs',
|
|
52
|
+
// Five-minute tracker drain: one stored-planned item, one /task, skip while it runs.
|
|
53
|
+
'tracker-planned-drain.mjs',
|
|
52
54
|
// The weekly upstream evolution review: opencode probe, registry/cursor,
|
|
53
55
|
// change window, read-only agent call, dedupe, digest and promotion record.
|
|
54
56
|
'upstream-research.mjs',
|
|
@@ -32,6 +32,10 @@ const AI_LOCAL_GITIGNORE = [
|
|
|
32
32
|
'team.db-wal',
|
|
33
33
|
'team.db-shm',
|
|
34
34
|
'team-db-errors.log',
|
|
35
|
+
'# A corrupt or fingerprint-stale projection moved aside by `sync --rebuild`;',
|
|
36
|
+
'# same database bytes, only the name differs, so it is ignored the same way.',
|
|
37
|
+
'team.db.corrupt-*',
|
|
38
|
+
'team.db.mismatch-*',
|
|
35
39
|
'# Per-session slug bindings for the chain hook; runtime state, never commit.',
|
|
36
40
|
'team/.session-leases/',
|
|
37
41
|
'# Scheduler runtime state; jobs.json stays tracked (jobs as code).',
|
|
@@ -369,11 +373,11 @@ function copyTemplates(presetTeamSrc, dest) {
|
|
|
369
373
|
copyFile(source, target);
|
|
370
374
|
written.push(`.ai.local/team/upstream/${name}`);
|
|
371
375
|
}
|
|
372
|
-
// The shipped
|
|
373
|
-
//
|
|
374
|
-
//
|
|
375
|
-
//
|
|
376
|
-
//
|
|
376
|
+
// The shipped jobs seed only when absent, like the research data above: the
|
|
377
|
+
// template carries `upstream-research` and `tracker-planned-drain`, and an
|
|
378
|
+
// operator-edited `scheduler/jobs.json` (tracked on purpose — jobs as code)
|
|
379
|
+
// is never overwritten. The scheduler owns the file under `scheduler/`; the
|
|
380
|
+
// template lives beside the other upstream templates.
|
|
377
381
|
{
|
|
378
382
|
const jobsSource = path.join(upstreamSrc, 'jobs.json');
|
|
379
383
|
const jobsTarget = path.join(dest, 'scheduler', 'jobs.json');
|
package/docs/TEAM-DB.md
CHANGED
|
@@ -20,8 +20,8 @@ The projection is installed by `init` as eight `team-db*.mjs` modules under `.ai
|
|
|
20
20
|
The same seeded set is `ENGINE_SCRIPTS` in `bin/lib/engine-scripts.js`: the eight `team-db*.mjs`
|
|
21
21
|
modules plus the self-learning engine, `manifest.mjs`, `dump-output.mjs`,
|
|
22
22
|
`check-write-scope.mjs`, `aggregate-agent-task-metrics.mjs`, `record-usage.mjs`,
|
|
23
|
-
`verification.mjs`, `incidents.mjs`, and the `processes.mjs` +
|
|
24
|
-
manager (twenty-
|
|
23
|
+
`verification.mjs`, `incidents.mjs`, `tracker-planned-drain.mjs`, and the `processes.mjs` +
|
|
24
|
+
`process-lease.mjs` process manager (twenty-five entries;
|
|
25
25
|
`node -e "require('./bin/lib/engine-scripts.js').ENGINE_SCRIPTS.length"` prints the shipped
|
|
26
26
|
count). One further module, `upstream-research.mjs`, is declared in
|
|
27
27
|
`REPO_ONLY_ENGINE_SCRIPTS`: it exists in this repository's preset source and dogfood mirror but
|
|
@@ -64,11 +64,18 @@ team.db
|
|
|
64
64
|
team.db-wal
|
|
65
65
|
team.db-shm
|
|
66
66
|
team-db-errors.log
|
|
67
|
+
team.db.corrupt-*
|
|
68
|
+
team.db.mismatch-*
|
|
67
69
|
team/scheduler/runs/
|
|
68
70
|
team/scheduler/state.json
|
|
69
71
|
team/output-guard/
|
|
70
72
|
```
|
|
71
73
|
|
|
74
|
+
The two `team.db.<reason>-*` patterns cover the whole file set a rebuild moves aside
|
|
75
|
+
(`team.db.corrupt-<stamp>`, `team.db.mismatch-<stamp>`, and their `-wal` / `-shm`
|
|
76
|
+
companions): same database bytes under a new name, so an untouched pattern would let a
|
|
77
|
+
~140 MB copy reach the index.
|
|
78
|
+
|
|
72
79
|
`team/scheduler/jobs.json` stays tracked: definitions are code, run output is not. `team/output-guard/` holds the OpenCode output-guard spill files; runtime state, never commit. The
|
|
73
80
|
consumer root `.gitignore` is never created or edited. Never commit the database even
|
|
74
81
|
for a demo: it contains copies of prompts and task documents.
|
|
@@ -151,6 +158,12 @@ vocabulary: `0` ok, `1` a validation refusal carrying its named code (`E_TRACKER
|
|
|
151
158
|
`E_TRACKER_TRANSITION`, `E_TRACKER_REVISION`, `E_SCHEMA`), `3` usage, `4` the tree lock was
|
|
152
159
|
contended (`E_TRACKER_BUSY`).
|
|
153
160
|
|
|
161
|
+
A `--rebuild` of `init`, `sync` or `migrate-tasks` takes the team-root rebuild lock
|
|
162
|
+
(`.ai.local/team/.rebuild.lock.d`, a transient directory) before it touches the database: a
|
|
163
|
+
second rebuild that meets it fails fast with `E_REBUILD_BUSY` (exit 4) instead of moving
|
|
164
|
+
`team.db` aside a second time. Lock order is fixed — rebuild lock outer, tracker lock inner,
|
|
165
|
+
SQLite `busy_timeout` last — and a plain `sync` takes no rebuild lock.
|
|
166
|
+
|
|
154
167
|
`search <query>` answers from the FTS5 projection: it calls `searchProjection` (`MATCH` when the
|
|
155
168
|
`search_fts` table exists, the escaped `LIKE` fallback otherwise) and never builds SQL from the
|
|
156
169
|
input. It opens the database read-only, defaults to 5 hits, clamps `--limit` to 1…20 (a larger
|
|
@@ -359,8 +372,10 @@ only in the `@bonesofspring/ai-rules` repository. The published tarball excludes
|
|
|
359
372
|
a consumer install seeds no job and no runner. The rest of this section documents the workflow
|
|
360
373
|
for repository maintainers.
|
|
361
374
|
|
|
362
|
-
The `next` preset carries
|
|
363
|
-
|
|
375
|
+
The `next` preset template carries the weekly `upstream-research` pipeline job and
|
|
376
|
+
`tracker-planned-drain` (`interval`, `everySeconds` 300, `concurrency: skip`), plus the
|
|
377
|
+
repository-only engine module `.ai.local/scripts/upstream-research.mjs`. The weekly job renders
|
|
378
|
+
`upstream/prompt.md` and runs the
|
|
364
379
|
module with `--prompt {promptFile} --team-root . --repo-root ../..`; it is a normal
|
|
365
380
|
definition in `scheduler/jobs.json`, so `jobs list|get|put|enable|disable|run`, the API job
|
|
366
381
|
routes, and every consumer UI work unchanged. `init`/`update` seed the definition into
|
package/package.json
CHANGED
|
@@ -321,7 +321,25 @@ export function projectAfterReceipt({ slug, teamRoot = DEFAULT_TEAM_ROOT, env =
|
|
|
321
321
|
return;
|
|
322
322
|
}
|
|
323
323
|
if (typeof result.status === 'number' && result.status !== 0) {
|
|
324
|
-
|
|
324
|
+
// The child's stderr names the file and the reason; a log line that says
|
|
325
|
+
// only "exited 1" leaves the cause to the next full projection run.
|
|
326
|
+
const reason = (result.stderr ?? '')
|
|
327
|
+
.split('\n')
|
|
328
|
+
.map((line) => line.trim())
|
|
329
|
+
.filter(Boolean)[0];
|
|
330
|
+
logProjectionFailure(
|
|
331
|
+
env,
|
|
332
|
+
'E_PROJECTION_FAILED',
|
|
333
|
+
`projection exited ${result.status}${reason ? `: ${reason}` : ''}`,
|
|
334
|
+
);
|
|
335
|
+
// An unmapped review ledger is a contract violation the producing agent
|
|
336
|
+
// can still fix: the projection keeps its rows, the receipt says why.
|
|
337
|
+
if (reason && reason.includes('review-ledger.md')) {
|
|
338
|
+
process.stderr.write(
|
|
339
|
+
`ledger: ${reason} — append rows under the canonical header ` +
|
|
340
|
+
`| id | at | source | summary | fair | disposition | evidence | signature |\n`,
|
|
341
|
+
);
|
|
342
|
+
}
|
|
325
343
|
}
|
|
326
344
|
} catch {
|
|
327
345
|
/* the seam never fails a receipt */
|
|
@@ -265,6 +265,40 @@ export function parsePromptMarkdown(text) {
|
|
|
265
265
|
return { content: body.trim(), meta, error: null };
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
+
/**
|
|
269
|
+
* A prompt-log entry written before the fenced `text` block keeps the user's
|
|
270
|
+
* words in a blockquote or under a `- text: |` bullet. The words are intact and
|
|
271
|
+
* the shape is legacy, so such an entry is a valid prompt, not a parse failure.
|
|
272
|
+
*/
|
|
273
|
+
const legacyPromptText = (body) => {
|
|
274
|
+
const quoted = body
|
|
275
|
+
.split('\n')
|
|
276
|
+
.filter((line) => /^\s*>/.test(line))
|
|
277
|
+
.map((line) => line.replace(/^\s*>\s?/, ''));
|
|
278
|
+
if (quoted.length > 0) {
|
|
279
|
+
const text = quoted.join('\n').trim();
|
|
280
|
+
if (text !== '') return text;
|
|
281
|
+
}
|
|
282
|
+
const block = /^-\s*text:\s*[|>][-+]?\s*$([\s\S]*)$/m.exec(body);
|
|
283
|
+
if (!block) return null;
|
|
284
|
+
const lines = block[1].split('\n');
|
|
285
|
+
const content = [];
|
|
286
|
+
let indent = null;
|
|
287
|
+
for (const line of lines) {
|
|
288
|
+
if (line.trim() === '') {
|
|
289
|
+
if (content.length > 0) content.push('');
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
const leading = line.match(/^\s*/)[0].length;
|
|
293
|
+
if (leading === 0) break;
|
|
294
|
+
if (indent === null) indent = leading;
|
|
295
|
+
if (leading < indent) break;
|
|
296
|
+
content.push(line.slice(indent));
|
|
297
|
+
}
|
|
298
|
+
const text = content.join('\n').trim();
|
|
299
|
+
return text === '' ? null : text;
|
|
300
|
+
};
|
|
301
|
+
|
|
268
302
|
export function parsePromptLogMarkdown(text) {
|
|
269
303
|
// `## <n>` is a section only outside a fenced block: a prompt may itself
|
|
270
304
|
// contain a Markdown heading.
|
|
@@ -287,11 +321,12 @@ export function parsePromptLogMarkdown(text) {
|
|
|
287
321
|
sections.forEach((section) => {
|
|
288
322
|
const body = section.lines.join('\n');
|
|
289
323
|
const fence = FENCE_RE.exec(body);
|
|
290
|
-
|
|
291
|
-
|
|
324
|
+
const content = fence ? fence[1] : legacyPromptText(body);
|
|
325
|
+
if (content === null) {
|
|
326
|
+
errors.push(`entry ${section.label} has no prompt text block`);
|
|
292
327
|
return;
|
|
293
328
|
}
|
|
294
|
-
const meta = parsePromptMeta(body.slice(0, fence.index));
|
|
329
|
+
const meta = parsePromptMeta(fence ? body.slice(0, fence.index) : body);
|
|
295
330
|
const seq = integerOrNull(meta.seq) ?? section.label;
|
|
296
331
|
if (seen.has(seq)) {
|
|
297
332
|
errors.push(`entry ${section.label} duplicates seq ${seq}`);
|
|
@@ -302,9 +337,9 @@ export function parsePromptLogMarkdown(text) {
|
|
|
302
337
|
seq,
|
|
303
338
|
source: meta.source ?? null,
|
|
304
339
|
command: meta.command ?? null,
|
|
305
|
-
capturedAt: isoTimestamp(meta.capturedAt),
|
|
340
|
+
capturedAt: isoTimestamp(meta.capturedAt ?? meta.at),
|
|
306
341
|
language: meta.language ?? null,
|
|
307
|
-
content
|
|
342
|
+
content,
|
|
308
343
|
});
|
|
309
344
|
});
|
|
310
345
|
return { entries, errors };
|
|
@@ -360,21 +395,36 @@ const LEDGER_COLUMN_ALIASES = {
|
|
|
360
395
|
id: ['id', 'seq'],
|
|
361
396
|
at: ['at', 'date'],
|
|
362
397
|
source: ['source', 'origin'],
|
|
363
|
-
summary: ['summary', 'finding'],
|
|
398
|
+
summary: ['summary', 'finding', 'path'],
|
|
364
399
|
fair: ['fair'],
|
|
365
|
-
disposition: ['disposition', 'status'],
|
|
400
|
+
disposition: ['disposition', 'status', 'resolution'],
|
|
366
401
|
evidence: ['evidence'],
|
|
367
402
|
signature: ['signature'],
|
|
368
403
|
};
|
|
369
404
|
|
|
370
|
-
|
|
405
|
+
/**
|
|
406
|
+
* A header cell may carry a qualifier (`finding (path:line)`, `Round 2`), so the
|
|
407
|
+
* matcher reads the cell's word tokens instead of the whole cell: `finding
|
|
408
|
+
* (path:line)` maps to `summary` the way a bare `finding` does.
|
|
409
|
+
*/
|
|
410
|
+
const ledgerHeaderTokens = (cell) =>
|
|
411
|
+
cell
|
|
412
|
+
.toLowerCase()
|
|
413
|
+
.split(/[^a-z]+/)
|
|
414
|
+
.filter(Boolean);
|
|
415
|
+
|
|
416
|
+
const ledgerCellMatches = (cell, aliases) => {
|
|
417
|
+
const trimmed = cell.trim();
|
|
418
|
+
if (trimmed === '#') return aliases.includes('id');
|
|
419
|
+
return ledgerHeaderTokens(trimmed).some((token) => aliases.includes(token));
|
|
420
|
+
};
|
|
371
421
|
|
|
372
422
|
const ledgerHeaderMap = (line) => {
|
|
373
423
|
if (!line.startsWith('|')) return null;
|
|
374
424
|
const cells = splitTableRow(line);
|
|
375
425
|
const map = {};
|
|
376
426
|
for (const [column, aliases] of Object.entries(LEDGER_COLUMN_ALIASES)) {
|
|
377
|
-
const index = cells.findIndex((cell) =>
|
|
427
|
+
const index = cells.findIndex((cell) => ledgerCellMatches(cell, aliases));
|
|
378
428
|
if (index !== -1) map[column] = index;
|
|
379
429
|
}
|
|
380
430
|
if (map.summary === undefined) return null;
|
|
@@ -416,6 +466,7 @@ export function parseReviewLedgerMarkdown(text) {
|
|
|
416
466
|
const lines = text.split('\n');
|
|
417
467
|
const rows = [];
|
|
418
468
|
const errors = [];
|
|
469
|
+
const rejectedHeaders = [];
|
|
419
470
|
let section = null;
|
|
420
471
|
let rowIndex = 0;
|
|
421
472
|
let headerFound = false;
|
|
@@ -429,6 +480,8 @@ export function parseReviewLedgerMarkdown(text) {
|
|
|
429
480
|
}
|
|
430
481
|
const header = line.startsWith('|') ? ledgerHeaderMap(line) : null;
|
|
431
482
|
if (!header) {
|
|
483
|
+
const next = (lines[index + 1] ?? '').trim();
|
|
484
|
+
if (line.startsWith('|') && /^\|[\s:|-]+\|$/.test(next)) rejectedHeaders.push(line);
|
|
432
485
|
index += 1;
|
|
433
486
|
continue;
|
|
434
487
|
}
|
|
@@ -474,7 +527,11 @@ export function parseReviewLedgerMarkdown(text) {
|
|
|
474
527
|
}
|
|
475
528
|
}
|
|
476
529
|
if (!headerFound) {
|
|
477
|
-
|
|
530
|
+
const rejected = rejectedHeaders[0];
|
|
531
|
+
return {
|
|
532
|
+
rows: [],
|
|
533
|
+
error: rejected ? `unmapped ledger table header: ${rejected}` : 'no ledger table header',
|
|
534
|
+
};
|
|
478
535
|
}
|
|
479
536
|
return { rows, error: null, errors };
|
|
480
537
|
}
|
|
@@ -1509,7 +1566,12 @@ const projectTask = ({ db, teamRoot, slug, now, searchMode, deadlineAt }) => {
|
|
|
1509
1566
|
if (artifacts) replaceArtifacts(db, slug, artifacts.artifacts);
|
|
1510
1567
|
replacePrompts(db, slug, parsed);
|
|
1511
1568
|
if (parsed.outcome || !parsed.outcomeExists) replaceOutcome(db, slug, parsed.outcome);
|
|
1512
|
-
|
|
1569
|
+
// A ledger the parser could not map keeps its projected rows: an unknown
|
|
1570
|
+
// table shape must not erase the recorded review history. The file is gone
|
|
1571
|
+
// only when the task directory no longer carries it.
|
|
1572
|
+
const ledger = parsed.reviewLedger;
|
|
1573
|
+
if (ledger && !ledger.error) replaceReviewLedger(db, slug, ledger);
|
|
1574
|
+
else if (!parsed.reviewLedgerExists) replaceReviewLedger(db, slug, null);
|
|
1513
1575
|
upsertDocuments(db, slug, files, now);
|
|
1514
1576
|
for (const error of errors) {
|
|
1515
1577
|
const relative = error.path.startsWith(`${slug}/`) ? error.path.slice(slug.length + 1) : null;
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* delete one task folder, then its rows
|
|
15
15
|
* migrate-tasks [--root <team-dir>] [--quiet] [--json]
|
|
16
16
|
* [--rebuild | --no-rebuild] create or reconcile the database
|
|
17
|
+
* ledger-check [--root <team-dir>] [--slug <slug>] [--json]
|
|
18
|
+
* validate the review-ledger tables
|
|
17
19
|
* serve [--root <team-dir>] [--host <addr>] [--port <n>] [--allow-remote]
|
|
18
20
|
* loopback API
|
|
19
21
|
* jobs list [--root <team-dir>] [--enabled] [--json] [--quiet]
|
|
@@ -33,7 +35,9 @@
|
|
|
33
35
|
* checksum drifted, 2 database-level failure, 3 usage, 4 deadline or busy.
|
|
34
36
|
* The tracker verbs reuse the same vocabulary: 0 ok, 1 a validation refusal
|
|
35
37
|
* (each with its named `E_TRACKER_*`/`E_SCHEMA`/`E_ID_COLLISION` code), 3
|
|
36
|
-
* usage, 4 the tree lock was contended (`E_TRACKER_BUSY`).
|
|
38
|
+
* usage, 4 the tree lock was contended (`E_TRACKER_BUSY`). A `--rebuild` of
|
|
39
|
+
* `init`/`sync`/`migrate-tasks` that meets another rebuild holds the team-root
|
|
40
|
+
* rebuild lock and exits 4 with `E_REBUILD_BUSY`.
|
|
37
41
|
*
|
|
38
42
|
* A runtime without `node:sqlite` prints one line and stays file-only:
|
|
39
43
|
* `init`/`sync`/`migrate-tasks` exit 0 without creating a database, `check` and
|
|
@@ -62,7 +66,15 @@ import {
|
|
|
62
66
|
openTeamDb,
|
|
63
67
|
teamDbFail,
|
|
64
68
|
} from './team-db-schema.mjs';
|
|
65
|
-
import {
|
|
69
|
+
import {
|
|
70
|
+
deleteTaskProjection,
|
|
71
|
+
describeSyncResult,
|
|
72
|
+
listTaskDirectories,
|
|
73
|
+
parseReviewLedgerMarkdown,
|
|
74
|
+
searchProjection,
|
|
75
|
+
syncProjection,
|
|
76
|
+
syncTrackerProjection,
|
|
77
|
+
} from './team-db-project.mjs';
|
|
66
78
|
import {
|
|
67
79
|
isLeaseFresh,
|
|
68
80
|
runJobsCommand,
|
|
@@ -70,6 +82,7 @@ import {
|
|
|
70
82
|
schedulerPaths,
|
|
71
83
|
} from './team-db-scheduler.mjs';
|
|
72
84
|
import { runTrackerCommand } from './team-db-tracker.mjs';
|
|
85
|
+
import { acquireLock, releaseLock } from './lock.mjs';
|
|
73
86
|
|
|
74
87
|
const USAGE = `usage:
|
|
75
88
|
team-db.mjs init [--root <team-dir>] [--rebuild]
|
|
@@ -81,6 +94,7 @@ const USAGE = `usage:
|
|
|
81
94
|
team-db.mjs delete --slug <slug> [--root <team-dir>] [--json]
|
|
82
95
|
team-db.mjs migrate-tasks [--root <team-dir>] [--quiet] [--json]
|
|
83
96
|
[--rebuild | --no-rebuild]
|
|
97
|
+
team-db.mjs ledger-check [--root <team-dir>] [--slug <slug>] [--json]
|
|
84
98
|
team-db.mjs serve [--root <team-dir>] [--host <addr>] [--port <n>]
|
|
85
99
|
[--allow-remote]
|
|
86
100
|
team-db.mjs jobs list [--root <team-dir>] [--enabled] [--json] [--quiet]
|
|
@@ -143,7 +157,7 @@ const BOOLEAN_FLAGS = new Set([
|
|
|
143
157
|
'ready',
|
|
144
158
|
'claim',
|
|
145
159
|
]);
|
|
146
|
-
const COMMANDS = new Set(['init', 'check', 'search', 'sync', 'delete', 'migrate-tasks', 'serve', 'jobs', 'schedule', 'tracker', 'task-run']);
|
|
160
|
+
const COMMANDS = new Set(['init', 'check', 'search', 'sync', 'delete', 'migrate-tasks', 'ledger-check', 'serve', 'jobs', 'schedule', 'tracker', 'task-run']);
|
|
147
161
|
const ALLOWED_FLAGS = {
|
|
148
162
|
init: new Set(['root', 'rebuild']),
|
|
149
163
|
check: new Set(['root']),
|
|
@@ -151,6 +165,7 @@ const ALLOWED_FLAGS = {
|
|
|
151
165
|
sync: new Set(['root', 'slug', 'quiet', 'json', 'maintain', 'prune', 'vacuum', 'rebuild', 'no-rebuild', 'telemetry', 'no-telemetry', 'deadline-ms']),
|
|
152
166
|
delete: new Set(['root', 'slug', 'json']),
|
|
153
167
|
'migrate-tasks': new Set(['root', 'quiet', 'json', 'rebuild', 'no-rebuild']),
|
|
168
|
+
'ledger-check': new Set(['root', 'slug', 'json']),
|
|
154
169
|
serve: new Set(['root', 'host', 'port', 'allow-remote']),
|
|
155
170
|
jobs: new Set(['root', 'json', 'quiet', 'enabled', 'file', 'id', 'dry-run', 'keep-runs']),
|
|
156
171
|
schedule: new Set(['root', 'json', 'quiet', 'once', 'interval-ms', 'grace-ms', 'drain-ms']),
|
|
@@ -273,17 +288,20 @@ const cannotProject = (env) => {
|
|
|
273
288
|
|
|
274
289
|
const runInit = (flags) => {
|
|
275
290
|
if (cannotProject(process.env)) return 0;
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
291
|
+
const teamRoot = teamRootFrom(flags);
|
|
292
|
+
assertNoLiveScheduler(teamRoot, Boolean(flags.rebuild));
|
|
293
|
+
return withRebuildLock(teamRoot, Boolean(flags.rebuild), () => {
|
|
294
|
+
const handle = openTeamDb({ teamRoot, rebuild: Boolean(flags.rebuild) });
|
|
295
|
+
try {
|
|
296
|
+
if (!integrityCheck(handle.db)) {
|
|
297
|
+
teamDbFail('E_DB_CORRUPT', `${handle.dbPath} failed PRAGMA integrity_check`, 2);
|
|
298
|
+
}
|
|
299
|
+
process.stdout.write(`${describeHandle(handle)}\n`);
|
|
300
|
+
return 0;
|
|
301
|
+
} finally {
|
|
302
|
+
handle.db.close();
|
|
281
303
|
}
|
|
282
|
-
|
|
283
|
-
return 0;
|
|
284
|
-
} finally {
|
|
285
|
-
handle.db.close();
|
|
286
|
-
}
|
|
304
|
+
});
|
|
287
305
|
};
|
|
288
306
|
|
|
289
307
|
const runCheck = (flags) => {
|
|
@@ -370,24 +388,26 @@ const runSearch = (flags, positionals) => {
|
|
|
370
388
|
const runSync = (flags) => {
|
|
371
389
|
if (cannotProject(process.env)) return 0;
|
|
372
390
|
if (flags.rebuild && flags['no-rebuild']) teamDbFail('E_USAGE', '--rebuild and --no-rebuild are exclusive', 3);
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
+
const teamRoot = teamRootFrom(flags);
|
|
392
|
+
assertNoLiveScheduler(teamRoot, Boolean(flags.rebuild || flags.vacuum));
|
|
393
|
+
const result = withRebuildLock(teamRoot, Boolean(flags.rebuild), () => {
|
|
394
|
+
try {
|
|
395
|
+
return syncProjection({
|
|
396
|
+
teamRoot,
|
|
397
|
+
slug: flags.slug ?? null,
|
|
398
|
+
maintain: Boolean(flags.maintain),
|
|
399
|
+
prune: Boolean(flags.prune),
|
|
400
|
+
vacuum: Boolean(flags.vacuum),
|
|
401
|
+
rebuild: Boolean(flags.rebuild),
|
|
402
|
+
noRebuild: Boolean(flags['no-rebuild']),
|
|
403
|
+
telemetry: flags.telemetry ? true : flags['no-telemetry'] ? false : undefined,
|
|
404
|
+
deadlineMs: flags['deadline-ms'],
|
|
405
|
+
});
|
|
406
|
+
} catch (error) {
|
|
407
|
+
if (error instanceof TeamDbError && error.code === 'E_DB_BUSY' && flags.slug) error.exitCode = 4;
|
|
408
|
+
throw error;
|
|
409
|
+
}
|
|
410
|
+
});
|
|
391
411
|
// JSON output narrows stdout to one line; failures still print on stderr so
|
|
392
412
|
// AC-2.5 holds in every output mode.
|
|
393
413
|
for (const failure of result.errors) {
|
|
@@ -446,15 +466,17 @@ const runMigrateTasks = (flags) => {
|
|
|
446
466
|
} catch {
|
|
447
467
|
/* absent or unreadable; openTeamDb reports the real error */
|
|
448
468
|
}
|
|
449
|
-
const result =
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
469
|
+
const result = withRebuildLock(teamRoot, Boolean(flags.rebuild), () =>
|
|
470
|
+
syncProjection({
|
|
471
|
+
teamRoot,
|
|
472
|
+
slug: null,
|
|
473
|
+
maintain: false,
|
|
474
|
+
prune: false,
|
|
475
|
+
vacuum: false,
|
|
476
|
+
rebuild: Boolean(flags.rebuild),
|
|
477
|
+
noRebuild: Boolean(flags['no-rebuild']),
|
|
478
|
+
}),
|
|
479
|
+
);
|
|
458
480
|
for (const failure of result.errors) {
|
|
459
481
|
process.stderr.write(`${failure.path}: ${failure.reason}\n`);
|
|
460
482
|
}
|
|
@@ -472,6 +494,45 @@ const runMigrateTasks = (flags) => {
|
|
|
472
494
|
return result.exitCode;
|
|
473
495
|
};
|
|
474
496
|
|
|
497
|
+
const LEDGER_FILE = 'review-ledger.md';
|
|
498
|
+
const LEDGER_HEADER_HINT =
|
|
499
|
+
'the canonical header is | id | at | source | summary | fair | disposition | evidence | signature |';
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Validate the review-ledger tables of one task or of every task. A table the
|
|
503
|
+
* parser cannot map is what makes the projection drop a task's ledger rows, so
|
|
504
|
+
* the check runs before a producer appends a row, not after the UI asks for it.
|
|
505
|
+
*/
|
|
506
|
+
const runLedgerCheck = (flags) => {
|
|
507
|
+
const teamRoot = teamRootFrom(flags);
|
|
508
|
+
const slugs = flags.slug ? [flags.slug] : listTaskDirectories(teamRoot);
|
|
509
|
+
const failures = [];
|
|
510
|
+
let checked = 0;
|
|
511
|
+
for (const slug of slugs) {
|
|
512
|
+
const file = path.join(teamRoot, 'tasks', slug, LEDGER_FILE);
|
|
513
|
+
if (!fs.existsSync(file)) continue;
|
|
514
|
+
checked += 1;
|
|
515
|
+
const parsed = parseReviewLedgerMarkdown(fs.readFileSync(file, 'utf8'));
|
|
516
|
+
if (parsed.error) {
|
|
517
|
+
failures.push({ path: `${slug}/${LEDGER_FILE}`, reason: parsed.error });
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
520
|
+
for (const reason of parsed.errors ?? []) {
|
|
521
|
+
failures.push({ path: `${slug}/${LEDGER_FILE}`, reason });
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (flags.json) {
|
|
525
|
+
process.stdout.write(`${JSON.stringify({ ok: failures.length === 0, checked, failures })}\n`);
|
|
526
|
+
return failures.length === 0 ? 0 : 1;
|
|
527
|
+
}
|
|
528
|
+
for (const failure of failures) {
|
|
529
|
+
process.stderr.write(`${failure.path}: ${failure.reason}\n`);
|
|
530
|
+
}
|
|
531
|
+
if (failures.length > 0) process.stderr.write(`ledger-check: ${LEDGER_HEADER_HINT}\n`);
|
|
532
|
+
process.stdout.write(`ledger-check: checked=${checked} failed=${failures.length}\n`);
|
|
533
|
+
return failures.length === 0 ? 0 : 1;
|
|
534
|
+
};
|
|
535
|
+
|
|
475
536
|
const runJobs = (flags, positionals) => {
|
|
476
537
|
const [subcommand = 'list', positionalId] = positionals;
|
|
477
538
|
try {
|
|
@@ -569,6 +630,29 @@ const assertNoLiveScheduler = (teamRoot, destructive) => {
|
|
|
569
630
|
);
|
|
570
631
|
};
|
|
571
632
|
|
|
633
|
+
/**
|
|
634
|
+
* The rebuild lock is outer to every inner lock (the tracker's `.lock`, the
|
|
635
|
+
* database's `busy_timeout`): a rebuild renames `team.db`, so two rebuilds must
|
|
636
|
+
* never overlap. Contention fails fast with the documented busy code — a wait
|
|
637
|
+
* would let the second rebuild rename the file the first one just wrote.
|
|
638
|
+
*/
|
|
639
|
+
const withRebuildLock = (teamRoot, rebuild, run) => {
|
|
640
|
+
if (!rebuild) return run();
|
|
641
|
+
fs.mkdirSync(teamRoot, { recursive: true });
|
|
642
|
+
const lockPath = path.join(teamRoot, '.rebuild.lock');
|
|
643
|
+
let token = null;
|
|
644
|
+
try {
|
|
645
|
+
token = acquireLock(lockPath, { timeoutMs: 0 });
|
|
646
|
+
} catch (error) {
|
|
647
|
+
teamDbFail('E_REBUILD_BUSY', `could not take the rebuild lock at ${lockPath}: ${error.message}`, 4);
|
|
648
|
+
}
|
|
649
|
+
try {
|
|
650
|
+
return run();
|
|
651
|
+
} finally {
|
|
652
|
+
releaseLock(lockPath, token);
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
|
|
572
656
|
const runSchedule = async (flags) => {
|
|
573
657
|
try {
|
|
574
658
|
return await runScheduler({
|
|
@@ -637,6 +721,7 @@ export async function runCli(argv) {
|
|
|
637
721
|
if (command === 'search') return runSearch(flags, positionals);
|
|
638
722
|
if (command === 'delete') return runDelete(flags);
|
|
639
723
|
if (command === 'migrate-tasks') return runMigrateTasks(flags);
|
|
724
|
+
if (command === 'ledger-check') return runLedgerCheck(flags);
|
|
640
725
|
if (command === 'serve') return runServe(flags);
|
|
641
726
|
if (command === 'jobs') return runJobs(flags, positionals);
|
|
642
727
|
if (command === 'tracker') return runTracker(flags, positionals);
|