@bonesofspring/ai-rules 0.2.64 → 0.2.65
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 +46 -11
- package/README.md +6 -6
- package/bin/lib/engine-scripts.js +14 -5
- package/bin/lib/seed-ai-local-team.js +7 -0
- package/docs/PRESET-CONTRIBUTION.md +41 -0
- package/docs/TEAM-DB.md +193 -52
- 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 +26 -20
- 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 +104 -23
- package/presets/_shared/core/agent-team/agent-team-orchestrator.md +1 -1
- 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/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 +1 -1
- package/presets/claude/android-kotlin/settings.json +6 -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/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/go/settings.json +6 -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/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/ios-swift/settings.json +6 -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/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/java/settings.json +6 -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/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/mcp-ts/settings.json +6 -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/tooling-and-review/agent-team-orchestrator.md +1 -1
- 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/commands/README.md +6 -0
- 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/stack/next-app-core.md +1 -0
- package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- 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/nuxt/hooks/chain-team-phases.sh +105 -17
- package/presets/claude/nuxt/hooks/guard-shell-command.mjs +41 -2
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/nuxt/settings.json +6 -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/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/php-hexagonal/settings.json +6 -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/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/php-laravel/settings.json +6 -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/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/svelte/settings.json +6 -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/go/hooks/chain-team-phases.sh +105 -17
- package/presets/cursor/go/hooks/guard-shell-command.mjs +41 -2
- 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/java/hooks/chain-team-phases.sh +105 -17
- package/presets/cursor/java/hooks/guard-shell-command.mjs +41 -2
- 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/mol/hooks/chain-team-phases.sh +105 -17
- package/presets/cursor/mol/hooks/guard-shell-command.mjs +41 -2
- 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/ai-local/rules-library/storybook-dev-compare-figma.md +1 -1
- package/presets/cursor/next/commands/README.md +6 -0
- 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/dev-process-lifecycle.mdc +43 -0
- package/presets/cursor/next/rules/next-app-core.mdc +1 -0
- 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/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-laravel/hooks/chain-team-phases.sh +106 -18
- package/presets/cursor/php-laravel/hooks/guard-shell-command.mjs +41 -2
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +105 -17
- package/presets/cursor/svelte/hooks/guard-shell-command.mjs +41 -2
- package/presets/mavis/android-kotlin/adapter-map.json +1 -1
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/go/adapter-map.json +1 -1
- package/presets/mavis/go/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/go/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/ios-swift/adapter-map.json +1 -1
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/java/adapter-map.json +1 -1
- package/presets/mavis/java/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/java/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/mcp-ts/adapter-map.json +1 -1
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/mol/adapter-map.json +1 -1
- package/presets/mavis/mol/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/mol/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/next/MCP.md +2 -0
- package/presets/mavis/next/REPO_AGENTS.md +2 -0
- package/presets/mavis/next/adapter-map.json +25 -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/ai-local/rules-library/storybook-dev-compare-figma.md +1 -1
- package/presets/mavis/next/commands/README.md +6 -0
- 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 +1 -1
- package/presets/mavis/next/rules/dev-process-lifecycle.md +38 -0
- package/presets/mavis/next/rules/next-app-core.md +1 -0
- package/presets/mavis/nuxt/adapter-map.json +1 -1
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/php-hexagonal/adapter-map.json +1 -1
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/php-laravel/adapter-map.json +1 -1
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +106 -18
- package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/svelte/adapter-map.json +1 -1
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +105 -17
- package/presets/mavis/svelte/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/android-kotlin/adapter-map.json +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 +1 -1
- package/presets/opencode/go/adapter-map.json +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 +1 -1
- package/presets/opencode/ios-swift/adapter-map.json +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 +1 -1
- package/presets/opencode/java/adapter-map.json +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 +1 -1
- package/presets/opencode/mcp-ts/adapter-map.json +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 +1 -1
- package/presets/opencode/mol/adapter-map.json +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 +1 -1
- package/presets/opencode/next/MCP.md +2 -0
- package/presets/opencode/next/REPO_AGENTS.md +2 -0
- package/presets/opencode/next/adapter-map.json +25 -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/ai-local/rules-library/storybook-dev-compare-figma.md +1 -1
- package/presets/opencode/next/commands/README.md +6 -0
- 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 +1 -1
- package/presets/opencode/next/rules/dev-process-lifecycle.md +38 -0
- package/presets/opencode/next/rules/next-app-core.md +1 -0
- package/presets/opencode/nuxt/adapter-map.json +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 +1 -1
- package/presets/opencode/php-hexagonal/adapter-map.json +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 +1 -1
- package/presets/opencode/php-laravel/adapter-map.json +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 +1 -1
- package/presets/opencode/svelte/adapter-map.json +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 +1 -1
- package/presets/zcode/android-kotlin/adapter-map.json +1 -1
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/go/adapter-map.json +1 -1
- package/presets/zcode/go/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/go/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/ios-swift/adapter-map.json +1 -1
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/java/adapter-map.json +1 -1
- package/presets/zcode/java/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/java/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/mcp-ts/adapter-map.json +1 -1
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/mol/adapter-map.json +1 -1
- package/presets/zcode/mol/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/mol/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/next/MCP.md +2 -0
- package/presets/zcode/next/REPO_AGENTS.md +2 -0
- package/presets/zcode/next/adapter-map.json +25 -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/ai-local/rules-library/storybook-dev-compare-figma.md +1 -1
- package/presets/zcode/next/commands/README.md +6 -0
- 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 +1 -1
- package/presets/zcode/next/rules/dev-process-lifecycle.md +38 -0
- package/presets/zcode/next/rules/next-app-core.md +1 -0
- package/presets/zcode/nuxt/adapter-map.json +1 -1
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/php-hexagonal/adapter-map.json +1 -1
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/php-laravel/adapter-map.json +1 -1
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +106 -18
- package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +1 -1
- package/presets/zcode/svelte/adapter-map.json +1 -1
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +105 -17
- package/presets/zcode/svelte/rules/agent-team-orchestrator.md +1 -1
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
* [--rebuild | --no-rebuild] create or reconcile the database
|
|
14
14
|
* serve [--root <team-dir>] [--host <addr>] [--port <n>] [--allow-remote]
|
|
15
15
|
* [--open] loopback API + dashboard
|
|
16
|
+
* ui start|restart [--host <loopback>] [--port <n>] [--open] [--json]
|
|
17
|
+
* [--quiet] [--root <team-dir>] detached dashboard + marker
|
|
18
|
+
* ui stop|status [--json] [--quiet] [--root <team-dir>]
|
|
16
19
|
* jobs list [--root <team-dir>] [--enabled] [--json] [--quiet]
|
|
17
20
|
* jobs get <id> [--root <team-dir>] [--json]
|
|
18
21
|
* jobs put --file <path|-> [--root <team-dir>] [--json] [--dry-run] [--quiet]
|
|
@@ -22,15 +25,17 @@
|
|
|
22
25
|
* jobs run --id <id> [--root <team-dir>] [--json]
|
|
23
26
|
* schedule [--root <team-dir>] [--once] [--interval-ms <n>] [--grace-ms <n>]
|
|
24
27
|
* [--drain-ms <n>] [--json] [--quiet] the scheduler timer
|
|
25
|
-
*
|
|
26
|
-
* [--root <team-dir>] [--json] [--quiet] the file-authoritative
|
|
28
|
+
* tracker add|set|show|list|ready|validate|import|enqueue|cancel|drain|recover|prune
|
|
29
|
+
* [--root <team-dir>] [--json] [--quiet] the file-authoritative tracker
|
|
27
30
|
*
|
|
28
31
|
* Exit codes: 0 ok, 1 at least one task failed, a delete refusal (unknown slug,
|
|
29
32
|
* active-task guard, kill switch, folder-delete failure) or a migration
|
|
30
33
|
* checksum drifted, 2 database-level failure, 3 usage, 4 deadline or busy.
|
|
31
|
-
* The
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
+
* The `ui` verbs reuse 0/1/2/3: 0 ok or a no-op, 1 a refusal (`E_UI_*` except a
|
|
35
|
+
* start failure), 2 a start failure, 3 usage.
|
|
36
|
+
* The tracker verbs reuse the same vocabulary: 0 ok, 1 a validation refusal
|
|
37
|
+
* (each with its named `E_TRACKER_*`/`E_SCHEMA`/`E_ID_COLLISION` code), 3
|
|
38
|
+
* usage, 4 the tree lock was contended (`E_TRACKER_BUSY`).
|
|
34
39
|
*
|
|
35
40
|
* A runtime without `node:sqlite` prints one line and stays file-only:
|
|
36
41
|
* `init`/`sync`/`migrate-tasks` exit 0 without creating a database, `check` and
|
|
@@ -61,14 +66,14 @@ import {
|
|
|
61
66
|
openTeamDb,
|
|
62
67
|
teamDbFail,
|
|
63
68
|
} from './team-db-schema.mjs';
|
|
64
|
-
import { deleteTaskProjection, describeSyncResult, syncProjection } from './team-db-project.mjs';
|
|
69
|
+
import { deleteTaskProjection, describeSyncResult, syncProjection, syncTrackerProjection } from './team-db-project.mjs';
|
|
65
70
|
import {
|
|
66
71
|
isLeaseFresh,
|
|
67
72
|
runJobsCommand,
|
|
68
73
|
runScheduler,
|
|
69
74
|
schedulerPaths,
|
|
70
75
|
} from './team-db-scheduler.mjs';
|
|
71
|
-
import {
|
|
76
|
+
import { runTrackerCommand } from './team-db-tracker.mjs';
|
|
72
77
|
|
|
73
78
|
const USAGE = `usage:
|
|
74
79
|
team-db.mjs init [--root <team-dir>] [--rebuild]
|
|
@@ -81,6 +86,9 @@ const USAGE = `usage:
|
|
|
81
86
|
[--rebuild | --no-rebuild]
|
|
82
87
|
team-db.mjs serve [--root <team-dir>] [--host <addr>] [--port <n>]
|
|
83
88
|
[--allow-remote] [--open]
|
|
89
|
+
team-db.mjs ui start|restart [--root <team-dir>] [--json] [--quiet]
|
|
90
|
+
[--host <loopback>] [--port <n>] [--open]
|
|
91
|
+
team-db.mjs ui stop|status [--root <team-dir>] [--json] [--quiet]
|
|
84
92
|
team-db.mjs jobs list [--root <team-dir>] [--enabled] [--json] [--quiet]
|
|
85
93
|
team-db.mjs jobs get <id> [--root <team-dir>] [--json]
|
|
86
94
|
team-db.mjs jobs put --file <path|-> [--root <team-dir>] [--json] [--dry-run] [--quiet]
|
|
@@ -90,14 +98,19 @@ const USAGE = `usage:
|
|
|
90
98
|
team-db.mjs jobs run --id <id> [--root <team-dir>] [--json]
|
|
91
99
|
team-db.mjs schedule [--root <team-dir>] [--once] [--interval-ms <n>]
|
|
92
100
|
[--grace-ms <n>] [--drain-ms <n>] [--json] [--quiet]
|
|
93
|
-
team-db.mjs
|
|
94
|
-
team-db.mjs
|
|
95
|
-
team-db.mjs
|
|
101
|
+
team-db.mjs tracker add --file <path|-> [--root <team-dir>] [--json] [--quiet]
|
|
102
|
+
team-db.mjs tracker set <id> --file <path|-> [--root <team-dir>] [--json]
|
|
103
|
+
team-db.mjs tracker show <id> | list [--status <csv>] [--ready] | ready | validate
|
|
96
104
|
[--root <team-dir>] [--json]
|
|
97
|
-
team-db.mjs
|
|
98
|
-
team-db.mjs
|
|
105
|
+
team-db.mjs tracker import --file <path|-> [--dry-run] [--root <team-dir>] [--json]
|
|
106
|
+
team-db.mjs tracker migrate-ids
|
|
107
|
+
team-db.mjs tracker enqueue --file <path|-> | cancel <entryId> | drain [--claim]
|
|
99
108
|
| recover | prune [--older-than <days>]
|
|
100
|
-
[--root <team-dir>] [--json] [--quiet]
|
|
109
|
+
[--root <team-dir>] [--json] [--quiet]
|
|
110
|
+
team-db.mjs task-run start --task <slug> [--item <id>] [--link <linkId>]
|
|
111
|
+
team-db.mjs task-run stop --task <slug> | list --task <slug>
|
|
112
|
+
team-db.mjs task-run show --task <slug> --run <runId> | status | ensure
|
|
113
|
+
[--root <team-dir>] [--json]`;
|
|
101
114
|
|
|
102
115
|
const VALUE_FLAGS = new Set([
|
|
103
116
|
'root',
|
|
@@ -112,6 +125,10 @@ const VALUE_FLAGS = new Set([
|
|
|
112
125
|
'drain-ms',
|
|
113
126
|
'status',
|
|
114
127
|
'older-than',
|
|
128
|
+
'task',
|
|
129
|
+
'item',
|
|
130
|
+
'link',
|
|
131
|
+
'run',
|
|
115
132
|
]);
|
|
116
133
|
const BOOLEAN_FLAGS = new Set([
|
|
117
134
|
'quiet',
|
|
@@ -130,7 +147,7 @@ const BOOLEAN_FLAGS = new Set([
|
|
|
130
147
|
'ready',
|
|
131
148
|
'claim',
|
|
132
149
|
]);
|
|
133
|
-
const COMMANDS = new Set(['init', 'check', 'sync', 'delete', 'migrate-tasks', 'serve', 'jobs', 'schedule', '
|
|
150
|
+
const COMMANDS = new Set(['init', 'check', 'sync', 'delete', 'migrate-tasks', 'serve', 'jobs', 'schedule', 'tracker', 'task-run', 'ui']);
|
|
134
151
|
const ALLOWED_FLAGS = {
|
|
135
152
|
init: new Set(['root', 'rebuild']),
|
|
136
153
|
check: new Set(['root']),
|
|
@@ -140,7 +157,11 @@ const ALLOWED_FLAGS = {
|
|
|
140
157
|
serve: new Set(['root', 'host', 'port', 'allow-remote', 'open']),
|
|
141
158
|
jobs: new Set(['root', 'json', 'quiet', 'enabled', 'file', 'id', 'dry-run', 'keep-runs']),
|
|
142
159
|
schedule: new Set(['root', 'json', 'quiet', 'once', 'interval-ms', 'grace-ms', 'drain-ms']),
|
|
143
|
-
|
|
160
|
+
tracker: new Set(['root', 'json', 'quiet', 'file', 'dry-run', 'older-than', 'status', 'ready', 'claim']),
|
|
161
|
+
'task-run': new Set(['root', 'json', 'task', 'item', 'link', 'run']),
|
|
162
|
+
// The union across the four verbs: `team-db-ui.mjs` owns the per-verb reach
|
|
163
|
+
// table, and `--allow-remote` is absent so it never parses for a `ui` verb.
|
|
164
|
+
ui: new Set(['root', 'json', 'quiet', 'host', 'port', 'open']),
|
|
144
165
|
};
|
|
145
166
|
|
|
146
167
|
const JOBS_POSITIONALS = new Set([
|
|
@@ -154,7 +175,7 @@ const JOBS_POSITIONALS = new Set([
|
|
|
154
175
|
'run',
|
|
155
176
|
]);
|
|
156
177
|
|
|
157
|
-
const
|
|
178
|
+
const TRACKER_POSITIONALS = new Set([
|
|
158
179
|
'add',
|
|
159
180
|
'set',
|
|
160
181
|
'show',
|
|
@@ -167,8 +188,23 @@ const BACKLOG_POSITIONALS = new Set([
|
|
|
167
188
|
'drain',
|
|
168
189
|
'recover',
|
|
169
190
|
'prune',
|
|
191
|
+
'link',
|
|
192
|
+
'delete',
|
|
193
|
+
'adopt',
|
|
194
|
+
'migrate-ids',
|
|
170
195
|
]);
|
|
171
196
|
|
|
197
|
+
const TASK_RUN_POSITIONALS = new Set(['start', 'stop', 'supervise', 'list', 'show', 'status', 'ensure']);
|
|
198
|
+
|
|
199
|
+
const UI_POSITIONALS = new Set(['start', 'stop', 'status', 'restart']);
|
|
200
|
+
|
|
201
|
+
const POSITIONAL_VERBS = {
|
|
202
|
+
jobs: JOBS_POSITIONALS,
|
|
203
|
+
tracker: TRACKER_POSITIONALS,
|
|
204
|
+
'task-run': TASK_RUN_POSITIONALS,
|
|
205
|
+
ui: UI_POSITIONALS,
|
|
206
|
+
};
|
|
207
|
+
|
|
172
208
|
const parseArgs = (argv) => {
|
|
173
209
|
const [command, ...rest] = argv;
|
|
174
210
|
if (command === undefined || command === '--help' || command === 'help') {
|
|
@@ -180,10 +216,10 @@ const parseArgs = (argv) => {
|
|
|
180
216
|
for (let index = 0; index < rest.length; index += 1) {
|
|
181
217
|
const token = rest[index];
|
|
182
218
|
if (!token.startsWith('--')) {
|
|
183
|
-
// `jobs <verb> [id]
|
|
184
|
-
// commands with positional arguments.
|
|
185
|
-
|
|
186
|
-
|
|
219
|
+
// `jobs <verb> [id]`, `tracker <verb> [id|entryId]` and `ui <verb>` are the
|
|
220
|
+
// only commands with positional arguments.
|
|
221
|
+
const verbs = POSITIONAL_VERBS[command];
|
|
222
|
+
if (verbs && positionals.length < 2) {
|
|
187
223
|
if (positionals.length === 0 && !verbs.has(token)) {
|
|
188
224
|
teamDbFail('E_USAGE', `unknown ${command} subcommand "${token}"`, 3);
|
|
189
225
|
}
|
|
@@ -396,10 +432,34 @@ const runJobs = (flags, positionals) => {
|
|
|
396
432
|
}
|
|
397
433
|
};
|
|
398
434
|
|
|
399
|
-
const
|
|
435
|
+
const runTaskRunner = async (flags, positionals) => {
|
|
436
|
+
const [subcommand = 'status'] = positionals;
|
|
437
|
+
try {
|
|
438
|
+
const { runTaskRunnerCommand } = await import('./team-db-task-runner.mjs');
|
|
439
|
+
const result = await runTaskRunnerCommand(subcommand, {
|
|
440
|
+
root: flags.root,
|
|
441
|
+
json: Boolean(flags.json),
|
|
442
|
+
task: flags.task,
|
|
443
|
+
item: flags.item,
|
|
444
|
+
link: flags.link,
|
|
445
|
+
run: flags.run,
|
|
446
|
+
});
|
|
447
|
+
if (result.output) process.stdout.write(result.output);
|
|
448
|
+
return result.exitCode;
|
|
449
|
+
} catch (error) {
|
|
450
|
+
const code = error instanceof TeamDbError ? error.code : 'E_INTERNAL';
|
|
451
|
+
const exitCode = error instanceof TeamDbError ? error.exitCode : 2;
|
|
452
|
+
const failure = { ok: false, code, message: error.message };
|
|
453
|
+
if (flags.json) process.stdout.write(`${JSON.stringify(failure)}\n`);
|
|
454
|
+
process.stderr.write(`${error.message}\n`);
|
|
455
|
+
return exitCode;
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
const runTracker = (flags, positionals) => {
|
|
400
460
|
const [subcommand = 'list', positionalId] = positionals;
|
|
401
461
|
try {
|
|
402
|
-
const result =
|
|
462
|
+
const result = runTrackerCommand(subcommand, positionalId ?? null, {
|
|
403
463
|
root: flags.root,
|
|
404
464
|
json: Boolean(flags.json),
|
|
405
465
|
quiet: Boolean(flags.quiet),
|
|
@@ -411,6 +471,13 @@ const runBacklog = (flags, positionals) => {
|
|
|
411
471
|
claim: Boolean(flags.claim),
|
|
412
472
|
});
|
|
413
473
|
if (result.output) process.stdout.write(result.output);
|
|
474
|
+
if (result.wrote && subcommand !== 'drain' && !cannotProject(process.env)) {
|
|
475
|
+
try {
|
|
476
|
+
syncTrackerProjection({ teamRoot: teamRootFrom(flags), env: process.env });
|
|
477
|
+
} catch {
|
|
478
|
+
/* files stay authoritative; the next sync reconciles the projection */
|
|
479
|
+
}
|
|
480
|
+
}
|
|
414
481
|
return result.exitCode;
|
|
415
482
|
} catch (error) {
|
|
416
483
|
const code = error instanceof TeamDbError ? error.code : 'E_INTERNAL';
|
|
@@ -477,6 +544,11 @@ const runServe = async (flags) => {
|
|
|
477
544
|
unavailableLine();
|
|
478
545
|
return 0;
|
|
479
546
|
}
|
|
547
|
+
// The `ui` supervisor detaches this process and closes both pipes right after
|
|
548
|
+
// the serving line; a later diagnostic write must not crash the server with an
|
|
549
|
+
// EPIPE error event.
|
|
550
|
+
process.stdout.on('error', () => {});
|
|
551
|
+
process.stderr.on('error', () => {});
|
|
480
552
|
// Loaded here, not at module scope: `init`, `sync` and `check` must not pay
|
|
481
553
|
// for the server, the dashboard strings or the OpenAPI document.
|
|
482
554
|
const api = await import('./team-db-api.mjs');
|
|
@@ -505,6 +577,13 @@ const runServe = async (flags) => {
|
|
|
505
577
|
return new Promise(() => {});
|
|
506
578
|
};
|
|
507
579
|
|
|
580
|
+
const runUi = async (flags, positionals) => {
|
|
581
|
+
// Loaded here, not at module scope: `init`, `sync` and `check` never load the
|
|
582
|
+
// supervisor or the server it probes.
|
|
583
|
+
const { runUiCommand } = await import('./team-db-ui.mjs');
|
|
584
|
+
return runUiCommand({ flags, positionals });
|
|
585
|
+
};
|
|
586
|
+
|
|
508
587
|
export async function runCli(argv) {
|
|
509
588
|
const { command, flags, positionals } = parseArgs(argv);
|
|
510
589
|
if (command === 'help') {
|
|
@@ -517,7 +596,9 @@ export async function runCli(argv) {
|
|
|
517
596
|
if (command === 'migrate-tasks') return runMigrateTasks(flags);
|
|
518
597
|
if (command === 'serve') return runServe(flags);
|
|
519
598
|
if (command === 'jobs') return runJobs(flags, positionals);
|
|
520
|
-
if (command === '
|
|
599
|
+
if (command === 'tracker') return runTracker(flags, positionals);
|
|
600
|
+
if (command === 'task-run') return runTaskRunner(flags, positionals);
|
|
601
|
+
if (command === 'ui') return runUi(flags, positionals);
|
|
521
602
|
if (command === 'schedule') return runSchedule(flags);
|
|
522
603
|
return runSync(flags);
|
|
523
604
|
}
|
|
@@ -205,7 +205,7 @@ Additional states: `blocked` — a step (or a parallel producer) cannot proceed;
|
|
|
205
205
|
|
|
206
206
|
- Pause new steps with a file at `.ai.local/STOP` (also accepted: `.ai.local/ESTOP`). The chain hook finishes the in-flight attempt and its terminal receipt, records `state: paused` / `phase: paused`, and emits no handoff. An empty or corrupt sentinel still counts as engaged.
|
|
207
207
|
- A paused human gate stays open: the pause check runs before `end_human_gate` closes it, so removing the sentinel and running `/task-continue <slug>` reruns the same gate resume.
|
|
208
|
-
- Remove the sentinel, then run `/task-continue <slug>`. Only the hook writes the `paused` state; never edit `status.json` to pause or resume.
|
|
208
|
+
- Remove the sentinel (`.ai.local/STOP`, `.ai.local/ESTOP`, or the per-task `.ai.local/team/tasks/<slug>/STOP` written by a tracker Stop), then run `/task-continue <slug>`. Only the hook writes the `paused` state; never edit `status.json` to pause or resume.
|
|
209
209
|
- An `activeAttempts` entry for the step being activated (or a sibling in the same parallel group) older than `AI_RULES_ATTEMPT_STALE_MS` with no terminal manifest receipt is reclaimed as `attempt_finished` with `outcome: stale` and `source: hook`, removed from `activeAttempts`, and that activation opens a new attempt. The override is **milliseconds** (default `3600000`, one hour); a value below the `60000` floor falls back to the default. An attempt belonging to another step is never reclaimed — its own activation owns it. A terminal receipt always wins; a fresh attempt is never reclaimed. The stale entry stays in the metrics ledger.
|
|
210
210
|
- The reclaim runs only inside the hook, immediately before a new attempt is activated. Never hand-reclaim an attempt by editing `.ai.local/team/tasks/<slug>` lifecycle files.
|
|
211
211
|
- In graph mode, a stale attempt on an in-flight step of another agent is reclaimed by that step's own activation or terminal receipt, not by an unrelated step; recovery is a receipt or `/task-continue <slug>`.
|
|
@@ -1361,7 +1361,11 @@ const PAUSE_SENTINELS = [
|
|
|
1361
1361
|
path.join(process.cwd(), '.ai.local', 'ESTOP'),
|
|
1362
1362
|
];
|
|
1363
1363
|
function readPauseSentinel() {
|
|
1364
|
-
|
|
1364
|
+
const sentinels = [...PAUSE_SENTINELS];
|
|
1365
|
+
if (typeof slug === 'string' && slug !== '') {
|
|
1366
|
+
sentinels.push(path.join(process.cwd(), '.ai.local', 'team', 'tasks', slug, 'STOP'));
|
|
1367
|
+
}
|
|
1368
|
+
for (const file of sentinels) {
|
|
1365
1369
|
let stat = null;
|
|
1366
1370
|
try { stat = fs.statSync(file); } catch (error) {
|
|
1367
1371
|
if (error && error.code === 'ENOENT') continue;
|
|
@@ -2625,6 +2629,60 @@ const fs = require('fs');
|
|
|
2625
2629
|
const path = require('path');
|
|
2626
2630
|
const { spawnSync } = require('child_process');
|
|
2627
2631
|
|
|
2632
|
+
// Dev-server cleanup: terminal task state only. `processes.mjs` proves
|
|
2633
|
+
// ownership from `.ai.local/.processes/leases/<name>.json` before any signal,
|
|
2634
|
+
// so a foreign process is never touched. A refusal or timeout is a warning,
|
|
2635
|
+
// never a hook failure.
|
|
2636
|
+
function stopOwnedDevServers() {
|
|
2637
|
+
const processes = path.join(process.cwd(), '.ai.local', 'scripts', 'processes.mjs');
|
|
2638
|
+
if (!fs.existsSync(processes)) return;
|
|
2639
|
+
const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
2640
|
+
let slug = typeof process.env.TEAM_TASK_SLUG === 'string' ? process.env.TEAM_TASK_SLUG : '';
|
|
2641
|
+
if (!slug) {
|
|
2642
|
+
try {
|
|
2643
|
+
const active = JSON.parse(
|
|
2644
|
+
fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'active-task.json'), 'utf8'),
|
|
2645
|
+
);
|
|
2646
|
+
slug = typeof active.slug === 'string' ? active.slug : '';
|
|
2647
|
+
} catch {
|
|
2648
|
+
return;
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
if (slug.length === 0 || slug.length > 48 || !SLUG_RE.test(slug)) return;
|
|
2652
|
+
let state = '';
|
|
2653
|
+
try {
|
|
2654
|
+
const status = JSON.parse(
|
|
2655
|
+
fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'tasks', slug, 'status.json'), 'utf8'),
|
|
2656
|
+
);
|
|
2657
|
+
state = typeof status.state === 'string' ? status.state : '';
|
|
2658
|
+
} catch {
|
|
2659
|
+
return;
|
|
2660
|
+
}
|
|
2661
|
+
if (state !== 'completed' && state !== 'blocked') return;
|
|
2662
|
+
const result = spawnSync(process.execPath, [processes, 'stop', '--task', slug, '--root', process.cwd()], {
|
|
2663
|
+
cwd: process.cwd(),
|
|
2664
|
+
encoding: 'utf8',
|
|
2665
|
+
timeout: 8000,
|
|
2666
|
+
killSignal: 'SIGKILL',
|
|
2667
|
+
});
|
|
2668
|
+
if (result.stdout) process.stderr.write(result.stdout);
|
|
2669
|
+
if (result.stderr) process.stderr.write(result.stderr);
|
|
2670
|
+
if (result.error) {
|
|
2671
|
+
const timedOut = result.error.code === 'ETIMEDOUT';
|
|
2672
|
+
process.stderr.write(
|
|
2673
|
+
`WARNING: dev-server cleanup ${timedOut ? 'timed out after 8s' : `failed: ${result.error.message}`}\n`,
|
|
2674
|
+
);
|
|
2675
|
+
} else if (result.status !== 0) {
|
|
2676
|
+
process.stderr.write(`WARNING: dev-server cleanup exited ${result.status}; inspect .ai.local/.processes/leases/** by hand\n`);
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
try {
|
|
2681
|
+
stopOwnedDevServers();
|
|
2682
|
+
} catch {
|
|
2683
|
+
// Cleanup never fails the stop.
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2628
2686
|
// <<<standards-draft>>>
|
|
2629
2687
|
// Explicit payload only. This postflight never walks the repo and never
|
|
2630
2688
|
// creates `.ai.local/rules/`. The same provenance tag does not rewrite an
|
|
@@ -2915,35 +2973,35 @@ function teamDbProject() {
|
|
|
2915
2973
|
}
|
|
2916
2974
|
|
|
2917
2975
|
teamDbProject();
|
|
2918
|
-
// ---
|
|
2919
|
-
// The launch queue's stop-seam drain. The
|
|
2976
|
+
// --- TEAM_DB_TRACKER_DRAIN (A-1, D-5) ----------------------------------------
|
|
2977
|
+
// The launch queue's stop-seam drain. The tracker module never starts a run:
|
|
2920
2978
|
// this seam claims at most one entry and bootstraps the task folder the claim
|
|
2921
2979
|
// names, so the next orchestration turn routes it. The recorded `command` is
|
|
2922
|
-
// never executed. `
|
|
2980
|
+
// never executed. `AI_RULES_TEAM_DB_TRACKER_DRAIN_DISABLE=1` stops this
|
|
2923
2981
|
// auto-drain trigger only; the file verbs stay usable. A disabled switch, a
|
|
2924
2982
|
// missing script, a lost race, or an invalid claim slug is a skip; a child
|
|
2925
2983
|
// failure is one log line. The seam never fails the stop.
|
|
2926
|
-
function
|
|
2984
|
+
function teamDbTrackerDrain() {
|
|
2927
2985
|
try {
|
|
2928
2986
|
const env = process.env;
|
|
2929
|
-
if (teamDbTruthy(env.
|
|
2987
|
+
if (teamDbTruthy(env.AI_RULES_TEAM_DB_TRACKER_DRAIN_DISABLE)) return;
|
|
2930
2988
|
const script = path.join(process.cwd(), '.ai.local', 'scripts', 'team-db.mjs');
|
|
2931
2989
|
if (!fs.existsSync(script)) return;
|
|
2932
2990
|
const result = spawnSync(
|
|
2933
2991
|
process.execPath,
|
|
2934
|
-
['.ai.local/scripts/team-db.mjs', '
|
|
2992
|
+
['.ai.local/scripts/team-db.mjs', 'tracker', 'drain', '--claim', '--quiet', '--json'],
|
|
2935
2993
|
{ cwd: process.cwd(), env: env, encoding: 'utf8', timeout: 5000, killSignal: 'SIGKILL', stdio: ['ignore', 'pipe', 'pipe'] },
|
|
2936
2994
|
);
|
|
2937
2995
|
if (result.error && result.error.code === 'ETIMEDOUT') {
|
|
2938
|
-
teamDbLogFailure(env, '
|
|
2996
|
+
teamDbLogFailure(env, 'E_TRACKER_DRAIN_TIMEOUT', 'tracker drain exceeded 5000 ms and was killed');
|
|
2939
2997
|
return;
|
|
2940
2998
|
}
|
|
2941
2999
|
if (result.error) {
|
|
2942
|
-
teamDbLogFailure(env, '
|
|
3000
|
+
teamDbLogFailure(env, 'E_TRACKER_DRAIN_FAILED', 'tracker drain could not start: ' + String(result.error.code || 'unknown'));
|
|
2943
3001
|
return;
|
|
2944
3002
|
}
|
|
2945
3003
|
if (typeof result.status === 'number' && result.status !== 0) {
|
|
2946
|
-
teamDbLogFailure(env, '
|
|
3004
|
+
teamDbLogFailure(env, 'E_TRACKER_DRAIN_FAILED', 'tracker drain exited ' + result.status);
|
|
2947
3005
|
return;
|
|
2948
3006
|
}
|
|
2949
3007
|
let payload = null;
|
|
@@ -2954,28 +3012,58 @@ function teamDbBacklogDrain() {
|
|
|
2954
3012
|
}
|
|
2955
3013
|
const claim = payload && payload.claim;
|
|
2956
3014
|
if (!claim || typeof claim.slug !== 'string' || claim.slug === '') return;
|
|
3015
|
+
const claimSlug = typeof claim.taskSlug === 'string' && claim.taskSlug !== '' ? claim.taskSlug : claim.slug;
|
|
2957
3016
|
// The slug is re-validated against the existing grammar before any write,
|
|
2958
3017
|
// so a forged queue file cannot bootstrap outside `tasks/`.
|
|
2959
3018
|
const drainSlugPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
2960
|
-
if (
|
|
2961
|
-
teamDbLogFailure(env, '
|
|
3019
|
+
if (claimSlug.length > 48 || !drainSlugPattern.test(claimSlug)) {
|
|
3020
|
+
teamDbLogFailure(env, 'E_TRACKER_DRAIN_FAILED', 'tracker drain returned an invalid slug; the claim is left for the CLAIM_STALE_MS recovery window (team-db-tracker.mjs)');
|
|
2962
3021
|
return;
|
|
2963
3022
|
}
|
|
2964
|
-
const drainTaskDir = path.join(process.cwd(), '.ai.local', 'team', 'tasks',
|
|
3023
|
+
const drainTaskDir = path.join(process.cwd(), '.ai.local', 'team', 'tasks', claimSlug);
|
|
2965
3024
|
const drainPipelinePath = path.join(drainTaskDir, 'pipeline.json');
|
|
2966
|
-
if (fs.existsSync(drainPipelinePath)) return; // already bootstrapped; the CLAIM_STALE_MS stale-claim rule releases it (team-db-
|
|
3025
|
+
if (fs.existsSync(drainPipelinePath)) return; // already bootstrapped; the CLAIM_STALE_MS stale-claim rule releases it (team-db-tracker.mjs)
|
|
2967
3026
|
// The bootstrap write is the dispatch: a task folder with `pipeline.json`
|
|
2968
3027
|
// is a routable slug. `status.json` stays runtime-owned from there.
|
|
2969
3028
|
fs.mkdirSync(drainTaskDir, { recursive: true });
|
|
3029
|
+
// The link is the relation of record; its prompt is the task prompt. A
|
|
3030
|
+
// legacy entry without a link keeps a minimal prompt naming the item.
|
|
3031
|
+
let link = null;
|
|
3032
|
+
if (typeof claim.linkId === 'string' && claim.linkId !== '') {
|
|
3033
|
+
try {
|
|
3034
|
+
const linkPath = path.join(process.cwd(), '.ai.local', 'team', 'tracker', 'links', claim.linkId + '.json');
|
|
3035
|
+
link = JSON.parse(fs.readFileSync(linkPath, 'utf8'));
|
|
3036
|
+
} catch (error) {
|
|
3037
|
+
link = null;
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
let prompt = null;
|
|
3041
|
+
if (link && typeof link.promptPath === 'string') {
|
|
3042
|
+
try {
|
|
3043
|
+
prompt = fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', link.promptPath), 'utf8');
|
|
3044
|
+
} catch (error) {
|
|
3045
|
+
prompt = null;
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
if (prompt === null) {
|
|
3049
|
+
prompt = 'Tracker item ' + (claim.itemId || claimSlug) + ' launched from the queue drain.\n';
|
|
3050
|
+
}
|
|
3051
|
+
const language = link && typeof link.language === 'string' ? link.language : '';
|
|
3052
|
+
fs.writeFileSync(
|
|
3053
|
+
path.join(drainTaskDir, 'prompt.md'),
|
|
3054
|
+
(language ? '<!-- language: ' + language + ' -->\n\n' : '') + prompt.trim() + '\n',
|
|
3055
|
+
);
|
|
2970
3056
|
fs.writeFileSync(
|
|
2971
3057
|
drainPipelinePath,
|
|
2972
3058
|
JSON.stringify(
|
|
2973
3059
|
{
|
|
2974
|
-
slug:
|
|
3060
|
+
slug: claimSlug,
|
|
2975
3061
|
intent: 'feature',
|
|
2976
3062
|
specMode: 'none',
|
|
2977
3063
|
profile: 'standard',
|
|
2978
|
-
summary: '
|
|
3064
|
+
summary: 'Tracker item ' + (claim.itemId || claimSlug) + ' launched from the queue drain.',
|
|
3065
|
+
trackerItemId: claim.itemId || claimSlug,
|
|
3066
|
+
trackerLinkId: claim.linkId || null,
|
|
2979
3067
|
steps: [],
|
|
2980
3068
|
humanGates: [],
|
|
2981
3069
|
autoChain: true,
|
|
@@ -2990,7 +3078,7 @@ function teamDbBacklogDrain() {
|
|
|
2990
3078
|
}
|
|
2991
3079
|
}
|
|
2992
3080
|
|
|
2993
|
-
|
|
3081
|
+
teamDbTrackerDrain();
|
|
2994
3082
|
// <<<team-db-projection-end>>>
|
|
2995
3083
|
// --- end TEAM_DB_PROJECTION ---------------------------------------------------
|
|
2996
3084
|
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
// Rendered from `presets/_shared/hooks/guard-shell-command.mjs.tmpl`; edit the
|
|
4
4
|
// template, never a rendered copy.
|
|
5
5
|
// <<<guard-slot:POLICY>>>
|
|
6
|
+
// <<<guard-slot:PORTS>>>
|
|
6
7
|
import fs from 'node:fs';
|
|
8
|
+
import net from 'node:net';
|
|
7
9
|
|
|
8
10
|
const PERMISSION_ALLOW = { permission: 'allow' };
|
|
9
11
|
|
|
@@ -61,6 +63,14 @@ if (dangerousGit.test(command)) {
|
|
|
61
63
|
);
|
|
62
64
|
}
|
|
63
65
|
|
|
66
|
+
if (/\b(?:pkill|killall)\b|\bxargs\s+kill\b/.test(command)) {
|
|
67
|
+
out(
|
|
68
|
+
'ask',
|
|
69
|
+
'This command can stop processes the task does not own. Name the process you started, or use `node .ai.local/scripts/processes.mjs stop`.',
|
|
70
|
+
'Never mass-kill processes. Stop the recorded pid through processes.mjs; ask before pkill, killall, or xargs kill.',
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
64
74
|
const managerByFile = [
|
|
65
75
|
['yarn.lock', 'yarn'],
|
|
66
76
|
['pnpm-lock.yaml', 'pnpm'],
|
|
@@ -79,10 +89,10 @@ if (!expected && fs.existsSync('package.json')) {
|
|
|
79
89
|
}
|
|
80
90
|
|
|
81
91
|
if (!expected) {
|
|
82
|
-
|
|
92
|
+
expected = undefined;
|
|
83
93
|
}
|
|
84
94
|
|
|
85
|
-
const used = command.match(/(^|[;&|]\s*)(npm|yarn|pnpm)\s+/)?.[2];
|
|
95
|
+
const used = expected ? command.match(/(^|[;&|]\s*)(npm|yarn|pnpm)\s+/)?.[2] : undefined;
|
|
86
96
|
if (used && used !== expected) {
|
|
87
97
|
out(
|
|
88
98
|
'ask',
|
|
@@ -91,4 +101,32 @@ if (used && used !== expected) {
|
|
|
91
101
|
);
|
|
92
102
|
}
|
|
93
103
|
|
|
104
|
+
const portIsOpen = (port) =>
|
|
105
|
+
new Promise((resolve) => {
|
|
106
|
+
const socket = net.createConnection({ host: '127.0.0.1', port });
|
|
107
|
+
const done = (open) => {
|
|
108
|
+
socket.destroy();
|
|
109
|
+
resolve(open);
|
|
110
|
+
};
|
|
111
|
+
socket.once('connect', () => done(true));
|
|
112
|
+
socket.once('error', () => done(false));
|
|
113
|
+
socket.setTimeout(400, () => done(false));
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Only a server-start shaped command is worth probing: the hook must not slow
|
|
117
|
+
// down or interrogate every shell call.
|
|
118
|
+
const explicitPortMatch = command.match(/--port[=\s]+(\d{2,5})|\bPORT=(\d{2,5})/);
|
|
119
|
+
const explicitPort = Number(explicitPortMatch?.[1] || explicitPortMatch?.[2] || 0) || null;
|
|
120
|
+
const startsServer = SERVER_COMMAND ? SERVER_COMMAND.test(command) : false;
|
|
121
|
+
const portsToProbe = startsServer ? (explicitPort ? [explicitPort] : SERVER_PORTS) : [];
|
|
122
|
+
|
|
123
|
+
for (const port of portsToProbe) {
|
|
124
|
+
if (!(await portIsOpen(port))) continue;
|
|
125
|
+
out(
|
|
126
|
+
'ask',
|
|
127
|
+
`Port ${port} is already listening. Reuse the running server, or stop the recorded process before starting another.`,
|
|
128
|
+
`A server may already serve port ${port}. Probe it first, reuse it, or stop it with \`node .ai.local/scripts/processes.mjs stop\`; never start a duplicate.`,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
94
132
|
out('allow');
|