@bonesofspring/ai-rules 0.2.77 → 0.2.80
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 +89 -0
- package/README.md +4 -2
- package/bin/lib/engine-scripts.js +9 -0
- package/bin/lib/seed-ai-local-team.js +2 -0
- package/docs/LOCAL-OVERLAY.md +4 -4
- package/docs/PRESET-CONTRIBUTION.md +9 -8
- package/docs/TEAM-DB.md +160 -22
- package/docs/openapi/team-db.v1.json +2879 -1858
- package/package.json +6 -1
- package/presets/_shared/ai-local/scripts/aggregate-agent-task-metrics.mjs +23 -0
- package/presets/_shared/ai-local/scripts/check-task-repositories.mjs +264 -0
- package/presets/_shared/ai-local/scripts/check-verification.mjs +275 -0
- package/presets/_shared/ai-local/scripts/check-write-scope.mjs +72 -18
- package/presets/_shared/ai-local/scripts/manifest.mjs +78 -4
- package/presets/_shared/ai-local/scripts/rr-migrate-repositories.mjs +481 -0
- package/presets/_shared/ai-local/scripts/rule-improver.mjs +366 -13
- package/presets/_shared/ai-local/scripts/run.mjs +29 -6
- package/presets/_shared/ai-local/scripts/team-db-api.mjs +211 -12
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +289 -3
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +1065 -4
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +144 -15
- package/presets/_shared/ai-local/scripts/team-db-tracker.mjs +29 -10
- package/presets/_shared/ai-local/scripts/team-db.mjs +65 -5
- package/presets/_shared/core/agent-team/agent-artifact-contracts.md +9 -4
- package/presets/_shared/core/agent-team/task-framing.md +1 -0
- package/presets/_shared/core/meta/preset-layering.md +4 -4
- package/presets/_shared/core/meta/preset-pr-checklist.md +2 -1
- package/presets/_shared/core/meta/preset-twin-sync.md +12 -5
- package/presets/_shared/core/quality/self-review-and-context-hygiene.md +1 -1
- package/presets/_shared/core/quality/verification-before-completion.md +28 -4
- package/presets/_shared/core/review/code-review-mr.md +1 -0
- package/presets/_shared/core/review/receiving-code-review.md +1 -0
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +382 -27
- package/presets/claude/android-kotlin/CLAUDE.md +1 -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/agents/task-router.md +2 -0
- package/presets/claude/android-kotlin/commands/README.md +1 -0
- package/presets/claude/android-kotlin/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/android-kotlin/commands/task.md +4 -0
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +382 -27
- package/presets/claude/android-kotlin/rules/tooling-and-review/ai-local-overlay.md +1 -1
- package/presets/claude/android-kotlin/rules/tooling-and-review/code-review.md +1 -0
- package/presets/claude/android-kotlin/rules/tooling-and-review/preset-layering.md +4 -4
- package/presets/claude/android-kotlin/rules/tooling-and-review/preset-pr-checklist.md +2 -1
- package/presets/claude/android-kotlin/rules/tooling-and-review/preset-twin-sync.md +12 -5
- package/presets/claude/go/CLAUDE.md +1 -1
- 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/agents/task-router.md +2 -0
- package/presets/claude/go/commands/README.md +1 -0
- package/presets/claude/go/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/go/commands/task.md +4 -0
- package/presets/claude/go/hooks/chain-team-phases.sh +382 -27
- package/presets/claude/go/rules/tooling-and-review/ai-local-overlay.md +1 -1
- package/presets/claude/go/rules/tooling-and-review/code-review.md +1 -0
- package/presets/claude/go/rules/tooling-and-review/preset-layering.md +4 -4
- package/presets/claude/go/rules/tooling-and-review/preset-pr-checklist.md +2 -1
- package/presets/claude/go/rules/tooling-and-review/preset-twin-sync.md +12 -5
- package/presets/claude/ios-swift/CLAUDE.md +1 -1
- package/presets/claude/ios-swift/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/claude/ios-swift/commands/README.md +1 -0
- package/presets/claude/ios-swift/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/ios-swift/commands/task.md +4 -0
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +382 -27
- package/presets/claude/ios-swift/rules/tooling-and-review/ai-local-overlay.md +1 -1
- package/presets/claude/ios-swift/rules/tooling-and-review/code-review.md +1 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/preset-layering.md +4 -4
- package/presets/claude/ios-swift/rules/tooling-and-review/preset-pr-checklist.md +2 -1
- package/presets/claude/ios-swift/rules/tooling-and-review/preset-twin-sync.md +12 -5
- package/presets/claude/java/CLAUDE.md +1 -1
- 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/agents/task-router.md +2 -0
- package/presets/claude/java/commands/README.md +1 -0
- package/presets/claude/java/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/java/commands/task.md +4 -0
- package/presets/claude/java/hooks/chain-team-phases.sh +382 -27
- package/presets/claude/java/rules/tooling-and-review/ai-local-overlay.md +1 -1
- package/presets/claude/java/rules/tooling-and-review/code-review.md +1 -0
- package/presets/claude/java/rules/tooling-and-review/preset-layering.md +4 -4
- package/presets/claude/java/rules/tooling-and-review/preset-pr-checklist.md +2 -1
- package/presets/claude/java/rules/tooling-and-review/preset-twin-sync.md +12 -5
- package/presets/claude/mcp-ts/CLAUDE.md +1 -1
- 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/agents/task-router.md +2 -0
- package/presets/claude/mcp-ts/commands/README.md +1 -0
- package/presets/claude/mcp-ts/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/mcp-ts/commands/task.md +4 -0
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +382 -27
- package/presets/claude/mcp-ts/rules/tooling-and-review/ai-local-overlay.md +1 -1
- package/presets/claude/mcp-ts/rules/tooling-and-review/code-review.md +1 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/preset-layering.md +4 -4
- package/presets/claude/mcp-ts/rules/tooling-and-review/preset-pr-checklist.md +2 -1
- package/presets/claude/mcp-ts/rules/tooling-and-review/preset-twin-sync.md +12 -5
- package/presets/claude/mol/CLAUDE.md +1 -1
- package/presets/claude/mol/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/claude/mol/commands/README.md +1 -0
- package/presets/claude/mol/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/mol/commands/task.md +4 -0
- package/presets/claude/mol/hooks/chain-team-phases.sh +382 -27
- package/presets/claude/mol/rules/tooling-and-review/ai-local-overlay.md +1 -1
- package/presets/claude/mol/rules/tooling-and-review/code-review-mr.md +1 -0
- package/presets/claude/mol/rules/tooling-and-review/preset-layering.md +4 -4
- package/presets/claude/mol/rules/tooling-and-review/preset-pr-checklist.md +2 -1
- package/presets/claude/mol/rules/tooling-and-review/preset-twin-sync.md +12 -5
- package/presets/claude/next/CLAUDE.md +1 -1
- package/presets/claude/next/agents/build-verifier.md +6 -1
- package/presets/claude/next/agents/code-reviewer.md +1 -1
- package/presets/claude/next/agents/debugger.md +1 -1
- package/presets/claude/next/agents/feature-developer.md +1 -1
- package/presets/claude/next/agents/task-analyst.md +1 -1
- package/presets/claude/next/agents/task-router.md +2 -0
- package/presets/claude/next/commands/README.md +1 -0
- package/presets/claude/next/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/next/commands/task.md +4 -0
- package/presets/claude/next/commands/ui-start.md +12 -4
- package/presets/claude/next/commands/ui-stop.md +5 -2
- package/presets/claude/next/hooks/chain-team-phases.sh +382 -27
- package/presets/claude/next/rules/tooling-and-review/ai-local-overlay.md +2 -1
- package/presets/claude/next/rules/tooling-and-review/code-review-mr.md +1 -0
- package/presets/claude/next/rules/tooling-and-review/preset-layering.md +4 -4
- package/presets/claude/next/rules/tooling-and-review/preset-pr-checklist.md +2 -1
- package/presets/claude/next/rules/tooling-and-review/preset-twin-sync.md +12 -5
- package/presets/claude/nuxt/CLAUDE.md +1 -1
- package/presets/claude/nuxt/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/claude/nuxt/commands/README.md +1 -0
- package/presets/claude/nuxt/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/nuxt/commands/task.md +4 -0
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +382 -27
- package/presets/claude/nuxt/rules/tooling-and-review/ai-local-overlay.md +1 -1
- package/presets/claude/nuxt/rules/tooling-and-review/code-review-mr.md +1 -0
- package/presets/claude/nuxt/rules/tooling-and-review/preset-layering.md +4 -4
- package/presets/claude/nuxt/rules/tooling-and-review/preset-pr-checklist.md +2 -1
- package/presets/claude/nuxt/rules/tooling-and-review/preset-twin-sync.md +12 -5
- package/presets/claude/php-hexagonal/CLAUDE.md +1 -1
- 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/agents/task-router.md +2 -0
- package/presets/claude/php-hexagonal/commands/README.md +1 -0
- package/presets/claude/php-hexagonal/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/php-hexagonal/commands/task.md +4 -0
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +382 -27
- package/presets/claude/php-hexagonal/rules/tooling-and-review/ai-local-overlay.md +1 -1
- package/presets/claude/php-hexagonal/rules/tooling-and-review/code-review.md +1 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-layering.md +4 -4
- package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-pr-checklist.md +2 -1
- package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-twin-sync.md +12 -5
- package/presets/claude/php-laravel/CLAUDE.md +1 -1
- 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/agents/task-router.md +2 -0
- package/presets/claude/php-laravel/commands/README.md +1 -0
- package/presets/claude/php-laravel/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/php-laravel/commands/task.md +4 -0
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +382 -27
- package/presets/claude/php-laravel/rules/tooling-and-review/ai-local-overlay.md +1 -1
- package/presets/claude/php-laravel/rules/tooling-and-review/code-review.md +1 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/preset-layering.md +4 -4
- package/presets/claude/php-laravel/rules/tooling-and-review/preset-pr-checklist.md +2 -1
- package/presets/claude/php-laravel/rules/tooling-and-review/preset-twin-sync.md +12 -5
- package/presets/claude/svelte/CLAUDE.md +1 -1
- package/presets/claude/svelte/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/claude/svelte/commands/README.md +1 -0
- package/presets/claude/svelte/commands/rr-migrate-repositories.md +59 -0
- package/presets/claude/svelte/commands/task.md +4 -0
- package/presets/claude/svelte/hooks/chain-team-phases.sh +382 -27
- package/presets/claude/svelte/rules/tooling-and-review/ai-local-overlay.md +1 -1
- package/presets/claude/svelte/rules/tooling-and-review/code-review-mr.md +1 -0
- package/presets/claude/svelte/rules/tooling-and-review/preset-layering.md +4 -4
- package/presets/claude/svelte/rules/tooling-and-review/preset-pr-checklist.md +2 -1
- package/presets/claude/svelte/rules/tooling-and-review/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/cursor/android-kotlin/commands/README.md +1 -0
- package/presets/cursor/android-kotlin/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/android-kotlin/commands/task.md +4 -0
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +382 -27
- package/presets/cursor/android-kotlin/rules/ai-local-overlay.mdc +1 -1
- package/presets/cursor/android-kotlin/rules/code-review-mr.mdc +1 -0
- package/presets/cursor/android-kotlin/rules/preset-layering.mdc +4 -4
- package/presets/cursor/android-kotlin/rules/preset-pr-checklist.mdc +2 -1
- package/presets/cursor/android-kotlin/rules/preset-twin-sync.mdc +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/cursor/go/commands/README.md +1 -0
- package/presets/cursor/go/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/go/commands/task.md +4 -0
- package/presets/cursor/go/hooks/chain-team-phases.sh +382 -27
- package/presets/cursor/go/rules/ai-local-overlay.mdc +1 -1
- package/presets/cursor/go/rules/code-review-mr.mdc +1 -0
- package/presets/cursor/go/rules/preset-layering.mdc +4 -4
- package/presets/cursor/go/rules/preset-pr-checklist.mdc +2 -1
- package/presets/cursor/go/rules/preset-twin-sync.mdc +12 -5
- package/presets/cursor/ios-swift/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/cursor/ios-swift/commands/README.md +1 -0
- package/presets/cursor/ios-swift/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/ios-swift/commands/task.md +4 -0
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +382 -27
- package/presets/cursor/ios-swift/rules/ai-local-overlay.mdc +1 -1
- package/presets/cursor/ios-swift/rules/code-review-mr.mdc +1 -0
- package/presets/cursor/ios-swift/rules/preset-layering.mdc +4 -4
- package/presets/cursor/ios-swift/rules/preset-pr-checklist.mdc +2 -1
- package/presets/cursor/ios-swift/rules/preset-twin-sync.mdc +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/cursor/java/commands/README.md +1 -0
- package/presets/cursor/java/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/java/commands/task.md +4 -0
- package/presets/cursor/java/hooks/chain-team-phases.sh +382 -27
- package/presets/cursor/java/rules/ai-local-overlay.mdc +1 -1
- package/presets/cursor/java/rules/code-review-mr.mdc +1 -0
- package/presets/cursor/java/rules/preset-layering.mdc +4 -4
- package/presets/cursor/java/rules/preset-pr-checklist.mdc +2 -1
- package/presets/cursor/java/rules/preset-twin-sync.mdc +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/cursor/mcp-ts/commands/README.md +1 -0
- package/presets/cursor/mcp-ts/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/mcp-ts/commands/task.md +4 -0
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +382 -27
- package/presets/cursor/mcp-ts/rules/ai-local-overlay.mdc +1 -1
- package/presets/cursor/mcp-ts/rules/code-review-mr.mdc +1 -0
- package/presets/cursor/mcp-ts/rules/preset-layering.mdc +4 -4
- package/presets/cursor/mcp-ts/rules/preset-pr-checklist.mdc +2 -1
- package/presets/cursor/mcp-ts/rules/preset-twin-sync.mdc +12 -5
- package/presets/cursor/mol/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/cursor/mol/commands/README.md +1 -0
- package/presets/cursor/mol/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/mol/commands/task.md +4 -0
- package/presets/cursor/mol/hooks/chain-team-phases.sh +382 -27
- package/presets/cursor/mol/rules/ai-local-overlay.mdc +1 -1
- package/presets/cursor/mol/rules/code-review-mr.mdc +1 -0
- package/presets/cursor/mol/rules/preset-layering.mdc +4 -4
- package/presets/cursor/mol/rules/preset-pr-checklist.mdc +2 -1
- package/presets/cursor/mol/rules/preset-twin-sync.mdc +12 -5
- package/presets/cursor/next/agents/build-verifier.md +6 -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/agents/task-router.md +2 -0
- package/presets/cursor/next/commands/README.md +1 -0
- package/presets/cursor/next/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/next/commands/task.md +4 -0
- package/presets/cursor/next/commands/ui-start.md +12 -4
- package/presets/cursor/next/commands/ui-stop.md +5 -2
- package/presets/cursor/next/hooks/chain-team-phases.sh +382 -27
- package/presets/cursor/next/rules/ai-local-overlay.mdc +2 -1
- package/presets/cursor/next/rules/code-review-mr.mdc +1 -0
- package/presets/cursor/next/rules/preset-layering.mdc +4 -4
- package/presets/cursor/next/rules/preset-pr-checklist.mdc +2 -1
- package/presets/cursor/next/rules/preset-twin-sync.mdc +12 -5
- package/presets/cursor/nuxt/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/cursor/nuxt/commands/README.md +1 -0
- package/presets/cursor/nuxt/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/nuxt/commands/task.md +4 -0
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +382 -27
- package/presets/cursor/nuxt/rules/ai-local-overlay.mdc +1 -1
- package/presets/cursor/nuxt/rules/code-review-mr.mdc +1 -0
- package/presets/cursor/nuxt/rules/preset-layering.mdc +4 -4
- package/presets/cursor/nuxt/rules/preset-pr-checklist.mdc +2 -1
- package/presets/cursor/nuxt/rules/preset-twin-sync.mdc +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/cursor/php-hexagonal/commands/README.md +1 -0
- package/presets/cursor/php-hexagonal/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/php-hexagonal/commands/task.md +4 -0
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +382 -27
- package/presets/cursor/php-hexagonal/rules/ai-local-overlay.mdc +1 -1
- package/presets/cursor/php-hexagonal/rules/code-review-mr.mdc +1 -0
- package/presets/cursor/php-hexagonal/rules/preset-layering.mdc +4 -4
- package/presets/cursor/php-hexagonal/rules/preset-pr-checklist.mdc +2 -1
- package/presets/cursor/php-hexagonal/rules/preset-twin-sync.mdc +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/cursor/php-laravel/commands/README.md +1 -0
- package/presets/cursor/php-laravel/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/php-laravel/commands/task.md +4 -0
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +382 -27
- package/presets/cursor/php-laravel/rules/ai-local-overlay.mdc +1 -1
- package/presets/cursor/php-laravel/rules/code-review-mr.mdc +1 -0
- package/presets/cursor/php-laravel/rules/preset-layering.mdc +4 -4
- package/presets/cursor/php-laravel/rules/preset-pr-checklist.mdc +2 -1
- package/presets/cursor/php-laravel/rules/preset-twin-sync.mdc +12 -5
- package/presets/cursor/svelte/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/cursor/svelte/commands/README.md +1 -0
- package/presets/cursor/svelte/commands/rr-migrate-repositories.md +59 -0
- package/presets/cursor/svelte/commands/task.md +4 -0
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +382 -27
- package/presets/cursor/svelte/rules/ai-local-overlay.mdc +1 -1
- package/presets/cursor/svelte/rules/code-review-mr.mdc +1 -0
- package/presets/cursor/svelte/rules/preset-layering.mdc +4 -4
- package/presets/cursor/svelte/rules/preset-pr-checklist.mdc +2 -1
- package/presets/cursor/svelte/rules/preset-twin-sync.mdc +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/mavis/android-kotlin/commands/README.md +1 -0
- package/presets/mavis/android-kotlin/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/android-kotlin/commands/task.md +4 -0
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +382 -27
- package/presets/mavis/android-kotlin/rules/ai-local-overlay.md +1 -1
- package/presets/mavis/android-kotlin/rules/code-review-mr.md +1 -0
- package/presets/mavis/android-kotlin/rules/preset-layering.md +4 -4
- package/presets/mavis/android-kotlin/rules/preset-pr-checklist.md +2 -1
- package/presets/mavis/android-kotlin/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/mavis/go/commands/README.md +1 -0
- package/presets/mavis/go/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/go/commands/task.md +4 -0
- package/presets/mavis/go/hooks/chain-team-phases.sh +382 -27
- package/presets/mavis/go/rules/ai-local-overlay.md +1 -1
- package/presets/mavis/go/rules/code-review-mr.md +1 -0
- package/presets/mavis/go/rules/preset-layering.md +4 -4
- package/presets/mavis/go/rules/preset-pr-checklist.md +2 -1
- package/presets/mavis/go/rules/preset-twin-sync.md +12 -5
- package/presets/mavis/ios-swift/adapter-map.json +9 -1
- package/presets/mavis/ios-swift/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/mavis/ios-swift/commands/README.md +1 -0
- package/presets/mavis/ios-swift/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/ios-swift/commands/task.md +4 -0
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +382 -27
- package/presets/mavis/ios-swift/rules/ai-local-overlay.md +1 -1
- package/presets/mavis/ios-swift/rules/code-review-mr.md +1 -0
- package/presets/mavis/ios-swift/rules/preset-layering.md +4 -4
- package/presets/mavis/ios-swift/rules/preset-pr-checklist.md +2 -1
- package/presets/mavis/ios-swift/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/mavis/java/commands/README.md +1 -0
- package/presets/mavis/java/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/java/commands/task.md +4 -0
- package/presets/mavis/java/hooks/chain-team-phases.sh +382 -27
- package/presets/mavis/java/rules/ai-local-overlay.md +1 -1
- package/presets/mavis/java/rules/code-review-mr.md +1 -0
- package/presets/mavis/java/rules/preset-layering.md +4 -4
- package/presets/mavis/java/rules/preset-pr-checklist.md +2 -1
- package/presets/mavis/java/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/mavis/mcp-ts/commands/README.md +1 -0
- package/presets/mavis/mcp-ts/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/mcp-ts/commands/task.md +4 -0
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +382 -27
- package/presets/mavis/mcp-ts/rules/ai-local-overlay.md +1 -1
- package/presets/mavis/mcp-ts/rules/code-review-mr.md +1 -0
- package/presets/mavis/mcp-ts/rules/preset-layering.md +4 -4
- package/presets/mavis/mcp-ts/rules/preset-pr-checklist.md +2 -1
- package/presets/mavis/mcp-ts/rules/preset-twin-sync.md +12 -5
- package/presets/mavis/mol/adapter-map.json +9 -1
- package/presets/mavis/mol/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/mavis/mol/commands/README.md +1 -0
- package/presets/mavis/mol/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/mol/commands/task.md +4 -0
- package/presets/mavis/mol/hooks/chain-team-phases.sh +382 -27
- package/presets/mavis/mol/rules/ai-local-overlay.md +1 -1
- package/presets/mavis/mol/rules/code-review-mr.md +1 -0
- package/presets/mavis/mol/rules/preset-layering.md +4 -4
- package/presets/mavis/mol/rules/preset-pr-checklist.md +2 -1
- package/presets/mavis/mol/rules/preset-twin-sync.md +12 -5
- package/presets/mavis/next/adapter-map.json +9 -1
- package/presets/mavis/next/agents/build-verifier.md +6 -1
- package/presets/mavis/next/agents/code-reviewer.md +1 -1
- package/presets/mavis/next/agents/debugger.md +1 -1
- package/presets/mavis/next/agents/feature-developer.md +1 -1
- package/presets/mavis/next/agents/task-analyst.md +1 -1
- package/presets/mavis/next/agents/task-router.md +2 -0
- package/presets/mavis/next/commands/README.md +1 -0
- package/presets/mavis/next/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/next/commands/task.md +4 -0
- package/presets/mavis/next/commands/ui-start.md +12 -4
- package/presets/mavis/next/commands/ui-stop.md +5 -2
- package/presets/mavis/next/hooks/chain-team-phases.sh +382 -27
- package/presets/mavis/next/rules/ai-local-overlay.md +2 -1
- package/presets/mavis/next/rules/code-review-mr.md +1 -0
- package/presets/mavis/next/rules/preset-layering.md +4 -4
- package/presets/mavis/next/rules/preset-pr-checklist.md +2 -1
- package/presets/mavis/next/rules/preset-twin-sync.md +12 -5
- package/presets/mavis/nuxt/adapter-map.json +9 -1
- package/presets/mavis/nuxt/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/mavis/nuxt/commands/README.md +1 -0
- package/presets/mavis/nuxt/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/nuxt/commands/task.md +4 -0
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +382 -27
- package/presets/mavis/nuxt/rules/ai-local-overlay.md +1 -1
- package/presets/mavis/nuxt/rules/code-review-mr.md +1 -0
- package/presets/mavis/nuxt/rules/preset-layering.md +4 -4
- package/presets/mavis/nuxt/rules/preset-pr-checklist.md +2 -1
- package/presets/mavis/nuxt/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/mavis/php-hexagonal/commands/README.md +1 -0
- package/presets/mavis/php-hexagonal/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/php-hexagonal/commands/task.md +4 -0
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +382 -27
- package/presets/mavis/php-hexagonal/rules/ai-local-overlay.md +1 -1
- package/presets/mavis/php-hexagonal/rules/code-review-mr.md +1 -0
- package/presets/mavis/php-hexagonal/rules/preset-layering.md +4 -4
- package/presets/mavis/php-hexagonal/rules/preset-pr-checklist.md +2 -1
- package/presets/mavis/php-hexagonal/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/mavis/php-laravel/commands/README.md +1 -0
- package/presets/mavis/php-laravel/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/php-laravel/commands/task.md +4 -0
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +382 -27
- package/presets/mavis/php-laravel/rules/ai-local-overlay.md +1 -1
- package/presets/mavis/php-laravel/rules/code-review-mr.md +1 -0
- package/presets/mavis/php-laravel/rules/preset-layering.md +4 -4
- package/presets/mavis/php-laravel/rules/preset-pr-checklist.md +2 -1
- package/presets/mavis/php-laravel/rules/preset-twin-sync.md +12 -5
- package/presets/mavis/svelte/adapter-map.json +9 -1
- package/presets/mavis/svelte/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/mavis/svelte/commands/README.md +1 -0
- package/presets/mavis/svelte/commands/rr-migrate-repositories.md +54 -0
- package/presets/mavis/svelte/commands/task.md +4 -0
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +382 -27
- package/presets/mavis/svelte/rules/ai-local-overlay.md +1 -1
- package/presets/mavis/svelte/rules/code-review-mr.md +1 -0
- package/presets/mavis/svelte/rules/preset-layering.md +4 -4
- package/presets/mavis/svelte/rules/preset-pr-checklist.md +2 -1
- package/presets/mavis/svelte/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/opencode/android-kotlin/commands/README.md +1 -0
- package/presets/opencode/android-kotlin/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/android-kotlin/commands/task.md +4 -0
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +382 -27
- package/presets/opencode/android-kotlin/rules/ai-local-overlay.md +1 -1
- package/presets/opencode/android-kotlin/rules/code-review-mr.md +1 -0
- package/presets/opencode/android-kotlin/rules/preset-layering.md +4 -4
- package/presets/opencode/android-kotlin/rules/preset-pr-checklist.md +2 -1
- package/presets/opencode/android-kotlin/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/opencode/go/commands/README.md +1 -0
- package/presets/opencode/go/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/go/commands/task.md +4 -0
- package/presets/opencode/go/hooks/chain-team-phases.sh +382 -27
- package/presets/opencode/go/rules/ai-local-overlay.md +1 -1
- package/presets/opencode/go/rules/code-review-mr.md +1 -0
- package/presets/opencode/go/rules/preset-layering.md +4 -4
- package/presets/opencode/go/rules/preset-pr-checklist.md +2 -1
- package/presets/opencode/go/rules/preset-twin-sync.md +12 -5
- package/presets/opencode/ios-swift/adapter-map.json +9 -1
- package/presets/opencode/ios-swift/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/opencode/ios-swift/commands/README.md +1 -0
- package/presets/opencode/ios-swift/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/ios-swift/commands/task.md +4 -0
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +382 -27
- package/presets/opencode/ios-swift/rules/ai-local-overlay.md +1 -1
- package/presets/opencode/ios-swift/rules/code-review-mr.md +1 -0
- package/presets/opencode/ios-swift/rules/preset-layering.md +4 -4
- package/presets/opencode/ios-swift/rules/preset-pr-checklist.md +2 -1
- package/presets/opencode/ios-swift/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/opencode/java/commands/README.md +1 -0
- package/presets/opencode/java/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/java/commands/task.md +4 -0
- package/presets/opencode/java/hooks/chain-team-phases.sh +382 -27
- package/presets/opencode/java/rules/ai-local-overlay.md +1 -1
- package/presets/opencode/java/rules/code-review-mr.md +1 -0
- package/presets/opencode/java/rules/preset-layering.md +4 -4
- package/presets/opencode/java/rules/preset-pr-checklist.md +2 -1
- package/presets/opencode/java/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/opencode/mcp-ts/commands/README.md +1 -0
- package/presets/opencode/mcp-ts/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/mcp-ts/commands/task.md +4 -0
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +382 -27
- package/presets/opencode/mcp-ts/rules/ai-local-overlay.md +1 -1
- package/presets/opencode/mcp-ts/rules/code-review-mr.md +1 -0
- package/presets/opencode/mcp-ts/rules/preset-layering.md +4 -4
- package/presets/opencode/mcp-ts/rules/preset-pr-checklist.md +2 -1
- package/presets/opencode/mcp-ts/rules/preset-twin-sync.md +12 -5
- package/presets/opencode/mol/adapter-map.json +9 -1
- package/presets/opencode/mol/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/opencode/mol/commands/README.md +1 -0
- package/presets/opencode/mol/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/mol/commands/task.md +4 -0
- package/presets/opencode/mol/hooks/chain-team-phases.sh +382 -27
- package/presets/opencode/mol/rules/ai-local-overlay.md +1 -1
- package/presets/opencode/mol/rules/code-review-mr.md +1 -0
- package/presets/opencode/mol/rules/preset-layering.md +4 -4
- package/presets/opencode/mol/rules/preset-pr-checklist.md +2 -1
- package/presets/opencode/mol/rules/preset-twin-sync.md +12 -5
- package/presets/opencode/next/adapter-map.json +9 -1
- package/presets/opencode/next/agents/build-verifier.md +6 -1
- package/presets/opencode/next/agents/code-reviewer.md +1 -1
- package/presets/opencode/next/agents/debugger.md +1 -1
- package/presets/opencode/next/agents/feature-developer.md +1 -1
- package/presets/opencode/next/agents/task-analyst.md +1 -1
- package/presets/opencode/next/agents/task-router.md +2 -0
- package/presets/opencode/next/commands/README.md +1 -0
- package/presets/opencode/next/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/next/commands/task.md +4 -0
- package/presets/opencode/next/commands/ui-start.md +12 -4
- package/presets/opencode/next/commands/ui-stop.md +5 -2
- package/presets/opencode/next/hooks/chain-team-phases.sh +382 -27
- package/presets/opencode/next/rules/ai-local-overlay.md +2 -1
- package/presets/opencode/next/rules/code-review-mr.md +1 -0
- package/presets/opencode/next/rules/preset-layering.md +4 -4
- package/presets/opencode/next/rules/preset-pr-checklist.md +2 -1
- package/presets/opencode/next/rules/preset-twin-sync.md +12 -5
- package/presets/opencode/nuxt/adapter-map.json +9 -1
- package/presets/opencode/nuxt/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/opencode/nuxt/commands/README.md +1 -0
- package/presets/opencode/nuxt/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/nuxt/commands/task.md +4 -0
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +382 -27
- package/presets/opencode/nuxt/rules/ai-local-overlay.md +1 -1
- package/presets/opencode/nuxt/rules/code-review-mr.md +1 -0
- package/presets/opencode/nuxt/rules/preset-layering.md +4 -4
- package/presets/opencode/nuxt/rules/preset-pr-checklist.md +2 -1
- package/presets/opencode/nuxt/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/opencode/php-hexagonal/commands/README.md +1 -0
- package/presets/opencode/php-hexagonal/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/php-hexagonal/commands/task.md +4 -0
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +382 -27
- package/presets/opencode/php-hexagonal/rules/ai-local-overlay.md +1 -1
- package/presets/opencode/php-hexagonal/rules/code-review-mr.md +1 -0
- package/presets/opencode/php-hexagonal/rules/preset-layering.md +4 -4
- package/presets/opencode/php-hexagonal/rules/preset-pr-checklist.md +2 -1
- package/presets/opencode/php-hexagonal/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/opencode/php-laravel/commands/README.md +1 -0
- package/presets/opencode/php-laravel/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/php-laravel/commands/task.md +4 -0
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +382 -27
- package/presets/opencode/php-laravel/rules/ai-local-overlay.md +1 -1
- package/presets/opencode/php-laravel/rules/code-review-mr.md +1 -0
- package/presets/opencode/php-laravel/rules/preset-layering.md +4 -4
- package/presets/opencode/php-laravel/rules/preset-pr-checklist.md +2 -1
- package/presets/opencode/php-laravel/rules/preset-twin-sync.md +12 -5
- package/presets/opencode/plugins/task-status/README.md +15 -7
- package/presets/opencode/plugins/task-status/deepseek.ts +193 -0
- package/presets/opencode/plugins/task-status/details-data.ts +39 -2
- package/presets/opencode/plugins/task-status/prompt-text.ts +18 -8
- package/presets/opencode/plugins/task-status/task-view.ts +253 -63
- package/presets/opencode/plugins/task-status/tui.tsx +48 -11
- package/presets/opencode/svelte/adapter-map.json +9 -1
- package/presets/opencode/svelte/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/opencode/svelte/commands/README.md +1 -0
- package/presets/opencode/svelte/commands/rr-migrate-repositories.md +62 -0
- package/presets/opencode/svelte/commands/task.md +4 -0
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +382 -27
- package/presets/opencode/svelte/rules/ai-local-overlay.md +1 -1
- package/presets/opencode/svelte/rules/code-review-mr.md +1 -0
- package/presets/opencode/svelte/rules/preset-layering.md +4 -4
- package/presets/opencode/svelte/rules/preset-pr-checklist.md +2 -1
- package/presets/opencode/svelte/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/zcode/android-kotlin/commands/README.md +1 -0
- package/presets/zcode/android-kotlin/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/android-kotlin/commands/task.md +4 -0
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +382 -27
- package/presets/zcode/android-kotlin/rules/ai-local-overlay.md +1 -1
- package/presets/zcode/android-kotlin/rules/code-review-mr.md +1 -0
- package/presets/zcode/android-kotlin/rules/preset-layering.md +4 -4
- package/presets/zcode/android-kotlin/rules/preset-pr-checklist.md +2 -1
- package/presets/zcode/android-kotlin/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/zcode/go/commands/README.md +1 -0
- package/presets/zcode/go/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/go/commands/task.md +4 -0
- package/presets/zcode/go/hooks/chain-team-phases.sh +382 -27
- package/presets/zcode/go/rules/ai-local-overlay.md +1 -1
- package/presets/zcode/go/rules/code-review-mr.md +1 -0
- package/presets/zcode/go/rules/preset-layering.md +4 -4
- package/presets/zcode/go/rules/preset-pr-checklist.md +2 -1
- package/presets/zcode/go/rules/preset-twin-sync.md +12 -5
- package/presets/zcode/ios-swift/adapter-map.json +9 -1
- package/presets/zcode/ios-swift/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/zcode/ios-swift/commands/README.md +1 -0
- package/presets/zcode/ios-swift/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/ios-swift/commands/task.md +4 -0
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +382 -27
- package/presets/zcode/ios-swift/rules/ai-local-overlay.md +1 -1
- package/presets/zcode/ios-swift/rules/code-review-mr.md +1 -0
- package/presets/zcode/ios-swift/rules/preset-layering.md +4 -4
- package/presets/zcode/ios-swift/rules/preset-pr-checklist.md +2 -1
- package/presets/zcode/ios-swift/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/zcode/java/commands/README.md +1 -0
- package/presets/zcode/java/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/java/commands/task.md +4 -0
- package/presets/zcode/java/hooks/chain-team-phases.sh +382 -27
- package/presets/zcode/java/rules/ai-local-overlay.md +1 -1
- package/presets/zcode/java/rules/code-review-mr.md +1 -0
- package/presets/zcode/java/rules/preset-layering.md +4 -4
- package/presets/zcode/java/rules/preset-pr-checklist.md +2 -1
- package/presets/zcode/java/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/zcode/mcp-ts/commands/README.md +1 -0
- package/presets/zcode/mcp-ts/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/mcp-ts/commands/task.md +4 -0
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +382 -27
- package/presets/zcode/mcp-ts/rules/ai-local-overlay.md +1 -1
- package/presets/zcode/mcp-ts/rules/code-review-mr.md +1 -0
- package/presets/zcode/mcp-ts/rules/preset-layering.md +4 -4
- package/presets/zcode/mcp-ts/rules/preset-pr-checklist.md +2 -1
- package/presets/zcode/mcp-ts/rules/preset-twin-sync.md +12 -5
- package/presets/zcode/mol/adapter-map.json +9 -1
- package/presets/zcode/mol/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/zcode/mol/commands/README.md +1 -0
- package/presets/zcode/mol/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/mol/commands/task.md +4 -0
- package/presets/zcode/mol/hooks/chain-team-phases.sh +382 -27
- package/presets/zcode/mol/rules/ai-local-overlay.md +1 -1
- package/presets/zcode/mol/rules/code-review-mr.md +1 -0
- package/presets/zcode/mol/rules/preset-layering.md +4 -4
- package/presets/zcode/mol/rules/preset-pr-checklist.md +2 -1
- package/presets/zcode/mol/rules/preset-twin-sync.md +12 -5
- package/presets/zcode/next/adapter-map.json +9 -1
- package/presets/zcode/next/agents/build-verifier.md +6 -1
- package/presets/zcode/next/agents/code-reviewer.md +1 -1
- package/presets/zcode/next/agents/debugger.md +1 -1
- package/presets/zcode/next/agents/feature-developer.md +1 -1
- package/presets/zcode/next/agents/task-analyst.md +1 -1
- package/presets/zcode/next/agents/task-router.md +2 -0
- package/presets/zcode/next/commands/README.md +1 -0
- package/presets/zcode/next/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/next/commands/task.md +4 -0
- package/presets/zcode/next/commands/ui-start.md +12 -4
- package/presets/zcode/next/commands/ui-stop.md +5 -2
- package/presets/zcode/next/hooks/chain-team-phases.sh +382 -27
- package/presets/zcode/next/rules/ai-local-overlay.md +2 -1
- package/presets/zcode/next/rules/code-review-mr.md +1 -0
- package/presets/zcode/next/rules/preset-layering.md +4 -4
- package/presets/zcode/next/rules/preset-pr-checklist.md +2 -1
- package/presets/zcode/next/rules/preset-twin-sync.md +12 -5
- package/presets/zcode/nuxt/adapter-map.json +9 -1
- package/presets/zcode/nuxt/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/zcode/nuxt/commands/README.md +1 -0
- package/presets/zcode/nuxt/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/nuxt/commands/task.md +4 -0
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +382 -27
- package/presets/zcode/nuxt/rules/ai-local-overlay.md +1 -1
- package/presets/zcode/nuxt/rules/code-review-mr.md +1 -0
- package/presets/zcode/nuxt/rules/preset-layering.md +4 -4
- package/presets/zcode/nuxt/rules/preset-pr-checklist.md +2 -1
- package/presets/zcode/nuxt/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/zcode/php-hexagonal/commands/README.md +1 -0
- package/presets/zcode/php-hexagonal/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/php-hexagonal/commands/task.md +4 -0
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +382 -27
- package/presets/zcode/php-hexagonal/rules/ai-local-overlay.md +1 -1
- package/presets/zcode/php-hexagonal/rules/code-review-mr.md +1 -0
- package/presets/zcode/php-hexagonal/rules/preset-layering.md +4 -4
- package/presets/zcode/php-hexagonal/rules/preset-pr-checklist.md +2 -1
- package/presets/zcode/php-hexagonal/rules/preset-twin-sync.md +12 -5
- 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/agents/task-router.md +2 -0
- package/presets/zcode/php-laravel/commands/README.md +1 -0
- package/presets/zcode/php-laravel/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/php-laravel/commands/task.md +4 -0
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +382 -27
- package/presets/zcode/php-laravel/rules/ai-local-overlay.md +1 -1
- package/presets/zcode/php-laravel/rules/code-review-mr.md +1 -0
- package/presets/zcode/php-laravel/rules/preset-layering.md +4 -4
- package/presets/zcode/php-laravel/rules/preset-pr-checklist.md +2 -1
- package/presets/zcode/php-laravel/rules/preset-twin-sync.md +12 -5
- package/presets/zcode/svelte/adapter-map.json +9 -1
- package/presets/zcode/svelte/agents/build-verifier.md +4 -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/agents/task-router.md +2 -0
- package/presets/zcode/svelte/commands/README.md +1 -0
- package/presets/zcode/svelte/commands/rr-migrate-repositories.md +62 -0
- package/presets/zcode/svelte/commands/task.md +4 -0
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +382 -27
- package/presets/zcode/svelte/rules/ai-local-overlay.md +1 -1
- package/presets/zcode/svelte/rules/code-review-mr.md +1 -0
- package/presets/zcode/svelte/rules/preset-layering.md +4 -4
- package/presets/zcode/svelte/rules/preset-pr-checklist.md +2 -1
- package/presets/zcode/svelte/rules/preset-twin-sync.md +12 -5
|
@@ -28,12 +28,14 @@ import {
|
|
|
28
28
|
isBusyError,
|
|
29
29
|
isCorruptError,
|
|
30
30
|
isKillSwitchSet,
|
|
31
|
+
isSqliteAvailable,
|
|
31
32
|
openTeamDb,
|
|
32
33
|
readSearchMode,
|
|
33
34
|
teamDbFail,
|
|
34
35
|
} from './team-db-schema.mjs';
|
|
35
36
|
import { ACTION_ERROR_CLASSES } from './action-signals.mjs';
|
|
36
|
-
import {
|
|
37
|
+
import { acquireLock, releaseLock } from './lock.mjs';
|
|
38
|
+
import { projectScheduler, resolveTeamRoot, retainRuns } from './team-db-scheduler.mjs';
|
|
37
39
|
import { validateEntrySchema, validateItemSchema, validateLinkIdentity, validateLinkSchema } from './team-db-tracker.mjs';
|
|
38
40
|
|
|
39
41
|
export const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
@@ -403,10 +405,48 @@ const LEDGER_COLUMN_ALIASES = {
|
|
|
403
405
|
summary: ['summary', 'finding', 'path'],
|
|
404
406
|
fair: ['fair'],
|
|
405
407
|
disposition: ['disposition', 'status', 'resolution'],
|
|
408
|
+
owner: ['owner', 'assignee'],
|
|
409
|
+
due: ['due', 'deadline'],
|
|
410
|
+
followUp: ['followup'],
|
|
406
411
|
evidence: ['evidence'],
|
|
407
412
|
signature: ['signature'],
|
|
408
413
|
};
|
|
409
414
|
|
|
415
|
+
/** The header a new ledger table uses. One literal; `team-db.mjs` and `manifest.mjs` import it. */
|
|
416
|
+
export const LEDGER_HEADER_ROW =
|
|
417
|
+
'| id | at | source | summary | fair | disposition | owner | due | followUp | evidence | signature |';
|
|
418
|
+
|
|
419
|
+
/** Rows written before this date keep validating without an owner or a due date. */
|
|
420
|
+
export const LEDGER_OWNER_CUTOFF = '2026-11-22';
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Frozen exact-match set: an `owner` cell that normalises to one of these is a
|
|
424
|
+
* placeholder, not a person. Equality only — a substring rule would refuse
|
|
425
|
+
* `team-lead` and `owner-proxy`.
|
|
426
|
+
*/
|
|
427
|
+
export const OWNER_PLACEHOLDERS = Object.freeze([
|
|
428
|
+
'-',
|
|
429
|
+
'—',
|
|
430
|
+
'?',
|
|
431
|
+
'n/a',
|
|
432
|
+
'na',
|
|
433
|
+
'none',
|
|
434
|
+
'null',
|
|
435
|
+
'tbd',
|
|
436
|
+
'tba',
|
|
437
|
+
'todo',
|
|
438
|
+
'unowned',
|
|
439
|
+
'unassigned',
|
|
440
|
+
'someone',
|
|
441
|
+
'anyone',
|
|
442
|
+
'owner',
|
|
443
|
+
'team',
|
|
444
|
+
]);
|
|
445
|
+
const OWNER_PLACEHOLDER_SET = new Set(OWNER_PLACEHOLDERS);
|
|
446
|
+
const LEDGER_OWNER_DISPOSITIONS = new Set(['open', 'accepted', 'deferred']);
|
|
447
|
+
const LEDGER_DUE_RE = /^\d{4}-\d{2}-\d{2}$/;
|
|
448
|
+
const FOLLOW_UP_PREFIX_RE = /^blocked-on:\s*/;
|
|
449
|
+
|
|
410
450
|
/**
|
|
411
451
|
* A header cell may carry a qualifier (`finding (path:line)`, `Round 2`), so the
|
|
412
452
|
* matcher reads the cell's word tokens instead of the whole cell: `finding
|
|
@@ -459,6 +499,155 @@ const normalizeLedgerDisposition = (value) => {
|
|
|
459
499
|
return text;
|
|
460
500
|
};
|
|
461
501
|
|
|
502
|
+
/**
|
|
503
|
+
* The stored disposition flattens `accepted` into `open`; the owner contract
|
|
504
|
+
* needs the disposition the reviewer wrote, so the validator reads the raw
|
|
505
|
+
* cell's first token instead of the column.
|
|
506
|
+
*/
|
|
507
|
+
export const ledgerDispositionClass = (value) => {
|
|
508
|
+
const token = String(value ?? '')
|
|
509
|
+
.trim()
|
|
510
|
+
.toLowerCase()
|
|
511
|
+
.split(/[^a-z]+/)
|
|
512
|
+
.filter(Boolean)[0];
|
|
513
|
+
if (!token) return 'open';
|
|
514
|
+
if (token === 'fixed' || token === 'resolved') return 'fixed';
|
|
515
|
+
if (token === 'rejected') return 'rejected';
|
|
516
|
+
if (token === 'accepted') return 'accepted';
|
|
517
|
+
if (token === 'deferred') return 'deferred';
|
|
518
|
+
if (token === 'open' || token === 'recorded') return 'open';
|
|
519
|
+
return 'other';
|
|
520
|
+
};
|
|
521
|
+
|
|
522
|
+
/** trim → strip quotes/backticks → strip one @ → lowercase → collapse spaces → strip trailing punctuation */
|
|
523
|
+
const normalizeOwnerToken = (value) =>
|
|
524
|
+
String(value ?? '')
|
|
525
|
+
.trim()
|
|
526
|
+
.replace(/^[`'"]+/, '')
|
|
527
|
+
.replace(/[`'"]+$/, '')
|
|
528
|
+
.replace(/^@/, '')
|
|
529
|
+
.toLowerCase()
|
|
530
|
+
.replace(/\s+/g, ' ')
|
|
531
|
+
.replace(/[.,:;]+$/, '')
|
|
532
|
+
.trim();
|
|
533
|
+
|
|
534
|
+
const ledgerRowDate = (value) => {
|
|
535
|
+
if (typeof value !== 'string' || value.trim() === '') return null;
|
|
536
|
+
const parsed = Date.parse(value);
|
|
537
|
+
return Number.isNaN(parsed) ? null : new Date(parsed).toISOString().slice(0, 10);
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
const ledgerTaskDirectory = (teamRoot, slug) => {
|
|
541
|
+
try {
|
|
542
|
+
return fs.statSync(path.join(teamRoot, 'tasks', slug)).isDirectory();
|
|
543
|
+
} catch {
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* The owner contract over parsed rows. One source for the message text: the
|
|
550
|
+
* CLI prints these strings and the chain hook relays `failures[].reason`
|
|
551
|
+
* verbatim, so neither holds a copy.
|
|
552
|
+
*
|
|
553
|
+
* Legacy is a two-clause OR, decided per row: a row with no usable `at` — the
|
|
554
|
+
* one date git cannot supply — or an `at` before `LEDGER_OWNER_CUTOFF`, and
|
|
555
|
+
* neither clause consults the header. The header only decides a dated row: a
|
|
556
|
+
* post-cutoff row under a stale header fails because the owner column is
|
|
557
|
+
* unreadable, so dating a row buys it nothing. `legacyRows` counts every parsed
|
|
558
|
+
* row the date rule removes from the contract, whatever its disposition — the
|
|
559
|
+
* counters describe the ledger's age, not its debt — and `undatedRows` is their
|
|
560
|
+
* no-date subset.
|
|
561
|
+
*
|
|
562
|
+
* A disposition outside `open`/`accepted`/`deferred` is out of the contract by
|
|
563
|
+
* design, not by omission: the aliased MCP roll-up tables put free text in that
|
|
564
|
+
* column, so the three classes are the contract and `checked` counts the rest.
|
|
565
|
+
*
|
|
566
|
+
* `followUp` must name a *different* task: a row that points at the task which
|
|
567
|
+
* filed it resolves to a directory while closing nothing, so the check refuses
|
|
568
|
+
* the self-reference when the caller knows the task (`taskSlug`).
|
|
569
|
+
* @returns {{ failures: string[], legacyRows: number, undatedRows: number }}
|
|
570
|
+
*/
|
|
571
|
+
export function validateLedgerRows(rows, options = {}) {
|
|
572
|
+
const teamRoot = options.teamRoot ?? DEFAULT_TEAM_ROOT;
|
|
573
|
+
const today = options.today ?? new Date().toISOString().slice(0, 10);
|
|
574
|
+
const taskSlug = options.taskSlug ?? null;
|
|
575
|
+
const failures = [];
|
|
576
|
+
let legacyRows = 0;
|
|
577
|
+
let undatedRows = 0;
|
|
578
|
+
for (const row of rows ?? []) {
|
|
579
|
+
const id = row.id || 'RL-?';
|
|
580
|
+
const date = ledgerRowDate(row.at);
|
|
581
|
+
if (date === null) {
|
|
582
|
+
legacyRows += 1;
|
|
583
|
+
undatedRows += 1;
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
if (date < LEDGER_OWNER_CUTOFF) {
|
|
587
|
+
legacyRows += 1;
|
|
588
|
+
continue;
|
|
589
|
+
}
|
|
590
|
+
const disposition = ledgerDispositionClass(row.dispositionRaw ?? row.disposition);
|
|
591
|
+
if (!LEDGER_OWNER_DISPOSITIONS.has(disposition)) continue;
|
|
592
|
+
if (!row.headerMapsOwner) {
|
|
593
|
+
failures.push(
|
|
594
|
+
`${id}: owner is unreadable because the table header has no owner column — ` +
|
|
595
|
+
`move the table to the canonical header ${LEDGER_HEADER_ROW}`,
|
|
596
|
+
);
|
|
597
|
+
continue;
|
|
598
|
+
}
|
|
599
|
+
const ownerCell = String(row.owner ?? '').trim();
|
|
600
|
+
if (ownerCell === '') {
|
|
601
|
+
failures.push(
|
|
602
|
+
`${id}: owner is empty for disposition ${disposition} — ` +
|
|
603
|
+
'name the person who owns the finding, or close the row as fixed/rejected',
|
|
604
|
+
);
|
|
605
|
+
} else if (OWNER_PLACEHOLDER_SET.has(normalizeOwnerToken(ownerCell))) {
|
|
606
|
+
failures.push(
|
|
607
|
+
`${id}: owner "${ownerCell}" is a placeholder — ` +
|
|
608
|
+
'name the person who owns the finding, or close the row as fixed/rejected',
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
const due = String(row.due ?? '').trim();
|
|
612
|
+
if (due === '') {
|
|
613
|
+
failures.push(`${id}: due is empty for disposition ${disposition} — add due as YYYY-MM-DD`);
|
|
614
|
+
} else if (!LEDGER_DUE_RE.test(due)) {
|
|
615
|
+
failures.push(`${id}: due "${due}" is not YYYY-MM-DD — write the date as YYYY-MM-DD`);
|
|
616
|
+
} else if (due < today) {
|
|
617
|
+
failures.push(
|
|
618
|
+
`${id}: due ${due} is before the check date ${today} (UTC) — set a current date, or close the row as fixed/rejected`,
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
const followUpCell = String(row.followUp ?? '').trim();
|
|
622
|
+
if (followUpCell === '') {
|
|
623
|
+
if (disposition === 'accepted' || disposition === 'deferred') {
|
|
624
|
+
failures.push(
|
|
625
|
+
`${id}: followUp is empty for disposition ${disposition} — ` +
|
|
626
|
+
'name the follow-up task slug as "<slug>" or "blocked-on: <slug>"',
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
const slug = followUpCell.replace(FOLLOW_UP_PREFIX_RE, '').trim();
|
|
632
|
+
if (slug.length > 48 || !SLUG_RE.test(slug)) {
|
|
633
|
+
failures.push(
|
|
634
|
+
`${id}: followUp "${followUpCell}" is not a single task slug — write "<slug>" or "blocked-on: <slug>"`,
|
|
635
|
+
);
|
|
636
|
+
} else if (!ledgerTaskDirectory(teamRoot, slug)) {
|
|
637
|
+
failures.push(
|
|
638
|
+
`${id}: followUp names "${slug}" but ${path.join(teamRoot, 'tasks', slug)} is not a task directory — ` +
|
|
639
|
+
'create the task first, or fix the slug',
|
|
640
|
+
);
|
|
641
|
+
} else if (taskSlug !== null && slug === taskSlug) {
|
|
642
|
+
failures.push(
|
|
643
|
+
`${id}: followUp names this task ("${slug}") — a follow-up is a separate task that will close the finding; ` +
|
|
644
|
+
'create it and name it, or close the row as fixed/rejected',
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
return { failures, legacyRows, undatedRows };
|
|
649
|
+
}
|
|
650
|
+
|
|
462
651
|
/**
|
|
463
652
|
* The canonical ledger is the fixed eight-column table from
|
|
464
653
|
* `agent-artifact-contracts.md`. Older task ledgers use six-column aliases
|
|
@@ -526,8 +715,13 @@ export function parseReviewLedgerMarkdown(text) {
|
|
|
526
715
|
summary,
|
|
527
716
|
fair: normalizeLedgerFair(cell('fair')),
|
|
528
717
|
disposition: normalizeLedgerDisposition(cell('disposition')),
|
|
718
|
+
dispositionRaw: (cell('disposition') ?? '').trim(),
|
|
719
|
+
owner: (cell('owner') ?? '').trim() || null,
|
|
720
|
+
due: (cell('due') ?? '').trim() || null,
|
|
721
|
+
followUp: (cell('followUp') ?? '').trim() || null,
|
|
529
722
|
evidence: cell('evidence') || null,
|
|
530
723
|
signature: cell('signature') || null,
|
|
724
|
+
headerMapsOwner: map.owner !== undefined,
|
|
531
725
|
});
|
|
532
726
|
}
|
|
533
727
|
}
|
|
@@ -1483,11 +1677,24 @@ const replaceReviewLedger = (db, slug, ledger) => {
|
|
|
1483
1677
|
db.prepare('DELETE FROM review_ledger WHERE task_slug = ?').run(slug);
|
|
1484
1678
|
if (!ledger) return;
|
|
1485
1679
|
const statement = db.prepare(
|
|
1486
|
-
`INSERT INTO review_ledger(task_slug, row_id, at, source, summary, fair, disposition, evidence, signature)
|
|
1487
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
1680
|
+
`INSERT INTO review_ledger(task_slug, row_id, at, source, summary, fair, disposition, owner, due, follow_up, evidence, signature)
|
|
1681
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
1488
1682
|
);
|
|
1489
1683
|
for (const row of ledger.rows) {
|
|
1490
|
-
statement.run(
|
|
1684
|
+
statement.run(
|
|
1685
|
+
slug,
|
|
1686
|
+
row.id,
|
|
1687
|
+
row.at,
|
|
1688
|
+
row.source,
|
|
1689
|
+
row.summary,
|
|
1690
|
+
row.fair,
|
|
1691
|
+
row.disposition,
|
|
1692
|
+
row.owner,
|
|
1693
|
+
row.due,
|
|
1694
|
+
row.followUp,
|
|
1695
|
+
row.evidence,
|
|
1696
|
+
row.signature,
|
|
1697
|
+
);
|
|
1491
1698
|
}
|
|
1492
1699
|
};
|
|
1493
1700
|
|
|
@@ -2993,6 +3200,848 @@ const resolveDeadline = (deadlineMs, slug) => {
|
|
|
2993
3200
|
|
|
2994
3201
|
const defaultDeadline = (slug) => (slug ? DEFAULT_SLUG_DEADLINE_MS : Infinity);
|
|
2995
3202
|
|
|
3203
|
+
/* --------------------------- repositories.json ---------------------------- */
|
|
3204
|
+
|
|
3205
|
+
export const REPOSITORIES_FILE = 'repositories.json';
|
|
3206
|
+
export const REPOSITORIES_LOCK = '.repositories.lock';
|
|
3207
|
+
export const REPOSITORIES_FILE_VERSION = 1;
|
|
3208
|
+
/** The closed write-time `status` vocabulary. The reader accepts anything. */
|
|
3209
|
+
export const REPOSITORY_STATUSES = ['active', 'archived'];
|
|
3210
|
+
/** Who wrote one link. The CRUD API never writes a link. */
|
|
3211
|
+
export const LINK_SOURCES = ['intake', 'backfill'];
|
|
3212
|
+
/** The two verdicts that resolve to a link. */
|
|
3213
|
+
export const LINK_INFERENCES = ['evidence-paths', 'repo-scope-only'];
|
|
3214
|
+
/** The two verdicts that resolve to no repository. */
|
|
3215
|
+
export const ATTRIBUTION_VERDICTS = ['unknown', 'ambiguous'];
|
|
3216
|
+
export const DECLARED_REPOSITORY_KEYS = [
|
|
3217
|
+
'id',
|
|
3218
|
+
'name',
|
|
3219
|
+
'locator',
|
|
3220
|
+
'description',
|
|
3221
|
+
'labels',
|
|
3222
|
+
'status',
|
|
3223
|
+
'revision',
|
|
3224
|
+
'createdAt',
|
|
3225
|
+
'updatedAt',
|
|
3226
|
+
];
|
|
3227
|
+
export const DECLARED_LINK_KEYS = [
|
|
3228
|
+
'taskSlug',
|
|
3229
|
+
'repositoryId',
|
|
3230
|
+
'addedAt',
|
|
3231
|
+
'source',
|
|
3232
|
+
'inference',
|
|
3233
|
+
'evidence',
|
|
3234
|
+
];
|
|
3235
|
+
export const DECLARED_ATTRIBUTION_KEYS = ['taskSlug', 'verdict', 'evidence', 'recordedAt', 'source'];
|
|
3236
|
+
|
|
3237
|
+
const REPOSITORY_ID_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
3238
|
+
const MAX_REPOSITORY_ID_LENGTH = 48;
|
|
3239
|
+
const MAX_REPOSITORY_NAME_LENGTH = 120;
|
|
3240
|
+
const MAX_REPOSITORY_LOCATOR_LENGTH = 512;
|
|
3241
|
+
const MAX_REPOSITORY_DESCRIPTION_LENGTH = 2000;
|
|
3242
|
+
const MAX_REPOSITORY_LABELS = 24;
|
|
3243
|
+
const MAX_REPOSITORY_LABEL_LENGTH = 48;
|
|
3244
|
+
const MAX_LINK_EVIDENCE_LENGTH = 300;
|
|
3245
|
+
|
|
3246
|
+
/** Every path the registry owns under one team root. */
|
|
3247
|
+
export function repositoriesPaths(teamRoot) {
|
|
3248
|
+
const root = resolveTeamRoot(teamRoot);
|
|
3249
|
+
return {
|
|
3250
|
+
root,
|
|
3251
|
+
file: path.join(root, REPOSITORIES_FILE),
|
|
3252
|
+
lock: path.join(root, REPOSITORIES_LOCK),
|
|
3253
|
+
};
|
|
3254
|
+
}
|
|
3255
|
+
|
|
3256
|
+
const failRepositoryField = (parameter, detail) => {
|
|
3257
|
+
const error = new TeamDbError('E_VALIDATION', `parameter "${parameter}": ${detail}`, 3);
|
|
3258
|
+
error.parameter = parameter;
|
|
3259
|
+
throw error;
|
|
3260
|
+
};
|
|
3261
|
+
|
|
3262
|
+
const repositoriesFileFailure = (detail) => teamDbFail('E_REPOSITORIES_PARSE', detail, 1);
|
|
3263
|
+
|
|
3264
|
+
const assertRepositoryKeys = (record, allowed, prefix) => {
|
|
3265
|
+
for (const key of Object.keys(record)) {
|
|
3266
|
+
if (!allowed.includes(key)) repositoriesFileFailure(`${prefix}${key}: unknown key`);
|
|
3267
|
+
}
|
|
3268
|
+
};
|
|
3269
|
+
|
|
3270
|
+
const repositoryText = (value, parameter, { min = 0, max } = {}) => {
|
|
3271
|
+
if (typeof value !== 'string' || value.length < min || (max !== undefined && value.length > max)) {
|
|
3272
|
+
repositoriesFileFailure(
|
|
3273
|
+
`"${parameter}" must be a string of ${min}-${max ?? 'unbounded'} characters`,
|
|
3274
|
+
);
|
|
3275
|
+
}
|
|
3276
|
+
return value;
|
|
3277
|
+
};
|
|
3278
|
+
|
|
3279
|
+
const repositoryIso = (value, parameter) => {
|
|
3280
|
+
if (typeof value !== 'string' || Number.isNaN(Date.parse(value))) {
|
|
3281
|
+
repositoriesFileFailure(`"${parameter}" must be an ISO 8601 timestamp`);
|
|
3282
|
+
}
|
|
3283
|
+
return value;
|
|
3284
|
+
};
|
|
3285
|
+
|
|
3286
|
+
/**
|
|
3287
|
+
* Validate one stored record and normalize it into the declared key order.
|
|
3288
|
+
*
|
|
3289
|
+
* The reader is strict about shapes and permissive about `status`: the write
|
|
3290
|
+
* verbs refuse an out-of-vocabulary status with `E_VALIDATION`, and the
|
|
3291
|
+
* projection serves whatever a hand-edited file says.
|
|
3292
|
+
*/
|
|
3293
|
+
const readRepositoryRecord = (entry, path_) => {
|
|
3294
|
+
if (!isRecord(entry)) repositoriesFileFailure(`${path_}: a repository must be an object`);
|
|
3295
|
+
assertRepositoryKeys(entry, DECLARED_REPOSITORY_KEYS, `${path_}: `);
|
|
3296
|
+
const id = entry.id;
|
|
3297
|
+
if (
|
|
3298
|
+
typeof id !== 'string' ||
|
|
3299
|
+
!REPOSITORY_ID_RE.test(id) ||
|
|
3300
|
+
id.length < 1 ||
|
|
3301
|
+
id.length > MAX_REPOSITORY_ID_LENGTH
|
|
3302
|
+
) {
|
|
3303
|
+
repositoriesFileFailure(`${path_}: "id" must match ${REPOSITORY_ID_RE.source} and be 1-48 characters`);
|
|
3304
|
+
}
|
|
3305
|
+
const description = entry.description ?? null;
|
|
3306
|
+
if (description !== null) repositoryText(description, 'description', { max: MAX_REPOSITORY_DESCRIPTION_LENGTH });
|
|
3307
|
+
const labels = entry.labels ?? null;
|
|
3308
|
+
if (labels !== null) {
|
|
3309
|
+
if (
|
|
3310
|
+
!Array.isArray(labels) ||
|
|
3311
|
+
labels.length > MAX_REPOSITORY_LABELS ||
|
|
3312
|
+
labels.some((label) => typeof label !== 'string' || label.length < 1 || label.length > MAX_REPOSITORY_LABEL_LENGTH)
|
|
3313
|
+
) {
|
|
3314
|
+
repositoriesFileFailure(`${path_}: "labels" must be null or at most 24 strings of 1-48 characters`);
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
if (!Number.isInteger(entry.revision) || entry.revision < 1) {
|
|
3318
|
+
repositoriesFileFailure(`${path_}: "revision" must be an integer of at least 1`);
|
|
3319
|
+
}
|
|
3320
|
+
return {
|
|
3321
|
+
id,
|
|
3322
|
+
name: repositoryText(entry.name, 'name', { min: 1, max: MAX_REPOSITORY_NAME_LENGTH }),
|
|
3323
|
+
locator: repositoryText(entry.locator, 'locator', { min: 1, max: MAX_REPOSITORY_LOCATOR_LENGTH }),
|
|
3324
|
+
description,
|
|
3325
|
+
labels: labels === null ? null : [...labels],
|
|
3326
|
+
status: repositoryText(entry.status, 'status', { min: 1 }),
|
|
3327
|
+
revision: entry.revision,
|
|
3328
|
+
createdAt: repositoryIso(entry.createdAt, 'createdAt'),
|
|
3329
|
+
updatedAt: repositoryIso(entry.updatedAt, 'updatedAt'),
|
|
3330
|
+
};
|
|
3331
|
+
};
|
|
3332
|
+
|
|
3333
|
+
const readLinkRecord = (entry, path_) => {
|
|
3334
|
+
if (!isRecord(entry)) repositoriesFileFailure(`${path_}: a link must be an object`);
|
|
3335
|
+
assertRepositoryKeys(entry, DECLARED_LINK_KEYS, `${path_}: `);
|
|
3336
|
+
if (typeof entry.taskSlug !== 'string' || !SLUG_RE.test(entry.taskSlug)) {
|
|
3337
|
+
repositoriesFileFailure(`${path_}: "taskSlug" must be a task slug`);
|
|
3338
|
+
}
|
|
3339
|
+
return {
|
|
3340
|
+
taskSlug: entry.taskSlug,
|
|
3341
|
+
repositoryId: repositoryText(entry.repositoryId, 'repositoryId', { min: 1 }),
|
|
3342
|
+
addedAt: repositoryIso(entry.addedAt, 'addedAt'),
|
|
3343
|
+
source: repositoryText(entry.source, 'source', { min: 1 }),
|
|
3344
|
+
inference: repositoryText(entry.inference, 'inference', { min: 1 }),
|
|
3345
|
+
evidence: repositoryText(entry.evidence ?? '', 'evidence', { max: MAX_LINK_EVIDENCE_LENGTH }),
|
|
3346
|
+
};
|
|
3347
|
+
};
|
|
3348
|
+
|
|
3349
|
+
const readAttributionRecord = (entry, path_) => {
|
|
3350
|
+
if (!isRecord(entry)) repositoriesFileFailure(`${path_}: an attribution must be an object`);
|
|
3351
|
+
assertRepositoryKeys(entry, DECLARED_ATTRIBUTION_KEYS, `${path_}: `);
|
|
3352
|
+
if (typeof entry.taskSlug !== 'string' || !SLUG_RE.test(entry.taskSlug)) {
|
|
3353
|
+
repositoriesFileFailure(`${path_}: "taskSlug" must be a task slug`);
|
|
3354
|
+
}
|
|
3355
|
+
return {
|
|
3356
|
+
taskSlug: entry.taskSlug,
|
|
3357
|
+
verdict: repositoryText(entry.verdict, 'verdict', { min: 1 }),
|
|
3358
|
+
evidence: repositoryText(entry.evidence ?? '', 'evidence', { max: MAX_LINK_EVIDENCE_LENGTH }),
|
|
3359
|
+
recordedAt: repositoryIso(entry.recordedAt, 'recordedAt'),
|
|
3360
|
+
source: repositoryText(entry.source, 'source', { min: 1 }),
|
|
3361
|
+
};
|
|
3362
|
+
};
|
|
3363
|
+
|
|
3364
|
+
/**
|
|
3365
|
+
* Read `repositories.json`. An absent file is an empty valid store.
|
|
3366
|
+
*
|
|
3367
|
+
* A malformed file is a named failure: the caller never writes over it, and
|
|
3368
|
+
* the projection records the error without tombstoning a row.
|
|
3369
|
+
*/
|
|
3370
|
+
export function readRepositoriesFile(teamRoot) {
|
|
3371
|
+
const paths = repositoriesPaths(teamRoot);
|
|
3372
|
+
let text;
|
|
3373
|
+
try {
|
|
3374
|
+
text = fs.readFileSync(paths.file, 'utf8');
|
|
3375
|
+
} catch (error) {
|
|
3376
|
+
if (error.code === 'ENOENT') {
|
|
3377
|
+
return {
|
|
3378
|
+
version: REPOSITORIES_FILE_VERSION,
|
|
3379
|
+
repositories: [],
|
|
3380
|
+
links: [],
|
|
3381
|
+
attributions: [],
|
|
3382
|
+
present: false,
|
|
3383
|
+
};
|
|
3384
|
+
}
|
|
3385
|
+
repositoriesFileFailure(`${paths.file}: ${error.message}`);
|
|
3386
|
+
}
|
|
3387
|
+
let parsed;
|
|
3388
|
+
try {
|
|
3389
|
+
parsed = JSON.parse(text);
|
|
3390
|
+
} catch (error) {
|
|
3391
|
+
repositoriesFileFailure(`${paths.file}: not valid JSON (${error.message})`);
|
|
3392
|
+
}
|
|
3393
|
+
if (!isRecord(parsed)) repositoriesFileFailure(`${paths.file}: top level must be an object`);
|
|
3394
|
+
for (const key of Object.keys(parsed)) {
|
|
3395
|
+
if (!['version', 'repositories', 'links', 'attributions'].includes(key)) {
|
|
3396
|
+
repositoriesFileFailure(`${paths.file}: unknown top-level key "${key}"`);
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3399
|
+
if (parsed.version !== REPOSITORIES_FILE_VERSION) {
|
|
3400
|
+
repositoriesFileFailure(
|
|
3401
|
+
`${paths.file}: version must be ${REPOSITORIES_FILE_VERSION}, got ${JSON.stringify(parsed.version)}`,
|
|
3402
|
+
);
|
|
3403
|
+
}
|
|
3404
|
+
if (!Array.isArray(parsed.repositories)) repositoriesFileFailure(`${paths.file}: "repositories" must be an array`);
|
|
3405
|
+
if (!Array.isArray(parsed.links)) repositoriesFileFailure(`${paths.file}: "links" must be an array`);
|
|
3406
|
+
if (!Array.isArray(parsed.attributions)) repositoriesFileFailure(`${paths.file}: "attributions" must be an array`);
|
|
3407
|
+
|
|
3408
|
+
const seen = new Set();
|
|
3409
|
+
const repositories = parsed.repositories.map((entry) => {
|
|
3410
|
+
const record = readRepositoryRecord(entry, paths.file);
|
|
3411
|
+
if (seen.has(record.id)) repositoriesFileFailure(`${paths.file}: duplicate repository id "${record.id}"`);
|
|
3412
|
+
seen.add(record.id);
|
|
3413
|
+
return record;
|
|
3414
|
+
});
|
|
3415
|
+
const linkKeys = new Set();
|
|
3416
|
+
const links = parsed.links.map((entry) => {
|
|
3417
|
+
const link = readLinkRecord(entry, paths.file);
|
|
3418
|
+
if (!seen.has(link.repositoryId)) {
|
|
3419
|
+
repositoriesFileFailure(`${paths.file}: link names the unknown repository "${link.repositoryId}"`);
|
|
3420
|
+
}
|
|
3421
|
+
const key = `${link.taskSlug}\u0000${link.repositoryId}`;
|
|
3422
|
+
if (linkKeys.has(key)) {
|
|
3423
|
+
repositoriesFileFailure(`${paths.file}: duplicate link "${link.taskSlug}" -> "${link.repositoryId}"`);
|
|
3424
|
+
}
|
|
3425
|
+
linkKeys.add(key);
|
|
3426
|
+
return link;
|
|
3427
|
+
});
|
|
3428
|
+
const attributed = new Set();
|
|
3429
|
+
const attributions = parsed.attributions.map((entry) => {
|
|
3430
|
+
const attribution = readAttributionRecord(entry, paths.file);
|
|
3431
|
+
if (attributed.has(attribution.taskSlug)) {
|
|
3432
|
+
repositoriesFileFailure(`${paths.file}: duplicate attribution for "${attribution.taskSlug}"`);
|
|
3433
|
+
}
|
|
3434
|
+
attributed.add(attribution.taskSlug);
|
|
3435
|
+
return attribution;
|
|
3436
|
+
});
|
|
3437
|
+
// ADR §4 / I-1: one task carries a link or a verdict, never both. A file
|
|
3438
|
+
// holding both is a hand-edit bug, so the reader names it instead of picking.
|
|
3439
|
+
const linkedSlugs = new Set(links.map((link) => link.taskSlug));
|
|
3440
|
+
for (const attribution of attributions) {
|
|
3441
|
+
if (linkedSlugs.has(attribution.taskSlug)) {
|
|
3442
|
+
repositoriesFileFailure(
|
|
3443
|
+
`${paths.file}: "${attribution.taskSlug}" carries both a link and an attribution; a task has one or the other`,
|
|
3444
|
+
);
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
return { version: REPOSITORIES_FILE_VERSION, repositories, links, attributions, present: true };
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3450
|
+
const byText = (left, right) => (left < right ? -1 : left > right ? 1 : 0);
|
|
3451
|
+
|
|
3452
|
+
/**
|
|
3453
|
+
* Deterministic serialization: declared key order, records sorted by id, links
|
|
3454
|
+
* by `(taskSlug, repositoryId)`, attributions by `taskSlug`, two-space indent,
|
|
3455
|
+
* one trailing newline. An unchanged rewrite is byte-identical.
|
|
3456
|
+
*/
|
|
3457
|
+
export function serializeRepositoriesFile(document) {
|
|
3458
|
+
const repositories = [...document.repositories]
|
|
3459
|
+
.sort((left, right) => byText(left.id, right.id))
|
|
3460
|
+
.map((record) => {
|
|
3461
|
+
const output = {};
|
|
3462
|
+
for (const key of DECLARED_REPOSITORY_KEYS) output[key] = record[key];
|
|
3463
|
+
return output;
|
|
3464
|
+
});
|
|
3465
|
+
const links = [...document.links]
|
|
3466
|
+
.sort((left, right) => byText(left.taskSlug, right.taskSlug) || byText(left.repositoryId, right.repositoryId))
|
|
3467
|
+
.map((record) => {
|
|
3468
|
+
const output = {};
|
|
3469
|
+
for (const key of DECLARED_LINK_KEYS) output[key] = record[key];
|
|
3470
|
+
return output;
|
|
3471
|
+
});
|
|
3472
|
+
const attributions = [...document.attributions]
|
|
3473
|
+
.sort((left, right) => byText(left.taskSlug, right.taskSlug))
|
|
3474
|
+
.map((record) => {
|
|
3475
|
+
const output = {};
|
|
3476
|
+
for (const key of DECLARED_ATTRIBUTION_KEYS) output[key] = record[key];
|
|
3477
|
+
return output;
|
|
3478
|
+
});
|
|
3479
|
+
return `${JSON.stringify(
|
|
3480
|
+
{ version: REPOSITORIES_FILE_VERSION, repositories, links, attributions },
|
|
3481
|
+
null,
|
|
3482
|
+
2,
|
|
3483
|
+
)}\n`;
|
|
3484
|
+
}
|
|
3485
|
+
|
|
3486
|
+
const writeAtomicRepositoriesFile = (filePath, content) => {
|
|
3487
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
3488
|
+
const temporary = `${filePath}.tmp`;
|
|
3489
|
+
fs.writeFileSync(temporary, content, { encoding: 'utf8', mode: 0o600 });
|
|
3490
|
+
fs.renameSync(temporary, filePath);
|
|
3491
|
+
};
|
|
3492
|
+
|
|
3493
|
+
/** Write the registry atomically; an identical rewrite performs no write. */
|
|
3494
|
+
export function writeRepositoriesFile(teamRoot, document) {
|
|
3495
|
+
const paths = repositoriesPaths(teamRoot);
|
|
3496
|
+
const content = serializeRepositoriesFile(document);
|
|
3497
|
+
try {
|
|
3498
|
+
if (fs.readFileSync(paths.file, 'utf8') === content) return false;
|
|
3499
|
+
} catch {
|
|
3500
|
+
/* absent or unreadable: write it */
|
|
3501
|
+
}
|
|
3502
|
+
writeAtomicRepositoriesFile(paths.file, content);
|
|
3503
|
+
return true;
|
|
3504
|
+
}
|
|
3505
|
+
|
|
3506
|
+
const repositoryContentHash = (record) => sha256(canonicalJson(record));
|
|
3507
|
+
const linkContentHash = (link) => sha256(canonicalJson(link));
|
|
3508
|
+
|
|
3509
|
+
const UPSERT_REPOSITORY_SQL = `
|
|
3510
|
+
INSERT INTO repositories(
|
|
3511
|
+
id, name, locator, description, labels_json, status, revision, created_at,
|
|
3512
|
+
updated_at, content_hash, parse_error, projected_at, first_seen_at,
|
|
3513
|
+
last_seen_at, absent_at
|
|
3514
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, ?, ?, ?, NULL)
|
|
3515
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
3516
|
+
name = excluded.name,
|
|
3517
|
+
locator = excluded.locator,
|
|
3518
|
+
description = excluded.description,
|
|
3519
|
+
labels_json = excluded.labels_json,
|
|
3520
|
+
status = excluded.status,
|
|
3521
|
+
revision = excluded.revision,
|
|
3522
|
+
created_at = excluded.created_at,
|
|
3523
|
+
updated_at = excluded.updated_at,
|
|
3524
|
+
content_hash = excluded.content_hash,
|
|
3525
|
+
parse_error = NULL,
|
|
3526
|
+
projected_at = excluded.projected_at,
|
|
3527
|
+
last_seen_at = excluded.last_seen_at,
|
|
3528
|
+
absent_at = NULL
|
|
3529
|
+
`;
|
|
3530
|
+
|
|
3531
|
+
const INSERT_LINK_SQL = `
|
|
3532
|
+
INSERT INTO task_repositories(
|
|
3533
|
+
task_slug, repository_id, added_at, source, inference, evidence, content_hash, projected_at
|
|
3534
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
3535
|
+
`;
|
|
3536
|
+
|
|
3537
|
+
const INSERT_ATTRIBUTION_SQL = `
|
|
3538
|
+
INSERT INTO task_repository_attributions(task_slug, verdict, content_hash, projected_at)
|
|
3539
|
+
VALUES (?, ?, ?, ?)
|
|
3540
|
+
`;
|
|
3541
|
+
|
|
3542
|
+
const projectRepositoryRecord = (db, record, now) => {
|
|
3543
|
+
const hash = repositoryContentHash(record);
|
|
3544
|
+
const existing = db.prepare('SELECT content_hash, first_seen_at FROM repositories WHERE id = ?1').get(record.id);
|
|
3545
|
+
if (existing && existing.content_hash === hash) {
|
|
3546
|
+
// An unchanged record only moves its inventory columns.
|
|
3547
|
+
db.prepare('UPDATE repositories SET projected_at = ?2, last_seen_at = ?2, absent_at = NULL WHERE id = ?1').run(
|
|
3548
|
+
record.id,
|
|
3549
|
+
now,
|
|
3550
|
+
);
|
|
3551
|
+
return;
|
|
3552
|
+
}
|
|
3553
|
+
db.prepare(UPSERT_REPOSITORY_SQL).run(
|
|
3554
|
+
record.id,
|
|
3555
|
+
record.name,
|
|
3556
|
+
record.locator,
|
|
3557
|
+
record.description,
|
|
3558
|
+
record.labels === null ? null : canonicalJson(record.labels),
|
|
3559
|
+
record.status,
|
|
3560
|
+
record.revision,
|
|
3561
|
+
record.createdAt,
|
|
3562
|
+
record.updatedAt,
|
|
3563
|
+
hash,
|
|
3564
|
+
now,
|
|
3565
|
+
existing ? existing.first_seen_at : now,
|
|
3566
|
+
now,
|
|
3567
|
+
);
|
|
3568
|
+
};
|
|
3569
|
+
|
|
3570
|
+
/**
|
|
3571
|
+
* Project the registry into `team.db`.
|
|
3572
|
+
*
|
|
3573
|
+
* `scope` narrows a write child to the rows its payload touched: the named
|
|
3574
|
+
* repository ids and the named task slugs. Without a scope the whole file is
|
|
3575
|
+
* projected, absent records are tombstoned and pruned, and the link and
|
|
3576
|
+
* attribution tables are replaced together.
|
|
3577
|
+
*
|
|
3578
|
+
* A malformed file records the failure and touches no row.
|
|
3579
|
+
*/
|
|
3580
|
+
export function projectRepositories(db, options = {}) {
|
|
3581
|
+
const teamRoot = resolveTeamRoot(options.teamRoot);
|
|
3582
|
+
const now = options.now ?? new Date().toISOString();
|
|
3583
|
+
const scope = options.scope ?? null;
|
|
3584
|
+
const result = { repositories: 0, links: 0, attributions: 0, absent: 0, pruned: 0, failed: 0, errors: [] };
|
|
3585
|
+
let file;
|
|
3586
|
+
try {
|
|
3587
|
+
file = readRepositoriesFile(teamRoot);
|
|
3588
|
+
} catch (error) {
|
|
3589
|
+
result.failed += 1;
|
|
3590
|
+
result.errors.push({ path: repositoriesPaths(teamRoot).file, reason: error.message });
|
|
3591
|
+
return result;
|
|
3592
|
+
}
|
|
3593
|
+
|
|
3594
|
+
const inRepositoryScope = (id) => scope === null || scope.repositoryIds.includes(id);
|
|
3595
|
+
const inTaskScope = (slug) => scope === null || scope.taskSlugs.includes(slug);
|
|
3596
|
+
const known = new Set(file.repositories.map((record) => record.id));
|
|
3597
|
+
|
|
3598
|
+
db.exec('BEGIN IMMEDIATE');
|
|
3599
|
+
try {
|
|
3600
|
+
for (const record of file.repositories) {
|
|
3601
|
+
if (!inRepositoryScope(record.id)) continue;
|
|
3602
|
+
projectRepositoryRecord(db, record, now);
|
|
3603
|
+
result.repositories += 1;
|
|
3604
|
+
}
|
|
3605
|
+
|
|
3606
|
+
if (scope === null) {
|
|
3607
|
+
result.absent += db
|
|
3608
|
+
.prepare('UPDATE repositories SET absent_at = ? WHERE absent_at IS NULL')
|
|
3609
|
+
.run(now).changes;
|
|
3610
|
+
// The full sync owns the tombstones: an id pruned here would take its
|
|
3611
|
+
// links with it, and the file is the one definition of record.
|
|
3612
|
+
const stale = db.prepare('SELECT id FROM repositories WHERE absent_at IS NOT NULL').all();
|
|
3613
|
+
for (const row of stale) {
|
|
3614
|
+
if (known.has(row.id)) {
|
|
3615
|
+
db.prepare('UPDATE repositories SET absent_at = NULL WHERE id = ?').run(row.id);
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
}
|
|
3619
|
+
|
|
3620
|
+
if (scope === null) {
|
|
3621
|
+
db.prepare('DELETE FROM task_repositories').run();
|
|
3622
|
+
db.prepare('DELETE FROM task_repository_attributions').run();
|
|
3623
|
+
} else {
|
|
3624
|
+
for (const slug of scope.taskSlugs) {
|
|
3625
|
+
db.prepare('DELETE FROM task_repositories WHERE task_slug = ?').run(slug);
|
|
3626
|
+
db.prepare('DELETE FROM task_repository_attributions WHERE task_slug = ?').run(slug);
|
|
3627
|
+
}
|
|
3628
|
+
}
|
|
3629
|
+
|
|
3630
|
+
for (const link of file.links) {
|
|
3631
|
+
if (!inTaskScope(link.taskSlug)) continue;
|
|
3632
|
+
if (!known.has(link.repositoryId)) continue;
|
|
3633
|
+
db.prepare(INSERT_LINK_SQL).run(
|
|
3634
|
+
link.taskSlug,
|
|
3635
|
+
link.repositoryId,
|
|
3636
|
+
link.addedAt,
|
|
3637
|
+
link.source,
|
|
3638
|
+
link.inference,
|
|
3639
|
+
link.evidence,
|
|
3640
|
+
linkContentHash(link),
|
|
3641
|
+
now,
|
|
3642
|
+
);
|
|
3643
|
+
result.links += 1;
|
|
3644
|
+
}
|
|
3645
|
+
for (const attribution of file.attributions) {
|
|
3646
|
+
if (!inTaskScope(attribution.taskSlug)) continue;
|
|
3647
|
+
db.prepare(INSERT_ATTRIBUTION_SQL).run(
|
|
3648
|
+
attribution.taskSlug,
|
|
3649
|
+
attribution.verdict,
|
|
3650
|
+
sha256(canonicalJson({ taskSlug: attribution.taskSlug, verdict: attribution.verdict })),
|
|
3651
|
+
now,
|
|
3652
|
+
);
|
|
3653
|
+
result.attributions += 1;
|
|
3654
|
+
}
|
|
3655
|
+
|
|
3656
|
+
if (scope === null) {
|
|
3657
|
+
result.pruned += db.prepare('DELETE FROM repositories WHERE absent_at IS NOT NULL').run().changes;
|
|
3658
|
+
} else {
|
|
3659
|
+
for (const id of scope.repositoryIds) {
|
|
3660
|
+
if (known.has(id)) continue;
|
|
3661
|
+
result.pruned += db.prepare('DELETE FROM repositories WHERE id = ?').run(id).changes;
|
|
3662
|
+
}
|
|
3663
|
+
}
|
|
3664
|
+
db.exec('COMMIT');
|
|
3665
|
+
} catch (error) {
|
|
3666
|
+
try {
|
|
3667
|
+
db.exec('ROLLBACK');
|
|
3668
|
+
} catch {
|
|
3669
|
+
/* the primary failure is the finding */
|
|
3670
|
+
}
|
|
3671
|
+
throw error;
|
|
3672
|
+
}
|
|
3673
|
+
return result;
|
|
3674
|
+
}
|
|
3675
|
+
|
|
3676
|
+
const projectRepositoriesInChild = (teamRoot, scope, env = process.env) => {
|
|
3677
|
+
if (!isSqliteAvailable(env)) return null;
|
|
3678
|
+
const handle = openTeamDb({ teamRoot });
|
|
3679
|
+
try {
|
|
3680
|
+
return projectRepositories(handle.db, { teamRoot: handle.teamRoot, scope });
|
|
3681
|
+
} finally {
|
|
3682
|
+
handle.db.close();
|
|
3683
|
+
}
|
|
3684
|
+
};
|
|
3685
|
+
|
|
3686
|
+
const renderJson = (value) => `${JSON.stringify(value)}\n`;
|
|
3687
|
+
|
|
3688
|
+
/**
|
|
3689
|
+
* Validate one `RepositoryWrite` body and normalize it into the record shape.
|
|
3690
|
+
*
|
|
3691
|
+
* `status` is the only closed vocabulary the write path enforces; the record's
|
|
3692
|
+
* `createdAt` and `updatedAt` belong to the writer, not to the client.
|
|
3693
|
+
*/
|
|
3694
|
+
export function validateRepositoryWrite(input) {
|
|
3695
|
+
if (!isRecord(input)) failRepositoryField('repository', 'must be an object');
|
|
3696
|
+
assertRepositoryKeys(
|
|
3697
|
+
input,
|
|
3698
|
+
[...DECLARED_REPOSITORY_KEYS, 'revision'],
|
|
3699
|
+
'',
|
|
3700
|
+
);
|
|
3701
|
+
const id = input.id;
|
|
3702
|
+
if (
|
|
3703
|
+
typeof id !== 'string' ||
|
|
3704
|
+
!REPOSITORY_ID_RE.test(id) ||
|
|
3705
|
+
id.length < 1 ||
|
|
3706
|
+
id.length > MAX_REPOSITORY_ID_LENGTH
|
|
3707
|
+
) {
|
|
3708
|
+
failRepositoryField('id', `must match ${REPOSITORY_ID_RE.source} and be 1-48 characters`);
|
|
3709
|
+
}
|
|
3710
|
+
const name = input.name;
|
|
3711
|
+
if (typeof name !== 'string' || name.trim().length < 1 || name.length > MAX_REPOSITORY_NAME_LENGTH) {
|
|
3712
|
+
failRepositoryField('name', `must be 1-${MAX_REPOSITORY_NAME_LENGTH} characters`);
|
|
3713
|
+
}
|
|
3714
|
+
const locator = input.locator;
|
|
3715
|
+
if (typeof locator !== 'string' || locator.trim().length < 1 || locator.length > MAX_REPOSITORY_LOCATOR_LENGTH) {
|
|
3716
|
+
failRepositoryField('locator', `must be 1-${MAX_REPOSITORY_LOCATOR_LENGTH} characters`);
|
|
3717
|
+
}
|
|
3718
|
+
const description = input.description ?? null;
|
|
3719
|
+
if (description !== null && (typeof description !== 'string' || description.length > MAX_REPOSITORY_DESCRIPTION_LENGTH)) {
|
|
3720
|
+
failRepositoryField('description', `must be null or at most ${MAX_REPOSITORY_DESCRIPTION_LENGTH} characters`);
|
|
3721
|
+
}
|
|
3722
|
+
const labels = input.labels ?? null;
|
|
3723
|
+
if (labels !== null) {
|
|
3724
|
+
if (
|
|
3725
|
+
!Array.isArray(labels) ||
|
|
3726
|
+
labels.length > MAX_REPOSITORY_LABELS ||
|
|
3727
|
+
labels.some((label) => typeof label !== 'string' || label.length < 1 || label.length > MAX_REPOSITORY_LABEL_LENGTH)
|
|
3728
|
+
) {
|
|
3729
|
+
failRepositoryField('labels', `must be null or at most ${MAX_REPOSITORY_LABELS} strings of 1-${MAX_REPOSITORY_LABEL_LENGTH} characters`);
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3732
|
+
if (typeof input.status !== 'string' || !REPOSITORY_STATUSES.includes(input.status)) {
|
|
3733
|
+
failRepositoryField('status', `must be one of ${REPOSITORY_STATUSES.join(', ')}`);
|
|
3734
|
+
}
|
|
3735
|
+
if (input.revision !== undefined && (!Number.isInteger(input.revision) || input.revision < 1)) {
|
|
3736
|
+
failRepositoryField('revision', 'must be an integer of at least 1');
|
|
3737
|
+
}
|
|
3738
|
+
return {
|
|
3739
|
+
id,
|
|
3740
|
+
name: name.trim(),
|
|
3741
|
+
locator: locator.trim(),
|
|
3742
|
+
description: description === null ? null : description,
|
|
3743
|
+
labels: labels === null ? null : [...labels],
|
|
3744
|
+
status: input.status,
|
|
3745
|
+
revision: input.revision,
|
|
3746
|
+
};
|
|
3747
|
+
}
|
|
3748
|
+
|
|
3749
|
+
const withRepositoriesLock = (teamRoot, run) => {
|
|
3750
|
+
const paths = repositoriesPaths(teamRoot);
|
|
3751
|
+
fs.mkdirSync(paths.root, { recursive: true });
|
|
3752
|
+
let token = null;
|
|
3753
|
+
try {
|
|
3754
|
+
token = acquireLock(paths.lock, { timeoutMs: 5000 });
|
|
3755
|
+
} catch (error) {
|
|
3756
|
+
teamDbFail('E_REPOSITORIES_BUSY', `could not take the repositories lock at ${paths.lock}: ${error.message}`, 4);
|
|
3757
|
+
}
|
|
3758
|
+
try {
|
|
3759
|
+
return run(paths);
|
|
3760
|
+
} finally {
|
|
3761
|
+
releaseLock(paths.lock, token);
|
|
3762
|
+
}
|
|
3763
|
+
};
|
|
3764
|
+
|
|
3765
|
+
const applyPayload = (file, payload, now) => {
|
|
3766
|
+
if (!isRecord(payload)) failRepositoryField('payload', 'must be an object');
|
|
3767
|
+
for (const key of Object.keys(payload)) {
|
|
3768
|
+
if (!['repositories', 'links', 'attributions'].includes(key)) failRepositoryField(key, 'unknown key');
|
|
3769
|
+
}
|
|
3770
|
+
const repositories = [...file.repositories];
|
|
3771
|
+
const addedRecords = [];
|
|
3772
|
+
for (const entry of payload.repositories ?? []) {
|
|
3773
|
+
const written = validateRepositoryWrite({ ...entry, revision: undefined });
|
|
3774
|
+
if (repositories.some((record) => record.id === written.id)) continue;
|
|
3775
|
+
const record = {
|
|
3776
|
+
id: written.id,
|
|
3777
|
+
name: written.name,
|
|
3778
|
+
locator: written.locator,
|
|
3779
|
+
description: written.description,
|
|
3780
|
+
labels: written.labels,
|
|
3781
|
+
status: written.status,
|
|
3782
|
+
revision: 1,
|
|
3783
|
+
createdAt: now,
|
|
3784
|
+
updatedAt: now,
|
|
3785
|
+
};
|
|
3786
|
+
repositories.push(record);
|
|
3787
|
+
addedRecords.push(record);
|
|
3788
|
+
}
|
|
3789
|
+
const knownIds = new Set(repositories.map((record) => record.id));
|
|
3790
|
+
const links = [...file.links];
|
|
3791
|
+
const addedLinks = [];
|
|
3792
|
+
for (const entry of payload.links ?? []) {
|
|
3793
|
+
if (!isRecord(entry)) failRepositoryField('link', 'must be an object');
|
|
3794
|
+
if (!knownIds.has(entry.repositoryId)) {
|
|
3795
|
+
failRepositoryField('repositoryId', `names the unknown repository "${String(entry.repositoryId)}"`);
|
|
3796
|
+
}
|
|
3797
|
+
const source = entry.source ?? 'intake';
|
|
3798
|
+
if (!LINK_SOURCES.includes(source)) failRepositoryField('source', `must be one of ${LINK_SOURCES.join(', ')}`);
|
|
3799
|
+
const inference = entry.inference ?? 'evidence-paths';
|
|
3800
|
+
if (!LINK_INFERENCES.includes(inference)) {
|
|
3801
|
+
failRepositoryField('inference', `must be one of ${LINK_INFERENCES.join(', ')}`);
|
|
3802
|
+
}
|
|
3803
|
+
if (typeof entry.taskSlug !== 'string' || !SLUG_RE.test(entry.taskSlug)) {
|
|
3804
|
+
failRepositoryField('taskSlug', 'must be a task slug');
|
|
3805
|
+
}
|
|
3806
|
+
const evidence = entry.evidence ?? '';
|
|
3807
|
+
if (typeof evidence !== 'string' || evidence.length > MAX_LINK_EVIDENCE_LENGTH) {
|
|
3808
|
+
failRepositoryField('evidence', `must be at most ${MAX_LINK_EVIDENCE_LENGTH} characters`);
|
|
3809
|
+
}
|
|
3810
|
+
const existing = links.find(
|
|
3811
|
+
(link) => link.taskSlug === entry.taskSlug && link.repositoryId === entry.repositoryId,
|
|
3812
|
+
);
|
|
3813
|
+
if (existing) {
|
|
3814
|
+
// A second write of the same pair keeps `addedAt` and updates the rest.
|
|
3815
|
+
existing.source = source;
|
|
3816
|
+
existing.inference = inference;
|
|
3817
|
+
existing.evidence = evidence;
|
|
3818
|
+
continue;
|
|
3819
|
+
}
|
|
3820
|
+
links.push({ taskSlug: entry.taskSlug, repositoryId: entry.repositoryId, addedAt: now, source, inference, evidence });
|
|
3821
|
+
addedLinks.push({ taskSlug: entry.taskSlug, repositoryId: entry.repositoryId });
|
|
3822
|
+
}
|
|
3823
|
+
const linkedSlugs = new Set(links.map((link) => link.taskSlug));
|
|
3824
|
+
const attributions = file.attributions.filter((attribution) => !linkedSlugs.has(attribution.taskSlug));
|
|
3825
|
+
const addedAttributions = [];
|
|
3826
|
+
for (const entry of payload.attributions ?? []) {
|
|
3827
|
+
if (!isRecord(entry)) failRepositoryField('attribution', 'must be an object');
|
|
3828
|
+
if (typeof entry.taskSlug !== 'string' || !SLUG_RE.test(entry.taskSlug)) {
|
|
3829
|
+
failRepositoryField('taskSlug', 'must be a task slug');
|
|
3830
|
+
}
|
|
3831
|
+
if (!ATTRIBUTION_VERDICTS.includes(entry.verdict)) {
|
|
3832
|
+
failRepositoryField('verdict', `must be one of ${ATTRIBUTION_VERDICTS.join(', ')}`);
|
|
3833
|
+
}
|
|
3834
|
+
const evidence = entry.evidence ?? '';
|
|
3835
|
+
if (typeof evidence !== 'string' || evidence.length > MAX_LINK_EVIDENCE_LENGTH) {
|
|
3836
|
+
failRepositoryField('evidence', `must be at most ${MAX_LINK_EVIDENCE_LENGTH} characters`);
|
|
3837
|
+
}
|
|
3838
|
+
// ADR §4 / I-1: a link that landed for this slug wins, and its verdict is
|
|
3839
|
+
// dropped in the same write so no projection can ever see both rows.
|
|
3840
|
+
if (linkedSlugs.has(entry.taskSlug)) continue;
|
|
3841
|
+
const existing = attributions.find((attribution) => attribution.taskSlug === entry.taskSlug);
|
|
3842
|
+
const source = entry.source ?? existing?.source ?? 'backfill';
|
|
3843
|
+
if (!LINK_SOURCES.includes(source)) failRepositoryField('source', `must be one of ${LINK_SOURCES.join(', ')}`);
|
|
3844
|
+
const rest = attributions.filter((attribution) => attribution.taskSlug !== entry.taskSlug);
|
|
3845
|
+
attributions.length = 0;
|
|
3846
|
+
attributions.push(...rest, {
|
|
3847
|
+
taskSlug: entry.taskSlug,
|
|
3848
|
+
verdict: entry.verdict,
|
|
3849
|
+
evidence,
|
|
3850
|
+
recordedAt: now,
|
|
3851
|
+
source,
|
|
3852
|
+
});
|
|
3853
|
+
addedAttributions.push(entry.taskSlug);
|
|
3854
|
+
}
|
|
3855
|
+
return { document: { repositories, links, attributions }, addedRecords, addedLinks, addedAttributions };
|
|
3856
|
+
};
|
|
3857
|
+
|
|
3858
|
+
/**
|
|
3859
|
+
* `repositories apply|put|delete|list|project` over the file of record.
|
|
3860
|
+
*
|
|
3861
|
+
* One lock spans the whole read-modify-write-projection: the definition lands
|
|
3862
|
+
* first, the projection follows and its failure never fails the write.
|
|
3863
|
+
*/
|
|
3864
|
+
export function runRepositoriesCommand(subcommand, args, options = {}) {
|
|
3865
|
+
const teamRoot = resolveTeamRoot(options.root);
|
|
3866
|
+
const paths = repositoriesPaths(teamRoot);
|
|
3867
|
+
const json = Boolean(options.json);
|
|
3868
|
+
const quiet = Boolean(options.quiet);
|
|
3869
|
+
const id = args[0] ?? options.id ?? null;
|
|
3870
|
+
const now = new Date().toISOString();
|
|
3871
|
+
|
|
3872
|
+
if (isKillSwitchSet(process.env) && subcommand !== 'list') {
|
|
3873
|
+
teamDbFail('E_DISABLED', 'disabled by AI_RULES_TEAM_DB_DISABLE', 1);
|
|
3874
|
+
}
|
|
3875
|
+
|
|
3876
|
+
const readStdinOrFile = (label) => {
|
|
3877
|
+
const source = options.file;
|
|
3878
|
+
if (typeof source !== 'string' || source === '') teamDbFail('E_USAGE', `repositories ${label} needs --file <path|->`, 3);
|
|
3879
|
+
const text = source === '-' ? fs.readFileSync(0, 'utf8') : fs.readFileSync(source, 'utf8');
|
|
3880
|
+
try {
|
|
3881
|
+
return JSON.parse(text);
|
|
3882
|
+
} catch (error) {
|
|
3883
|
+
failRepositoryField('payload', `the body is not JSON (${error.message})`);
|
|
3884
|
+
}
|
|
3885
|
+
return null;
|
|
3886
|
+
};
|
|
3887
|
+
|
|
3888
|
+
if (subcommand === 'list') {
|
|
3889
|
+
const file = readRepositoriesFile(teamRoot);
|
|
3890
|
+
if (json) return { exitCode: 0, output: renderJson({ ...file }) };
|
|
3891
|
+
if (quiet) return { exitCode: 0, output: '' };
|
|
3892
|
+
const lines = ['ID NAME STATUS LINKED TASKS'];
|
|
3893
|
+
for (const record of file.repositories) {
|
|
3894
|
+
const linked = file.links.filter((link) => link.repositoryId === record.id).length;
|
|
3895
|
+
lines.push(`${record.id} ${record.name} ${record.status} ${linked}`);
|
|
3896
|
+
}
|
|
3897
|
+
return { exitCode: 0, output: `${lines.join('\n')}\n` };
|
|
3898
|
+
}
|
|
3899
|
+
|
|
3900
|
+
if (subcommand === 'project') {
|
|
3901
|
+
return withRepositoriesLock(teamRoot, () => {
|
|
3902
|
+
const result = projectRepositoriesInChild(teamRoot, null);
|
|
3903
|
+
if (json) return { exitCode: 0, output: renderJson({ ok: true, projection: result }) };
|
|
3904
|
+
return { exitCode: 0, output: `project: repositories=${result?.repositories ?? 0} links=${result?.links ?? 0} attributions=${result?.attributions ?? 0}\n` };
|
|
3905
|
+
});
|
|
3906
|
+
}
|
|
3907
|
+
|
|
3908
|
+
if (subcommand === 'apply') {
|
|
3909
|
+
const payload = readStdinOrFile('apply');
|
|
3910
|
+
return withRepositoriesLock(teamRoot, () => {
|
|
3911
|
+
const file = readRepositoriesFile(teamRoot);
|
|
3912
|
+
const applied = applyPayload(file, payload, now);
|
|
3913
|
+
if (options.dryRun) {
|
|
3914
|
+
const preview = { ok: true, dryRun: true, repositories: applied.addedRecords.length, links: applied.addedLinks.length, attributions: applied.addedAttributions.length };
|
|
3915
|
+
if (json) return { exitCode: 0, output: renderJson(preview) };
|
|
3916
|
+
return { exitCode: 0, output: `${JSON.stringify(preview, null, 2)}\n` };
|
|
3917
|
+
}
|
|
3918
|
+
writeRepositoriesFile(teamRoot, applied.document);
|
|
3919
|
+
const scope = {
|
|
3920
|
+
repositoryIds: applied.addedRecords.map((record) => record.id),
|
|
3921
|
+
taskSlugs: [...new Set([...applied.addedLinks.map((link) => link.taskSlug), ...applied.addedAttributions])],
|
|
3922
|
+
};
|
|
3923
|
+
const projection = containProjection(() => projectRepositoriesInChild(teamRoot, scope));
|
|
3924
|
+
const summary = {
|
|
3925
|
+
ok: true,
|
|
3926
|
+
repositories: applied.addedRecords.length,
|
|
3927
|
+
links: applied.addedLinks.length,
|
|
3928
|
+
attributions: applied.addedAttributions.length,
|
|
3929
|
+
projection,
|
|
3930
|
+
};
|
|
3931
|
+
if (json) return { exitCode: 0, output: renderJson(summary) };
|
|
3932
|
+
return {
|
|
3933
|
+
exitCode: 0,
|
|
3934
|
+
output: `apply: repositories=${summary.repositories} links=${summary.links} attributions=${summary.attributions}\n`,
|
|
3935
|
+
};
|
|
3936
|
+
});
|
|
3937
|
+
}
|
|
3938
|
+
|
|
3939
|
+
if (subcommand === 'put') {
|
|
3940
|
+
const payload = readStdinOrFile('put');
|
|
3941
|
+
return withRepositoriesLock(teamRoot, () => {
|
|
3942
|
+
const file = readRepositoriesFile(teamRoot);
|
|
3943
|
+
const written = validateRepositoryWrite(payload);
|
|
3944
|
+
const existing = file.repositories.find((record) => record.id === written.id) ?? null;
|
|
3945
|
+
if (existing) {
|
|
3946
|
+
if (payload.revision === undefined) {
|
|
3947
|
+
teamDbFail(
|
|
3948
|
+
'E_CONFLICT',
|
|
3949
|
+
`repository "${existing.id}" is at revision ${existing.revision}; an update must carry "revision"`,
|
|
3950
|
+
1,
|
|
3951
|
+
);
|
|
3952
|
+
}
|
|
3953
|
+
if (payload.revision !== existing.revision) {
|
|
3954
|
+
teamDbFail(
|
|
3955
|
+
'E_CONFLICT',
|
|
3956
|
+
`repository "${existing.id}" is at revision ${existing.revision}, the body sent ${payload.revision}`,
|
|
3957
|
+
1,
|
|
3958
|
+
);
|
|
3959
|
+
}
|
|
3960
|
+
} else if (payload.revision !== undefined && payload.revision !== 1) {
|
|
3961
|
+
teamDbFail('E_CONFLICT', `repository "${written.id}" does not exist; revision must be 1`, 1);
|
|
3962
|
+
}
|
|
3963
|
+
const record = {
|
|
3964
|
+
id: written.id,
|
|
3965
|
+
name: written.name,
|
|
3966
|
+
locator: written.locator,
|
|
3967
|
+
description: written.description,
|
|
3968
|
+
labels: written.labels,
|
|
3969
|
+
status: written.status,
|
|
3970
|
+
revision: existing ? existing.revision + 1 : 1,
|
|
3971
|
+
createdAt: existing ? existing.createdAt : now,
|
|
3972
|
+
updatedAt: now,
|
|
3973
|
+
};
|
|
3974
|
+
if (options.dryRun) {
|
|
3975
|
+
if (json) return { exitCode: 0, output: renderJson({ ok: true, dryRun: true, repository: record }) };
|
|
3976
|
+
return { exitCode: 0, output: `${JSON.stringify(record, null, 2)}\n` };
|
|
3977
|
+
}
|
|
3978
|
+
const repositories = existing
|
|
3979
|
+
? file.repositories.map((entry) => (entry.id === record.id ? record : entry))
|
|
3980
|
+
: [...file.repositories, record];
|
|
3981
|
+
writeRepositoriesFile(teamRoot, { ...file, repositories });
|
|
3982
|
+
const projection = containProjection(() => projectRepositoriesInChild(teamRoot, { repositoryIds: [record.id], taskSlugs: [] }));
|
|
3983
|
+
if (json) return { exitCode: 0, output: renderJson({ ok: true, repository: record, projection }) };
|
|
3984
|
+
return { exitCode: 0, output: `put: ${record.id} revision ${record.revision}\n` };
|
|
3985
|
+
});
|
|
3986
|
+
}
|
|
3987
|
+
|
|
3988
|
+
if (subcommand === 'delete') {
|
|
3989
|
+
if (!id) teamDbFail('E_USAGE', 'repositories delete needs a repository id', 3);
|
|
3990
|
+
return withRepositoriesLock(teamRoot, () => {
|
|
3991
|
+
const file = readRepositoriesFile(teamRoot);
|
|
3992
|
+
const record = file.repositories.find((entry) => entry.id === id);
|
|
3993
|
+
if (!record) teamDbFail('E_NOT_FOUND', `no repository "${id}"`, 1);
|
|
3994
|
+
if (options.revision !== undefined && options.revision !== record.revision) {
|
|
3995
|
+
teamDbFail(
|
|
3996
|
+
'E_CONFLICT',
|
|
3997
|
+
`repository "${id}" is at revision ${record.revision}, the request sent ${options.revision}`,
|
|
3998
|
+
1,
|
|
3999
|
+
);
|
|
4000
|
+
}
|
|
4001
|
+
const linksRemoved = file.links.filter((link) => link.repositoryId === id).length;
|
|
4002
|
+
if (linksRemoved > 0 && !options.force) {
|
|
4003
|
+
const error = new TeamDbError(
|
|
4004
|
+
'E_REPOSITORY_IN_USE',
|
|
4005
|
+
`this repository is linked to ${linksRemoved} task(s); delete it anyway?`,
|
|
4006
|
+
1,
|
|
4007
|
+
);
|
|
4008
|
+
error.linkedTasks = linksRemoved;
|
|
4009
|
+
throw error;
|
|
4010
|
+
}
|
|
4011
|
+
if (options.dryRun) {
|
|
4012
|
+
if (json) return { exitCode: 0, output: renderJson({ ok: true, dryRun: true, id, linksRemoved }) };
|
|
4013
|
+
return { exitCode: 0, output: `delete (dry run): ${id} linksRemoved=${linksRemoved}\n` };
|
|
4014
|
+
}
|
|
4015
|
+
writeRepositoriesFile(teamRoot, {
|
|
4016
|
+
...file,
|
|
4017
|
+
repositories: file.repositories.filter((entry) => entry.id !== id),
|
|
4018
|
+
links: file.links.filter((link) => link.repositoryId !== id),
|
|
4019
|
+
});
|
|
4020
|
+
const projection = containProjection(() => projectRepositoriesInChild(teamRoot, { repositoryIds: [id], taskSlugs: [] }));
|
|
4021
|
+
if (json) return { exitCode: 0, output: renderJson({ ok: true, id, linksRemoved, projection }) };
|
|
4022
|
+
return { exitCode: 0, output: `delete: ${id} linksRemoved=${linksRemoved}\n` };
|
|
4023
|
+
});
|
|
4024
|
+
}
|
|
4025
|
+
|
|
4026
|
+
teamDbFail('E_USAGE', `unknown repositories subcommand "${subcommand}"`, 3);
|
|
4027
|
+
return null;
|
|
4028
|
+
}
|
|
4029
|
+
|
|
4030
|
+
/**
|
|
4031
|
+
* A projection failure never fails a file write: one error-log line, and the
|
|
4032
|
+
* caller still reports `ok: true` with `failed >= 1`.
|
|
4033
|
+
*/
|
|
4034
|
+
const containProjection = (run) => {
|
|
4035
|
+
try {
|
|
4036
|
+
const result = run();
|
|
4037
|
+
if (result === null) return { skipped: true, failed: 0 };
|
|
4038
|
+
return result;
|
|
4039
|
+
} catch (error) {
|
|
4040
|
+
logProjectionFailure('E_REPOSITORIES_PROJECTION', error.message);
|
|
4041
|
+
return { failed: 1, errors: [{ path: REPOSITORIES_FILE, reason: error.message }] };
|
|
4042
|
+
}
|
|
4043
|
+
};
|
|
4044
|
+
|
|
2996
4045
|
/**
|
|
2997
4046
|
* Project a tree (or one slug) into the database.
|
|
2998
4047
|
*
|
|
@@ -3133,6 +4182,18 @@ export function syncProjection(options = {}) {
|
|
|
3133
4182
|
result.failed += trackerProjection.failed;
|
|
3134
4183
|
for (const error of trackerProjection.errors) result.errors.push(error);
|
|
3135
4184
|
}
|
|
4185
|
+
if (!slug) {
|
|
4186
|
+
try {
|
|
4187
|
+
const repositoryProjection = projectRepositories(db, { teamRoot: handle.teamRoot });
|
|
4188
|
+
result.failed += repositoryProjection.failed;
|
|
4189
|
+
for (const error of repositoryProjection.errors) result.errors.push(error);
|
|
4190
|
+
} catch (error) {
|
|
4191
|
+
// The registry is derived from a file: a projection failure is a
|
|
4192
|
+
// recorded finding, never a failed walk of the task tree.
|
|
4193
|
+
result.failed += 1;
|
|
4194
|
+
result.errors.push({ path: REPOSITORIES_FILE, reason: error.message });
|
|
4195
|
+
}
|
|
4196
|
+
}
|
|
3136
4197
|
if (!slug) {
|
|
3137
4198
|
const schedulerProjection = projectScheduler(db, { teamRoot: handle.teamRoot });
|
|
3138
4199
|
result.failed += schedulerProjection.failed;
|