@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
|
@@ -1385,7 +1385,11 @@ const PAUSE_SENTINELS = [
|
|
|
1385
1385
|
path.join(process.cwd(), '.ai.local', 'ESTOP'),
|
|
1386
1386
|
];
|
|
1387
1387
|
function readPauseSentinel() {
|
|
1388
|
-
|
|
1388
|
+
const sentinels = [...PAUSE_SENTINELS];
|
|
1389
|
+
if (typeof slug === 'string' && slug !== '') {
|
|
1390
|
+
sentinels.push(path.join(process.cwd(), '.ai.local', 'team', 'tasks', slug, 'STOP'));
|
|
1391
|
+
}
|
|
1392
|
+
for (const file of sentinels) {
|
|
1389
1393
|
let stat = null;
|
|
1390
1394
|
try { stat = fs.statSync(file); } catch (error) {
|
|
1391
1395
|
if (error && error.code === 'ENOENT') continue;
|
|
@@ -2726,6 +2730,60 @@ const fs = require('fs');
|
|
|
2726
2730
|
const path = require('path');
|
|
2727
2731
|
const { spawnSync } = require('child_process');
|
|
2728
2732
|
|
|
2733
|
+
// Dev-server cleanup: terminal task state only. `processes.mjs` proves
|
|
2734
|
+
// ownership from `.ai.local/.processes/leases/<name>.json` before any signal,
|
|
2735
|
+
// so a foreign process is never touched. A refusal or timeout is a warning,
|
|
2736
|
+
// never a hook failure.
|
|
2737
|
+
function stopOwnedDevServers() {
|
|
2738
|
+
const processes = path.join(process.cwd(), '.ai.local', 'scripts', 'processes.mjs');
|
|
2739
|
+
if (!fs.existsSync(processes)) return;
|
|
2740
|
+
const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
2741
|
+
let slug = typeof process.env.TEAM_TASK_SLUG === 'string' ? process.env.TEAM_TASK_SLUG : '';
|
|
2742
|
+
if (!slug) {
|
|
2743
|
+
try {
|
|
2744
|
+
const active = JSON.parse(
|
|
2745
|
+
fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'active-task.json'), 'utf8'),
|
|
2746
|
+
);
|
|
2747
|
+
slug = typeof active.slug === 'string' ? active.slug : '';
|
|
2748
|
+
} catch {
|
|
2749
|
+
return;
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
if (slug.length === 0 || slug.length > 48 || !SLUG_RE.test(slug)) return;
|
|
2753
|
+
let state = '';
|
|
2754
|
+
try {
|
|
2755
|
+
const status = JSON.parse(
|
|
2756
|
+
fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'tasks', slug, 'status.json'), 'utf8'),
|
|
2757
|
+
);
|
|
2758
|
+
state = typeof status.state === 'string' ? status.state : '';
|
|
2759
|
+
} catch {
|
|
2760
|
+
return;
|
|
2761
|
+
}
|
|
2762
|
+
if (state !== 'completed' && state !== 'blocked') return;
|
|
2763
|
+
const result = spawnSync(process.execPath, [processes, 'stop', '--task', slug, '--root', process.cwd()], {
|
|
2764
|
+
cwd: process.cwd(),
|
|
2765
|
+
encoding: 'utf8',
|
|
2766
|
+
timeout: 8000,
|
|
2767
|
+
killSignal: 'SIGKILL',
|
|
2768
|
+
});
|
|
2769
|
+
if (result.stdout) process.stderr.write(result.stdout);
|
|
2770
|
+
if (result.stderr) process.stderr.write(result.stderr);
|
|
2771
|
+
if (result.error) {
|
|
2772
|
+
const timedOut = result.error.code === 'ETIMEDOUT';
|
|
2773
|
+
process.stderr.write(
|
|
2774
|
+
`WARNING: dev-server cleanup ${timedOut ? 'timed out after 8s' : `failed: ${result.error.message}`}\n`,
|
|
2775
|
+
);
|
|
2776
|
+
} else if (result.status !== 0) {
|
|
2777
|
+
process.stderr.write(`WARNING: dev-server cleanup exited ${result.status}; inspect .ai.local/.processes/leases/** by hand\n`);
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
|
|
2781
|
+
try {
|
|
2782
|
+
stopOwnedDevServers();
|
|
2783
|
+
} catch {
|
|
2784
|
+
// Cleanup never fails the stop.
|
|
2785
|
+
}
|
|
2786
|
+
|
|
2729
2787
|
// <<<standards-draft>>>
|
|
2730
2788
|
// Explicit payload only. This postflight never walks the repo and never
|
|
2731
2789
|
// creates `.ai.local/rules/`. The same provenance tag does not rewrite an
|
|
@@ -3016,35 +3074,35 @@ function teamDbProject() {
|
|
|
3016
3074
|
}
|
|
3017
3075
|
|
|
3018
3076
|
teamDbProject();
|
|
3019
|
-
// ---
|
|
3020
|
-
// The launch queue's stop-seam drain. The
|
|
3077
|
+
// --- TEAM_DB_TRACKER_DRAIN (A-1, D-5) ----------------------------------------
|
|
3078
|
+
// The launch queue's stop-seam drain. The tracker module never starts a run:
|
|
3021
3079
|
// this seam claims at most one entry and bootstraps the task folder the claim
|
|
3022
3080
|
// names, so the next orchestration turn routes it. The recorded `command` is
|
|
3023
|
-
// never executed. `
|
|
3081
|
+
// never executed. `AI_RULES_TEAM_DB_TRACKER_DRAIN_DISABLE=1` stops this
|
|
3024
3082
|
// auto-drain trigger only; the file verbs stay usable. A disabled switch, a
|
|
3025
3083
|
// missing script, a lost race, or an invalid claim slug is a skip; a child
|
|
3026
3084
|
// failure is one log line. The seam never fails the stop.
|
|
3027
|
-
function
|
|
3085
|
+
function teamDbTrackerDrain() {
|
|
3028
3086
|
try {
|
|
3029
3087
|
const env = process.env;
|
|
3030
|
-
if (teamDbTruthy(env.
|
|
3088
|
+
if (teamDbTruthy(env.AI_RULES_TEAM_DB_TRACKER_DRAIN_DISABLE)) return;
|
|
3031
3089
|
const script = path.join(process.cwd(), '.ai.local', 'scripts', 'team-db.mjs');
|
|
3032
3090
|
if (!fs.existsSync(script)) return;
|
|
3033
3091
|
const result = spawnSync(
|
|
3034
3092
|
process.execPath,
|
|
3035
|
-
['.ai.local/scripts/team-db.mjs', '
|
|
3093
|
+
['.ai.local/scripts/team-db.mjs', 'tracker', 'drain', '--claim', '--quiet', '--json'],
|
|
3036
3094
|
{ cwd: process.cwd(), env: env, encoding: 'utf8', timeout: 5000, killSignal: 'SIGKILL', stdio: ['ignore', 'pipe', 'pipe'] },
|
|
3037
3095
|
);
|
|
3038
3096
|
if (result.error && result.error.code === 'ETIMEDOUT') {
|
|
3039
|
-
teamDbLogFailure(env, '
|
|
3097
|
+
teamDbLogFailure(env, 'E_TRACKER_DRAIN_TIMEOUT', 'tracker drain exceeded 5000 ms and was killed');
|
|
3040
3098
|
return;
|
|
3041
3099
|
}
|
|
3042
3100
|
if (result.error) {
|
|
3043
|
-
teamDbLogFailure(env, '
|
|
3101
|
+
teamDbLogFailure(env, 'E_TRACKER_DRAIN_FAILED', 'tracker drain could not start: ' + String(result.error.code || 'unknown'));
|
|
3044
3102
|
return;
|
|
3045
3103
|
}
|
|
3046
3104
|
if (typeof result.status === 'number' && result.status !== 0) {
|
|
3047
|
-
teamDbLogFailure(env, '
|
|
3105
|
+
teamDbLogFailure(env, 'E_TRACKER_DRAIN_FAILED', 'tracker drain exited ' + result.status);
|
|
3048
3106
|
return;
|
|
3049
3107
|
}
|
|
3050
3108
|
let payload = null;
|
|
@@ -3055,28 +3113,58 @@ function teamDbBacklogDrain() {
|
|
|
3055
3113
|
}
|
|
3056
3114
|
const claim = payload && payload.claim;
|
|
3057
3115
|
if (!claim || typeof claim.slug !== 'string' || claim.slug === '') return;
|
|
3116
|
+
const claimSlug = typeof claim.taskSlug === 'string' && claim.taskSlug !== '' ? claim.taskSlug : claim.slug;
|
|
3058
3117
|
// The slug is re-validated against the existing grammar before any write,
|
|
3059
3118
|
// so a forged queue file cannot bootstrap outside `tasks/`.
|
|
3060
3119
|
const drainSlugPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
3061
|
-
if (
|
|
3062
|
-
teamDbLogFailure(env, '
|
|
3120
|
+
if (claimSlug.length > 48 || !drainSlugPattern.test(claimSlug)) {
|
|
3121
|
+
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)');
|
|
3063
3122
|
return;
|
|
3064
3123
|
}
|
|
3065
|
-
const drainTaskDir = path.join(process.cwd(), '.ai.local', 'team', 'tasks',
|
|
3124
|
+
const drainTaskDir = path.join(process.cwd(), '.ai.local', 'team', 'tasks', claimSlug);
|
|
3066
3125
|
const drainPipelinePath = path.join(drainTaskDir, 'pipeline.json');
|
|
3067
|
-
if (fs.existsSync(drainPipelinePath)) return; // already bootstrapped; the CLAIM_STALE_MS stale-claim rule releases it (team-db-
|
|
3126
|
+
if (fs.existsSync(drainPipelinePath)) return; // already bootstrapped; the CLAIM_STALE_MS stale-claim rule releases it (team-db-tracker.mjs)
|
|
3068
3127
|
// The bootstrap write is the dispatch: a task folder with `pipeline.json`
|
|
3069
3128
|
// is a routable slug. `status.json` stays runtime-owned from there.
|
|
3070
3129
|
fs.mkdirSync(drainTaskDir, { recursive: true });
|
|
3130
|
+
// The link is the relation of record; its prompt is the task prompt. A
|
|
3131
|
+
// legacy entry without a link keeps a minimal prompt naming the item.
|
|
3132
|
+
let link = null;
|
|
3133
|
+
if (typeof claim.linkId === 'string' && claim.linkId !== '') {
|
|
3134
|
+
try {
|
|
3135
|
+
const linkPath = path.join(process.cwd(), '.ai.local', 'team', 'tracker', 'links', claim.linkId + '.json');
|
|
3136
|
+
link = JSON.parse(fs.readFileSync(linkPath, 'utf8'));
|
|
3137
|
+
} catch (error) {
|
|
3138
|
+
link = null;
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
let prompt = null;
|
|
3142
|
+
if (link && typeof link.promptPath === 'string') {
|
|
3143
|
+
try {
|
|
3144
|
+
prompt = fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', link.promptPath), 'utf8');
|
|
3145
|
+
} catch (error) {
|
|
3146
|
+
prompt = null;
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
if (prompt === null) {
|
|
3150
|
+
prompt = 'Tracker item ' + (claim.itemId || claimSlug) + ' launched from the queue drain.\n';
|
|
3151
|
+
}
|
|
3152
|
+
const language = link && typeof link.language === 'string' ? link.language : '';
|
|
3153
|
+
fs.writeFileSync(
|
|
3154
|
+
path.join(drainTaskDir, 'prompt.md'),
|
|
3155
|
+
(language ? '<!-- language: ' + language + ' -->\n\n' : '') + prompt.trim() + '\n',
|
|
3156
|
+
);
|
|
3071
3157
|
fs.writeFileSync(
|
|
3072
3158
|
drainPipelinePath,
|
|
3073
3159
|
JSON.stringify(
|
|
3074
3160
|
{
|
|
3075
|
-
slug:
|
|
3161
|
+
slug: claimSlug,
|
|
3076
3162
|
intent: 'feature',
|
|
3077
3163
|
specMode: 'none',
|
|
3078
3164
|
profile: 'standard',
|
|
3079
|
-
summary: '
|
|
3165
|
+
summary: 'Tracker item ' + (claim.itemId || claimSlug) + ' launched from the queue drain.',
|
|
3166
|
+
trackerItemId: claim.itemId || claimSlug,
|
|
3167
|
+
trackerLinkId: claim.linkId || null,
|
|
3080
3168
|
steps: [],
|
|
3081
3169
|
humanGates: [],
|
|
3082
3170
|
autoChain: true,
|
|
@@ -3091,7 +3179,7 @@ function teamDbBacklogDrain() {
|
|
|
3091
3179
|
}
|
|
3092
3180
|
}
|
|
3093
3181
|
|
|
3094
|
-
|
|
3182
|
+
teamDbTrackerDrain();
|
|
3095
3183
|
// <<<team-db-projection-end>>>
|
|
3096
3184
|
// --- end TEAM_DB_PROJECTION ---------------------------------------------------
|
|
3097
3185
|
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
// template, never a rendered copy.
|
|
5
5
|
// TypeScript MCP: allow npm/npx/node/tsc/vitest/jest; package-manager mismatch checks when lockfile exists.
|
|
6
6
|
// Package-manager mismatch checks apply only when a JS lockfile/package.json exists.
|
|
7
|
+
const SERVER_COMMAND = null;
|
|
8
|
+
const SERVER_PORTS = [];
|
|
7
9
|
import fs from 'node:fs';
|
|
10
|
+
import net from 'node:net';
|
|
8
11
|
|
|
9
12
|
const PERMISSION_ALLOW = { permission: 'allow' };
|
|
10
13
|
|
|
@@ -62,6 +65,14 @@ if (dangerousGit.test(command)) {
|
|
|
62
65
|
);
|
|
63
66
|
}
|
|
64
67
|
|
|
68
|
+
if (/\b(?:pkill|killall)\b|\bxargs\s+kill\b/.test(command)) {
|
|
69
|
+
out(
|
|
70
|
+
'ask',
|
|
71
|
+
'This command can stop processes the task does not own. Name the process you started, or use `node .ai.local/scripts/processes.mjs stop`.',
|
|
72
|
+
'Never mass-kill processes. Stop the recorded pid through processes.mjs; ask before pkill, killall, or xargs kill.',
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
65
76
|
const managerByFile = [
|
|
66
77
|
['yarn.lock', 'yarn'],
|
|
67
78
|
['pnpm-lock.yaml', 'pnpm'],
|
|
@@ -80,10 +91,10 @@ if (!expected && fs.existsSync('package.json')) {
|
|
|
80
91
|
}
|
|
81
92
|
|
|
82
93
|
if (!expected) {
|
|
83
|
-
|
|
94
|
+
expected = undefined;
|
|
84
95
|
}
|
|
85
96
|
|
|
86
|
-
const used = command.match(/(^|[;&|]\s*)(npm|yarn|pnpm)\s+/)?.[2];
|
|
97
|
+
const used = expected ? command.match(/(^|[;&|]\s*)(npm|yarn|pnpm)\s+/)?.[2] : undefined;
|
|
87
98
|
if (used && used !== expected) {
|
|
88
99
|
out(
|
|
89
100
|
'ask',
|
|
@@ -92,4 +103,32 @@ if (used && used !== expected) {
|
|
|
92
103
|
);
|
|
93
104
|
}
|
|
94
105
|
|
|
106
|
+
const portIsOpen = (port) =>
|
|
107
|
+
new Promise((resolve) => {
|
|
108
|
+
const socket = net.createConnection({ host: '127.0.0.1', port });
|
|
109
|
+
const done = (open) => {
|
|
110
|
+
socket.destroy();
|
|
111
|
+
resolve(open);
|
|
112
|
+
};
|
|
113
|
+
socket.once('connect', () => done(true));
|
|
114
|
+
socket.once('error', () => done(false));
|
|
115
|
+
socket.setTimeout(400, () => done(false));
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// Only a server-start shaped command is worth probing: the hook must not slow
|
|
119
|
+
// down or interrogate every shell call.
|
|
120
|
+
const explicitPortMatch = command.match(/--port[=\s]+(\d{2,5})|\bPORT=(\d{2,5})/);
|
|
121
|
+
const explicitPort = Number(explicitPortMatch?.[1] || explicitPortMatch?.[2] || 0) || null;
|
|
122
|
+
const startsServer = SERVER_COMMAND ? SERVER_COMMAND.test(command) : false;
|
|
123
|
+
const portsToProbe = startsServer ? (explicitPort ? [explicitPort] : SERVER_PORTS) : [];
|
|
124
|
+
|
|
125
|
+
for (const port of portsToProbe) {
|
|
126
|
+
if (!(await portIsOpen(port))) continue;
|
|
127
|
+
out(
|
|
128
|
+
'ask',
|
|
129
|
+
`Port ${port} is already listening. Reuse the running server, or stop the recorded process before starting another.`,
|
|
130
|
+
`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.`,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
95
134
|
out('allow');
|
|
@@ -216,7 +216,7 @@ Additional states: `blocked` — a step (or a parallel producer) cannot proceed;
|
|
|
216
216
|
|
|
217
217
|
- 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.
|
|
218
218
|
- 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.
|
|
219
|
-
- Remove the sentinel, then run `/task-continue <slug>`. Only the hook writes the `paused` state; never edit `status.json` to pause or resume.
|
|
219
|
+
- 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.
|
|
220
220
|
- 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.
|
|
221
221
|
- 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.
|
|
222
222
|
- 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>`.
|
|
@@ -1398,7 +1398,11 @@ const PAUSE_SENTINELS = [
|
|
|
1398
1398
|
path.join(process.cwd(), '.ai.local', 'ESTOP'),
|
|
1399
1399
|
];
|
|
1400
1400
|
function readPauseSentinel() {
|
|
1401
|
-
|
|
1401
|
+
const sentinels = [...PAUSE_SENTINELS];
|
|
1402
|
+
if (typeof slug === 'string' && slug !== '') {
|
|
1403
|
+
sentinels.push(path.join(process.cwd(), '.ai.local', 'team', 'tasks', slug, 'STOP'));
|
|
1404
|
+
}
|
|
1405
|
+
for (const file of sentinels) {
|
|
1402
1406
|
let stat = null;
|
|
1403
1407
|
try { stat = fs.statSync(file); } catch (error) {
|
|
1404
1408
|
if (error && error.code === 'ENOENT') continue;
|
|
@@ -2781,6 +2785,60 @@ const fs = require('fs');
|
|
|
2781
2785
|
const path = require('path');
|
|
2782
2786
|
const { spawnSync } = require('child_process');
|
|
2783
2787
|
|
|
2788
|
+
// Dev-server cleanup: terminal task state only. `processes.mjs` proves
|
|
2789
|
+
// ownership from `.ai.local/.processes/leases/<name>.json` before any signal,
|
|
2790
|
+
// so a foreign process is never touched. A refusal or timeout is a warning,
|
|
2791
|
+
// never a hook failure.
|
|
2792
|
+
function stopOwnedDevServers() {
|
|
2793
|
+
const processes = path.join(process.cwd(), '.ai.local', 'scripts', 'processes.mjs');
|
|
2794
|
+
if (!fs.existsSync(processes)) return;
|
|
2795
|
+
const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
2796
|
+
let slug = typeof process.env.TEAM_TASK_SLUG === 'string' ? process.env.TEAM_TASK_SLUG : '';
|
|
2797
|
+
if (!slug) {
|
|
2798
|
+
try {
|
|
2799
|
+
const active = JSON.parse(
|
|
2800
|
+
fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'active-task.json'), 'utf8'),
|
|
2801
|
+
);
|
|
2802
|
+
slug = typeof active.slug === 'string' ? active.slug : '';
|
|
2803
|
+
} catch {
|
|
2804
|
+
return;
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
if (slug.length === 0 || slug.length > 48 || !SLUG_RE.test(slug)) return;
|
|
2808
|
+
let state = '';
|
|
2809
|
+
try {
|
|
2810
|
+
const status = JSON.parse(
|
|
2811
|
+
fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'tasks', slug, 'status.json'), 'utf8'),
|
|
2812
|
+
);
|
|
2813
|
+
state = typeof status.state === 'string' ? status.state : '';
|
|
2814
|
+
} catch {
|
|
2815
|
+
return;
|
|
2816
|
+
}
|
|
2817
|
+
if (state !== 'completed' && state !== 'blocked') return;
|
|
2818
|
+
const result = spawnSync(process.execPath, [processes, 'stop', '--task', slug, '--root', process.cwd()], {
|
|
2819
|
+
cwd: process.cwd(),
|
|
2820
|
+
encoding: 'utf8',
|
|
2821
|
+
timeout: 8000,
|
|
2822
|
+
killSignal: 'SIGKILL',
|
|
2823
|
+
});
|
|
2824
|
+
if (result.stdout) process.stderr.write(result.stdout);
|
|
2825
|
+
if (result.stderr) process.stderr.write(result.stderr);
|
|
2826
|
+
if (result.error) {
|
|
2827
|
+
const timedOut = result.error.code === 'ETIMEDOUT';
|
|
2828
|
+
process.stderr.write(
|
|
2829
|
+
`WARNING: dev-server cleanup ${timedOut ? 'timed out after 8s' : `failed: ${result.error.message}`}\n`,
|
|
2830
|
+
);
|
|
2831
|
+
} else if (result.status !== 0) {
|
|
2832
|
+
process.stderr.write(`WARNING: dev-server cleanup exited ${result.status}; inspect .ai.local/.processes/leases/** by hand\n`);
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
|
|
2836
|
+
try {
|
|
2837
|
+
stopOwnedDevServers();
|
|
2838
|
+
} catch {
|
|
2839
|
+
// Cleanup never fails the stop.
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2784
2842
|
// <<<standards-draft>>>
|
|
2785
2843
|
// Explicit payload only. This postflight never walks the repo and never
|
|
2786
2844
|
// creates `.ai.local/rules/`. The same provenance tag does not rewrite an
|
|
@@ -3071,35 +3129,35 @@ function teamDbProject() {
|
|
|
3071
3129
|
}
|
|
3072
3130
|
|
|
3073
3131
|
teamDbProject();
|
|
3074
|
-
// ---
|
|
3075
|
-
// The launch queue's stop-seam drain. The
|
|
3132
|
+
// --- TEAM_DB_TRACKER_DRAIN (A-1, D-5) ----------------------------------------
|
|
3133
|
+
// The launch queue's stop-seam drain. The tracker module never starts a run:
|
|
3076
3134
|
// this seam claims at most one entry and bootstraps the task folder the claim
|
|
3077
3135
|
// names, so the next orchestration turn routes it. The recorded `command` is
|
|
3078
|
-
// never executed. `
|
|
3136
|
+
// never executed. `AI_RULES_TEAM_DB_TRACKER_DRAIN_DISABLE=1` stops this
|
|
3079
3137
|
// auto-drain trigger only; the file verbs stay usable. A disabled switch, a
|
|
3080
3138
|
// missing script, a lost race, or an invalid claim slug is a skip; a child
|
|
3081
3139
|
// failure is one log line. The seam never fails the stop.
|
|
3082
|
-
function
|
|
3140
|
+
function teamDbTrackerDrain() {
|
|
3083
3141
|
try {
|
|
3084
3142
|
const env = process.env;
|
|
3085
|
-
if (teamDbTruthy(env.
|
|
3143
|
+
if (teamDbTruthy(env.AI_RULES_TEAM_DB_TRACKER_DRAIN_DISABLE)) return;
|
|
3086
3144
|
const script = path.join(process.cwd(), '.ai.local', 'scripts', 'team-db.mjs');
|
|
3087
3145
|
if (!fs.existsSync(script)) return;
|
|
3088
3146
|
const result = spawnSync(
|
|
3089
3147
|
process.execPath,
|
|
3090
|
-
['.ai.local/scripts/team-db.mjs', '
|
|
3148
|
+
['.ai.local/scripts/team-db.mjs', 'tracker', 'drain', '--claim', '--quiet', '--json'],
|
|
3091
3149
|
{ cwd: process.cwd(), env: env, encoding: 'utf8', timeout: 5000, killSignal: 'SIGKILL', stdio: ['ignore', 'pipe', 'pipe'] },
|
|
3092
3150
|
);
|
|
3093
3151
|
if (result.error && result.error.code === 'ETIMEDOUT') {
|
|
3094
|
-
teamDbLogFailure(env, '
|
|
3152
|
+
teamDbLogFailure(env, 'E_TRACKER_DRAIN_TIMEOUT', 'tracker drain exceeded 5000 ms and was killed');
|
|
3095
3153
|
return;
|
|
3096
3154
|
}
|
|
3097
3155
|
if (result.error) {
|
|
3098
|
-
teamDbLogFailure(env, '
|
|
3156
|
+
teamDbLogFailure(env, 'E_TRACKER_DRAIN_FAILED', 'tracker drain could not start: ' + String(result.error.code || 'unknown'));
|
|
3099
3157
|
return;
|
|
3100
3158
|
}
|
|
3101
3159
|
if (typeof result.status === 'number' && result.status !== 0) {
|
|
3102
|
-
teamDbLogFailure(env, '
|
|
3160
|
+
teamDbLogFailure(env, 'E_TRACKER_DRAIN_FAILED', 'tracker drain exited ' + result.status);
|
|
3103
3161
|
return;
|
|
3104
3162
|
}
|
|
3105
3163
|
let payload = null;
|
|
@@ -3110,28 +3168,58 @@ function teamDbBacklogDrain() {
|
|
|
3110
3168
|
}
|
|
3111
3169
|
const claim = payload && payload.claim;
|
|
3112
3170
|
if (!claim || typeof claim.slug !== 'string' || claim.slug === '') return;
|
|
3171
|
+
const claimSlug = typeof claim.taskSlug === 'string' && claim.taskSlug !== '' ? claim.taskSlug : claim.slug;
|
|
3113
3172
|
// The slug is re-validated against the existing grammar before any write,
|
|
3114
3173
|
// so a forged queue file cannot bootstrap outside `tasks/`.
|
|
3115
3174
|
const drainSlugPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
3116
|
-
if (
|
|
3117
|
-
teamDbLogFailure(env, '
|
|
3175
|
+
if (claimSlug.length > 48 || !drainSlugPattern.test(claimSlug)) {
|
|
3176
|
+
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)');
|
|
3118
3177
|
return;
|
|
3119
3178
|
}
|
|
3120
|
-
const drainTaskDir = path.join(process.cwd(), '.ai.local', 'team', 'tasks',
|
|
3179
|
+
const drainTaskDir = path.join(process.cwd(), '.ai.local', 'team', 'tasks', claimSlug);
|
|
3121
3180
|
const drainPipelinePath = path.join(drainTaskDir, 'pipeline.json');
|
|
3122
|
-
if (fs.existsSync(drainPipelinePath)) return; // already bootstrapped; the CLAIM_STALE_MS stale-claim rule releases it (team-db-
|
|
3181
|
+
if (fs.existsSync(drainPipelinePath)) return; // already bootstrapped; the CLAIM_STALE_MS stale-claim rule releases it (team-db-tracker.mjs)
|
|
3123
3182
|
// The bootstrap write is the dispatch: a task folder with `pipeline.json`
|
|
3124
3183
|
// is a routable slug. `status.json` stays runtime-owned from there.
|
|
3125
3184
|
fs.mkdirSync(drainTaskDir, { recursive: true });
|
|
3185
|
+
// The link is the relation of record; its prompt is the task prompt. A
|
|
3186
|
+
// legacy entry without a link keeps a minimal prompt naming the item.
|
|
3187
|
+
let link = null;
|
|
3188
|
+
if (typeof claim.linkId === 'string' && claim.linkId !== '') {
|
|
3189
|
+
try {
|
|
3190
|
+
const linkPath = path.join(process.cwd(), '.ai.local', 'team', 'tracker', 'links', claim.linkId + '.json');
|
|
3191
|
+
link = JSON.parse(fs.readFileSync(linkPath, 'utf8'));
|
|
3192
|
+
} catch (error) {
|
|
3193
|
+
link = null;
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
let prompt = null;
|
|
3197
|
+
if (link && typeof link.promptPath === 'string') {
|
|
3198
|
+
try {
|
|
3199
|
+
prompt = fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', link.promptPath), 'utf8');
|
|
3200
|
+
} catch (error) {
|
|
3201
|
+
prompt = null;
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
if (prompt === null) {
|
|
3205
|
+
prompt = 'Tracker item ' + (claim.itemId || claimSlug) + ' launched from the queue drain.\n';
|
|
3206
|
+
}
|
|
3207
|
+
const language = link && typeof link.language === 'string' ? link.language : '';
|
|
3208
|
+
fs.writeFileSync(
|
|
3209
|
+
path.join(drainTaskDir, 'prompt.md'),
|
|
3210
|
+
(language ? '<!-- language: ' + language + ' -->\n\n' : '') + prompt.trim() + '\n',
|
|
3211
|
+
);
|
|
3126
3212
|
fs.writeFileSync(
|
|
3127
3213
|
drainPipelinePath,
|
|
3128
3214
|
JSON.stringify(
|
|
3129
3215
|
{
|
|
3130
|
-
slug:
|
|
3216
|
+
slug: claimSlug,
|
|
3131
3217
|
intent: 'feature',
|
|
3132
3218
|
specMode: 'none',
|
|
3133
3219
|
profile: 'standard',
|
|
3134
|
-
summary: '
|
|
3220
|
+
summary: 'Tracker item ' + (claim.itemId || claimSlug) + ' launched from the queue drain.',
|
|
3221
|
+
trackerItemId: claim.itemId || claimSlug,
|
|
3222
|
+
trackerLinkId: claim.linkId || null,
|
|
3135
3223
|
steps: [],
|
|
3136
3224
|
humanGates: [],
|
|
3137
3225
|
autoChain: true,
|
|
@@ -3146,7 +3234,7 @@ function teamDbBacklogDrain() {
|
|
|
3146
3234
|
}
|
|
3147
3235
|
}
|
|
3148
3236
|
|
|
3149
|
-
|
|
3237
|
+
teamDbTrackerDrain();
|
|
3150
3238
|
// <<<team-db-projection-end>>>
|
|
3151
3239
|
// --- end TEAM_DB_PROJECTION ---------------------------------------------------
|
|
3152
3240
|
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
// Rendered from `presets/_shared/hooks/guard-shell-command.mjs.tmpl`; edit the
|
|
4
4
|
// template, never a rendered copy.
|
|
5
5
|
// $mol: JS project — package-manager mismatch checks apply when yarn.lock, pnpm-lock.yaml, or package-lock.json exists.
|
|
6
|
+
const SERVER_COMMAND = null;
|
|
7
|
+
const SERVER_PORTS = [];
|
|
6
8
|
import fs from 'node:fs';
|
|
9
|
+
import net from 'node:net';
|
|
7
10
|
|
|
8
11
|
const PERMISSION_ALLOW = { permission: 'allow' };
|
|
9
12
|
|
|
@@ -61,6 +64,14 @@ if (dangerousGit.test(command)) {
|
|
|
61
64
|
);
|
|
62
65
|
}
|
|
63
66
|
|
|
67
|
+
if (/\b(?:pkill|killall)\b|\bxargs\s+kill\b/.test(command)) {
|
|
68
|
+
out(
|
|
69
|
+
'ask',
|
|
70
|
+
'This command can stop processes the task does not own. Name the process you started, or use `node .ai.local/scripts/processes.mjs stop`.',
|
|
71
|
+
'Never mass-kill processes. Stop the recorded pid through processes.mjs; ask before pkill, killall, or xargs kill.',
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
64
75
|
const managerByFile = [
|
|
65
76
|
['yarn.lock', 'yarn'],
|
|
66
77
|
['pnpm-lock.yaml', 'pnpm'],
|
|
@@ -79,10 +90,10 @@ if (!expected && fs.existsSync('package.json')) {
|
|
|
79
90
|
}
|
|
80
91
|
|
|
81
92
|
if (!expected) {
|
|
82
|
-
|
|
93
|
+
expected = undefined;
|
|
83
94
|
}
|
|
84
95
|
|
|
85
|
-
const used = command.match(/(^|[;&|]\s*)(npm|yarn|pnpm)\s+/)?.[2];
|
|
96
|
+
const used = expected ? command.match(/(^|[;&|]\s*)(npm|yarn|pnpm)\s+/)?.[2] : undefined;
|
|
86
97
|
if (used && used !== expected) {
|
|
87
98
|
out(
|
|
88
99
|
'ask',
|
|
@@ -91,4 +102,32 @@ if (used && used !== expected) {
|
|
|
91
102
|
);
|
|
92
103
|
}
|
|
93
104
|
|
|
105
|
+
const portIsOpen = (port) =>
|
|
106
|
+
new Promise((resolve) => {
|
|
107
|
+
const socket = net.createConnection({ host: '127.0.0.1', port });
|
|
108
|
+
const done = (open) => {
|
|
109
|
+
socket.destroy();
|
|
110
|
+
resolve(open);
|
|
111
|
+
};
|
|
112
|
+
socket.once('connect', () => done(true));
|
|
113
|
+
socket.once('error', () => done(false));
|
|
114
|
+
socket.setTimeout(400, () => done(false));
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Only a server-start shaped command is worth probing: the hook must not slow
|
|
118
|
+
// down or interrogate every shell call.
|
|
119
|
+
const explicitPortMatch = command.match(/--port[=\s]+(\d{2,5})|\bPORT=(\d{2,5})/);
|
|
120
|
+
const explicitPort = Number(explicitPortMatch?.[1] || explicitPortMatch?.[2] || 0) || null;
|
|
121
|
+
const startsServer = SERVER_COMMAND ? SERVER_COMMAND.test(command) : false;
|
|
122
|
+
const portsToProbe = startsServer ? (explicitPort ? [explicitPort] : SERVER_PORTS) : [];
|
|
123
|
+
|
|
124
|
+
for (const port of portsToProbe) {
|
|
125
|
+
if (!(await portIsOpen(port))) continue;
|
|
126
|
+
out(
|
|
127
|
+
'ask',
|
|
128
|
+
`Port ${port} is already listening. Reuse the running server, or stop the recorded process before starting another.`,
|
|
129
|
+
`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.`,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
94
133
|
out('allow');
|
|
@@ -216,7 +216,7 @@ Additional states: `blocked` — a step (or a parallel producer) cannot proceed;
|
|
|
216
216
|
|
|
217
217
|
- 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.
|
|
218
218
|
- 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.
|
|
219
|
-
- Remove the sentinel, then run `/task-continue <slug>`. Only the hook writes the `paused` state; never edit `status.json` to pause or resume.
|
|
219
|
+
- 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.
|
|
220
220
|
- 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.
|
|
221
221
|
- 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.
|
|
222
222
|
- 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>`.
|
|
@@ -43,3 +43,5 @@ Use an overlay only when it is **ready** (`serverStatus` not `error` / `needsAut
|
|
|
43
43
|
| Storybook | `storybook`, `user-storybook`, `plugin-storybook`, `storybook-mcp-addon` | component docs/stories/controls; needs Storybook running; not shipped |
|
|
44
44
|
|
|
45
45
|
**Browser split (this preset):** Playwright MCP → e2e agents and selectors. Chrome DevTools MCP → `debugger` / `performance-auditor` against a running app. Not interchangeable.
|
|
46
|
+
|
|
47
|
+
**One browser, one owner.** A persistent Playwright MCP profile is single-instance: a second client conflicts. Reuse the open window for the target app; prefer `--isolated` for one-off screenshot work — the MCP server then closes the browser it launched; use a distinct `--user-data-dir` only when isolation must survive restarts. To share one Chrome between both servers, launch it through `node .ai.local/scripts/processes.mjs start --name chrome --port <cdp-port> --command '<chrome … --remote-debugging-port=<cdp-port>>'` and point Playwright (`--cdp-endpoint`) and Chrome DevTools (`--browser-url`) at that port; task-end cleanup stops only that recorded Chrome. Rule: `dev-process-lifecycle`.
|
|
@@ -54,6 +54,8 @@ Working directory for app scripts: **`app/`**. Detect the package manager from l
|
|
|
54
54
|
|
|
55
55
|
After code edits: invoke **`post-change-lint`** (requestable). Full gate: agent `build-verifier`.
|
|
56
56
|
|
|
57
|
+
Long-lived processes: start, inspect, and stop with `processes.mjs` — `dev-process-lifecycle`.
|
|
58
|
+
|
|
57
59
|
Repositories with more than one package (e.g. `app/` + `storybook/`) run each package's own scripts from its own directory; do not conflate runners.
|
|
58
60
|
|
|
59
61
|
## Preset version
|
|
@@ -61,7 +61,7 @@ node scripts/check-preset-delta.mjs --base <last-green-ref> --json
|
|
|
61
61
|
|
|
62
62
|
- A gate whose domain the classifier reports as **changed** MUST be re-run.
|
|
63
63
|
- A gate whose domain is **unchanged** MAY be carried forward only when `validation-report.md` records the base ref, the classifier output, and the last green command + exit code.
|
|
64
|
-
- Never carry a targeted gate for a changed domain; the full structure composite is release-only (`yarn release:gate`); never carry the
|
|
64
|
+
- Never carry a targeted gate for a changed domain; the full structure composite is release-only (`yarn release:gate`); never carry the team-db suites when the `team-db` domain changed.
|
|
65
65
|
- A test-only app retry may carry the preset and team-db gates, but must still re-run the affected app lint, type-check, unit, and e2e suites.
|
|
66
66
|
- Carry-forward is evidence, not a skip: the final report still quotes every command (carried or fresh).
|
|
67
67
|
|
|
@@ -25,6 +25,7 @@ This subagent does **not** inherit the parent session context or `CLAUDE.md`. Re
|
|
|
25
25
|
- `.claude/rules/anti-hallucination/react-next-anti-hallucination.md` — phantom import banlist
|
|
26
26
|
- `.claude/rules/ui-and-accessibility/no-props-spread.md`
|
|
27
27
|
- `.claude/rules/stack/no-type-assertion.md`
|
|
28
|
+
- `.claude/rules/tooling-and-review/dev-process-lifecycle.md`
|
|
28
29
|
- `.claude/rules/architecture/architecture-boundaries-ui.md`
|
|
29
30
|
- `.claude/rules/stack/arrow-functions.md`
|
|
30
31
|
- `.claude/rules/ui-and-accessibility/css-property-order.md`
|
|
@@ -43,6 +44,8 @@ You are a CI failure investigator for a Next.js TypeScript frontend monorepo.
|
|
|
43
44
|
|
|
44
45
|
Use the **`ci-investigation` skill** for the investigation loop.
|
|
45
46
|
|
|
47
|
+
Load `dev-process-lifecycle` before starting, reusing, or stopping a dev server, Storybook, or a browser.
|
|
48
|
+
|
|
46
49
|
## Inputs
|
|
47
50
|
|
|
48
51
|
1. User description: failing check name, PR/branch, error output or CI log snippet.
|
|
@@ -25,6 +25,7 @@ This subagent does **not** inherit the parent session context or `CLAUDE.md`. Re
|
|
|
25
25
|
- `.claude/rules/anti-hallucination/react-next-anti-hallucination.md` — phantom import banlist
|
|
26
26
|
- `.claude/rules/ui-and-accessibility/no-props-spread.md`
|
|
27
27
|
- `.claude/rules/stack/no-type-assertion.md`
|
|
28
|
+
- `.claude/rules/tooling-and-review/dev-process-lifecycle.md`
|
|
28
29
|
- `.claude/rules/architecture/architecture-boundaries-ui.md`
|
|
29
30
|
- `.claude/rules/stack/arrow-functions.md`
|
|
30
31
|
- `.claude/rules/ui-and-accessibility/css-property-order.md`
|
|
@@ -41,6 +42,8 @@ Also read matching `.ai.local/rules/*.md` (local overlay) for the active zone, a
|
|
|
41
42
|
|
|
42
43
|
You are an expert debugger for a Next.js TypeScript frontend. Use the **`debug-investigation` skill** for the investigation loop.
|
|
43
44
|
|
|
45
|
+
Load `dev-process-lifecycle` before starting, reusing, or stopping a dev server, Storybook, or a browser.
|
|
46
|
+
|
|
44
47
|
## Inputs
|
|
45
48
|
|
|
46
49
|
1. `.ai.local/team/tasks/<slug>/brief.md` if present; else the user task description.
|