@bonesofspring/ai-rules 0.2.64 → 0.2.66
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 +80 -11
- package/README.md +24 -16
- package/bin/lib/engine-scripts.js +52 -12
- package/bin/lib/engine-upgrade.js +5 -2
- package/bin/lib/seed-ai-local-team.js +13 -3
- package/docs/OPENCODE.md +17 -9
- package/docs/PRESET-CONTRIBUTION.md +41 -0
- package/docs/TEAM-DB.md +240 -60
- package/docs/TOKEN-ECONOMY.md +79 -0
- package/docs/openapi/team-db.v1.json +1238 -377
- package/mcp/defectdojo-mcp.mjs +7 -5
- package/mcp/lib/defectdojo.mjs +26 -14
- package/package.json +31 -20
- package/presets/_shared/ai-local/scripts/dump-output.mjs +371 -0
- package/presets/_shared/ai-local/scripts/process-lease.mjs +576 -0
- package/presets/_shared/ai-local/scripts/processes.mjs +1618 -0
- package/presets/_shared/ai-local/scripts/run.mjs +5 -5
- package/presets/_shared/ai-local/scripts/team-db-api.mjs +465 -152
- package/presets/_shared/ai-local/scripts/team-db-dashboard.mjs +235 -10
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +416 -176
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +171 -62
- package/presets/_shared/ai-local/scripts/team-db-scheduler.mjs +4 -0
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +143 -5
- package/presets/_shared/ai-local/scripts/team-db-task-runner.mjs +567 -0
- package/presets/_shared/ai-local/scripts/{team-db-backlog.mjs → team-db-tracker.mjs} +900 -197
- package/presets/_shared/ai-local/scripts/team-db-ui.mjs +750 -0
- package/presets/_shared/ai-local/scripts/team-db.mjs +184 -23
- package/presets/_shared/core/agent-team/agent-team-orchestrator.md +4 -2
- package/presets/_shared/core/architecture/feature-delivery-workflow.md +4 -0
- package/presets/_shared/core/quality/context-and-iteration.md +1 -0
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +105 -17
- package/presets/_shared/hooks/guard-shell-command.mjs.tmpl +40 -2
- package/presets/claude/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +105 -17
- package/presets/claude/android-kotlin/hooks/guard-shell-command.mjs +41 -2
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
- package/presets/claude/android-kotlin/settings.json +6 -1
- package/presets/claude/go/agents/task-analyst.md +1 -1
- package/presets/claude/go/hooks/chain-team-phases.sh +105 -17
- package/presets/claude/go/hooks/guard-shell-command.mjs +41 -2
- package/presets/claude/go/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
- package/presets/claude/go/settings.json +6 -1
- package/presets/claude/ios-swift/agents/task-analyst.md +1 -1
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +105 -17
- package/presets/claude/ios-swift/hooks/guard-shell-command.mjs +41 -2
- package/presets/claude/ios-swift/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
- package/presets/claude/ios-swift/settings.json +6 -1
- package/presets/claude/java/agents/task-analyst.md +1 -1
- package/presets/claude/java/hooks/chain-team-phases.sh +105 -17
- package/presets/claude/java/hooks/guard-shell-command.mjs +41 -2
- package/presets/claude/java/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
- package/presets/claude/java/settings.json +6 -1
- package/presets/claude/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +105 -17
- package/presets/claude/mcp-ts/hooks/guard-shell-command.mjs +41 -2
- package/presets/claude/mcp-ts/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
- package/presets/claude/mcp-ts/settings.json +6 -1
- package/presets/claude/mol/agents/task-analyst.md +1 -1
- package/presets/claude/mol/hooks/chain-team-phases.sh +105 -17
- package/presets/claude/mol/hooks/guard-shell-command.mjs +41 -2
- package/presets/claude/mol/rules/architecture/feature-delivery-workflow.md +4 -0
- package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
- package/presets/claude/mol/settings.json +6 -1
- package/presets/claude/next/MCP.md +2 -0
- package/presets/claude/next/REPO_AGENTS.md +2 -0
- package/presets/claude/next/agents/build-verifier.md +1 -1
- package/presets/claude/next/agents/ci-investigator.md +3 -0
- package/presets/claude/next/agents/debugger.md +3 -0
- package/presets/claude/next/agents/feature-developer.md +3 -0
- package/presets/claude/next/agents/mockup-reviewer.md +2 -0
- package/presets/claude/next/agents/performance-auditor.md +2 -0
- package/presets/claude/next/agents/playwright-test-generator.md +3 -0
- package/presets/claude/next/agents/playwright-test-healer.md +3 -0
- package/presets/claude/next/agents/playwright-test-planner.md +3 -0
- package/presets/claude/next/agents/qa-tester.md +3 -0
- package/presets/claude/next/agents/task-analyst.md +1 -1
- package/presets/claude/next/commands/README.md +7 -1
- package/presets/claude/next/commands/task.md +1 -1
- package/presets/claude/next/commands/ui-start.md +78 -0
- package/presets/claude/next/commands/ui-stop.md +71 -0
- package/presets/claude/next/hooks/chain-team-phases.sh +105 -17
- package/presets/claude/next/hooks/guard-shell-command.mjs +41 -2
- package/presets/claude/next/rules/README.md +2 -1
- package/presets/claude/next/rules/architecture/feature-delivery-workflow.md +4 -0
- package/presets/claude/next/rules/stack/next-app-core.md +1 -0
- package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
- package/presets/claude/next/rules/tooling-and-review/dev-process-lifecycle.md +43 -0
- package/presets/claude/next/settings.json +6 -1
- package/presets/claude/next/team/README.md +7 -3
- package/presets/claude/nuxt/agents/task-analyst.md +1 -1
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +105 -17
- package/presets/claude/nuxt/hooks/guard-shell-command.mjs +41 -2
- package/presets/claude/nuxt/rules/architecture/feature-delivery-workflow.md +4 -0
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
- package/presets/claude/nuxt/settings.json +6 -1
- package/presets/claude/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +105 -17
- package/presets/claude/php-hexagonal/hooks/guard-shell-command.mjs +41 -2
- package/presets/claude/php-hexagonal/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
- package/presets/claude/php-hexagonal/settings.json +6 -1
- package/presets/claude/php-laravel/agents/task-analyst.md +1 -1
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +106 -18
- package/presets/claude/php-laravel/hooks/guard-shell-command.mjs +41 -2
- package/presets/claude/php-laravel/rules/architecture/feature-delivery.md +4 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
- package/presets/claude/php-laravel/settings.json +6 -1
- package/presets/claude/svelte/agents/task-analyst.md +1 -1
- package/presets/claude/svelte/hooks/chain-team-phases.sh +105 -17
- package/presets/claude/svelte/hooks/guard-shell-command.mjs +41 -2
- package/presets/claude/svelte/rules/architecture/feature-delivery-workflow.md +4 -0
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +4 -2
- package/presets/claude/svelte/settings.json +6 -1
- package/presets/cursor/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +105 -17
- package/presets/cursor/android-kotlin/hooks/guard-shell-command.mjs +41 -2
- package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/go/agents/task-analyst.md +1 -1
- package/presets/cursor/go/hooks/chain-team-phases.sh +105 -17
- package/presets/cursor/go/hooks/guard-shell-command.mjs +41 -2
- package/presets/cursor/go/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/ios-swift/agents/task-analyst.md +1 -1
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +105 -17
- package/presets/cursor/ios-swift/hooks/guard-shell-command.mjs +41 -2
- package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/java/agents/task-analyst.md +1 -1
- package/presets/cursor/java/hooks/chain-team-phases.sh +105 -17
- package/presets/cursor/java/hooks/guard-shell-command.mjs +41 -2
- package/presets/cursor/java/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +105 -17
- package/presets/cursor/mcp-ts/hooks/guard-shell-command.mjs +41 -2
- package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/mol/agents/task-analyst.md +1 -1
- package/presets/cursor/mol/hooks/chain-team-phases.sh +105 -17
- package/presets/cursor/mol/hooks/guard-shell-command.mjs +41 -2
- package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/next/MCP.md +2 -0
- package/presets/cursor/next/REPO_AGENTS.md +2 -0
- package/presets/cursor/next/agents/build-verifier.md +1 -1
- package/presets/cursor/next/agents/ci-investigator.md +2 -0
- package/presets/cursor/next/agents/debugger.md +2 -0
- package/presets/cursor/next/agents/feature-developer.md +2 -0
- package/presets/cursor/next/agents/mockup-reviewer.md +2 -0
- package/presets/cursor/next/agents/performance-auditor.md +2 -0
- package/presets/cursor/next/agents/playwright-test-generator.md +2 -0
- package/presets/cursor/next/agents/playwright-test-healer.md +2 -0
- package/presets/cursor/next/agents/playwright-test-planner.md +2 -0
- package/presets/cursor/next/agents/qa-tester.md +2 -0
- package/presets/cursor/next/agents/task-analyst.md +1 -1
- package/presets/cursor/next/ai-local/rules-library/storybook-dev-compare-figma.md +1 -1
- package/presets/cursor/next/commands/README.md +7 -1
- package/presets/cursor/next/commands/task.md +1 -1
- package/presets/cursor/next/commands/ui-start.md +78 -0
- package/presets/cursor/next/commands/ui-stop.md +71 -0
- package/presets/cursor/next/hooks/chain-team-phases.sh +105 -17
- package/presets/cursor/next/hooks/guard-shell-command.mjs +41 -2
- package/presets/cursor/next/rules/README.md +2 -1
- package/presets/cursor/next/rules/agent-team-orchestrator.mdc +3 -1
- package/presets/cursor/next/rules/dev-process-lifecycle.mdc +43 -0
- package/presets/cursor/next/rules/next-app-core.mdc +1 -0
- package/presets/cursor/next/team/README.md +7 -3
- package/presets/cursor/nuxt/agents/task-analyst.md +1 -1
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +105 -17
- package/presets/cursor/nuxt/hooks/guard-shell-command.mjs +41 -2
- package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +105 -17
- package/presets/cursor/php-hexagonal/hooks/guard-shell-command.mjs +41 -2
- package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-laravel/agents/task-analyst.md +1 -1
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +106 -18
- package/presets/cursor/php-laravel/hooks/guard-shell-command.mjs +41 -2
- package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/svelte/agents/task-analyst.md +1 -1
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +105 -17
- package/presets/cursor/svelte/hooks/guard-shell-command.mjs +41 -2
- package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +4 -2
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/agents/task-analyst.md +1 -1
- package/presets/mavis/go/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/go/rules/agent-team-orchestrator.md +4 -2
- package/presets/mavis/go/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/agents/task-analyst.md +1 -1
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +4 -2
- package/presets/mavis/ios-swift/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/agents/task-analyst.md +1 -1
- package/presets/mavis/java/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/java/rules/agent-team-orchestrator.md +4 -2
- package/presets/mavis/java/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +4 -2
- package/presets/mavis/mcp-ts/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/mol/adapter-map.json +1 -1
- package/presets/mavis/mol/agents/task-analyst.md +1 -1
- package/presets/mavis/mol/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/mol/rules/agent-team-orchestrator.md +4 -2
- package/presets/mavis/mol/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/next/MCP.md +2 -0
- package/presets/mavis/next/REPO_AGENTS.md +2 -0
- package/presets/mavis/next/adapter-map.json +33 -1
- package/presets/mavis/next/agents/build-verifier.md +1 -1
- package/presets/mavis/next/agents/ci-investigator.md +3 -0
- package/presets/mavis/next/agents/debugger.md +3 -0
- package/presets/mavis/next/agents/feature-developer.md +3 -0
- package/presets/mavis/next/agents/mockup-reviewer.md +2 -0
- package/presets/mavis/next/agents/performance-auditor.md +2 -0
- package/presets/mavis/next/agents/playwright-test-generator.md +3 -0
- package/presets/mavis/next/agents/playwright-test-healer.md +3 -0
- package/presets/mavis/next/agents/playwright-test-planner.md +3 -0
- package/presets/mavis/next/agents/qa-tester.md +3 -0
- package/presets/mavis/next/agents/task-analyst.md +1 -1
- package/presets/mavis/next/ai-local/rules-library/storybook-dev-compare-figma.md +1 -1
- package/presets/mavis/next/commands/README.md +7 -1
- package/presets/mavis/next/commands/task.md +1 -1
- package/presets/mavis/next/commands/ui-start.md +73 -0
- package/presets/mavis/next/commands/ui-stop.md +66 -0
- package/presets/mavis/next/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/next/rules/agent-team-orchestrator.md +4 -2
- package/presets/mavis/next/rules/dev-process-lifecycle.md +38 -0
- package/presets/mavis/next/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/next/rules/next-app-core.md +1 -0
- package/presets/mavis/next/team/README.md +7 -3
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/agents/task-analyst.md +1 -1
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +4 -2
- package/presets/mavis/nuxt/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +4 -2
- package/presets/mavis/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/agents/task-analyst.md +1 -1
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +106 -18
- package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +4 -2
- package/presets/mavis/php-laravel/rules/feature-delivery-workflow.md +4 -0
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/agents/task-analyst.md +1 -1
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/svelte/rules/agent-team-orchestrator.md +4 -2
- package/presets/mavis/svelte/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/android-kotlin/adapter-map.json +1 -1
- package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +105 -17
- package/presets/opencode/android-kotlin/opencode.json +5 -1
- package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +4 -2
- package/presets/opencode/go/adapter-map.json +1 -1
- package/presets/opencode/go/agents/task-analyst.md +1 -1
- package/presets/opencode/go/hooks/chain-team-phases.sh +105 -17
- package/presets/opencode/go/opencode.json +5 -1
- package/presets/opencode/go/rules/agent-team-orchestrator.md +4 -2
- package/presets/opencode/go/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/ios-swift/adapter-map.json +1 -1
- package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +105 -17
- package/presets/opencode/ios-swift/opencode.json +5 -1
- package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +4 -2
- package/presets/opencode/ios-swift/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/java/adapter-map.json +1 -1
- package/presets/opencode/java/agents/task-analyst.md +1 -1
- package/presets/opencode/java/hooks/chain-team-phases.sh +105 -17
- package/presets/opencode/java/opencode.json +5 -1
- package/presets/opencode/java/rules/agent-team-orchestrator.md +4 -2
- package/presets/opencode/java/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/mcp-ts/adapter-map.json +1 -1
- package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +105 -17
- package/presets/opencode/mcp-ts/opencode.json +5 -1
- package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +4 -2
- package/presets/opencode/mcp-ts/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/mol/adapter-map.json +1 -1
- package/presets/opencode/mol/agents/task-analyst.md +1 -1
- package/presets/opencode/mol/hooks/chain-team-phases.sh +105 -17
- package/presets/opencode/mol/opencode.json +4 -0
- package/presets/opencode/mol/rules/agent-team-orchestrator.md +4 -2
- package/presets/opencode/mol/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/next/MCP.md +2 -0
- package/presets/opencode/next/REPO_AGENTS.md +2 -0
- package/presets/opencode/next/adapter-map.json +33 -1
- package/presets/opencode/next/agents/build-verifier.md +1 -1
- package/presets/opencode/next/agents/ci-investigator.md +3 -0
- package/presets/opencode/next/agents/debugger.md +3 -0
- package/presets/opencode/next/agents/feature-developer.md +3 -0
- package/presets/opencode/next/agents/mockup-reviewer.md +2 -0
- package/presets/opencode/next/agents/performance-auditor.md +2 -0
- package/presets/opencode/next/agents/playwright-test-generator.md +3 -0
- package/presets/opencode/next/agents/playwright-test-healer.md +3 -0
- package/presets/opencode/next/agents/playwright-test-planner.md +3 -0
- package/presets/opencode/next/agents/qa-tester.md +3 -0
- package/presets/opencode/next/agents/task-analyst.md +1 -1
- package/presets/opencode/next/ai-local/rules-library/storybook-dev-compare-figma.md +1 -1
- package/presets/opencode/next/commands/README.md +7 -1
- package/presets/opencode/next/commands/task.md +1 -1
- package/presets/opencode/next/commands/ui-start.md +81 -0
- package/presets/opencode/next/commands/ui-stop.md +74 -0
- package/presets/opencode/next/hooks/chain-team-phases.sh +105 -17
- package/presets/opencode/next/opencode.json +4 -0
- package/presets/opencode/next/rules/agent-team-orchestrator.md +4 -2
- package/presets/opencode/next/rules/dev-process-lifecycle.md +38 -0
- package/presets/opencode/next/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/next/rules/next-app-core.md +1 -0
- package/presets/opencode/next/team/README.md +7 -3
- package/presets/opencode/nuxt/adapter-map.json +1 -1
- package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +105 -17
- package/presets/opencode/nuxt/opencode.json +4 -0
- package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +4 -2
- package/presets/opencode/nuxt/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/php-hexagonal/adapter-map.json +1 -1
- package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +105 -17
- package/presets/opencode/php-hexagonal/opencode.json +5 -1
- package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +4 -2
- package/presets/opencode/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/php-laravel/adapter-map.json +1 -1
- package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +106 -18
- package/presets/opencode/php-laravel/opencode.json +5 -1
- package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +4 -2
- package/presets/opencode/php-laravel/rules/feature-delivery-workflow.md +4 -0
- package/presets/opencode/plugins/task-status/README.md +23 -11
- package/presets/opencode/plugins/task-status/details-data.ts +64 -46
- package/presets/opencode/plugins/task-status/details.tsx +12 -2
- package/presets/opencode/plugins/task-status/format.ts +16 -0
- package/presets/opencode/plugins/task-status/prompt-text.ts +37 -0
- package/presets/opencode/plugins/task-status/task-view.ts +241 -177
- package/presets/opencode/plugins/task-status/tui.tsx +57 -15
- package/presets/opencode/plugins/task-status/types.ts +74 -0
- package/presets/opencode/svelte/adapter-map.json +1 -1
- package/presets/opencode/svelte/agents/task-analyst.md +1 -1
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +105 -17
- package/presets/opencode/svelte/opencode.json +4 -0
- package/presets/opencode/svelte/rules/agent-team-orchestrator.md +4 -2
- package/presets/opencode/svelte/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/android-kotlin/adapter-map.json +1 -1
- package/presets/zcode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +4 -2
- package/presets/zcode/go/adapter-map.json +1 -1
- package/presets/zcode/go/agents/task-analyst.md +1 -1
- package/presets/zcode/go/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/go/rules/agent-team-orchestrator.md +4 -2
- package/presets/zcode/go/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/ios-swift/adapter-map.json +1 -1
- package/presets/zcode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +4 -2
- package/presets/zcode/ios-swift/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/java/adapter-map.json +1 -1
- package/presets/zcode/java/agents/task-analyst.md +1 -1
- package/presets/zcode/java/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/java/rules/agent-team-orchestrator.md +4 -2
- package/presets/zcode/java/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/mcp-ts/adapter-map.json +1 -1
- package/presets/zcode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +4 -2
- package/presets/zcode/mcp-ts/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/mol/adapter-map.json +1 -1
- package/presets/zcode/mol/agents/task-analyst.md +1 -1
- package/presets/zcode/mol/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/mol/rules/agent-team-orchestrator.md +4 -2
- package/presets/zcode/mol/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/next/MCP.md +2 -0
- package/presets/zcode/next/REPO_AGENTS.md +2 -0
- package/presets/zcode/next/adapter-map.json +33 -1
- package/presets/zcode/next/agents/build-verifier.md +1 -1
- package/presets/zcode/next/agents/ci-investigator.md +3 -0
- package/presets/zcode/next/agents/debugger.md +3 -0
- package/presets/zcode/next/agents/feature-developer.md +3 -0
- package/presets/zcode/next/agents/mockup-reviewer.md +2 -0
- package/presets/zcode/next/agents/performance-auditor.md +2 -0
- package/presets/zcode/next/agents/playwright-test-generator.md +3 -0
- package/presets/zcode/next/agents/playwright-test-healer.md +3 -0
- package/presets/zcode/next/agents/playwright-test-planner.md +3 -0
- package/presets/zcode/next/agents/qa-tester.md +3 -0
- package/presets/zcode/next/agents/task-analyst.md +1 -1
- package/presets/zcode/next/ai-local/rules-library/storybook-dev-compare-figma.md +1 -1
- package/presets/zcode/next/commands/README.md +7 -1
- package/presets/zcode/next/commands/task.md +1 -1
- package/presets/zcode/next/commands/ui-start.md +81 -0
- package/presets/zcode/next/commands/ui-stop.md +74 -0
- package/presets/zcode/next/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/next/rules/agent-team-orchestrator.md +4 -2
- package/presets/zcode/next/rules/dev-process-lifecycle.md +38 -0
- package/presets/zcode/next/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/next/rules/next-app-core.md +1 -0
- package/presets/zcode/next/team/README.md +7 -3
- package/presets/zcode/nuxt/adapter-map.json +1 -1
- package/presets/zcode/nuxt/agents/task-analyst.md +1 -1
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +4 -2
- package/presets/zcode/nuxt/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
- package/presets/zcode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +4 -2
- package/presets/zcode/php-hexagonal/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/php-laravel/adapter-map.json +1 -1
- package/presets/zcode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +106 -18
- package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +4 -2
- package/presets/zcode/php-laravel/rules/feature-delivery-workflow.md +4 -0
- package/presets/zcode/svelte/adapter-map.json +1 -1
- package/presets/zcode/svelte/agents/task-analyst.md +1 -1
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/svelte/rules/agent-team-orchestrator.md +4 -2
- package/presets/zcode/svelte/rules/feature-delivery-workflow.md +4 -0
- package/presets/_shared/ai-local/scripts/upstream-research.mjs +0 -2964
- package/presets/claude/next/commands/upstream-research.md +0 -23
- package/presets/claude/next/team/upstream/config.json +0 -31
- package/presets/claude/next/team/upstream/digest-template.md +0 -55
- package/presets/claude/next/team/upstream/jobs.json +0 -34
- package/presets/claude/next/team/upstream/opencode.json +0 -34
- package/presets/claude/next/team/upstream/projects.json +0 -4
- package/presets/claude/next/team/upstream/prompt.md +0 -77
- package/presets/claude/next/team/upstream/signatures.json +0 -9
- package/presets/cursor/next/commands/upstream-research.md +0 -23
- package/presets/cursor/next/team/upstream/config.json +0 -31
- package/presets/cursor/next/team/upstream/digest-template.md +0 -55
- package/presets/cursor/next/team/upstream/jobs.json +0 -34
- package/presets/cursor/next/team/upstream/opencode.json +0 -34
- package/presets/cursor/next/team/upstream/projects.json +0 -4
- package/presets/cursor/next/team/upstream/prompt.md +0 -77
- package/presets/cursor/next/team/upstream/signatures.json +0 -9
- package/presets/mavis/next/commands/upstream-research.md +0 -18
- package/presets/mavis/next/team/upstream/config.json +0 -31
- package/presets/mavis/next/team/upstream/digest-template.md +0 -55
- package/presets/mavis/next/team/upstream/jobs.json +0 -34
- package/presets/mavis/next/team/upstream/opencode.json +0 -34
- package/presets/mavis/next/team/upstream/projects.json +0 -4
- package/presets/mavis/next/team/upstream/prompt.md +0 -77
- package/presets/mavis/next/team/upstream/signatures.json +0 -9
- package/presets/opencode/next/commands/upstream-research.md +0 -26
- package/presets/opencode/next/team/upstream/config.json +0 -31
- package/presets/opencode/next/team/upstream/digest-template.md +0 -55
- package/presets/opencode/next/team/upstream/jobs.json +0 -34
- package/presets/opencode/next/team/upstream/opencode.json +0 -34
- package/presets/opencode/next/team/upstream/projects.json +0 -4
- package/presets/opencode/next/team/upstream/prompt.md +0 -77
- package/presets/opencode/next/team/upstream/signatures.json +0 -9
- package/presets/zcode/next/commands/upstream-research.md +0 -26
- package/presets/zcode/next/team/upstream/config.json +0 -31
- package/presets/zcode/next/team/upstream/digest-template.md +0 -55
- package/presets/zcode/next/team/upstream/jobs.json +0 -34
- package/presets/zcode/next/team/upstream/opencode.json +0 -34
- package/presets/zcode/next/team/upstream/projects.json +0 -4
- package/presets/zcode/next/team/upstream/prompt.md +0 -77
- package/presets/zcode/next/team/upstream/signatures.json +0 -9
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
teamDbFail,
|
|
33
33
|
} from './team-db-schema.mjs';
|
|
34
34
|
import { projectScheduler, retainRuns } from './team-db-scheduler.mjs';
|
|
35
|
-
import { validateEntrySchema, validateItemSchema } from './team-db-
|
|
35
|
+
import { validateEntrySchema, validateItemSchema, validateLinkIdentity, validateLinkSchema } from './team-db-tracker.mjs';
|
|
36
36
|
|
|
37
37
|
export const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
38
38
|
export const MAX_RAW_BYTES = 32 * 1024 * 1024;
|
|
@@ -1338,12 +1338,13 @@ const projectTask = ({ db, teamRoot, slug, now, searchMode, deadlineAt }) => {
|
|
|
1338
1338
|
return { status: existing ? 'updated' : 'inserted', errors };
|
|
1339
1339
|
};
|
|
1340
1340
|
|
|
1341
|
-
/* ------------------------------
|
|
1341
|
+
/* ------------------------------ tracker walker ----------------------------- */
|
|
1342
1342
|
|
|
1343
|
-
const
|
|
1344
|
-
const
|
|
1343
|
+
const TRACKER_ITEM_DIR = 'tracker/items';
|
|
1344
|
+
const TRACKER_QUEUE_DIR = 'tracker/queue';
|
|
1345
|
+
const TRACKER_LINK_DIR = 'tracker/links';
|
|
1345
1346
|
|
|
1346
|
-
const
|
|
1347
|
+
const listTrackerJsonFiles = (teamRoot, dirName) => {
|
|
1347
1348
|
const dir = path.join(teamRoot, dirName);
|
|
1348
1349
|
if (!fs.existsSync(dir)) return [];
|
|
1349
1350
|
return fs
|
|
@@ -1353,7 +1354,7 @@ const listBacklogJsonFiles = (teamRoot, dirName) => {
|
|
|
1353
1354
|
.sort();
|
|
1354
1355
|
};
|
|
1355
1356
|
|
|
1356
|
-
const
|
|
1357
|
+
const readTrackerJson = (file) => {
|
|
1357
1358
|
try {
|
|
1358
1359
|
return { text: fs.readFileSync(file, 'utf8'), error: null };
|
|
1359
1360
|
} catch (error) {
|
|
@@ -1361,8 +1362,8 @@ const readBacklogJson = (file) => {
|
|
|
1361
1362
|
}
|
|
1362
1363
|
};
|
|
1363
1364
|
|
|
1364
|
-
const
|
|
1365
|
-
INSERT INTO
|
|
1365
|
+
const UPSERT_TRACKER_ITEM_SQL = `
|
|
1366
|
+
INSERT INTO tracker_items (
|
|
1366
1367
|
id, title, status, priority, type, description, labels_json, source_task,
|
|
1367
1368
|
source_refs_json, revision, created_at, updated_at, completed_at, cancelled_at,
|
|
1368
1369
|
cancel_reason, superseded_by, history_json, content_hash, parse_error,
|
|
@@ -1392,14 +1393,16 @@ ON CONFLICT(id) DO UPDATE SET
|
|
|
1392
1393
|
absent_at = NULL
|
|
1393
1394
|
`;
|
|
1394
1395
|
|
|
1395
|
-
const
|
|
1396
|
-
INSERT INTO
|
|
1397
|
-
entry_id, item_id, status, reason, requested_by, command, revision,
|
|
1396
|
+
const UPSERT_TRACKER_ENTRY_SQL = `
|
|
1397
|
+
INSERT INTO tracker_queue (
|
|
1398
|
+
entry_id, item_id, task_slug, link_id, status, reason, requested_by, command, revision,
|
|
1398
1399
|
requested_at, claimed_at, finished_at, history_json, content_hash, parse_error,
|
|
1399
1400
|
projected_at, first_seen_at, last_seen_at, absent_at
|
|
1400
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)
|
|
1401
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)
|
|
1401
1402
|
ON CONFLICT(entry_id) DO UPDATE SET
|
|
1402
1403
|
item_id = excluded.item_id,
|
|
1404
|
+
task_slug = excluded.task_slug,
|
|
1405
|
+
link_id = excluded.link_id,
|
|
1403
1406
|
status = excluded.status,
|
|
1404
1407
|
reason = excluded.reason,
|
|
1405
1408
|
requested_by = excluded.requested_by,
|
|
@@ -1416,19 +1419,44 @@ ON CONFLICT(entry_id) DO UPDATE SET
|
|
|
1416
1419
|
absent_at = NULL
|
|
1417
1420
|
`;
|
|
1418
1421
|
|
|
1422
|
+
const UPSERT_TRACKER_LINK_SQL = `
|
|
1423
|
+
INSERT INTO tracker_item_tasks (
|
|
1424
|
+
link_id, item_id, task_slug, entry_id, role, decision, prompt_path, language,
|
|
1425
|
+
revision, created_at, updated_at, history_json, content_hash, parse_error,
|
|
1426
|
+
projected_at, first_seen_at, last_seen_at, absent_at
|
|
1427
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)
|
|
1428
|
+
ON CONFLICT(link_id) DO UPDATE SET
|
|
1429
|
+
item_id = excluded.item_id,
|
|
1430
|
+
task_slug = excluded.task_slug,
|
|
1431
|
+
entry_id = excluded.entry_id,
|
|
1432
|
+
role = excluded.role,
|
|
1433
|
+
decision = excluded.decision,
|
|
1434
|
+
prompt_path = excluded.prompt_path,
|
|
1435
|
+
language = excluded.language,
|
|
1436
|
+
revision = excluded.revision,
|
|
1437
|
+
created_at = excluded.created_at,
|
|
1438
|
+
updated_at = excluded.updated_at,
|
|
1439
|
+
history_json = excluded.history_json,
|
|
1440
|
+
content_hash = excluded.content_hash,
|
|
1441
|
+
parse_error = excluded.parse_error,
|
|
1442
|
+
projected_at = excluded.projected_at,
|
|
1443
|
+
last_seen_at = excluded.last_seen_at,
|
|
1444
|
+
absent_at = NULL
|
|
1445
|
+
`;
|
|
1446
|
+
|
|
1419
1447
|
/**
|
|
1420
|
-
* One
|
|
1448
|
+
* One tracker item: parse, validate, upsert by natural key, replace its deps.
|
|
1421
1449
|
* An unchanged `content_hash` only touches `last_seen_at`; a broken file
|
|
1422
1450
|
* projects as a recorded `parse_error`, never aborts the run.
|
|
1423
1451
|
*/
|
|
1424
|
-
const
|
|
1425
|
-
if (Date.now() > deadlineAt) teamDbFail('E_DEADLINE', 'projection deadline expired in the
|
|
1426
|
-
const file = path.join(teamRoot,
|
|
1427
|
-
const read =
|
|
1452
|
+
const projectTrackerItem = ({ db, teamRoot, stem, now, deadlineAt }) => {
|
|
1453
|
+
if (Date.now() > deadlineAt) teamDbFail('E_DEADLINE', 'projection deadline expired in the tracker walk', 4);
|
|
1454
|
+
const file = path.join(teamRoot, TRACKER_ITEM_DIR, `${stem}.json`);
|
|
1455
|
+
const read = readTrackerJson(file);
|
|
1428
1456
|
const contentHash = sha256(read.text ?? '');
|
|
1429
|
-
const existing = db.prepare('SELECT content_hash, absent_at FROM
|
|
1457
|
+
const existing = db.prepare('SELECT content_hash, absent_at FROM tracker_items WHERE id = ?').get(stem);
|
|
1430
1458
|
if (read.text !== null && existing && existing.content_hash === contentHash && existing.absent_at === null) {
|
|
1431
|
-
db.prepare('UPDATE
|
|
1459
|
+
db.prepare('UPDATE tracker_items SET last_seen_at = ? WHERE id = ?').run(now, stem);
|
|
1432
1460
|
return { status: 'unchanged', parseError: null };
|
|
1433
1461
|
}
|
|
1434
1462
|
let item = null;
|
|
@@ -1447,7 +1475,7 @@ const projectBacklogItem = ({ db, teamRoot, stem, now, deadlineAt }) => {
|
|
|
1447
1475
|
}
|
|
1448
1476
|
}
|
|
1449
1477
|
}
|
|
1450
|
-
db.prepare(
|
|
1478
|
+
db.prepare(UPSERT_TRACKER_ITEM_SQL).run(
|
|
1451
1479
|
stem,
|
|
1452
1480
|
item?.title ?? null,
|
|
1453
1481
|
item?.status ?? null,
|
|
@@ -1471,23 +1499,23 @@ const projectBacklogItem = ({ db, teamRoot, stem, now, deadlineAt }) => {
|
|
|
1471
1499
|
now,
|
|
1472
1500
|
now,
|
|
1473
1501
|
);
|
|
1474
|
-
db.prepare('DELETE FROM
|
|
1502
|
+
db.prepare('DELETE FROM tracker_item_deps WHERE item_id = ?').run(stem);
|
|
1475
1503
|
if (Array.isArray(item?.dependsOn)) {
|
|
1476
|
-
const insert = db.prepare('INSERT INTO
|
|
1504
|
+
const insert = db.prepare('INSERT INTO tracker_item_deps(item_id, dep_id, ordinal) VALUES (?, ?, ?)');
|
|
1477
1505
|
item.dependsOn.forEach((dep, ordinal) => insert.run(stem, dep, ordinal));
|
|
1478
1506
|
}
|
|
1479
1507
|
return { status: existing ? 'updated' : 'inserted', parseError };
|
|
1480
1508
|
};
|
|
1481
1509
|
|
|
1482
1510
|
/** One queue entry: upsert by entry id and replace its derived event rows. */
|
|
1483
|
-
const
|
|
1484
|
-
if (Date.now() > deadlineAt) teamDbFail('E_DEADLINE', 'projection deadline expired in the
|
|
1485
|
-
const file = path.join(teamRoot,
|
|
1486
|
-
const read =
|
|
1511
|
+
const projectTrackerEntry = ({ db, teamRoot, stem, now, deadlineAt }) => {
|
|
1512
|
+
if (Date.now() > deadlineAt) teamDbFail('E_DEADLINE', 'projection deadline expired in the tracker walk', 4);
|
|
1513
|
+
const file = path.join(teamRoot, TRACKER_QUEUE_DIR, `${stem}.json`);
|
|
1514
|
+
const read = readTrackerJson(file);
|
|
1487
1515
|
const contentHash = sha256(read.text ?? '');
|
|
1488
|
-
const existing = db.prepare('SELECT content_hash, absent_at FROM
|
|
1516
|
+
const existing = db.prepare('SELECT content_hash, absent_at FROM tracker_queue WHERE entry_id = ?').get(stem);
|
|
1489
1517
|
if (read.text !== null && existing && existing.content_hash === contentHash && existing.absent_at === null) {
|
|
1490
|
-
db.prepare('UPDATE
|
|
1518
|
+
db.prepare('UPDATE tracker_queue SET last_seen_at = ? WHERE entry_id = ?').run(now, stem);
|
|
1491
1519
|
return { status: 'unchanged', parseError: null };
|
|
1492
1520
|
}
|
|
1493
1521
|
let entry = null;
|
|
@@ -1506,9 +1534,11 @@ const projectBacklogEntry = ({ db, teamRoot, stem, now, deadlineAt }) => {
|
|
|
1506
1534
|
}
|
|
1507
1535
|
}
|
|
1508
1536
|
}
|
|
1509
|
-
db.prepare(
|
|
1537
|
+
db.prepare(UPSERT_TRACKER_ENTRY_SQL).run(
|
|
1510
1538
|
stem,
|
|
1511
1539
|
entry?.itemId ?? null,
|
|
1540
|
+
entry?.taskSlug ?? null,
|
|
1541
|
+
entry?.linkId ?? null,
|
|
1512
1542
|
entry?.status ?? null,
|
|
1513
1543
|
entry?.reason ?? null,
|
|
1514
1544
|
entry?.requestedBy ?? null,
|
|
@@ -1524,10 +1554,10 @@ const projectBacklogEntry = ({ db, teamRoot, stem, now, deadlineAt }) => {
|
|
|
1524
1554
|
now,
|
|
1525
1555
|
now,
|
|
1526
1556
|
);
|
|
1527
|
-
db.prepare('DELETE FROM
|
|
1557
|
+
db.prepare('DELETE FROM tracker_queue_events WHERE entry_id = ?').run(stem);
|
|
1528
1558
|
if (Array.isArray(entry?.history)) {
|
|
1529
1559
|
const insert = db.prepare(
|
|
1530
|
-
'INSERT INTO
|
|
1560
|
+
'INSERT INTO tracker_queue_events(entry_id, seq, at, type, actor, detail) VALUES (?, ?, ?, ?, ?, ?)',
|
|
1531
1561
|
);
|
|
1532
1562
|
entry.history.forEach((event, index) => {
|
|
1533
1563
|
insert.run(stem, index + 1, isoTimestamp(event?.at), event?.type ?? null, event?.actor ?? null, event?.detail ?? null);
|
|
@@ -1536,59 +1566,118 @@ const projectBacklogEntry = ({ db, teamRoot, stem, now, deadlineAt }) => {
|
|
|
1536
1566
|
return { status: existing ? 'updated' : 'inserted', parseError };
|
|
1537
1567
|
};
|
|
1538
1568
|
|
|
1539
|
-
/**
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1569
|
+
/** One tracker link: upsert by link id; the prompt file is read through the document plane. */
|
|
1570
|
+
const projectTrackerLink = ({ db, teamRoot, stem, now, deadlineAt }) => {
|
|
1571
|
+
if (Date.now() > deadlineAt) teamDbFail('E_DEADLINE', 'projection deadline expired in the tracker walk', 4);
|
|
1572
|
+
const file = path.join(teamRoot, TRACKER_LINK_DIR, `${stem}.json`);
|
|
1573
|
+
const read = readTrackerJson(file);
|
|
1574
|
+
const contentHash = sha256(read.text ?? '');
|
|
1575
|
+
const existing = db.prepare('SELECT content_hash, absent_at FROM tracker_item_tasks WHERE link_id = ?').get(stem);
|
|
1576
|
+
if (read.text !== null && existing && existing.content_hash === contentHash && existing.absent_at === null) {
|
|
1577
|
+
db.prepare('UPDATE tracker_item_tasks SET last_seen_at = ? WHERE link_id = ?').run(now, stem);
|
|
1578
|
+
return { status: 'unchanged', parseError: null };
|
|
1579
|
+
}
|
|
1580
|
+
let link = null;
|
|
1581
|
+
let parseError = read.error;
|
|
1582
|
+
if (read.text !== null) {
|
|
1583
|
+
try {
|
|
1584
|
+
link = JSON.parse(read.text);
|
|
1585
|
+
} catch (error) {
|
|
1586
|
+
parseError = error.message;
|
|
1587
|
+
}
|
|
1588
|
+
if (link !== null) {
|
|
1589
|
+
try {
|
|
1590
|
+
validateLinkSchema(link);
|
|
1591
|
+
validateLinkIdentity(link, stem);
|
|
1592
|
+
} catch (error) {
|
|
1593
|
+
parseError = error instanceof TeamDbError ? `${error.code}: ${error.message}` : error.message;
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
db.prepare(UPSERT_TRACKER_LINK_SQL).run(
|
|
1598
|
+
stem,
|
|
1599
|
+
link?.itemId ?? null,
|
|
1600
|
+
link?.taskSlug ?? null,
|
|
1601
|
+
link?.entryId ?? null,
|
|
1602
|
+
link?.role ?? null,
|
|
1603
|
+
link?.decision ?? null,
|
|
1604
|
+
link?.promptPath ?? null,
|
|
1605
|
+
link?.language ?? null,
|
|
1606
|
+
Number.isInteger(link?.revision) ? link.revision : null,
|
|
1607
|
+
isoTimestamp(link?.createdAt),
|
|
1608
|
+
isoTimestamp(link?.updatedAt),
|
|
1609
|
+
Array.isArray(link?.history) ? canonicalJson(link.history) : null,
|
|
1610
|
+
contentHash,
|
|
1611
|
+
parseError,
|
|
1612
|
+
now,
|
|
1613
|
+
now,
|
|
1614
|
+
now,
|
|
1615
|
+
);
|
|
1616
|
+
return { status: existing ? 'updated' : 'inserted', parseError };
|
|
1617
|
+
};
|
|
1618
|
+
export function projectTracker({ db, teamRoot, now, deadlineAt = Infinity }) {
|
|
1547
1619
|
const seenItems = new Set();
|
|
1548
1620
|
const seenEntries = new Set();
|
|
1621
|
+
const seenLinks = new Set();
|
|
1549
1622
|
const counters = { inserted: 0, updated: 0, unchanged: 0, failed: 0, absent: 0 };
|
|
1550
1623
|
const errors = [];
|
|
1551
1624
|
db.exec('BEGIN IMMEDIATE');
|
|
1552
1625
|
try {
|
|
1553
|
-
for (const stem of
|
|
1626
|
+
for (const stem of listTrackerJsonFiles(teamRoot, TRACKER_ITEM_DIR)) {
|
|
1554
1627
|
seenItems.add(stem);
|
|
1555
1628
|
try {
|
|
1556
|
-
const { status, parseError } =
|
|
1629
|
+
const { status, parseError } = projectTrackerItem({ db, teamRoot, stem, now, deadlineAt });
|
|
1557
1630
|
counters[status] += 1;
|
|
1558
1631
|
if (parseError !== null) {
|
|
1559
1632
|
counters.failed += 1;
|
|
1560
|
-
errors.push({ path: `${
|
|
1633
|
+
errors.push({ path: `${TRACKER_ITEM_DIR}/${stem}.json`, reason: parseError });
|
|
1561
1634
|
}
|
|
1562
1635
|
} catch (error) {
|
|
1563
1636
|
if (error instanceof TeamDbError) throw error;
|
|
1564
1637
|
counters.failed += 1;
|
|
1565
|
-
errors.push({ path: `${
|
|
1638
|
+
errors.push({ path: `${TRACKER_ITEM_DIR}/${stem}.json`, reason: error.message });
|
|
1566
1639
|
}
|
|
1567
1640
|
}
|
|
1568
|
-
for (const stem of
|
|
1641
|
+
for (const stem of listTrackerJsonFiles(teamRoot, TRACKER_QUEUE_DIR)) {
|
|
1569
1642
|
seenEntries.add(stem);
|
|
1570
1643
|
try {
|
|
1571
|
-
const { status, parseError } =
|
|
1644
|
+
const { status, parseError } = projectTrackerEntry({ db, teamRoot, stem, now, deadlineAt });
|
|
1572
1645
|
counters[status] += 1;
|
|
1573
1646
|
if (parseError !== null) {
|
|
1574
1647
|
counters.failed += 1;
|
|
1575
|
-
errors.push({ path: `${
|
|
1648
|
+
errors.push({ path: `${TRACKER_QUEUE_DIR}/${stem}.json`, reason: parseError });
|
|
1576
1649
|
}
|
|
1577
1650
|
} catch (error) {
|
|
1578
1651
|
if (error instanceof TeamDbError) throw error;
|
|
1579
1652
|
counters.failed += 1;
|
|
1580
|
-
errors.push({ path: `${
|
|
1653
|
+
errors.push({ path: `${TRACKER_QUEUE_DIR}/${stem}.json`, reason: error.message });
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
for (const stem of listTrackerJsonFiles(teamRoot, TRACKER_LINK_DIR)) {
|
|
1657
|
+
seenLinks.add(stem);
|
|
1658
|
+
try {
|
|
1659
|
+
const { status, parseError } = projectTrackerLink({ db, teamRoot, stem, now, deadlineAt });
|
|
1660
|
+
counters[status] += 1;
|
|
1661
|
+
if (parseError !== null) {
|
|
1662
|
+
counters.failed += 1;
|
|
1663
|
+
errors.push({ path: `${TRACKER_LINK_DIR}/${stem}.json`, reason: parseError });
|
|
1664
|
+
}
|
|
1665
|
+
} catch (error) {
|
|
1666
|
+
if (error instanceof TeamDbError) throw error;
|
|
1667
|
+
counters.failed += 1;
|
|
1668
|
+
errors.push({ path: `${TRACKER_LINK_DIR}/${stem}.json`, reason: error.message });
|
|
1581
1669
|
}
|
|
1582
1670
|
}
|
|
1583
1671
|
const markAbsent = (table, keyColumn, seen) => {
|
|
1584
1672
|
for (const row of db.prepare(`SELECT ${keyColumn} AS key FROM ${table} WHERE absent_at IS NULL`).all()) {
|
|
1585
|
-
if (seen.has(row.key)) continue;
|
|
1673
|
+
if (seen.has(String(row.key))) continue;
|
|
1586
1674
|
db.prepare(`UPDATE ${table} SET absent_at = ? WHERE ${keyColumn} = ? AND absent_at IS NULL`).run(now, row.key);
|
|
1587
1675
|
counters.absent += 1;
|
|
1588
1676
|
}
|
|
1589
1677
|
};
|
|
1590
|
-
markAbsent('
|
|
1591
|
-
markAbsent('
|
|
1678
|
+
markAbsent('tracker_items', 'id', seenItems);
|
|
1679
|
+
markAbsent('tracker_queue', 'entry_id', seenEntries);
|
|
1680
|
+
markAbsent('tracker_item_tasks', 'link_id', seenLinks);
|
|
1592
1681
|
db.exec('COMMIT');
|
|
1593
1682
|
} catch (error) {
|
|
1594
1683
|
try {
|
|
@@ -1728,6 +1817,26 @@ const defaultDeadline = (slug) => (slug ? DEFAULT_SLUG_DEADLINE_MS : Infinity);
|
|
|
1728
1817
|
* Returns the `SyncResult` shape; throws `TeamDbError` for database-level
|
|
1729
1818
|
* failures, usage errors, and deadline expiry.
|
|
1730
1819
|
*/
|
|
1820
|
+
/**
|
|
1821
|
+
* Project only the tracker store. The write verbs call this after a tracker
|
|
1822
|
+
* write so the read-only API sees the new rows without paying for a full task
|
|
1823
|
+
* walk; the next full sync reconciles every other surface.
|
|
1824
|
+
*/
|
|
1825
|
+
export function syncTrackerProjection(options = {}) {
|
|
1826
|
+
const handle = openTeamDb({
|
|
1827
|
+
teamRoot: options.teamRoot,
|
|
1828
|
+
dbPath: options.dbPath,
|
|
1829
|
+
env: options.env,
|
|
1830
|
+
});
|
|
1831
|
+
try {
|
|
1832
|
+
const now = (options.now ?? new Date()).toISOString();
|
|
1833
|
+
const deadlineAt = Date.now() + (options.deadlineMs ?? 4_000);
|
|
1834
|
+
return projectTracker({ db: handle.db, teamRoot: handle.teamRoot, now, deadlineAt });
|
|
1835
|
+
} finally {
|
|
1836
|
+
handle.db.close();
|
|
1837
|
+
}
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1731
1840
|
export function syncProjection(options = {}) {
|
|
1732
1841
|
const slug = options.slug ?? null;
|
|
1733
1842
|
const maintain = Boolean(options.maintain || options.vacuum);
|
|
@@ -1816,27 +1925,27 @@ export function syncProjection(options = {}) {
|
|
|
1816
1925
|
}
|
|
1817
1926
|
if (prune) {
|
|
1818
1927
|
result.pruned += db.prepare('DELETE FROM tasks WHERE absent_at IS NOT NULL').run().changes;
|
|
1819
|
-
//
|
|
1820
|
-
result.pruned += db.prepare('DELETE FROM
|
|
1821
|
-
result.pruned += db.prepare('DELETE FROM
|
|
1928
|
+
// Tracker rows follow their files: pruning deletes rows marked absent.
|
|
1929
|
+
result.pruned += db.prepare('DELETE FROM tracker_queue WHERE absent_at IS NOT NULL').run().changes;
|
|
1930
|
+
result.pruned += db.prepare('DELETE FROM tracker_items WHERE absent_at IS NOT NULL').run().changes;
|
|
1822
1931
|
}
|
|
1823
|
-
// Projection order is tasks ->
|
|
1824
|
-
// -> retention. The
|
|
1932
|
+
// Projection order is tasks -> tracker -> jobs.json -> runs/** (FK-safe)
|
|
1933
|
+
// -> retention. The tracker walk is two bounded listings, runs in slug
|
|
1825
1934
|
// mode too, and stays inside the deadline budget (WP3 VERIFY: 200 items
|
|
1826
1935
|
// must cost well under 250 ms).
|
|
1827
1936
|
{
|
|
1828
|
-
const
|
|
1937
|
+
const trackerProjection = projectTracker({
|
|
1829
1938
|
db,
|
|
1830
1939
|
teamRoot: handle.teamRoot,
|
|
1831
1940
|
now: new Date().toISOString(),
|
|
1832
1941
|
deadlineAt,
|
|
1833
1942
|
});
|
|
1834
|
-
result.inserted +=
|
|
1835
|
-
result.updated +=
|
|
1836
|
-
result.unchanged +=
|
|
1837
|
-
result.absent +=
|
|
1838
|
-
result.failed +=
|
|
1839
|
-
for (const error of
|
|
1943
|
+
result.inserted += trackerProjection.inserted;
|
|
1944
|
+
result.updated += trackerProjection.updated;
|
|
1945
|
+
result.unchanged += trackerProjection.unchanged;
|
|
1946
|
+
result.absent += trackerProjection.absent;
|
|
1947
|
+
result.failed += trackerProjection.failed;
|
|
1948
|
+
for (const error of trackerProjection.errors) result.errors.push(error);
|
|
1840
1949
|
}
|
|
1841
1950
|
if (!slug) {
|
|
1842
1951
|
const schedulerProjection = projectScheduler(db, { teamRoot: handle.teamRoot });
|
|
@@ -887,6 +887,10 @@ const writeLease = (teamRoot, lease) => {
|
|
|
887
887
|
*/
|
|
888
888
|
const claimLease = (teamRoot, lease) => {
|
|
889
889
|
const paths = schedulerPaths(teamRoot);
|
|
890
|
+
// The replaced writeLease created the directory through writeAtomic; the
|
|
891
|
+
// exclusive create must do the same, or a bare team root fails with ENOENT.
|
|
892
|
+
// Two contenders both mkdir recursively, then exactly one `wx` wins.
|
|
893
|
+
fs.mkdirSync(path.dirname(paths.lock), { recursive: true, mode: 0o700 });
|
|
890
894
|
let fd;
|
|
891
895
|
try {
|
|
892
896
|
fd = fs.openSync(paths.lock, 'wx', 0o600);
|
|
@@ -397,11 +397,10 @@ CREATE INDEX idx_job_run_events_at ON job_run_events(at);
|
|
|
397
397
|
`;
|
|
398
398
|
|
|
399
399
|
/**
|
|
400
|
-
* Migration 3: the backlog projection.
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
* a broken file set projects as a recorded error instead of aborting the run.
|
|
400
|
+
* Migration 3: the shipped backlog projection. Kept byte-for-byte because
|
|
401
|
+
* migration history is immutable; migration 4 replaces it with the integer-id
|
|
402
|
+
* tracker surface. Its rows are not carried across: the projection is rebuilt
|
|
403
|
+
* from the files after `tracker migrate-ids`.
|
|
405
404
|
*/
|
|
406
405
|
export const BACKLOG_SQL = SQL`CREATE TABLE backlog_items (
|
|
407
406
|
id TEXT PRIMARY KEY,
|
|
@@ -473,6 +472,116 @@ CREATE INDEX idx_backlog_queue_status ON backlog_queue(status, requested_at);
|
|
|
473
472
|
CREATE INDEX idx_backlog_queue_item ON backlog_queue(item_id);
|
|
474
473
|
`;
|
|
475
474
|
|
|
475
|
+
/**
|
|
476
|
+
* Migration 4: the integer-id tracker surface. Tracker tables carry the
|
|
477
|
+
* `backlog` status and a numeric item key, the queue gains task/link columns,
|
|
478
|
+
* and `tracker_item_tasks` holds the item↔task relation. The old backlog tables
|
|
479
|
+
* are dropped without a row copy: the projection is derived from the files and
|
|
480
|
+
* the next sync rebuilds it. Migration 3 stays byte-identical.
|
|
481
|
+
*/
|
|
482
|
+
export const TRACKER_SQL = SQL`CREATE TABLE tracker_items (
|
|
483
|
+
id INTEGER PRIMARY KEY,
|
|
484
|
+
title TEXT,
|
|
485
|
+
status TEXT CHECK (status IS NULL OR status IN ('backlog','planned','completed','cancelled','superseded')),
|
|
486
|
+
priority INTEGER CHECK (priority IS NULL OR priority BETWEEN 0 AND 9),
|
|
487
|
+
type TEXT,
|
|
488
|
+
description TEXT,
|
|
489
|
+
labels_json TEXT,
|
|
490
|
+
source_task TEXT,
|
|
491
|
+
source_refs_json TEXT,
|
|
492
|
+
revision INTEGER,
|
|
493
|
+
created_at TEXT,
|
|
494
|
+
updated_at TEXT,
|
|
495
|
+
completed_at TEXT,
|
|
496
|
+
cancelled_at TEXT,
|
|
497
|
+
cancel_reason TEXT,
|
|
498
|
+
superseded_by INTEGER,
|
|
499
|
+
history_json TEXT,
|
|
500
|
+
content_hash TEXT,
|
|
501
|
+
parse_error TEXT,
|
|
502
|
+
projected_at TEXT NOT NULL,
|
|
503
|
+
first_seen_at TEXT NOT NULL,
|
|
504
|
+
last_seen_at TEXT NOT NULL,
|
|
505
|
+
absent_at TEXT
|
|
506
|
+
) STRICT;
|
|
507
|
+
|
|
508
|
+
CREATE TABLE tracker_item_deps (
|
|
509
|
+
item_id INTEGER NOT NULL,
|
|
510
|
+
dep_id INTEGER NOT NULL,
|
|
511
|
+
ordinal INTEGER NOT NULL,
|
|
512
|
+
PRIMARY KEY (item_id, dep_id)
|
|
513
|
+
) STRICT;
|
|
514
|
+
|
|
515
|
+
CREATE TABLE tracker_queue (
|
|
516
|
+
entry_id TEXT PRIMARY KEY,
|
|
517
|
+
item_id INTEGER NOT NULL,
|
|
518
|
+
task_slug TEXT,
|
|
519
|
+
link_id TEXT,
|
|
520
|
+
status TEXT CHECK (status IS NULL OR status IN ('queued','claimed','cancelled','expired')),
|
|
521
|
+
reason TEXT,
|
|
522
|
+
requested_by TEXT,
|
|
523
|
+
command TEXT,
|
|
524
|
+
revision INTEGER,
|
|
525
|
+
requested_at TEXT,
|
|
526
|
+
claimed_at TEXT,
|
|
527
|
+
finished_at TEXT,
|
|
528
|
+
history_json TEXT,
|
|
529
|
+
content_hash TEXT,
|
|
530
|
+
parse_error TEXT,
|
|
531
|
+
projected_at TEXT NOT NULL,
|
|
532
|
+
first_seen_at TEXT NOT NULL,
|
|
533
|
+
last_seen_at TEXT NOT NULL,
|
|
534
|
+
absent_at TEXT
|
|
535
|
+
) STRICT;
|
|
536
|
+
|
|
537
|
+
CREATE TABLE tracker_queue_events (
|
|
538
|
+
entry_id TEXT NOT NULL,
|
|
539
|
+
seq INTEGER NOT NULL CHECK (seq >= 1),
|
|
540
|
+
at TEXT,
|
|
541
|
+
type TEXT,
|
|
542
|
+
actor TEXT,
|
|
543
|
+
detail TEXT,
|
|
544
|
+
PRIMARY KEY (entry_id, seq)
|
|
545
|
+
) STRICT;
|
|
546
|
+
|
|
547
|
+
CREATE TABLE tracker_item_tasks (
|
|
548
|
+
link_id TEXT PRIMARY KEY,
|
|
549
|
+
item_id INTEGER NOT NULL,
|
|
550
|
+
task_slug TEXT NOT NULL,
|
|
551
|
+
entry_id TEXT,
|
|
552
|
+
role TEXT,
|
|
553
|
+
decision TEXT CHECK (decision IS NULL OR decision IN ('requested','stopped','unlinked')),
|
|
554
|
+
prompt_path TEXT,
|
|
555
|
+
language TEXT,
|
|
556
|
+
revision INTEGER,
|
|
557
|
+
created_at TEXT,
|
|
558
|
+
updated_at TEXT,
|
|
559
|
+
history_json TEXT,
|
|
560
|
+
content_hash TEXT,
|
|
561
|
+
parse_error TEXT,
|
|
562
|
+
projected_at TEXT NOT NULL,
|
|
563
|
+
first_seen_at TEXT NOT NULL,
|
|
564
|
+
last_seen_at TEXT NOT NULL,
|
|
565
|
+
absent_at TEXT
|
|
566
|
+
) STRICT;
|
|
567
|
+
|
|
568
|
+
-- The projection is derived: the first sync rebuilds it from the files.
|
|
569
|
+
DROP TABLE backlog_item_deps;
|
|
570
|
+
DROP TABLE backlog_queue_events;
|
|
571
|
+
DROP TABLE backlog_queue;
|
|
572
|
+
DROP TABLE backlog_items;
|
|
573
|
+
|
|
574
|
+
CREATE INDEX idx_tracker_items_order ON tracker_items(status, priority, created_at, id);
|
|
575
|
+
CREATE INDEX idx_tracker_items_source ON tracker_items(source_task);
|
|
576
|
+
CREATE INDEX idx_tracker_item_deps_dep ON tracker_item_deps(dep_id);
|
|
577
|
+
CREATE INDEX idx_tracker_queue_status ON tracker_queue(status, requested_at);
|
|
578
|
+
CREATE INDEX idx_tracker_queue_item ON tracker_queue(item_id);
|
|
579
|
+
CREATE INDEX idx_tracker_queue_task ON tracker_queue(task_slug);
|
|
580
|
+
CREATE INDEX idx_tracker_item_tasks_item ON tracker_item_tasks(item_id);
|
|
581
|
+
CREATE INDEX idx_tracker_item_tasks_task ON tracker_item_tasks(task_slug);
|
|
582
|
+
CREATE INDEX idx_tracker_item_tasks_decision ON tracker_item_tasks(decision);
|
|
583
|
+
`;
|
|
584
|
+
|
|
476
585
|
const sha256 = (value) => crypto.createHash('sha256').update(value).digest('hex');
|
|
477
586
|
|
|
478
587
|
/**
|
|
@@ -498,6 +607,12 @@ export const MIGRATIONS = [
|
|
|
498
607
|
sql: BACKLOG_SQL,
|
|
499
608
|
checksum: '430c079a4ec42bc93094f364df228c2f55772e1f9e8f1e0e509b1d16c2de7f90',
|
|
500
609
|
},
|
|
610
|
+
{
|
|
611
|
+
version: 4,
|
|
612
|
+
name: '0004-tracker',
|
|
613
|
+
sql: TRACKER_SQL,
|
|
614
|
+
checksum: '641f18c269a1595d1fb1e4878f9919e9d41a257d030cf1f65ee07fb99ac55552',
|
|
615
|
+
},
|
|
501
616
|
];
|
|
502
617
|
|
|
503
618
|
/** Highest migration version shipped by this module. */
|
|
@@ -530,6 +645,29 @@ const isTruthy = (value) => {
|
|
|
530
645
|
|
|
531
646
|
export const isKillSwitchSet = (env = process.env) => isTruthy(env.AI_RULES_TEAM_DB_DISABLE);
|
|
532
647
|
|
|
648
|
+
/**
|
|
649
|
+
* Repository identity of one team root: the first 12 hex characters of
|
|
650
|
+
* `sha256(<resolved team root>)`.
|
|
651
|
+
*
|
|
652
|
+
* The path is canonicalised through `realpath` when it exists, so a symlinked
|
|
653
|
+
* spelling of the same repository hashes like the real one; a path that does not
|
|
654
|
+
* exist yet falls back to `path.resolve`. The API publishes the value as
|
|
655
|
+
* `/health.rootId` and the `ui` supervisor compares it with its own hash, so two
|
|
656
|
+
* repositories that find each other on one port are a named refusal instead of a
|
|
657
|
+
* silent cross-wired dashboard. It is a hash, never a path: the value discloses
|
|
658
|
+
* nothing about the filesystem.
|
|
659
|
+
*/
|
|
660
|
+
export const teamRootId = (teamRoot) => {
|
|
661
|
+
const resolved = path.resolve(teamRoot);
|
|
662
|
+
let identity = resolved;
|
|
663
|
+
try {
|
|
664
|
+
identity = fs.realpathSync(resolved);
|
|
665
|
+
} catch {
|
|
666
|
+
identity = resolved;
|
|
667
|
+
}
|
|
668
|
+
return crypto.createHash('sha256').update(identity).digest('hex').slice(0, 12);
|
|
669
|
+
};
|
|
670
|
+
|
|
533
671
|
const parseNodeVersion = (version) => {
|
|
534
672
|
const match = /^(\d+)\.(\d+)\.(\d+)/.exec(String(version || ''));
|
|
535
673
|
if (!match) return null;
|