@bonesofspring/ai-rules 0.2.37 → 0.2.38
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 +38 -0
- package/README.md +23 -2
- package/bin/cli.js +106 -1
- package/bin/lib/engine-scripts.js +22 -0
- package/bin/lib/fs-utils.js +78 -11
- package/bin/lib/merged-config.js +30 -16
- package/bin/lib/seed-ai-local-team.js +160 -12
- package/bin/opencode-install.js +37 -52
- package/docs/OPENCODE.md +4 -4
- package/docs/specs/INDEX.md +5 -2
- package/package.json +4 -1
- package/presets/_shared/ai-local/scripts/derive-gate-signals.mjs +173 -0
- package/presets/_shared/ai-local/scripts/efficacy-oracle.mjs +576 -0
- package/presets/_shared/ai-local/scripts/lock.mjs +118 -0
- package/presets/_shared/ai-local/scripts/rule-improver.mjs +795 -0
- package/presets/_shared/ai-local/scripts/run.mjs +309 -0
- package/presets/_shared/ai-local/scripts/signals.mjs +256 -0
- package/presets/_shared/core/agent-team/agent-team-orchestrator.md +1 -1
- package/presets/_shared/core/quality/self-review-and-context-hygiene.md +8 -7
- package/presets/_shared/hooks/README.md +5 -0
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +107 -18
- package/presets/_shared/hooks/check-preset-update.mjs +227 -0
- package/presets/claude/android-kotlin/CLAUDE.md +1 -1
- package/presets/claude/android-kotlin/REPO_AGENTS.md +14 -0
- package/presets/claude/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/claude/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/claude/android-kotlin/agents/debugger.md +1 -1
- package/presets/claude/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/claude/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/claude/android-kotlin/commands/README.md +1 -0
- package/presets/claude/android-kotlin/commands/task-continue.md +9 -0
- package/presets/claude/android-kotlin/commands/technical-retro.md +8 -0
- package/presets/claude/android-kotlin/commands/update.md +39 -0
- package/presets/claude/android-kotlin/hooks/README.md +1 -0
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +107 -18
- package/presets/claude/android-kotlin/hooks/check-preset-update.mjs +227 -0
- package/presets/claude/android-kotlin/hooks/examples/README.md +1 -1
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/android-kotlin/settings.json +14 -1
- package/presets/claude/android-kotlin/skills/technical-retro/SKILL.md +2 -0
- package/presets/claude/go/CLAUDE.md +1 -1
- package/presets/claude/go/REPO_AGENTS.md +14 -0
- package/presets/claude/go/agents/build-verifier.md +1 -1
- package/presets/claude/go/agents/code-reviewer.md +1 -1
- package/presets/claude/go/agents/debugger.md +1 -1
- package/presets/claude/go/agents/feature-developer.md +1 -1
- package/presets/claude/go/agents/task-analyst.md +1 -1
- package/presets/claude/go/commands/README.md +1 -0
- package/presets/claude/go/commands/task-continue.md +9 -0
- package/presets/claude/go/commands/technical-retro.md +8 -0
- package/presets/claude/go/commands/update.md +39 -0
- package/presets/claude/go/hooks/README.md +1 -0
- package/presets/claude/go/hooks/chain-team-phases.sh +107 -18
- package/presets/claude/go/hooks/check-preset-update.mjs +227 -0
- package/presets/claude/go/hooks/examples/README.md +1 -1
- package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/go/settings.json +14 -1
- package/presets/claude/go/skills/technical-retro/SKILL.md +2 -0
- package/presets/claude/ios-swift/CLAUDE.md +1 -1
- package/presets/claude/ios-swift/REPO_AGENTS.md +14 -0
- package/presets/claude/ios-swift/agents/build-verifier.md +1 -1
- package/presets/claude/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/claude/ios-swift/agents/debugger.md +1 -1
- package/presets/claude/ios-swift/agents/feature-developer.md +1 -1
- package/presets/claude/ios-swift/agents/task-analyst.md +1 -1
- package/presets/claude/ios-swift/commands/README.md +1 -0
- package/presets/claude/ios-swift/commands/task-continue.md +9 -0
- package/presets/claude/ios-swift/commands/technical-retro.md +8 -0
- package/presets/claude/ios-swift/commands/update.md +39 -0
- package/presets/claude/ios-swift/hooks/README.md +1 -0
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +107 -18
- package/presets/claude/ios-swift/hooks/check-preset-update.mjs +227 -0
- package/presets/claude/ios-swift/hooks/examples/README.md +1 -1
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/ios-swift/settings.json +14 -1
- package/presets/claude/ios-swift/skills/technical-retro/SKILL.md +2 -0
- package/presets/claude/java/CLAUDE.md +2 -2
- package/presets/claude/java/REPO_AGENTS.md +14 -0
- package/presets/claude/java/agents/build-verifier.md +1 -1
- package/presets/claude/java/agents/code-reviewer.md +1 -1
- package/presets/claude/java/agents/debugger.md +1 -1
- package/presets/claude/java/agents/feature-developer.md +1 -1
- package/presets/claude/java/agents/task-analyst.md +1 -1
- package/presets/claude/java/commands/README.md +1 -0
- package/presets/claude/java/commands/task-continue.md +9 -0
- package/presets/claude/java/commands/technical-retro.md +8 -0
- package/presets/claude/java/commands/update.md +39 -0
- package/presets/claude/java/hooks/README.md +1 -0
- package/presets/claude/java/hooks/chain-team-phases.sh +107 -18
- package/presets/claude/java/hooks/check-preset-update.mjs +227 -0
- package/presets/claude/java/hooks/examples/README.md +1 -1
- package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/java/settings.json +14 -1
- package/presets/claude/java/skills/technical-retro/SKILL.md +2 -0
- package/presets/claude/mcp-ts/CLAUDE.md +1 -1
- package/presets/claude/mcp-ts/REPO_AGENTS.md +14 -0
- package/presets/claude/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/claude/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/claude/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/claude/mcp-ts/commands/README.md +1 -0
- package/presets/claude/mcp-ts/commands/task-continue.md +9 -0
- package/presets/claude/mcp-ts/commands/technical-retro.md +8 -0
- package/presets/claude/mcp-ts/commands/update.md +39 -0
- package/presets/claude/mcp-ts/hooks/README.md +1 -0
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +107 -18
- package/presets/claude/mcp-ts/hooks/check-preset-update.mjs +227 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/mcp-ts/settings.json +14 -1
- package/presets/claude/next/CLAUDE.md +2 -1
- package/presets/claude/next/REPO_AGENTS.md +15 -1
- package/presets/claude/next/agents/build-verifier.md +1 -1
- package/presets/claude/next/agents/code-reviewer.md +1 -1
- package/presets/claude/next/agents/debugger.md +1 -1
- package/presets/claude/next/agents/feature-developer.md +1 -1
- package/presets/claude/next/agents/task-analyst.md +1 -1
- package/presets/claude/next/agents/task-router.md +1 -1
- package/presets/claude/next/commands/README.md +1 -0
- package/presets/claude/next/commands/task-continue.md +9 -0
- package/presets/claude/next/commands/technical-retro.md +8 -0
- package/presets/claude/next/commands/update.md +39 -0
- package/presets/claude/next/hooks/README.md +1 -0
- package/presets/claude/next/hooks/chain-team-phases.sh +107 -18
- package/presets/claude/next/hooks/check-preset-update.mjs +227 -0
- package/presets/claude/next/hooks/examples/README.md +1 -1
- package/presets/claude/next/rules/anti-hallucination/react-next-anti-hallucination.md +21 -18
- package/presets/claude/next/rules/stack/next-app-router.md +27 -0
- package/presets/claude/next/rules/stack/next-static-export.md +16 -0
- package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/next/rules/tooling-and-review/security-next.md +16 -2
- package/presets/claude/next/rules/ui-and-accessibility/component-catalog-gate.md +13 -0
- package/presets/claude/next/rules/ui-and-accessibility/forms-validation.md +12 -0
- package/presets/claude/next/settings.json +13 -0
- package/presets/claude/next/skills/technical-retro/SKILL.md +2 -0
- package/presets/claude/next/team/fixtures/feature-light.json +2 -1
- package/presets/claude/next/team/fixtures/feature-ui-standard.json +24 -0
- package/presets/claude/nuxt/CLAUDE.md +2 -1
- package/presets/claude/nuxt/REPO_AGENTS.md +14 -0
- package/presets/claude/nuxt/agents/build-verifier.md +1 -1
- package/presets/claude/nuxt/agents/code-reviewer.md +1 -1
- package/presets/claude/nuxt/agents/debugger.md +1 -1
- package/presets/claude/nuxt/agents/feature-developer.md +1 -1
- package/presets/claude/nuxt/agents/task-analyst.md +1 -1
- package/presets/claude/nuxt/commands/README.md +1 -0
- package/presets/claude/nuxt/commands/task-continue.md +9 -0
- package/presets/claude/nuxt/commands/technical-retro.md +8 -0
- package/presets/claude/nuxt/commands/update.md +39 -0
- package/presets/claude/nuxt/hooks/README.md +1 -0
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +107 -18
- package/presets/claude/nuxt/hooks/check-preset-update.mjs +227 -0
- package/presets/claude/nuxt/hooks/examples/README.md +1 -1
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/nuxt/settings.json +13 -0
- package/presets/claude/nuxt/skills/technical-retro/SKILL.md +2 -0
- package/presets/claude/php-hexagonal/CLAUDE.md +2 -2
- package/presets/claude/php-hexagonal/REPO_AGENTS.md +14 -0
- package/presets/claude/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/claude/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/claude/php-hexagonal/agents/debugger.md +1 -1
- package/presets/claude/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/claude/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/claude/php-hexagonal/commands/README.md +1 -0
- package/presets/claude/php-hexagonal/commands/task-continue.md +9 -0
- package/presets/claude/php-hexagonal/commands/technical-retro.md +8 -0
- package/presets/claude/php-hexagonal/commands/update.md +39 -0
- package/presets/claude/php-hexagonal/hooks/README.md +1 -0
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +107 -18
- package/presets/claude/php-hexagonal/hooks/check-preset-update.mjs +227 -0
- package/presets/claude/php-hexagonal/hooks/examples/README.md +1 -1
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/php-hexagonal/settings.json +14 -1
- package/presets/claude/php-hexagonal/skills/technical-retro/SKILL.md +2 -0
- package/presets/claude/php-laravel/CLAUDE.md +1 -1
- package/presets/claude/php-laravel/REPO_AGENTS.md +14 -0
- package/presets/claude/php-laravel/agents/build-verifier.md +1 -1
- package/presets/claude/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/claude/php-laravel/agents/debugger.md +1 -1
- package/presets/claude/php-laravel/agents/feature-developer.md +1 -1
- package/presets/claude/php-laravel/agents/task-analyst.md +1 -1
- package/presets/claude/php-laravel/commands/README.md +1 -0
- package/presets/claude/php-laravel/commands/task-continue.md +9 -0
- package/presets/claude/php-laravel/commands/technical-retro.md +8 -0
- package/presets/claude/php-laravel/commands/update.md +39 -0
- package/presets/claude/php-laravel/hooks/README.md +1 -0
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +107 -18
- package/presets/claude/php-laravel/hooks/check-preset-update.mjs +227 -0
- package/presets/claude/php-laravel/hooks/examples/README.md +1 -1
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/php-laravel/settings.json +14 -1
- package/presets/claude/php-laravel/skills/technical-retro/SKILL.md +2 -0
- package/presets/claude/svelte/CLAUDE.md +2 -1
- package/presets/claude/svelte/REPO_AGENTS.md +14 -0
- package/presets/claude/svelte/agents/build-verifier.md +1 -1
- package/presets/claude/svelte/agents/code-reviewer.md +1 -1
- package/presets/claude/svelte/agents/debugger.md +1 -1
- package/presets/claude/svelte/agents/feature-developer.md +1 -1
- package/presets/claude/svelte/agents/task-analyst.md +1 -1
- package/presets/claude/svelte/commands/README.md +1 -0
- package/presets/claude/svelte/commands/task-continue.md +9 -0
- package/presets/claude/svelte/commands/technical-retro.md +8 -0
- package/presets/claude/svelte/commands/update.md +39 -0
- package/presets/claude/svelte/hooks/README.md +1 -0
- package/presets/claude/svelte/hooks/chain-team-phases.sh +107 -18
- package/presets/claude/svelte/hooks/check-preset-update.mjs +227 -0
- package/presets/claude/svelte/hooks/examples/README.md +1 -1
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +1 -1
- package/presets/claude/svelte/settings.json +13 -0
- package/presets/claude/svelte/skills/technical-retro/SKILL.md +2 -0
- package/presets/cursor/android-kotlin/AGENTS.md +1 -0
- package/presets/cursor/android-kotlin/REPO_AGENTS.md +14 -0
- package/presets/cursor/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/cursor/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/cursor/android-kotlin/agents/debugger.md +1 -1
- package/presets/cursor/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/cursor/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/cursor/android-kotlin/commands/README.md +1 -0
- package/presets/cursor/android-kotlin/commands/task-continue.md +9 -0
- package/presets/cursor/android-kotlin/commands/technical-retro.md +8 -0
- package/presets/cursor/android-kotlin/commands/update.md +39 -0
- package/presets/cursor/android-kotlin/hooks/README.md +5 -1
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +107 -18
- package/presets/cursor/android-kotlin/hooks/check-preset-update.mjs +227 -0
- package/presets/cursor/android-kotlin/hooks/examples/README.md +1 -1
- package/presets/cursor/android-kotlin/hooks.json +6 -0
- package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/android-kotlin/skills/technical-retro/SKILL.md +2 -0
- package/presets/cursor/go/REPO_AGENTS.md +14 -0
- package/presets/cursor/go/agents/build-verifier.md +1 -1
- package/presets/cursor/go/agents/code-reviewer.md +1 -1
- package/presets/cursor/go/agents/debugger.md +1 -1
- package/presets/cursor/go/agents/feature-developer.md +1 -1
- package/presets/cursor/go/agents/task-analyst.md +1 -1
- package/presets/cursor/go/commands/README.md +1 -0
- package/presets/cursor/go/commands/task-continue.md +9 -0
- package/presets/cursor/go/commands/technical-retro.md +8 -0
- package/presets/cursor/go/commands/update.md +39 -0
- package/presets/cursor/go/hooks/README.md +5 -1
- package/presets/cursor/go/hooks/chain-team-phases.sh +107 -18
- package/presets/cursor/go/hooks/check-preset-update.mjs +227 -0
- package/presets/cursor/go/hooks/examples/README.md +1 -1
- package/presets/cursor/go/hooks.json +6 -0
- package/presets/cursor/go/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/go/skills/technical-retro/SKILL.md +2 -0
- package/presets/cursor/ios-swift/AGENTS.md +1 -0
- package/presets/cursor/ios-swift/REPO_AGENTS.md +14 -0
- package/presets/cursor/ios-swift/agents/build-verifier.md +1 -1
- package/presets/cursor/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/cursor/ios-swift/agents/debugger.md +1 -1
- package/presets/cursor/ios-swift/agents/feature-developer.md +1 -1
- package/presets/cursor/ios-swift/agents/task-analyst.md +1 -1
- package/presets/cursor/ios-swift/commands/README.md +1 -0
- package/presets/cursor/ios-swift/commands/task-continue.md +9 -0
- package/presets/cursor/ios-swift/commands/technical-retro.md +8 -0
- package/presets/cursor/ios-swift/commands/update.md +39 -0
- package/presets/cursor/ios-swift/hooks/README.md +5 -1
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +107 -18
- package/presets/cursor/ios-swift/hooks/check-preset-update.mjs +227 -0
- package/presets/cursor/ios-swift/hooks/examples/README.md +1 -1
- package/presets/cursor/ios-swift/hooks.json +6 -0
- package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/ios-swift/skills/technical-retro/SKILL.md +2 -0
- package/presets/cursor/java/AGENTS.md +1 -1
- package/presets/cursor/java/REPO_AGENTS.md +14 -0
- package/presets/cursor/java/agents/build-verifier.md +1 -1
- package/presets/cursor/java/agents/code-reviewer.md +1 -1
- package/presets/cursor/java/agents/debugger.md +1 -1
- package/presets/cursor/java/agents/feature-developer.md +1 -1
- package/presets/cursor/java/agents/task-analyst.md +1 -1
- package/presets/cursor/java/commands/README.md +1 -0
- package/presets/cursor/java/commands/task-continue.md +9 -0
- package/presets/cursor/java/commands/technical-retro.md +8 -0
- package/presets/cursor/java/commands/update.md +39 -0
- package/presets/cursor/java/hooks/README.md +5 -1
- package/presets/cursor/java/hooks/chain-team-phases.sh +107 -18
- package/presets/cursor/java/hooks/check-preset-update.mjs +227 -0
- package/presets/cursor/java/hooks/examples/README.md +1 -1
- package/presets/cursor/java/hooks.json +6 -0
- package/presets/cursor/java/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/java/skills/technical-retro/SKILL.md +2 -0
- package/presets/cursor/mcp-ts/REPO_AGENTS.md +14 -0
- package/presets/cursor/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/cursor/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/cursor/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/cursor/mcp-ts/commands/README.md +1 -0
- package/presets/cursor/mcp-ts/commands/task-continue.md +9 -0
- package/presets/cursor/mcp-ts/commands/technical-retro.md +8 -0
- package/presets/cursor/mcp-ts/commands/update.md +39 -0
- package/presets/cursor/mcp-ts/hooks/README.md +5 -1
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +107 -18
- package/presets/cursor/mcp-ts/hooks/check-preset-update.mjs +227 -0
- package/presets/cursor/mcp-ts/hooks.json +6 -0
- package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/next/AGENTS.md +1 -0
- package/presets/cursor/next/REPO_AGENTS.md +15 -1
- package/presets/cursor/next/agents/build-verifier.md +1 -1
- package/presets/cursor/next/agents/code-reviewer.md +1 -1
- package/presets/cursor/next/agents/debugger.md +1 -1
- package/presets/cursor/next/agents/feature-developer.md +1 -1
- package/presets/cursor/next/agents/task-analyst.md +1 -1
- package/presets/cursor/next/agents/task-router.md +1 -1
- package/presets/cursor/next/commands/README.md +1 -0
- package/presets/cursor/next/commands/task-continue.md +9 -0
- package/presets/cursor/next/commands/technical-retro.md +8 -0
- package/presets/cursor/next/commands/update.md +39 -0
- package/presets/cursor/next/hooks/README.md +6 -0
- package/presets/cursor/next/hooks/chain-team-phases.sh +107 -18
- package/presets/cursor/next/hooks/check-preset-update.mjs +227 -0
- package/presets/cursor/next/hooks/examples/README.md +1 -1
- package/presets/cursor/next/hooks.json +6 -0
- package/presets/cursor/next/rules/README.md +3 -1
- package/presets/cursor/next/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/next/rules/component-catalog-gate.mdc +13 -0
- package/presets/cursor/next/rules/forms-validation.mdc +12 -0
- package/presets/cursor/next/rules/next-app-router.mdc +27 -0
- package/presets/cursor/next/rules/next-static-export.mdc +16 -0
- package/presets/cursor/next/rules/react-next-anti-hallucination.mdc +21 -18
- package/presets/cursor/next/rules/security-next.mdc +16 -2
- package/presets/cursor/next/skills/technical-retro/SKILL.md +2 -0
- package/presets/cursor/next/team/fixtures/feature-light.json +2 -1
- package/presets/cursor/next/team/fixtures/feature-ui-standard.json +24 -0
- package/presets/cursor/nuxt/AGENTS.md +1 -0
- package/presets/cursor/nuxt/REPO_AGENTS.md +14 -0
- package/presets/cursor/nuxt/agents/build-verifier.md +1 -1
- package/presets/cursor/nuxt/agents/code-reviewer.md +1 -1
- package/presets/cursor/nuxt/agents/debugger.md +1 -1
- package/presets/cursor/nuxt/agents/feature-developer.md +1 -1
- package/presets/cursor/nuxt/agents/task-analyst.md +1 -1
- package/presets/cursor/nuxt/commands/README.md +1 -0
- package/presets/cursor/nuxt/commands/task-continue.md +9 -0
- package/presets/cursor/nuxt/commands/technical-retro.md +8 -0
- package/presets/cursor/nuxt/commands/update.md +39 -0
- package/presets/cursor/nuxt/hooks/README.md +4 -0
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +107 -18
- package/presets/cursor/nuxt/hooks/check-preset-update.mjs +227 -0
- package/presets/cursor/nuxt/hooks/examples/README.md +1 -1
- package/presets/cursor/nuxt/hooks.json +6 -0
- package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/nuxt/skills/technical-retro/SKILL.md +2 -0
- package/presets/cursor/php-hexagonal/AGENTS.md +1 -1
- package/presets/cursor/php-hexagonal/REPO_AGENTS.md +14 -0
- package/presets/cursor/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/cursor/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/cursor/php-hexagonal/agents/debugger.md +1 -1
- package/presets/cursor/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/cursor/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/cursor/php-hexagonal/commands/README.md +1 -0
- package/presets/cursor/php-hexagonal/commands/task-continue.md +9 -0
- package/presets/cursor/php-hexagonal/commands/technical-retro.md +8 -0
- package/presets/cursor/php-hexagonal/commands/update.md +39 -0
- package/presets/cursor/php-hexagonal/hooks/README.md +5 -1
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +107 -18
- package/presets/cursor/php-hexagonal/hooks/check-preset-update.mjs +227 -0
- package/presets/cursor/php-hexagonal/hooks/examples/README.md +1 -1
- package/presets/cursor/php-hexagonal/hooks.json +6 -0
- package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-hexagonal/skills/technical-retro/SKILL.md +2 -0
- package/presets/cursor/php-laravel/AGENTS.md +1 -1
- package/presets/cursor/php-laravel/REPO_AGENTS.md +14 -0
- package/presets/cursor/php-laravel/agents/build-verifier.md +1 -1
- package/presets/cursor/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/cursor/php-laravel/agents/debugger.md +1 -1
- package/presets/cursor/php-laravel/agents/feature-developer.md +1 -1
- package/presets/cursor/php-laravel/agents/task-analyst.md +1 -1
- package/presets/cursor/php-laravel/commands/README.md +1 -0
- package/presets/cursor/php-laravel/commands/task-continue.md +9 -0
- package/presets/cursor/php-laravel/commands/technical-retro.md +8 -0
- package/presets/cursor/php-laravel/commands/update.md +39 -0
- package/presets/cursor/php-laravel/hooks/README.md +5 -1
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +107 -18
- package/presets/cursor/php-laravel/hooks/check-preset-update.mjs +227 -0
- package/presets/cursor/php-laravel/hooks/examples/README.md +1 -1
- package/presets/cursor/php-laravel/hooks.json +6 -0
- package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/php-laravel/skills/technical-retro/SKILL.md +2 -0
- package/presets/cursor/svelte/AGENTS.md +1 -0
- package/presets/cursor/svelte/REPO_AGENTS.md +14 -0
- package/presets/cursor/svelte/agents/build-verifier.md +1 -1
- package/presets/cursor/svelte/agents/code-reviewer.md +1 -1
- package/presets/cursor/svelte/agents/debugger.md +1 -1
- package/presets/cursor/svelte/agents/feature-developer.md +1 -1
- package/presets/cursor/svelte/agents/task-analyst.md +1 -1
- package/presets/cursor/svelte/commands/README.md +1 -0
- package/presets/cursor/svelte/commands/task-continue.md +9 -0
- package/presets/cursor/svelte/commands/technical-retro.md +8 -0
- package/presets/cursor/svelte/commands/update.md +39 -0
- package/presets/cursor/svelte/hooks/README.md +4 -0
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +107 -18
- package/presets/cursor/svelte/hooks/check-preset-update.mjs +227 -0
- package/presets/cursor/svelte/hooks/examples/README.md +1 -1
- package/presets/cursor/svelte/hooks.json +6 -0
- package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +1 -1
- package/presets/cursor/svelte/skills/technical-retro/SKILL.md +2 -0
- package/presets/mavis/android-kotlin/MAVIS.md +1 -0
- package/presets/mavis/android-kotlin/REPO_AGENTS.md +14 -0
- package/presets/mavis/android-kotlin/adapter-map.json +17 -1
- package/presets/mavis/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/mavis/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/mavis/android-kotlin/agents/debugger.md +1 -1
- package/presets/mavis/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/mavis/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/mavis/android-kotlin/commands/README.md +1 -0
- package/presets/mavis/android-kotlin/commands/task-continue.md +9 -0
- package/presets/mavis/android-kotlin/commands/technical-retro.md +8 -0
- package/presets/mavis/android-kotlin/commands/update.md +34 -0
- package/presets/mavis/android-kotlin/hooks/README.md +3 -0
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +107 -18
- package/presets/mavis/android-kotlin/hooks/check-preset-update.mjs +227 -0
- package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/android-kotlin/skills/technical-retro/SKILL.md +2 -0
- package/presets/mavis/go/REPO_AGENTS.md +14 -0
- package/presets/mavis/go/adapter-map.json +17 -1
- package/presets/mavis/go/agents/build-verifier.md +1 -1
- package/presets/mavis/go/agents/code-reviewer.md +1 -1
- package/presets/mavis/go/agents/debugger.md +1 -1
- package/presets/mavis/go/agents/feature-developer.md +1 -1
- package/presets/mavis/go/agents/task-analyst.md +1 -1
- package/presets/mavis/go/commands/README.md +1 -0
- package/presets/mavis/go/commands/task-continue.md +9 -0
- package/presets/mavis/go/commands/technical-retro.md +8 -0
- package/presets/mavis/go/commands/update.md +34 -0
- package/presets/mavis/go/hooks/README.md +3 -0
- package/presets/mavis/go/hooks/chain-team-phases.sh +107 -18
- package/presets/mavis/go/hooks/check-preset-update.mjs +227 -0
- package/presets/mavis/go/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/go/skills/technical-retro/SKILL.md +2 -0
- package/presets/mavis/ios-swift/MAVIS.md +1 -0
- package/presets/mavis/ios-swift/REPO_AGENTS.md +14 -0
- package/presets/mavis/ios-swift/adapter-map.json +17 -1
- package/presets/mavis/ios-swift/agents/build-verifier.md +1 -1
- package/presets/mavis/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/mavis/ios-swift/agents/debugger.md +1 -1
- package/presets/mavis/ios-swift/agents/feature-developer.md +1 -1
- package/presets/mavis/ios-swift/agents/task-analyst.md +1 -1
- package/presets/mavis/ios-swift/commands/README.md +1 -0
- package/presets/mavis/ios-swift/commands/task-continue.md +9 -0
- package/presets/mavis/ios-swift/commands/technical-retro.md +8 -0
- package/presets/mavis/ios-swift/commands/update.md +34 -0
- package/presets/mavis/ios-swift/hooks/README.md +3 -0
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +107 -18
- package/presets/mavis/ios-swift/hooks/check-preset-update.mjs +227 -0
- package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/ios-swift/skills/technical-retro/SKILL.md +2 -0
- package/presets/mavis/java/REPO_AGENTS.md +14 -0
- package/presets/mavis/java/adapter-map.json +17 -1
- package/presets/mavis/java/agents/build-verifier.md +1 -1
- package/presets/mavis/java/agents/code-reviewer.md +1 -1
- package/presets/mavis/java/agents/debugger.md +1 -1
- package/presets/mavis/java/agents/feature-developer.md +1 -1
- package/presets/mavis/java/agents/task-analyst.md +1 -1
- package/presets/mavis/java/commands/README.md +1 -0
- package/presets/mavis/java/commands/task-continue.md +9 -0
- package/presets/mavis/java/commands/technical-retro.md +8 -0
- package/presets/mavis/java/commands/update.md +34 -0
- package/presets/mavis/java/hooks/README.md +3 -0
- package/presets/mavis/java/hooks/chain-team-phases.sh +107 -18
- package/presets/mavis/java/hooks/check-preset-update.mjs +227 -0
- package/presets/mavis/java/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/java/skills/technical-retro/SKILL.md +2 -0
- package/presets/mavis/mcp-ts/REPO_AGENTS.md +14 -0
- package/presets/mavis/mcp-ts/adapter-map.json +17 -1
- package/presets/mavis/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/mavis/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/mavis/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/mavis/mcp-ts/commands/README.md +1 -0
- package/presets/mavis/mcp-ts/commands/task-continue.md +9 -0
- package/presets/mavis/mcp-ts/commands/technical-retro.md +8 -0
- package/presets/mavis/mcp-ts/commands/update.md +34 -0
- package/presets/mavis/mcp-ts/hooks/README.md +3 -0
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +107 -18
- package/presets/mavis/mcp-ts/hooks/check-preset-update.mjs +227 -0
- package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/next/MAVIS.md +1 -0
- package/presets/mavis/next/REPO_AGENTS.md +15 -1
- package/presets/mavis/next/adapter-map.json +25 -1
- package/presets/mavis/next/agents/build-verifier.md +1 -1
- package/presets/mavis/next/agents/code-reviewer.md +1 -1
- package/presets/mavis/next/agents/debugger.md +1 -1
- package/presets/mavis/next/agents/feature-developer.md +1 -1
- package/presets/mavis/next/agents/task-analyst.md +1 -1
- package/presets/mavis/next/agents/task-router.md +1 -1
- package/presets/mavis/next/commands/README.md +1 -0
- package/presets/mavis/next/commands/task-continue.md +9 -0
- package/presets/mavis/next/commands/technical-retro.md +8 -0
- package/presets/mavis/next/commands/update.md +34 -0
- package/presets/mavis/next/hooks/README.md +3 -0
- package/presets/mavis/next/hooks/chain-team-phases.sh +107 -18
- package/presets/mavis/next/hooks/check-preset-update.mjs +227 -0
- package/presets/mavis/next/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/next/rules/component-catalog-gate.md +13 -0
- package/presets/mavis/next/rules/forms-validation.md +12 -0
- package/presets/mavis/next/rules/next-app-router.md +27 -0
- package/presets/mavis/next/rules/next-static-export.md +16 -0
- package/presets/mavis/next/rules/react-next-anti-hallucination.md +20 -18
- package/presets/mavis/next/rules/security-next.md +13 -0
- package/presets/mavis/next/skills/technical-retro/SKILL.md +2 -0
- package/presets/mavis/next/team/fixtures/feature-light.json +2 -1
- package/presets/mavis/next/team/fixtures/feature-ui-standard.json +24 -0
- package/presets/mavis/nuxt/MAVIS.md +1 -0
- package/presets/mavis/nuxt/REPO_AGENTS.md +14 -0
- package/presets/mavis/nuxt/adapter-map.json +17 -1
- package/presets/mavis/nuxt/agents/build-verifier.md +1 -1
- package/presets/mavis/nuxt/agents/code-reviewer.md +1 -1
- package/presets/mavis/nuxt/agents/debugger.md +1 -1
- package/presets/mavis/nuxt/agents/feature-developer.md +1 -1
- package/presets/mavis/nuxt/agents/task-analyst.md +1 -1
- package/presets/mavis/nuxt/commands/README.md +1 -0
- package/presets/mavis/nuxt/commands/task-continue.md +9 -0
- package/presets/mavis/nuxt/commands/technical-retro.md +8 -0
- package/presets/mavis/nuxt/commands/update.md +34 -0
- package/presets/mavis/nuxt/hooks/README.md +3 -0
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +107 -18
- package/presets/mavis/nuxt/hooks/check-preset-update.mjs +227 -0
- package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/nuxt/skills/technical-retro/SKILL.md +2 -0
- package/presets/mavis/php-hexagonal/REPO_AGENTS.md +14 -0
- package/presets/mavis/php-hexagonal/adapter-map.json +17 -1
- package/presets/mavis/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/mavis/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/mavis/php-hexagonal/agents/debugger.md +1 -1
- package/presets/mavis/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/mavis/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/mavis/php-hexagonal/commands/README.md +1 -0
- package/presets/mavis/php-hexagonal/commands/task-continue.md +9 -0
- package/presets/mavis/php-hexagonal/commands/technical-retro.md +8 -0
- package/presets/mavis/php-hexagonal/commands/update.md +34 -0
- package/presets/mavis/php-hexagonal/hooks/README.md +3 -0
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +107 -18
- package/presets/mavis/php-hexagonal/hooks/check-preset-update.mjs +227 -0
- package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/php-hexagonal/skills/technical-retro/SKILL.md +2 -0
- package/presets/mavis/php-laravel/REPO_AGENTS.md +14 -0
- package/presets/mavis/php-laravel/adapter-map.json +17 -1
- package/presets/mavis/php-laravel/agents/build-verifier.md +1 -1
- package/presets/mavis/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/mavis/php-laravel/agents/debugger.md +1 -1
- package/presets/mavis/php-laravel/agents/feature-developer.md +1 -1
- package/presets/mavis/php-laravel/agents/task-analyst.md +1 -1
- package/presets/mavis/php-laravel/commands/README.md +1 -0
- package/presets/mavis/php-laravel/commands/task-continue.md +9 -0
- package/presets/mavis/php-laravel/commands/technical-retro.md +8 -0
- package/presets/mavis/php-laravel/commands/update.md +34 -0
- package/presets/mavis/php-laravel/hooks/README.md +3 -0
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +107 -18
- package/presets/mavis/php-laravel/hooks/check-preset-update.mjs +227 -0
- package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/php-laravel/skills/technical-retro/SKILL.md +2 -0
- package/presets/mavis/svelte/MAVIS.md +1 -0
- package/presets/mavis/svelte/REPO_AGENTS.md +14 -0
- package/presets/mavis/svelte/adapter-map.json +17 -1
- package/presets/mavis/svelte/agents/build-verifier.md +1 -1
- package/presets/mavis/svelte/agents/code-reviewer.md +1 -1
- package/presets/mavis/svelte/agents/debugger.md +1 -1
- package/presets/mavis/svelte/agents/feature-developer.md +1 -1
- package/presets/mavis/svelte/agents/task-analyst.md +1 -1
- package/presets/mavis/svelte/commands/README.md +1 -0
- package/presets/mavis/svelte/commands/task-continue.md +9 -0
- package/presets/mavis/svelte/commands/technical-retro.md +8 -0
- package/presets/mavis/svelte/commands/update.md +34 -0
- package/presets/mavis/svelte/hooks/README.md +3 -0
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +107 -18
- package/presets/mavis/svelte/hooks/check-preset-update.mjs +227 -0
- package/presets/mavis/svelte/rules/agent-team-orchestrator.md +1 -1
- package/presets/mavis/svelte/skills/technical-retro/SKILL.md +2 -0
- package/presets/opencode/android-kotlin/OPENCODE.md +15 -6
- package/presets/opencode/android-kotlin/REPO_AGENTS.md +14 -0
- package/presets/opencode/android-kotlin/adapter-map.json +17 -1
- package/presets/opencode/android-kotlin/agents/build-verifier.md +1 -1
- package/presets/opencode/android-kotlin/agents/code-reviewer.md +1 -1
- package/presets/opencode/android-kotlin/agents/debugger.md +1 -1
- package/presets/opencode/android-kotlin/agents/feature-developer.md +1 -1
- package/presets/opencode/android-kotlin/agents/task-analyst.md +1 -1
- package/presets/opencode/android-kotlin/commands/README.md +1 -0
- package/presets/opencode/android-kotlin/commands/task-continue.md +9 -0
- package/presets/opencode/android-kotlin/commands/technical-retro.md +8 -0
- package/presets/opencode/android-kotlin/commands/update.md +42 -0
- package/presets/opencode/android-kotlin/hooks/README.md +3 -0
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +107 -18
- package/presets/opencode/android-kotlin/hooks/check-preset-update.mjs +227 -0
- package/presets/opencode/android-kotlin/opencode.json +2 -12
- package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/android-kotlin/skills/technical-retro/SKILL.md +2 -0
- package/presets/opencode/go/OPENCODE.md +14 -6
- package/presets/opencode/go/REPO_AGENTS.md +14 -0
- package/presets/opencode/go/adapter-map.json +17 -1
- package/presets/opencode/go/agents/build-verifier.md +1 -1
- package/presets/opencode/go/agents/code-reviewer.md +1 -1
- package/presets/opencode/go/agents/debugger.md +1 -1
- package/presets/opencode/go/agents/feature-developer.md +1 -1
- package/presets/opencode/go/agents/task-analyst.md +1 -1
- package/presets/opencode/go/commands/README.md +1 -0
- package/presets/opencode/go/commands/task-continue.md +9 -0
- package/presets/opencode/go/commands/technical-retro.md +8 -0
- package/presets/opencode/go/commands/update.md +42 -0
- package/presets/opencode/go/hooks/README.md +3 -0
- package/presets/opencode/go/hooks/chain-team-phases.sh +107 -18
- package/presets/opencode/go/hooks/check-preset-update.mjs +227 -0
- package/presets/opencode/go/opencode.json +2 -12
- package/presets/opencode/go/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/go/skills/technical-retro/SKILL.md +2 -0
- package/presets/opencode/ios-swift/OPENCODE.md +15 -6
- package/presets/opencode/ios-swift/REPO_AGENTS.md +14 -0
- package/presets/opencode/ios-swift/adapter-map.json +17 -1
- package/presets/opencode/ios-swift/agents/build-verifier.md +1 -1
- package/presets/opencode/ios-swift/agents/code-reviewer.md +1 -1
- package/presets/opencode/ios-swift/agents/debugger.md +1 -1
- package/presets/opencode/ios-swift/agents/feature-developer.md +1 -1
- package/presets/opencode/ios-swift/agents/task-analyst.md +1 -1
- package/presets/opencode/ios-swift/commands/README.md +1 -0
- package/presets/opencode/ios-swift/commands/task-continue.md +9 -0
- package/presets/opencode/ios-swift/commands/technical-retro.md +8 -0
- package/presets/opencode/ios-swift/commands/update.md +42 -0
- package/presets/opencode/ios-swift/hooks/README.md +3 -0
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +107 -18
- package/presets/opencode/ios-swift/hooks/check-preset-update.mjs +227 -0
- package/presets/opencode/ios-swift/opencode.json +2 -12
- package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/ios-swift/skills/technical-retro/SKILL.md +2 -0
- package/presets/opencode/java/OPENCODE.md +14 -6
- package/presets/opencode/java/REPO_AGENTS.md +14 -0
- package/presets/opencode/java/adapter-map.json +17 -1
- package/presets/opencode/java/agents/build-verifier.md +1 -1
- package/presets/opencode/java/agents/code-reviewer.md +1 -1
- package/presets/opencode/java/agents/debugger.md +1 -1
- package/presets/opencode/java/agents/feature-developer.md +1 -1
- package/presets/opencode/java/agents/task-analyst.md +1 -1
- package/presets/opencode/java/commands/README.md +1 -0
- package/presets/opencode/java/commands/task-continue.md +9 -0
- package/presets/opencode/java/commands/technical-retro.md +8 -0
- package/presets/opencode/java/commands/update.md +42 -0
- package/presets/opencode/java/hooks/README.md +3 -0
- package/presets/opencode/java/hooks/chain-team-phases.sh +107 -18
- package/presets/opencode/java/hooks/check-preset-update.mjs +227 -0
- package/presets/opencode/java/opencode.json +2 -12
- package/presets/opencode/java/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/java/skills/technical-retro/SKILL.md +2 -0
- package/presets/opencode/mcp-ts/OPENCODE.md +14 -6
- package/presets/opencode/mcp-ts/REPO_AGENTS.md +14 -0
- package/presets/opencode/mcp-ts/adapter-map.json +17 -1
- package/presets/opencode/mcp-ts/agents/build-verifier.md +1 -1
- package/presets/opencode/mcp-ts/agents/feature-developer.md +1 -1
- package/presets/opencode/mcp-ts/agents/task-analyst.md +1 -1
- package/presets/opencode/mcp-ts/commands/README.md +1 -0
- package/presets/opencode/mcp-ts/commands/task-continue.md +9 -0
- package/presets/opencode/mcp-ts/commands/technical-retro.md +8 -0
- package/presets/opencode/mcp-ts/commands/update.md +42 -0
- package/presets/opencode/mcp-ts/hooks/README.md +3 -0
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +107 -18
- package/presets/opencode/mcp-ts/hooks/check-preset-update.mjs +227 -0
- package/presets/opencode/mcp-ts/opencode.json +2 -12
- package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/next/OPENCODE.md +15 -6
- package/presets/opencode/next/REPO_AGENTS.md +15 -1
- package/presets/opencode/next/adapter-map.json +25 -1
- package/presets/opencode/next/agents/build-verifier.md +1 -1
- package/presets/opencode/next/agents/code-reviewer.md +1 -1
- package/presets/opencode/next/agents/debugger.md +1 -1
- package/presets/opencode/next/agents/feature-developer.md +1 -1
- package/presets/opencode/next/agents/task-analyst.md +1 -1
- package/presets/opencode/next/agents/task-router.md +1 -1
- package/presets/opencode/next/commands/README.md +1 -0
- package/presets/opencode/next/commands/task-continue.md +9 -0
- package/presets/opencode/next/commands/technical-retro.md +8 -0
- package/presets/opencode/next/commands/update.md +42 -0
- package/presets/opencode/next/hooks/README.md +3 -0
- package/presets/opencode/next/hooks/chain-team-phases.sh +107 -18
- package/presets/opencode/next/hooks/check-preset-update.mjs +227 -0
- package/presets/opencode/next/opencode.json +2 -12
- package/presets/opencode/next/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/next/rules/component-catalog-gate.md +13 -0
- package/presets/opencode/next/rules/forms-validation.md +12 -0
- package/presets/opencode/next/rules/next-app-router.md +27 -0
- package/presets/opencode/next/rules/next-static-export.md +16 -0
- package/presets/opencode/next/rules/react-next-anti-hallucination.md +20 -18
- package/presets/opencode/next/rules/security-next.md +13 -0
- package/presets/opencode/next/skills/technical-retro/SKILL.md +2 -0
- package/presets/opencode/next/team/fixtures/feature-light.json +2 -1
- package/presets/opencode/next/team/fixtures/feature-ui-standard.json +24 -0
- package/presets/opencode/nuxt/OPENCODE.md +15 -6
- package/presets/opencode/nuxt/REPO_AGENTS.md +14 -0
- package/presets/opencode/nuxt/adapter-map.json +17 -1
- package/presets/opencode/nuxt/agents/build-verifier.md +1 -1
- package/presets/opencode/nuxt/agents/code-reviewer.md +1 -1
- package/presets/opencode/nuxt/agents/debugger.md +1 -1
- package/presets/opencode/nuxt/agents/feature-developer.md +1 -1
- package/presets/opencode/nuxt/agents/task-analyst.md +1 -1
- package/presets/opencode/nuxt/commands/README.md +1 -0
- package/presets/opencode/nuxt/commands/task-continue.md +9 -0
- package/presets/opencode/nuxt/commands/technical-retro.md +8 -0
- package/presets/opencode/nuxt/commands/update.md +42 -0
- package/presets/opencode/nuxt/hooks/README.md +3 -0
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +107 -18
- package/presets/opencode/nuxt/hooks/check-preset-update.mjs +227 -0
- package/presets/opencode/nuxt/opencode.json +2 -12
- package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/nuxt/skills/technical-retro/SKILL.md +2 -0
- package/presets/opencode/php-hexagonal/OPENCODE.md +14 -6
- package/presets/opencode/php-hexagonal/REPO_AGENTS.md +14 -0
- package/presets/opencode/php-hexagonal/adapter-map.json +17 -1
- package/presets/opencode/php-hexagonal/agents/build-verifier.md +1 -1
- package/presets/opencode/php-hexagonal/agents/code-reviewer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/debugger.md +1 -1
- package/presets/opencode/php-hexagonal/agents/feature-developer.md +1 -1
- package/presets/opencode/php-hexagonal/agents/task-analyst.md +1 -1
- package/presets/opencode/php-hexagonal/commands/README.md +1 -0
- package/presets/opencode/php-hexagonal/commands/task-continue.md +9 -0
- package/presets/opencode/php-hexagonal/commands/technical-retro.md +8 -0
- package/presets/opencode/php-hexagonal/commands/update.md +42 -0
- package/presets/opencode/php-hexagonal/hooks/README.md +3 -0
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +107 -18
- package/presets/opencode/php-hexagonal/hooks/check-preset-update.mjs +227 -0
- package/presets/opencode/php-hexagonal/opencode.json +2 -12
- package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/php-hexagonal/skills/technical-retro/SKILL.md +2 -0
- package/presets/opencode/php-laravel/OPENCODE.md +14 -6
- package/presets/opencode/php-laravel/REPO_AGENTS.md +14 -0
- package/presets/opencode/php-laravel/adapter-map.json +17 -1
- package/presets/opencode/php-laravel/agents/build-verifier.md +1 -1
- package/presets/opencode/php-laravel/agents/code-reviewer.md +1 -1
- package/presets/opencode/php-laravel/agents/debugger.md +1 -1
- package/presets/opencode/php-laravel/agents/feature-developer.md +1 -1
- package/presets/opencode/php-laravel/agents/task-analyst.md +1 -1
- package/presets/opencode/php-laravel/commands/README.md +1 -0
- package/presets/opencode/php-laravel/commands/task-continue.md +9 -0
- package/presets/opencode/php-laravel/commands/technical-retro.md +8 -0
- package/presets/opencode/php-laravel/commands/update.md +42 -0
- package/presets/opencode/php-laravel/hooks/README.md +3 -0
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +107 -18
- package/presets/opencode/php-laravel/hooks/check-preset-update.mjs +227 -0
- package/presets/opencode/php-laravel/opencode.json +2 -12
- package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/php-laravel/skills/technical-retro/SKILL.md +2 -0
- package/presets/opencode/svelte/OPENCODE.md +15 -6
- package/presets/opencode/svelte/REPO_AGENTS.md +14 -0
- package/presets/opencode/svelte/adapter-map.json +17 -1
- package/presets/opencode/svelte/agents/build-verifier.md +1 -1
- package/presets/opencode/svelte/agents/code-reviewer.md +1 -1
- package/presets/opencode/svelte/agents/debugger.md +1 -1
- package/presets/opencode/svelte/agents/feature-developer.md +1 -1
- package/presets/opencode/svelte/agents/task-analyst.md +1 -1
- package/presets/opencode/svelte/commands/README.md +1 -0
- package/presets/opencode/svelte/commands/task-continue.md +9 -0
- package/presets/opencode/svelte/commands/technical-retro.md +8 -0
- package/presets/opencode/svelte/commands/update.md +42 -0
- package/presets/opencode/svelte/hooks/README.md +3 -0
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +107 -18
- package/presets/opencode/svelte/hooks/check-preset-update.mjs +227 -0
- package/presets/opencode/svelte/opencode.json +2 -12
- package/presets/opencode/svelte/rules/agent-team-orchestrator.md +1 -1
- package/presets/opencode/svelte/skills/technical-retro/SKILL.md +2 -0
- package/scripts/check-product-specs.sh +115 -9
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-learning efficacy oracle — decides `retain | rollback | insufficient-data`
|
|
3
|
+
* for a retained local rule (architecture.md §6 Efficacy oracle, §8 slug 4).
|
|
4
|
+
*
|
|
5
|
+
* A retained rule must, over its cohort, show non-increasing quality /
|
|
6
|
+
* wrong-turn / waste rates, no duration or human-gate-wait rise, and zero guard
|
|
7
|
+
* violations vs the pre-change cohort; otherwise the verdict is `rollback`.
|
|
8
|
+
* This module does not write and does not apply that inverse. Small cohorts
|
|
9
|
+
* or low attribution confidence hold the rule as `staged`.
|
|
10
|
+
*
|
|
11
|
+
* The oracle is strictly read-only: it parses
|
|
12
|
+
* - `.ai.local/rule-changes.jsonl` (slug 2 ledger; per-rule `t0` = the
|
|
13
|
+
* earliest applied `at`, plus the guard-violation audit surface),
|
|
14
|
+
* - `.ai.local/signals.jsonl` (slug 1 wrong-turn taxonomy),
|
|
15
|
+
* - `.ai.local/team/tasks/<slug>/metrics.json` (attempt/gate outcomes).
|
|
16
|
+
* It never writes the ledgers, rule text, or lifecycle fields.
|
|
17
|
+
*
|
|
18
|
+
* `aggregate-agent-task-metrics.mjs` emits only role-level averages, so the
|
|
19
|
+
* per-task cohorts are computed directly from the `metrics.json` ledgers
|
|
20
|
+
* (the architecture.md "otherwise compute directly" branch).
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import fs from 'node:fs';
|
|
24
|
+
import path from 'node:path';
|
|
25
|
+
import { pathToFileURL } from 'node:url';
|
|
26
|
+
|
|
27
|
+
import { isDenied } from './rule-improver.mjs';
|
|
28
|
+
|
|
29
|
+
export const DEFAULT_BASE_DIR = path.join(process.cwd(), '.ai.local');
|
|
30
|
+
|
|
31
|
+
// --- Thresholds (architecture.md §6) ----------------------------------------
|
|
32
|
+
export const MIN_COHORT_SIZE = 5; // ≥5 completed tasks per cohort (R-3)
|
|
33
|
+
export const MIN_COHORT_CONFIDENCE = 0.5; // post-cohort mean attribution floor
|
|
34
|
+
export const ROLLBACK_RELATIVE_RISE = 0.2; // >20% relative wrong-turn/waste rise
|
|
35
|
+
|
|
36
|
+
// Wrong-turn taxonomy (slug 1 / signals.mjs). The rollback axis is the full
|
|
37
|
+
// set (the brief's "correction/retry/waste" is shorthand for §1's taxonomy).
|
|
38
|
+
export const WRONG_TURN_KINDS = ['correction', 'retry', 'waste', 'reversal', 'dead-end'];
|
|
39
|
+
|
|
40
|
+
// Attribution confidence → numeric weight. `fallback`/`unknown` tasks are
|
|
41
|
+
// down-weighted to zero (§6 "exclude or down-weight", R-3); `low` is retained
|
|
42
|
+
// but lowers the cohort mean toward the confidence floor.
|
|
43
|
+
export const CONFIDENCE_WEIGHT = { high: 1, medium: 0.66, low: 0.33, fallback: 0, unknown: 0 };
|
|
44
|
+
export const FALLBACK_LEVELS = new Set(['fallback', 'unknown']);
|
|
45
|
+
|
|
46
|
+
const QUALITY_OUTCOMES = new Set(['changes_requested', 'validation_failed']);
|
|
47
|
+
|
|
48
|
+
// Only these ledger actions put a rule into service (a behavioral effect).
|
|
49
|
+
// `seed-staged`/`staged`/`proposed`/`rejected` never act; `rollback` removes
|
|
50
|
+
// the rule. None of the non-applied actions may form a `t0`/cohort verdict.
|
|
51
|
+
const APPLIED_ACTIONS = new Set(['rule-created', 'conventions-added', 'applied']);
|
|
52
|
+
const ROLLED_BACK_ACTIONS = new Set(['rollback', 'rolled_back']);
|
|
53
|
+
|
|
54
|
+
// --- Pure helpers -------------------------------------------------------------
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Map an `attributionConfidence` level to its numeric weight (0 for unknown
|
|
58
|
+
* levels so a malformed level never inflates confidence).
|
|
59
|
+
*/
|
|
60
|
+
export function attributionWeight(level) {
|
|
61
|
+
return CONFIDENCE_WEIGHT[level] ?? 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Split completed tasks by `t0`. Pre = the last up-to-MIN_COHORT_SIZE tasks
|
|
66
|
+
* with `completedAt < t0`; post = the first up-to-MIN_COHORT_SIZE tasks with
|
|
67
|
+
* `completedAt ≥ t0`. Deterministic tie-break on `slug`.
|
|
68
|
+
*/
|
|
69
|
+
export function partitionTasks(tasks, t0) {
|
|
70
|
+
const sorted = [...tasks].sort((a, b) => {
|
|
71
|
+
const delta = Date.parse(a.completedAt) - Date.parse(b.completedAt);
|
|
72
|
+
if (delta !== 0) return delta;
|
|
73
|
+
return (a.slug ?? '').localeCompare(b.slug ?? '');
|
|
74
|
+
});
|
|
75
|
+
const pre = sorted.filter((task) => Date.parse(task.completedAt) < t0).slice(-MIN_COHORT_SIZE);
|
|
76
|
+
const post = sorted.filter((task) => Date.parse(task.completedAt) >= t0).slice(0, MIN_COHORT_SIZE);
|
|
77
|
+
return { pre, post };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Exclude tasks whose attempt attribution is predominantly `fallback`/`unknown`
|
|
82
|
+
* (R-3). Every kept task also gets a `confidence` (mean attempt weight) used
|
|
83
|
+
* for the low-confidence floor. Returns `{ kept, excluded }`.
|
|
84
|
+
*/
|
|
85
|
+
export function filterConfidentTasks(tasks) {
|
|
86
|
+
const kept = [];
|
|
87
|
+
const excluded = [];
|
|
88
|
+
for (const task of tasks) {
|
|
89
|
+
const levels = (task.attempts ?? []).map((a) => a.attributionConfidence ?? 'high');
|
|
90
|
+
const fallbackCount = levels.filter((level) => FALLBACK_LEVELS.has(level)).length;
|
|
91
|
+
const predominantlyFallback = levels.length > 0 && fallbackCount * 2 > levels.length;
|
|
92
|
+
const confidence = levels.length === 0
|
|
93
|
+
? 1
|
|
94
|
+
: levels.reduce((sum, level) => sum + attributionWeight(level), 0) / levels.length;
|
|
95
|
+
const entry = { ...task, confidence };
|
|
96
|
+
if (predominantlyFallback) excluded.push(entry);
|
|
97
|
+
else kept.push(entry);
|
|
98
|
+
}
|
|
99
|
+
return { kept, excluded };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Aggregate one cohort's decision metrics from its tasks + the signals
|
|
104
|
+
* timestamped inside the cohort window. All rates are normalized per task
|
|
105
|
+
* (or per attempt / per gate) so differently sized cohorts stay comparable.
|
|
106
|
+
*/
|
|
107
|
+
export function computeCohortMetrics({ tasks, signals }) {
|
|
108
|
+
const taskCount = tasks.length;
|
|
109
|
+
let attemptCount = 0;
|
|
110
|
+
let qualityFailures = 0;
|
|
111
|
+
let durationSum = 0;
|
|
112
|
+
let gateWaitSum = 0;
|
|
113
|
+
let gateCount = 0;
|
|
114
|
+
let confidenceSum = 0;
|
|
115
|
+
|
|
116
|
+
for (const task of tasks) {
|
|
117
|
+
for (const attempt of task.attempts ?? []) {
|
|
118
|
+
attemptCount += 1;
|
|
119
|
+
if (QUALITY_OUTCOMES.has(attempt.outcome)) qualityFailures += 1;
|
|
120
|
+
if (typeof attempt.durationMs === 'number' && attempt.durationMs >= 0) {
|
|
121
|
+
durationSum += attempt.durationMs;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (typeof task.gateWaitTotalMs === 'number' && task.gateWaitTotalMs >= 0) {
|
|
125
|
+
gateWaitSum += task.gateWaitTotalMs;
|
|
126
|
+
}
|
|
127
|
+
if (typeof task.gateCount === 'number' && task.gateCount > 0) gateCount += task.gateCount;
|
|
128
|
+
confidenceSum += typeof task.confidence === 'number' ? task.confidence : 1;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
let wrongTurnSignals = 0;
|
|
132
|
+
let wasteSignals = 0;
|
|
133
|
+
let highSeverityCount = 0;
|
|
134
|
+
for (const signal of signals ?? []) {
|
|
135
|
+
if (WRONG_TURN_KINDS.includes(signal.kind)) wrongTurnSignals += 1;
|
|
136
|
+
if (signal.kind === 'waste') wasteSignals += 1;
|
|
137
|
+
if (signal.severity === 'high') highSeverityCount += 1;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
taskCount,
|
|
142
|
+
attemptCount,
|
|
143
|
+
qualityRate: attemptCount === 0 ? 0 : qualityFailures / attemptCount,
|
|
144
|
+
wrongTurnRate: taskCount === 0 ? 0 : wrongTurnSignals / taskCount,
|
|
145
|
+
wasteRate: taskCount === 0 ? 0 : wasteSignals / taskCount,
|
|
146
|
+
highSeverityCount,
|
|
147
|
+
avgDurationMs: attemptCount === 0 ? 0 : durationSum / attemptCount,
|
|
148
|
+
gateWaitMeanMs: gateCount === 0 ? 0 : gateWaitSum / gateCount,
|
|
149
|
+
meanConfidence: taskCount === 0 ? 1 : confidenceSum / taskCount,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Detect guard violations across a rule's change entries (defense-in-depth on
|
|
155
|
+
* top of the improver's own denylist/stage guards). A violation is a denylist
|
|
156
|
+
* phrase in the applied content/target/signature, or an unauthorized
|
|
157
|
+
* `override: kill` line in an auto-applied rule body.
|
|
158
|
+
*/
|
|
159
|
+
export function detectGuardViolations(entries) {
|
|
160
|
+
const violations = [];
|
|
161
|
+
for (const entry of entries ?? []) {
|
|
162
|
+
const after = typeof entry.after === 'string' ? entry.after : '';
|
|
163
|
+
const target = typeof entry.target === 'string' ? entry.target : '';
|
|
164
|
+
const signature = typeof entry.signature === 'string' ? entry.signature : '';
|
|
165
|
+
const where = { signature: entry.signature ?? null, at: entry.at ?? null, target: entry.target ?? null };
|
|
166
|
+
if (isDenied(after) || isDenied(target) || isDenied(signature)) {
|
|
167
|
+
violations.push({ type: 'denylist', ...where });
|
|
168
|
+
}
|
|
169
|
+
if (/override\s*:\s*kill/i.test(after)) {
|
|
170
|
+
violations.push({ type: 'override-kill', ...where });
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return violations;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// --- Decision -----------------------------------------------------------------
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Decide `retain | rollback | insufficient-data` from pre/post cohort metrics
|
|
180
|
+
* plus guard violations. Pure: no I/O, deterministic for fixed inputs.
|
|
181
|
+
*
|
|
182
|
+
* Ladder (highest precedence first):
|
|
183
|
+
* 1. guard violation → rollback (hard gate)
|
|
184
|
+
* 2. cohort < MIN_COHORT_SIZE → insufficient-data
|
|
185
|
+
* 3. post confidence < floor → insufficient-data (low attribution)
|
|
186
|
+
* 4. any regression trigger → rollback
|
|
187
|
+
* 5. otherwise → retain
|
|
188
|
+
*
|
|
189
|
+
* Regression triggers: quality rate increase; wrong-turn or waste rate rising
|
|
190
|
+
* >20% relative; any high-severity rise; average duration increase; mean gate
|
|
191
|
+
* wait increase.
|
|
192
|
+
*/
|
|
193
|
+
export function computeVerdict({ signature, t0, pre, post, guardViolations, preExcluded = 0, postExcluded = 0 }) {
|
|
194
|
+
const guardOk = guardViolations.length === 0;
|
|
195
|
+
const cohortShort = pre.taskCount < MIN_COHORT_SIZE || post.taskCount < MIN_COHORT_SIZE;
|
|
196
|
+
const lowConfidence = post.meanConfidence < MIN_COHORT_CONFIDENCE;
|
|
197
|
+
|
|
198
|
+
const qualityUp = post.qualityRate > pre.qualityRate;
|
|
199
|
+
const wrongTurnUp = post.wrongTurnRate > pre.wrongTurnRate * (1 + ROLLBACK_RELATIVE_RISE);
|
|
200
|
+
const wasteUp = post.wasteRate > pre.wasteRate * (1 + ROLLBACK_RELATIVE_RISE);
|
|
201
|
+
const highUp = post.highSeverityCount > pre.highSeverityCount;
|
|
202
|
+
const durationUp = post.avgDurationMs > pre.avgDurationMs;
|
|
203
|
+
const gateUp = post.gateWaitMeanMs > pre.gateWaitMeanMs;
|
|
204
|
+
|
|
205
|
+
const evidence = [
|
|
206
|
+
{
|
|
207
|
+
dimension: 'quality',
|
|
208
|
+
label: 'changes_requested + validation_failed rate',
|
|
209
|
+
before: pre.qualityRate,
|
|
210
|
+
after: post.qualityRate,
|
|
211
|
+
condition: 'post ≤ pre',
|
|
212
|
+
ok: !qualityUp,
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
dimension: 'wrong-turn',
|
|
216
|
+
label: 'correction+retry+waste+reversal+dead-end rate',
|
|
217
|
+
before: pre.wrongTurnRate,
|
|
218
|
+
after: post.wrongTurnRate,
|
|
219
|
+
condition: `post ≤ pre × ${1 + ROLLBACK_RELATIVE_RISE}`,
|
|
220
|
+
ok: !wrongTurnUp,
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
dimension: 'waste',
|
|
224
|
+
label: 'waste signal rate',
|
|
225
|
+
before: pre.wasteRate,
|
|
226
|
+
after: post.wasteRate,
|
|
227
|
+
condition: `post ≤ pre × ${1 + ROLLBACK_RELATIVE_RISE}`,
|
|
228
|
+
ok: !wasteUp,
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
dimension: 'high-severity',
|
|
232
|
+
label: 'high-severity signal count',
|
|
233
|
+
before: pre.highSeverityCount,
|
|
234
|
+
after: post.highSeverityCount,
|
|
235
|
+
condition: 'post ≤ pre',
|
|
236
|
+
ok: !highUp,
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
dimension: 'duration',
|
|
240
|
+
label: 'avg attempt duration (ms)',
|
|
241
|
+
before: pre.avgDurationMs,
|
|
242
|
+
after: post.avgDurationMs,
|
|
243
|
+
condition: 'post ≤ pre',
|
|
244
|
+
ok: !durationUp,
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
dimension: 'gate-wait',
|
|
248
|
+
label: 'mean human-gate wait (ms)',
|
|
249
|
+
before: pre.gateWaitMeanMs,
|
|
250
|
+
after: post.gateWaitMeanMs,
|
|
251
|
+
condition: 'post ≤ pre',
|
|
252
|
+
ok: !gateUp,
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
dimension: 'guard',
|
|
256
|
+
label: 'guard violations',
|
|
257
|
+
before: 0,
|
|
258
|
+
after: guardViolations.length,
|
|
259
|
+
condition: 'zero',
|
|
260
|
+
ok: guardOk,
|
|
261
|
+
},
|
|
262
|
+
];
|
|
263
|
+
|
|
264
|
+
const regressionReasons = [];
|
|
265
|
+
if (qualityUp) regressionReasons.push('quality rate increased');
|
|
266
|
+
if (wrongTurnUp) regressionReasons.push('wrong-turn rate >20% relative');
|
|
267
|
+
if (wasteUp) regressionReasons.push('waste rate >20% relative');
|
|
268
|
+
if (highUp) regressionReasons.push('high-severity rise');
|
|
269
|
+
if (durationUp) regressionReasons.push('duration increased');
|
|
270
|
+
if (gateUp) regressionReasons.push('gate wait increased');
|
|
271
|
+
|
|
272
|
+
let verdict;
|
|
273
|
+
let reasons;
|
|
274
|
+
if (!guardOk) {
|
|
275
|
+
verdict = 'rollback';
|
|
276
|
+
reasons = ['guard violation', ...regressionReasons];
|
|
277
|
+
} else if (cohortShort) {
|
|
278
|
+
verdict = 'insufficient-data';
|
|
279
|
+
reasons = [`cohort < ${MIN_COHORT_SIZE}`];
|
|
280
|
+
} else if (lowConfidence) {
|
|
281
|
+
verdict = 'insufficient-data';
|
|
282
|
+
reasons = ['low confidence'];
|
|
283
|
+
} else if (regressionReasons.length > 0) {
|
|
284
|
+
verdict = 'rollback';
|
|
285
|
+
reasons = regressionReasons;
|
|
286
|
+
} else {
|
|
287
|
+
verdict = 'retain';
|
|
288
|
+
reasons = [];
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return {
|
|
292
|
+
verdict,
|
|
293
|
+
signature,
|
|
294
|
+
t0,
|
|
295
|
+
reasons,
|
|
296
|
+
cohort: { pre: pre.taskCount, post: post.taskCount, preExcluded, postExcluded },
|
|
297
|
+
confidence: { pre: pre.meanConfidence, post: post.meanConfidence },
|
|
298
|
+
guardViolations,
|
|
299
|
+
evidence,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// --- Ledger readers (read-only I/O) -------------------------------------------
|
|
304
|
+
|
|
305
|
+
function readLedger(ledgerPath) {
|
|
306
|
+
const entries = [];
|
|
307
|
+
const errors = [];
|
|
308
|
+
let raw = '';
|
|
309
|
+
try { raw = fs.readFileSync(ledgerPath, 'utf8'); } catch (error) {
|
|
310
|
+
if (error && error.code === 'ENOENT') return { entries, errors };
|
|
311
|
+
throw error;
|
|
312
|
+
}
|
|
313
|
+
raw.split('\n').forEach((line, index) => {
|
|
314
|
+
const trimmed = line.trim();
|
|
315
|
+
if (trimmed === '') return;
|
|
316
|
+
try { entries.push(JSON.parse(trimmed)); } catch (error) {
|
|
317
|
+
errors.push({ line: index + 1, reason: error instanceof Error ? error.message : String(error) });
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
return { entries, errors };
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Derive the wrong-turn kind from the signature prefix when the stored `kind`
|
|
324
|
+
// disagrees, so wrong-turn/waste rates never move independently of the rule
|
|
325
|
+
// the signal is actually about (W5). Falls back to the stored kind when the
|
|
326
|
+
// prefix is not a known taxonomy kind.
|
|
327
|
+
function signalKind(signal) {
|
|
328
|
+
const signature = typeof signal.signature === 'string' ? signal.signature : '';
|
|
329
|
+
const colon = signature.indexOf(':');
|
|
330
|
+
const prefix = colon === -1 ? '' : signature.slice(0, colon);
|
|
331
|
+
return WRONG_TURN_KINDS.includes(prefix) ? prefix : signal.kind;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function readSignals(signalsPath) {
|
|
335
|
+
const signals = [];
|
|
336
|
+
const errors = [];
|
|
337
|
+
let raw = '';
|
|
338
|
+
try { raw = fs.readFileSync(signalsPath, 'utf8'); } catch (error) {
|
|
339
|
+
if (error && error.code === 'ENOENT') return { signals, errors };
|
|
340
|
+
throw error;
|
|
341
|
+
}
|
|
342
|
+
raw.split('\n').forEach((line, index) => {
|
|
343
|
+
const trimmed = line.trim();
|
|
344
|
+
if (trimmed === '') return;
|
|
345
|
+
let signal;
|
|
346
|
+
try { signal = JSON.parse(trimmed); } catch (error) {
|
|
347
|
+
errors.push({ line: index + 1, reason: error instanceof Error ? error.message : String(error) });
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
if (typeof signal.at !== 'string' || Number.isNaN(Date.parse(signal.at))) {
|
|
351
|
+
errors.push({ line: index + 1, reason: '"at" must be an ISO timestamp' });
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
signals.push({
|
|
355
|
+
kind: signalKind(signal),
|
|
356
|
+
severity: signal.severity,
|
|
357
|
+
signature: signal.signature,
|
|
358
|
+
slug: signal.slug,
|
|
359
|
+
at: signal.at,
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
return { signals, errors };
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Read every task `metrics.json` under `tasksDir` into `{ slug, completedAt,
|
|
367
|
+
* attempts, gateWaitTotalMs, gateCount }`. Read-only; `run.mjs --strict` reuses
|
|
368
|
+
* it to order the capture window without a second metrics reader.
|
|
369
|
+
*/
|
|
370
|
+
export function readAllTasks(tasksDir) {
|
|
371
|
+
const tasks = [];
|
|
372
|
+
const errors = [];
|
|
373
|
+
let names = [];
|
|
374
|
+
try { names = fs.readdirSync(tasksDir); } catch (error) {
|
|
375
|
+
if (error && error.code === 'ENOENT') return { tasks, errors };
|
|
376
|
+
throw error;
|
|
377
|
+
}
|
|
378
|
+
for (const name of names) {
|
|
379
|
+
const metricsPath = path.join(tasksDir, name, 'metrics.json');
|
|
380
|
+
let raw;
|
|
381
|
+
try {
|
|
382
|
+
raw = fs.readFileSync(metricsPath, 'utf8');
|
|
383
|
+
} catch (error) {
|
|
384
|
+
// A task dir without metrics.json yet is normal (in-flight); any other
|
|
385
|
+
// read error is real and must fail the verdict, not shrink the cohort.
|
|
386
|
+
if (error && error.code === 'ENOENT') continue;
|
|
387
|
+
errors.push({ task: name, reason: error instanceof Error ? error.message : String(error) });
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
let data;
|
|
391
|
+
try {
|
|
392
|
+
data = JSON.parse(raw);
|
|
393
|
+
} catch (error) {
|
|
394
|
+
errors.push({ task: name, reason: `metrics.json parse error: ${error instanceof Error ? error.message : String(error)}` });
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
const slug = data?.task?.slug ?? name;
|
|
398
|
+
const events = Array.isArray(data?.events) ? data.events : [];
|
|
399
|
+
const completed = events.find((event) => event.type === 'task_completed');
|
|
400
|
+
if (!completed || typeof completed.at !== 'string') continue;
|
|
401
|
+
|
|
402
|
+
const attempts = events
|
|
403
|
+
.filter((event) => event.type === 'attempt_finished')
|
|
404
|
+
.map((event) => ({
|
|
405
|
+
outcome: event.outcome ?? null,
|
|
406
|
+
durationMs: typeof event.durationMs === 'number' ? event.durationMs : null,
|
|
407
|
+
attributionConfidence: event.attributionConfidence ?? 'high',
|
|
408
|
+
}));
|
|
409
|
+
|
|
410
|
+
const startedById = new Map();
|
|
411
|
+
for (const event of events) {
|
|
412
|
+
if (event.type === 'human_gate_started' && typeof event.eventId === 'string') {
|
|
413
|
+
startedById.set(event.eventId, Date.parse(event.at));
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
let gateWaitTotalMs = 0;
|
|
417
|
+
let gateCount = 0;
|
|
418
|
+
for (const event of events) {
|
|
419
|
+
if (event.type !== 'human_gate_ended') continue;
|
|
420
|
+
const startedAt = startedById.get(event.gateStartedEventId);
|
|
421
|
+
if (startedAt == null || Number.isNaN(startedAt)) continue;
|
|
422
|
+
const duration = Date.parse(event.at) - startedAt;
|
|
423
|
+
if (duration >= 0) { gateWaitTotalMs += duration; gateCount += 1; }
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
tasks.push({ slug, completedAt: completed.at, attempts, gateWaitTotalMs, gateCount });
|
|
427
|
+
}
|
|
428
|
+
return { tasks, errors };
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function decideRule({ rule, entries, signals, tasks }) {
|
|
432
|
+
if (entries.length === 0) {
|
|
433
|
+
return { verdict: 'insufficient-data', signature: rule, t0: null, reasons: ['no applied change'], cohort: { pre: 0, post: 0, preExcluded: 0, postExcluded: 0 }, confidence: { pre: 1, post: 1 }, guardViolations: [], evidence: [] };
|
|
434
|
+
}
|
|
435
|
+
// `t0` only from genuinely-applied actions: a staged seed (or a
|
|
436
|
+
// proposed/rejected change) has no behavioral effect, so it never forms a
|
|
437
|
+
// cohort and must not yield a retain/rollback verdict.
|
|
438
|
+
const applied = entries.filter((entry) => APPLIED_ACTIONS.has(entry.action));
|
|
439
|
+
const t0s = applied
|
|
440
|
+
.map((entry) => Date.parse(entry.at))
|
|
441
|
+
.filter((ms) => Number.isFinite(ms));
|
|
442
|
+
if (t0s.length === 0) {
|
|
443
|
+
return { verdict: 'insufficient-data', signature: rule, t0: null, reasons: ['not yet applied'], cohort: { pre: 0, post: 0, preExcluded: 0, postExcluded: 0 }, confidence: { pre: 1, post: 1 }, guardViolations: detectGuardViolations(entries), evidence: [] };
|
|
444
|
+
}
|
|
445
|
+
// A rule whose latest entry is a rollback is already out of service — no
|
|
446
|
+
// fresh cohort verdict either.
|
|
447
|
+
let latestAction = null;
|
|
448
|
+
let latestAt = -Infinity;
|
|
449
|
+
for (const entry of entries) {
|
|
450
|
+
const ms = Date.parse(entry.at);
|
|
451
|
+
if (Number.isFinite(ms) && ms >= latestAt) {
|
|
452
|
+
latestAt = ms;
|
|
453
|
+
latestAction = entry.action;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
if (ROLLED_BACK_ACTIONS.has(latestAction)) {
|
|
457
|
+
return { verdict: 'insufficient-data', signature: rule, t0: null, reasons: ['already rolled back'], cohort: { pre: 0, post: 0, preExcluded: 0, postExcluded: 0 }, confidence: { pre: 1, post: 1 }, guardViolations: detectGuardViolations(entries), evidence: [] };
|
|
458
|
+
}
|
|
459
|
+
const t0 = Math.min(...t0s);
|
|
460
|
+
const guardViolations = detectGuardViolations(entries);
|
|
461
|
+
|
|
462
|
+
const completed = tasks.filter((task) => task.completedAt != null);
|
|
463
|
+
const { pre, post } = partitionTasks(completed, t0);
|
|
464
|
+
const preFiltered = filterConfidentTasks(pre);
|
|
465
|
+
const postFiltered = filterConfidentTasks(post);
|
|
466
|
+
|
|
467
|
+
const preSlugs = new Set(preFiltered.kept.map((task) => task.slug));
|
|
468
|
+
const postSlugs = new Set(postFiltered.kept.map((task) => task.slug));
|
|
469
|
+
const preSignals = signals.filter((signal) => Date.parse(signal.at) < t0 && preSlugs.has(signal.slug));
|
|
470
|
+
const postSignals = signals.filter((signal) => Date.parse(signal.at) >= t0 && postSlugs.has(signal.slug));
|
|
471
|
+
|
|
472
|
+
const preMetrics = computeCohortMetrics({ tasks: preFiltered.kept, signals: preSignals });
|
|
473
|
+
const postMetrics = computeCohortMetrics({ tasks: postFiltered.kept, signals: postSignals });
|
|
474
|
+
|
|
475
|
+
return computeVerdict({
|
|
476
|
+
signature: rule,
|
|
477
|
+
t0: new Date(t0).toISOString(),
|
|
478
|
+
pre: preMetrics,
|
|
479
|
+
post: postMetrics,
|
|
480
|
+
guardViolations,
|
|
481
|
+
preExcluded: preFiltered.excluded.length,
|
|
482
|
+
postExcluded: postFiltered.excluded.length,
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// --- Engine -------------------------------------------------------------------
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Read the ledgers and compute verdict(s). With `options.rule` → one verdict
|
|
490
|
+
* for that signature; without → one verdict per distinct signature in
|
|
491
|
+
* `rule-changes.jsonl`. Read-only.
|
|
492
|
+
*/
|
|
493
|
+
export function oracle(options = {}) {
|
|
494
|
+
const baseDir = options.baseDir ?? DEFAULT_BASE_DIR;
|
|
495
|
+
const ruleChangesPath = options.ruleChangesPath ?? path.join(baseDir, 'rule-changes.jsonl');
|
|
496
|
+
const signalsPath = options.signalsPath ?? path.join(baseDir, 'signals.jsonl');
|
|
497
|
+
const tasksDir = options.tasksDir ?? path.join(baseDir, 'team', 'tasks');
|
|
498
|
+
|
|
499
|
+
const { entries, errors: ledgerErrors } = readLedger(ruleChangesPath);
|
|
500
|
+
const { signals, errors: signalErrors } = readSignals(signalsPath);
|
|
501
|
+
const { tasks, errors: taskErrors } = readAllTasks(tasksDir);
|
|
502
|
+
const parseReasons = [];
|
|
503
|
+
if (ledgerErrors.length > 0) parseReasons.push('ledger parse error');
|
|
504
|
+
if (signalErrors.length > 0) parseReasons.push('signals parse error');
|
|
505
|
+
if (taskErrors.length > 0) parseReasons.push('metrics parse error');
|
|
506
|
+
if (parseReasons.length > 0) {
|
|
507
|
+
const parsed = {
|
|
508
|
+
verdict: 'insufficient-data',
|
|
509
|
+
signature: options.rule ?? null,
|
|
510
|
+
t0: null,
|
|
511
|
+
reasons: parseReasons,
|
|
512
|
+
cohort: { pre: 0, post: 0, preExcluded: 0, postExcluded: 0 },
|
|
513
|
+
confidence: { pre: 1, post: 1 },
|
|
514
|
+
guardViolations: [],
|
|
515
|
+
evidence: [],
|
|
516
|
+
};
|
|
517
|
+
if (options.rule != null) return parsed;
|
|
518
|
+
return { signatures: [], verdicts: [parsed] };
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
if (options.rule != null) {
|
|
522
|
+
const ruleEntries = entries.filter((entry) => entry.signature === options.rule);
|
|
523
|
+
return decideRule({ rule: options.rule, entries: ruleEntries, signals, tasks });
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const signatures = [...new Set(entries.map((entry) => entry.signature).filter(Boolean))].sort();
|
|
527
|
+
return {
|
|
528
|
+
signatures,
|
|
529
|
+
verdicts: signatures.map((signature) => decideRule({
|
|
530
|
+
rule: signature,
|
|
531
|
+
entries: entries.filter((entry) => entry.signature === signature),
|
|
532
|
+
signals,
|
|
533
|
+
tasks,
|
|
534
|
+
})),
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// --- Renderer -----------------------------------------------------------------
|
|
539
|
+
|
|
540
|
+
function fmtRate(value) {
|
|
541
|
+
return (value * 100).toFixed(1);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
function fmtMs(value) {
|
|
545
|
+
return Math.round(value).toLocaleString('en-US');
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function renderVerdict(verdict) {
|
|
549
|
+
const lines = [];
|
|
550
|
+
lines.push(`efficacy oracle — ${verdict.signature ?? '(unknown)'}`);
|
|
551
|
+
lines.push(`t0: ${verdict.t0 ?? '(none)'}`);
|
|
552
|
+
lines.push(`verdict: ${verdict.verdict}${verdict.reasons.length ? ` (${verdict.reasons.join('; ')})` : ''}`);
|
|
553
|
+
lines.push(`cohort: pre ${verdict.cohort.pre} (excluded ${verdict.cohort.preExcluded}) / post ${verdict.cohort.post} (excluded ${verdict.cohort.postExcluded})`);
|
|
554
|
+
lines.push(`confidence: pre ${verdict.confidence.pre.toFixed(2)} / post ${verdict.confidence.post.toFixed(2)}`);
|
|
555
|
+
lines.push('');
|
|
556
|
+
lines.push('evidence (before → after)');
|
|
557
|
+
for (const row of verdict.evidence) {
|
|
558
|
+
const before = row.dimension === 'duration' || row.dimension === 'gate-wait' ? fmtMs(row.before) : (Number.isInteger(row.before) ? String(row.before) : fmtRate(row.before));
|
|
559
|
+
const after = row.dimension === 'duration' || row.dimension === 'gate-wait' ? fmtMs(row.after) : (Number.isInteger(row.after) ? String(row.after) : fmtRate(row.after));
|
|
560
|
+
lines.push(` ${row.dimension.padEnd(14)} ${before.padStart(10)} → ${after.padStart(10)} ${row.ok ? 'ok' : 'FAIL'} (${row.condition})`);
|
|
561
|
+
}
|
|
562
|
+
return `${lines.join('\n')}\n`;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// CLI entry: `node efficacy-oracle.mjs [--rule <signature>]`.
|
|
566
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
567
|
+
const args = process.argv.slice(2);
|
|
568
|
+
const ruleIndex = args.indexOf('--rule');
|
|
569
|
+
const rule = ruleIndex !== -1 && args[ruleIndex + 1] ? args[ruleIndex + 1] : null;
|
|
570
|
+
const result = oracle({ rule });
|
|
571
|
+
if (Array.isArray(result.verdicts)) {
|
|
572
|
+
for (const verdict of result.verdicts) process.stdout.write(`\n${renderVerdict(verdict)}`);
|
|
573
|
+
} else {
|
|
574
|
+
process.stdout.write(renderVerdict(result));
|
|
575
|
+
}
|
|
576
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared advisory file lock with ownership token.
|
|
3
|
+
*
|
|
4
|
+
* The slug-1 review flagged a stale-reclaim race in the token-less lock
|
|
5
|
+
* inherited from `waitForMetricsLock`: process A holds the lock longer than
|
|
6
|
+
* STALE_LOCK_MS, process B reclaims it by mtime and acquires its own lock,
|
|
7
|
+
* then A's `releaseLock` unlinks B's lock — opening a parallel-write window.
|
|
8
|
+
*
|
|
9
|
+
* This module closes it: every acquired lock writes an ownership token
|
|
10
|
+
* (`pid:nonce`) into the lock file; release unlinks only if the file still
|
|
11
|
+
* carries our token; stale reclaim happens only when the lock is stale AND
|
|
12
|
+
* the recorded owner pid is no longer alive. Shared by `signals.mjs` and
|
|
13
|
+
* `rule-improver.mjs` (Rule of Three: two consumers).
|
|
14
|
+
*
|
|
15
|
+
* Reclaim is `unlink` + re-`wx` (not a single CAS): the `wx` retry is the
|
|
16
|
+
* atomic acquire — at most one contender wins; losers EEXIST and retry.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import fs from 'node:fs';
|
|
20
|
+
import crypto from 'node:crypto';
|
|
21
|
+
|
|
22
|
+
export const DEFAULT_STALE_MS = 30000;
|
|
23
|
+
export const DEFAULT_MAX_ATTEMPTS = 200;
|
|
24
|
+
export const DEFAULT_BUSY_WAIT_MS = 10;
|
|
25
|
+
|
|
26
|
+
function newToken() {
|
|
27
|
+
return `${process.pid}:${crypto.randomBytes(8).toString('hex')}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function pidFromToken(token) {
|
|
31
|
+
const match = /^(\d+):/.exec(token ?? '');
|
|
32
|
+
return match ? Number(match[1]) : null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* POSIX liveness probe: signal 0 raises ESRCH when no such pid exists, and
|
|
37
|
+
* EPERM when it exists but is owned by another user (still alive).
|
|
38
|
+
*/
|
|
39
|
+
export function isPidAlive(pid) {
|
|
40
|
+
try {
|
|
41
|
+
process.kill(pid, 0);
|
|
42
|
+
return true;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
return Boolean(error && error.code === 'EPERM');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function readToken(lockPath) {
|
|
49
|
+
try {
|
|
50
|
+
const content = fs.readFileSync(lockPath, 'utf8').trim();
|
|
51
|
+
return content.length > 0 ? content : null;
|
|
52
|
+
} catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function busyWait(ms) {
|
|
58
|
+
const until = Date.now() + ms;
|
|
59
|
+
while (Date.now() < until) { /* busy-wait */ }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Acquire the advisory lock at `lockPath`, returning the ownership token that
|
|
64
|
+
* must be passed to `releaseLock`. Throws on lock timeout.
|
|
65
|
+
*/
|
|
66
|
+
export function acquireLock(lockPath, options = {}) {
|
|
67
|
+
const staleMs = options.staleMs ?? DEFAULT_STALE_MS;
|
|
68
|
+
const maxAttempts = options.maxAttempts ?? DEFAULT_MAX_ATTEMPTS;
|
|
69
|
+
const busyWaitMs = options.busyWaitMs ?? DEFAULT_BUSY_WAIT_MS;
|
|
70
|
+
const checkLive = options.isPidAlive ?? isPidAlive;
|
|
71
|
+
const token = newToken();
|
|
72
|
+
|
|
73
|
+
for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
|
|
74
|
+
let fd;
|
|
75
|
+
try {
|
|
76
|
+
fd = fs.openSync(lockPath, 'wx');
|
|
77
|
+
} catch (error) {
|
|
78
|
+
if (!error || error.code !== 'EEXIST') throw error;
|
|
79
|
+
let stat = null;
|
|
80
|
+
try { stat = fs.statSync(lockPath); } catch { /* lock vanished; retry */ }
|
|
81
|
+
const stale = stat !== null && Date.now() - stat.mtimeMs > staleMs;
|
|
82
|
+
if (stale) {
|
|
83
|
+
const ownerPid = pidFromToken(readToken(lockPath));
|
|
84
|
+
// Reclaim only when the recorded owner is provably gone. A live owner
|
|
85
|
+
// holding the lock past staleMs is left alone — do not steal it.
|
|
86
|
+
if (ownerPid === null || !checkLive(ownerPid)) {
|
|
87
|
+
try { fs.unlinkSync(lockPath); } catch { /* already reclaimed */ }
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
busyWait(busyWaitMs);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
// Created exclusively — write the ownership token into the lock file.
|
|
95
|
+
try {
|
|
96
|
+
fs.writeSync(fd, token);
|
|
97
|
+
try { fs.fsyncSync(fd); } catch {}
|
|
98
|
+
} finally {
|
|
99
|
+
try { fs.closeSync(fd); } catch {}
|
|
100
|
+
}
|
|
101
|
+
// Re-read the path: a concurrent reclaim could have unlinked the still-empty
|
|
102
|
+
// file after our `wx` won but before the token landed, leaving our fd
|
|
103
|
+
// writing into an unlinked inode while a new owner holds the path. If the
|
|
104
|
+
// file no longer carries our token, retry the acquire (S1).
|
|
105
|
+
if (readToken(lockPath) !== token) continue;
|
|
106
|
+
return token;
|
|
107
|
+
}
|
|
108
|
+
throw new Error('lock timeout');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Release `lockPath` only if it still carries our `token`. If another
|
|
113
|
+
* process reclaimed the lock after us, we must not unlink their file.
|
|
114
|
+
*/
|
|
115
|
+
export function releaseLock(lockPath, token) {
|
|
116
|
+
if (readToken(lockPath) !== token) return;
|
|
117
|
+
try { fs.unlinkSync(lockPath); } catch {}
|
|
118
|
+
}
|