@bonesofspring/ai-rules 0.2.52 → 0.2.55
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 +67 -0
- package/README.md +45 -16
- package/bin/cli.js +599 -69
- package/bin/lib/engine-scripts.js +10 -0
- package/bin/lib/mcp/clients.js +205 -0
- package/bin/lib/mcp/credentials.js +310 -0
- package/bin/lib/mcp/doctor.js +396 -0
- package/bin/lib/mcp/prompt.js +115 -0
- package/bin/lib/mcp/registry.js +171 -0
- package/bin/lib/mcp/run.js +125 -0
- package/bin/lib/merged-config.js +68 -2
- package/bin/lib/seed-ai-local-team.js +6 -1
- package/bin/lib/tool-installs.js +28 -0
- package/bin/opencode-install.js +18 -0
- package/bin/zcode-install.js +479 -0
- package/docs/MAVIS.md +3 -3
- package/docs/MCP-SETUP.md +62 -0
- package/docs/OPENCODE-COMPATIBILITY.md +1 -1
- package/docs/OPENCODE.md +3 -3
- package/docs/PRESET-CONTRIBUTION.md +25 -11
- package/docs/TEAM-DB.md +188 -0
- package/docs/ZCODE-COMPATIBILITY.md +143 -0
- package/docs/ZCODE.md +50 -0
- package/docs/openapi/team-db.v1.json +5085 -0
- package/mcp/gitlab.mjs +123 -0
- package/mcp/lib/envfile.mjs +126 -0
- package/mcp/lib/yandex.mjs +384 -0
- package/mcp/yandex-mcp-proxy.mjs +155 -0
- package/mcp/yandex-token-refresh.mjs +65 -0
- package/package.json +23 -3
- package/presets/_shared/ai-local/scripts/manifest.mjs +99 -0
- package/presets/_shared/ai-local/scripts/team-db-api.mjs +1275 -0
- package/presets/_shared/ai-local/scripts/team-db-dashboard.mjs +1067 -0
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +1301 -0
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +1590 -0
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +831 -0
- package/presets/_shared/ai-local/scripts/team-db.mjs +297 -0
- package/presets/_shared/core/agent-team/agent-artifact-contracts.md +1 -1
- package/presets/_shared/core/meta/preset-pr-checklist.md +1 -1
- package/presets/_shared/core/meta/preset-twin-sync.md +2 -2
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +109 -0
- package/presets/claude/android-kotlin/REPO_AGENTS.md +15 -8
- package/presets/claude/android-kotlin/commands/README.md +1 -0
- package/presets/claude/android-kotlin/commands/migrate-tasks.md +41 -0
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/android-kotlin/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/android-kotlin/rules/tooling-and-review/preset-twin-sync.md +2 -2
- package/presets/claude/android-kotlin/team/README.md +14 -2
- package/presets/claude/go/REPO_AGENTS.md +15 -8
- package/presets/claude/go/commands/README.md +1 -0
- package/presets/claude/go/commands/migrate-tasks.md +41 -0
- package/presets/claude/go/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/go/rules/README.md +1 -1
- package/presets/claude/go/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/go/rules/tooling-and-review/preset-twin-sync.md +2 -2
- package/presets/claude/go/team/README.md +14 -2
- package/presets/claude/ios-swift/REPO_AGENTS.md +15 -8
- package/presets/claude/ios-swift/commands/README.md +1 -0
- package/presets/claude/ios-swift/commands/migrate-tasks.md +41 -0
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/ios-swift/rules/README.md +1 -1
- package/presets/claude/ios-swift/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/ios-swift/rules/tooling-and-review/preset-twin-sync.md +2 -2
- package/presets/claude/ios-swift/team/README.md +14 -2
- package/presets/claude/java/REPO_AGENTS.md +15 -8
- package/presets/claude/java/commands/README.md +1 -0
- package/presets/claude/java/commands/migrate-tasks.md +41 -0
- package/presets/claude/java/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/java/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/java/rules/tooling-and-review/preset-twin-sync.md +2 -2
- package/presets/claude/java/team/README.md +14 -2
- package/presets/claude/mcp-ts/REPO_AGENTS.md +15 -8
- package/presets/claude/mcp-ts/commands/README.md +1 -0
- package/presets/claude/mcp-ts/commands/migrate-tasks.md +41 -0
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/mcp-ts/rules/tooling-and-review/preset-twin-sync.md +2 -2
- package/presets/claude/mcp-ts/team/README.md +14 -2
- package/presets/claude/mol/CLAUDE.md +53 -0
- package/presets/claude/mol/MCP.md +38 -0
- package/presets/claude/mol/README.md +9 -0
- package/presets/claude/mol/REPO_AGENTS.md +107 -0
- package/presets/claude/mol/agents/README.md +97 -0
- package/presets/claude/mol/agents/accessibility-reviewer.md +86 -0
- package/presets/claude/mol/agents/api-contract-reviewer.md +81 -0
- package/presets/claude/mol/agents/build-verifier.md +111 -0
- package/presets/claude/mol/agents/ci-investigator.md +91 -0
- package/presets/claude/mol/agents/code-reviewer.md +133 -0
- package/presets/claude/mol/agents/codebase-analyzer.md +45 -0
- package/presets/claude/mol/agents/debugger.md +122 -0
- package/presets/claude/mol/agents/feature-developer.md +147 -0
- package/presets/claude/mol/agents/migration-specialist.md +91 -0
- package/presets/claude/mol/agents/mockup-reviewer.md +125 -0
- package/presets/claude/mol/agents/openspec-author.md +207 -0
- package/presets/claude/mol/agents/performance-auditor.md +92 -0
- package/presets/claude/mol/agents/playwright-test-generator.md +52 -0
- package/presets/claude/mol/agents/playwright-test-healer.md +53 -0
- package/presets/claude/mol/agents/playwright-test-planner.md +45 -0
- package/presets/claude/mol/agents/qa-tester.md +76 -0
- package/presets/claude/mol/agents/security-reviewer.md +83 -0
- package/presets/claude/mol/agents/solution-architect.md +93 -0
- package/presets/claude/mol/agents/task-analyst.md +249 -0
- package/presets/claude/mol/agents/task-router.md +261 -0
- package/presets/claude/mol/agents/tech-writer.md +82 -0
- package/presets/claude/mol/agents/unit-test-generator.md +55 -0
- package/presets/claude/mol/agents/unit-test-healer.md +56 -0
- package/presets/claude/mol/agents/unit-test-planner.md +78 -0
- package/presets/claude/mol/ai-local/conventions.md +49 -0
- package/presets/claude/mol/ai-local/rules/task-levels.md +40 -0
- package/presets/claude/mol/ai-local/rules-library/agent-artifacts-no-local-paths.md +71 -0
- package/presets/claude/mol/ai-local/rules-library/agent-pipeline-gates.md +19 -0
- package/presets/claude/mol/ai-local/rules-library/analytics-events.md +18 -0
- package/presets/claude/mol/ai-local/rules-library/api-contract-source.md +14 -0
- package/presets/claude/mol/ai-local/rules-library/artifact-lifecycle.md +17 -0
- package/presets/claude/mol/ai-local/rules-library/code-style.md +68 -0
- package/presets/claude/mol/ai-local/rules-library/commit-hygiene.md +17 -0
- package/presets/claude/mol/ai-local/rules-library/component-child-decomposition.md +81 -0
- package/presets/claude/mol/ai-local/rules-library/feature-flags-experiments.md +15 -0
- package/presets/claude/mol/ai-local/rules-library/mcp-required-for-ui-layout.md +45 -0
- package/presets/claude/mol/ai-local/rules-library/no-react-fc.md +46 -0
- package/presets/claude/mol/ai-local/rules-library/no-test-driven-behavior-change.md +14 -0
- package/presets/claude/mol/ai-local/rules-library/pre-pr-checklist.md +16 -0
- package/presets/claude/mol/ai-local/rules-library/pwa-service-worker.md +15 -0
- package/presets/claude/mol/ai-local/rules-library/qa-test-cases.md +14 -0
- package/presets/claude/mol/ai-local/rules-library/router-pages.md +25 -0
- package/presets/claude/mol/ai-local/rules-library/single-source-copy-constants.md +18 -0
- package/presets/claude/mol/ai-local/rules-library/storybook-catalog-structure.md +62 -0
- package/presets/claude/mol/ai-local/rules-library/storybook-cleanup-temp-screenshots.md +40 -0
- package/presets/claude/mol/ai-local/rules-library/storybook-csf-authoring.md +100 -0
- package/presets/claude/mol/ai-local/rules-library/storybook-dev-compare-figma.md +71 -0
- package/presets/claude/mol/ai-local/rules-library/storybook-keep-tests-current.md +75 -0
- package/presets/claude/mol/ai-local/rules-library/storybook-modals.md +64 -0
- package/presets/claude/mol/ai-local/rules-library/storybook-no-app-node-modules.md +40 -0
- package/presets/claude/mol/ai-local/rules-library/storybook-ui-quality-gate.md +38 -0
- package/presets/claude/mol/ai-local/rules-library/ui-change-review-gate.md +15 -0
- package/presets/claude/mol/commands/README.md +56 -0
- package/presets/claude/mol/commands/migrate-tasks.md +41 -0
- package/presets/claude/mol/commands/spec-start.md +29 -0
- package/presets/claude/mol/commands/task-continue.md +72 -0
- package/presets/claude/mol/commands/task-evil.md +84 -0
- package/presets/claude/mol/commands/task.md +72 -0
- package/presets/claude/mol/commands/technical-retro.md +93 -0
- package/presets/claude/mol/commands/update.md +40 -0
- package/presets/claude/mol/hooks/chain-team-phases.sh +2783 -0
- package/presets/claude/mol/hooks/check-preset-update.mjs +232 -0
- package/presets/claude/mol/hooks/list-ai-local.mjs +299 -0
- package/presets/claude/mol/mcp.json +20 -0
- package/presets/claude/mol/rules/README.md +87 -0
- package/presets/claude/mol/rules/architecture/feature-delivery-workflow.md +149 -0
- package/presets/claude/mol/rules/architecture/mol-state.md +30 -0
- package/presets/claude/mol/rules/architecture/mol-theming.md +30 -0
- package/presets/claude/mol/rules/architecture/product-specs-authoring.md +124 -0
- package/presets/claude/mol/rules/architecture/product-specs.md +67 -0
- package/presets/claude/mol/rules/architecture/reference-features.md +87 -0
- package/presets/claude/mol/rules/stack/mol-app-core.md +34 -0
- package/presets/claude/mol/rules/stack/mol-components.md +36 -0
- package/presets/claude/mol/rules/stack/mol-reactivity.md +26 -0
- package/presets/claude/mol/rules/stack/mol-view-tree.md +32 -0
- package/presets/claude/mol/rules/stack/package-manager.md +12 -0
- package/presets/claude/mol/rules/testing/mol-build.md +29 -0
- package/presets/claude/mol/rules/testing/mol-testing.md +36 -0
- package/presets/claude/mol/rules/tooling-and-review/agent-team-intake.md +19 -0
- package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +287 -0
- package/presets/claude/mol/rules/tooling-and-review/ai-local-overlay.md +23 -0
- package/presets/claude/mol/rules/tooling-and-review/anti-hallucination-contract.md +42 -0
- package/presets/claude/mol/rules/tooling-and-review/anti-sycophancy-discipline.md +28 -0
- package/presets/claude/mol/rules/tooling-and-review/code-quality.md +80 -0
- package/presets/claude/mol/rules/tooling-and-review/code-review-mr.md +100 -0
- package/presets/claude/mol/rules/tooling-and-review/design-guidance.md +109 -0
- package/presets/claude/mol/rules/tooling-and-review/interactive-questions.md +34 -0
- package/presets/claude/mol/rules/tooling-and-review/language-policy.md +59 -0
- package/presets/claude/mol/rules/tooling-and-review/mcp-usage.md +101 -0
- package/presets/claude/mol/rules/tooling-and-review/preset-goals.md +39 -0
- package/presets/claude/mol/rules/tooling-and-review/preset-layering.md +35 -0
- package/presets/claude/mol/rules/tooling-and-review/preset-no-cross-stack-leakage.md +97 -0
- package/presets/claude/mol/rules/tooling-and-review/preset-pr-checklist.md +53 -0
- package/presets/claude/mol/rules/tooling-and-review/preset-token-budget.md +46 -0
- package/presets/claude/mol/rules/tooling-and-review/preset-twin-sync.md +49 -0
- package/presets/claude/mol/rules/tooling-and-review/preset-writing-style.md +50 -0
- package/presets/claude/mol/rules/tooling-and-review/technical-retro.md +18 -0
- package/presets/claude/mol/settings.json +52 -0
- package/presets/claude/mol/skills/README.md +17 -0
- package/presets/claude/mol/skills/ci-investigation/SKILL.md +44 -0
- package/presets/claude/mol/skills/code-review/SKILL.md +55 -0
- package/presets/claude/mol/skills/debug-investigation/SKILL.md +59 -0
- package/presets/claude/mol/skills/feature-delivery/SKILL.md +39 -0
- package/presets/claude/mol/skills/spec-authoring/SKILL.md +26 -0
- package/presets/claude/mol/skills/spec-discovery/SKILL.md +58 -0
- package/presets/claude/mol/skills/technical-retro/SKILL.md +67 -0
- package/presets/claude/mol/skills/unit-testing/SKILL.md +33 -0
- package/presets/claude/mol/skills/write-adr/SKILL.md +41 -0
- package/presets/claude/mol/team/README.md +135 -0
- package/presets/claude/mol/team/fixtures/artifact-manifest.example.json +80 -0
- package/presets/claude/mol/team/fixtures/bugfix-standard.json +25 -0
- package/presets/claude/mol/team/fixtures/feature-full.json +29 -0
- package/presets/claude/mol/team/fixtures/feature-light.json +28 -0
- package/presets/claude/mol/team/fixtures/feature-parallel.json +84 -0
- package/presets/claude/mol/team/fixtures/feature-ui-standard.json +24 -0
- package/presets/claude/mol/team/fixtures/feature-with-figma-url.json +27 -0
- package/presets/claude/mol/team/fixtures/feature-with-ux-no-figma.json +26 -0
- package/presets/claude/mol/team/fixtures/memlog.example.md +9 -0
- package/presets/claude/mol/team/fixtures/metrics-scenarios/tasks/human-gate/metrics.json +69 -0
- package/presets/claude/mol/team/fixtures/metrics-scenarios/tasks/missing-ledger/status.json +5 -0
- package/presets/claude/mol/team/fixtures/metrics-scenarios/tasks/parallel-receipts/metrics.json +79 -0
- package/presets/claude/mol/team/fixtures/metrics-scenarios/tasks/serial-retry/metrics.json +124 -0
- package/presets/claude/mol/team/fixtures/metrics-scenarios/tasks/validation-failed/metrics.json +124 -0
- package/presets/claude/mol/team/fixtures/metrics.example.json +54 -0
- package/presets/claude/mol/team/fixtures/mockup-review-fail-embedded-status.json +8 -0
- package/presets/claude/mol/team/fixtures/mockup-review-standalone.json +23 -0
- package/presets/claude/mol/team/fixtures/ux-design-standalone.json +24 -0
- package/presets/claude/mol/team/tasks/.gitkeep +0 -0
- package/presets/claude/next/REPO_AGENTS.md +16 -9
- package/presets/claude/next/agents/task-analyst.md +11 -0
- package/presets/claude/next/agents/task-router.md +11 -0
- package/presets/claude/next/commands/README.md +4 -0
- package/presets/claude/next/commands/migrate-tasks.md +41 -0
- package/presets/claude/next/commands/task-evil.md +88 -0
- package/presets/claude/next/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/next/rules/README.md +1 -1
- package/presets/claude/next/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/next/rules/tooling-and-review/preset-twin-sync.md +2 -2
- package/presets/claude/next/settings.json +1 -6
- package/presets/claude/next/team/README.md +14 -2
- package/presets/claude/nuxt/REPO_AGENTS.md +15 -8
- package/presets/claude/nuxt/commands/README.md +1 -0
- package/presets/claude/nuxt/commands/migrate-tasks.md +41 -0
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/nuxt/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/nuxt/rules/tooling-and-review/preset-twin-sync.md +2 -2
- package/presets/claude/nuxt/settings.json +1 -6
- package/presets/claude/nuxt/team/README.md +14 -2
- package/presets/claude/php-hexagonal/REPO_AGENTS.md +15 -8
- package/presets/claude/php-hexagonal/commands/README.md +1 -0
- package/presets/claude/php-hexagonal/commands/migrate-tasks.md +41 -0
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-twin-sync.md +2 -2
- package/presets/claude/php-hexagonal/team/README.md +14 -2
- package/presets/claude/php-laravel/REPO_AGENTS.md +15 -8
- package/presets/claude/php-laravel/commands/README.md +1 -0
- package/presets/claude/php-laravel/commands/migrate-tasks.md +41 -0
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/php-laravel/rules/tooling-and-review/preset-twin-sync.md +2 -2
- package/presets/claude/php-laravel/team/README.md +14 -2
- package/presets/claude/svelte/REPO_AGENTS.md +15 -8
- package/presets/claude/svelte/commands/README.md +1 -0
- package/presets/claude/svelte/commands/migrate-tasks.md +41 -0
- package/presets/claude/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/claude/svelte/rules/tooling-and-review/preset-pr-checklist.md +1 -1
- package/presets/claude/svelte/rules/tooling-and-review/preset-twin-sync.md +2 -2
- package/presets/claude/svelte/settings.json +1 -6
- package/presets/claude/svelte/team/README.md +14 -2
- package/presets/cursor/android-kotlin/REPO_AGENTS.md +15 -8
- package/presets/cursor/android-kotlin/commands/README.md +1 -0
- package/presets/cursor/android-kotlin/commands/migrate-tasks.md +41 -0
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/android-kotlin/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/android-kotlin/rules/preset-twin-sync.mdc +2 -2
- package/presets/cursor/android-kotlin/team/README.md +14 -2
- package/presets/cursor/go/REPO_AGENTS.md +15 -8
- package/presets/cursor/go/commands/README.md +1 -0
- package/presets/cursor/go/commands/migrate-tasks.md +41 -0
- package/presets/cursor/go/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/go/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/go/rules/preset-twin-sync.mdc +2 -2
- package/presets/cursor/go/team/README.md +14 -2
- package/presets/cursor/ios-swift/REPO_AGENTS.md +15 -8
- package/presets/cursor/ios-swift/commands/README.md +1 -0
- package/presets/cursor/ios-swift/commands/migrate-tasks.md +41 -0
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/ios-swift/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/ios-swift/rules/preset-twin-sync.mdc +2 -2
- package/presets/cursor/ios-swift/team/README.md +14 -2
- package/presets/cursor/java/REPO_AGENTS.md +15 -8
- package/presets/cursor/java/commands/README.md +1 -0
- package/presets/cursor/java/commands/migrate-tasks.md +41 -0
- package/presets/cursor/java/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/java/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/java/rules/preset-twin-sync.mdc +2 -2
- package/presets/cursor/java/team/README.md +14 -2
- package/presets/cursor/mcp-ts/REPO_AGENTS.md +15 -8
- package/presets/cursor/mcp-ts/commands/README.md +1 -0
- package/presets/cursor/mcp-ts/commands/migrate-tasks.md +41 -0
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/mcp-ts/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/mcp-ts/rules/preset-twin-sync.mdc +2 -2
- package/presets/cursor/mcp-ts/team/README.md +14 -2
- package/presets/cursor/mol/AGENTS.md +40 -0
- package/presets/cursor/mol/BUGBOT.md +14 -0
- package/presets/cursor/mol/MCP.md +50 -0
- package/presets/cursor/mol/README.md +18 -0
- package/presets/cursor/mol/REPO_AGENTS.md +107 -0
- package/presets/cursor/mol/agents/README.md +97 -0
- package/presets/cursor/mol/agents/accessibility-reviewer.md +74 -0
- package/presets/cursor/mol/agents/api-contract-reviewer.md +69 -0
- package/presets/cursor/mol/agents/build-verifier.md +99 -0
- package/presets/cursor/mol/agents/ci-investigator.md +75 -0
- package/presets/cursor/mol/agents/code-reviewer.md +120 -0
- package/presets/cursor/mol/agents/codebase-analyzer.md +33 -0
- package/presets/cursor/mol/agents/debugger.md +106 -0
- package/presets/cursor/mol/agents/feature-developer.md +131 -0
- package/presets/cursor/mol/agents/migration-specialist.md +79 -0
- package/presets/cursor/mol/agents/mockup-reviewer.md +113 -0
- package/presets/cursor/mol/agents/openspec-author.md +195 -0
- package/presets/cursor/mol/agents/performance-auditor.md +80 -0
- package/presets/cursor/mol/agents/playwright-test-generator.md +40 -0
- package/presets/cursor/mol/agents/playwright-test-healer.md +41 -0
- package/presets/cursor/mol/agents/playwright-test-planner.md +33 -0
- package/presets/cursor/mol/agents/qa-tester.md +64 -0
- package/presets/cursor/mol/agents/security-reviewer.md +71 -0
- package/presets/cursor/mol/agents/solution-architect.md +81 -0
- package/presets/cursor/mol/agents/task-analyst.md +237 -0
- package/presets/cursor/mol/agents/task-router.md +249 -0
- package/presets/cursor/mol/agents/tech-writer.md +70 -0
- package/presets/cursor/mol/agents/unit-test-generator.md +43 -0
- package/presets/cursor/mol/agents/unit-test-healer.md +44 -0
- package/presets/cursor/mol/agents/unit-test-planner.md +66 -0
- package/presets/cursor/mol/ai-local/conventions.md +49 -0
- package/presets/cursor/mol/ai-local/rules/task-levels.md +40 -0
- package/presets/cursor/mol/ai-local/rules-library/agent-artifacts-no-local-paths.md +71 -0
- package/presets/cursor/mol/ai-local/rules-library/agent-pipeline-gates.md +19 -0
- package/presets/cursor/mol/ai-local/rules-library/analytics-events.md +18 -0
- package/presets/cursor/mol/ai-local/rules-library/api-contract-source.md +14 -0
- package/presets/cursor/mol/ai-local/rules-library/artifact-lifecycle.md +17 -0
- package/presets/cursor/mol/ai-local/rules-library/code-style.md +68 -0
- package/presets/cursor/mol/ai-local/rules-library/commit-hygiene.md +17 -0
- package/presets/cursor/mol/ai-local/rules-library/component-child-decomposition.md +81 -0
- package/presets/cursor/mol/ai-local/rules-library/feature-flags-experiments.md +15 -0
- package/presets/cursor/mol/ai-local/rules-library/mcp-required-for-ui-layout.md +45 -0
- package/presets/cursor/mol/ai-local/rules-library/no-react-fc.md +46 -0
- package/presets/cursor/mol/ai-local/rules-library/no-test-driven-behavior-change.md +14 -0
- package/presets/cursor/mol/ai-local/rules-library/pre-pr-checklist.md +16 -0
- package/presets/cursor/mol/ai-local/rules-library/pwa-service-worker.md +15 -0
- package/presets/cursor/mol/ai-local/rules-library/qa-test-cases.md +14 -0
- package/presets/cursor/mol/ai-local/rules-library/router-pages.md +25 -0
- package/presets/cursor/mol/ai-local/rules-library/single-source-copy-constants.md +18 -0
- package/presets/cursor/mol/ai-local/rules-library/storybook-catalog-structure.md +62 -0
- package/presets/cursor/mol/ai-local/rules-library/storybook-cleanup-temp-screenshots.md +40 -0
- package/presets/cursor/mol/ai-local/rules-library/storybook-csf-authoring.md +100 -0
- package/presets/cursor/mol/ai-local/rules-library/storybook-dev-compare-figma.md +71 -0
- package/presets/cursor/mol/ai-local/rules-library/storybook-keep-tests-current.md +75 -0
- package/presets/cursor/mol/ai-local/rules-library/storybook-modals.md +64 -0
- package/presets/cursor/mol/ai-local/rules-library/storybook-no-app-node-modules.md +40 -0
- package/presets/cursor/mol/ai-local/rules-library/storybook-ui-quality-gate.md +38 -0
- package/presets/cursor/mol/ai-local/rules-library/ui-change-review-gate.md +15 -0
- package/presets/cursor/mol/commands/README.md +56 -0
- package/presets/cursor/mol/commands/migrate-tasks.md +41 -0
- package/presets/cursor/mol/commands/spec-start.md +29 -0
- package/presets/cursor/mol/commands/task-continue.md +72 -0
- package/presets/cursor/mol/commands/task-evil.md +88 -0
- package/presets/cursor/mol/commands/task.md +76 -0
- package/presets/cursor/mol/commands/technical-retro.md +93 -0
- package/presets/cursor/mol/commands/update.md +40 -0
- package/presets/cursor/mol/hooks/README.md +14 -0
- package/presets/cursor/mol/hooks/chain-team-phases.sh +2765 -0
- package/presets/cursor/mol/hooks/check-preset-update.mjs +232 -0
- package/presets/cursor/mol/hooks/examples/README.md +18 -0
- package/presets/cursor/mol/hooks/examples/format-edited.example.sh +11 -0
- package/presets/cursor/mol/hooks/examples/secret-guard.example.sh +10 -0
- package/presets/cursor/mol/hooks/examples/test-on-save.example.sh +8 -0
- package/presets/cursor/mol/hooks/guard-shell-command.sh +77 -0
- package/presets/cursor/mol/hooks/list-ai-local.mjs +299 -0
- package/presets/cursor/mol/hooks.json +27 -0
- package/presets/cursor/mol/mcp.json +19 -0
- package/presets/cursor/mol/rules/README.md +71 -0
- package/presets/cursor/mol/rules/agent-team-intake.mdc +19 -0
- package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +263 -0
- package/presets/cursor/mol/rules/ai-local-overlay.mdc +24 -0
- package/presets/cursor/mol/rules/anti-hallucination-contract.mdc +42 -0
- package/presets/cursor/mol/rules/anti-sycophancy-discipline.mdc +28 -0
- package/presets/cursor/mol/rules/code-quality-and-refactoring.mdc +81 -0
- package/presets/cursor/mol/rules/code-review-mr.mdc +100 -0
- package/presets/cursor/mol/rules/design-guidance.mdc +109 -0
- package/presets/cursor/mol/rules/feature-delivery-workflow.mdc +93 -0
- package/presets/cursor/mol/rules/interactive-questions.mdc +34 -0
- package/presets/cursor/mol/rules/language-policy.mdc +60 -0
- package/presets/cursor/mol/rules/mcp-usage.mdc +101 -0
- package/presets/cursor/mol/rules/mol-app-core.mdc +35 -0
- package/presets/cursor/mol/rules/mol-build.mdc +30 -0
- package/presets/cursor/mol/rules/mol-components.mdc +37 -0
- package/presets/cursor/mol/rules/mol-reactivity.mdc +27 -0
- package/presets/cursor/mol/rules/mol-state.mdc +31 -0
- package/presets/cursor/mol/rules/mol-testing.mdc +37 -0
- package/presets/cursor/mol/rules/mol-theming.mdc +31 -0
- package/presets/cursor/mol/rules/mol-view-tree.mdc +33 -0
- package/presets/cursor/mol/rules/package-manager.mdc +12 -0
- package/presets/cursor/mol/rules/preset-goals.mdc +40 -0
- package/presets/cursor/mol/rules/preset-layering.mdc +36 -0
- package/presets/cursor/mol/rules/preset-no-cross-stack-leakage.mdc +98 -0
- package/presets/cursor/mol/rules/preset-pr-checklist.mdc +54 -0
- package/presets/cursor/mol/rules/preset-token-budget.mdc +47 -0
- package/presets/cursor/mol/rules/preset-twin-sync.mdc +50 -0
- package/presets/cursor/mol/rules/preset-writing-style.mdc +51 -0
- package/presets/cursor/mol/rules/product-specs-authoring.mdc +125 -0
- package/presets/cursor/mol/rules/product-specs.mdc +68 -0
- package/presets/cursor/mol/rules/reference-features.mdc +45 -0
- package/presets/cursor/mol/rules/technical-retro.mdc +18 -0
- package/presets/cursor/mol/skills/README.md +17 -0
- package/presets/cursor/mol/skills/ci-investigation/SKILL.md +49 -0
- package/presets/cursor/mol/skills/code-review/SKILL.md +60 -0
- package/presets/cursor/mol/skills/debug-investigation/SKILL.md +63 -0
- package/presets/cursor/mol/skills/feature-delivery/SKILL.md +44 -0
- package/presets/cursor/mol/skills/spec-authoring/SKILL.md +31 -0
- package/presets/cursor/mol/skills/spec-discovery/SKILL.md +63 -0
- package/presets/cursor/mol/skills/technical-retro/SKILL.md +72 -0
- package/presets/cursor/mol/skills/unit-testing/SKILL.md +38 -0
- package/presets/cursor/mol/skills/write-adr/SKILL.md +46 -0
- package/presets/cursor/mol/team/README.md +135 -0
- package/presets/cursor/mol/team/fixtures/artifact-manifest.example.json +80 -0
- package/presets/cursor/mol/team/fixtures/bugfix-standard.json +25 -0
- package/presets/cursor/mol/team/fixtures/feature-full.json +29 -0
- package/presets/cursor/mol/team/fixtures/feature-light.json +28 -0
- package/presets/cursor/mol/team/fixtures/feature-parallel.json +84 -0
- package/presets/cursor/mol/team/fixtures/feature-ui-standard.json +24 -0
- package/presets/cursor/mol/team/fixtures/feature-with-figma-url.json +27 -0
- package/presets/cursor/mol/team/fixtures/feature-with-ux-no-figma.json +26 -0
- package/presets/cursor/mol/team/fixtures/memlog.example.md +9 -0
- package/presets/cursor/mol/team/fixtures/metrics-scenarios/tasks/human-gate/metrics.json +69 -0
- package/presets/cursor/mol/team/fixtures/metrics-scenarios/tasks/missing-ledger/status.json +5 -0
- package/presets/cursor/mol/team/fixtures/metrics-scenarios/tasks/parallel-receipts/metrics.json +79 -0
- package/presets/cursor/mol/team/fixtures/metrics-scenarios/tasks/serial-retry/metrics.json +124 -0
- package/presets/cursor/mol/team/fixtures/metrics-scenarios/tasks/validation-failed/metrics.json +124 -0
- package/presets/cursor/mol/team/fixtures/metrics.example.json +54 -0
- package/presets/cursor/mol/team/fixtures/mockup-review-fail-embedded-status.json +8 -0
- package/presets/cursor/mol/team/fixtures/mockup-review-standalone.json +23 -0
- package/presets/cursor/mol/team/fixtures/ux-design-standalone.json +24 -0
- package/presets/cursor/mol/team/tasks/.gitkeep +0 -0
- package/presets/cursor/next/MCP.md +7 -0
- package/presets/cursor/next/REPO_AGENTS.md +16 -9
- package/presets/cursor/next/agents/task-analyst.md +11 -0
- package/presets/cursor/next/agents/task-router.md +11 -0
- package/presets/cursor/next/commands/README.md +6 -0
- package/presets/cursor/next/commands/migrate-tasks.md +41 -0
- package/presets/cursor/next/commands/task-evil.md +88 -0
- package/presets/cursor/next/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/next/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/next/rules/preset-twin-sync.mdc +2 -2
- package/presets/cursor/next/team/README.md +14 -2
- package/presets/cursor/nuxt/REPO_AGENTS.md +15 -8
- package/presets/cursor/nuxt/commands/README.md +1 -0
- package/presets/cursor/nuxt/commands/migrate-tasks.md +41 -0
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/nuxt/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/nuxt/rules/preset-twin-sync.mdc +2 -2
- package/presets/cursor/nuxt/team/README.md +14 -2
- package/presets/cursor/php-hexagonal/REPO_AGENTS.md +15 -8
- package/presets/cursor/php-hexagonal/commands/README.md +1 -0
- package/presets/cursor/php-hexagonal/commands/migrate-tasks.md +41 -0
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/php-hexagonal/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/php-hexagonal/rules/preset-twin-sync.mdc +2 -2
- package/presets/cursor/php-hexagonal/team/README.md +14 -2
- package/presets/cursor/php-laravel/REPO_AGENTS.md +15 -8
- package/presets/cursor/php-laravel/commands/README.md +1 -0
- package/presets/cursor/php-laravel/commands/migrate-tasks.md +41 -0
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/php-laravel/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/php-laravel/rules/preset-twin-sync.mdc +2 -2
- package/presets/cursor/php-laravel/team/README.md +14 -2
- package/presets/cursor/svelte/REPO_AGENTS.md +15 -8
- package/presets/cursor/svelte/commands/README.md +1 -0
- package/presets/cursor/svelte/commands/migrate-tasks.md +41 -0
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/cursor/svelte/rules/preset-pr-checklist.mdc +1 -1
- package/presets/cursor/svelte/rules/preset-twin-sync.mdc +2 -2
- package/presets/cursor/svelte/team/README.md +14 -2
- package/presets/mavis/README.md +1 -1
- package/presets/mavis/android-kotlin/REPO_AGENTS.md +15 -8
- package/presets/mavis/android-kotlin/adapter-map.json +9 -1
- package/presets/mavis/android-kotlin/commands/README.md +1 -0
- package/presets/mavis/android-kotlin/commands/migrate-tasks.md +36 -0
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/android-kotlin/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/android-kotlin/rules/preset-twin-sync.md +2 -2
- package/presets/mavis/android-kotlin/team/README.md +14 -2
- package/presets/mavis/go/REPO_AGENTS.md +15 -8
- package/presets/mavis/go/adapter-map.json +9 -1
- package/presets/mavis/go/commands/README.md +1 -0
- package/presets/mavis/go/commands/migrate-tasks.md +36 -0
- package/presets/mavis/go/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/go/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/go/rules/preset-twin-sync.md +2 -2
- package/presets/mavis/go/team/README.md +14 -2
- package/presets/mavis/ios-swift/REPO_AGENTS.md +15 -8
- package/presets/mavis/ios-swift/adapter-map.json +9 -1
- package/presets/mavis/ios-swift/commands/README.md +1 -0
- package/presets/mavis/ios-swift/commands/migrate-tasks.md +36 -0
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/ios-swift/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/ios-swift/rules/preset-twin-sync.md +2 -2
- package/presets/mavis/ios-swift/team/README.md +14 -2
- package/presets/mavis/java/REPO_AGENTS.md +15 -8
- package/presets/mavis/java/adapter-map.json +9 -1
- package/presets/mavis/java/commands/README.md +1 -0
- package/presets/mavis/java/commands/migrate-tasks.md +36 -0
- package/presets/mavis/java/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/java/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/java/rules/preset-twin-sync.md +2 -2
- package/presets/mavis/java/team/README.md +14 -2
- package/presets/mavis/mcp-ts/REPO_AGENTS.md +15 -8
- package/presets/mavis/mcp-ts/adapter-map.json +9 -1
- package/presets/mavis/mcp-ts/commands/README.md +1 -0
- package/presets/mavis/mcp-ts/commands/migrate-tasks.md +36 -0
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/mcp-ts/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/mcp-ts/rules/preset-twin-sync.md +2 -2
- package/presets/mavis/mcp-ts/team/README.md +14 -2
- package/presets/mavis/mol/MAVIS.md +94 -0
- package/presets/mavis/mol/MCP.md +50 -0
- package/presets/mavis/mol/README.md +16 -0
- package/presets/mavis/mol/REPO_AGENTS.md +107 -0
- package/presets/mavis/mol/adapter-map.json +1122 -0
- package/presets/mavis/mol/agents/README.md +96 -0
- package/presets/mavis/mol/agents/accessibility-reviewer.md +85 -0
- package/presets/mavis/mol/agents/api-contract-reviewer.md +80 -0
- package/presets/mavis/mol/agents/build-verifier.md +110 -0
- package/presets/mavis/mol/agents/ci-investigator.md +90 -0
- package/presets/mavis/mol/agents/code-reviewer.md +132 -0
- package/presets/mavis/mol/agents/codebase-analyzer.md +44 -0
- package/presets/mavis/mol/agents/debugger.md +121 -0
- package/presets/mavis/mol/agents/feature-developer.md +146 -0
- package/presets/mavis/mol/agents/migration-specialist.md +90 -0
- package/presets/mavis/mol/agents/mockup-reviewer.md +124 -0
- package/presets/mavis/mol/agents/openspec-author.md +206 -0
- package/presets/mavis/mol/agents/performance-auditor.md +91 -0
- package/presets/mavis/mol/agents/playwright-test-generator.md +51 -0
- package/presets/mavis/mol/agents/playwright-test-healer.md +52 -0
- package/presets/mavis/mol/agents/playwright-test-planner.md +44 -0
- package/presets/mavis/mol/agents/qa-tester.md +75 -0
- package/presets/mavis/mol/agents/security-reviewer.md +82 -0
- package/presets/mavis/mol/agents/solution-architect.md +92 -0
- package/presets/mavis/mol/agents/task-analyst.md +248 -0
- package/presets/mavis/mol/agents/task-router.md +260 -0
- package/presets/mavis/mol/agents/tech-writer.md +81 -0
- package/presets/mavis/mol/agents/unit-test-generator.md +54 -0
- package/presets/mavis/mol/agents/unit-test-healer.md +55 -0
- package/presets/mavis/mol/agents/unit-test-planner.md +77 -0
- package/presets/mavis/mol/ai-local/conventions.md +49 -0
- package/presets/mavis/mol/ai-local/rules/task-levels.md +40 -0
- package/presets/mavis/mol/ai-local/rules-library/agent-artifacts-no-local-paths.md +71 -0
- package/presets/mavis/mol/ai-local/rules-library/agent-pipeline-gates.md +19 -0
- package/presets/mavis/mol/ai-local/rules-library/analytics-events.md +18 -0
- package/presets/mavis/mol/ai-local/rules-library/api-contract-source.md +14 -0
- package/presets/mavis/mol/ai-local/rules-library/artifact-lifecycle.md +17 -0
- package/presets/mavis/mol/ai-local/rules-library/code-style.md +68 -0
- package/presets/mavis/mol/ai-local/rules-library/commit-hygiene.md +17 -0
- package/presets/mavis/mol/ai-local/rules-library/component-child-decomposition.md +81 -0
- package/presets/mavis/mol/ai-local/rules-library/feature-flags-experiments.md +15 -0
- package/presets/mavis/mol/ai-local/rules-library/mcp-required-for-ui-layout.md +45 -0
- package/presets/mavis/mol/ai-local/rules-library/no-react-fc.md +46 -0
- package/presets/mavis/mol/ai-local/rules-library/no-test-driven-behavior-change.md +14 -0
- package/presets/mavis/mol/ai-local/rules-library/pre-pr-checklist.md +16 -0
- package/presets/mavis/mol/ai-local/rules-library/pwa-service-worker.md +15 -0
- package/presets/mavis/mol/ai-local/rules-library/qa-test-cases.md +14 -0
- package/presets/mavis/mol/ai-local/rules-library/router-pages.md +25 -0
- package/presets/mavis/mol/ai-local/rules-library/single-source-copy-constants.md +18 -0
- package/presets/mavis/mol/ai-local/rules-library/storybook-catalog-structure.md +62 -0
- package/presets/mavis/mol/ai-local/rules-library/storybook-cleanup-temp-screenshots.md +40 -0
- package/presets/mavis/mol/ai-local/rules-library/storybook-csf-authoring.md +100 -0
- package/presets/mavis/mol/ai-local/rules-library/storybook-dev-compare-figma.md +71 -0
- package/presets/mavis/mol/ai-local/rules-library/storybook-keep-tests-current.md +75 -0
- package/presets/mavis/mol/ai-local/rules-library/storybook-modals.md +64 -0
- package/presets/mavis/mol/ai-local/rules-library/storybook-no-app-node-modules.md +40 -0
- package/presets/mavis/mol/ai-local/rules-library/storybook-ui-quality-gate.md +38 -0
- package/presets/mavis/mol/ai-local/rules-library/ui-change-review-gate.md +15 -0
- package/presets/mavis/mol/commands/README.md +56 -0
- package/presets/mavis/mol/commands/migrate-tasks.md +36 -0
- package/presets/mavis/mol/commands/spec-start.md +24 -0
- package/presets/mavis/mol/commands/task-continue.md +67 -0
- package/presets/mavis/mol/commands/task-evil.md +82 -0
- package/presets/mavis/mol/commands/task.md +71 -0
- package/presets/mavis/mol/commands/technical-retro.md +88 -0
- package/presets/mavis/mol/commands/update.md +35 -0
- package/presets/mavis/mol/hooks/README.md +27 -0
- package/presets/mavis/mol/hooks/chain-team-phases.sh +2765 -0
- package/presets/mavis/mol/hooks/check-preset-update.mjs +232 -0
- package/presets/mavis/mol/hooks/list-ai-local.mjs +299 -0
- package/presets/mavis/mol/mcp.json +19 -0
- package/presets/mavis/mol/rules/README.md +16 -0
- package/presets/mavis/mol/rules/agent-team-intake.md +14 -0
- package/presets/mavis/mol/rules/agent-team-orchestrator.md +282 -0
- package/presets/mavis/mol/rules/ai-local-overlay.md +18 -0
- package/presets/mavis/mol/rules/anti-hallucination-contract.md +37 -0
- package/presets/mavis/mol/rules/anti-sycophancy-discipline.md +23 -0
- package/presets/mavis/mol/rules/code-quality-and-refactoring.md +76 -0
- package/presets/mavis/mol/rules/code-review-mr.md +95 -0
- package/presets/mavis/mol/rules/design-guidance.md +104 -0
- package/presets/mavis/mol/rules/feature-delivery-workflow.md +144 -0
- package/presets/mavis/mol/rules/interactive-questions.md +29 -0
- package/presets/mavis/mol/rules/language-policy.md +51 -0
- package/presets/mavis/mol/rules/mcp-usage.md +96 -0
- package/presets/mavis/mol/rules/mol-app-core.md +29 -0
- package/presets/mavis/mol/rules/mol-build.md +19 -0
- package/presets/mavis/mol/rules/mol-components.md +31 -0
- package/presets/mavis/mol/rules/mol-reactivity.md +21 -0
- package/presets/mavis/mol/rules/mol-state.md +22 -0
- package/presets/mavis/mol/rules/mol-testing.md +28 -0
- package/presets/mavis/mol/rules/mol-theming.md +22 -0
- package/presets/mavis/mol/rules/mol-view-tree.md +27 -0
- package/presets/mavis/mol/rules/package-manager.md +7 -0
- package/presets/mavis/mol/rules/preset-goals.md +31 -0
- package/presets/mavis/mol/rules/preset-layering.md +27 -0
- package/presets/mavis/mol/rules/preset-no-cross-stack-leakage.md +89 -0
- package/presets/mavis/mol/rules/preset-pr-checklist.md +45 -0
- package/presets/mavis/mol/rules/preset-token-budget.md +38 -0
- package/presets/mavis/mol/rules/preset-twin-sync.md +41 -0
- package/presets/mavis/mol/rules/preset-writing-style.md +42 -0
- package/presets/mavis/mol/rules/product-specs-authoring.md +118 -0
- package/presets/mavis/mol/rules/product-specs.md +61 -0
- package/presets/mavis/mol/rules/reference-features.md +82 -0
- package/presets/mavis/mol/rules/technical-retro.md +13 -0
- package/presets/mavis/mol/skills/README.md +17 -0
- package/presets/mavis/mol/skills/ci-investigation/SKILL.md +44 -0
- package/presets/mavis/mol/skills/code-review/SKILL.md +55 -0
- package/presets/mavis/mol/skills/debug-investigation/SKILL.md +58 -0
- package/presets/mavis/mol/skills/feature-delivery/SKILL.md +39 -0
- package/presets/mavis/mol/skills/spec-authoring/SKILL.md +26 -0
- package/presets/mavis/mol/skills/spec-discovery/SKILL.md +58 -0
- package/presets/mavis/mol/skills/technical-retro/SKILL.md +67 -0
- package/presets/mavis/mol/skills/unit-testing/SKILL.md +33 -0
- package/presets/mavis/mol/skills/write-adr/SKILL.md +41 -0
- package/presets/mavis/mol/team/README.md +135 -0
- package/presets/mavis/mol/team/fixtures/artifact-manifest.example.json +80 -0
- package/presets/mavis/mol/team/fixtures/bugfix-standard.json +25 -0
- package/presets/mavis/mol/team/fixtures/feature-full.json +29 -0
- package/presets/mavis/mol/team/fixtures/feature-light.json +28 -0
- package/presets/mavis/mol/team/fixtures/feature-parallel.json +84 -0
- package/presets/mavis/mol/team/fixtures/feature-ui-standard.json +24 -0
- package/presets/mavis/mol/team/fixtures/feature-with-figma-url.json +27 -0
- package/presets/mavis/mol/team/fixtures/feature-with-ux-no-figma.json +26 -0
- package/presets/mavis/mol/team/fixtures/memlog.example.md +9 -0
- package/presets/mavis/mol/team/fixtures/metrics-scenarios/tasks/human-gate/metrics.json +69 -0
- package/presets/mavis/mol/team/fixtures/metrics-scenarios/tasks/missing-ledger/status.json +5 -0
- package/presets/mavis/mol/team/fixtures/metrics-scenarios/tasks/parallel-receipts/metrics.json +79 -0
- package/presets/mavis/mol/team/fixtures/metrics-scenarios/tasks/serial-retry/metrics.json +124 -0
- package/presets/mavis/mol/team/fixtures/metrics-scenarios/tasks/validation-failed/metrics.json +124 -0
- package/presets/mavis/mol/team/fixtures/metrics.example.json +54 -0
- package/presets/mavis/mol/team/fixtures/mockup-review-fail-embedded-status.json +8 -0
- package/presets/mavis/mol/team/fixtures/mockup-review-standalone.json +23 -0
- package/presets/mavis/mol/team/fixtures/ux-design-standalone.json +24 -0
- package/presets/mavis/mol/team/tasks/.gitkeep +0 -0
- package/presets/mavis/next/MCP.md +7 -0
- package/presets/mavis/next/REPO_AGENTS.md +16 -9
- package/presets/mavis/next/adapter-map.json +18 -1
- package/presets/mavis/next/agents/task-analyst.md +11 -0
- package/presets/mavis/next/agents/task-router.md +11 -0
- package/presets/mavis/next/commands/README.md +6 -0
- package/presets/mavis/next/commands/migrate-tasks.md +36 -0
- package/presets/mavis/next/commands/task-evil.md +82 -0
- package/presets/mavis/next/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/next/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/next/rules/preset-twin-sync.md +2 -2
- package/presets/mavis/next/team/README.md +14 -2
- package/presets/mavis/nuxt/REPO_AGENTS.md +15 -8
- package/presets/mavis/nuxt/adapter-map.json +9 -1
- package/presets/mavis/nuxt/commands/README.md +1 -0
- package/presets/mavis/nuxt/commands/migrate-tasks.md +36 -0
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/nuxt/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/nuxt/rules/preset-twin-sync.md +2 -2
- package/presets/mavis/nuxt/team/README.md +14 -2
- package/presets/mavis/php-hexagonal/REPO_AGENTS.md +15 -8
- package/presets/mavis/php-hexagonal/adapter-map.json +9 -1
- package/presets/mavis/php-hexagonal/commands/README.md +1 -0
- package/presets/mavis/php-hexagonal/commands/migrate-tasks.md +36 -0
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/php-hexagonal/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/php-hexagonal/rules/preset-twin-sync.md +2 -2
- package/presets/mavis/php-hexagonal/team/README.md +14 -2
- package/presets/mavis/php-laravel/REPO_AGENTS.md +15 -8
- package/presets/mavis/php-laravel/adapter-map.json +9 -1
- package/presets/mavis/php-laravel/commands/README.md +1 -0
- package/presets/mavis/php-laravel/commands/migrate-tasks.md +36 -0
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/php-laravel/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/php-laravel/rules/preset-twin-sync.md +2 -2
- package/presets/mavis/php-laravel/team/README.md +14 -2
- package/presets/mavis/platform-contract.json +2 -1
- package/presets/mavis/svelte/REPO_AGENTS.md +15 -8
- package/presets/mavis/svelte/adapter-map.json +9 -1
- package/presets/mavis/svelte/commands/README.md +1 -0
- package/presets/mavis/svelte/commands/migrate-tasks.md +36 -0
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/mavis/svelte/rules/preset-pr-checklist.md +1 -1
- package/presets/mavis/svelte/rules/preset-twin-sync.md +2 -2
- package/presets/mavis/svelte/team/README.md +14 -2
- package/presets/opencode/android-kotlin/REPO_AGENTS.md +15 -8
- package/presets/opencode/android-kotlin/adapter-map.json +9 -1
- package/presets/opencode/android-kotlin/commands/README.md +1 -0
- package/presets/opencode/android-kotlin/commands/migrate-tasks.md +44 -0
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/android-kotlin/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/android-kotlin/rules/preset-twin-sync.md +2 -2
- package/presets/opencode/android-kotlin/team/README.md +14 -2
- package/presets/opencode/go/REPO_AGENTS.md +15 -8
- package/presets/opencode/go/adapter-map.json +9 -1
- package/presets/opencode/go/commands/README.md +1 -0
- package/presets/opencode/go/commands/migrate-tasks.md +44 -0
- package/presets/opencode/go/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/go/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/go/rules/preset-twin-sync.md +2 -2
- package/presets/opencode/go/team/README.md +14 -2
- package/presets/opencode/ios-swift/REPO_AGENTS.md +15 -8
- package/presets/opencode/ios-swift/adapter-map.json +9 -1
- package/presets/opencode/ios-swift/commands/README.md +1 -0
- package/presets/opencode/ios-swift/commands/migrate-tasks.md +44 -0
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/ios-swift/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/ios-swift/rules/preset-twin-sync.md +2 -2
- package/presets/opencode/ios-swift/team/README.md +14 -2
- package/presets/opencode/java/REPO_AGENTS.md +15 -8
- package/presets/opencode/java/adapter-map.json +9 -1
- package/presets/opencode/java/commands/README.md +1 -0
- package/presets/opencode/java/commands/migrate-tasks.md +44 -0
- package/presets/opencode/java/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/java/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/java/rules/preset-twin-sync.md +2 -2
- package/presets/opencode/java/team/README.md +14 -2
- package/presets/opencode/mcp-ts/REPO_AGENTS.md +15 -8
- package/presets/opencode/mcp-ts/adapter-map.json +9 -1
- package/presets/opencode/mcp-ts/commands/README.md +1 -0
- package/presets/opencode/mcp-ts/commands/migrate-tasks.md +44 -0
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/mcp-ts/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/mcp-ts/rules/preset-twin-sync.md +2 -2
- package/presets/opencode/mcp-ts/team/README.md +14 -2
- package/presets/opencode/mol/MCP.md +50 -0
- package/presets/opencode/mol/OPENCODE.md +99 -0
- package/presets/opencode/mol/README.md +17 -0
- package/presets/opencode/mol/REPO_AGENTS.md +107 -0
- package/presets/opencode/mol/adapter-map.json +1122 -0
- package/presets/opencode/mol/agents/README.md +97 -0
- package/presets/opencode/mol/agents/accessibility-reviewer.md +97 -0
- package/presets/opencode/mol/agents/api-contract-reviewer.md +92 -0
- package/presets/opencode/mol/agents/build-verifier.md +122 -0
- package/presets/opencode/mol/agents/ci-investigator.md +98 -0
- package/presets/opencode/mol/agents/code-reviewer.md +144 -0
- package/presets/opencode/mol/agents/codebase-analyzer.md +56 -0
- package/presets/opencode/mol/agents/debugger.md +129 -0
- package/presets/opencode/mol/agents/feature-developer.md +154 -0
- package/presets/opencode/mol/agents/migration-specialist.md +102 -0
- package/presets/opencode/mol/agents/mockup-reviewer.md +136 -0
- package/presets/opencode/mol/agents/openspec-author.md +219 -0
- package/presets/opencode/mol/agents/performance-auditor.md +103 -0
- package/presets/opencode/mol/agents/playwright-test-generator.md +59 -0
- package/presets/opencode/mol/agents/playwright-test-healer.md +60 -0
- package/presets/opencode/mol/agents/playwright-test-planner.md +56 -0
- package/presets/opencode/mol/agents/qa-tester.md +83 -0
- package/presets/opencode/mol/agents/security-reviewer.md +94 -0
- package/presets/opencode/mol/agents/solution-architect.md +104 -0
- package/presets/opencode/mol/agents/task-analyst.md +260 -0
- package/presets/opencode/mol/agents/task-router.md +272 -0
- package/presets/opencode/mol/agents/tech-writer.md +99 -0
- package/presets/opencode/mol/agents/unit-test-generator.md +62 -0
- package/presets/opencode/mol/agents/unit-test-healer.md +63 -0
- package/presets/opencode/mol/agents/unit-test-planner.md +89 -0
- package/presets/opencode/mol/ai-local/conventions.md +49 -0
- package/presets/opencode/mol/ai-local/rules/task-levels.md +40 -0
- package/presets/opencode/mol/ai-local/rules-library/agent-artifacts-no-local-paths.md +71 -0
- package/presets/opencode/mol/ai-local/rules-library/agent-pipeline-gates.md +19 -0
- package/presets/opencode/mol/ai-local/rules-library/analytics-events.md +18 -0
- package/presets/opencode/mol/ai-local/rules-library/api-contract-source.md +14 -0
- package/presets/opencode/mol/ai-local/rules-library/artifact-lifecycle.md +17 -0
- package/presets/opencode/mol/ai-local/rules-library/code-style.md +68 -0
- package/presets/opencode/mol/ai-local/rules-library/commit-hygiene.md +17 -0
- package/presets/opencode/mol/ai-local/rules-library/component-child-decomposition.md +81 -0
- package/presets/opencode/mol/ai-local/rules-library/feature-flags-experiments.md +15 -0
- package/presets/opencode/mol/ai-local/rules-library/mcp-required-for-ui-layout.md +45 -0
- package/presets/opencode/mol/ai-local/rules-library/no-react-fc.md +46 -0
- package/presets/opencode/mol/ai-local/rules-library/no-test-driven-behavior-change.md +14 -0
- package/presets/opencode/mol/ai-local/rules-library/pre-pr-checklist.md +16 -0
- package/presets/opencode/mol/ai-local/rules-library/pwa-service-worker.md +15 -0
- package/presets/opencode/mol/ai-local/rules-library/qa-test-cases.md +14 -0
- package/presets/opencode/mol/ai-local/rules-library/router-pages.md +25 -0
- package/presets/opencode/mol/ai-local/rules-library/single-source-copy-constants.md +18 -0
- package/presets/opencode/mol/ai-local/rules-library/storybook-catalog-structure.md +62 -0
- package/presets/opencode/mol/ai-local/rules-library/storybook-cleanup-temp-screenshots.md +40 -0
- package/presets/opencode/mol/ai-local/rules-library/storybook-csf-authoring.md +100 -0
- package/presets/opencode/mol/ai-local/rules-library/storybook-dev-compare-figma.md +71 -0
- package/presets/opencode/mol/ai-local/rules-library/storybook-keep-tests-current.md +75 -0
- package/presets/opencode/mol/ai-local/rules-library/storybook-modals.md +64 -0
- package/presets/opencode/mol/ai-local/rules-library/storybook-no-app-node-modules.md +40 -0
- package/presets/opencode/mol/ai-local/rules-library/storybook-ui-quality-gate.md +38 -0
- package/presets/opencode/mol/ai-local/rules-library/ui-change-review-gate.md +15 -0
- package/presets/opencode/mol/commands/README.md +56 -0
- package/presets/opencode/mol/commands/migrate-tasks.md +44 -0
- package/presets/opencode/mol/commands/spec-start.md +32 -0
- package/presets/opencode/mol/commands/task-continue.md +75 -0
- package/presets/opencode/mol/commands/task-evil.md +91 -0
- package/presets/opencode/mol/commands/task.md +79 -0
- package/presets/opencode/mol/commands/technical-retro.md +96 -0
- package/presets/opencode/mol/commands/update.md +43 -0
- package/presets/opencode/mol/hooks/README.md +27 -0
- package/presets/opencode/mol/hooks/chain-team-phases.sh +2765 -0
- package/presets/opencode/mol/hooks/check-preset-update.mjs +232 -0
- package/presets/opencode/mol/hooks/list-ai-local.mjs +299 -0
- package/presets/opencode/mol/opencode.json +78 -0
- package/presets/opencode/mol/rules/README.md +25 -0
- package/presets/opencode/mol/rules/agent-team-intake.md +14 -0
- package/presets/opencode/mol/rules/agent-team-orchestrator.md +282 -0
- package/presets/opencode/mol/rules/ai-local-overlay.md +18 -0
- package/presets/opencode/mol/rules/anti-hallucination-contract.md +37 -0
- package/presets/opencode/mol/rules/anti-sycophancy-discipline.md +23 -0
- package/presets/opencode/mol/rules/code-quality-and-refactoring.md +76 -0
- package/presets/opencode/mol/rules/code-review-mr.md +95 -0
- package/presets/opencode/mol/rules/design-guidance.md +104 -0
- package/presets/opencode/mol/rules/feature-delivery-workflow.md +144 -0
- package/presets/opencode/mol/rules/interactive-questions.md +29 -0
- package/presets/opencode/mol/rules/language-policy.md +51 -0
- package/presets/opencode/mol/rules/mcp-usage.md +96 -0
- package/presets/opencode/mol/rules/mol-app-core.md +29 -0
- package/presets/opencode/mol/rules/mol-build.md +19 -0
- package/presets/opencode/mol/rules/mol-components.md +31 -0
- package/presets/opencode/mol/rules/mol-reactivity.md +21 -0
- package/presets/opencode/mol/rules/mol-state.md +22 -0
- package/presets/opencode/mol/rules/mol-testing.md +28 -0
- package/presets/opencode/mol/rules/mol-theming.md +22 -0
- package/presets/opencode/mol/rules/mol-view-tree.md +27 -0
- package/presets/opencode/mol/rules/package-manager.md +7 -0
- package/presets/opencode/mol/rules/preset-goals.md +31 -0
- package/presets/opencode/mol/rules/preset-layering.md +27 -0
- package/presets/opencode/mol/rules/preset-no-cross-stack-leakage.md +89 -0
- package/presets/opencode/mol/rules/preset-pr-checklist.md +45 -0
- package/presets/opencode/mol/rules/preset-token-budget.md +38 -0
- package/presets/opencode/mol/rules/preset-twin-sync.md +41 -0
- package/presets/opencode/mol/rules/preset-writing-style.md +42 -0
- package/presets/opencode/mol/rules/product-specs-authoring.md +118 -0
- package/presets/opencode/mol/rules/product-specs.md +61 -0
- package/presets/opencode/mol/rules/reference-features.md +82 -0
- package/presets/opencode/mol/rules/technical-retro.md +13 -0
- package/presets/opencode/mol/skills/README.md +17 -0
- package/presets/opencode/mol/skills/ci-investigation/SKILL.md +49 -0
- package/presets/opencode/mol/skills/code-review/SKILL.md +60 -0
- package/presets/opencode/mol/skills/debug-investigation/SKILL.md +63 -0
- package/presets/opencode/mol/skills/feature-delivery/SKILL.md +44 -0
- package/presets/opencode/mol/skills/spec-authoring/SKILL.md +31 -0
- package/presets/opencode/mol/skills/spec-discovery/SKILL.md +63 -0
- package/presets/opencode/mol/skills/technical-retro/SKILL.md +72 -0
- package/presets/opencode/mol/skills/unit-testing/SKILL.md +38 -0
- package/presets/opencode/mol/skills/write-adr/SKILL.md +46 -0
- package/presets/opencode/mol/team/README.md +135 -0
- package/presets/opencode/mol/team/fixtures/artifact-manifest.example.json +80 -0
- package/presets/opencode/mol/team/fixtures/bugfix-standard.json +25 -0
- package/presets/opencode/mol/team/fixtures/feature-full.json +29 -0
- package/presets/opencode/mol/team/fixtures/feature-light.json +28 -0
- package/presets/opencode/mol/team/fixtures/feature-parallel.json +84 -0
- package/presets/opencode/mol/team/fixtures/feature-ui-standard.json +24 -0
- package/presets/opencode/mol/team/fixtures/feature-with-figma-url.json +27 -0
- package/presets/opencode/mol/team/fixtures/feature-with-ux-no-figma.json +26 -0
- package/presets/opencode/mol/team/fixtures/memlog.example.md +9 -0
- package/presets/opencode/mol/team/fixtures/metrics-scenarios/tasks/human-gate/metrics.json +69 -0
- package/presets/opencode/mol/team/fixtures/metrics-scenarios/tasks/missing-ledger/status.json +5 -0
- package/presets/opencode/mol/team/fixtures/metrics-scenarios/tasks/parallel-receipts/metrics.json +79 -0
- package/presets/opencode/mol/team/fixtures/metrics-scenarios/tasks/serial-retry/metrics.json +124 -0
- package/presets/opencode/mol/team/fixtures/metrics-scenarios/tasks/validation-failed/metrics.json +124 -0
- package/presets/opencode/mol/team/fixtures/metrics.example.json +54 -0
- package/presets/opencode/mol/team/fixtures/mockup-review-fail-embedded-status.json +8 -0
- package/presets/opencode/mol/team/fixtures/mockup-review-standalone.json +23 -0
- package/presets/opencode/mol/team/fixtures/ux-design-standalone.json +24 -0
- package/presets/opencode/mol/team/tasks/.gitkeep +0 -0
- package/presets/opencode/next/MCP.md +7 -0
- package/presets/opencode/next/REPO_AGENTS.md +16 -9
- package/presets/opencode/next/adapter-map.json +18 -1
- package/presets/opencode/next/agents/task-analyst.md +11 -0
- package/presets/opencode/next/agents/task-router.md +11 -0
- package/presets/opencode/next/commands/README.md +6 -0
- package/presets/opencode/next/commands/migrate-tasks.md +44 -0
- package/presets/opencode/next/commands/task-evil.md +91 -0
- package/presets/opencode/next/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/next/opencode.json +26 -4
- package/presets/opencode/next/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/next/rules/preset-twin-sync.md +2 -2
- package/presets/opencode/next/team/README.md +14 -2
- package/presets/opencode/nuxt/REPO_AGENTS.md +15 -8
- package/presets/opencode/nuxt/adapter-map.json +9 -1
- package/presets/opencode/nuxt/commands/README.md +1 -0
- package/presets/opencode/nuxt/commands/migrate-tasks.md +44 -0
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/nuxt/opencode.json +4 -4
- package/presets/opencode/nuxt/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/nuxt/rules/preset-twin-sync.md +2 -2
- package/presets/opencode/nuxt/team/README.md +14 -2
- package/presets/opencode/php-hexagonal/REPO_AGENTS.md +15 -8
- package/presets/opencode/php-hexagonal/adapter-map.json +9 -1
- package/presets/opencode/php-hexagonal/commands/README.md +1 -0
- package/presets/opencode/php-hexagonal/commands/migrate-tasks.md +44 -0
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/php-hexagonal/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/php-hexagonal/rules/preset-twin-sync.md +2 -2
- package/presets/opencode/php-hexagonal/team/README.md +14 -2
- package/presets/opencode/php-laravel/REPO_AGENTS.md +15 -8
- package/presets/opencode/php-laravel/adapter-map.json +9 -1
- package/presets/opencode/php-laravel/commands/README.md +1 -0
- package/presets/opencode/php-laravel/commands/migrate-tasks.md +44 -0
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/php-laravel/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/php-laravel/rules/preset-twin-sync.md +2 -2
- package/presets/opencode/php-laravel/team/README.md +14 -2
- package/presets/opencode/platform-contract.json +2 -1
- package/presets/opencode/svelte/REPO_AGENTS.md +15 -8
- package/presets/opencode/svelte/adapter-map.json +9 -1
- package/presets/opencode/svelte/commands/README.md +1 -0
- package/presets/opencode/svelte/commands/migrate-tasks.md +44 -0
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +109 -0
- package/presets/opencode/svelte/opencode.json +4 -4
- package/presets/opencode/svelte/rules/preset-pr-checklist.md +1 -1
- package/presets/opencode/svelte/rules/preset-twin-sync.md +2 -2
- package/presets/opencode/svelte/team/README.md +14 -2
- package/presets/zcode/README.md +17 -0
- package/presets/zcode/android-kotlin/MCP.md +35 -0
- package/presets/zcode/android-kotlin/README.md +20 -0
- package/presets/zcode/android-kotlin/REPO_AGENTS.md +100 -0
- package/presets/zcode/android-kotlin/adapter-map.json +925 -0
- package/presets/zcode/android-kotlin/agents/README.md +68 -0
- package/presets/zcode/android-kotlin/agents/accessibility-reviewer.md +87 -0
- package/presets/zcode/android-kotlin/agents/api-contract-reviewer.md +92 -0
- package/presets/zcode/android-kotlin/agents/build-verifier.md +87 -0
- package/presets/zcode/android-kotlin/agents/ci-investigator.md +114 -0
- package/presets/zcode/android-kotlin/agents/code-reviewer.md +133 -0
- package/presets/zcode/android-kotlin/agents/codebase-analyzer.md +49 -0
- package/presets/zcode/android-kotlin/agents/debugger.md +136 -0
- package/presets/zcode/android-kotlin/agents/feature-developer.md +154 -0
- package/presets/zcode/android-kotlin/agents/instrumentation-test-generator.md +43 -0
- package/presets/zcode/android-kotlin/agents/instrumentation-test-healer.md +43 -0
- package/presets/zcode/android-kotlin/agents/instrumentation-test-planner.md +45 -0
- package/presets/zcode/android-kotlin/agents/migration-specialist.md +101 -0
- package/presets/zcode/android-kotlin/agents/mockup-reviewer.md +81 -0
- package/presets/zcode/android-kotlin/agents/openspec-author.md +185 -0
- package/presets/zcode/android-kotlin/agents/performance-auditor.md +94 -0
- package/presets/zcode/android-kotlin/agents/qa-tester.md +91 -0
- package/presets/zcode/android-kotlin/agents/security-reviewer.md +86 -0
- package/presets/zcode/android-kotlin/agents/solution-architect.md +48 -0
- package/presets/zcode/android-kotlin/agents/task-analyst.md +152 -0
- package/presets/zcode/android-kotlin/agents/task-router.md +190 -0
- package/presets/zcode/android-kotlin/agents/tech-writer.md +91 -0
- package/presets/zcode/android-kotlin/agents/unit-test-generator.md +77 -0
- package/presets/zcode/android-kotlin/agents/unit-test-healer.md +76 -0
- package/presets/zcode/android-kotlin/agents/unit-test-planner.md +89 -0
- package/presets/zcode/android-kotlin/ai-local/conventions.md +25 -0
- package/presets/zcode/android-kotlin/commands/README.md +51 -0
- package/presets/zcode/android-kotlin/commands/migrate-tasks.md +44 -0
- package/presets/zcode/android-kotlin/commands/spec-start.md +32 -0
- package/presets/zcode/android-kotlin/commands/task-continue.md +75 -0
- package/presets/zcode/android-kotlin/commands/task.md +76 -0
- package/presets/zcode/android-kotlin/commands/technical-retro.md +96 -0
- package/presets/zcode/android-kotlin/commands/update.md +43 -0
- package/presets/zcode/android-kotlin/hooks/README.md +31 -0
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +2768 -0
- package/presets/zcode/android-kotlin/hooks/check-preset-update.mjs +232 -0
- package/presets/zcode/android-kotlin/hooks/list-ai-local.mjs +299 -0
- package/presets/zcode/android-kotlin/mcp.json +11 -0
- package/presets/zcode/android-kotlin/rules/README.md +25 -0
- package/presets/zcode/android-kotlin/rules/agent-team-intake.md +14 -0
- package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +282 -0
- package/presets/zcode/android-kotlin/rules/ai-local-overlay.md +18 -0
- package/presets/zcode/android-kotlin/rules/android-app-core.md +27 -0
- package/presets/zcode/android-kotlin/rules/anti-hallucination-contract.md +37 -0
- package/presets/zcode/android-kotlin/rules/anti-sycophancy-discipline.md +23 -0
- package/presets/zcode/android-kotlin/rules/architecture-boundaries.md +23 -0
- package/presets/zcode/android-kotlin/rules/code-quality-and-refactoring.md +77 -0
- package/presets/zcode/android-kotlin/rules/code-review-mr.md +109 -0
- package/presets/zcode/android-kotlin/rules/compose-ui.md +25 -0
- package/presets/zcode/android-kotlin/rules/design-guidance.md +104 -0
- package/presets/zcode/android-kotlin/rules/di-dagger-feature-holders.md +26 -0
- package/presets/zcode/android-kotlin/rules/feature-delivery-workflow.md +43 -0
- package/presets/zcode/android-kotlin/rules/gradle-tooling.md +22 -0
- package/presets/zcode/android-kotlin/rules/interactive-questions.md +29 -0
- package/presets/zcode/android-kotlin/rules/kotlin-anti-hallucination.md +27 -0
- package/presets/zcode/android-kotlin/rules/kotlin-conventions.md +24 -0
- package/presets/zcode/android-kotlin/rules/language-policy.md +51 -0
- package/presets/zcode/android-kotlin/rules/mcp-usage.md +94 -0
- package/presets/zcode/android-kotlin/rules/mockup-review.md +171 -0
- package/presets/zcode/android-kotlin/rules/module-public-api.md +22 -0
- package/presets/zcode/android-kotlin/rules/navigation-feature-launcher.md +23 -0
- package/presets/zcode/android-kotlin/rules/networking-data.md +23 -0
- package/presets/zcode/android-kotlin/rules/persistence-data.md +22 -0
- package/presets/zcode/android-kotlin/rules/post-change-build.md +25 -0
- package/presets/zcode/android-kotlin/rules/preset-goals.md +31 -0
- package/presets/zcode/android-kotlin/rules/preset-layering.md +27 -0
- package/presets/zcode/android-kotlin/rules/preset-no-cross-stack-leakage.md +93 -0
- package/presets/zcode/android-kotlin/rules/preset-pr-checklist.md +45 -0
- package/presets/zcode/android-kotlin/rules/preset-token-budget.md +38 -0
- package/presets/zcode/android-kotlin/rules/preset-twin-sync.md +41 -0
- package/presets/zcode/android-kotlin/rules/preset-writing-style.md +42 -0
- package/presets/zcode/android-kotlin/rules/product-specs-authoring.md +118 -0
- package/presets/zcode/android-kotlin/rules/product-specs.md +61 -0
- package/presets/zcode/android-kotlin/rules/reference-features.md +22 -0
- package/presets/zcode/android-kotlin/rules/security-android.md +21 -0
- package/presets/zcode/android-kotlin/rules/state-and-viewmodels.md +21 -0
- package/presets/zcode/android-kotlin/rules/technical-retro.md +13 -0
- package/presets/zcode/android-kotlin/rules/tests-ui.md +22 -0
- package/presets/zcode/android-kotlin/rules/tests-unit.md +22 -0
- package/presets/zcode/android-kotlin/rules/ux-design.md +103 -0
- package/presets/zcode/android-kotlin/skills/README.md +18 -0
- package/presets/zcode/android-kotlin/skills/ci-investigation/SKILL.md +53 -0
- package/presets/zcode/android-kotlin/skills/code-review/SKILL.md +61 -0
- package/presets/zcode/android-kotlin/skills/debug-investigation/SKILL.md +72 -0
- package/presets/zcode/android-kotlin/skills/feature-delivery/SKILL.md +51 -0
- package/presets/zcode/android-kotlin/skills/instrumentation-ui-e2e/SKILL.md +23 -0
- package/presets/zcode/android-kotlin/skills/mockup-review/SKILL.md +34 -0
- package/presets/zcode/android-kotlin/skills/spec-authoring/SKILL.md +31 -0
- package/presets/zcode/android-kotlin/skills/spec-discovery/SKILL.md +63 -0
- package/presets/zcode/android-kotlin/skills/technical-retro/SKILL.md +72 -0
- package/presets/zcode/android-kotlin/skills/unit-testing/SKILL.md +38 -0
- package/presets/zcode/android-kotlin/skills/ux-design/SKILL.md +41 -0
- package/presets/zcode/android-kotlin/skills/write-adr/SKILL.md +46 -0
- package/presets/zcode/android-kotlin/team/README.md +123 -0
- package/presets/zcode/android-kotlin/team/fixtures/artifact-manifest.example.json +26 -0
- package/presets/zcode/android-kotlin/team/fixtures/bugfix-standard.json +47 -0
- package/presets/zcode/android-kotlin/team/fixtures/feature-full.json +98 -0
- package/presets/zcode/android-kotlin/team/fixtures/feature-light.json +38 -0
- package/presets/zcode/android-kotlin/team/fixtures/feature-with-figma-url.json +17 -0
- package/presets/zcode/android-kotlin/team/fixtures/feature-with-ux-no-figma.json +17 -0
- package/presets/zcode/android-kotlin/team/fixtures/memlog.example.md +9 -0
- package/presets/zcode/android-kotlin/team/fixtures/mockup-review-fail-embedded-status.json +8 -0
- package/presets/zcode/android-kotlin/team/fixtures/mockup-review-standalone.json +14 -0
- package/presets/zcode/android-kotlin/team/fixtures/ux-design-standalone.json +15 -0
- package/presets/zcode/go/MCP.md +37 -0
- package/presets/zcode/go/README.md +20 -0
- package/presets/zcode/go/REPO_AGENTS.md +100 -0
- package/presets/zcode/go/adapter-map.json +864 -0
- package/presets/zcode/go/agents/README.md +55 -0
- package/presets/zcode/go/agents/api-contract-reviewer.md +47 -0
- package/presets/zcode/go/agents/build-verifier.md +72 -0
- package/presets/zcode/go/agents/ci-investigator.md +66 -0
- package/presets/zcode/go/agents/code-reviewer.md +128 -0
- package/presets/zcode/go/agents/codebase-analyzer.md +49 -0
- package/presets/zcode/go/agents/debugger.md +98 -0
- package/presets/zcode/go/agents/feature-developer.md +144 -0
- package/presets/zcode/go/agents/integration-test-generator.md +46 -0
- package/presets/zcode/go/agents/integration-test-healer.md +46 -0
- package/presets/zcode/go/agents/integration-test-planner.md +48 -0
- package/presets/zcode/go/agents/migration-specialist.md +59 -0
- package/presets/zcode/go/agents/openspec-author.md +185 -0
- package/presets/zcode/go/agents/performance-auditor.md +50 -0
- package/presets/zcode/go/agents/qa-tester.md +53 -0
- package/presets/zcode/go/agents/security-reviewer.md +42 -0
- package/presets/zcode/go/agents/solution-architect.md +56 -0
- package/presets/zcode/go/agents/task-analyst.md +131 -0
- package/presets/zcode/go/agents/task-router.md +179 -0
- package/presets/zcode/go/agents/tech-writer.md +45 -0
- package/presets/zcode/go/agents/unit-test-generator.md +44 -0
- package/presets/zcode/go/agents/unit-test-healer.md +36 -0
- package/presets/zcode/go/agents/unit-test-planner.md +51 -0
- package/presets/zcode/go/ai-local/conventions.md +29 -0
- package/presets/zcode/go/commands/README.md +54 -0
- package/presets/zcode/go/commands/migrate-tasks.md +44 -0
- package/presets/zcode/go/commands/spec-start.md +32 -0
- package/presets/zcode/go/commands/task-continue.md +73 -0
- package/presets/zcode/go/commands/task.md +74 -0
- package/presets/zcode/go/commands/technical-retro.md +96 -0
- package/presets/zcode/go/commands/update.md +43 -0
- package/presets/zcode/go/hooks/README.md +31 -0
- package/presets/zcode/go/hooks/chain-team-phases.sh +2763 -0
- package/presets/zcode/go/hooks/check-preset-update.mjs +232 -0
- package/presets/zcode/go/hooks/list-ai-local.mjs +299 -0
- package/presets/zcode/go/mcp.json +11 -0
- package/presets/zcode/go/rules/README.md +25 -0
- package/presets/zcode/go/rules/adapters-driven.md +25 -0
- package/presets/zcode/go/rules/adapters-driving.md +26 -0
- package/presets/zcode/go/rules/agent-team-intake.md +18 -0
- package/presets/zcode/go/rules/agent-team-orchestrator.md +282 -0
- package/presets/zcode/go/rules/ai-local-overlay.md +18 -0
- package/presets/zcode/go/rules/anti-hallucination-contract.md +37 -0
- package/presets/zcode/go/rules/anti-sycophancy-discipline.md +23 -0
- package/presets/zcode/go/rules/api-grpc.md +20 -0
- package/presets/zcode/go/rules/api-http.md +25 -0
- package/presets/zcode/go/rules/application-usecases.md +26 -0
- package/presets/zcode/go/rules/architecture-boundaries.md +31 -0
- package/presets/zcode/go/rules/code-quality-and-refactoring.md +78 -0
- package/presets/zcode/go/rules/code-review-mr.md +77 -0
- package/presets/zcode/go/rules/composition-root.md +26 -0
- package/presets/zcode/go/rules/design-guidance.md +104 -0
- package/presets/zcode/go/rules/domain-layer.md +25 -0
- package/presets/zcode/go/rules/feature-delivery-workflow.md +59 -0
- package/presets/zcode/go/rules/go-anti-hallucination.md +27 -0
- package/presets/zcode/go/rules/go-app-core.md +31 -0
- package/presets/zcode/go/rules/go-conventions.md +46 -0
- package/presets/zcode/go/rules/go-tooling.md +28 -0
- package/presets/zcode/go/rules/interactive-questions.md +29 -0
- package/presets/zcode/go/rules/language-policy.md +51 -0
- package/presets/zcode/go/rules/mcp-usage.md +93 -0
- package/presets/zcode/go/rules/messaging-adapters.md +15 -0
- package/presets/zcode/go/rules/module-public-api.md +16 -0
- package/presets/zcode/go/rules/persistence-adapters.md +24 -0
- package/presets/zcode/go/rules/ports-interfaces.md +26 -0
- package/presets/zcode/go/rules/post-change-test.md +22 -0
- package/presets/zcode/go/rules/preset-goals.md +31 -0
- package/presets/zcode/go/rules/preset-layering.md +27 -0
- package/presets/zcode/go/rules/preset-no-cross-stack-leakage.md +89 -0
- package/presets/zcode/go/rules/preset-pr-checklist.md +45 -0
- package/presets/zcode/go/rules/preset-token-budget.md +38 -0
- package/presets/zcode/go/rules/preset-twin-sync.md +41 -0
- package/presets/zcode/go/rules/preset-writing-style.md +42 -0
- package/presets/zcode/go/rules/product-specs-authoring.md +118 -0
- package/presets/zcode/go/rules/product-specs.md +62 -0
- package/presets/zcode/go/rules/reference-features.md +45 -0
- package/presets/zcode/go/rules/security-go.md +26 -0
- package/presets/zcode/go/rules/technical-retro.md +13 -0
- package/presets/zcode/go/rules/tests-e2e.md +13 -0
- package/presets/zcode/go/rules/tests-integration.md +22 -0
- package/presets/zcode/go/rules/tests-unit.md +18 -0
- package/presets/zcode/go/skills/README.md +5 -0
- package/presets/zcode/go/skills/ci-investigation/SKILL.md +24 -0
- package/presets/zcode/go/skills/code-review/SKILL.md +47 -0
- package/presets/zcode/go/skills/debug-investigation/SKILL.md +55 -0
- package/presets/zcode/go/skills/feature-delivery/SKILL.md +43 -0
- package/presets/zcode/go/skills/integration-testing/SKILL.md +21 -0
- package/presets/zcode/go/skills/spec-authoring/SKILL.md +31 -0
- package/presets/zcode/go/skills/spec-discovery/SKILL.md +63 -0
- package/presets/zcode/go/skills/technical-retro/SKILL.md +72 -0
- package/presets/zcode/go/skills/unit-testing/SKILL.md +20 -0
- package/presets/zcode/go/skills/write-adr/SKILL.md +46 -0
- package/presets/zcode/go/team/README.md +123 -0
- package/presets/zcode/go/team/fixtures/bugfix-standard.json +37 -0
- package/presets/zcode/go/team/fixtures/feature-full.json +61 -0
- package/presets/zcode/go/team/fixtures/feature-light.json +17 -0
- package/presets/zcode/go/team/fixtures/memlog.example.md +9 -0
- package/presets/zcode/ios-swift/MCP.md +35 -0
- package/presets/zcode/ios-swift/README.md +20 -0
- package/presets/zcode/ios-swift/REPO_AGENTS.md +98 -0
- package/presets/zcode/ios-swift/adapter-map.json +918 -0
- package/presets/zcode/ios-swift/agents/README.md +86 -0
- package/presets/zcode/ios-swift/agents/accessibility-reviewer.md +85 -0
- package/presets/zcode/ios-swift/agents/api-contract-reviewer.md +85 -0
- package/presets/zcode/ios-swift/agents/build-verifier.md +103 -0
- package/presets/zcode/ios-swift/agents/ci-investigator.md +107 -0
- package/presets/zcode/ios-swift/agents/code-reviewer.md +133 -0
- package/presets/zcode/ios-swift/agents/codebase-analyzer.md +49 -0
- package/presets/zcode/ios-swift/agents/debugger.md +129 -0
- package/presets/zcode/ios-swift/agents/feature-developer.md +153 -0
- package/presets/zcode/ios-swift/agents/migration-specialist.md +95 -0
- package/presets/zcode/ios-swift/agents/mockup-reviewer.md +81 -0
- package/presets/zcode/ios-swift/agents/openspec-author.md +185 -0
- package/presets/zcode/ios-swift/agents/performance-auditor.md +94 -0
- package/presets/zcode/ios-swift/agents/qa-tester.md +85 -0
- package/presets/zcode/ios-swift/agents/security-reviewer.md +81 -0
- package/presets/zcode/ios-swift/agents/solution-architect.md +48 -0
- package/presets/zcode/ios-swift/agents/task-analyst.md +152 -0
- package/presets/zcode/ios-swift/agents/task-router.md +190 -0
- package/presets/zcode/ios-swift/agents/tech-writer.md +75 -0
- package/presets/zcode/ios-swift/agents/unit-test-generator.md +71 -0
- package/presets/zcode/ios-swift/agents/unit-test-healer.md +70 -0
- package/presets/zcode/ios-swift/agents/unit-test-planner.md +83 -0
- package/presets/zcode/ios-swift/agents/xcuitest-test-generator.md +59 -0
- package/presets/zcode/ios-swift/agents/xcuitest-test-healer.md +59 -0
- package/presets/zcode/ios-swift/agents/xcuitest-test-planner.md +79 -0
- package/presets/zcode/ios-swift/ai-local/conventions.md +29 -0
- package/presets/zcode/ios-swift/commands/README.md +51 -0
- package/presets/zcode/ios-swift/commands/migrate-tasks.md +44 -0
- package/presets/zcode/ios-swift/commands/spec-start.md +32 -0
- package/presets/zcode/ios-swift/commands/task-continue.md +75 -0
- package/presets/zcode/ios-swift/commands/task.md +76 -0
- package/presets/zcode/ios-swift/commands/technical-retro.md +96 -0
- package/presets/zcode/ios-swift/commands/update.md +43 -0
- package/presets/zcode/ios-swift/hooks/README.md +31 -0
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +2768 -0
- package/presets/zcode/ios-swift/hooks/check-preset-update.mjs +232 -0
- package/presets/zcode/ios-swift/hooks/list-ai-local.mjs +299 -0
- package/presets/zcode/ios-swift/mcp.json +11 -0
- package/presets/zcode/ios-swift/rules/README.md +25 -0
- package/presets/zcode/ios-swift/rules/agent-team-intake.md +14 -0
- package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +282 -0
- package/presets/zcode/ios-swift/rules/ai-local-overlay.md +18 -0
- package/presets/zcode/ios-swift/rules/anti-hallucination-contract.md +37 -0
- package/presets/zcode/ios-swift/rules/anti-sycophancy-discipline.md +23 -0
- package/presets/zcode/ios-swift/rules/architecture-boundaries.md +29 -0
- package/presets/zcode/ios-swift/rules/code-quality-and-refactoring.md +77 -0
- package/presets/zcode/ios-swift/rules/code-review-mr.md +109 -0
- package/presets/zcode/ios-swift/rules/design-guidance.md +104 -0
- package/presets/zcode/ios-swift/rules/feature-delivery-workflow.md +129 -0
- package/presets/zcode/ios-swift/rules/interactive-questions.md +29 -0
- package/presets/zcode/ios-swift/rules/ios-app-core.md +20 -0
- package/presets/zcode/ios-swift/rules/language-policy.md +51 -0
- package/presets/zcode/ios-swift/rules/mcp-usage.md +94 -0
- package/presets/zcode/ios-swift/rules/mockup-review.md +171 -0
- package/presets/zcode/ios-swift/rules/module-public-api.md +17 -0
- package/presets/zcode/ios-swift/rules/navigation-coordinators.md +18 -0
- package/presets/zcode/ios-swift/rules/networking-services.md +43 -0
- package/presets/zcode/ios-swift/rules/persistence-data.md +20 -0
- package/presets/zcode/ios-swift/rules/post-change-build.md +27 -0
- package/presets/zcode/ios-swift/rules/preset-goals.md +31 -0
- package/presets/zcode/ios-swift/rules/preset-layering.md +27 -0
- package/presets/zcode/ios-swift/rules/preset-no-cross-stack-leakage.md +89 -0
- package/presets/zcode/ios-swift/rules/preset-pr-checklist.md +45 -0
- package/presets/zcode/ios-swift/rules/preset-token-budget.md +38 -0
- package/presets/zcode/ios-swift/rules/preset-twin-sync.md +41 -0
- package/presets/zcode/ios-swift/rules/preset-writing-style.md +42 -0
- package/presets/zcode/ios-swift/rules/product-specs-authoring.md +118 -0
- package/presets/zcode/ios-swift/rules/product-specs.md +61 -0
- package/presets/zcode/ios-swift/rules/reference-features.md +94 -0
- package/presets/zcode/ios-swift/rules/security-ios.md +24 -0
- package/presets/zcode/ios-swift/rules/state-and-viewmodels.md +37 -0
- package/presets/zcode/ios-swift/rules/swift-anti-hallucination.md +27 -0
- package/presets/zcode/ios-swift/rules/swift-conventions.md +55 -0
- package/presets/zcode/ios-swift/rules/swiftui-ui.md +70 -0
- package/presets/zcode/ios-swift/rules/technical-retro.md +13 -0
- package/presets/zcode/ios-swift/rules/tests-ui.md +37 -0
- package/presets/zcode/ios-swift/rules/tests-unit.md +35 -0
- package/presets/zcode/ios-swift/rules/ux-design.md +103 -0
- package/presets/zcode/ios-swift/rules/xcode-tooling.md +15 -0
- package/presets/zcode/ios-swift/skills/README.md +18 -0
- package/presets/zcode/ios-swift/skills/ci-investigation/SKILL.md +53 -0
- package/presets/zcode/ios-swift/skills/code-review/SKILL.md +61 -0
- package/presets/zcode/ios-swift/skills/debug-investigation/SKILL.md +72 -0
- package/presets/zcode/ios-swift/skills/feature-delivery/SKILL.md +51 -0
- package/presets/zcode/ios-swift/skills/mockup-review/SKILL.md +34 -0
- package/presets/zcode/ios-swift/skills/spec-authoring/SKILL.md +31 -0
- package/presets/zcode/ios-swift/skills/spec-discovery/SKILL.md +63 -0
- package/presets/zcode/ios-swift/skills/technical-retro/SKILL.md +72 -0
- package/presets/zcode/ios-swift/skills/unit-testing/SKILL.md +38 -0
- package/presets/zcode/ios-swift/skills/ux-design/SKILL.md +41 -0
- package/presets/zcode/ios-swift/skills/write-adr/SKILL.md +46 -0
- package/presets/zcode/ios-swift/skills/xcuitest-e2e/SKILL.md +39 -0
- package/presets/zcode/ios-swift/team/README.md +123 -0
- package/presets/zcode/ios-swift/team/fixtures/artifact-manifest.example.json +26 -0
- package/presets/zcode/ios-swift/team/fixtures/bugfix-standard.json +33 -0
- package/presets/zcode/ios-swift/team/fixtures/feature-full.json +61 -0
- package/presets/zcode/ios-swift/team/fixtures/feature-light.json +17 -0
- package/presets/zcode/ios-swift/team/fixtures/feature-with-figma-url.json +17 -0
- package/presets/zcode/ios-swift/team/fixtures/feature-with-ux-no-figma.json +17 -0
- package/presets/zcode/ios-swift/team/fixtures/memlog.example.md +9 -0
- package/presets/zcode/ios-swift/team/fixtures/mockup-review-fail-embedded-status.json +8 -0
- package/presets/zcode/ios-swift/team/fixtures/mockup-review-standalone.json +14 -0
- package/presets/zcode/ios-swift/team/fixtures/ux-design-standalone.json +15 -0
- package/presets/zcode/java/MCP.md +34 -0
- package/presets/zcode/java/README.md +20 -0
- package/presets/zcode/java/REPO_AGENTS.md +98 -0
- package/presets/zcode/java/adapter-map.json +864 -0
- package/presets/zcode/java/agents/README.md +55 -0
- package/presets/zcode/java/agents/api-contract-reviewer.md +47 -0
- package/presets/zcode/java/agents/build-verifier.md +72 -0
- package/presets/zcode/java/agents/ci-investigator.md +66 -0
- package/presets/zcode/java/agents/code-reviewer.md +128 -0
- package/presets/zcode/java/agents/codebase-analyzer.md +49 -0
- package/presets/zcode/java/agents/debugger.md +98 -0
- package/presets/zcode/java/agents/feature-developer.md +144 -0
- package/presets/zcode/java/agents/integration-test-generator.md +46 -0
- package/presets/zcode/java/agents/integration-test-healer.md +46 -0
- package/presets/zcode/java/agents/integration-test-planner.md +48 -0
- package/presets/zcode/java/agents/migration-specialist.md +59 -0
- package/presets/zcode/java/agents/openspec-author.md +185 -0
- package/presets/zcode/java/agents/performance-auditor.md +50 -0
- package/presets/zcode/java/agents/qa-tester.md +53 -0
- package/presets/zcode/java/agents/security-reviewer.md +42 -0
- package/presets/zcode/java/agents/solution-architect.md +56 -0
- package/presets/zcode/java/agents/task-analyst.md +131 -0
- package/presets/zcode/java/agents/task-router.md +179 -0
- package/presets/zcode/java/agents/tech-writer.md +45 -0
- package/presets/zcode/java/agents/unit-test-generator.md +44 -0
- package/presets/zcode/java/agents/unit-test-healer.md +36 -0
- package/presets/zcode/java/agents/unit-test-planner.md +51 -0
- package/presets/zcode/java/ai-local/conventions.md +29 -0
- package/presets/zcode/java/commands/README.md +54 -0
- package/presets/zcode/java/commands/migrate-tasks.md +44 -0
- package/presets/zcode/java/commands/spec-start.md +32 -0
- package/presets/zcode/java/commands/task-continue.md +73 -0
- package/presets/zcode/java/commands/task.md +74 -0
- package/presets/zcode/java/commands/technical-retro.md +96 -0
- package/presets/zcode/java/commands/update.md +43 -0
- package/presets/zcode/java/hooks/README.md +31 -0
- package/presets/zcode/java/hooks/chain-team-phases.sh +2763 -0
- package/presets/zcode/java/hooks/check-preset-update.mjs +232 -0
- package/presets/zcode/java/hooks/list-ai-local.mjs +299 -0
- package/presets/zcode/java/mcp.json +11 -0
- package/presets/zcode/java/rules/README.md +25 -0
- package/presets/zcode/java/rules/adapters-driven.md +30 -0
- package/presets/zcode/java/rules/adapters-driving.md +30 -0
- package/presets/zcode/java/rules/agent-team-intake.md +18 -0
- package/presets/zcode/java/rules/agent-team-orchestrator.md +282 -0
- package/presets/zcode/java/rules/ai-local-overlay.md +18 -0
- package/presets/zcode/java/rules/anti-hallucination-contract.md +37 -0
- package/presets/zcode/java/rules/anti-sycophancy-discipline.md +23 -0
- package/presets/zcode/java/rules/api-grpc.md +22 -0
- package/presets/zcode/java/rules/api-http.md +28 -0
- package/presets/zcode/java/rules/application-usecases.md +26 -0
- package/presets/zcode/java/rules/architecture-boundaries.md +31 -0
- package/presets/zcode/java/rules/code-quality-and-refactoring.md +78 -0
- package/presets/zcode/java/rules/code-review-mr.md +79 -0
- package/presets/zcode/java/rules/composition-root.md +25 -0
- package/presets/zcode/java/rules/design-guidance.md +105 -0
- package/presets/zcode/java/rules/domain-layer.md +32 -0
- package/presets/zcode/java/rules/feature-delivery-workflow.md +59 -0
- package/presets/zcode/java/rules/interactive-questions.md +29 -0
- package/presets/zcode/java/rules/java-anti-hallucination.md +27 -0
- package/presets/zcode/java/rules/java-app-core.md +32 -0
- package/presets/zcode/java/rules/java-conventions.md +48 -0
- package/presets/zcode/java/rules/java-tooling.md +24 -0
- package/presets/zcode/java/rules/language-policy.md +51 -0
- package/presets/zcode/java/rules/mcp-usage.md +92 -0
- package/presets/zcode/java/rules/messaging-adapters.md +23 -0
- package/presets/zcode/java/rules/module-public-api.md +23 -0
- package/presets/zcode/java/rules/persistence-adapters.md +25 -0
- package/presets/zcode/java/rules/ports-interfaces.md +27 -0
- package/presets/zcode/java/rules/post-change-test.md +20 -0
- package/presets/zcode/java/rules/preset-goals.md +31 -0
- package/presets/zcode/java/rules/preset-layering.md +27 -0
- package/presets/zcode/java/rules/preset-no-cross-stack-leakage.md +89 -0
- package/presets/zcode/java/rules/preset-pr-checklist.md +45 -0
- package/presets/zcode/java/rules/preset-token-budget.md +38 -0
- package/presets/zcode/java/rules/preset-twin-sync.md +41 -0
- package/presets/zcode/java/rules/preset-writing-style.md +42 -0
- package/presets/zcode/java/rules/product-specs-authoring.md +118 -0
- package/presets/zcode/java/rules/product-specs.md +62 -0
- package/presets/zcode/java/rules/reference-features.md +45 -0
- package/presets/zcode/java/rules/security-java.md +21 -0
- package/presets/zcode/java/rules/technical-retro.md +13 -0
- package/presets/zcode/java/rules/tests-e2e.md +15 -0
- package/presets/zcode/java/rules/tests-integration.md +19 -0
- package/presets/zcode/java/rules/tests-unit.md +26 -0
- package/presets/zcode/java/skills/README.md +5 -0
- package/presets/zcode/java/skills/ci-investigation/SKILL.md +24 -0
- package/presets/zcode/java/skills/code-review/SKILL.md +47 -0
- package/presets/zcode/java/skills/debug-investigation/SKILL.md +55 -0
- package/presets/zcode/java/skills/feature-delivery/SKILL.md +43 -0
- package/presets/zcode/java/skills/integration-testing/SKILL.md +21 -0
- package/presets/zcode/java/skills/spec-authoring/SKILL.md +31 -0
- package/presets/zcode/java/skills/spec-discovery/SKILL.md +63 -0
- package/presets/zcode/java/skills/technical-retro/SKILL.md +72 -0
- package/presets/zcode/java/skills/unit-testing/SKILL.md +20 -0
- package/presets/zcode/java/skills/write-adr/SKILL.md +46 -0
- package/presets/zcode/java/team/README.md +123 -0
- package/presets/zcode/java/team/fixtures/bugfix-standard.json +37 -0
- package/presets/zcode/java/team/fixtures/feature-full.json +61 -0
- package/presets/zcode/java/team/fixtures/feature-light.json +17 -0
- package/presets/zcode/java/team/fixtures/memlog.example.md +9 -0
- package/presets/zcode/mcp-ts/MCP.md +56 -0
- package/presets/zcode/mcp-ts/README.md +20 -0
- package/presets/zcode/mcp-ts/REPO_AGENTS.md +101 -0
- package/presets/zcode/mcp-ts/adapter-map.json +612 -0
- package/presets/zcode/mcp-ts/agents/README.md +53 -0
- package/presets/zcode/mcp-ts/agents/build-verifier.md +73 -0
- package/presets/zcode/mcp-ts/agents/feature-developer.md +138 -0
- package/presets/zcode/mcp-ts/agents/security-reviewer.md +43 -0
- package/presets/zcode/mcp-ts/agents/solution-architect.md +50 -0
- package/presets/zcode/mcp-ts/agents/task-analyst.md +134 -0
- package/presets/zcode/mcp-ts/agents/task-router.md +175 -0
- package/presets/zcode/mcp-ts/ai-local/conventions.md +22 -0
- package/presets/zcode/mcp-ts/commands/README.md +11 -0
- package/presets/zcode/mcp-ts/commands/migrate-tasks.md +44 -0
- package/presets/zcode/mcp-ts/commands/spec-start.md +32 -0
- package/presets/zcode/mcp-ts/commands/task-continue.md +73 -0
- package/presets/zcode/mcp-ts/commands/task.md +74 -0
- package/presets/zcode/mcp-ts/commands/technical-retro.md +96 -0
- package/presets/zcode/mcp-ts/commands/update.md +43 -0
- package/presets/zcode/mcp-ts/hooks/README.md +31 -0
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +2710 -0
- package/presets/zcode/mcp-ts/hooks/check-preset-update.mjs +232 -0
- package/presets/zcode/mcp-ts/hooks/list-ai-local.mjs +299 -0
- package/presets/zcode/mcp-ts/mcp.json +11 -0
- package/presets/zcode/mcp-ts/rules/README.md +25 -0
- package/presets/zcode/mcp-ts/rules/agent-team-intake.md +19 -0
- package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +282 -0
- package/presets/zcode/mcp-ts/rules/ai-local-overlay.md +18 -0
- package/presets/zcode/mcp-ts/rules/anti-hallucination-contract.md +37 -0
- package/presets/zcode/mcp-ts/rules/anti-sycophancy-discipline.md +27 -0
- package/presets/zcode/mcp-ts/rules/code-quality-and-refactoring.md +78 -0
- package/presets/zcode/mcp-ts/rules/code-review-mr.md +76 -0
- package/presets/zcode/mcp-ts/rules/design-guidance.md +104 -0
- package/presets/zcode/mcp-ts/rules/feature-delivery-workflow.md +59 -0
- package/presets/zcode/mcp-ts/rules/interactive-questions.md +29 -0
- package/presets/zcode/mcp-ts/rules/language-policy.md +51 -0
- package/presets/zcode/mcp-ts/rules/mcp-auth-secrets.md +35 -0
- package/presets/zcode/mcp-ts/rules/mcp-contract-testing.md +32 -0
- package/presets/zcode/mcp-ts/rules/mcp-server-boundaries.md +24 -0
- package/presets/zcode/mcp-ts/rules/mcp-tool-design.md +29 -0
- package/presets/zcode/mcp-ts/rules/mcp-transport-packaging.md +34 -0
- package/presets/zcode/mcp-ts/rules/mcp-ts-anti-hallucination.md +27 -0
- package/presets/zcode/mcp-ts/rules/mcp-ts-app-core.md +27 -0
- package/presets/zcode/mcp-ts/rules/mcp-ts-conventions.md +22 -0
- package/presets/zcode/mcp-ts/rules/mcp-ts-tooling.md +21 -0
- package/presets/zcode/mcp-ts/rules/mcp-usage.md +93 -0
- package/presets/zcode/mcp-ts/rules/post-change-test.md +21 -0
- package/presets/zcode/mcp-ts/rules/preset-goals.md +31 -0
- package/presets/zcode/mcp-ts/rules/preset-layering.md +27 -0
- package/presets/zcode/mcp-ts/rules/preset-no-cross-stack-leakage.md +89 -0
- package/presets/zcode/mcp-ts/rules/preset-pr-checklist.md +45 -0
- package/presets/zcode/mcp-ts/rules/preset-token-budget.md +38 -0
- package/presets/zcode/mcp-ts/rules/preset-twin-sync.md +41 -0
- package/presets/zcode/mcp-ts/rules/preset-writing-style.md +42 -0
- package/presets/zcode/mcp-ts/rules/product-specs-authoring.md +118 -0
- package/presets/zcode/mcp-ts/rules/product-specs.md +62 -0
- package/presets/zcode/mcp-ts/rules/reference-features.md +45 -0
- package/presets/zcode/mcp-ts/rules/security-mcp.md +43 -0
- package/presets/zcode/mcp-ts/rules/technical-retro.md +13 -0
- package/presets/zcode/mcp-ts/rules/tests-unit.md +23 -0
- package/presets/zcode/mcp-ts/skills/README.md +14 -0
- package/presets/zcode/mcp-ts/skills/code-review/SKILL.md +31 -0
- package/presets/zcode/mcp-ts/skills/debug-investigation/SKILL.md +51 -0
- package/presets/zcode/mcp-ts/skills/feature-delivery/SKILL.md +42 -0
- package/presets/zcode/mcp-ts/skills/spec-authoring/SKILL.md +31 -0
- package/presets/zcode/mcp-ts/skills/spec-discovery/SKILL.md +63 -0
- package/presets/zcode/mcp-ts/skills/unit-testing/SKILL.md +22 -0
- package/presets/zcode/mcp-ts/team/README.md +123 -0
- package/presets/zcode/mcp-ts/team/fixtures/bugfix-standard.json +32 -0
- package/presets/zcode/mcp-ts/team/fixtures/feature-full.json +36 -0
- package/presets/zcode/mcp-ts/team/fixtures/feature-light.json +34 -0
- package/presets/zcode/mcp-ts/team/fixtures/memlog.example.md +9 -0
- package/presets/zcode/mol/MCP.md +50 -0
- package/presets/zcode/mol/README.md +20 -0
- package/presets/zcode/mol/REPO_AGENTS.md +107 -0
- package/presets/zcode/mol/adapter-map.json +1122 -0
- package/presets/zcode/mol/agents/README.md +98 -0
- package/presets/zcode/mol/agents/accessibility-reviewer.md +92 -0
- package/presets/zcode/mol/agents/api-contract-reviewer.md +87 -0
- package/presets/zcode/mol/agents/build-verifier.md +117 -0
- package/presets/zcode/mol/agents/ci-investigator.md +95 -0
- package/presets/zcode/mol/agents/code-reviewer.md +139 -0
- package/presets/zcode/mol/agents/codebase-analyzer.md +51 -0
- package/presets/zcode/mol/agents/debugger.md +126 -0
- package/presets/zcode/mol/agents/feature-developer.md +151 -0
- package/presets/zcode/mol/agents/migration-specialist.md +97 -0
- package/presets/zcode/mol/agents/mockup-reviewer.md +131 -0
- package/presets/zcode/mol/agents/openspec-author.md +213 -0
- package/presets/zcode/mol/agents/performance-auditor.md +98 -0
- package/presets/zcode/mol/agents/playwright-test-generator.md +56 -0
- package/presets/zcode/mol/agents/playwright-test-healer.md +57 -0
- package/presets/zcode/mol/agents/playwright-test-planner.md +51 -0
- package/presets/zcode/mol/agents/qa-tester.md +80 -0
- package/presets/zcode/mol/agents/security-reviewer.md +89 -0
- package/presets/zcode/mol/agents/solution-architect.md +99 -0
- package/presets/zcode/mol/agents/task-analyst.md +255 -0
- package/presets/zcode/mol/agents/task-router.md +267 -0
- package/presets/zcode/mol/agents/tech-writer.md +88 -0
- package/presets/zcode/mol/agents/unit-test-generator.md +59 -0
- package/presets/zcode/mol/agents/unit-test-healer.md +60 -0
- package/presets/zcode/mol/agents/unit-test-planner.md +84 -0
- package/presets/zcode/mol/ai-local/conventions.md +49 -0
- package/presets/zcode/mol/ai-local/rules/task-levels.md +40 -0
- package/presets/zcode/mol/ai-local/rules-library/agent-artifacts-no-local-paths.md +71 -0
- package/presets/zcode/mol/ai-local/rules-library/agent-pipeline-gates.md +19 -0
- package/presets/zcode/mol/ai-local/rules-library/analytics-events.md +18 -0
- package/presets/zcode/mol/ai-local/rules-library/api-contract-source.md +14 -0
- package/presets/zcode/mol/ai-local/rules-library/artifact-lifecycle.md +17 -0
- package/presets/zcode/mol/ai-local/rules-library/code-style.md +68 -0
- package/presets/zcode/mol/ai-local/rules-library/commit-hygiene.md +17 -0
- package/presets/zcode/mol/ai-local/rules-library/component-child-decomposition.md +81 -0
- package/presets/zcode/mol/ai-local/rules-library/feature-flags-experiments.md +15 -0
- package/presets/zcode/mol/ai-local/rules-library/mcp-required-for-ui-layout.md +45 -0
- package/presets/zcode/mol/ai-local/rules-library/no-react-fc.md +46 -0
- package/presets/zcode/mol/ai-local/rules-library/no-test-driven-behavior-change.md +14 -0
- package/presets/zcode/mol/ai-local/rules-library/pre-pr-checklist.md +16 -0
- package/presets/zcode/mol/ai-local/rules-library/pwa-service-worker.md +15 -0
- package/presets/zcode/mol/ai-local/rules-library/qa-test-cases.md +14 -0
- package/presets/zcode/mol/ai-local/rules-library/router-pages.md +25 -0
- package/presets/zcode/mol/ai-local/rules-library/single-source-copy-constants.md +18 -0
- package/presets/zcode/mol/ai-local/rules-library/storybook-catalog-structure.md +62 -0
- package/presets/zcode/mol/ai-local/rules-library/storybook-cleanup-temp-screenshots.md +40 -0
- package/presets/zcode/mol/ai-local/rules-library/storybook-csf-authoring.md +100 -0
- package/presets/zcode/mol/ai-local/rules-library/storybook-dev-compare-figma.md +71 -0
- package/presets/zcode/mol/ai-local/rules-library/storybook-keep-tests-current.md +75 -0
- package/presets/zcode/mol/ai-local/rules-library/storybook-modals.md +64 -0
- package/presets/zcode/mol/ai-local/rules-library/storybook-no-app-node-modules.md +40 -0
- package/presets/zcode/mol/ai-local/rules-library/storybook-ui-quality-gate.md +38 -0
- package/presets/zcode/mol/ai-local/rules-library/ui-change-review-gate.md +15 -0
- package/presets/zcode/mol/commands/README.md +56 -0
- package/presets/zcode/mol/commands/migrate-tasks.md +44 -0
- package/presets/zcode/mol/commands/spec-start.md +32 -0
- package/presets/zcode/mol/commands/task-continue.md +75 -0
- package/presets/zcode/mol/commands/task-evil.md +90 -0
- package/presets/zcode/mol/commands/task.md +79 -0
- package/presets/zcode/mol/commands/technical-retro.md +96 -0
- package/presets/zcode/mol/commands/update.md +43 -0
- package/presets/zcode/mol/hooks/README.md +31 -0
- package/presets/zcode/mol/hooks/chain-team-phases.sh +2765 -0
- package/presets/zcode/mol/hooks/check-preset-update.mjs +232 -0
- package/presets/zcode/mol/hooks/list-ai-local.mjs +299 -0
- package/presets/zcode/mol/mcp.json +19 -0
- package/presets/zcode/mol/rules/README.md +25 -0
- package/presets/zcode/mol/rules/agent-team-intake.md +14 -0
- package/presets/zcode/mol/rules/agent-team-orchestrator.md +282 -0
- package/presets/zcode/mol/rules/ai-local-overlay.md +18 -0
- package/presets/zcode/mol/rules/anti-hallucination-contract.md +37 -0
- package/presets/zcode/mol/rules/anti-sycophancy-discipline.md +23 -0
- package/presets/zcode/mol/rules/code-quality-and-refactoring.md +76 -0
- package/presets/zcode/mol/rules/code-review-mr.md +95 -0
- package/presets/zcode/mol/rules/design-guidance.md +104 -0
- package/presets/zcode/mol/rules/feature-delivery-workflow.md +144 -0
- package/presets/zcode/mol/rules/interactive-questions.md +29 -0
- package/presets/zcode/mol/rules/language-policy.md +51 -0
- package/presets/zcode/mol/rules/mcp-usage.md +96 -0
- package/presets/zcode/mol/rules/mol-app-core.md +29 -0
- package/presets/zcode/mol/rules/mol-build.md +19 -0
- package/presets/zcode/mol/rules/mol-components.md +31 -0
- package/presets/zcode/mol/rules/mol-reactivity.md +21 -0
- package/presets/zcode/mol/rules/mol-state.md +22 -0
- package/presets/zcode/mol/rules/mol-testing.md +28 -0
- package/presets/zcode/mol/rules/mol-theming.md +22 -0
- package/presets/zcode/mol/rules/mol-view-tree.md +27 -0
- package/presets/zcode/mol/rules/package-manager.md +7 -0
- package/presets/zcode/mol/rules/preset-goals.md +31 -0
- package/presets/zcode/mol/rules/preset-layering.md +27 -0
- package/presets/zcode/mol/rules/preset-no-cross-stack-leakage.md +89 -0
- package/presets/zcode/mol/rules/preset-pr-checklist.md +45 -0
- package/presets/zcode/mol/rules/preset-token-budget.md +38 -0
- package/presets/zcode/mol/rules/preset-twin-sync.md +41 -0
- package/presets/zcode/mol/rules/preset-writing-style.md +42 -0
- package/presets/zcode/mol/rules/product-specs-authoring.md +118 -0
- package/presets/zcode/mol/rules/product-specs.md +61 -0
- package/presets/zcode/mol/rules/reference-features.md +82 -0
- package/presets/zcode/mol/rules/technical-retro.md +13 -0
- package/presets/zcode/mol/skills/README.md +17 -0
- package/presets/zcode/mol/skills/ci-investigation/SKILL.md +49 -0
- package/presets/zcode/mol/skills/code-review/SKILL.md +60 -0
- package/presets/zcode/mol/skills/debug-investigation/SKILL.md +63 -0
- package/presets/zcode/mol/skills/feature-delivery/SKILL.md +44 -0
- package/presets/zcode/mol/skills/spec-authoring/SKILL.md +31 -0
- package/presets/zcode/mol/skills/spec-discovery/SKILL.md +63 -0
- package/presets/zcode/mol/skills/technical-retro/SKILL.md +72 -0
- package/presets/zcode/mol/skills/unit-testing/SKILL.md +38 -0
- package/presets/zcode/mol/skills/write-adr/SKILL.md +46 -0
- package/presets/zcode/mol/team/README.md +135 -0
- package/presets/zcode/mol/team/fixtures/artifact-manifest.example.json +80 -0
- package/presets/zcode/mol/team/fixtures/bugfix-standard.json +25 -0
- package/presets/zcode/mol/team/fixtures/feature-full.json +29 -0
- package/presets/zcode/mol/team/fixtures/feature-light.json +28 -0
- package/presets/zcode/mol/team/fixtures/feature-parallel.json +84 -0
- package/presets/zcode/mol/team/fixtures/feature-ui-standard.json +24 -0
- package/presets/zcode/mol/team/fixtures/feature-with-figma-url.json +27 -0
- package/presets/zcode/mol/team/fixtures/feature-with-ux-no-figma.json +26 -0
- package/presets/zcode/mol/team/fixtures/memlog.example.md +9 -0
- package/presets/zcode/mol/team/fixtures/metrics-scenarios/tasks/human-gate/metrics.json +69 -0
- package/presets/zcode/mol/team/fixtures/metrics-scenarios/tasks/missing-ledger/status.json +5 -0
- package/presets/zcode/mol/team/fixtures/metrics-scenarios/tasks/parallel-receipts/metrics.json +79 -0
- package/presets/zcode/mol/team/fixtures/metrics-scenarios/tasks/serial-retry/metrics.json +124 -0
- package/presets/zcode/mol/team/fixtures/metrics-scenarios/tasks/validation-failed/metrics.json +124 -0
- package/presets/zcode/mol/team/fixtures/metrics.example.json +54 -0
- package/presets/zcode/mol/team/fixtures/mockup-review-fail-embedded-status.json +8 -0
- package/presets/zcode/mol/team/fixtures/mockup-review-standalone.json +23 -0
- package/presets/zcode/mol/team/fixtures/ux-design-standalone.json +24 -0
- package/presets/zcode/mol/team/tasks/.gitkeep +0 -0
- package/presets/zcode/next/MCP.md +50 -0
- package/presets/zcode/next/README.md +20 -0
- package/presets/zcode/next/REPO_AGENTS.md +110 -0
- package/presets/zcode/next/adapter-map.json +1347 -0
- package/presets/zcode/next/agents/README.md +98 -0
- package/presets/zcode/next/agents/accessibility-reviewer.md +92 -0
- package/presets/zcode/next/agents/api-contract-reviewer.md +89 -0
- package/presets/zcode/next/agents/build-verifier.md +119 -0
- package/presets/zcode/next/agents/ci-investigator.md +109 -0
- package/presets/zcode/next/agents/code-reviewer.md +141 -0
- package/presets/zcode/next/agents/codebase-analyzer.md +51 -0
- package/presets/zcode/next/agents/debugger.md +140 -0
- package/presets/zcode/next/agents/feature-developer.md +188 -0
- package/presets/zcode/next/agents/migration-specialist.md +97 -0
- package/presets/zcode/next/agents/mockup-reviewer.md +131 -0
- package/presets/zcode/next/agents/openspec-author.md +213 -0
- package/presets/zcode/next/agents/performance-auditor.md +98 -0
- package/presets/zcode/next/agents/playwright-test-generator.md +60 -0
- package/presets/zcode/next/agents/playwright-test-healer.md +61 -0
- package/presets/zcode/next/agents/playwright-test-planner.md +55 -0
- package/presets/zcode/next/agents/qa-tester.md +85 -0
- package/presets/zcode/next/agents/security-reviewer.md +89 -0
- package/presets/zcode/next/agents/solution-architect.md +99 -0
- package/presets/zcode/next/agents/task-analyst.md +272 -0
- package/presets/zcode/next/agents/task-router.md +267 -0
- package/presets/zcode/next/agents/tech-writer.md +88 -0
- package/presets/zcode/next/agents/unit-test-generator.md +62 -0
- package/presets/zcode/next/agents/unit-test-healer.md +63 -0
- package/presets/zcode/next/agents/unit-test-planner.md +87 -0
- package/presets/zcode/next/ai-local/conventions.md +49 -0
- package/presets/zcode/next/ai-local/rules/task-levels.md +40 -0
- package/presets/zcode/next/ai-local/rules-library/agent-artifacts-no-local-paths.md +71 -0
- package/presets/zcode/next/ai-local/rules-library/agent-pipeline-gates.md +19 -0
- package/presets/zcode/next/ai-local/rules-library/analytics-events.md +18 -0
- package/presets/zcode/next/ai-local/rules-library/api-contract-source.md +14 -0
- package/presets/zcode/next/ai-local/rules-library/artifact-lifecycle.md +17 -0
- package/presets/zcode/next/ai-local/rules-library/code-style.md +68 -0
- package/presets/zcode/next/ai-local/rules-library/commit-hygiene.md +17 -0
- package/presets/zcode/next/ai-local/rules-library/component-child-decomposition.md +81 -0
- package/presets/zcode/next/ai-local/rules-library/feature-flags-experiments.md +15 -0
- package/presets/zcode/next/ai-local/rules-library/mcp-required-for-ui-layout.md +45 -0
- package/presets/zcode/next/ai-local/rules-library/no-react-fc.md +46 -0
- package/presets/zcode/next/ai-local/rules-library/no-test-driven-behavior-change.md +14 -0
- package/presets/zcode/next/ai-local/rules-library/pre-pr-checklist.md +16 -0
- package/presets/zcode/next/ai-local/rules-library/pwa-service-worker.md +15 -0
- package/presets/zcode/next/ai-local/rules-library/qa-test-cases.md +14 -0
- package/presets/zcode/next/ai-local/rules-library/router-pages.md +25 -0
- package/presets/zcode/next/ai-local/rules-library/single-source-copy-constants.md +18 -0
- package/presets/zcode/next/ai-local/rules-library/storybook-catalog-structure.md +62 -0
- package/presets/zcode/next/ai-local/rules-library/storybook-cleanup-temp-screenshots.md +40 -0
- package/presets/zcode/next/ai-local/rules-library/storybook-csf-authoring.md +100 -0
- package/presets/zcode/next/ai-local/rules-library/storybook-dev-compare-figma.md +71 -0
- package/presets/zcode/next/ai-local/rules-library/storybook-keep-tests-current.md +75 -0
- package/presets/zcode/next/ai-local/rules-library/storybook-modals.md +64 -0
- package/presets/zcode/next/ai-local/rules-library/storybook-no-app-node-modules.md +40 -0
- package/presets/zcode/next/ai-local/rules-library/storybook-ui-quality-gate.md +38 -0
- package/presets/zcode/next/ai-local/rules-library/ui-change-review-gate.md +15 -0
- package/presets/zcode/next/commands/README.md +56 -0
- package/presets/zcode/next/commands/migrate-tasks.md +44 -0
- package/presets/zcode/next/commands/spec-start.md +32 -0
- package/presets/zcode/next/commands/task-continue.md +75 -0
- package/presets/zcode/next/commands/task-evil.md +90 -0
- package/presets/zcode/next/commands/task.md +79 -0
- package/presets/zcode/next/commands/technical-retro.md +96 -0
- package/presets/zcode/next/commands/update.md +43 -0
- package/presets/zcode/next/hooks/README.md +31 -0
- package/presets/zcode/next/hooks/chain-team-phases.sh +2766 -0
- package/presets/zcode/next/hooks/check-preset-update.mjs +232 -0
- package/presets/zcode/next/hooks/list-ai-local.mjs +299 -0
- package/presets/zcode/next/mcp.json +19 -0
- package/presets/zcode/next/rules/README.md +25 -0
- package/presets/zcode/next/rules/agent-team-intake.md +14 -0
- package/presets/zcode/next/rules/agent-team-orchestrator.md +282 -0
- package/presets/zcode/next/rules/ai-local-overlay.md +18 -0
- package/presets/zcode/next/rules/anti-hallucination-contract.md +37 -0
- package/presets/zcode/next/rules/anti-sycophancy-discipline.md +23 -0
- package/presets/zcode/next/rules/api-services.md +74 -0
- package/presets/zcode/next/rules/architecture-boundaries-ui.md +9 -0
- package/presets/zcode/next/rules/architecture-boundaries.md +86 -0
- package/presets/zcode/next/rules/arrow-functions.md +25 -0
- package/presets/zcode/next/rules/code-quality-and-refactoring.md +76 -0
- package/presets/zcode/next/rules/code-review-mr.md +95 -0
- package/presets/zcode/next/rules/component-catalog-gate.md +44 -0
- package/presets/zcode/next/rules/css-property-order-stylelint.md +13 -0
- package/presets/zcode/next/rules/design-guidance.md +104 -0
- package/presets/zcode/next/rules/design-tokens-binding.md +44 -0
- package/presets/zcode/next/rules/feature-delivery-workflow.md +166 -0
- package/presets/zcode/next/rules/forms-validation.md +38 -0
- package/presets/zcode/next/rules/http-client.md +55 -0
- package/presets/zcode/next/rules/interactive-questions.md +29 -0
- package/presets/zcode/next/rules/language-policy.md +51 -0
- package/presets/zcode/next/rules/layer-barrel-exports.md +68 -0
- package/presets/zcode/next/rules/mcp-usage.md +96 -0
- package/presets/zcode/next/rules/mockup-review.md +195 -0
- package/presets/zcode/next/rules/navigation-router-stack.md +68 -0
- package/presets/zcode/next/rules/navigation-router-ui.md +10 -0
- package/presets/zcode/next/rules/next-app-core.md +38 -0
- package/presets/zcode/next/rules/next-app-router.md +58 -0
- package/presets/zcode/next/rules/next-static-export.md +44 -0
- package/presets/zcode/next/rules/no-props-spread.md +31 -0
- package/presets/zcode/next/rules/no-type-assertion-as-import-export.md +51 -0
- package/presets/zcode/next/rules/package-manager.md +11 -0
- package/presets/zcode/next/rules/playwright-agents.md +67 -0
- package/presets/zcode/next/rules/post-change-lint.md +39 -0
- package/presets/zcode/next/rules/preset-goals.md +31 -0
- package/presets/zcode/next/rules/preset-layering.md +27 -0
- package/presets/zcode/next/rules/preset-no-cross-stack-leakage.md +89 -0
- package/presets/zcode/next/rules/preset-pr-checklist.md +45 -0
- package/presets/zcode/next/rules/preset-token-budget.md +38 -0
- package/presets/zcode/next/rules/preset-twin-sync.md +41 -0
- package/presets/zcode/next/rules/preset-writing-style.md +42 -0
- package/presets/zcode/next/rules/product-specs-authoring.md +119 -0
- package/presets/zcode/next/rules/product-specs.md +63 -0
- package/presets/zcode/next/rules/public-imports.md +50 -0
- package/presets/zcode/next/rules/react-a11y-coding.md +32 -0
- package/presets/zcode/next/rules/react-next-anti-hallucination.md +75 -0
- package/presets/zcode/next/rules/react-ui.md +154 -0
- package/presets/zcode/next/rules/reference-features.md +86 -0
- package/presets/zcode/next/rules/security-next.md +91 -0
- package/presets/zcode/next/rules/store-rtk.md +85 -0
- package/presets/zcode/next/rules/technical-retro.md +13 -0
- package/presets/zcode/next/rules/tests-e2e-structure.md +87 -0
- package/presets/zcode/next/rules/tests-unit.md +105 -0
- package/presets/zcode/next/rules/types-jsdoc.md +40 -0
- package/presets/zcode/next/rules/ux-design.md +103 -0
- package/presets/zcode/next/skills/README.md +22 -0
- package/presets/zcode/next/skills/ci-investigation/SKILL.md +50 -0
- package/presets/zcode/next/skills/code-review/SKILL.md +61 -0
- package/presets/zcode/next/skills/debug-investigation/SKILL.md +64 -0
- package/presets/zcode/next/skills/feature-delivery/SKILL.md +45 -0
- package/presets/zcode/next/skills/figma-fidelity/SKILL.md +128 -0
- package/presets/zcode/next/skills/mockup-review/SKILL.md +40 -0
- package/presets/zcode/next/skills/playwright-e2e/SKILL.md +39 -0
- package/presets/zcode/next/skills/react-performance/SKILL.md +49 -0
- package/presets/zcode/next/skills/spec-authoring/SKILL.md +31 -0
- package/presets/zcode/next/skills/spec-discovery/SKILL.md +63 -0
- package/presets/zcode/next/skills/technical-retro/SKILL.md +72 -0
- package/presets/zcode/next/skills/unit-testing/SKILL.md +40 -0
- package/presets/zcode/next/skills/ux-design/SKILL.md +41 -0
- package/presets/zcode/next/skills/write-adr/SKILL.md +46 -0
- package/presets/zcode/next/team/README.md +135 -0
- package/presets/zcode/next/team/fixtures/artifact-manifest.example.json +80 -0
- package/presets/zcode/next/team/fixtures/bugfix-standard.json +25 -0
- package/presets/zcode/next/team/fixtures/feature-full.json +29 -0
- package/presets/zcode/next/team/fixtures/feature-light.json +28 -0
- package/presets/zcode/next/team/fixtures/feature-parallel.json +84 -0
- package/presets/zcode/next/team/fixtures/feature-ui-standard.json +24 -0
- package/presets/zcode/next/team/fixtures/feature-with-figma-url.json +27 -0
- package/presets/zcode/next/team/fixtures/feature-with-ux-no-figma.json +26 -0
- package/presets/zcode/next/team/fixtures/memlog.example.md +9 -0
- package/presets/zcode/next/team/fixtures/metrics-scenarios/tasks/human-gate/metrics.json +69 -0
- package/presets/zcode/next/team/fixtures/metrics-scenarios/tasks/missing-ledger/status.json +5 -0
- package/presets/zcode/next/team/fixtures/metrics-scenarios/tasks/parallel-receipts/metrics.json +79 -0
- package/presets/zcode/next/team/fixtures/metrics-scenarios/tasks/serial-retry/metrics.json +124 -0
- package/presets/zcode/next/team/fixtures/metrics-scenarios/tasks/validation-failed/metrics.json +124 -0
- package/presets/zcode/next/team/fixtures/metrics.example.json +54 -0
- package/presets/zcode/next/team/fixtures/mockup-review-fail-embedded-status.json +8 -0
- package/presets/zcode/next/team/fixtures/mockup-review-standalone.json +23 -0
- package/presets/zcode/next/team/fixtures/ux-design-standalone.json +24 -0
- package/presets/zcode/next/team/tasks/.gitkeep +0 -0
- package/presets/zcode/nuxt/MCP.md +36 -0
- package/presets/zcode/nuxt/README.md +20 -0
- package/presets/zcode/nuxt/REPO_AGENTS.md +101 -0
- package/presets/zcode/nuxt/adapter-map.json +1065 -0
- package/presets/zcode/nuxt/agents/README.md +107 -0
- package/presets/zcode/nuxt/agents/accessibility-reviewer.md +91 -0
- package/presets/zcode/nuxt/agents/api-contract-reviewer.md +89 -0
- package/presets/zcode/nuxt/agents/build-verifier.md +106 -0
- package/presets/zcode/nuxt/agents/ci-investigator.md +109 -0
- package/presets/zcode/nuxt/agents/code-reviewer.md +124 -0
- package/presets/zcode/nuxt/agents/codebase-analyzer.md +51 -0
- package/presets/zcode/nuxt/agents/debugger.md +140 -0
- package/presets/zcode/nuxt/agents/feature-developer.md +161 -0
- package/presets/zcode/nuxt/agents/migration-specialist.md +97 -0
- package/presets/zcode/nuxt/agents/mockup-reviewer.md +83 -0
- package/presets/zcode/nuxt/agents/openspec-author.md +187 -0
- package/presets/zcode/nuxt/agents/performance-auditor.md +98 -0
- package/presets/zcode/nuxt/agents/playwright-test-generator.md +60 -0
- package/presets/zcode/nuxt/agents/playwright-test-healer.md +60 -0
- package/presets/zcode/nuxt/agents/playwright-test-planner.md +55 -0
- package/presets/zcode/nuxt/agents/qa-tester.md +85 -0
- package/presets/zcode/nuxt/agents/security-reviewer.md +84 -0
- package/presets/zcode/nuxt/agents/solution-architect.md +98 -0
- package/presets/zcode/nuxt/agents/task-analyst.md +239 -0
- package/presets/zcode/nuxt/agents/task-router.md +226 -0
- package/presets/zcode/nuxt/agents/tech-writer.md +87 -0
- package/presets/zcode/nuxt/agents/unit-test-generator.md +62 -0
- package/presets/zcode/nuxt/agents/unit-test-healer.md +63 -0
- package/presets/zcode/nuxt/agents/unit-test-planner.md +87 -0
- package/presets/zcode/nuxt/ai-local/conventions.md +29 -0
- package/presets/zcode/nuxt/commands/README.md +51 -0
- package/presets/zcode/nuxt/commands/migrate-tasks.md +44 -0
- package/presets/zcode/nuxt/commands/spec-start.md +32 -0
- package/presets/zcode/nuxt/commands/task-continue.md +75 -0
- package/presets/zcode/nuxt/commands/task.md +76 -0
- package/presets/zcode/nuxt/commands/technical-retro.md +96 -0
- package/presets/zcode/nuxt/commands/update.md +43 -0
- package/presets/zcode/nuxt/hooks/README.md +31 -0
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +2766 -0
- package/presets/zcode/nuxt/hooks/check-preset-update.mjs +232 -0
- package/presets/zcode/nuxt/hooks/list-ai-local.mjs +299 -0
- package/presets/zcode/nuxt/mcp.json +19 -0
- package/presets/zcode/nuxt/rules/README.md +25 -0
- package/presets/zcode/nuxt/rules/agent-team-intake.md +14 -0
- package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +282 -0
- package/presets/zcode/nuxt/rules/ai-local-overlay.md +18 -0
- package/presets/zcode/nuxt/rules/anti-hallucination-contract.md +37 -0
- package/presets/zcode/nuxt/rules/anti-sycophancy-discipline.md +23 -0
- package/presets/zcode/nuxt/rules/api-services.md +72 -0
- package/presets/zcode/nuxt/rules/architecture-boundaries-ui.md +9 -0
- package/presets/zcode/nuxt/rules/architecture-boundaries.md +90 -0
- package/presets/zcode/nuxt/rules/code-quality-and-refactoring.md +76 -0
- package/presets/zcode/nuxt/rules/code-review-mr.md +84 -0
- package/presets/zcode/nuxt/rules/css-property-order-stylelint.md +14 -0
- package/presets/zcode/nuxt/rules/design-guidance.md +104 -0
- package/presets/zcode/nuxt/rules/feature-delivery-workflow.md +145 -0
- package/presets/zcode/nuxt/rules/http-client.md +9 -0
- package/presets/zcode/nuxt/rules/interactive-questions.md +29 -0
- package/presets/zcode/nuxt/rules/language-policy.md +51 -0
- package/presets/zcode/nuxt/rules/layer-barrel-exports.md +67 -0
- package/presets/zcode/nuxt/rules/mcp-usage.md +95 -0
- package/presets/zcode/nuxt/rules/mockup-review.md +171 -0
- package/presets/zcode/nuxt/rules/navigation-router-stack.md +55 -0
- package/presets/zcode/nuxt/rules/navigation-router-ui.md +10 -0
- package/presets/zcode/nuxt/rules/no-type-assertion-as-import-export.md +51 -0
- package/presets/zcode/nuxt/rules/no-v-bind-spread.md +7 -0
- package/presets/zcode/nuxt/rules/nuxt-app-core.md +44 -0
- package/presets/zcode/nuxt/rules/nuxt-pages-routing.md +31 -0
- package/presets/zcode/nuxt/rules/package-manager.md +13 -0
- package/presets/zcode/nuxt/rules/playwright-agents.md +74 -0
- package/presets/zcode/nuxt/rules/post-change-lint.md +37 -0
- package/presets/zcode/nuxt/rules/preset-goals.md +31 -0
- package/presets/zcode/nuxt/rules/preset-layering.md +27 -0
- package/presets/zcode/nuxt/rules/preset-no-cross-stack-leakage.md +89 -0
- package/presets/zcode/nuxt/rules/preset-pr-checklist.md +45 -0
- package/presets/zcode/nuxt/rules/preset-token-budget.md +38 -0
- package/presets/zcode/nuxt/rules/preset-twin-sync.md +41 -0
- package/presets/zcode/nuxt/rules/preset-writing-style.md +42 -0
- package/presets/zcode/nuxt/rules/product-specs-authoring.md +118 -0
- package/presets/zcode/nuxt/rules/product-specs.md +61 -0
- package/presets/zcode/nuxt/rules/public-imports.md +50 -0
- package/presets/zcode/nuxt/rules/reference-features.md +81 -0
- package/presets/zcode/nuxt/rules/script-setup-conventions.md +7 -0
- package/presets/zcode/nuxt/rules/security-nuxt.md +28 -0
- package/presets/zcode/nuxt/rules/store-pinia.md +61 -0
- package/presets/zcode/nuxt/rules/technical-retro.md +13 -0
- package/presets/zcode/nuxt/rules/tests-e2e-structure.md +87 -0
- package/presets/zcode/nuxt/rules/tests-unit.md +82 -0
- package/presets/zcode/nuxt/rules/types-jsdoc.md +40 -0
- package/presets/zcode/nuxt/rules/ux-design.md +103 -0
- package/presets/zcode/nuxt/rules/vue-a11y-coding.md +9 -0
- package/presets/zcode/nuxt/rules/vue-nuxt-anti-hallucination.md +65 -0
- package/presets/zcode/nuxt/rules/vue-ui.md +34 -0
- package/presets/zcode/nuxt/skills/README.md +21 -0
- package/presets/zcode/nuxt/skills/ci-investigation/SKILL.md +50 -0
- package/presets/zcode/nuxt/skills/code-review/SKILL.md +60 -0
- package/presets/zcode/nuxt/skills/debug-investigation/SKILL.md +64 -0
- package/presets/zcode/nuxt/skills/feature-delivery/SKILL.md +52 -0
- package/presets/zcode/nuxt/skills/mockup-review/SKILL.md +34 -0
- package/presets/zcode/nuxt/skills/playwright-e2e/SKILL.md +43 -0
- package/presets/zcode/nuxt/skills/spec-authoring/SKILL.md +31 -0
- package/presets/zcode/nuxt/skills/spec-discovery/SKILL.md +63 -0
- package/presets/zcode/nuxt/skills/technical-retro/SKILL.md +72 -0
- package/presets/zcode/nuxt/skills/unit-testing/SKILL.md +38 -0
- package/presets/zcode/nuxt/skills/ux-design/SKILL.md +41 -0
- package/presets/zcode/nuxt/skills/vue-performance/SKILL.md +58 -0
- package/presets/zcode/nuxt/skills/write-adr/SKILL.md +46 -0
- package/presets/zcode/nuxt/team/README.md +123 -0
- package/presets/zcode/nuxt/team/fixtures/artifact-manifest.example.json +80 -0
- package/presets/zcode/nuxt/team/fixtures/bugfix-standard.json +25 -0
- package/presets/zcode/nuxt/team/fixtures/feature-full.json +62 -0
- package/presets/zcode/nuxt/team/fixtures/feature-light.json +27 -0
- package/presets/zcode/nuxt/team/fixtures/feature-with-figma-url.json +17 -0
- package/presets/zcode/nuxt/team/fixtures/feature-with-ux-no-figma.json +17 -0
- package/presets/zcode/nuxt/team/fixtures/memlog.example.md +9 -0
- package/presets/zcode/nuxt/team/fixtures/metrics-scenarios/tasks/human-gate/metrics.json +69 -0
- package/presets/zcode/nuxt/team/fixtures/metrics-scenarios/tasks/missing-ledger/status.json +5 -0
- package/presets/zcode/nuxt/team/fixtures/metrics-scenarios/tasks/parallel-receipts/metrics.json +79 -0
- package/presets/zcode/nuxt/team/fixtures/metrics-scenarios/tasks/serial-retry/metrics.json +124 -0
- package/presets/zcode/nuxt/team/fixtures/metrics-scenarios/tasks/validation-failed/metrics.json +124 -0
- package/presets/zcode/nuxt/team/fixtures/metrics.example.json +54 -0
- package/presets/zcode/nuxt/team/fixtures/mockup-review-fail-embedded-status.json +8 -0
- package/presets/zcode/nuxt/team/fixtures/mockup-review-standalone.json +14 -0
- package/presets/zcode/nuxt/team/fixtures/ux-design-standalone.json +15 -0
- package/presets/zcode/nuxt/team/tasks/.gitkeep +0 -0
- package/presets/zcode/php-hexagonal/MCP.md +34 -0
- package/presets/zcode/php-hexagonal/README.md +20 -0
- package/presets/zcode/php-hexagonal/REPO_AGENTS.md +99 -0
- package/presets/zcode/php-hexagonal/adapter-map.json +864 -0
- package/presets/zcode/php-hexagonal/agents/README.md +55 -0
- package/presets/zcode/php-hexagonal/agents/api-contract-reviewer.md +47 -0
- package/presets/zcode/php-hexagonal/agents/build-verifier.md +72 -0
- package/presets/zcode/php-hexagonal/agents/ci-investigator.md +66 -0
- package/presets/zcode/php-hexagonal/agents/code-reviewer.md +128 -0
- package/presets/zcode/php-hexagonal/agents/codebase-analyzer.md +49 -0
- package/presets/zcode/php-hexagonal/agents/debugger.md +98 -0
- package/presets/zcode/php-hexagonal/agents/feature-developer.md +144 -0
- package/presets/zcode/php-hexagonal/agents/integration-test-generator.md +46 -0
- package/presets/zcode/php-hexagonal/agents/integration-test-healer.md +46 -0
- package/presets/zcode/php-hexagonal/agents/integration-test-planner.md +48 -0
- package/presets/zcode/php-hexagonal/agents/migration-specialist.md +59 -0
- package/presets/zcode/php-hexagonal/agents/openspec-author.md +185 -0
- package/presets/zcode/php-hexagonal/agents/performance-auditor.md +50 -0
- package/presets/zcode/php-hexagonal/agents/qa-tester.md +53 -0
- package/presets/zcode/php-hexagonal/agents/security-reviewer.md +42 -0
- package/presets/zcode/php-hexagonal/agents/solution-architect.md +56 -0
- package/presets/zcode/php-hexagonal/agents/task-analyst.md +131 -0
- package/presets/zcode/php-hexagonal/agents/task-router.md +179 -0
- package/presets/zcode/php-hexagonal/agents/tech-writer.md +45 -0
- package/presets/zcode/php-hexagonal/agents/unit-test-generator.md +44 -0
- package/presets/zcode/php-hexagonal/agents/unit-test-healer.md +36 -0
- package/presets/zcode/php-hexagonal/agents/unit-test-planner.md +51 -0
- package/presets/zcode/php-hexagonal/ai-local/conventions.md +29 -0
- package/presets/zcode/php-hexagonal/commands/README.md +54 -0
- package/presets/zcode/php-hexagonal/commands/migrate-tasks.md +44 -0
- package/presets/zcode/php-hexagonal/commands/spec-start.md +32 -0
- package/presets/zcode/php-hexagonal/commands/task-continue.md +73 -0
- package/presets/zcode/php-hexagonal/commands/task.md +74 -0
- package/presets/zcode/php-hexagonal/commands/technical-retro.md +96 -0
- package/presets/zcode/php-hexagonal/commands/update.md +43 -0
- package/presets/zcode/php-hexagonal/hooks/README.md +31 -0
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +2764 -0
- package/presets/zcode/php-hexagonal/hooks/check-preset-update.mjs +232 -0
- package/presets/zcode/php-hexagonal/hooks/list-ai-local.mjs +299 -0
- package/presets/zcode/php-hexagonal/mcp.json +11 -0
- package/presets/zcode/php-hexagonal/rules/README.md +25 -0
- package/presets/zcode/php-hexagonal/rules/adapters-driven.md +30 -0
- package/presets/zcode/php-hexagonal/rules/adapters-driving.md +30 -0
- package/presets/zcode/php-hexagonal/rules/agent-team-intake.md +18 -0
- package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +282 -0
- package/presets/zcode/php-hexagonal/rules/ai-local-overlay.md +18 -0
- package/presets/zcode/php-hexagonal/rules/anti-hallucination-contract.md +37 -0
- package/presets/zcode/php-hexagonal/rules/anti-sycophancy-discipline.md +23 -0
- package/presets/zcode/php-hexagonal/rules/api-grpc.md +22 -0
- package/presets/zcode/php-hexagonal/rules/api-http.md +28 -0
- package/presets/zcode/php-hexagonal/rules/application-usecases.md +25 -0
- package/presets/zcode/php-hexagonal/rules/architecture-boundaries.md +31 -0
- package/presets/zcode/php-hexagonal/rules/code-quality-and-refactoring.md +78 -0
- package/presets/zcode/php-hexagonal/rules/code-review-mr.md +79 -0
- package/presets/zcode/php-hexagonal/rules/composition-root.md +27 -0
- package/presets/zcode/php-hexagonal/rules/design-guidance.md +105 -0
- package/presets/zcode/php-hexagonal/rules/domain-layer.md +31 -0
- package/presets/zcode/php-hexagonal/rules/feature-delivery-workflow.md +59 -0
- package/presets/zcode/php-hexagonal/rules/interactive-questions.md +29 -0
- package/presets/zcode/php-hexagonal/rules/language-policy.md +51 -0
- package/presets/zcode/php-hexagonal/rules/mcp-usage.md +92 -0
- package/presets/zcode/php-hexagonal/rules/messaging-adapters.md +29 -0
- package/presets/zcode/php-hexagonal/rules/module-public-api.md +24 -0
- package/presets/zcode/php-hexagonal/rules/persistence-adapters.md +25 -0
- package/presets/zcode/php-hexagonal/rules/php-app-core.md +36 -0
- package/presets/zcode/php-hexagonal/rules/php-conventions.md +47 -0
- package/presets/zcode/php-hexagonal/rules/php-hexagonal-anti-hallucination.md +27 -0
- package/presets/zcode/php-hexagonal/rules/php-tooling.md +26 -0
- package/presets/zcode/php-hexagonal/rules/ports-interfaces.md +27 -0
- package/presets/zcode/php-hexagonal/rules/post-change-test.md +20 -0
- package/presets/zcode/php-hexagonal/rules/preset-goals.md +31 -0
- package/presets/zcode/php-hexagonal/rules/preset-layering.md +27 -0
- package/presets/zcode/php-hexagonal/rules/preset-no-cross-stack-leakage.md +89 -0
- package/presets/zcode/php-hexagonal/rules/preset-pr-checklist.md +45 -0
- package/presets/zcode/php-hexagonal/rules/preset-token-budget.md +38 -0
- package/presets/zcode/php-hexagonal/rules/preset-twin-sync.md +41 -0
- package/presets/zcode/php-hexagonal/rules/preset-writing-style.md +42 -0
- package/presets/zcode/php-hexagonal/rules/product-specs-authoring.md +118 -0
- package/presets/zcode/php-hexagonal/rules/product-specs.md +62 -0
- package/presets/zcode/php-hexagonal/rules/reference-features.md +45 -0
- package/presets/zcode/php-hexagonal/rules/security-php.md +21 -0
- package/presets/zcode/php-hexagonal/rules/technical-retro.md +13 -0
- package/presets/zcode/php-hexagonal/rules/tests-e2e.md +26 -0
- package/presets/zcode/php-hexagonal/rules/tests-integration.md +23 -0
- package/presets/zcode/php-hexagonal/rules/tests-unit.md +25 -0
- package/presets/zcode/php-hexagonal/skills/README.md +5 -0
- package/presets/zcode/php-hexagonal/skills/ci-investigation/SKILL.md +24 -0
- package/presets/zcode/php-hexagonal/skills/code-review/SKILL.md +47 -0
- package/presets/zcode/php-hexagonal/skills/debug-investigation/SKILL.md +55 -0
- package/presets/zcode/php-hexagonal/skills/feature-delivery/SKILL.md +43 -0
- package/presets/zcode/php-hexagonal/skills/integration-testing/SKILL.md +21 -0
- package/presets/zcode/php-hexagonal/skills/spec-authoring/SKILL.md +31 -0
- package/presets/zcode/php-hexagonal/skills/spec-discovery/SKILL.md +63 -0
- package/presets/zcode/php-hexagonal/skills/technical-retro/SKILL.md +72 -0
- package/presets/zcode/php-hexagonal/skills/unit-testing/SKILL.md +20 -0
- package/presets/zcode/php-hexagonal/skills/write-adr/SKILL.md +46 -0
- package/presets/zcode/php-hexagonal/team/README.md +123 -0
- package/presets/zcode/php-hexagonal/team/fixtures/bugfix-standard.json +37 -0
- package/presets/zcode/php-hexagonal/team/fixtures/feature-full.json +61 -0
- package/presets/zcode/php-hexagonal/team/fixtures/feature-light.json +17 -0
- package/presets/zcode/php-hexagonal/team/fixtures/memlog.example.md +9 -0
- package/presets/zcode/php-laravel/MCP.md +26 -0
- package/presets/zcode/php-laravel/README.md +20 -0
- package/presets/zcode/php-laravel/REPO_AGENTS.md +100 -0
- package/presets/zcode/php-laravel/adapter-map.json +864 -0
- package/presets/zcode/php-laravel/agents/README.md +55 -0
- package/presets/zcode/php-laravel/agents/api-contract-reviewer.md +48 -0
- package/presets/zcode/php-laravel/agents/build-verifier.md +72 -0
- package/presets/zcode/php-laravel/agents/ci-investigator.md +66 -0
- package/presets/zcode/php-laravel/agents/code-reviewer.md +128 -0
- package/presets/zcode/php-laravel/agents/codebase-analyzer.md +49 -0
- package/presets/zcode/php-laravel/agents/debugger.md +98 -0
- package/presets/zcode/php-laravel/agents/feature-developer.md +144 -0
- package/presets/zcode/php-laravel/agents/integration-test-generator.md +46 -0
- package/presets/zcode/php-laravel/agents/integration-test-healer.md +46 -0
- package/presets/zcode/php-laravel/agents/integration-test-planner.md +48 -0
- package/presets/zcode/php-laravel/agents/migration-specialist.md +59 -0
- package/presets/zcode/php-laravel/agents/openspec-author.md +185 -0
- package/presets/zcode/php-laravel/agents/performance-auditor.md +50 -0
- package/presets/zcode/php-laravel/agents/qa-tester.md +59 -0
- package/presets/zcode/php-laravel/agents/security-reviewer.md +54 -0
- package/presets/zcode/php-laravel/agents/solution-architect.md +57 -0
- package/presets/zcode/php-laravel/agents/task-analyst.md +131 -0
- package/presets/zcode/php-laravel/agents/task-router.md +195 -0
- package/presets/zcode/php-laravel/agents/tech-writer.md +45 -0
- package/presets/zcode/php-laravel/agents/unit-test-generator.md +44 -0
- package/presets/zcode/php-laravel/agents/unit-test-healer.md +36 -0
- package/presets/zcode/php-laravel/agents/unit-test-planner.md +51 -0
- package/presets/zcode/php-laravel/ai-local/conventions.md +29 -0
- package/presets/zcode/php-laravel/commands/README.md +54 -0
- package/presets/zcode/php-laravel/commands/migrate-tasks.md +44 -0
- package/presets/zcode/php-laravel/commands/spec-start.md +32 -0
- package/presets/zcode/php-laravel/commands/task-continue.md +73 -0
- package/presets/zcode/php-laravel/commands/task.md +74 -0
- package/presets/zcode/php-laravel/commands/technical-retro.md +96 -0
- package/presets/zcode/php-laravel/commands/update.md +43 -0
- package/presets/zcode/php-laravel/hooks/README.md +31 -0
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +2764 -0
- package/presets/zcode/php-laravel/hooks/check-preset-update.mjs +232 -0
- package/presets/zcode/php-laravel/hooks/list-ai-local.mjs +299 -0
- package/presets/zcode/php-laravel/mcp.json +11 -0
- package/presets/zcode/php-laravel/rules/README.md +25 -0
- package/presets/zcode/php-laravel/rules/actions-services.md +25 -0
- package/presets/zcode/php-laravel/rules/agent-team-intake.md +18 -0
- package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +282 -0
- package/presets/zcode/php-laravel/rules/ai-local-overlay.md +18 -0
- package/presets/zcode/php-laravel/rules/anti-hallucination-contract.md +37 -0
- package/presets/zcode/php-laravel/rules/anti-sycophancy-discipline.md +23 -0
- package/presets/zcode/php-laravel/rules/architecture-boundaries.md +32 -0
- package/presets/zcode/php-laravel/rules/code-quality-and-refactoring.md +78 -0
- package/presets/zcode/php-laravel/rules/code-review-mr.md +80 -0
- package/presets/zcode/php-laravel/rules/design-guidance.md +105 -0
- package/presets/zcode/php-laravel/rules/domain-layer.md +19 -0
- package/presets/zcode/php-laravel/rules/eloquent-persistence.md +24 -0
- package/presets/zcode/php-laravel/rules/events-listeners.md +24 -0
- package/presets/zcode/php-laravel/rules/feature-delivery-workflow.md +59 -0
- package/presets/zcode/php-laravel/rules/form-requests.md +24 -0
- package/presets/zcode/php-laravel/rules/http-layer.md +25 -0
- package/presets/zcode/php-laravel/rules/interactive-questions.md +29 -0
- package/presets/zcode/php-laravel/rules/jobs-queues.md +36 -0
- package/presets/zcode/php-laravel/rules/language-policy.md +51 -0
- package/presets/zcode/php-laravel/rules/laravel-anti-hallucination.md +27 -0
- package/presets/zcode/php-laravel/rules/laravel-app-core.md +34 -0
- package/presets/zcode/php-laravel/rules/laravel-conventions.md +34 -0
- package/presets/zcode/php-laravel/rules/mcp-usage.md +92 -0
- package/presets/zcode/php-laravel/rules/module-public-api.md +23 -0
- package/presets/zcode/php-laravel/rules/php-tooling.md +26 -0
- package/presets/zcode/php-laravel/rules/policies-authorization.md +24 -0
- package/presets/zcode/php-laravel/rules/post-change-test.md +20 -0
- package/presets/zcode/php-laravel/rules/preset-goals.md +31 -0
- package/presets/zcode/php-laravel/rules/preset-layering.md +27 -0
- package/presets/zcode/php-laravel/rules/preset-no-cross-stack-leakage.md +89 -0
- package/presets/zcode/php-laravel/rules/preset-pr-checklist.md +45 -0
- package/presets/zcode/php-laravel/rules/preset-token-budget.md +38 -0
- package/presets/zcode/php-laravel/rules/preset-twin-sync.md +41 -0
- package/presets/zcode/php-laravel/rules/preset-writing-style.md +42 -0
- package/presets/zcode/php-laravel/rules/product-specs-authoring.md +118 -0
- package/presets/zcode/php-laravel/rules/product-specs.md +62 -0
- package/presets/zcode/php-laravel/rules/reference-features.md +45 -0
- package/presets/zcode/php-laravel/rules/routes-api.md +24 -0
- package/presets/zcode/php-laravel/rules/security-php.md +47 -0
- package/presets/zcode/php-laravel/rules/service-providers.md +23 -0
- package/presets/zcode/php-laravel/rules/technical-retro.md +13 -0
- package/presets/zcode/php-laravel/rules/tests-e2e.md +26 -0
- package/presets/zcode/php-laravel/rules/tests-integration.md +23 -0
- package/presets/zcode/php-laravel/rules/tests-unit.md +24 -0
- package/presets/zcode/php-laravel/skills/README.md +5 -0
- package/presets/zcode/php-laravel/skills/ci-investigation/SKILL.md +24 -0
- package/presets/zcode/php-laravel/skills/code-review/SKILL.md +47 -0
- package/presets/zcode/php-laravel/skills/debug-investigation/SKILL.md +55 -0
- package/presets/zcode/php-laravel/skills/feature-delivery/SKILL.md +43 -0
- package/presets/zcode/php-laravel/skills/integration-testing/SKILL.md +21 -0
- package/presets/zcode/php-laravel/skills/spec-authoring/SKILL.md +31 -0
- package/presets/zcode/php-laravel/skills/spec-discovery/SKILL.md +63 -0
- package/presets/zcode/php-laravel/skills/technical-retro/SKILL.md +72 -0
- package/presets/zcode/php-laravel/skills/unit-testing/SKILL.md +20 -0
- package/presets/zcode/php-laravel/skills/write-adr/SKILL.md +46 -0
- package/presets/zcode/php-laravel/team/README.md +123 -0
- package/presets/zcode/php-laravel/team/fixtures/bugfix-standard.json +12 -0
- package/presets/zcode/php-laravel/team/fixtures/feature-full.json +44 -0
- package/presets/zcode/php-laravel/team/fixtures/feature-light.json +8 -0
- package/presets/zcode/php-laravel/team/fixtures/memlog.example.md +9 -0
- package/presets/zcode/platform-contract.json +135 -0
- package/presets/zcode/svelte/MCP.md +36 -0
- package/presets/zcode/svelte/README.md +20 -0
- package/presets/zcode/svelte/REPO_AGENTS.md +101 -0
- package/presets/zcode/svelte/adapter-map.json +1065 -0
- package/presets/zcode/svelte/agents/README.md +107 -0
- package/presets/zcode/svelte/agents/accessibility-reviewer.md +91 -0
- package/presets/zcode/svelte/agents/api-contract-reviewer.md +89 -0
- package/presets/zcode/svelte/agents/build-verifier.md +106 -0
- package/presets/zcode/svelte/agents/ci-investigator.md +109 -0
- package/presets/zcode/svelte/agents/code-reviewer.md +124 -0
- package/presets/zcode/svelte/agents/codebase-analyzer.md +51 -0
- package/presets/zcode/svelte/agents/debugger.md +140 -0
- package/presets/zcode/svelte/agents/feature-developer.md +161 -0
- package/presets/zcode/svelte/agents/migration-specialist.md +97 -0
- package/presets/zcode/svelte/agents/mockup-reviewer.md +83 -0
- package/presets/zcode/svelte/agents/openspec-author.md +187 -0
- package/presets/zcode/svelte/agents/performance-auditor.md +98 -0
- package/presets/zcode/svelte/agents/playwright-test-generator.md +60 -0
- package/presets/zcode/svelte/agents/playwright-test-healer.md +60 -0
- package/presets/zcode/svelte/agents/playwright-test-planner.md +55 -0
- package/presets/zcode/svelte/agents/qa-tester.md +85 -0
- package/presets/zcode/svelte/agents/security-reviewer.md +84 -0
- package/presets/zcode/svelte/agents/solution-architect.md +98 -0
- package/presets/zcode/svelte/agents/task-analyst.md +239 -0
- package/presets/zcode/svelte/agents/task-router.md +226 -0
- package/presets/zcode/svelte/agents/tech-writer.md +87 -0
- package/presets/zcode/svelte/agents/unit-test-generator.md +62 -0
- package/presets/zcode/svelte/agents/unit-test-healer.md +63 -0
- package/presets/zcode/svelte/agents/unit-test-planner.md +87 -0
- package/presets/zcode/svelte/ai-local/conventions.md +29 -0
- package/presets/zcode/svelte/commands/README.md +51 -0
- package/presets/zcode/svelte/commands/migrate-tasks.md +44 -0
- package/presets/zcode/svelte/commands/spec-start.md +32 -0
- package/presets/zcode/svelte/commands/task-continue.md +75 -0
- package/presets/zcode/svelte/commands/task.md +76 -0
- package/presets/zcode/svelte/commands/technical-retro.md +96 -0
- package/presets/zcode/svelte/commands/update.md +43 -0
- package/presets/zcode/svelte/hooks/README.md +31 -0
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +2766 -0
- package/presets/zcode/svelte/hooks/check-preset-update.mjs +232 -0
- package/presets/zcode/svelte/hooks/list-ai-local.mjs +299 -0
- package/presets/zcode/svelte/mcp.json +19 -0
- package/presets/zcode/svelte/rules/README.md +25 -0
- package/presets/zcode/svelte/rules/agent-team-intake.md +14 -0
- package/presets/zcode/svelte/rules/agent-team-orchestrator.md +282 -0
- package/presets/zcode/svelte/rules/ai-local-overlay.md +18 -0
- package/presets/zcode/svelte/rules/anti-hallucination-contract.md +37 -0
- package/presets/zcode/svelte/rules/anti-sycophancy-discipline.md +23 -0
- package/presets/zcode/svelte/rules/api-services.md +39 -0
- package/presets/zcode/svelte/rules/architecture-boundaries-ui.md +9 -0
- package/presets/zcode/svelte/rules/architecture-boundaries.md +54 -0
- package/presets/zcode/svelte/rules/code-quality-and-refactoring.md +76 -0
- package/presets/zcode/svelte/rules/code-review-mr.md +84 -0
- package/presets/zcode/svelte/rules/css-property-order-stylelint.md +14 -0
- package/presets/zcode/svelte/rules/design-guidance.md +104 -0
- package/presets/zcode/svelte/rules/feature-delivery-workflow.md +117 -0
- package/presets/zcode/svelte/rules/http-client.md +10 -0
- package/presets/zcode/svelte/rules/interactive-questions.md +29 -0
- package/presets/zcode/svelte/rules/language-policy.md +51 -0
- package/presets/zcode/svelte/rules/layer-barrel-exports.md +67 -0
- package/presets/zcode/svelte/rules/mcp-usage.md +95 -0
- package/presets/zcode/svelte/rules/mockup-review.md +171 -0
- package/presets/zcode/svelte/rules/navigation-router-stack.md +34 -0
- package/presets/zcode/svelte/rules/navigation-router-ui.md +19 -0
- package/presets/zcode/svelte/rules/no-rest-props-spread.md +26 -0
- package/presets/zcode/svelte/rules/no-type-assertion-as-import-export.md +51 -0
- package/presets/zcode/svelte/rules/package-manager.md +13 -0
- package/presets/zcode/svelte/rules/playwright-agents.md +74 -0
- package/presets/zcode/svelte/rules/post-change-lint.md +37 -0
- package/presets/zcode/svelte/rules/preset-goals.md +31 -0
- package/presets/zcode/svelte/rules/preset-layering.md +27 -0
- package/presets/zcode/svelte/rules/preset-no-cross-stack-leakage.md +89 -0
- package/presets/zcode/svelte/rules/preset-pr-checklist.md +45 -0
- package/presets/zcode/svelte/rules/preset-token-budget.md +38 -0
- package/presets/zcode/svelte/rules/preset-twin-sync.md +41 -0
- package/presets/zcode/svelte/rules/preset-writing-style.md +42 -0
- package/presets/zcode/svelte/rules/product-specs-authoring.md +118 -0
- package/presets/zcode/svelte/rules/product-specs.md +61 -0
- package/presets/zcode/svelte/rules/public-imports.md +32 -0
- package/presets/zcode/svelte/rules/reference-features.md +82 -0
- package/presets/zcode/svelte/rules/security-sveltekit.md +32 -0
- package/presets/zcode/svelte/rules/store-svelte.md +59 -0
- package/presets/zcode/svelte/rules/svelte-a11y-coding.md +21 -0
- package/presets/zcode/svelte/rules/svelte-app-core.md +44 -0
- package/presets/zcode/svelte/rules/svelte-script-conventions.md +27 -0
- package/presets/zcode/svelte/rules/svelte-sveltekit-anti-hallucination.md +66 -0
- package/presets/zcode/svelte/rules/svelte-ui.md +38 -0
- package/presets/zcode/svelte/rules/sveltekit-routing.md +33 -0
- package/presets/zcode/svelte/rules/technical-retro.md +13 -0
- package/presets/zcode/svelte/rules/tests-e2e-structure.md +87 -0
- package/presets/zcode/svelte/rules/tests-unit.md +82 -0
- package/presets/zcode/svelte/rules/types-jsdoc.md +40 -0
- package/presets/zcode/svelte/rules/ux-design.md +103 -0
- package/presets/zcode/svelte/skills/README.md +21 -0
- package/presets/zcode/svelte/skills/ci-investigation/SKILL.md +50 -0
- package/presets/zcode/svelte/skills/code-review/SKILL.md +60 -0
- package/presets/zcode/svelte/skills/debug-investigation/SKILL.md +64 -0
- package/presets/zcode/svelte/skills/feature-delivery/SKILL.md +52 -0
- package/presets/zcode/svelte/skills/mockup-review/SKILL.md +34 -0
- package/presets/zcode/svelte/skills/playwright-e2e/SKILL.md +43 -0
- package/presets/zcode/svelte/skills/spec-authoring/SKILL.md +31 -0
- package/presets/zcode/svelte/skills/spec-discovery/SKILL.md +63 -0
- package/presets/zcode/svelte/skills/svelte-performance/SKILL.md +57 -0
- package/presets/zcode/svelte/skills/technical-retro/SKILL.md +72 -0
- package/presets/zcode/svelte/skills/unit-testing/SKILL.md +38 -0
- package/presets/zcode/svelte/skills/ux-design/SKILL.md +41 -0
- package/presets/zcode/svelte/skills/write-adr/SKILL.md +46 -0
- package/presets/zcode/svelte/team/README.md +123 -0
- package/presets/zcode/svelte/team/fixtures/artifact-manifest.example.json +80 -0
- package/presets/zcode/svelte/team/fixtures/bugfix-standard.json +25 -0
- package/presets/zcode/svelte/team/fixtures/feature-full.json +62 -0
- package/presets/zcode/svelte/team/fixtures/feature-light.json +27 -0
- package/presets/zcode/svelte/team/fixtures/feature-with-figma-url.json +17 -0
- package/presets/zcode/svelte/team/fixtures/feature-with-ux-no-figma.json +17 -0
- package/presets/zcode/svelte/team/fixtures/memlog.example.md +9 -0
- package/presets/zcode/svelte/team/fixtures/metrics-scenarios/tasks/human-gate/metrics.json +69 -0
- package/presets/zcode/svelte/team/fixtures/metrics-scenarios/tasks/missing-ledger/status.json +5 -0
- package/presets/zcode/svelte/team/fixtures/metrics-scenarios/tasks/parallel-receipts/metrics.json +79 -0
- package/presets/zcode/svelte/team/fixtures/metrics-scenarios/tasks/serial-retry/metrics.json +124 -0
- package/presets/zcode/svelte/team/fixtures/metrics-scenarios/tasks/validation-failed/metrics.json +124 -0
- package/presets/zcode/svelte/team/fixtures/metrics.example.json +54 -0
- package/presets/zcode/svelte/team/fixtures/mockup-review-fail-embedded-status.json +8 -0
- package/presets/zcode/svelte/team/fixtures/mockup-review-standalone.json +14 -0
- package/presets/zcode/svelte/team/fixtures/ux-design-standalone.json +15 -0
- package/presets/zcode/svelte/team/tasks/.gitkeep +0 -0
|
@@ -0,0 +1,2765 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Chains agent team steps from pipeline.json after subagentStop.
|
|
3
|
+
# Falls back to legacy phase-based flow when pipeline.json is absent.
|
|
4
|
+
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
input=$(cat)
|
|
8
|
+
|
|
9
|
+
INPUT="$input" node <<'NODE'
|
|
10
|
+
const fs = require('fs');
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const crypto = require('crypto');
|
|
13
|
+
|
|
14
|
+
const TEAM_ROOT = path.join(process.cwd(), '.ai.local', 'team');
|
|
15
|
+
|
|
16
|
+
const inputRaw = process.env.INPUT || '';
|
|
17
|
+
let hookInput;
|
|
18
|
+
try {
|
|
19
|
+
hookInput = JSON.parse(inputRaw);
|
|
20
|
+
} catch {
|
|
21
|
+
process.stdout.write('{}');
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (hookInput.status !== 'completed') {
|
|
26
|
+
process.stdout.write('{}');
|
|
27
|
+
process.exit(0);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const activePath = path.join(TEAM_ROOT, 'active-task.json');
|
|
31
|
+
|
|
32
|
+
if (!fs.existsSync(activePath)) {
|
|
33
|
+
process.stdout.write('{}');
|
|
34
|
+
process.exit(0);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let active;
|
|
38
|
+
try {
|
|
39
|
+
active = JSON.parse(fs.readFileSync(activePath, 'utf8'));
|
|
40
|
+
} catch {
|
|
41
|
+
process.stdout.write('{}');
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const slug = active.slug;
|
|
46
|
+
// Reject non-kebab / traversal slugs: the runtime writes status.json and
|
|
47
|
+
// metrics.json under tasks/<slug>, so an unchecked slug could escape the tree.
|
|
48
|
+
const SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
49
|
+
if (typeof slug !== 'string' || slug.length > 48 || !SLUG_RE.test(slug)) {
|
|
50
|
+
process.stdout.write('{}');
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const taskDir = path.join(TEAM_ROOT, 'tasks', slug);
|
|
55
|
+
const statusPath = path.join(taskDir, 'status.json');
|
|
56
|
+
const pipelinePath = path.join(taskDir, 'pipeline.json');
|
|
57
|
+
const METRICS_PATH = path.join(taskDir, 'metrics.json');
|
|
58
|
+
const METRICS_LOCK = `${METRICS_PATH}.lock`;
|
|
59
|
+
// Pipeline step graph is assigned once pipeline.json is parsed; declared early so the
|
|
60
|
+
// gate-resume branch can schedule from the graph before the main parse point.
|
|
61
|
+
let steps = [];
|
|
62
|
+
|
|
63
|
+
if (!fs.existsSync(statusPath)) {
|
|
64
|
+
process.stdout.write('{}');
|
|
65
|
+
process.exit(0);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let status;
|
|
69
|
+
const now = new Date().toISOString();
|
|
70
|
+
const STACK = 'mol';
|
|
71
|
+
const PLATFORM = 'mavis';
|
|
72
|
+
|
|
73
|
+
let metricsLockToken = null;
|
|
74
|
+
function readMetricsLockToken() {
|
|
75
|
+
try {
|
|
76
|
+
const content = fs.readFileSync(METRICS_LOCK, 'utf8').trim();
|
|
77
|
+
return content.length > 0 ? content : null;
|
|
78
|
+
} catch { return null; }
|
|
79
|
+
}
|
|
80
|
+
function pidFromToken(token) {
|
|
81
|
+
const match = /^(\d+):/.exec(token || '');
|
|
82
|
+
return match ? Number(match[1]) : null;
|
|
83
|
+
}
|
|
84
|
+
function isPidAlive(pid) {
|
|
85
|
+
try { process.kill(pid, 0); return true; } catch (error) { return Boolean(error && error.code === 'EPERM'); }
|
|
86
|
+
}
|
|
87
|
+
function waitForMetricsLock() {
|
|
88
|
+
// OD-1: advisory lock via create-exclusive (fs.openSync(_, 'wx')) carrying an
|
|
89
|
+
// ownership token, backported from .ai.local/scripts/lock.mjs. Two concurrent
|
|
90
|
+
// subagentStop events serialize; release unlinks only when the file still
|
|
91
|
+
// carries our token. A lock left behind by a killed process is reclaimed only
|
|
92
|
+
// once its mtime is older than STALE_LOCK_MS AND the recorded owner pid is no
|
|
93
|
+
// longer alive, so a slow-but-live owner is never stolen.
|
|
94
|
+
const STALE_LOCK_MS = 30000;
|
|
95
|
+
const token = `${process.pid}:${crypto.randomBytes(8).toString('hex')}`;
|
|
96
|
+
for (let attempt = 0; attempt < 200; attempt += 1) {
|
|
97
|
+
let fd;
|
|
98
|
+
try {
|
|
99
|
+
fd = fs.openSync(METRICS_LOCK, 'wx');
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (!error || error.code !== 'EEXIST') throw error;
|
|
102
|
+
let stat = null;
|
|
103
|
+
try { stat = fs.statSync(METRICS_LOCK); } catch { /* lock vanished; retry */ }
|
|
104
|
+
const stale = stat !== null && Date.now() - stat.mtimeMs > STALE_LOCK_MS;
|
|
105
|
+
if (stale) {
|
|
106
|
+
const ownerPid = pidFromToken(readMetricsLockToken());
|
|
107
|
+
if (ownerPid === null || !isPidAlive(ownerPid)) {
|
|
108
|
+
try { fs.unlinkSync(METRICS_LOCK); } catch { /* already reclaimed */ }
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const until = Date.now() + 10;
|
|
113
|
+
while (Date.now() < until) { /* 10 ms busy-wait */ }
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
fs.writeSync(fd, token);
|
|
118
|
+
try { fs.fsyncSync(fd); } catch {}
|
|
119
|
+
} finally {
|
|
120
|
+
try { fs.closeSync(fd); } catch {}
|
|
121
|
+
}
|
|
122
|
+
metricsLockToken = token;
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
throw new Error('metrics lock timeout');
|
|
126
|
+
}
|
|
127
|
+
function releaseMetricsLock() {
|
|
128
|
+
if (metricsLockToken != null && readMetricsLockToken() === metricsLockToken) {
|
|
129
|
+
try { fs.unlinkSync(METRICS_LOCK); } catch {}
|
|
130
|
+
}
|
|
131
|
+
metricsLockToken = null;
|
|
132
|
+
}
|
|
133
|
+
let taskLockHeld = false;
|
|
134
|
+
function releaseTaskLock() {
|
|
135
|
+
if (!taskLockHeld) return;
|
|
136
|
+
taskLockHeld = false;
|
|
137
|
+
releaseMetricsLock();
|
|
138
|
+
}
|
|
139
|
+
waitForMetricsLock();
|
|
140
|
+
taskLockHeld = true;
|
|
141
|
+
process.on('exit', releaseTaskLock);
|
|
142
|
+
try {
|
|
143
|
+
status = JSON.parse(fs.readFileSync(statusPath, 'utf8'));
|
|
144
|
+
} catch {
|
|
145
|
+
releaseTaskLock();
|
|
146
|
+
process.stdout.write('{}');
|
|
147
|
+
process.exit(0);
|
|
148
|
+
}
|
|
149
|
+
function mutateMetrics(mutator) {
|
|
150
|
+
const acquiredHere = !taskLockHeld;
|
|
151
|
+
if (acquiredHere) waitForMetricsLock();
|
|
152
|
+
try {
|
|
153
|
+
let metrics;
|
|
154
|
+
try { metrics = JSON.parse(fs.readFileSync(METRICS_PATH, 'utf8')); } catch {
|
|
155
|
+
const runId = status.metricsRunId || `${slug}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
156
|
+
status.metricsRunId = runId;
|
|
157
|
+
// Resolve profile from pipeline.json (preferred) or status.json, falling back to 'unknown'.
|
|
158
|
+
// The router/agent must never write profile into status.json — pipeline.json is the SoT.
|
|
159
|
+
let profile = 'unknown';
|
|
160
|
+
try {
|
|
161
|
+
if (fs.existsSync(pipelinePath)) {
|
|
162
|
+
const pipe = JSON.parse(fs.readFileSync(pipelinePath, 'utf8'));
|
|
163
|
+
if (pipe && (pipe.profile === 'light' || pipe.profile === 'standard' || pipe.profile === 'full')) {
|
|
164
|
+
profile = pipe.profile;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
} catch {}
|
|
168
|
+
if (profile === 'unknown' && (status.profile === 'light' || status.profile === 'standard' || status.profile === 'full')) {
|
|
169
|
+
profile = status.profile;
|
|
170
|
+
}
|
|
171
|
+
metrics = { schemaVersion: 1, task: { runId, slug, preset: 'ai-rules', stack: STACK, platform: PLATFORM, intent: status.intent || 'unknown', profile }, events: [] };
|
|
172
|
+
metrics.events.push({ eventId: `${runId}:task_started`, type: 'task_started', at: now, source: 'hook', attributionConfidence: 'high' });
|
|
173
|
+
}
|
|
174
|
+
mutator(metrics);
|
|
175
|
+
const temporary = `${METRICS_PATH}.${process.pid}.${Date.now()}.tmp`;
|
|
176
|
+
fs.writeFileSync(temporary, JSON.stringify(metrics, null, 2) + '\n');
|
|
177
|
+
fs.renameSync(temporary, METRICS_PATH);
|
|
178
|
+
} finally {
|
|
179
|
+
if (acquiredHere) releaseMetricsLock();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function appendMetric(event) { mutateMetrics((metrics) => metrics.events.push({ eventId: `${metrics.task.runId}:${Date.now()}:${Math.random().toString(16).slice(2)}`, ...event })); }
|
|
183
|
+
function nextAttemptOrdinal(stepIndex, agent) {
|
|
184
|
+
try {
|
|
185
|
+
const metrics = JSON.parse(fs.readFileSync(METRICS_PATH, 'utf8'));
|
|
186
|
+
return metrics.events.reduce((highest, event) => event.type === 'attempt_started' && event.stepIndex === stepIndex && event.agent === agent ? Math.max(highest, Number(event.attempt) || 0) : highest, 0) + 1;
|
|
187
|
+
} catch { return 1; }
|
|
188
|
+
}
|
|
189
|
+
function roleFor(agent) {
|
|
190
|
+
if (/analyst|architect|router|migration/.test(agent || '')) return 'planning';
|
|
191
|
+
if (/verifier/.test(agent || '')) return 'validation';
|
|
192
|
+
if (/reviewer|auditor/.test(agent || '')) return 'review';
|
|
193
|
+
if (/test|qa/.test(agent || '')) return 'testing';
|
|
194
|
+
if (/writer/.test(agent || '')) return 'docs';
|
|
195
|
+
return 'implementation';
|
|
196
|
+
}
|
|
197
|
+
const DEFAULT_ARTIFACT_OUTPUT_IDS = {
|
|
198
|
+
'task-router': 'routing',
|
|
199
|
+
'task-analyst': 'analysis',
|
|
200
|
+
'solution-architect': 'architecture',
|
|
201
|
+
'migration-specialist': 'migration-plan',
|
|
202
|
+
debugger: 'debug',
|
|
203
|
+
'ci-investigator': 'ci',
|
|
204
|
+
'feature-developer': 'implementation',
|
|
205
|
+
'build-verifier': 'validation',
|
|
206
|
+
'code-reviewer': 'review',
|
|
207
|
+
'security-reviewer': 'security-review',
|
|
208
|
+
'accessibility-reviewer': 'a11y-review',
|
|
209
|
+
'performance-auditor': 'perf-report',
|
|
210
|
+
'mockup-reviewer': 'mockup-review',
|
|
211
|
+
'api-contract-reviewer': 'api-contract-review',
|
|
212
|
+
'tech-writer': 'documentation',
|
|
213
|
+
'openspec-author': 'openspec-change',
|
|
214
|
+
'qa-tester': 'qa',
|
|
215
|
+
'unit-test-planner': 'unit-test-plan',
|
|
216
|
+
'unit-test-generator': 'unit-test-spec',
|
|
217
|
+
'unit-test-healer': 'unit-test-heal',
|
|
218
|
+
'playwright-test-planner': 'e2e-plan',
|
|
219
|
+
'playwright-test-generator': 'e2e-spec',
|
|
220
|
+
'playwright-test-healer': 'e2e-heal',
|
|
221
|
+
};
|
|
222
|
+
// Artifact status enum — mirrors the writer (`manifest.mjs`) and the schema
|
|
223
|
+
// table in agent-artifact-contracts.md. A receipt outcome is not a status.
|
|
224
|
+
const ARTIFACT_STATUSES = ['planned', 'in_progress', 'completed', 'blocked', 'superseded'];
|
|
225
|
+
const RECEIPT_OUTCOME_STATUS = { completed: 'completed', blocked: 'blocked', changes_requested: 'blocked', validation_failed: 'blocked' };
|
|
226
|
+
function artifactOutputIdFor(step, agent) {
|
|
227
|
+
if (step && typeof step.artifactOutputId === 'string') return step.artifactOutputId;
|
|
228
|
+
if (step?.artifactOutputIds && typeof step.artifactOutputIds[agent] === 'string') return step.artifactOutputIds[agent];
|
|
229
|
+
return DEFAULT_ARTIFACT_OUTPUT_IDS[agent] || agent;
|
|
230
|
+
}
|
|
231
|
+
function activateAttempts(step, stepIndex, waveId = null, agentsOverride = null) {
|
|
232
|
+
const active = { ...(status.activeAttempts || {}) };
|
|
233
|
+
const agents = Array.isArray(agentsOverride) && agentsOverride.length > 0 ? agentsOverride : getStepAgents(step);
|
|
234
|
+
const parallelGroupId = step.parallel && getStepAgents(step).length > 1 ? `${status.metricsRunId || slug}:step-${stepIndex}` : null;
|
|
235
|
+
for (const agent of agents) {
|
|
236
|
+
const attempt = nextAttemptOrdinal(stepIndex, agent); const runId = status.metricsRunId || `${slug}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
237
|
+
status.metricsRunId = runId; const attemptId = `${runId}:step-${stepIndex}:${agent}:attempt-${attempt}`;
|
|
238
|
+
if (active[attemptId]) continue;
|
|
239
|
+
active[attemptId] = { agent, stepIndex, attempt, startedAt: now, parallelGroupId, waveId: waveId || null };
|
|
240
|
+
appendMetric({ type: 'attempt_started', at: now, attemptId, stepIndex, stepLabel: step.label || null, agent, role: roleFor(agent), attempt, parallelGroupId, waveId: waveId || null, source: 'hook', attributionConfidence: 'high' });
|
|
241
|
+
}
|
|
242
|
+
status.activeAttempts = active;
|
|
243
|
+
}
|
|
244
|
+
function resolvedAttempt() {
|
|
245
|
+
const active = status.activeAttempts || {}; const entries = Object.entries(active);
|
|
246
|
+
const stableAttemptId = hookInput.attemptId;
|
|
247
|
+
if (stableAttemptId) {
|
|
248
|
+
return active[stableAttemptId]
|
|
249
|
+
? { attemptId: stableAttemptId, entry: active[stableAttemptId], confidence: 'high' }
|
|
250
|
+
: null;
|
|
251
|
+
}
|
|
252
|
+
if (entries.length === 1) return { attemptId: entries[0][0], entry: entries[0][1], confidence: 'high' };
|
|
253
|
+
try { const receipts = JSON.parse(fs.readFileSync(path.join(taskDir, '.metrics-receipts.json'), 'utf8')); const receipt = Array.isArray(receipts) ? receipts.find((item) => active[item.attemptId]) : null; if (receipt) return { attemptId: receipt.attemptId, entry: active[receipt.attemptId], confidence: 'fallback', source: 'agent' }; } catch {}
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
let artifactStallMessage = null;
|
|
257
|
+
|
|
258
|
+
// A1: seed the manifest a modern pipeline expects instead of advancing without
|
|
259
|
+
// one. Exclusive publish via hard link so a producer that wrote the file in the
|
|
260
|
+
// meantime is never overwritten; returns null on success (or when the file
|
|
261
|
+
// appeared) and the fs error otherwise.
|
|
262
|
+
function writeSkeletonManifest(manifestPath) {
|
|
263
|
+
const temporary = `${manifestPath}.${process.pid}.${Date.now()}.seed`;
|
|
264
|
+
const body = JSON.stringify({ schemaVersion: 1, slug, artifacts: [] }, null, 2) + '\n';
|
|
265
|
+
let descriptor = null;
|
|
266
|
+
try {
|
|
267
|
+
descriptor = fs.openSync(temporary, 'wx');
|
|
268
|
+
try { fs.writeSync(descriptor, body); try { fs.fsyncSync(descriptor); } catch {} } finally { fs.closeSync(descriptor); descriptor = null; }
|
|
269
|
+
fs.linkSync(temporary, manifestPath);
|
|
270
|
+
fs.unlinkSync(temporary);
|
|
271
|
+
return null;
|
|
272
|
+
} catch (error) {
|
|
273
|
+
if (descriptor !== null) { try { fs.closeSync(descriptor); } catch {} }
|
|
274
|
+
try { fs.unlinkSync(temporary); } catch {}
|
|
275
|
+
if (error && error.code === 'EEXIST' && fs.existsSync(manifestPath)) return null;
|
|
276
|
+
return String(error && error.message ? error.message : error);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function normalizeRepoPath(value) {
|
|
281
|
+
let text = typeof value === 'string' ? value.trim() : '';
|
|
282
|
+
text = text.replace(/\\/g, '/');
|
|
283
|
+
while (text.startsWith('./')) text = text.slice(2);
|
|
284
|
+
if (!text || text === '—' || text === '-' || text === '–') return '';
|
|
285
|
+
if (/[\s()]/.test(text)) return '';
|
|
286
|
+
return text;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function isAppPath(file) {
|
|
290
|
+
const normalized = normalizeRepoPath(file);
|
|
291
|
+
return normalized === 'app' || normalized.startsWith('app/') || normalized.startsWith('app/**') || normalized.startsWith('app/*');
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function isSpecFolderPath(file) {
|
|
295
|
+
const normalized = normalizeRepoPath(file);
|
|
296
|
+
return normalized.startsWith('docs/specs/') || normalized.startsWith('docs/specs/**') || normalized.startsWith('openspec/') || normalized.startsWith('openspec/**');
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function listsBothSpecAndApp(files) {
|
|
300
|
+
let app = false;
|
|
301
|
+
let spec = false;
|
|
302
|
+
for (const file of files || []) {
|
|
303
|
+
if (isAppPath(file)) app = true;
|
|
304
|
+
if (isSpecFolderPath(file)) spec = true;
|
|
305
|
+
}
|
|
306
|
+
return app && spec;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function pathInWriteScopes(file, writeScopes) {
|
|
310
|
+
const target = normalizeRepoPath(file);
|
|
311
|
+
if (!target) return false;
|
|
312
|
+
const scopes = Array.isArray(writeScopes) ? writeScopes : [];
|
|
313
|
+
for (const scope of scopes) {
|
|
314
|
+
const normalized = normalizeRepoPath(scope);
|
|
315
|
+
if (!normalized) continue;
|
|
316
|
+
if (normalized === target) return true;
|
|
317
|
+
if (normalized.endsWith('/**')) {
|
|
318
|
+
const prefix = normalized.slice(0, -3);
|
|
319
|
+
if (target === prefix || target.startsWith(prefix + '/')) return true;
|
|
320
|
+
} else if (normalized.endsWith('/*')) {
|
|
321
|
+
const prefix = normalized.slice(0, -2);
|
|
322
|
+
const rest = target.startsWith(prefix + '/') ? target.slice(prefix.length + 1) : '';
|
|
323
|
+
if (rest && !rest.includes('/')) return true;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function taskFileSet(task) {
|
|
330
|
+
const all = []
|
|
331
|
+
.concat((task && task.files) || [], (task && task.specFiles) || [], (task && task.appFiles) || [])
|
|
332
|
+
.map((file) => normalizeRepoPath(file))
|
|
333
|
+
.filter(Boolean);
|
|
334
|
+
return new Set(all);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function taskReaches(tasks, startId, targetId) {
|
|
338
|
+
const byId = new Map(tasks.map((task) => [String(task.id), task]));
|
|
339
|
+
const seen = new Set();
|
|
340
|
+
const stack = [String(startId)];
|
|
341
|
+
while (stack.length > 0) {
|
|
342
|
+
const id = stack.pop();
|
|
343
|
+
if (seen.has(id)) continue;
|
|
344
|
+
seen.add(id);
|
|
345
|
+
const task = byId.get(id);
|
|
346
|
+
const deps = task && Array.isArray(task.dependsOn) ? task.dependsOn : [];
|
|
347
|
+
for (const dep of deps) {
|
|
348
|
+
if (String(dep) === String(targetId)) return true;
|
|
349
|
+
stack.push(String(dep));
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function tasksAreOrdered(tasks, left, right) {
|
|
356
|
+
return taskReaches(tasks, left.id, right.id) || taskReaches(tasks, right.id, left.id);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function validateTaskFileLists(tasks, writeScopes) {
|
|
360
|
+
const list = Array.isArray(tasks) ? tasks : [];
|
|
361
|
+
const scopes = Array.isArray(writeScopes) ? writeScopes : [];
|
|
362
|
+
for (const task of list) {
|
|
363
|
+
const id = task && task.id ? task.id : '(unnamed)';
|
|
364
|
+
const files = (task && task.files) || [];
|
|
365
|
+
if (listsBothSpecAndApp(files)) {
|
|
366
|
+
return 'task "' + id + '" lists spec-folder paths and app/** paths in one file list; they are different lists';
|
|
367
|
+
}
|
|
368
|
+
if (scopes.length === 0) continue;
|
|
369
|
+
const combined = files.concat((task && task.specFiles) || [], (task && task.appFiles) || []);
|
|
370
|
+
for (const file of combined) {
|
|
371
|
+
if (!pathInWriteScopes(file, scopes)) {
|
|
372
|
+
const label = normalizeRepoPath(file) || file;
|
|
373
|
+
return 'task "' + id + '" file "' + label + '" is outside the implementing step writeScopes';
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
for (let i = 0; i < list.length; i += 1) {
|
|
378
|
+
for (let j = i + 1; j < list.length; j += 1) {
|
|
379
|
+
if (tasksAreOrdered(list, list[i], list[j])) continue;
|
|
380
|
+
const left = taskFileSet(list[i]);
|
|
381
|
+
let shared = '';
|
|
382
|
+
for (const file of taskFileSet(list[j])) {
|
|
383
|
+
if (left.has(file)) {
|
|
384
|
+
shared = file;
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (shared) return 'parallel tasks "' + list[i].id + '" and "' + list[j].id + '" share "' + shared + '"';
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function productionPathsOutsideTaskList(paths, tasks) {
|
|
395
|
+
const allowed = new Set();
|
|
396
|
+
for (const task of tasks || []) {
|
|
397
|
+
for (const file of taskFileSet(task)) allowed.add(file);
|
|
398
|
+
}
|
|
399
|
+
const outside = [];
|
|
400
|
+
for (const cited of paths || []) {
|
|
401
|
+
const normalized = normalizeRepoPath(cited);
|
|
402
|
+
if (normalized && !allowed.has(normalized)) outside.push(normalized);
|
|
403
|
+
}
|
|
404
|
+
return outside;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function splitMarkdownCells(line) {
|
|
408
|
+
const trimmed = String(line || '').trim();
|
|
409
|
+
if (!trimmed.startsWith('|')) return [];
|
|
410
|
+
const cells = trimmed.split('|').map((cell) => cell.trim());
|
|
411
|
+
if (cells.length && cells[0] === '') cells.shift();
|
|
412
|
+
if (cells.length && cells[cells.length - 1] === '') cells.pop();
|
|
413
|
+
return cells;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function isSeparatorRow(cells) {
|
|
417
|
+
return cells.length > 0 && cells.every((cell) => /^:?-{3,}:?$/.test(cell));
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function pathsFromCell(cell) {
|
|
421
|
+
const text = String(cell || '');
|
|
422
|
+
const found = [];
|
|
423
|
+
const pattern = /`([^`]+)`/g;
|
|
424
|
+
let match = pattern.exec(text);
|
|
425
|
+
while (match) {
|
|
426
|
+
const normalized = normalizeRepoPath(match[1]);
|
|
427
|
+
if (normalized && normalized.includes('/')) found.push(normalized);
|
|
428
|
+
match = pattern.exec(text);
|
|
429
|
+
}
|
|
430
|
+
if (found.length > 0) return found;
|
|
431
|
+
return text.split(',').map((part) => normalizeRepoPath(part)).filter((part) => part.includes('/'));
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function dependsFromCell(cell) {
|
|
435
|
+
const cleaned = String(cell || '').replace(/[`*]/g, '').trim();
|
|
436
|
+
if (!cleaned || cleaned === '—' || cleaned === '-' || cleaned === '–') return [];
|
|
437
|
+
return cleaned.split(/[,|/]/).map((part) => part.trim()).filter((part) => /^[A-Za-z][A-Za-z0-9._-]*$/.test(part));
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function cellIsComplete(cell) {
|
|
441
|
+
const cleaned = String(cell || '').replace(/[`*[\]]/g, '').trim().toLowerCase();
|
|
442
|
+
return cleaned === 'complete' || cleaned === 'completed' || cleaned === 'done' || cleaned === 'x';
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
function absorbMarkdownTable(block, byId) {
|
|
446
|
+
const rows = [];
|
|
447
|
+
for (const line of block) {
|
|
448
|
+
const cells = splitMarkdownCells(line);
|
|
449
|
+
if (cells.length === 0 || isSeparatorRow(cells)) continue;
|
|
450
|
+
rows.push(cells);
|
|
451
|
+
}
|
|
452
|
+
if (rows.length < 2) return false;
|
|
453
|
+
const headers = rows[0].map((cell) => cell.replace(/[`*]/g, '').trim());
|
|
454
|
+
const idIndex = headers.findIndex((header) => /^id$/i.test(header));
|
|
455
|
+
if (idIndex < 0) return false;
|
|
456
|
+
const dependsIndex = headers.findIndex((header) => /dependson/i.test(header));
|
|
457
|
+
const specIndex = headers.findIndex((header) => /spec files/i.test(header));
|
|
458
|
+
const appIndex = headers.findIndex((header) => /^app files$/i.test(header));
|
|
459
|
+
const filesIndex = headers.findIndex((header, index) => index !== specIndex && index !== appIndex && /files|paths/i.test(header));
|
|
460
|
+
const statusIndex = headers.findIndex((header) => /^(status|done|state)$/i.test(header));
|
|
461
|
+
const sawFiles = specIndex >= 0 || appIndex >= 0 || filesIndex >= 0;
|
|
462
|
+
for (const cells of rows.slice(1)) {
|
|
463
|
+
const id = String(cells[idIndex] || '').replace(/[`*]/g, '').trim();
|
|
464
|
+
if (!id || /^id$/i.test(id)) continue;
|
|
465
|
+
const task = byId.get(id) || { id, dependsOn: [], files: [], specFiles: [], appFiles: [], tracked: false, rowComplete: false };
|
|
466
|
+
if (dependsIndex >= 0) {
|
|
467
|
+
task.dependsOn = dependsFromCell(cells[dependsIndex] || '');
|
|
468
|
+
task.tracked = true;
|
|
469
|
+
}
|
|
470
|
+
if (statusIndex >= 0) task.rowComplete = cellIsComplete(cells[statusIndex] || '');
|
|
471
|
+
if (filesIndex >= 0) {
|
|
472
|
+
const parsed = pathsFromCell(cells[filesIndex] || '');
|
|
473
|
+
if (parsed.length > 0) task.files = parsed;
|
|
474
|
+
}
|
|
475
|
+
if (specIndex >= 0) {
|
|
476
|
+
const parsed = pathsFromCell(cells[specIndex] || '');
|
|
477
|
+
if (parsed.length > 0) task.specFiles = parsed;
|
|
478
|
+
}
|
|
479
|
+
if (appIndex >= 0) {
|
|
480
|
+
const parsed = pathsFromCell(cells[appIndex] || '');
|
|
481
|
+
if (parsed.length > 0) task.appFiles = parsed;
|
|
482
|
+
}
|
|
483
|
+
byId.set(id, task);
|
|
484
|
+
}
|
|
485
|
+
return sawFiles;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function parseDecompositionTaskFileLists(markdown) {
|
|
489
|
+
const lines = String(markdown || '').split(/\r?\n/);
|
|
490
|
+
const byId = new Map();
|
|
491
|
+
let hasFileColumn = false;
|
|
492
|
+
let index = 0;
|
|
493
|
+
while (index < lines.length) {
|
|
494
|
+
if (!String(lines[index] || '').trim().startsWith('|')) {
|
|
495
|
+
index += 1;
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
const block = [];
|
|
499
|
+
while (index < lines.length && String(lines[index] || '').trim().startsWith('|')) {
|
|
500
|
+
block.push(lines[index]);
|
|
501
|
+
index += 1;
|
|
502
|
+
}
|
|
503
|
+
if (absorbMarkdownTable(block, byId)) hasFileColumn = true;
|
|
504
|
+
}
|
|
505
|
+
return { tasks: [...byId.values()], hasFileColumn };
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
function parseDecompositionTasks(markdown) {
|
|
509
|
+
const lines = String(markdown || '').split(/\r?\n/);
|
|
510
|
+
const byId = new Map();
|
|
511
|
+
let index = 0;
|
|
512
|
+
while (index < lines.length) {
|
|
513
|
+
if (!String(lines[index] || '').trim().startsWith('|')) {
|
|
514
|
+
index += 1;
|
|
515
|
+
continue;
|
|
516
|
+
}
|
|
517
|
+
const block = [];
|
|
518
|
+
while (index < lines.length && String(lines[index] || '').trim().startsWith('|')) {
|
|
519
|
+
block.push(lines[index]);
|
|
520
|
+
index += 1;
|
|
521
|
+
}
|
|
522
|
+
absorbMarkdownTable(block, byId);
|
|
523
|
+
}
|
|
524
|
+
return [...byId.values()].filter((task) => task.tracked === true);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
function taskCoveredByCompletedArtifact(taskId, artifacts) {
|
|
528
|
+
const id = String(taskId);
|
|
529
|
+
const list = Array.isArray(artifacts) ? artifacts : [];
|
|
530
|
+
for (let index = 0; index < list.length; index += 1) {
|
|
531
|
+
const artifact = list[index];
|
|
532
|
+
if (!artifact || artifact.status !== 'completed') continue;
|
|
533
|
+
if (String(artifact.id) === id) return true;
|
|
534
|
+
const taskIds = Array.isArray(artifact.taskIds) ? artifact.taskIds : [];
|
|
535
|
+
for (let taskIndex = 0; taskIndex < taskIds.length; taskIndex += 1) {
|
|
536
|
+
if (String(taskIds[taskIndex]) === id) return true;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return false;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
function computeDecompositionReadySet(tasks, artifacts) {
|
|
543
|
+
const list = (Array.isArray(tasks) ? tasks : []).filter((task) => task && task.id && task.tracked !== false);
|
|
544
|
+
const complete = new Set();
|
|
545
|
+
for (let index = 0; index < list.length; index += 1) {
|
|
546
|
+
const task = list[index];
|
|
547
|
+
if (task.rowComplete === true || taskCoveredByCompletedArtifact(task.id, artifacts)) complete.add(String(task.id));
|
|
548
|
+
}
|
|
549
|
+
const ready = [];
|
|
550
|
+
const blocked = [];
|
|
551
|
+
for (let index = 0; index < list.length; index += 1) {
|
|
552
|
+
const task = list[index];
|
|
553
|
+
const id = String(task.id);
|
|
554
|
+
if (complete.has(id)) continue;
|
|
555
|
+
const deps = Array.isArray(task.dependsOn) ? task.dependsOn.map((dep) => String(dep)) : [];
|
|
556
|
+
const waiting = [];
|
|
557
|
+
const seen = new Set();
|
|
558
|
+
for (let depIndex = 0; depIndex < deps.length; depIndex += 1) {
|
|
559
|
+
const dep = deps[depIndex];
|
|
560
|
+
if (!dep || seen.has(dep) || complete.has(dep)) continue;
|
|
561
|
+
seen.add(dep);
|
|
562
|
+
waiting.push(dep);
|
|
563
|
+
}
|
|
564
|
+
if (waiting.length === 0) ready.push(id);
|
|
565
|
+
else blocked.push({ id, waiting_on: waiting });
|
|
566
|
+
}
|
|
567
|
+
return { ready, blocked };
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
function readManifestArtifacts(dir) {
|
|
571
|
+
try {
|
|
572
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(dir, 'artifact-manifest.json'), 'utf8'));
|
|
573
|
+
return Array.isArray(manifest.artifacts) ? manifest.artifacts : [];
|
|
574
|
+
} catch {
|
|
575
|
+
return [];
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
function readDecompositionReadySet(dir) {
|
|
580
|
+
let markdown = '';
|
|
581
|
+
try {
|
|
582
|
+
markdown = fs.readFileSync(path.join(dir, 'decomposition.md'), 'utf8');
|
|
583
|
+
} catch {
|
|
584
|
+
markdown = '';
|
|
585
|
+
}
|
|
586
|
+
return computeDecompositionReadySet(parseDecompositionTasks(markdown), readManifestArtifacts(dir));
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
function formatDecompositionReadyClause(report, stepsForRows) {
|
|
590
|
+
const source = report && typeof report === 'object' ? report : { ready: [], blocked: [] };
|
|
591
|
+
const stepList = Array.isArray(stepsForRows) ? stepsForRows : [];
|
|
592
|
+
const allow = [];
|
|
593
|
+
for (let index = 0; index < stepList.length; index += 1) {
|
|
594
|
+
const taskIds = stepList[index] && stepList[index].taskIds;
|
|
595
|
+
if (!Array.isArray(taskIds)) continue;
|
|
596
|
+
for (let idIndex = 0; idIndex < taskIds.length; idIndex += 1) {
|
|
597
|
+
if (taskIds[idIndex] != null && String(taskIds[idIndex])) allow.push(String(taskIds[idIndex]));
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
const gate = allow.length > 0 ? new Set(allow) : null;
|
|
601
|
+
const ready = (Array.isArray(source.ready) ? source.ready : []).filter((id) => !gate || gate.has(String(id)));
|
|
602
|
+
const blocked = (Array.isArray(source.blocked) ? source.blocked : []).filter((row) => row && (!gate || gate.has(String(row.id))));
|
|
603
|
+
const readyText = ready.length > 0 ? ready.join(', ') : '(none)';
|
|
604
|
+
let text = ' Decomposition ready set: ' + readyText + '.';
|
|
605
|
+
if (blocked.length > 0) {
|
|
606
|
+
const parts = [];
|
|
607
|
+
for (let index = 0; index < blocked.length; index += 1) {
|
|
608
|
+
const row = blocked[index];
|
|
609
|
+
const waiting = Array.isArray(row.waiting_on) ? row.waiting_on.join(', ') : '';
|
|
610
|
+
parts.push(String(row.id) + ' waiting_on ' + waiting);
|
|
611
|
+
}
|
|
612
|
+
text += ' Blocked: ' + parts.join('; ') + '.';
|
|
613
|
+
}
|
|
614
|
+
return text;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
function decompositionReadyClause(stepsForRows) {
|
|
618
|
+
try {
|
|
619
|
+
return formatDecompositionReadyClause(readDecompositionReadySet(taskDir), stepsForRows);
|
|
620
|
+
} catch {
|
|
621
|
+
return ' Decomposition ready set: (none).';
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
function productionCitationRepoPath(cited) {
|
|
626
|
+
const value = typeof cited === 'string' ? cited.trim() : '';
|
|
627
|
+
if (!value) return null;
|
|
628
|
+
const normalized = value.replace(/\\/g, '/');
|
|
629
|
+
if (path.isAbsolute(normalized)) {
|
|
630
|
+
const fromCwd = path.relative(process.cwd(), normalized);
|
|
631
|
+
if (fromCwd && !fromCwd.startsWith('..') && !path.isAbsolute(fromCwd)) return normalizeRepoPath(fromCwd);
|
|
632
|
+
return normalizeRepoPath(normalized) || normalized;
|
|
633
|
+
}
|
|
634
|
+
const taskResolved = path.resolve(taskDir, normalized);
|
|
635
|
+
const taskRelative = path.relative(taskDir, taskResolved);
|
|
636
|
+
const insideTask = taskRelative !== '' && taskRelative !== '..' && !taskRelative.startsWith('..' + path.sep) && !path.isAbsolute(taskRelative);
|
|
637
|
+
if (insideTask) {
|
|
638
|
+
try {
|
|
639
|
+
if (fs.statSync(taskResolved).isFile()) return null;
|
|
640
|
+
} catch {}
|
|
641
|
+
}
|
|
642
|
+
return normalizeRepoPath(normalized);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
function implementingStepForTaskIds(taskIds) {
|
|
646
|
+
if (!Array.isArray(steps) || taskIds.length === 0) return null;
|
|
647
|
+
return steps.find((step) => Array.isArray(step && step.taskIds) && taskIds.some((id) => step.taskIds.map((item) => String(item)).includes(String(id)))) || null;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
function productionWriteListError(entry) {
|
|
651
|
+
const artifactId = entry && entry.id ? entry.id : '(unnamed)';
|
|
652
|
+
const resume = 'Then resume with: /task-continue ' + slug;
|
|
653
|
+
const fail = (detail) => '[chain-team-phases] ' + slug + ': receipt "' + artifactId + '" ' + detail + ' ' + resume;
|
|
654
|
+
try {
|
|
655
|
+
const evidence = entry && Array.isArray(entry.evidencePaths) ? entry.evidencePaths : [];
|
|
656
|
+
const production = [];
|
|
657
|
+
for (const cited of evidence) {
|
|
658
|
+
const repoPath = productionCitationRepoPath(cited);
|
|
659
|
+
if (repoPath) production.push(repoPath);
|
|
660
|
+
}
|
|
661
|
+
if (production.length === 0) return null;
|
|
662
|
+
let markdown = '';
|
|
663
|
+
try {
|
|
664
|
+
markdown = fs.readFileSync(path.join(taskDir, 'decomposition.md'), 'utf8');
|
|
665
|
+
} catch {
|
|
666
|
+
markdown = '';
|
|
667
|
+
}
|
|
668
|
+
const parsed = parseDecompositionTaskFileLists(markdown);
|
|
669
|
+
if (!parsed.hasFileColumn) return null;
|
|
670
|
+
const tasks = parsed.tasks;
|
|
671
|
+
const taskIds = Array.isArray(entry && entry.taskIds) ? entry.taskIds.map((id) => String(id)) : [];
|
|
672
|
+
const step = implementingStepForTaskIds(taskIds);
|
|
673
|
+
const selectedIds = new Set(taskIds);
|
|
674
|
+
if (step && Array.isArray(step.taskIds)) {
|
|
675
|
+
for (const id of step.taskIds) selectedIds.add(String(id));
|
|
676
|
+
}
|
|
677
|
+
const selected = tasks.filter((task) => selectedIds.has(String(task.id)));
|
|
678
|
+
if (selected.length === 0) {
|
|
679
|
+
return fail('cites production paths but decomposition.md has no file list for ' + (taskIds.join(', ') || '(none)') + '. Record the task file list.');
|
|
680
|
+
}
|
|
681
|
+
const writeScopes = step && Array.isArray(step.writeScopes) ? step.writeScopes : [];
|
|
682
|
+
const listError = validateTaskFileLists(selected, writeScopes);
|
|
683
|
+
if (listError) return fail(listError + '.');
|
|
684
|
+
const owned = selected.filter((task) => taskIds.includes(String(task.id)));
|
|
685
|
+
const citedAgainst = owned.length > 0 ? owned : selected;
|
|
686
|
+
const outside = productionPathsOutsideTaskList(production, citedAgainst);
|
|
687
|
+
if (outside.length > 0) {
|
|
688
|
+
const ids = taskIds.length > 0 ? taskIds.join(', ') : citedAgainst.map((task) => task.id).join(', ');
|
|
689
|
+
return fail('cites production path "' + outside[0] + '", which is not on the decomposition file list for ' + ids + '.');
|
|
690
|
+
}
|
|
691
|
+
return null;
|
|
692
|
+
} catch (error) {
|
|
693
|
+
return fail('production file-list check failed (' + (error && error.message ? error.message : error) + ').');
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
// A2: a `completed` receipt must cite evidence the harness can inspect. Order is
|
|
698
|
+
// the message order — the first failing predicate wins, so the operator sees one
|
|
699
|
+
// actionable line. `authoritativePaths[]` stays task-dir-relative; external
|
|
700
|
+
// references belong in `evidencePaths[]`. The task-folder checks below stay in
|
|
701
|
+
// place. A later production evidencePaths check uses the decomposition file list
|
|
702
|
+
// only when that list column exists.
|
|
703
|
+
function validateCompletedArtifact(entry) {
|
|
704
|
+
const artifactId = entry && entry.id ? entry.id : '(unnamed)';
|
|
705
|
+
const entryStatus = entry && entry.status;
|
|
706
|
+
if (entryStatus !== 'completed') {
|
|
707
|
+
return `[chain-team-phases] ${slug}: receipt "${artifactId}" has receipt.outcome "completed" but entry status "${entryStatus}". Make entry.status and receipt.outcome agree, then resume with: /task-continue ${slug}`;
|
|
708
|
+
}
|
|
709
|
+
const authoritativePaths = entry && Array.isArray(entry.authoritativePaths) ? entry.authoritativePaths : [];
|
|
710
|
+
if (authoritativePaths.length === 0) {
|
|
711
|
+
return `[chain-team-phases] ${slug}: receipt "${artifactId}" is "completed" but authoritativePaths[] is empty. Record at least one file you produced under .ai.local/team/tasks/${slug}/, then resume with: /task-continue ${slug}`;
|
|
712
|
+
}
|
|
713
|
+
for (const cited of authoritativePaths) {
|
|
714
|
+
const value = typeof cited === 'string' ? cited.trim() : '';
|
|
715
|
+
const resolvedPath = value ? path.resolve(taskDir, value) : taskDir;
|
|
716
|
+
const relative = path.relative(taskDir, resolvedPath);
|
|
717
|
+
const escapes = !value || path.isAbsolute(value) || relative === '' || relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative);
|
|
718
|
+
if (escapes) {
|
|
719
|
+
return `[chain-team-phases] ${slug}: receipt "${artifactId}" cites "${value}", which resolves outside .ai.local/team/tasks/${slug}/ (relative: "${relative}"). Cite a task-relative path; keep external references in evidencePaths[]. Then resume with: /task-continue ${slug}`;
|
|
720
|
+
}
|
|
721
|
+
let stat = null;
|
|
722
|
+
try { stat = fs.statSync(resolvedPath); } catch {}
|
|
723
|
+
if (!stat || !stat.isFile()) {
|
|
724
|
+
return `[chain-team-phases] ${slug}: receipt "${artifactId}" cites "${value}" but no such file exists under .ai.local/team/tasks/${slug}/. Write the file, then resume with: /task-continue ${slug}`;
|
|
725
|
+
}
|
|
726
|
+
if (/\.md[c]?$/i.test(value)) {
|
|
727
|
+
let content = '';
|
|
728
|
+
try { content = fs.readFileSync(resolvedPath, 'utf8'); } catch {}
|
|
729
|
+
if (!/\S/.test(content)) {
|
|
730
|
+
return `[chain-team-phases] ${slug}: receipt "${artifactId}" is "completed" but authoritative path "${value}" has no non-whitespace content. Produce the artifact, then resume with: /task-continue ${slug}`;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
const productionListError = productionWriteListError(entry);
|
|
735
|
+
if (productionListError) return productionListError;
|
|
736
|
+
return null;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
function readBoundReceiptOutcome(agent, step, resolved) {
|
|
740
|
+
if (!agent || !resolved) return { outcome: null, receiptRequired: false };
|
|
741
|
+
const manifestPath = path.join(taskDir, 'artifact-manifest.json');
|
|
742
|
+
const expectedOutputId = artifactOutputIdFor(step, agent);
|
|
743
|
+
if (!fs.existsSync(manifestPath)) {
|
|
744
|
+
// A1: absent manifest + a parsed modern pipeline denies silent advancement.
|
|
745
|
+
// Legacy/step-less pipelines keep their previous behaviour (legacyFlow owns them).
|
|
746
|
+
if (!(Array.isArray(steps) && steps.length > 0)) return { outcome: null, receiptRequired: false };
|
|
747
|
+
const seeded = writeSkeletonManifest(manifestPath);
|
|
748
|
+
const stepIndex = typeof resolved.entry.stepIndex === 'number' ? resolved.entry.stepIndex : 0;
|
|
749
|
+
if (seeded) {
|
|
750
|
+
return { outcome: null, receiptRequired: true, stallMessage: `[chain-team-phases] ${slug}: artifact-manifest.json is missing and the skeleton could not be written (${seeded}). Create it with "node .ai.local/scripts/manifest.mjs init --slug ${slug}", then merge the receipt for artifactOutputId "${expectedOutputId}" with "node .ai.local/scripts/manifest.mjs upsert --slug ${slug} --id ${expectedOutputId} --producer ${agent} --outcome completed --paths <artifact>.md" (whole-file merge; never patch the JSON), then resume with: /task-continue ${slug}` };
|
|
751
|
+
}
|
|
752
|
+
return { outcome: null, receiptRequired: true, stallMessage: `[chain-team-phases] ${slug}: no artifact-manifest.json for step ${stepIndex} (${agent}). Wrote a skeleton {schemaVersion:1, slug, artifacts:[]}. Expected artifactOutputId "${expectedOutputId}". Write the artifact, then merge its receipt with "node .ai.local/scripts/manifest.mjs upsert --slug ${slug} --id ${expectedOutputId} --producer ${agent} --outcome completed --paths <artifact>.md" (whole-file merge; never patch the JSON), then resume with: /task-continue ${slug}` };
|
|
753
|
+
}
|
|
754
|
+
try {
|
|
755
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
756
|
+
// Guard: the schema key is `artifacts` (see agent-artifact-contracts.md). A top-level
|
|
757
|
+
// `entries` key is a silent bug — producer wrote to a wrong field, hook would not
|
|
758
|
+
// see the receipt, and the step hangs in `awaiting_artifact_receipt`. Warn loudly.
|
|
759
|
+
if (manifest && typeof manifest === 'object' && !Array.isArray(manifest.artifacts) && Array.isArray(manifest.entries)) {
|
|
760
|
+
process.stderr.write(`WARNING: ${manifestPath} has top-level "entries" but no "artifacts" array; reading only "artifacts" per schema. The producer likely upserted into the wrong key. See agent-artifact-contracts.md (Schema field name).` + '\n');
|
|
761
|
+
} else if (manifest && typeof manifest === 'object' && Array.isArray(manifest.entries) && Array.isArray(manifest.artifacts)) {
|
|
762
|
+
process.stderr.write(`WARNING: ${manifestPath} has both "artifacts" and "entries" keys; reading only "artifacts" per schema. Foreign "entries" content is ignored.` + '\n');
|
|
763
|
+
}
|
|
764
|
+
const artifacts = Array.isArray(manifest.artifacts) ? manifest.artifacts : [];
|
|
765
|
+
const attemptStartedAt = Date.parse(resolved.entry.startedAt);
|
|
766
|
+
// Pre-scan: warn on the silent-bug classes the filter below would otherwise drop.
|
|
767
|
+
// A receipt with a non-matching attemptId is dropped silently; without this warning,
|
|
768
|
+
// the step hangs in `awaiting_artifact_receipt` with no signal of why. Same for
|
|
769
|
+
// receipts whose terminal timestamp is older than the active attempt (stale retry).
|
|
770
|
+
const activeIds = new Set(Object.keys(status.activeAttempts || {}));
|
|
771
|
+
for (const entry of artifacts) {
|
|
772
|
+
if (!entry || entry.producer !== agent || !entry.receipt || typeof entry.receipt.outcome !== 'string') continue;
|
|
773
|
+
const rid = entry.receipt.attemptId;
|
|
774
|
+
if (typeof rid === 'string' && rid !== resolved.attemptId && !activeIds.has(rid)) {
|
|
775
|
+
process.stderr.write(`WARNING: ${manifestPath} receipt for producer "${agent}" id "${entry.id}" carries attemptId "${rid}" that does not match the active attempt "${resolved.attemptId}". The receipt is being dropped; step will hang in \`awaiting_artifact_receipt\` unless the producer retries. Common cause: agent reused an attemptId from a prior failed attempt. See agent-artifact-contracts.md (Receipt binding).` + '\n');
|
|
776
|
+
}
|
|
777
|
+
const terminalAt = Date.parse(entry.timestamps?.completedAt || entry.timestamps?.updatedAt || '');
|
|
778
|
+
if (Number.isFinite(attemptStartedAt) && Number.isFinite(terminalAt) && terminalAt < attemptStartedAt) {
|
|
779
|
+
process.stderr.write(`WARNING: ${manifestPath} receipt for producer "${agent}" id "${entry.id}" has timestamps.completedAt older than the active attempt's startedAt. Likely a stale receipt from a previous attempt; it is being dropped. See agent-artifact-contracts.md (Receipt binding).` + '\n');
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
const owned = artifacts
|
|
783
|
+
.filter((entry) => {
|
|
784
|
+
if (!entry || entry.producer !== agent || !entry.receipt || typeof entry.receipt.outcome !== 'string') return false;
|
|
785
|
+
const boundByAttempt = typeof entry.receipt.attemptId === 'string' && entry.receipt.attemptId === resolved.attemptId;
|
|
786
|
+
const boundByOutput = entry.receipt.attemptId == null && entry.id === expectedOutputId;
|
|
787
|
+
if (!boundByAttempt && !boundByOutput) return false;
|
|
788
|
+
const terminalAt = Date.parse(entry.timestamps?.completedAt || entry.timestamps?.updatedAt || '');
|
|
789
|
+
return Number.isFinite(terminalAt) && (!Number.isFinite(attemptStartedAt) || terminalAt >= attemptStartedAt);
|
|
790
|
+
})
|
|
791
|
+
.sort((a, b) => {
|
|
792
|
+
const ta = Date.parse(a.timestamps?.completedAt || a.timestamps?.updatedAt || 0) || 0;
|
|
793
|
+
const tb = Date.parse(b.timestamps?.completedAt || b.timestamps?.updatedAt || 0) || 0;
|
|
794
|
+
return tb - ta;
|
|
795
|
+
});
|
|
796
|
+
// Bonus: warn if the active attempt's receipts all lack attemptId in a non-parallel step.
|
|
797
|
+
// The orchestrator always provides attemptId, so a missing one means the agent dropped it
|
|
798
|
+
// (model output, JSON.stringify omission, etc.). boundByOutput still binds the receipt by
|
|
799
|
+
// expectedOutputId, so this is not fatal — but it is a contract violation worth flagging.
|
|
800
|
+
if (owned.length > 0 && owned[0].receipt.attemptId == null && !(step && step.parallel && Array.isArray(getStepAgents(step)) && getStepAgents(step).length > 1)) {
|
|
801
|
+
process.stderr.write(`WARNING: ${manifestPath} receipt for producer "${agent}" id "${owned[0].id}" lacks entry.receipt.attemptId on a non-parallel step. The receipt is bound by output-id fallback; the agent should always include the attemptId the orchestrator provides. See agent-artifact-contracts.md (Receipt binding).` + '\n');
|
|
802
|
+
}
|
|
803
|
+
const outcome = owned[0]?.receipt?.outcome || null;
|
|
804
|
+
const bound = owned[0];
|
|
805
|
+
if (bound && typeof bound.status === 'string' && !ARTIFACT_STATUSES.includes(bound.status)) {
|
|
806
|
+
const expected = RECEIPT_OUTCOME_STATUS[bound.receipt.outcome] || 'blocked';
|
|
807
|
+
return { outcome: null, receiptRequired: true, stallMessage: `[chain-team-phases] ${slug}: receipt "${bound.id}" has artifact status "${bound.status}", which is not one of ${ARTIFACT_STATUSES.join(' | ')}. A receipt outcome is not a status — rewrite the entry with "node .ai.local/scripts/manifest.mjs upsert --slug ${slug} --id ${bound.id} --producer ${agent} --status ${expected} --outcome ${bound.receipt.outcome} --paths <artifact>.md", then resume with: /task-continue ${slug}` };
|
|
808
|
+
}
|
|
809
|
+
if (outcome === 'completed') {
|
|
810
|
+
const stallMessage = validateCompletedArtifact(owned[0]);
|
|
811
|
+
if (stallMessage) return { outcome: null, receiptRequired: true, stallMessage };
|
|
812
|
+
}
|
|
813
|
+
return { outcome, receiptRequired: true };
|
|
814
|
+
} catch {
|
|
815
|
+
return { outcome: null, receiptRequired: false };
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
function reconcileStatusFromManifest(agent, step, resolved) {
|
|
819
|
+
const terminal = new Set(['completed', 'blocked', 'changes_requested', 'validation_failed']);
|
|
820
|
+
artifactStallMessage = null;
|
|
821
|
+
const { outcome, receiptRequired, stallMessage } = readBoundReceiptOutcome(agent, step, resolved);
|
|
822
|
+
if (terminal.has(outcome)) {
|
|
823
|
+
status.state = outcome;
|
|
824
|
+
return outcome;
|
|
825
|
+
}
|
|
826
|
+
if (receiptRequired) {
|
|
827
|
+
artifactStallMessage = stallMessage || null;
|
|
828
|
+
status.state = 'awaiting_artifact_receipt';
|
|
829
|
+
status.phase = 'blocked';
|
|
830
|
+
return status.state;
|
|
831
|
+
}
|
|
832
|
+
if (terminal.has(status.state)) return status.state;
|
|
833
|
+
// Host reported subagent completed and no blocking receipt → treat as completed for metrics/advance.
|
|
834
|
+
if (hookInput.status === 'completed') {
|
|
835
|
+
status.state = 'completed';
|
|
836
|
+
return 'completed';
|
|
837
|
+
}
|
|
838
|
+
return status.state;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
function finishActiveAttempt(forced) {
|
|
842
|
+
const resolved = forced || resolvedAttempt(); if (!resolved) return null;
|
|
843
|
+
const durationMs = Date.parse(now) - Date.parse(resolved.entry.startedAt);
|
|
844
|
+
const outcome = ['completed', 'blocked', 'changes_requested', 'validation_failed'].includes(status.state) ? status.state : 'unknown';
|
|
845
|
+
appendMetric({ type: 'attempt_finished', at: now, attemptId: resolved.attemptId, outcome, durationMs: Number.isFinite(durationMs) && durationMs >= 0 ? durationMs : null, retryAfterFix: status.retryAfterFix || null, source: resolved.source || 'hook', attributionConfidence: resolved.confidence });
|
|
846
|
+
const active = { ...(status.activeAttempts || {}) }; delete active[resolved.attemptId]; status.activeAttempts = active; status.lastCompletedAttempt = { attemptId: resolved.attemptId, completedAt: now }; return { ...resolved, outcome };
|
|
847
|
+
}
|
|
848
|
+
function missingConsumerArtifacts() {
|
|
849
|
+
const file = path.join(process.cwd(), '.ai.local', 'pipeline-gates.json');
|
|
850
|
+
if (!fs.existsSync(file)) return [];
|
|
851
|
+
let parsed;
|
|
852
|
+
try { parsed = JSON.parse(fs.readFileSync(file, 'utf8')); } catch { return []; }
|
|
853
|
+
const required = Array.isArray(parsed && parsed.requireArtifacts) ? parsed.requireArtifacts : [];
|
|
854
|
+
const ids = required.filter((id) => typeof id === 'string' && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(id));
|
|
855
|
+
if (ids.length === 0) return [];
|
|
856
|
+
let manifest = { artifacts: [] };
|
|
857
|
+
try { manifest = JSON.parse(fs.readFileSync(path.join(taskDir, 'artifact-manifest.json'), 'utf8')); } catch {}
|
|
858
|
+
const done = new Set(
|
|
859
|
+
(manifest.artifacts || [])
|
|
860
|
+
.filter((artifact) => artifact && artifact.status === 'completed' && ids.includes(artifact.id))
|
|
861
|
+
.map((artifact) => artifact.id),
|
|
862
|
+
);
|
|
863
|
+
return ids.filter((id) => !done.has(id));
|
|
864
|
+
}
|
|
865
|
+
function completePipeline(statusPatch) {
|
|
866
|
+
const missing = missingConsumerArtifacts();
|
|
867
|
+
if (missing.length > 0) {
|
|
868
|
+
writeStatus({ ...statusPatch, phase: 'blocked', state: 'blocked', currentAgent: null, awaitingHumanGate: false });
|
|
869
|
+
out(`Pipeline blocked for "${slug}": .ai.local/pipeline-gates.json requireArtifacts missing completed receipt(s): ${missing.join(', ')}.`);
|
|
870
|
+
process.exit(0);
|
|
871
|
+
}
|
|
872
|
+
// task_completed is written only on this branch. A missing receipt blocks
|
|
873
|
+
// above and must not be counted as a finished task.
|
|
874
|
+
status.state = 'completed';
|
|
875
|
+
completeTaskMetrics();
|
|
876
|
+
writeStatus(statusPatch);
|
|
877
|
+
out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
|
|
878
|
+
process.exit(0);
|
|
879
|
+
}
|
|
880
|
+
function beginHumanGate() { const eventId = `${status.metricsRunId || slug}:gate:${Date.now()}`; appendMetric({ eventId, type: 'human_gate_started', at: now, source: 'hook', attributionConfidence: 'high' }); status.activeHumanGateEventId = eventId; }
|
|
881
|
+
function endHumanGateIfResumed() {
|
|
882
|
+
if (!status.activeHumanGateEventId || status.awaitingHumanGate || status.state === 'awaiting_approval') return;
|
|
883
|
+
appendMetric({ type: 'human_gate_ended', at: now, gateStartedEventId: status.activeHumanGateEventId, source: 'hook', attributionConfidence: 'high' });
|
|
884
|
+
delete status.activeHumanGateEventId;
|
|
885
|
+
}
|
|
886
|
+
function completeTaskMetrics() {
|
|
887
|
+
// Two hook processes can both enter completion before either writes the
|
|
888
|
+
// event. The metrics lock serializes them; the second sees the first write.
|
|
889
|
+
mutateMetrics((metrics) => {
|
|
890
|
+
if (metrics.events.some((event) => event && event.type === 'task_completed')) return;
|
|
891
|
+
metrics.events.push({
|
|
892
|
+
eventId: `${metrics.task.runId}:${Date.now()}:${Math.random().toString(16).slice(2)}`,
|
|
893
|
+
type: 'task_completed',
|
|
894
|
+
at: now,
|
|
895
|
+
outcome: status.state === 'completed' ? 'completed' : 'unknown',
|
|
896
|
+
source: 'hook',
|
|
897
|
+
attributionConfidence: 'high',
|
|
898
|
+
});
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
function recordSkippedStep(step, stepIndex) {
|
|
902
|
+
for (const agent of getStepAgents(step)) {
|
|
903
|
+
const runId = status.metricsRunId || `${slug}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
904
|
+
status.metricsRunId = runId;
|
|
905
|
+
const attempt = nextAttemptOrdinal(stepIndex, agent);
|
|
906
|
+
appendMetric({ type: 'attempt_skipped', at: now, attemptId: `${runId}:step-${stepIndex}:${agent}:attempt-${attempt}`, stepIndex, stepLabel: step.label || null, agent, role: roleFor(agent), attempt, outcome: 'skipped', source: 'hook', attributionConfidence: 'high' });
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
// Living task files and the hook ledger stay put. A completed entry's other markdown is the body that leaves the default read.
|
|
911
|
+
const CLOSED_BODY_KEEP = new Set([
|
|
912
|
+
'brief.md',
|
|
913
|
+
'decomposition.md',
|
|
914
|
+
'goal.md',
|
|
915
|
+
'prompt.md',
|
|
916
|
+
'prompt-log.md',
|
|
917
|
+
'pipeline.json',
|
|
918
|
+
'implementation.md',
|
|
919
|
+
'.memlog.md',
|
|
920
|
+
'focus.md',
|
|
921
|
+
'status.json',
|
|
922
|
+
'metrics.json',
|
|
923
|
+
'artifact-manifest.json',
|
|
924
|
+
'overlay-scope.json',
|
|
925
|
+
]);
|
|
926
|
+
|
|
927
|
+
function closedMarkdownBody(dir, cited) {
|
|
928
|
+
if (typeof cited !== 'string') return null;
|
|
929
|
+
const value = cited.trim();
|
|
930
|
+
if (!value || path.isAbsolute(value)) return null;
|
|
931
|
+
const resolved = path.resolve(dir, value);
|
|
932
|
+
const relative = path.relative(dir, resolved);
|
|
933
|
+
if (!relative || relative === '..' || relative.startsWith('..' + path.sep) || path.isAbsolute(relative)) return null;
|
|
934
|
+
const normalized = relative.split(path.sep).join('/');
|
|
935
|
+
if (!/\.md$/i.test(normalized) || normalized.startsWith('archive/')) return null;
|
|
936
|
+
const base = normalized.slice(normalized.lastIndexOf('/') + 1);
|
|
937
|
+
if (CLOSED_BODY_KEEP.has(base) || CLOSED_BODY_KEEP.has(normalized)) return null;
|
|
938
|
+
return { resolved, base };
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
function archiveClosedBody(dir, date, id, body) {
|
|
942
|
+
const archiveDir = path.join(dir, 'archive', date);
|
|
943
|
+
fs.mkdirSync(archiveDir, { recursive: true });
|
|
944
|
+
let name = body.base;
|
|
945
|
+
let destination = path.join(archiveDir, name);
|
|
946
|
+
if (fs.existsSync(destination)) {
|
|
947
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(id)) return null;
|
|
948
|
+
name = id + '--' + body.base;
|
|
949
|
+
destination = path.join(archiveDir, name);
|
|
950
|
+
}
|
|
951
|
+
if (fs.existsSync(destination)) return null;
|
|
952
|
+
fs.renameSync(body.resolved, destination);
|
|
953
|
+
return 'archive/' + date + '/' + name;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
function appendMemlogEvent(dir, text) {
|
|
957
|
+
const memlogPath = path.join(dir, '.memlog.md');
|
|
958
|
+
const line = '- `event`: ' + text + '\n';
|
|
959
|
+
let existing = '';
|
|
960
|
+
try { existing = fs.readFileSync(memlogPath, 'utf8'); } catch { existing = ''; }
|
|
961
|
+
if (existing.includes(text)) return existing;
|
|
962
|
+
const prefix = existing.length > 0 && !existing.endsWith('\n') ? '\n' : '';
|
|
963
|
+
fs.appendFileSync(memlogPath, prefix + line);
|
|
964
|
+
return existing + prefix + line;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
function writeJsonFile(filePath, value) {
|
|
968
|
+
const temporary = filePath + '.' + String(process.pid) + '.tmp';
|
|
969
|
+
const fd = fs.openSync(temporary, 'w');
|
|
970
|
+
try {
|
|
971
|
+
fs.writeSync(fd, JSON.stringify(value, null, 2) + '\n');
|
|
972
|
+
} finally {
|
|
973
|
+
fs.closeSync(fd);
|
|
974
|
+
}
|
|
975
|
+
fs.renameSync(temporary, filePath);
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
function compactClosedManifestBodies(dir, closedOn) {
|
|
979
|
+
const date = typeof closedOn === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(closedOn)
|
|
980
|
+
? closedOn
|
|
981
|
+
: new Date().toISOString().slice(0, 10);
|
|
982
|
+
const manifestPath = path.join(dir, 'artifact-manifest.json');
|
|
983
|
+
let manifest;
|
|
984
|
+
try {
|
|
985
|
+
manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
986
|
+
} catch {
|
|
987
|
+
return { moved: [] };
|
|
988
|
+
}
|
|
989
|
+
const slugBefore = manifest.slug;
|
|
990
|
+
const artifacts = Array.isArray(manifest.artifacts) ? manifest.artifacts : [];
|
|
991
|
+
let memlog = '';
|
|
992
|
+
try { memlog = fs.readFileSync(path.join(dir, '.memlog.md'), 'utf8'); } catch { memlog = ''; }
|
|
993
|
+
let manifestChanged = false;
|
|
994
|
+
const moved = [];
|
|
995
|
+
for (let index = 0; index < artifacts.length; index += 1) {
|
|
996
|
+
const entry = artifacts[index];
|
|
997
|
+
if (!entry || entry.status !== 'completed' || typeof entry.id !== 'string' || !entry.id) continue;
|
|
998
|
+
const marker = 'closed manifest artifact ' + entry.id + ';';
|
|
999
|
+
if (memlog.includes(marker)) continue;
|
|
1000
|
+
const cited = Array.isArray(entry.authoritativePaths) ? entry.authoritativePaths.slice() : [];
|
|
1001
|
+
const relocated = [];
|
|
1002
|
+
for (let pathIndex = 0; pathIndex < cited.length; pathIndex += 1) {
|
|
1003
|
+
const body = closedMarkdownBody(dir, cited[pathIndex]);
|
|
1004
|
+
if (!body) continue;
|
|
1005
|
+
let stat = null;
|
|
1006
|
+
try { stat = fs.statSync(body.resolved); } catch { stat = null; }
|
|
1007
|
+
if (!stat || !stat.isFile()) continue;
|
|
1008
|
+
let content = '';
|
|
1009
|
+
try { content = fs.readFileSync(body.resolved, 'utf8'); } catch { content = ''; }
|
|
1010
|
+
if (!/\S/.test(content)) continue;
|
|
1011
|
+
const archived = archiveClosedBody(dir, date, entry.id, body);
|
|
1012
|
+
if (!archived) continue;
|
|
1013
|
+
cited[pathIndex] = archived;
|
|
1014
|
+
relocated.push(archived);
|
|
1015
|
+
moved.push(archived);
|
|
1016
|
+
manifestChanged = true;
|
|
1017
|
+
}
|
|
1018
|
+
if (relocated.length > 0) entry.authoritativePaths = cited;
|
|
1019
|
+
let archiveHint = relocated.length > 0 ? 'archive/' + date + '/' : '';
|
|
1020
|
+
if (!archiveHint) {
|
|
1021
|
+
for (let pathIndex = 0; pathIndex < cited.length; pathIndex += 1) {
|
|
1022
|
+
const value = typeof cited[pathIndex] === 'string' ? cited[pathIndex].trim() : '';
|
|
1023
|
+
const match = /^archive\/\d{4}-\d{2}-\d{2}\//.exec(value);
|
|
1024
|
+
if (match) {
|
|
1025
|
+
archiveHint = match[0];
|
|
1026
|
+
break;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
const text = archiveHint
|
|
1031
|
+
? 'closed manifest artifact ' + entry.id + '; body archived under ' + archiveHint
|
|
1032
|
+
: 'closed manifest artifact ' + entry.id + '; no bulky markdown body moved';
|
|
1033
|
+
memlog = appendMemlogEvent(dir, text);
|
|
1034
|
+
}
|
|
1035
|
+
if (manifest.slug !== slugBefore) manifest.slug = slugBefore;
|
|
1036
|
+
if (manifestChanged) writeJsonFile(manifestPath, manifest);
|
|
1037
|
+
return { moved };
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
function projectResumeArtifact(entry) {
|
|
1041
|
+
if (!entry || typeof entry !== 'object') return entry;
|
|
1042
|
+
if (entry.status !== 'completed') return entry;
|
|
1043
|
+
return {
|
|
1044
|
+
id: entry.id,
|
|
1045
|
+
status: entry.status,
|
|
1046
|
+
authoritativePaths: Array.isArray(entry.authoritativePaths) ? entry.authoritativePaths : [],
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
function defaultResumeRead(dir) {
|
|
1051
|
+
const chunks = [];
|
|
1052
|
+
try { chunks.push(fs.readFileSync(path.join(dir, 'focus.md'), 'utf8')); } catch {}
|
|
1053
|
+
try {
|
|
1054
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(dir, 'artifact-manifest.json'), 'utf8'));
|
|
1055
|
+
const artifacts = Array.isArray(manifest.artifacts) ? manifest.artifacts : [];
|
|
1056
|
+
const projected = [];
|
|
1057
|
+
for (let index = 0; index < artifacts.length; index += 1) {
|
|
1058
|
+
projected.push(projectResumeArtifact(artifacts[index]));
|
|
1059
|
+
}
|
|
1060
|
+
chunks.push(JSON.stringify({ slug: manifest.slug, artifacts: projected }));
|
|
1061
|
+
} catch {}
|
|
1062
|
+
try { chunks.push(fs.readFileSync(path.join(dir, '.memlog.md'), 'utf8')); } catch {}
|
|
1063
|
+
return chunks.join('\n');
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
function archiveIndexLine(dir) {
|
|
1067
|
+
const root = path.join(dir, 'archive');
|
|
1068
|
+
let names = [];
|
|
1069
|
+
try { names = fs.readdirSync(root); } catch { names = []; }
|
|
1070
|
+
const dates = [];
|
|
1071
|
+
for (let index = 0; index < names.length; index += 1) {
|
|
1072
|
+
const name = names[index];
|
|
1073
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(name)) continue;
|
|
1074
|
+
let stat = null;
|
|
1075
|
+
try { stat = fs.statSync(path.join(root, name)); } catch { stat = null; }
|
|
1076
|
+
if (stat && stat.isDirectory()) dates.push(name);
|
|
1077
|
+
}
|
|
1078
|
+
dates.sort();
|
|
1079
|
+
if (dates.length === 0) return '- archive index: (none)';
|
|
1080
|
+
const parts = [];
|
|
1081
|
+
for (let index = 0; index < dates.length; index += 1) parts.push('archive/' + dates[index] + '/');
|
|
1082
|
+
return '- archive index: ' + parts.join(', ');
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
function focusDigestMarkdown(dir, statusSnapshot) {
|
|
1086
|
+
const snapshot = statusSnapshot && typeof statusSnapshot === 'object' ? statusSnapshot : {};
|
|
1087
|
+
const slugValue = typeof snapshot.slug === 'string' ? snapshot.slug : '';
|
|
1088
|
+
const stepIndex = Number.isInteger(snapshot.pipelineIndex) ? snapshot.pipelineIndex : 0;
|
|
1089
|
+
const incomplete = [];
|
|
1090
|
+
try {
|
|
1091
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(dir, 'artifact-manifest.json'), 'utf8'));
|
|
1092
|
+
const artifacts = Array.isArray(manifest.artifacts) ? manifest.artifacts : [];
|
|
1093
|
+
for (let index = 0; index < artifacts.length; index += 1) {
|
|
1094
|
+
const artifact = artifacts[index];
|
|
1095
|
+
if (!artifact || artifact.status === 'completed') continue;
|
|
1096
|
+
const id = typeof artifact.id === 'string' ? artifact.id : '(no id)';
|
|
1097
|
+
const cited = Array.isArray(artifact.authoritativePaths) ? artifact.authoritativePaths : [];
|
|
1098
|
+
const paths = [];
|
|
1099
|
+
for (let pathIndex = 0; pathIndex < cited.length; pathIndex += 1) {
|
|
1100
|
+
if (typeof cited[pathIndex] === 'string') paths.push(cited[pathIndex]);
|
|
1101
|
+
}
|
|
1102
|
+
incomplete.push({ id, paths });
|
|
1103
|
+
}
|
|
1104
|
+
} catch {}
|
|
1105
|
+
let lastEvent = '(none)';
|
|
1106
|
+
try {
|
|
1107
|
+
const raw = fs.readFileSync(path.join(dir, '.memlog.md'), 'utf8');
|
|
1108
|
+
const lines = raw.split(/\r?\n/);
|
|
1109
|
+
const tickEvent = /`event`:\s*(.*)$/;
|
|
1110
|
+
const bareEvent = /(?:^|\s)event:\s*(.*)$/;
|
|
1111
|
+
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
1112
|
+
const line = lines[index];
|
|
1113
|
+
let matched = tickEvent.exec(line);
|
|
1114
|
+
if (!matched) matched = bareEvent.exec(line);
|
|
1115
|
+
if (matched && matched[1].trim()) {
|
|
1116
|
+
lastEvent = matched[1].trim();
|
|
1117
|
+
break;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
} catch {}
|
|
1121
|
+
let nextGate = 'none';
|
|
1122
|
+
if (snapshot.awaitingHumanGate === true || snapshot.state === 'awaiting_approval') {
|
|
1123
|
+
nextGate = 'human gate — /task-continue ' + slugValue;
|
|
1124
|
+
} else {
|
|
1125
|
+
try {
|
|
1126
|
+
const pipeline = JSON.parse(fs.readFileSync(path.join(dir, 'pipeline.json'), 'utf8'));
|
|
1127
|
+
const steps = Array.isArray(pipeline.steps) ? pipeline.steps : [];
|
|
1128
|
+
const gates = Array.isArray(pipeline.humanGates) ? pipeline.humanGates : [];
|
|
1129
|
+
for (let index = stepIndex; index < steps.length; index += 1) {
|
|
1130
|
+
const step = steps[index];
|
|
1131
|
+
const agents = !step ? [] : (Array.isArray(step.agent) ? step.agent : [step.agent]);
|
|
1132
|
+
let hit = '';
|
|
1133
|
+
for (let agentIndex = 0; agentIndex < agents.length; agentIndex += 1) {
|
|
1134
|
+
const agent = agents[agentIndex];
|
|
1135
|
+
if (typeof agent === 'string' && gates.indexOf('after:' + agent) !== -1) {
|
|
1136
|
+
hit = agent;
|
|
1137
|
+
break;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
if (hit) {
|
|
1141
|
+
const stepId = step && typeof step.id === 'string' ? step.id : 'step-' + String(index);
|
|
1142
|
+
nextGate = 'after:' + hit + ' (step ' + stepId + ', index ' + String(index) + ')';
|
|
1143
|
+
break;
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
} catch {}
|
|
1147
|
+
}
|
|
1148
|
+
const pathLines = [];
|
|
1149
|
+
if (incomplete.length === 0) pathLines.push(' - (none)');
|
|
1150
|
+
else {
|
|
1151
|
+
for (let index = 0; index < incomplete.length; index += 1) {
|
|
1152
|
+
const item = incomplete[index];
|
|
1153
|
+
if (item.paths.length === 0) pathLines.push(' - ' + item.id + ': (none)');
|
|
1154
|
+
else {
|
|
1155
|
+
for (let pathIndex = 0; pathIndex < item.paths.length; pathIndex += 1) {
|
|
1156
|
+
pathLines.push(' - ' + item.id + ': ' + item.paths[pathIndex]);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
let readyLine = '- decomposition ready set: (none)';
|
|
1162
|
+
try {
|
|
1163
|
+
const report = readDecompositionReadySet(dir);
|
|
1164
|
+
const ids = Array.isArray(report.ready) ? report.ready : [];
|
|
1165
|
+
readyLine = '- decomposition ready set: ' + (ids.length > 0 ? ids.join(', ') : '(none)');
|
|
1166
|
+
} catch {
|
|
1167
|
+
readyLine = '- decomposition ready set: (none)';
|
|
1168
|
+
}
|
|
1169
|
+
const head = [
|
|
1170
|
+
'# focus.md',
|
|
1171
|
+
'',
|
|
1172
|
+
'View only. `status.json`, `metrics.json`, `artifact-manifest.json`, and `.memlog.md` stay the system of record.',
|
|
1173
|
+
'',
|
|
1174
|
+
'- slug: ' + slugValue,
|
|
1175
|
+
'- pipeline step index: ' + String(stepIndex),
|
|
1176
|
+
readyLine,
|
|
1177
|
+
archiveIndexLine(dir),
|
|
1178
|
+
'- incomplete authoritative paths:',
|
|
1179
|
+
];
|
|
1180
|
+
const tail = [
|
|
1181
|
+
'- last memlog event: ' + lastEvent,
|
|
1182
|
+
'- next gate: ' + nextGate,
|
|
1183
|
+
];
|
|
1184
|
+
let pathBudget = 99 - head.length - tail.length;
|
|
1185
|
+
if (pathBudget < 1) pathBudget = 1;
|
|
1186
|
+
let kept = pathLines;
|
|
1187
|
+
if (pathLines.length > pathBudget) {
|
|
1188
|
+
const room = pathBudget - 1;
|
|
1189
|
+
kept = pathLines.slice(0, room);
|
|
1190
|
+
const omitted = pathLines.length - kept.length;
|
|
1191
|
+
kept.push(' - (' + String(omitted) + ' lines omitted to stay under 100)');
|
|
1192
|
+
}
|
|
1193
|
+
return head.concat(kept, tail).join('\n') + '\n';
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
function writeFocusDigest() {
|
|
1197
|
+
const focusPath = path.join(taskDir, 'focus.md');
|
|
1198
|
+
const temporary = focusPath + '.' + String(process.pid) + '.' + String(Date.now()) + '.tmp';
|
|
1199
|
+
try {
|
|
1200
|
+
const markdown = focusDigestMarkdown(taskDir, status);
|
|
1201
|
+
const fd = fs.openSync(temporary, 'w');
|
|
1202
|
+
try {
|
|
1203
|
+
fs.writeSync(fd, markdown);
|
|
1204
|
+
try { fs.fsyncSync(fd); } catch {}
|
|
1205
|
+
} finally {
|
|
1206
|
+
fs.closeSync(fd);
|
|
1207
|
+
}
|
|
1208
|
+
fs.renameSync(temporary, focusPath);
|
|
1209
|
+
} catch {
|
|
1210
|
+
try { fs.unlinkSync(temporary); } catch {}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
function writeStatus(next) {
|
|
1215
|
+
status = { ...status, ...next, slug, updatedAt: now };
|
|
1216
|
+
const temporary = `${statusPath}.${process.pid}.${Date.now()}.tmp`;
|
|
1217
|
+
// Open + write + fsync + rename so the durable file lands on disk before
|
|
1218
|
+
// the orchestrator reads it. Closes the race window where a subagent that
|
|
1219
|
+
// completed milliseconds before writeStatus() could otherwise invoke the
|
|
1220
|
+
// next step on a stale status (in particular the human-gate write).
|
|
1221
|
+
const fd = fs.openSync(temporary, 'w');
|
|
1222
|
+
try {
|
|
1223
|
+
fs.writeSync(fd, JSON.stringify(status, null, 2) + '\n');
|
|
1224
|
+
try { fs.fsyncSync(fd); } catch {}
|
|
1225
|
+
} finally {
|
|
1226
|
+
fs.closeSync(fd);
|
|
1227
|
+
}
|
|
1228
|
+
fs.renameSync(temporary, statusPath);
|
|
1229
|
+
// Closed bodies move after the checkpoint lands. A compaction miss must not roll status.json back.
|
|
1230
|
+
try { compactClosedManifestBodies(taskDir, now.slice(0, 10)); } catch {}
|
|
1231
|
+
// focus.md is a view of this checkpoint. It is written after status.json
|
|
1232
|
+
// lands so a digest failure cannot roll the checkpoint back.
|
|
1233
|
+
writeFocusDigest();
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
function out(message) {
|
|
1237
|
+
process.stdout.write(JSON.stringify({ followup_message: message }));
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
// The stall text always reaches stderr so a second, different rejection is never
|
|
1241
|
+
// silent; `out()` fires only when the stop enters the stall, so the follow-up
|
|
1242
|
+
// message cannot loop.
|
|
1243
|
+
function emitArtifactStall(message, announce) {
|
|
1244
|
+
if (message) process.stderr.write(message + '\n');
|
|
1245
|
+
if (message && announce) out(message);
|
|
1246
|
+
else process.stdout.write('{}');
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1249
|
+
function readArtifact(name) {
|
|
1250
|
+
const p = path.join(taskDir, name);
|
|
1251
|
+
if (!fs.existsSync(p)) return '';
|
|
1252
|
+
try {
|
|
1253
|
+
return fs.readFileSync(p, 'utf8');
|
|
1254
|
+
} catch {
|
|
1255
|
+
return '';
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
function getStepAgents(step) {
|
|
1260
|
+
if (!step) return [];
|
|
1261
|
+
return Array.isArray(step.agent) ? step.agent : [step.agent];
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
function skipIfMatches(skipIf, dir) {
|
|
1265
|
+
if (!skipIf) return false;
|
|
1266
|
+
if (skipIf === 'debugger.fixed') {
|
|
1267
|
+
const text = readArtifact('debug-report.md');
|
|
1268
|
+
return /fixApplied:\s*true/i.test(text) || /\*\*Fix applied:\*\*\s*true/i.test(text);
|
|
1269
|
+
}
|
|
1270
|
+
if (skipIf === 'ci-investigator.resolved') {
|
|
1271
|
+
const text = readArtifact('ci-report.md');
|
|
1272
|
+
return /fixApplied:\s*true/i.test(text) || /## Verdict\s*\nPASS/i.test(text);
|
|
1273
|
+
}
|
|
1274
|
+
return false;
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
function findNextExecutableStep(steps, startIdx, dir) {
|
|
1278
|
+
for (let i = startIdx; i < steps.length; i++) {
|
|
1279
|
+
if (!skipIfMatches(steps[i].skipIf, dir)) return { step: steps[i], index: i };
|
|
1280
|
+
recordSkippedStep(steps[i], i);
|
|
1281
|
+
}
|
|
1282
|
+
return null;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
// --- Parallel scheduling & conflict model (mirrors _shared/core/agent-team/plan-graph.md) ---
|
|
1286
|
+
function isGraphMode() { return steps.some((step) => step && Array.isArray(step.dependsOn)); }
|
|
1287
|
+
function graphSlotKey(stepIndex, agent) { return `${stepIndex}:${agent}`; }
|
|
1288
|
+
function readJoinedSlots() { return { ...(status.joinedSlots || {}) }; }
|
|
1289
|
+
function isSlotSatisfied(stepIndex, agent) { return Boolean((status.joinedSlots || {})[graphSlotKey(stepIndex, agent)]); }
|
|
1290
|
+
function resolveStepIndex(dep) {
|
|
1291
|
+
for (let i = 0; i < steps.length; i += 1) if (steps[i] && steps[i].id === dep) return i;
|
|
1292
|
+
for (let i = 0; i < steps.length; i += 1) {
|
|
1293
|
+
const ids = Array.isArray(steps[i]?.taskIds) ? steps[i].taskIds : [];
|
|
1294
|
+
if (ids.includes(dep)) return i;
|
|
1295
|
+
}
|
|
1296
|
+
return -1;
|
|
1297
|
+
}
|
|
1298
|
+
function isStepSkipped(stepIndex) {
|
|
1299
|
+
if (Array.isArray(status.skippedSteps) && status.skippedSteps.includes(stepIndex)) return true;
|
|
1300
|
+
return skipIfMatches(steps[stepIndex]?.skipIf, taskDir);
|
|
1301
|
+
}
|
|
1302
|
+
function isStepSatisfied(stepIndex) {
|
|
1303
|
+
const step = steps[stepIndex];
|
|
1304
|
+
if (!step) return false;
|
|
1305
|
+
if (isStepSkipped(stepIndex)) return true;
|
|
1306
|
+
return getStepAgents(step).every((agent) => isSlotSatisfied(stepIndex, agent));
|
|
1307
|
+
}
|
|
1308
|
+
function pendingStepIndexes() { return steps.map((_, index) => index).filter((index) => !isStepSatisfied(index)); }
|
|
1309
|
+
function unsatisfiedAgents(stepIndex) {
|
|
1310
|
+
const step = steps[stepIndex];
|
|
1311
|
+
if (!step) return [];
|
|
1312
|
+
return getStepAgents(step).filter((agent) => !isSlotSatisfied(stepIndex, agent));
|
|
1313
|
+
}
|
|
1314
|
+
function declaredScopes(step) {
|
|
1315
|
+
return Array.isArray(step?.writeScopes) ? step.writeScopes.filter((scope) => typeof scope === 'string' && scope.length > 0) : [];
|
|
1316
|
+
}
|
|
1317
|
+
function normalizeScope(scope) { return String(scope).replace(/\/+$/, ''); }
|
|
1318
|
+
function scopesOverlap(left, right) {
|
|
1319
|
+
const a = normalizeScope(left); const b = normalizeScope(right);
|
|
1320
|
+
return a === b || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);
|
|
1321
|
+
}
|
|
1322
|
+
function stepsConflict(leftIndex, rightIndex) {
|
|
1323
|
+
if (leftIndex === rightIndex) return true;
|
|
1324
|
+
const leftStep = steps[leftIndex]; const rightStep = steps[rightIndex];
|
|
1325
|
+
const leftAgents = getStepAgents(leftStep); const rightAgents = getStepAgents(rightStep);
|
|
1326
|
+
if (leftAgents.some((agent) => rightAgents.includes(agent))) return true;
|
|
1327
|
+
const leftOutputs = new Set(leftAgents.map((agent) => artifactOutputIdFor(leftStep, agent)));
|
|
1328
|
+
if (rightAgents.some((agent) => leftOutputs.has(artifactOutputIdFor(rightStep, agent)))) return true;
|
|
1329
|
+
// An undeclared scope is unknown, and an unknown unit conflicts with everything (safe default).
|
|
1330
|
+
const leftScopes = declaredScopes(leftStep); const rightScopes = declaredScopes(rightStep);
|
|
1331
|
+
if (leftScopes.length === 0 || rightScopes.length === 0) return true;
|
|
1332
|
+
for (const a of leftScopes) for (const b of rightScopes) if (scopesOverlap(a, b)) return true;
|
|
1333
|
+
return false;
|
|
1334
|
+
}
|
|
1335
|
+
function selectWave(candidates) {
|
|
1336
|
+
const wave = []; const deferred = [];
|
|
1337
|
+
for (const index of candidates) {
|
|
1338
|
+
if (wave.every((chosen) => !stepsConflict(chosen, index))) wave.push(index);
|
|
1339
|
+
else deferred.push(index);
|
|
1340
|
+
}
|
|
1341
|
+
return { wave, deferred };
|
|
1342
|
+
}
|
|
1343
|
+
function invalidateFrom(stepIndex, preserveStepIndex) {
|
|
1344
|
+
const remove = new Set([stepIndex]);
|
|
1345
|
+
let changed = true;
|
|
1346
|
+
while (changed) {
|
|
1347
|
+
changed = false;
|
|
1348
|
+
for (let i = 0; i < steps.length; i += 1) {
|
|
1349
|
+
if (remove.has(i)) continue;
|
|
1350
|
+
const deps = Array.isArray(steps[i]?.dependsOn) ? steps[i].dependsOn : [];
|
|
1351
|
+
if (deps.some((dep) => { const j = resolveStepIndex(dep); return j >= 0 && remove.has(j); })) { remove.add(i); changed = true; }
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
// Preserve the requesting step's satisfied slots so a sibling is never re-invoked.
|
|
1355
|
+
if (Number.isInteger(preserveStepIndex)) remove.delete(preserveStepIndex);
|
|
1356
|
+
const slots = readJoinedSlots();
|
|
1357
|
+
const removedAgents = new Set();
|
|
1358
|
+
for (const key of Object.keys(slots)) {
|
|
1359
|
+
const index = Number(key.split(':')[0]);
|
|
1360
|
+
if (remove.has(index)) { removedAgents.add(slots[key].agent); delete slots[key]; }
|
|
1361
|
+
}
|
|
1362
|
+
status.joinedSlots = slots;
|
|
1363
|
+
status.parallelCompleted = (status.parallelCompleted || []).filter((agent) => !removedAgents.has(agent));
|
|
1364
|
+
return remove;
|
|
1365
|
+
}
|
|
1366
|
+
function computeReadySteps() {
|
|
1367
|
+
if (!isGraphMode()) return [];
|
|
1368
|
+
const inFlight = new Set(Object.values(status.activeAttempts || {}).map((entry) => entry.stepIndex));
|
|
1369
|
+
const blocked = new Set(Array.isArray(status.blockedSteps) ? status.blockedSteps : []);
|
|
1370
|
+
const skipped = new Set(Array.isArray(status.skippedSteps) ? status.skippedSteps : []);
|
|
1371
|
+
const ready = [];
|
|
1372
|
+
for (let i = 0; i < steps.length; i += 1) {
|
|
1373
|
+
if (blocked.has(i) || inFlight.has(i)) continue;
|
|
1374
|
+
if (skipIfMatches(steps[i].skipIf, taskDir)) {
|
|
1375
|
+
if (!skipped.has(i)) { recordSkippedStep(steps[i], i); skipped.add(i); }
|
|
1376
|
+
continue;
|
|
1377
|
+
}
|
|
1378
|
+
if (isStepSatisfied(i)) continue;
|
|
1379
|
+
const deps = Array.isArray(steps[i].dependsOn) ? steps[i].dependsOn : [];
|
|
1380
|
+
if (deps.every((dep) => { const j = resolveStepIndex(dep); return j >= 0 && isStepSatisfied(j); })) ready.push(i);
|
|
1381
|
+
}
|
|
1382
|
+
status.skippedSteps = [...skipped];
|
|
1383
|
+
return ready;
|
|
1384
|
+
}
|
|
1385
|
+
function handoffForWave(units, waveId) {
|
|
1386
|
+
const labels = units.map((unit) => `${steps[unit.stepIndex].id || `step-${unit.stepIndex}`}=${unit.agent}`);
|
|
1387
|
+
const attemptIds = Object.entries(status.activeAttempts || {})
|
|
1388
|
+
.filter(([, entry]) => units.some((unit) => unit.stepIndex === entry.stepIndex && unit.agent === entry.agent))
|
|
1389
|
+
.map(([attemptId, entry]) => `${entry.agent}=${attemptId}`);
|
|
1390
|
+
const outputIds = units.map((unit) => `${unit.agent}=${artifactOutputIdFor(steps[unit.stepIndex], unit.agent)}`);
|
|
1391
|
+
const inputIds = [...new Set(units.flatMap((unit) => (Array.isArray(steps[unit.stepIndex].artifactInputIds) ? steps[unit.stepIndex].artifactInputIds : [])))];
|
|
1392
|
+
return (
|
|
1393
|
+
`Invoke IN PARALLEL (one message, multiple Task calls): ${labels.join(' AND ')} for slug "${slug}"${waveId ? ` (waveId=${waveId})` : ''}. ` +
|
|
1394
|
+
`Each agent writes its artifact and owned receipt; the hook records slot joins from stops. Do not mutate status.json lifecycle fields. ` +
|
|
1395
|
+
`Artifact inputs: ${inputIds.length > 0 ? inputIds.join(', ') : 'manifest defaults'}; owned output IDs: ${outputIds.join('; ')}. ` +
|
|
1396
|
+
`Metrics attemptIds: ${attemptIds.join('; ')}. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not calculate duration. ${receiptPathClause()}` +
|
|
1397
|
+
decompositionReadyClause(units.map((unit) => steps[unit.stepIndex]))
|
|
1398
|
+
);
|
|
1399
|
+
}
|
|
1400
|
+
function blockedNotice(blockedIndex, agent) {
|
|
1401
|
+
const gated = [];
|
|
1402
|
+
for (let i = 0; i < steps.length; i += 1) {
|
|
1403
|
+
if (i === blockedIndex || isStepSatisfied(i)) continue;
|
|
1404
|
+
const deps = Array.isArray(steps[i].dependsOn) ? steps[i].dependsOn : [];
|
|
1405
|
+
if (deps.some((dep) => resolveStepIndex(dep) === blockedIndex)) gated.push(steps[i].id || `step-${i}`);
|
|
1406
|
+
}
|
|
1407
|
+
return `Step ${blockedIndex} (${agent}) is blocked for slug "${slug}"${gated.length > 0 ? ` and gates: ${gated.join(', ')}` : ''}. No independent ready step remains. Resume only via /task-continue ${slug}.`;
|
|
1408
|
+
}
|
|
1409
|
+
function noProgressNotice() {
|
|
1410
|
+
const pending = pendingStepIndexes().map((index) => steps[index].id || `step-${index}`);
|
|
1411
|
+
return `No schedulable step remains for slug "${slug}" (unsatisfied: ${pending.join(', ')}). Resume only via /task-continue ${slug}.`;
|
|
1412
|
+
}
|
|
1413
|
+
function deferReason(wave, deferred) {
|
|
1414
|
+
const sameAgent = deferred.some((index) => wave.some((chosen) => {
|
|
1415
|
+
const left = getStepAgents(steps[chosen]);
|
|
1416
|
+
return getStepAgents(steps[index]).some((agent) => left.includes(agent));
|
|
1417
|
+
}));
|
|
1418
|
+
if (sameAgent) return 'same agent already in the wave';
|
|
1419
|
+
const missingScope = [...wave, ...deferred].some((index) => declaredScopes(steps[index]).length === 0);
|
|
1420
|
+
if (missingScope) return 'writeScopes undeclared';
|
|
1421
|
+
return 'writeScopes overlap';
|
|
1422
|
+
}
|
|
1423
|
+
function dispatchReadyWave(prefixMessage) {
|
|
1424
|
+
const ready = computeReadySteps();
|
|
1425
|
+
if (ready.length === 0) return false;
|
|
1426
|
+
const { wave, deferred } = selectWave(ready);
|
|
1427
|
+
if (deferred.length > 0) {
|
|
1428
|
+
appendMetric({ type: 'parallel_conflict_deferred', at: now, stepIndex: wave[0], deferredStepIndexes: deferred, reason: deferReason(wave, deferred), source: 'hook', attributionConfidence: 'fallback' });
|
|
1429
|
+
}
|
|
1430
|
+
// Slot-filtered dispatch: only unsatisfied (stepIndex, agent) slots are invoked.
|
|
1431
|
+
const units = wave.flatMap((stepIndex) => unsatisfiedAgents(stepIndex).map((agent) => ({ stepIndex, agent })));
|
|
1432
|
+
if (units.length === 0) return false;
|
|
1433
|
+
const unitAgents = units.map((unit) => unit.agent);
|
|
1434
|
+
refuseImplementationStart(unitAgents, (agent) => implementationDebugRetry(agent));
|
|
1435
|
+
recordAllowedDebugRetries(unitAgents);
|
|
1436
|
+
const first = units[0].stepIndex;
|
|
1437
|
+
const waveId = `${status.metricsRunId || slug}:wave-${first}`;
|
|
1438
|
+
for (const unit of units) activateAttempts(steps[unit.stepIndex], unit.stepIndex, units.length > 1 ? waveId : null, [unit.agent]);
|
|
1439
|
+
writeStatus({
|
|
1440
|
+
pipelineIndex: first,
|
|
1441
|
+
currentAgent: units[0].agent,
|
|
1442
|
+
phase: 'executing',
|
|
1443
|
+
state: 'in_progress',
|
|
1444
|
+
awaitingHumanGate: false,
|
|
1445
|
+
parallelCompleted: [],
|
|
1446
|
+
parallelOutcomes: {},
|
|
1447
|
+
waveSteps: wave,
|
|
1448
|
+
waveId,
|
|
1449
|
+
});
|
|
1450
|
+
const stepIndexes = [...new Set(units.map((unit) => unit.stepIndex))];
|
|
1451
|
+
appendMetric({ type: 'parallel_wave_started', at: now, waveId, stepIndexes, agents: units.map((unit) => unit.agent), source: 'hook', attributionConfidence: 'high' });
|
|
1452
|
+
let message;
|
|
1453
|
+
if (units.length === 1) message = handoffForAgent(units[0].agent, steps[first]?.scope, steps[first]);
|
|
1454
|
+
else if (stepIndexes.length === 1 && steps[first].parallel && units.length === getStepAgents(steps[first]).length) message = handoffForParallelStep(steps[first]);
|
|
1455
|
+
else message = handoffForWave(units, waveId);
|
|
1456
|
+
out(prefixMessage ? `${prefixMessage} ${message}` : message);
|
|
1457
|
+
return true;
|
|
1458
|
+
}
|
|
1459
|
+
function resolveProducerStepIndex(agent, fromIndex) {
|
|
1460
|
+
const seen = new Set([fromIndex]);
|
|
1461
|
+
const stack = [fromIndex];
|
|
1462
|
+
let best = -1;
|
|
1463
|
+
while (stack.length > 0) {
|
|
1464
|
+
const node = stack.pop();
|
|
1465
|
+
const deps = Array.isArray(steps[node]?.dependsOn) ? steps[node].dependsOn : [];
|
|
1466
|
+
for (const dep of deps) {
|
|
1467
|
+
const j = resolveStepIndex(dep);
|
|
1468
|
+
if (j < 0 || seen.has(j)) continue;
|
|
1469
|
+
seen.add(j);
|
|
1470
|
+
if (getStepAgents(steps[j]).includes(agent)) best = Math.max(best, j);
|
|
1471
|
+
stack.push(j);
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
return best >= 0 ? best : -1;
|
|
1475
|
+
}
|
|
1476
|
+
function repairUnattributableStop() {
|
|
1477
|
+
const entries = Object.entries(status.activeAttempts || {});
|
|
1478
|
+
if (entries.length === 0) return null;
|
|
1479
|
+
const bindByAgent = (agent) => {
|
|
1480
|
+
if (!agent) return null;
|
|
1481
|
+
const matches = entries.filter(([, entry]) => entry.agent === agent);
|
|
1482
|
+
return matches.length === 1 ? { attemptId: matches[0][0], entry: matches[0][1], confidence: 'fallback', repaired: true } : null;
|
|
1483
|
+
};
|
|
1484
|
+
const payloadAgent = typeof hookInput.agentType === 'string' ? hookInput.agentType : (typeof hookInput.agent_type === 'string' ? hookInput.agent_type : null);
|
|
1485
|
+
const byPayload = bindByAgent(payloadAgent);
|
|
1486
|
+
if (byPayload) return byPayload;
|
|
1487
|
+
if (Array.isArray(status.waveSteps) && status.waveSteps.length > 0) {
|
|
1488
|
+
const outcomes = status.parallelOutcomes || {};
|
|
1489
|
+
const unrecorded = status.waveSteps.flatMap((index) => getStepAgents(steps[index])).filter((agent) => !outcomes[agent]);
|
|
1490
|
+
if (unrecorded.length === 1) { const bySole = bindByAgent(unrecorded[0]); if (bySole) return bySole; }
|
|
1491
|
+
}
|
|
1492
|
+
const byCurrent = bindByAgent(status.currentAgent);
|
|
1493
|
+
if (byCurrent) return byCurrent;
|
|
1494
|
+
return null;
|
|
1495
|
+
}
|
|
1496
|
+
function repairHandoffMessage() {
|
|
1497
|
+
const listing = Object.entries(status.activeAttempts || {}).map(([attemptId, entry]) => `${entry.agent}=${attemptId}`).join('; ');
|
|
1498
|
+
return `Parallel stop could not be attributed for slug "${slug}": in-flight attempts ${listing}; no payload attemptId and no bound receipt for the finished agent. Resume deterministically: append a minimal { attemptId, outcome } receipt for the agent that just finished to .ai.local/team/tasks/${slug}/.metrics-receipts.json, then re-run the installed hooks/chain-team-phases.sh with that attemptId. Do not edit status.json manually.`;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
const AGENT_HANDOFF = {
|
|
1502
|
+
'task-analyst': (s) =>
|
|
1503
|
+
`Invoke task-analyst for slug "${s}". Write brief.md and decomposition.md under .ai.local/team/tasks/${s}/. ` +
|
|
1504
|
+
`Upsert the analysis receipt in artifact-manifest.json; do not mutate status.json lifecycle fields. Do not use legacy phase analysis.`,
|
|
1505
|
+
debugger: (s) =>
|
|
1506
|
+
`Invoke debugger subagent for slug "${s}". Investigate root cause with module build output and runtime logs; write debug-report.md with fixApplied: true/false. ` +
|
|
1507
|
+
`Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1508
|
+
'solution-architect': (s) =>
|
|
1509
|
+
`Invoke solution-architect for slug "${s}". Read brief.md; write architecture.md for $mol module composition, state homes, and view trees. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1510
|
+
'migration-specialist': (s) =>
|
|
1511
|
+
`Invoke migration-specialist for slug "${s}". Read brief.md; write migration-plan.md for the $mol framework / MAM checkout. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1512
|
+
'api-contract-reviewer': (s) =>
|
|
1513
|
+
`Invoke api-contract-reviewer (readonly) for slug "${s}". Review typed DTO/state module surface; write api-contract-review.md. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1514
|
+
'ci-investigator': (s) =>
|
|
1515
|
+
`Invoke ci-investigator for slug "${s}". Diagnose CI failure (module builds via npm start <module/path>, $mol_test bundles); write ci-report.md; apply minimal fix. ` +
|
|
1516
|
+
`Use ci-investigation skill. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1517
|
+
'feature-developer': (s) =>
|
|
1518
|
+
`Invoke feature-developer for slug "${s}". Read brief.md, decomposition.md, validation-report.md, review.md, architecture.md, migration-plan.md, api-contract-review.md, debug-report.md if present. ` +
|
|
1519
|
+
`Follow feature-delivery-workflow.md and reference-features.md. Compose from $mol batteries, one component per module; build touched modules and run their $mol_test suites before handoff. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1520
|
+
'build-verifier': (s) =>
|
|
1521
|
+
`Invoke build-verifier (readonly) for slug "${s}". Build every touched module (npm start <module/path> from the MAM checkout root) and run its $mol_test bundles — there is no lint gate in $mol. ` +
|
|
1522
|
+
`Write validation-report.md and emit receipt outcome completed or validation_failed. Do not edit production code.`,
|
|
1523
|
+
'accessibility-reviewer': (s) =>
|
|
1524
|
+
`Invoke accessibility-reviewer (readonly) for slug "${s}". Review view modules (*.view.tree, *.view.css, *.view.ts); write a11y-review.md. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1525
|
+
'performance-auditor': (s) =>
|
|
1526
|
+
`Invoke performance-auditor (readonly) for slug "${s}". Write perf-report.md. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1527
|
+
'mockup-reviewer': (s) =>
|
|
1528
|
+
`Invoke mockup-reviewer (readonly) for slug "${s}". Write mockup-review.md. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1529
|
+
'code-reviewer': (s) =>
|
|
1530
|
+
`Invoke code-reviewer subagent (readonly) for slug "${s}". Review git diff vs brief.md per code-review-mr.md. ` +
|
|
1531
|
+
`Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1532
|
+
'security-reviewer': (s) =>
|
|
1533
|
+
`Invoke security-reviewer (readonly) for slug "${s}". Write security-review.md. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1534
|
+
'qa-tester': (s, scope) =>
|
|
1535
|
+
`Invoke qa-tester for slug "${s}"${scope ? ` (scope: ${scope})` : ''}. ` +
|
|
1536
|
+
`Add/update $mol_test suites co-located with modules per brief. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1537
|
+
'unit-test-planner': (s) =>
|
|
1538
|
+
`Invoke unit-test-planner for slug "${s}". Write unit-test-plan.md. Use unit-testing skill. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1539
|
+
'unit-test-generator': (s) =>
|
|
1540
|
+
`Invoke unit-test-generator for slug "${s}". Implement $mol_test specs from unit-test-plan.md co-located with modules. Use unit-testing skill. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1541
|
+
'unit-test-healer': (s) =>
|
|
1542
|
+
`Invoke unit-test-healer for slug "${s}". Fix failing $mol_test suites. Use unit-testing and debug-investigation skills. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1543
|
+
'playwright-test-planner': (s) =>
|
|
1544
|
+
`Invoke playwright-test-planner for slug "${s}". Create/update browser e2e plans in the repo's e2e tree. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1545
|
+
'playwright-test-generator': (s) =>
|
|
1546
|
+
`Invoke playwright-test-generator for slug "${s}". Generate/update e2e specs from matching plans in the repo's e2e tree. ` +
|
|
1547
|
+
`Use playwright MCP when available. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1548
|
+
'playwright-test-healer': (s) =>
|
|
1549
|
+
`Invoke playwright-test-healer for slug "${s}". Fix failing/flaky browser e2e while preserving plan assertions. ` +
|
|
1550
|
+
`Use playwright MCP when available and debug-investigation. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1551
|
+
'tech-writer': (s) =>
|
|
1552
|
+
`Invoke tech-writer for slug "${s}". Write documentation.md from task artifacts. Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`,
|
|
1553
|
+
'openspec-author': (s, scope) =>
|
|
1554
|
+
`Invoke openspec-author for slug "${s}"${scope ? ` (scope: ${scope})` : ''}. ` +
|
|
1555
|
+
`Read openspec/config.yaml schema + rules; if openspec/** is absent, emit blocked ("openspec/** not initialized"). ` +
|
|
1556
|
+
`Author openspec/changes/<change-id>/{proposal.md, design.md, tasks.md, .openspec.yaml} and the capability spec delta per phase (explore|propose|apply|archive). ` +
|
|
1557
|
+
`Run \`openspec validate <change-id> --type change --strict\` and \`openspec validate --specs --strict\` (Phase 3); surface FAIL output verbatim. ` +
|
|
1558
|
+
`Upsert the owned terminal receipt (artifactOutputId \`openspec-change\`) in artifact-manifest.json with validator exit code + evidence paths; do not mutate status.json lifecycle fields. `,
|
|
1559
|
+
};
|
|
1560
|
+
|
|
1561
|
+
const REVIEW_AGENTS = new Set([
|
|
1562
|
+
'code-reviewer',
|
|
1563
|
+
'accessibility-reviewer',
|
|
1564
|
+
'security-reviewer',
|
|
1565
|
+
'api-contract-reviewer',
|
|
1566
|
+
]);
|
|
1567
|
+
|
|
1568
|
+
function metricsHandoff(agent) {
|
|
1569
|
+
const matches = Object.entries(status.activeAttempts || {}).filter(([, entry]) => entry.agent === agent);
|
|
1570
|
+
if (matches.length === 1) {
|
|
1571
|
+
return ` Metrics attemptId: ${matches[0][0]}; write owned artifact-manifest receipt outcome. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not mutate status.json or calculate duration.`;
|
|
1572
|
+
}
|
|
1573
|
+
return ' Metrics: use the supplied attemptId when available; for a parallel completion, write a minimal { attemptId, outcome } receipt to .metrics-receipts.json rather than relying on currentAgent. Do not calculate duration.';
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
function receiptPathClause() {
|
|
1577
|
+
return 'authoritativePaths are relative to the task folder (brief.md), not the repo root; put external files in evidencePaths.';
|
|
1578
|
+
}
|
|
1579
|
+
function artifactHandoff(step, agent) {
|
|
1580
|
+
const inputIds = Array.isArray(step?.artifactInputIds) ? step.artifactInputIds.join(', ') : 'manifest defaults';
|
|
1581
|
+
return ` Artifact inputs: ${inputIds}; owned output ID: ${artifactOutputIdFor(step, agent)}. Bind the terminal receipt to the supplied attemptId. ${receiptPathClause()}`;
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
// <<<implementation-rail>>>
|
|
1585
|
+
// Opt-in. Omitted, "off", and non-production intents stay off. Only "on" applies.
|
|
1586
|
+
function testBeforeHandoffRule() {
|
|
1587
|
+
return 'Include unit tests for mappers/logic before handoff.';
|
|
1588
|
+
}
|
|
1589
|
+
function railOnHandoffClause() {
|
|
1590
|
+
return ' Strict implementation rail: write a failing test before production edits; use a branch or worktree before the first implementation task; run code-reviewer between decomposition tasks; debug retries for this handoff are capped at two.';
|
|
1591
|
+
}
|
|
1592
|
+
function implementationRailApplies(pipeline) {
|
|
1593
|
+
if (!pipeline || typeof pipeline !== 'object') return false;
|
|
1594
|
+
const intent = typeof pipeline.intent === 'string' ? pipeline.intent : '';
|
|
1595
|
+
const level = pipeline.taskLevel;
|
|
1596
|
+
if (level === 'L0' || level === 0 || level === '0') return false;
|
|
1597
|
+
if (intent === 'docs-only' || intent === 'research' || intent === 'preset-only' || intent === 'spike') return false;
|
|
1598
|
+
if (pipeline.presetOnly === true) return false;
|
|
1599
|
+
return pipeline.implementationRail === 'on';
|
|
1600
|
+
}
|
|
1601
|
+
function briefHasOpenClarificationMarker(text) {
|
|
1602
|
+
if (typeof text !== 'string' || text.length === 0) return false;
|
|
1603
|
+
const lines = text.split(/\r?\n/);
|
|
1604
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
1605
|
+
let body = lines[index].trim().replace(/^(?:>\s*)+/, '');
|
|
1606
|
+
body = body.replace(/^(?:[-*+]|\d+[.)])\s+/, '');
|
|
1607
|
+
if (body.startsWith('[NEEDS CLARIFICATION]')) return true;
|
|
1608
|
+
}
|
|
1609
|
+
return false;
|
|
1610
|
+
}
|
|
1611
|
+
function implementationHandoffDecision(input) {
|
|
1612
|
+
const agent = input && input.agent;
|
|
1613
|
+
const applies = agent === 'feature-developer' && implementationRailApplies(input && input.pipeline);
|
|
1614
|
+
if (!applies) {
|
|
1615
|
+
return {
|
|
1616
|
+
start: true,
|
|
1617
|
+
rail: 'off',
|
|
1618
|
+
handoffRule: agent === 'feature-developer' ? testBeforeHandoffRule() : null,
|
|
1619
|
+
constraints: [],
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
if (briefHasOpenClarificationMarker(input && input.briefText)) {
|
|
1623
|
+
return { start: false, rail: 'on', reason: 'open-marker', handoffRule: testBeforeHandoffRule(), constraints: [] };
|
|
1624
|
+
}
|
|
1625
|
+
const debugRetries = Number(input && input.debugRetryCount) || 0;
|
|
1626
|
+
if (input && input.debugRetry === true && debugRetries >= 2) {
|
|
1627
|
+
return { start: false, rail: 'on', reason: 'debug-retry-cap', handoffRule: testBeforeHandoffRule(), constraints: [] };
|
|
1628
|
+
}
|
|
1629
|
+
return {
|
|
1630
|
+
start: true,
|
|
1631
|
+
rail: 'on',
|
|
1632
|
+
handoffRule: testBeforeHandoffRule(),
|
|
1633
|
+
constraints: [
|
|
1634
|
+
'failing test before production edits',
|
|
1635
|
+
'branch or worktree before the first implementation task',
|
|
1636
|
+
'code-reviewer between decomposition tasks',
|
|
1637
|
+
'debug retries capped at two',
|
|
1638
|
+
],
|
|
1639
|
+
};
|
|
1640
|
+
}
|
|
1641
|
+
// <<<implementation-rail-end>>>
|
|
1642
|
+
|
|
1643
|
+
function readPipelineRecord() {
|
|
1644
|
+
try {
|
|
1645
|
+
return JSON.parse(fs.readFileSync(pipelinePath, 'utf8'));
|
|
1646
|
+
} catch {
|
|
1647
|
+
return null;
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
function readBriefText() {
|
|
1651
|
+
try {
|
|
1652
|
+
return fs.readFileSync(path.join(taskDir, 'brief.md'), 'utf8');
|
|
1653
|
+
} catch {
|
|
1654
|
+
return '';
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
function countDebugImplementationRetries() {
|
|
1658
|
+
try {
|
|
1659
|
+
const metrics = JSON.parse(fs.readFileSync(METRICS_PATH, 'utf8'));
|
|
1660
|
+
const events = Array.isArray(metrics.events) ? metrics.events : [];
|
|
1661
|
+
return events.filter((event) => event && event.type === 'retry_scheduled' && event.nextAgent === 'feature-developer' && event.retryAfterFix === 'debugger').length;
|
|
1662
|
+
} catch {
|
|
1663
|
+
return 0;
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
function featureDeveloperAlreadyStarted() {
|
|
1667
|
+
try {
|
|
1668
|
+
const metrics = JSON.parse(fs.readFileSync(METRICS_PATH, 'utf8'));
|
|
1669
|
+
const events = Array.isArray(metrics.events) ? metrics.events : [];
|
|
1670
|
+
return events.some((event) => event && event.type === 'attempt_started' && event.agent === 'feature-developer');
|
|
1671
|
+
} catch {
|
|
1672
|
+
return false;
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
function implementationDebugRetry(agent) {
|
|
1676
|
+
return agent === 'feature-developer' && status.currentAgent === 'debugger' && featureDeveloperAlreadyStarted();
|
|
1677
|
+
}
|
|
1678
|
+
function blockImplementationStart(agent, debugRetry) {
|
|
1679
|
+
const decision = implementationHandoffDecision({
|
|
1680
|
+
agent,
|
|
1681
|
+
pipeline: readPipelineRecord(),
|
|
1682
|
+
briefText: readBriefText(),
|
|
1683
|
+
debugRetry: Boolean(debugRetry),
|
|
1684
|
+
debugRetryCount: countDebugImplementationRetries(),
|
|
1685
|
+
});
|
|
1686
|
+
if (decision.start) return null;
|
|
1687
|
+
if (decision.reason === 'debug-retry-cap') {
|
|
1688
|
+
return `Strict implementation rail is on for slug "${slug}". Debug retries for the implementation handoff are capped at two. Do not start implementation.`;
|
|
1689
|
+
}
|
|
1690
|
+
return `Strict implementation rail is on for slug "${slug}" and a [NEEDS CLARIFICATION] marker is open. Do not start implementation.`;
|
|
1691
|
+
}
|
|
1692
|
+
function refuseImplementationStart(agents, debugRetryFor) {
|
|
1693
|
+
const list = Array.isArray(agents) ? agents : [agents];
|
|
1694
|
+
for (let index = 0; index < list.length; index += 1) {
|
|
1695
|
+
const block = blockImplementationStart(list[index], debugRetryFor(list[index]));
|
|
1696
|
+
if (!block) continue;
|
|
1697
|
+
beginHumanGate();
|
|
1698
|
+
writeStatus({
|
|
1699
|
+
state: 'awaiting_approval',
|
|
1700
|
+
phase: 'human_gate',
|
|
1701
|
+
awaitingHumanGate: true,
|
|
1702
|
+
waveSteps: [],
|
|
1703
|
+
waveId: null,
|
|
1704
|
+
retryAfterFix: null,
|
|
1705
|
+
retryAfterFixStepIndex: null,
|
|
1706
|
+
});
|
|
1707
|
+
out(block);
|
|
1708
|
+
process.exit(0);
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
function recordAllowedDebugRetries(agents) {
|
|
1712
|
+
if (!implementationRailApplies(readPipelineRecord())) return;
|
|
1713
|
+
const list = Array.isArray(agents) ? agents : [agents];
|
|
1714
|
+
for (let index = 0; index < list.length; index += 1) {
|
|
1715
|
+
if (!implementationDebugRetry(list[index])) continue;
|
|
1716
|
+
appendMetric({
|
|
1717
|
+
type: 'retry_scheduled',
|
|
1718
|
+
at: now,
|
|
1719
|
+
attemptId: null,
|
|
1720
|
+
nextAgent: 'feature-developer',
|
|
1721
|
+
retryAfterFix: 'debugger',
|
|
1722
|
+
source: 'hook',
|
|
1723
|
+
attributionConfidence: 'high',
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
function railInstructionClause(agent) {
|
|
1728
|
+
const decision = implementationHandoffDecision({
|
|
1729
|
+
agent,
|
|
1730
|
+
pipeline: readPipelineRecord(),
|
|
1731
|
+
briefText: readBriefText(),
|
|
1732
|
+
debugRetry: false,
|
|
1733
|
+
debugRetryCount: 0,
|
|
1734
|
+
});
|
|
1735
|
+
if (decision.rail !== 'on' || !decision.start) return '';
|
|
1736
|
+
return railOnHandoffClause();
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
function handoffForAgent(agent, scope, step = null) {
|
|
1740
|
+
const fn = AGENT_HANDOFF[agent];
|
|
1741
|
+
const handoff = fn ? fn(slug, scope) : `Invoke ${agent} subagent for slug "${slug}". Upsert the owned terminal receipt in artifact-manifest.json; do not mutate status.json lifecycle fields.`;
|
|
1742
|
+
return handoff + railInstructionClause(agent) + artifactHandoff(step, agent) + metricsHandoff(agent) + decompositionReadyClause(step ? [step] : []);
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
function handoffForParallelStep(step) {
|
|
1746
|
+
const agents = getStepAgents(step);
|
|
1747
|
+
const attemptIds = Object.entries(status.activeAttempts || {})
|
|
1748
|
+
.filter(([, entry]) => agents.includes(entry.agent))
|
|
1749
|
+
.map(([attemptId, entry]) => `${entry.agent}=${attemptId}`);
|
|
1750
|
+
return (
|
|
1751
|
+
`Invoke IN PARALLEL (one message, multiple Task calls): ${agents.join(' AND ')} for slug "${slug}". ` +
|
|
1752
|
+
`Each agent writes its artifact and owned receipt; the hook records parallelCompleted from stops. Do not mutate status.json lifecycle fields. ` +
|
|
1753
|
+
`Artifact inputs: ${Array.isArray(step.artifactInputIds) ? step.artifactInputIds.join(', ') : 'manifest defaults'}; owned output IDs: ${agents.map((agent) => `${agent}=${artifactOutputIdFor(step, agent)}`).join('; ')}. ` +
|
|
1754
|
+
`Metrics attemptIds: ${attemptIds.join('; ')}. If the hook cannot identify a parallel stop, append a minimal { attemptId, outcome } receipt to .metrics-receipts.json; do not calculate duration. ${receiptPathClause()}` +
|
|
1755
|
+
decompositionReadyClause([step])
|
|
1756
|
+
);
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
function hasGateAfter(agent, humanGates) {
|
|
1760
|
+
return Array.isArray(humanGates) && humanGates.includes(`after:${agent}`);
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
function hasGateAfterStep(step, humanGates) {
|
|
1764
|
+
if (!Array.isArray(humanGates) || !step) return false;
|
|
1765
|
+
if (typeof step.id === 'string' && step.id.length > 0 && humanGates.includes(`after:${step.id}`)) return true;
|
|
1766
|
+
return getStepAgents(step).some((a) => hasGateAfter(a, humanGates));
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
// A followup loop of the subagent that just finished arrives with no attemptId
|
|
1770
|
+
// and no receipt for the attempt this same transition opened. That stop is not
|
|
1771
|
+
// the next agent. A stop more than 15s later, still without a receipt, is a
|
|
1772
|
+
// real missing receipt and must stall.
|
|
1773
|
+
function isSchedulingEcho() {
|
|
1774
|
+
if (typeof hookInput.attemptId === 'string' && hookInput.attemptId.length > 0) return false;
|
|
1775
|
+
const entries = Object.entries(status.activeAttempts || {});
|
|
1776
|
+
if (entries.length !== 1) return false;
|
|
1777
|
+
const [attemptId, entry] = entries[0];
|
|
1778
|
+
const previous = status.lastCompletedAttempt;
|
|
1779
|
+
if (!previous || previous.completedAt !== entry.startedAt) return false;
|
|
1780
|
+
const ageMs = Date.parse(now) - Date.parse(entry.startedAt);
|
|
1781
|
+
if (!Number.isFinite(ageMs) || ageMs < 0 || ageMs > 15000) return false;
|
|
1782
|
+
const previousJoined = Object.values(status.joinedSlots || {}).some((slot) => slot && slot.attemptId === previous.attemptId);
|
|
1783
|
+
const linearAdvance = !isGraphMode() && typeof entry.stepIndex === 'number' && entry.stepIndex > 0;
|
|
1784
|
+
if (!previousJoined && !linearAdvance) return false;
|
|
1785
|
+
try {
|
|
1786
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(taskDir, 'artifact-manifest.json'), 'utf8'));
|
|
1787
|
+
const artifacts = Array.isArray(manifest.artifacts) ? manifest.artifacts : [];
|
|
1788
|
+
if (artifacts.some((item) => item && item.receipt && item.receipt.attemptId === attemptId)) return false;
|
|
1789
|
+
} catch {}
|
|
1790
|
+
return true;
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
function legacyFlow() {
|
|
1794
|
+
if (status.phase === 'analysis') {
|
|
1795
|
+
process.stdout.write('{}');
|
|
1796
|
+
process.exit(0);
|
|
1797
|
+
}
|
|
1798
|
+
if (status.phase === 'development' && (status.state === 'completed' || status.state === 'in_progress')) {
|
|
1799
|
+
writeStatus({ phase: 'executing', state: 'in_progress', currentAgent: 'build-verifier' });
|
|
1800
|
+
out(handoffForAgent('build-verifier'));
|
|
1801
|
+
process.exit(0);
|
|
1802
|
+
}
|
|
1803
|
+
if (status.currentAgent === 'build-verifier' && status.state === 'completed') {
|
|
1804
|
+
writeStatus({ phase: 'executing', state: 'in_progress', currentAgent: 'code-reviewer' });
|
|
1805
|
+
out(handoffForAgent('code-reviewer'));
|
|
1806
|
+
process.exit(0);
|
|
1807
|
+
}
|
|
1808
|
+
if (status.phase === 'review' && status.state === 'completed') {
|
|
1809
|
+
writeStatus({ phase: 'executing', state: 'in_progress', currentAgent: 'qa-tester' });
|
|
1810
|
+
out(handoffForAgent('qa-tester'));
|
|
1811
|
+
process.exit(0);
|
|
1812
|
+
}
|
|
1813
|
+
function scheduleLegacyRetry(agent, retryAfterFix) {
|
|
1814
|
+
const stepIndex = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
|
|
1815
|
+
const predecessorAttemptId = status.lastCompletedAttempt?.attemptId || null;
|
|
1816
|
+
appendMetric({ type: 'retry_scheduled', at: now, attemptId: predecessorAttemptId, nextAgent: agent, retryAfterFix: retryAfterFix || null, source: 'hook', attributionConfidence: 'unknown' });
|
|
1817
|
+
activateAttempts({ agent }, stepIndex);
|
|
1818
|
+
}
|
|
1819
|
+
if (status.state === 'changes_requested') {
|
|
1820
|
+
const reviewer = status.currentAgent;
|
|
1821
|
+
if (!reviewer) {
|
|
1822
|
+
process.stdout.write('{}');
|
|
1823
|
+
process.exit(0);
|
|
1824
|
+
}
|
|
1825
|
+
scheduleLegacyRetry('feature-developer', reviewer);
|
|
1826
|
+
writeStatus({
|
|
1827
|
+
currentAgent: 'feature-developer',
|
|
1828
|
+
state: 'in_progress',
|
|
1829
|
+
phase: 'executing',
|
|
1830
|
+
retryAfterFix: reviewer,
|
|
1831
|
+
});
|
|
1832
|
+
out(handoffForAgent('feature-developer') + ` After fixes, re-run ${reviewer}.`);
|
|
1833
|
+
process.exit(0);
|
|
1834
|
+
}
|
|
1835
|
+
if (status.state === 'validation_failed' && status.currentAgent === 'build-verifier') {
|
|
1836
|
+
scheduleLegacyRetry('feature-developer', 'build-verifier');
|
|
1837
|
+
writeStatus({
|
|
1838
|
+
currentAgent: 'feature-developer',
|
|
1839
|
+
state: 'in_progress',
|
|
1840
|
+
phase: 'executing',
|
|
1841
|
+
retryAfterFix: 'build-verifier',
|
|
1842
|
+
});
|
|
1843
|
+
out(handoffForAgent('feature-developer') + ' Read validation-report.md. After fixes, re-run build-verifier.');
|
|
1844
|
+
process.exit(0);
|
|
1845
|
+
}
|
|
1846
|
+
if (status.state === 'completed' && status.retryAfterFix) {
|
|
1847
|
+
const retry = status.retryAfterFix;
|
|
1848
|
+
scheduleLegacyRetry(retry, null);
|
|
1849
|
+
writeStatus({ currentAgent: retry, state: 'in_progress', retryAfterFix: null });
|
|
1850
|
+
out(handoffForAgent(retry));
|
|
1851
|
+
process.exit(0);
|
|
1852
|
+
}
|
|
1853
|
+
if (status.phase === 'testing' && status.state === 'completed') {
|
|
1854
|
+
writeStatus({ phase: 'done', state: 'completed' });
|
|
1855
|
+
out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
|
|
1856
|
+
process.exit(0);
|
|
1857
|
+
}
|
|
1858
|
+
process.stdout.write('{}');
|
|
1859
|
+
process.exit(0);
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
|
|
1863
|
+
if (hookInput.action === 'end_human_gate') {
|
|
1864
|
+
// Only advance when a gate was actually open. A duplicate or retried
|
|
1865
|
+
// end_human_gate must be a no-op, not a silent pipeline skip.
|
|
1866
|
+
const gateWasOpen = Boolean(status.activeHumanGateEventId) || status.awaitingHumanGate === true;
|
|
1867
|
+
status.awaitingHumanGate = false;
|
|
1868
|
+
// A2 (retro §8): pin a single runId per pipeline so subsequent events don't
|
|
1869
|
+
// fragment the metrics ledger across multiple runId sequences. Prefer
|
|
1870
|
+
// metrics.json.task.runId when metrics already exist, then status.metricsRunId,
|
|
1871
|
+
// then mint a fresh seed only on first ever emit.
|
|
1872
|
+
try {
|
|
1873
|
+
if (fs.existsSync(METRICS_PATH)) {
|
|
1874
|
+
const existing = JSON.parse(fs.readFileSync(METRICS_PATH, 'utf8'));
|
|
1875
|
+
if (existing && existing.task && typeof existing.task.runId === 'string') {
|
|
1876
|
+
status.metricsRunId = existing.task.runId;
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
} catch {}
|
|
1880
|
+
if (status.state === 'awaiting_approval') {
|
|
1881
|
+
status.state = 'in_progress';
|
|
1882
|
+
status.phase = status.phase === 'human_gate' ? 'executing' : status.phase;
|
|
1883
|
+
}
|
|
1884
|
+
if (status.activeHumanGateEventId) {
|
|
1885
|
+
appendMetric({
|
|
1886
|
+
type: 'human_gate_ended',
|
|
1887
|
+
at: now,
|
|
1888
|
+
gateStartedEventId: status.activeHumanGateEventId,
|
|
1889
|
+
source: 'orchestrator',
|
|
1890
|
+
attributionConfidence: 'high',
|
|
1891
|
+
});
|
|
1892
|
+
delete status.activeHumanGateEventId;
|
|
1893
|
+
}
|
|
1894
|
+
if (gateWasOpen && hookInput.activateNext && fs.existsSync(pipelinePath)) {
|
|
1895
|
+
let resumePipeline = null;
|
|
1896
|
+
try { resumePipeline = JSON.parse(fs.readFileSync(pipelinePath, 'utf8')); } catch {}
|
|
1897
|
+
if (resumePipeline) {
|
|
1898
|
+
const resumeSteps = resumePipeline.steps || [];
|
|
1899
|
+
if (resumeSteps.some((step) => step && Array.isArray(step.dependsOn))) {
|
|
1900
|
+
steps = resumeSteps;
|
|
1901
|
+
status.blockedSteps = [];
|
|
1902
|
+
status.parallelCompleted = [];
|
|
1903
|
+
status.parallelOutcomes = {};
|
|
1904
|
+
status.waveSteps = [];
|
|
1905
|
+
status.waveId = null;
|
|
1906
|
+
if (dispatchReadyWave()) process.exit(0);
|
|
1907
|
+
if (pendingStepIndexes().length === 0) {
|
|
1908
|
+
status.state = 'completed';
|
|
1909
|
+
completePipeline({ pipelineIndex: resumeSteps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
|
|
1910
|
+
}
|
|
1911
|
+
out(noProgressNotice());
|
|
1912
|
+
process.exit(0);
|
|
1913
|
+
}
|
|
1914
|
+
const resumeStart = (typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0) + 1;
|
|
1915
|
+
const resumeNext = findNextExecutableStep(resumeSteps, resumeStart, taskDir);
|
|
1916
|
+
if (resumeNext) {
|
|
1917
|
+
const resumeAgents = getStepAgents(resumeNext.step);
|
|
1918
|
+
refuseImplementationStart(resumeAgents, (agent) => implementationDebugRetry(agent));
|
|
1919
|
+
recordAllowedDebugRetries(resumeAgents);
|
|
1920
|
+
activateAttempts(resumeNext.step, resumeNext.index);
|
|
1921
|
+
writeStatus({
|
|
1922
|
+
pipelineIndex: resumeNext.index,
|
|
1923
|
+
currentAgent: resumeAgents[0],
|
|
1924
|
+
phase: 'executing',
|
|
1925
|
+
state: 'in_progress',
|
|
1926
|
+
awaitingHumanGate: false,
|
|
1927
|
+
parallelCompleted: [],
|
|
1928
|
+
});
|
|
1929
|
+
if (resumeNext.step.parallel && resumeAgents.length > 1) out(handoffForParallelStep(resumeNext.step));
|
|
1930
|
+
else out(handoffForAgent(resumeAgents[0], resumeNext.step.scope, resumeNext.step));
|
|
1931
|
+
process.exit(0);
|
|
1932
|
+
}
|
|
1933
|
+
// Gate on the final step: no executable step remains. Complete the
|
|
1934
|
+
// pipeline instead of leaving it in_progress forever.
|
|
1935
|
+
status.state = 'completed';
|
|
1936
|
+
completePipeline({
|
|
1937
|
+
pipelineIndex: resumeSteps.length,
|
|
1938
|
+
phase: 'done',
|
|
1939
|
+
state: 'completed',
|
|
1940
|
+
currentAgent: null,
|
|
1941
|
+
awaitingHumanGate: false,
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
// A2 (retro §8): if gate closes the final human gate of the pipeline
|
|
1946
|
+
// (no resume happens, or current step's gate was the last), surface
|
|
1947
|
+
// state="awaiting_approval" so a subsequent /task-continue doesn't misinterpret
|
|
1948
|
+
// the post-gate idle state as "still in progress".
|
|
1949
|
+
{
|
|
1950
|
+
let gateWasTerminal = false;
|
|
1951
|
+
if (!hookInput.activateNext && fs.existsSync(pipelinePath)) {
|
|
1952
|
+
try {
|
|
1953
|
+
const pipe = JSON.parse(fs.readFileSync(pipelinePath, 'utf8'));
|
|
1954
|
+
const steps = pipe.steps || [];
|
|
1955
|
+
const idx = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
|
|
1956
|
+
const cur = steps[idx];
|
|
1957
|
+
const gates = Array.isArray(pipe.humanGates) ? pipe.humanGates : [];
|
|
1958
|
+
const hasGate = (step) => Array.isArray(gates) && gates.some((g) => typeof g === 'string' && getStepAgents(step).some((a) => g === `after:${a}`));
|
|
1959
|
+
if (cur && hasGate(cur)) gateWasTerminal = true;
|
|
1960
|
+
} catch {}
|
|
1961
|
+
}
|
|
1962
|
+
writeStatus({
|
|
1963
|
+
awaitingHumanGate: false,
|
|
1964
|
+
state: gateWasTerminal ? 'awaiting_approval' : status.state,
|
|
1965
|
+
phase: status.phase,
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1968
|
+
process.stdout.write(JSON.stringify({ ok: true, action: 'end_human_gate', activeHumanGateEventId: status.activeHumanGateEventId || null }));
|
|
1969
|
+
process.exit(0);
|
|
1970
|
+
}
|
|
1971
|
+
|
|
1972
|
+
if (!fs.existsSync(pipelinePath)) {
|
|
1973
|
+
legacyFlow();
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
let pipeline;
|
|
1977
|
+
let pipelineParseError = null;
|
|
1978
|
+
try {
|
|
1979
|
+
pipeline = JSON.parse(fs.readFileSync(pipelinePath, 'utf8'));
|
|
1980
|
+
} catch (error) {
|
|
1981
|
+
pipelineParseError = error;
|
|
1982
|
+
}
|
|
1983
|
+
// Modern pipelines carry an `intent` field. If pipeline.json is present but
|
|
1984
|
+
// unparseable, surface the error so the orchestrator can stop and report
|
|
1985
|
+
// instead of falling back to legacyFlow() — which silently drops modern
|
|
1986
|
+
// roles like `openspec-author`, `qa-tester`, and the test-planner trio.
|
|
1987
|
+
if (pipelineParseError) {
|
|
1988
|
+
if (fs.existsSync(pipelinePath)) {
|
|
1989
|
+
const raw = fs.readFileSync(pipelinePath, 'utf8');
|
|
1990
|
+
const hasModernIntent = /"intent"\s*:/.test(raw);
|
|
1991
|
+
appendMetric({
|
|
1992
|
+
eventId: `${status.metricsRunId || slug}:pipeline_parse_error:${Date.now()}`,
|
|
1993
|
+
type: 'pipeline_parse_error',
|
|
1994
|
+
at: now,
|
|
1995
|
+
source: 'hook',
|
|
1996
|
+
attributionConfidence: 'high',
|
|
1997
|
+
error: String(pipelineParseError.message || pipelineParseError),
|
|
1998
|
+
hasModernIntent,
|
|
1999
|
+
});
|
|
2000
|
+
if (hasModernIntent) {
|
|
2001
|
+
writeStatus({ state: 'blocked', phase: 'blocked', currentAgent: 'task-router' });
|
|
2002
|
+
process.stdout.write(JSON.stringify({
|
|
2003
|
+
followup_message: `pipeline.json is malformed for slug "${slug}" — JSON parse error: ${pipelineParseError.message}. Re-run the task-router to regenerate pipeline.json, then resume via /task-continue ${slug}.`,
|
|
2004
|
+
}));
|
|
2005
|
+
process.exit(0);
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
legacyFlow();
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
steps = pipeline.steps || [];
|
|
2012
|
+
if (isSchedulingEcho()) {
|
|
2013
|
+
process.stdout.write('{}');
|
|
2014
|
+
process.exit(0);
|
|
2015
|
+
}
|
|
2016
|
+
const initialIdx = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
|
|
2017
|
+
const initialStep = steps[initialIdx];
|
|
2018
|
+
const activeAttemptCountBeforeFinish = Object.keys(status.activeAttempts || {}).length;
|
|
2019
|
+
const completingAgentHint = (() => {
|
|
2020
|
+
const resolved = resolvedAttempt();
|
|
2021
|
+
if (resolved?.entry?.agent) return resolved.entry.agent;
|
|
2022
|
+
if (status.currentAgent) return status.currentAgent;
|
|
2023
|
+
return getStepAgents(initialStep)[0];
|
|
2024
|
+
})();
|
|
2025
|
+
const reconcilingAttempt = resolvedAttempt();
|
|
2026
|
+
const wasWaitingForReceipt = status.state === 'awaiting_artifact_receipt';
|
|
2027
|
+
reconcileStatusFromManifest(completingAgentHint, initialStep, reconcilingAttempt);
|
|
2028
|
+
if (status.state === 'awaiting_artifact_receipt') {
|
|
2029
|
+
writeStatus({});
|
|
2030
|
+
emitArtifactStall(artifactStallMessage, !wasWaitingForReceipt);
|
|
2031
|
+
process.exit(0);
|
|
2032
|
+
}
|
|
2033
|
+
let finishedAttempt = finishActiveAttempt();
|
|
2034
|
+
if (!finishedAttempt && activeAttemptCountBeforeFinish > 0) {
|
|
2035
|
+
if (!hookInput.attemptId) {
|
|
2036
|
+
const repaired = repairUnattributableStop();
|
|
2037
|
+
if (repaired) {
|
|
2038
|
+
appendMetric({ type: 'parallel_attribution_repair', at: now, attemptIds: [repaired.attemptId], source: 'hook', attributionConfidence: 'fallback' });
|
|
2039
|
+
reconcileStatusFromManifest(repaired.entry.agent, steps[repaired.entry.stepIndex], repaired);
|
|
2040
|
+
if (status.state === 'awaiting_artifact_receipt') {
|
|
2041
|
+
writeStatus({});
|
|
2042
|
+
emitArtifactStall(artifactStallMessage, true);
|
|
2043
|
+
process.exit(0);
|
|
2044
|
+
}
|
|
2045
|
+
finishedAttempt = finishActiveAttempt(repaired);
|
|
2046
|
+
} else {
|
|
2047
|
+
writeStatus({});
|
|
2048
|
+
out(repairHandoffMessage());
|
|
2049
|
+
process.exit(0);
|
|
2050
|
+
}
|
|
2051
|
+
} else {
|
|
2052
|
+
process.stdout.write('{}');
|
|
2053
|
+
process.exit(0);
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
endHumanGateIfResumed();
|
|
2057
|
+
if (steps.length === 0 || pipeline.autoChain === false) {
|
|
2058
|
+
writeStatus({});
|
|
2059
|
+
process.stdout.write('{}');
|
|
2060
|
+
process.exit(0);
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2063
|
+
if (status.awaitingHumanGate || status.state === 'awaiting_approval') {
|
|
2064
|
+
process.stdout.write('{}');
|
|
2065
|
+
process.exit(0);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
function nearestPrecedingStepIndex(agent, fromIndex, fallback) {
|
|
2069
|
+
for (let index = fromIndex - 1; index >= 0; index -= 1) {
|
|
2070
|
+
if (getStepAgents(steps[index]).includes(agent)) return index;
|
|
2071
|
+
}
|
|
2072
|
+
const match = steps.findIndex((step) => getStepAgents(step).includes(agent));
|
|
2073
|
+
return match >= 0 ? match : fallback;
|
|
2074
|
+
}
|
|
2075
|
+
function scheduleRetry(agent, retryAfterFix, predecessor, explicitStepIndex = null) {
|
|
2076
|
+
if (agent === 'feature-developer') {
|
|
2077
|
+
refuseImplementationStart([agent], () => retryAfterFix === 'debugger');
|
|
2078
|
+
}
|
|
2079
|
+
const currentIndex = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
|
|
2080
|
+
const explicitOk = Number.isInteger(explicitStepIndex) && getStepAgents(steps[explicitStepIndex]).includes(agent);
|
|
2081
|
+
const stepIndex = explicitOk ? explicitStepIndex : nearestPrecedingStepIndex(agent, currentIndex, -1);
|
|
2082
|
+
// Refuse to activate an agent the pipeline never planned; callers fall back to a human gate.
|
|
2083
|
+
if (stepIndex < 0) return -1;
|
|
2084
|
+
const predecessorAttemptId = predecessor?.attemptId || status.lastCompletedAttempt?.attemptId || null;
|
|
2085
|
+
appendMetric({ type: 'retry_scheduled', at: now, attemptId: predecessorAttemptId, nextAgent: agent, retryAfterFix: retryAfterFix || null, source: 'hook', attributionConfidence: predecessor ? predecessor.confidence : 'unknown' });
|
|
2086
|
+
activateAttempts(steps[stepIndex] || { agent }, stepIndex);
|
|
2087
|
+
return stepIndex;
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
const idx = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
|
|
2091
|
+
const currentStep = steps[idx];
|
|
2092
|
+
const completedAgent = finishedAttempt?.entry?.agent || status.currentAgent || getStepAgents(currentStep)[0];
|
|
2093
|
+
const completedStepIndex = Number.isInteger(finishedAttempt?.entry?.stepIndex) ? finishedAttempt.entry.stepIndex : idx;
|
|
2094
|
+
const stepAgents = getStepAgents(currentStep);
|
|
2095
|
+
const activeWave = isGraphMode() && Array.isArray(status.waveSteps) && status.waveSteps.filter((i) => Number.isInteger(i) && steps[i]).length > 0
|
|
2096
|
+
? status.waveSteps.filter((i) => Number.isInteger(i) && steps[i])
|
|
2097
|
+
: null;
|
|
2098
|
+
const waveIndexes = activeWave
|
|
2099
|
+
? activeWave
|
|
2100
|
+
: (currentStep?.parallel && stepAgents.length > 1
|
|
2101
|
+
? [idx]
|
|
2102
|
+
: (isGraphMode() && finishedAttempt ? [completedStepIndex] : null));
|
|
2103
|
+
|
|
2104
|
+
|
|
2105
|
+
if (waveIndexes) {
|
|
2106
|
+
const waveAgents = waveIndexes.flatMap((i) => getStepAgents(steps[i]));
|
|
2107
|
+
const done = [...(status.parallelCompleted || [])];
|
|
2108
|
+
if (isGraphMode()) {
|
|
2109
|
+
for (const waveStep of waveIndexes) {
|
|
2110
|
+
for (const waveAgent of getStepAgents(steps[waveStep])) {
|
|
2111
|
+
if (isSlotSatisfied(waveStep, waveAgent) && !done.includes(waveAgent)) done.push(waveAgent);
|
|
2112
|
+
}
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
const outcomes = { ...(status.parallelOutcomes || {}) };
|
|
2116
|
+
if (finishedAttempt && completedAgent) {
|
|
2117
|
+
if (!done.includes(completedAgent)) done.push(completedAgent);
|
|
2118
|
+
outcomes[completedAgent] = {
|
|
2119
|
+
outcome: finishedAttempt.outcome || status.state,
|
|
2120
|
+
attemptId: finishedAttempt.attemptId,
|
|
2121
|
+
confidence: finishedAttempt.confidence,
|
|
2122
|
+
};
|
|
2123
|
+
}
|
|
2124
|
+
if (finishedAttempt && completedAgent && isGraphMode() && (finishedAttempt.outcome || status.state) === 'completed') {
|
|
2125
|
+
const completedSlots = readJoinedSlots();
|
|
2126
|
+
completedSlots[graphSlotKey(completedStepIndex, completedAgent)] = {
|
|
2127
|
+
agent: completedAgent,
|
|
2128
|
+
stepIndex: completedStepIndex,
|
|
2129
|
+
attemptId: finishedAttempt.attemptId,
|
|
2130
|
+
outcome: 'completed',
|
|
2131
|
+
};
|
|
2132
|
+
status.joinedSlots = completedSlots;
|
|
2133
|
+
appendMetric({ type: 'step_joined', at: now, stepIndex: completedStepIndex, slotKeys: [graphSlotKey(completedStepIndex, completedAgent)], attemptIds: [finishedAttempt.attemptId], source: 'hook', attributionConfidence: 'high' });
|
|
2134
|
+
}
|
|
2135
|
+
writeStatus({ parallelCompleted: done, parallelOutcomes: outcomes });
|
|
2136
|
+
const remaining = waveAgents.filter((agent) => !done.includes(agent));
|
|
2137
|
+
if (remaining.length > 0) {
|
|
2138
|
+
process.stdout.write('{}');
|
|
2139
|
+
process.exit(0);
|
|
2140
|
+
}
|
|
2141
|
+
|
|
2142
|
+
const blockedProducer = waveAgents.find((agent) => outcomes[agent]?.outcome === 'blocked');
|
|
2143
|
+
if (blockedProducer) {
|
|
2144
|
+
if (isGraphMode()) {
|
|
2145
|
+
const blockedStepIndex = waveIndexes.find((i) => getStepAgents(steps[i]).includes(blockedProducer));
|
|
2146
|
+
status.blockedSteps = [...new Set([...(status.blockedSteps || []), blockedStepIndex])];
|
|
2147
|
+
writeStatus({ state: 'blocked', phase: 'blocked', currentAgent: blockedProducer, parallelCompleted: [], parallelOutcomes: {}, waveSteps: [], waveId: null });
|
|
2148
|
+
if (!dispatchReadyWave(`Step ${blockedStepIndex} (${blockedProducer}) is blocked; proceeding with independent ready steps.`)) out(blockedNotice(blockedStepIndex, blockedProducer));
|
|
2149
|
+
process.exit(0);
|
|
2150
|
+
}
|
|
2151
|
+
writeStatus({ parallelCompleted: [], parallelOutcomes: {}, state: 'blocked', phase: 'blocked', currentAgent: blockedProducer });
|
|
2152
|
+
process.stdout.write('{}');
|
|
2153
|
+
process.exit(0);
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2156
|
+
const retryReviewer = waveAgents.find((agent) => outcomes[agent]?.outcome === 'changes_requested');
|
|
2157
|
+
if (retryReviewer === 'mockup-reviewer') {
|
|
2158
|
+
beginHumanGate();
|
|
2159
|
+
writeStatus({
|
|
2160
|
+
awaitingHumanGate: true,
|
|
2161
|
+
state: 'awaiting_approval',
|
|
2162
|
+
currentAgent: 'mockup-reviewer',
|
|
2163
|
+
parallelCompleted: [],
|
|
2164
|
+
parallelOutcomes: {},
|
|
2165
|
+
waveSteps: [],
|
|
2166
|
+
waveId: null,
|
|
2167
|
+
});
|
|
2168
|
+
out(`Mockup review FAIL for slug "${slug}". Read mockup-review.md. Resume only via /task-continue. Do not retry feature-developer.`);
|
|
2169
|
+
process.exit(0);
|
|
2170
|
+
}
|
|
2171
|
+
if (retryReviewer) {
|
|
2172
|
+
if (isGraphMode()) {
|
|
2173
|
+
const reviewerStepIndex = waveIndexes.find((i) => getStepAgents(steps[i]).includes(retryReviewer));
|
|
2174
|
+
const producerIndex = resolveProducerStepIndex('feature-developer', reviewerStepIndex);
|
|
2175
|
+
if (producerIndex < 0) {
|
|
2176
|
+
beginHumanGate();
|
|
2177
|
+
writeStatus({ awaitingHumanGate: true, state: 'awaiting_approval', currentAgent: retryReviewer, parallelCompleted: [], parallelOutcomes: {}, waveSteps: [], waveId: null });
|
|
2178
|
+
out(`${retryReviewer} requested changes for slug "${slug}" but no graph ancestor authors fixes. Read the review artifact. Resume only via /task-continue.`);
|
|
2179
|
+
process.exit(0);
|
|
2180
|
+
}
|
|
2181
|
+
const graphPredecessor = outcomes[retryReviewer]
|
|
2182
|
+
? { attemptId: outcomes[retryReviewer].attemptId, confidence: outcomes[retryReviewer].confidence }
|
|
2183
|
+
: finishedAttempt;
|
|
2184
|
+
appendMetric({ type: 'retry_scheduled', at: now, attemptId: graphPredecessor?.attemptId || status.lastCompletedAttempt?.attemptId || null, nextAgent: 'feature-developer', retryAfterFix: retryReviewer, source: 'hook', attributionConfidence: graphPredecessor ? graphPredecessor.confidence : 'unknown' });
|
|
2185
|
+
invalidateFrom(producerIndex, reviewerStepIndex);
|
|
2186
|
+
const siblingOutcomes = { ...(status.parallelOutcomes || {}) };
|
|
2187
|
+
delete siblingOutcomes[retryReviewer];
|
|
2188
|
+
status.parallelOutcomes = siblingOutcomes;
|
|
2189
|
+
writeStatus({ state: 'in_progress', phase: 'executing', waveSteps: [], waveId: null, retryAfterFix: null, retryAfterFixStepIndex: null });
|
|
2190
|
+
if (!dispatchReadyWave(`Step ${reviewerStepIndex} (${retryReviewer}) requested changes; re-dispatching unsatisfied steps.`)) out(noProgressNotice());
|
|
2191
|
+
process.exit(0);
|
|
2192
|
+
}
|
|
2193
|
+
const retryAfterFixStepIndex = idx;
|
|
2194
|
+
const predecessor = outcomes[retryReviewer]
|
|
2195
|
+
? {
|
|
2196
|
+
attemptId: outcomes[retryReviewer].attemptId,
|
|
2197
|
+
confidence: outcomes[retryReviewer].confidence,
|
|
2198
|
+
}
|
|
2199
|
+
: finishedAttempt;
|
|
2200
|
+
const developerIndex = scheduleRetry('feature-developer', retryReviewer, predecessor);
|
|
2201
|
+
if (developerIndex < 0) {
|
|
2202
|
+
beginHumanGate();
|
|
2203
|
+
writeStatus({
|
|
2204
|
+
awaitingHumanGate: true,
|
|
2205
|
+
state: 'awaiting_approval',
|
|
2206
|
+
currentAgent: retryReviewer,
|
|
2207
|
+
parallelCompleted: [],
|
|
2208
|
+
parallelOutcomes: {},
|
|
2209
|
+
});
|
|
2210
|
+
out(`${retryReviewer} requested changes for slug "${slug}" but this pipeline has no feature-developer step. Read the review artifact. Resume only via /task-continue.`);
|
|
2211
|
+
process.exit(0);
|
|
2212
|
+
}
|
|
2213
|
+
writeStatus({
|
|
2214
|
+
pipelineIndex: developerIndex,
|
|
2215
|
+
currentAgent: 'feature-developer',
|
|
2216
|
+
state: 'in_progress',
|
|
2217
|
+
phase: 'executing',
|
|
2218
|
+
retryAfterFix: retryReviewer,
|
|
2219
|
+
retryAfterFixStepIndex,
|
|
2220
|
+
parallelCompleted: [],
|
|
2221
|
+
parallelOutcomes: {},
|
|
2222
|
+
});
|
|
2223
|
+
out(handoffForAgent('feature-developer', steps[developerIndex]?.scope, steps[developerIndex]) + ` After fixes, re-run ${retryReviewer}.`);
|
|
2224
|
+
process.exit(0);
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
if (isGraphMode()) {
|
|
2228
|
+
const validationProducer = waveAgents.find((agent) => outcomes[agent]?.outcome === 'validation_failed');
|
|
2229
|
+
if (validationProducer) {
|
|
2230
|
+
const verifierStepIndex = waveIndexes.find((i) => getStepAgents(steps[i]).includes(validationProducer));
|
|
2231
|
+
const producerIndex = resolveProducerStepIndex('feature-developer', verifierStepIndex);
|
|
2232
|
+
if (producerIndex >= 0) {
|
|
2233
|
+
appendMetric({ type: 'retry_scheduled', at: now, attemptId: outcomes[validationProducer]?.attemptId || null, nextAgent: 'feature-developer', retryAfterFix: validationProducer, source: 'hook', attributionConfidence: 'fallback' });
|
|
2234
|
+
invalidateFrom(producerIndex, verifierStepIndex);
|
|
2235
|
+
writeStatus({ state: 'in_progress', phase: 'executing', parallelCompleted: [], parallelOutcomes: {}, waveSteps: [], waveId: null });
|
|
2236
|
+
if (dispatchReadyWave(`Step ${verifierStepIndex} (${validationProducer}) failed validation; re-dispatching unsatisfied steps.`)) process.exit(0);
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
const gatedStep = waveIndexes.find((i) => hasGateAfterStep(steps[i], pipeline.humanGates));
|
|
2240
|
+
if (gatedStep !== undefined) {
|
|
2241
|
+
beginHumanGate();
|
|
2242
|
+
writeStatus({ awaitingHumanGate: true, state: 'awaiting_approval', currentAgent: completedAgent, pipelineIndex: gatedStep, parallelCompleted: [], parallelOutcomes: {}, waveSteps: [], waveId: null });
|
|
2243
|
+
process.stdout.write('{}');
|
|
2244
|
+
process.exit(0);
|
|
2245
|
+
}
|
|
2246
|
+
writeStatus({ parallelCompleted: [], parallelOutcomes: {}, waveSteps: [], waveId: null, state: 'completed' });
|
|
2247
|
+
if (dispatchReadyWave()) process.exit(0);
|
|
2248
|
+
if (Object.keys(status.activeAttempts || {}).length > 0) {
|
|
2249
|
+
process.stdout.write('{}');
|
|
2250
|
+
process.exit(0);
|
|
2251
|
+
}
|
|
2252
|
+
if (pendingStepIndexes().length === 0) {
|
|
2253
|
+
completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
|
|
2254
|
+
}
|
|
2255
|
+
out(noProgressNotice());
|
|
2256
|
+
process.exit(0);
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
writeStatus({ parallelCompleted: [], parallelOutcomes: {}, state: 'completed' });
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
if (status.state === 'blocked') {
|
|
2263
|
+
if (isGraphMode()) {
|
|
2264
|
+
status.blockedSteps = [...new Set([...(status.blockedSteps || []), idx])];
|
|
2265
|
+
writeStatus({ state: 'blocked', phase: 'blocked', currentAgent: completedAgent, waveSteps: [], waveId: null, parallelCompleted: [], parallelOutcomes: {} });
|
|
2266
|
+
if (!dispatchReadyWave(`Step ${idx} (${completedAgent}) is blocked; proceeding with independent ready steps.`)) out(blockedNotice(idx, completedAgent));
|
|
2267
|
+
process.exit(0);
|
|
2268
|
+
}
|
|
2269
|
+
writeStatus({ state: 'blocked', phase: 'blocked', currentAgent: completedAgent });
|
|
2270
|
+
process.stdout.write('{}');
|
|
2271
|
+
process.exit(0);
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
if (status.state === 'changes_requested' && (completedAgent === 'mockup-reviewer' || status.currentAgent === 'mockup-reviewer')) {
|
|
2275
|
+
beginHumanGate();
|
|
2276
|
+
writeStatus({
|
|
2277
|
+
awaitingHumanGate: true,
|
|
2278
|
+
state: 'awaiting_approval',
|
|
2279
|
+
currentAgent: 'mockup-reviewer',
|
|
2280
|
+
});
|
|
2281
|
+
out(`Mockup review FAIL for slug "${slug}". Read mockup-review.md. Resume only via /task-continue. Do not retry feature-developer.`);
|
|
2282
|
+
process.exit(0);
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
if (status.state === 'changes_requested') {
|
|
2286
|
+
const reviewer = status.currentAgent || finishedAttempt?.entry?.agent;
|
|
2287
|
+
if (!reviewer) {
|
|
2288
|
+
process.stdout.write('{}');
|
|
2289
|
+
process.exit(0);
|
|
2290
|
+
}
|
|
2291
|
+
const retryAfterFixStepIndex = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
|
|
2292
|
+
const developerIndex = scheduleRetry('feature-developer', reviewer, finishedAttempt);
|
|
2293
|
+
if (developerIndex < 0) {
|
|
2294
|
+
beginHumanGate();
|
|
2295
|
+
writeStatus({ awaitingHumanGate: true, state: 'awaiting_approval', currentAgent: reviewer });
|
|
2296
|
+
out(`${reviewer} requested changes for slug "${slug}" but this pipeline has no feature-developer step. Read the review artifact. Resume only via /task-continue.`);
|
|
2297
|
+
process.exit(0);
|
|
2298
|
+
}
|
|
2299
|
+
writeStatus({
|
|
2300
|
+
pipelineIndex: developerIndex,
|
|
2301
|
+
currentAgent: 'feature-developer',
|
|
2302
|
+
state: 'in_progress',
|
|
2303
|
+
phase: 'executing',
|
|
2304
|
+
retryAfterFix: reviewer,
|
|
2305
|
+
retryAfterFixStepIndex,
|
|
2306
|
+
});
|
|
2307
|
+
out(handoffForAgent('feature-developer', steps[developerIndex]?.scope, steps[developerIndex]) + ` After fixes, re-run ${reviewer}.`);
|
|
2308
|
+
process.exit(0);
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
if (status.state === 'validation_failed' && status.currentAgent === 'build-verifier') {
|
|
2312
|
+
const retryAfterFixStepIndex = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
|
|
2313
|
+
const developerIndex = scheduleRetry('feature-developer', 'build-verifier', finishedAttempt);
|
|
2314
|
+
if (developerIndex < 0) {
|
|
2315
|
+
beginHumanGate();
|
|
2316
|
+
writeStatus({ awaitingHumanGate: true, state: 'awaiting_approval', currentAgent: 'build-verifier' });
|
|
2317
|
+
out(`Validation failed for slug "${slug}" but this pipeline has no feature-developer step. Read validation-report.md. Resume only via /task-continue.`);
|
|
2318
|
+
process.exit(0);
|
|
2319
|
+
}
|
|
2320
|
+
writeStatus({
|
|
2321
|
+
pipelineIndex: developerIndex,
|
|
2322
|
+
currentAgent: 'feature-developer',
|
|
2323
|
+
state: 'in_progress',
|
|
2324
|
+
phase: 'executing',
|
|
2325
|
+
retryAfterFix: 'build-verifier',
|
|
2326
|
+
retryAfterFixStepIndex,
|
|
2327
|
+
});
|
|
2328
|
+
out(handoffForAgent('feature-developer', steps[developerIndex]?.scope, steps[developerIndex]) + ' Read validation-report.md. After fixes, re-run build-verifier.');
|
|
2329
|
+
process.exit(0);
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
if (status.state === 'completed' && status.retryAfterFix) {
|
|
2333
|
+
const retry = status.retryAfterFix;
|
|
2334
|
+
const retryIndex = scheduleRetry(retry, null, finishedAttempt, status.retryAfterFixStepIndex);
|
|
2335
|
+
if (retryIndex >= 0) {
|
|
2336
|
+
writeStatus({ pipelineIndex: retryIndex, currentAgent: retry, state: 'in_progress', retryAfterFix: null, retryAfterFixStepIndex: null });
|
|
2337
|
+
out(handoffForAgent(retry, steps[retryIndex]?.scope, steps[retryIndex]));
|
|
2338
|
+
process.exit(0);
|
|
2339
|
+
}
|
|
2340
|
+
// The reviewer to re-run is no longer in steps[]; drop the marker and advance normally.
|
|
2341
|
+
writeStatus({ retryAfterFix: null, retryAfterFixStepIndex: null });
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
if (!currentStep) {
|
|
2345
|
+
completePipeline({ phase: 'done', state: 'completed', currentAgent: null });
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
if (hasGateAfterStep(currentStep, pipeline.humanGates)) {
|
|
2349
|
+
beginHumanGate();
|
|
2350
|
+
writeStatus({
|
|
2351
|
+
awaitingHumanGate: true,
|
|
2352
|
+
state: 'awaiting_approval',
|
|
2353
|
+
currentAgent: completedAgent,
|
|
2354
|
+
});
|
|
2355
|
+
process.stdout.write('{}');
|
|
2356
|
+
process.exit(0);
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
if (isGraphMode()) {
|
|
2360
|
+
if (Object.keys(status.activeAttempts || {}).length > 0) {
|
|
2361
|
+
process.stdout.write('{}');
|
|
2362
|
+
process.exit(0);
|
|
2363
|
+
}
|
|
2364
|
+
if (dispatchReadyWave()) process.exit(0);
|
|
2365
|
+
if (pendingStepIndexes().length === 0) {
|
|
2366
|
+
completePipeline({ pipelineIndex: steps.length, phase: 'done', state: 'completed', currentAgent: null, awaitingHumanGate: false });
|
|
2367
|
+
}
|
|
2368
|
+
out(noProgressNotice());
|
|
2369
|
+
process.exit(0);
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
const next = findNextExecutableStep(steps, idx + 1, taskDir);
|
|
2373
|
+
if (!next) {
|
|
2374
|
+
completePipeline({
|
|
2375
|
+
pipelineIndex: steps.length,
|
|
2376
|
+
phase: 'done',
|
|
2377
|
+
state: 'completed',
|
|
2378
|
+
currentAgent: null,
|
|
2379
|
+
awaitingHumanGate: false,
|
|
2380
|
+
});
|
|
2381
|
+
}
|
|
2382
|
+
|
|
2383
|
+
const { step: nextStep, index: nextIdx } = next;
|
|
2384
|
+
const nextAgents = getStepAgents(nextStep);
|
|
2385
|
+
|
|
2386
|
+
refuseImplementationStart(nextAgents, (agent) => implementationDebugRetry(agent));
|
|
2387
|
+
recordAllowedDebugRetries(nextAgents);
|
|
2388
|
+
activateAttempts(nextStep, nextIdx);
|
|
2389
|
+
writeStatus({
|
|
2390
|
+
pipelineIndex: nextIdx,
|
|
2391
|
+
currentAgent: nextAgents[0],
|
|
2392
|
+
phase: 'executing',
|
|
2393
|
+
state: 'in_progress',
|
|
2394
|
+
awaitingHumanGate: false,
|
|
2395
|
+
parallelCompleted: [],
|
|
2396
|
+
});
|
|
2397
|
+
|
|
2398
|
+
if (nextStep.parallel && nextAgents.length > 1) {
|
|
2399
|
+
out(handoffForParallelStep(nextStep));
|
|
2400
|
+
} else {
|
|
2401
|
+
out(handoffForAgent(nextAgents[0], nextStep.scope, nextStep));
|
|
2402
|
+
}
|
|
2403
|
+
NODE
|
|
2404
|
+
|
|
2405
|
+
# --- In-task self-learning postflight ----------------------------------------
|
|
2406
|
+
# One loop run per completed stop, as a second process: capture must not depend
|
|
2407
|
+
# on an agent remembering to run it. The child's stdout is forwarded to stderr
|
|
2408
|
+
# so the hook's own stdout contract (the JSON above) is untouched; `|| true`
|
|
2409
|
+
# plus an unconditional exit 0 keep a loop failure from failing the task; and
|
|
2410
|
+
# `--strict` is never passed — a gate must not live in a hook.
|
|
2411
|
+
INPUT="$input" node <<'POSTFLIGHT' || true
|
|
2412
|
+
const fs = require('fs');
|
|
2413
|
+
const path = require('path');
|
|
2414
|
+
const { spawnSync } = require('child_process');
|
|
2415
|
+
|
|
2416
|
+
// <<<standards-draft>>>
|
|
2417
|
+
// Explicit payload only. This postflight never walks the repo and never
|
|
2418
|
+
// creates `.ai.local/rules/`. The same provenance tag does not rewrite an
|
|
2419
|
+
// accepted Gotchas, Patterns, or Decisions line.
|
|
2420
|
+
function standardsDraftTag(provenance) {
|
|
2421
|
+
return '(`' + provenance + '`)';
|
|
2422
|
+
}
|
|
2423
|
+
|
|
2424
|
+
function standardsDraftLineIndex(content, header) {
|
|
2425
|
+
if (content.startsWith(header) && (content.length === header.length || content.charAt(header.length) === '\n')) return 0;
|
|
2426
|
+
const at = content.indexOf('\n' + header + '\n');
|
|
2427
|
+
if (at !== -1) return at + 1;
|
|
2428
|
+
if (content.endsWith('\n' + header)) return content.length - header.length;
|
|
2429
|
+
return -1;
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
function standardsDraftSection(content, name) {
|
|
2433
|
+
const header = '## ' + name;
|
|
2434
|
+
const start = standardsDraftLineIndex(content, header);
|
|
2435
|
+
if (start === -1) return null;
|
|
2436
|
+
const from = start + header.length;
|
|
2437
|
+
const next = content.indexOf('\n## ', from);
|
|
2438
|
+
const end = next === -1 ? content.length : next;
|
|
2439
|
+
return content.slice(start, end);
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
function standardsDraftProtected(content) {
|
|
2443
|
+
const names = ['Language', 'Gotchas', 'Patterns', 'Decisions', 'Advisory index'];
|
|
2444
|
+
let snapshot = '';
|
|
2445
|
+
for (let index = 0; index < names.length; index += 1) {
|
|
2446
|
+
const body = standardsDraftSection(content, names[index]);
|
|
2447
|
+
snapshot += names[index] + '\n' + (body === null ? '' : body) + '\n';
|
|
2448
|
+
}
|
|
2449
|
+
return snapshot;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
function standardsDraftNormalize(line) {
|
|
2453
|
+
return line.trim().replace(/\s+/g, ' ').replace(/^-\s+/, '').replace(/\s+\(`[^`]*`\)$/, '').toLowerCase();
|
|
2454
|
+
}
|
|
2455
|
+
|
|
2456
|
+
function standardsDraftAccepted(content, text) {
|
|
2457
|
+
const pending = standardsDraftSection(content, 'Pending');
|
|
2458
|
+
let rest = content;
|
|
2459
|
+
if (pending !== null) {
|
|
2460
|
+
const start = content.indexOf(pending);
|
|
2461
|
+
rest = content.slice(0, start) + content.slice(start + pending.length);
|
|
2462
|
+
}
|
|
2463
|
+
const needle = standardsDraftNormalize(text);
|
|
2464
|
+
if (!needle) return false;
|
|
2465
|
+
const lines = rest.split('\n');
|
|
2466
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
2467
|
+
const line = lines[index];
|
|
2468
|
+
if (!/^-\s+\S/.test(line)) continue;
|
|
2469
|
+
if (standardsDraftNormalize(line) === needle) return true;
|
|
2470
|
+
}
|
|
2471
|
+
return false;
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
function standardsDraftAppendPending(content, line) {
|
|
2475
|
+
const header = '## Pending';
|
|
2476
|
+
const start = standardsDraftLineIndex(content, header);
|
|
2477
|
+
if (start === -1) {
|
|
2478
|
+
const sep = content.endsWith('\n') ? '\n' : '\n\n';
|
|
2479
|
+
return content + sep + header + '\n\n' + line + '\n';
|
|
2480
|
+
}
|
|
2481
|
+
const from = start + header.length;
|
|
2482
|
+
const next = content.indexOf('\n## ', from);
|
|
2483
|
+
const end = next === -1 ? content.length : next;
|
|
2484
|
+
let body = content.slice(from, end);
|
|
2485
|
+
const hasBullet = /(^|\n)-\s+\S/.test(body);
|
|
2486
|
+
if (!hasBullet && /(^|\n)-[ \t]*(?=\n|$)/.test(body)) {
|
|
2487
|
+
body = body.replace(/(^|\n)-[ \t]*(?=\n|$)/, '$1' + line);
|
|
2488
|
+
} else if (body.endsWith('\n\n')) {
|
|
2489
|
+
body = body.slice(0, -1) + line + '\n\n';
|
|
2490
|
+
} else if (body.endsWith('\n')) {
|
|
2491
|
+
body = body + line + '\n';
|
|
2492
|
+
} else {
|
|
2493
|
+
body = body + '\n' + line + '\n';
|
|
2494
|
+
}
|
|
2495
|
+
return content.slice(0, from) + body + content.slice(end);
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2498
|
+
function standardsDraftProvenance(draft) {
|
|
2499
|
+
if (!draft || typeof draft.provenance !== 'string') return '';
|
|
2500
|
+
const provenance = draft.provenance.trim();
|
|
2501
|
+
if (/^incident: [A-Za-z0-9][A-Za-z0-9._:-]{0,80}$/.test(provenance)) return provenance;
|
|
2502
|
+
const read = /^read: ([A-Za-z0-9][A-Za-z0-9._/-]{0,160})$/.exec(provenance);
|
|
2503
|
+
if (!read) return '';
|
|
2504
|
+
const parts = read[1].split('/');
|
|
2505
|
+
if (parts.indexOf('..') !== -1 || parts.indexOf('.') !== -1) return '';
|
|
2506
|
+
if (read[1] === '.ai.local/rules' || read[1].indexOf('.ai.local/rules/') === 0) return '';
|
|
2507
|
+
return provenance;
|
|
2508
|
+
}
|
|
2509
|
+
|
|
2510
|
+
function standardsDraftWrite(target, content) {
|
|
2511
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
2512
|
+
const temporary = target + '.' + String(process.pid) + '.tmp';
|
|
2513
|
+
fs.writeFileSync(temporary, content);
|
|
2514
|
+
fs.renameSync(temporary, target);
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
function appendOptionalStandardsDraft(root, draft) {
|
|
2518
|
+
const provenance = standardsDraftProvenance(draft);
|
|
2519
|
+
if (!provenance) return { wrote: false, reason: 'provenance' };
|
|
2520
|
+
const text = draft && typeof draft.text === 'string' ? draft.text.trim() : '';
|
|
2521
|
+
if (!text || text.length > 400 || text.indexOf('\n') !== -1 || text.indexOf('\r') !== -1 || text.indexOf('## ') !== -1) {
|
|
2522
|
+
return { wrote: false, reason: 'text' };
|
|
2523
|
+
}
|
|
2524
|
+
let destination = 'conventions';
|
|
2525
|
+
if (draft.destination != null) {
|
|
2526
|
+
if (draft.destination === 'conventions' || draft.destination === 'rules-library') destination = draft.destination;
|
|
2527
|
+
else return { wrote: false, reason: 'destination' };
|
|
2528
|
+
}
|
|
2529
|
+
const line = '- ' + text + ' ' + standardsDraftTag(provenance);
|
|
2530
|
+
const overlay = path.join(root, '.ai.local');
|
|
2531
|
+
const rulesDir = path.join(overlay, 'rules');
|
|
2532
|
+
const rulesPrefix = rulesDir + path.sep;
|
|
2533
|
+
|
|
2534
|
+
if (destination === 'rules-library') {
|
|
2535
|
+
const stem = draft && typeof draft.stem === 'string' ? draft.stem : '';
|
|
2536
|
+
if (!/^[a-z0-9]+(?:-[a-z0-9]+){0,8}$/.test(stem) || stem.length > 48) {
|
|
2537
|
+
return { wrote: false, reason: 'stem' };
|
|
2538
|
+
}
|
|
2539
|
+
const libraryDir = path.join(overlay, 'rules-library');
|
|
2540
|
+
const target = path.join(libraryDir, stem + '.md');
|
|
2541
|
+
const libraryPrefix = libraryDir + path.sep;
|
|
2542
|
+
if (!target.startsWith(libraryPrefix)) return { wrote: false, reason: 'path' };
|
|
2543
|
+
if (target === rulesDir || target.startsWith(rulesPrefix)) return { wrote: false, reason: 'rules' };
|
|
2544
|
+
let existing = null;
|
|
2545
|
+
try {
|
|
2546
|
+
existing = fs.readFileSync(target, 'utf8');
|
|
2547
|
+
} catch (error) {
|
|
2548
|
+
if (!error || error.code !== 'ENOENT') throw error;
|
|
2549
|
+
}
|
|
2550
|
+
if (existing !== null) {
|
|
2551
|
+
if (existing.indexOf(standardsDraftTag(provenance)) !== -1) {
|
|
2552
|
+
return { wrote: false, reason: 'same-provenance', target: target };
|
|
2553
|
+
}
|
|
2554
|
+
const prefix = existing.endsWith('\n') ? '' : '\n';
|
|
2555
|
+
fs.appendFileSync(target, prefix + line + '\n');
|
|
2556
|
+
return { wrote: true, target: target, mode: 'append-provenance' };
|
|
2557
|
+
}
|
|
2558
|
+
standardsDraftWrite(target, '# ' + stem + '\n\nPending draft. Inactive until a human moves this file into `.ai.local/rules/`.\n\n' + line + '\n');
|
|
2559
|
+
return { wrote: true, target: target, mode: 'create' };
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
const conventionsPath = path.join(overlay, 'conventions.md');
|
|
2563
|
+
if (conventionsPath === rulesDir || conventionsPath.startsWith(rulesPrefix)) {
|
|
2564
|
+
return { wrote: false, reason: 'rules' };
|
|
2565
|
+
}
|
|
2566
|
+
let content = null;
|
|
2567
|
+
try {
|
|
2568
|
+
content = fs.readFileSync(conventionsPath, 'utf8');
|
|
2569
|
+
} catch (error) {
|
|
2570
|
+
if (!error || error.code !== 'ENOENT') throw error;
|
|
2571
|
+
}
|
|
2572
|
+
if (content === null) content = '# Living conventions\n';
|
|
2573
|
+
if (content.indexOf(standardsDraftTag(provenance)) !== -1) {
|
|
2574
|
+
return { wrote: false, reason: 'same-provenance', target: conventionsPath };
|
|
2575
|
+
}
|
|
2576
|
+
const before = standardsDraftProtected(content);
|
|
2577
|
+
const next = standardsDraftAppendPending(content, line);
|
|
2578
|
+
if (standardsDraftProtected(next) !== before) {
|
|
2579
|
+
return { wrote: false, reason: 'protected', target: conventionsPath };
|
|
2580
|
+
}
|
|
2581
|
+
standardsDraftWrite(conventionsPath, next);
|
|
2582
|
+
return {
|
|
2583
|
+
wrote: true,
|
|
2584
|
+
target: conventionsPath,
|
|
2585
|
+
mode: standardsDraftAccepted(content, text) ? 'provenance-only' : 'pending',
|
|
2586
|
+
};
|
|
2587
|
+
}
|
|
2588
|
+
// <<<standards-draft-end>>>
|
|
2589
|
+
|
|
2590
|
+
let input;
|
|
2591
|
+
try {
|
|
2592
|
+
input = JSON.parse(process.env.INPUT || '');
|
|
2593
|
+
} catch {
|
|
2594
|
+
process.exit(0);
|
|
2595
|
+
}
|
|
2596
|
+
if (!input || input.status !== 'completed') {
|
|
2597
|
+
process.exit(0);
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2600
|
+
// --- TEAM_DB_PROJECTION -------------------------------------------------------
|
|
2601
|
+
// The status, metrics, compaction and focus writes are already durable when this
|
|
2602
|
+
// postflight starts. The projection is a bounded child process: it must never
|
|
2603
|
+
// fail this stop, never change hook stdout/stderr beyond the capability line,
|
|
2604
|
+
// and never write a task file. A disabled switch, a missing script, or a
|
|
2605
|
+
// runtime without `node:sqlite` is a skip; a child failure is one log line.
|
|
2606
|
+
// This is a plain region marker, not a `hook-slot`: the block is identical in
|
|
2607
|
+
// all 40 rendered bodies and needs no per-stack fragment.
|
|
2608
|
+
// <<<team-db-projection>>>
|
|
2609
|
+
function teamDbTruthy(value) {
|
|
2610
|
+
if (typeof value !== 'string') return false;
|
|
2611
|
+
const normalized = value.trim().toLowerCase();
|
|
2612
|
+
return normalized === '1' || normalized === 'true' || normalized === 'yes';
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
function teamDbLogPath(env) {
|
|
2616
|
+
const override = typeof env.AI_RULES_TEAM_DB_LOG === 'string' ? env.AI_RULES_TEAM_DB_LOG.trim() : '';
|
|
2617
|
+
if (override) return path.resolve(override);
|
|
2618
|
+
return path.join(process.cwd(), '.ai.local', 'team', 'team-db-errors.log');
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
function teamDbLogPhase(env) {
|
|
2622
|
+
const value = typeof env.AI_RULES_TEAM_DB_SEAM === 'string' ? env.AI_RULES_TEAM_DB_SEAM.trim() : '';
|
|
2623
|
+
return value === 'hook' || value === 'receipt' || value === 'cli' || value === 'serve' ? value : 'hook';
|
|
2624
|
+
}
|
|
2625
|
+
|
|
2626
|
+
// One line per failure, newest 200 lines and at most 64 KiB. Never a prompt
|
|
2627
|
+
// body: only the code and the message this block owns.
|
|
2628
|
+
function teamDbLogFailure(env, code, message) {
|
|
2629
|
+
try {
|
|
2630
|
+
const target = teamDbLogPath(env);
|
|
2631
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
2632
|
+
const line = new Date().toISOString() + ' ' + code + ' ' + teamDbLogPhase(env) + ' ' + message;
|
|
2633
|
+
fs.appendFileSync(target, line + '\n');
|
|
2634
|
+
let content = fs.readFileSync(target, 'utf8');
|
|
2635
|
+
let lines = content.split('\n').filter(function (entry) { return entry.length > 0; });
|
|
2636
|
+
if (lines.length > 200) lines = lines.slice(lines.length - 200);
|
|
2637
|
+
while (Buffer.byteLength(lines.join('\n') + '\n', 'utf8') > 65536 && lines.length > 1) lines.shift();
|
|
2638
|
+
content = lines.join('\n') + (lines.length > 0 ? '\n' : '');
|
|
2639
|
+
fs.writeFileSync(target, content);
|
|
2640
|
+
} catch (error) {
|
|
2641
|
+
/* a log failure is not a stop failure */
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
|
|
2645
|
+
function teamDbSqliteAvailable(env) {
|
|
2646
|
+
if (teamDbTruthy(env.AI_RULES_TEAM_DB_FORCE_FALLBACK)) return false;
|
|
2647
|
+
const match = /^(\d+)\.(\d+)\.(\d+)/.exec(String(process.versions.node || ''));
|
|
2648
|
+
if (!match) return false;
|
|
2649
|
+
const major = Number(match[1]);
|
|
2650
|
+
const minor = Number(match[2]);
|
|
2651
|
+
if (major < 22) return false;
|
|
2652
|
+
if (major === 22 && minor < 13) return false;
|
|
2653
|
+
try {
|
|
2654
|
+
const sqlite = require('node:sqlite');
|
|
2655
|
+
return typeof sqlite.DatabaseSync === 'function';
|
|
2656
|
+
} catch (error) {
|
|
2657
|
+
return false;
|
|
2658
|
+
}
|
|
2659
|
+
}
|
|
2660
|
+
|
|
2661
|
+
function teamDbProject() {
|
|
2662
|
+
try {
|
|
2663
|
+
const env = process.env;
|
|
2664
|
+
if (teamDbTruthy(env.AI_RULES_TEAM_DB_DISABLE)) return;
|
|
2665
|
+
// Same pattern as POSTFLIGHT_SLUG_RE above: the slug is re-derived from
|
|
2666
|
+
// `active-task.json` on this path too, so it cannot escape the tree.
|
|
2667
|
+
const slugPattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
2668
|
+
let slug = '';
|
|
2669
|
+
try {
|
|
2670
|
+
const active = JSON.parse(fs.readFileSync(path.join(process.cwd(), '.ai.local', 'team', 'active-task.json'), 'utf8'));
|
|
2671
|
+
slug = typeof active.slug === 'string' ? active.slug : '';
|
|
2672
|
+
} catch (error) {
|
|
2673
|
+
return;
|
|
2674
|
+
}
|
|
2675
|
+
if (!slug || slug.length > 48 || !slugPattern.test(slug)) return;
|
|
2676
|
+
const taskDir = path.join(process.cwd(), '.ai.local', 'team', 'tasks', slug);
|
|
2677
|
+
if (!fs.existsSync(path.join(taskDir, 'status.json'))) return;
|
|
2678
|
+
const script = path.join(process.cwd(), '.ai.local', 'scripts', 'team-db.mjs');
|
|
2679
|
+
if (!fs.existsSync(script)) return;
|
|
2680
|
+
if (!teamDbSqliteAvailable(env)) {
|
|
2681
|
+
process.stderr.write('team-db: projection skipped (node:sqlite unavailable); file-only mode\n');
|
|
2682
|
+
return;
|
|
2683
|
+
}
|
|
2684
|
+
const result = spawnSync(
|
|
2685
|
+
process.execPath,
|
|
2686
|
+
['.ai.local/scripts/team-db.mjs', 'sync', '--slug', slug, '--quiet', '--no-rebuild', '--deadline-ms', '4500'],
|
|
2687
|
+
{ cwd: process.cwd(), env: env, encoding: 'utf8', timeout: 5000, killSignal: 'SIGKILL', stdio: ['ignore', 'pipe', 'pipe'] },
|
|
2688
|
+
);
|
|
2689
|
+
if (result.error && result.error.code === 'ETIMEDOUT') {
|
|
2690
|
+
teamDbLogFailure(env, 'E_PROJECTION_TIMEOUT', 'projection exceeded 5000 ms and was killed');
|
|
2691
|
+
return;
|
|
2692
|
+
}
|
|
2693
|
+
if (result.error) {
|
|
2694
|
+
teamDbLogFailure(env, 'E_PROJECTION_FAILED', 'projection could not start: ' + String(result.error.code || 'unknown'));
|
|
2695
|
+
return;
|
|
2696
|
+
}
|
|
2697
|
+
if (typeof result.status === 'number' && result.status !== 0) {
|
|
2698
|
+
teamDbLogFailure(env, 'E_PROJECTION_FAILED', 'projection exited ' + result.status);
|
|
2699
|
+
}
|
|
2700
|
+
} catch (error) {
|
|
2701
|
+
/* the seam never fails the stop */
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
|
|
2705
|
+
teamDbProject();
|
|
2706
|
+
// <<<team-db-projection-end>>>
|
|
2707
|
+
// --- end TEAM_DB_PROJECTION ---------------------------------------------------
|
|
2708
|
+
|
|
2709
|
+
// Ratchet: off for `light` pipelines and `spike` intents. A policy skip is
|
|
2710
|
+
// silent on purpose — a warning on every light receipt would make the
|
|
2711
|
+
// containment warnings below unreadable.
|
|
2712
|
+
let pipeline = null;
|
|
2713
|
+
try {
|
|
2714
|
+
const teamRoot = path.join(process.cwd(), '.ai.local', 'team');
|
|
2715
|
+
const active = JSON.parse(fs.readFileSync(path.join(teamRoot, 'active-task.json'), 'utf8'));
|
|
2716
|
+
const pipelineSlug = typeof active.slug === 'string' ? active.slug : '';
|
|
2717
|
+
// Same pattern as `SLUG_RE` at the top of this file: `tasks/<slug>` is
|
|
2718
|
+
// re-derived from `active-task.json` here too, so an unchecked slug could
|
|
2719
|
+
// escape the tree on this path exactly as it could there.
|
|
2720
|
+
const POSTFLIGHT_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
2721
|
+
if (pipelineSlug.length <= 48 && POSTFLIGHT_SLUG_RE.test(pipelineSlug)) {
|
|
2722
|
+
pipeline = JSON.parse(fs.readFileSync(path.join(teamRoot, 'tasks', pipelineSlug, 'pipeline.json'), 'utf8'));
|
|
2723
|
+
}
|
|
2724
|
+
} catch {
|
|
2725
|
+
pipeline = null;
|
|
2726
|
+
}
|
|
2727
|
+
if (pipeline && (pipeline.profile === 'light' || pipeline.intent === 'spike')) {
|
|
2728
|
+
process.exit(0);
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
try {
|
|
2732
|
+
appendOptionalStandardsDraft(process.cwd(), input.standardsDraft);
|
|
2733
|
+
} catch {
|
|
2734
|
+
// A draft failure must not fail the stop, and must not add a WARNING.
|
|
2735
|
+
}
|
|
2736
|
+
|
|
2737
|
+
if (!fs.existsSync(path.join(process.cwd(), '.ai.local', 'scripts', 'run.mjs'))) {
|
|
2738
|
+
process.stderr.write(
|
|
2739
|
+
'WARNING: self-learning loop skipped: .ai.local/scripts/run.mjs is missing (install it with `npx @bonesofspring/ai-rules init <tool> --preset <stack>`)\n',
|
|
2740
|
+
);
|
|
2741
|
+
process.exit(0);
|
|
2742
|
+
}
|
|
2743
|
+
|
|
2744
|
+
// Relative argv[1] + `cwd` keeps `run.mjs`'s own entry guard (pathToFileURL
|
|
2745
|
+
// comparison) satisfied even when the project path traverses a symlink.
|
|
2746
|
+
// SIGKILL, not the SIGTERM default: a child that ignores SIGTERM would hold the
|
|
2747
|
+
// hook for its whole runtime while the warning below still reported 15 s.
|
|
2748
|
+
const result = spawnSync(process.execPath, ['.ai.local/scripts/run.mjs'], {
|
|
2749
|
+
cwd: process.cwd(),
|
|
2750
|
+
encoding: 'utf8',
|
|
2751
|
+
timeout: 15000,
|
|
2752
|
+
killSignal: 'SIGKILL',
|
|
2753
|
+
});
|
|
2754
|
+
if (result.stdout) process.stderr.write(result.stdout);
|
|
2755
|
+
if (result.stderr) process.stderr.write(result.stderr);
|
|
2756
|
+
if (result.error) {
|
|
2757
|
+
const timedOut = result.error.code === 'ETIMEDOUT';
|
|
2758
|
+
process.stderr.write(
|
|
2759
|
+
`WARNING: self-learning loop ${timedOut ? 'timed out after 15s' : `failed: ${result.error.message}`}\n`,
|
|
2760
|
+
);
|
|
2761
|
+
} else if (result.status !== 0) {
|
|
2762
|
+
process.stderr.write(`WARNING: self-learning loop exited ${result.status}\n`);
|
|
2763
|
+
}
|
|
2764
|
+
process.exit(0);
|
|
2765
|
+
POSTFLIGHT
|