@bonesofspring/ai-rules 0.2.60 → 0.2.63
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 +102 -0
- package/README.md +62 -29
- package/bin/cli.js +368 -59
- package/bin/lib/ai-local-drift.js +18 -0
- package/bin/lib/engine-scripts.js +22 -5
- package/bin/lib/engine-upgrade.js +279 -0
- package/bin/lib/mcp/catalog.js +66 -5
- package/bin/lib/mcp/clients.js +4 -4
- package/bin/lib/mcp/credentials.js +88 -0
- package/bin/lib/mcp/doctor.js +100 -8
- package/bin/lib/mcp/npx.js +17 -0
- package/bin/lib/mcp/registry.js +2 -0
- package/bin/lib/merged-config.js +38 -0
- package/bin/lib/seed-ai-local-team.js +32 -14
- package/bin/mavis-install.js +3 -1
- package/bin/opencode-install.js +3 -1
- package/bin/zcode-install.js +3 -1
- package/docs/MAVIS.md +5 -2
- package/docs/MCP-CATALOG.md +30 -2
- package/docs/MCP-SETUP.md +30 -6
- package/docs/OPENCODE.md +27 -4
- package/docs/PLATFORMS.md +38 -0
- package/docs/PRESET-CONTRIBUTION.md +27 -14
- package/docs/TEAM-DB.md +194 -21
- package/docs/openapi/team-db.v1.json +4443 -2083
- package/mcp/defectdojo-mcp.mjs +353 -0
- package/mcp/gitlab.mjs +5 -1
- package/mcp/lib/defectdojo.mjs +249 -0
- package/mcp/lib/yandex.mjs +39 -15
- package/package.json +11 -5
- package/presets/_shared/ai-local/scripts/check-write-scope.mjs +176 -28
- package/presets/_shared/ai-local/scripts/lock.mjs +128 -69
- package/presets/_shared/ai-local/scripts/signals.mjs +17 -1
- package/presets/_shared/ai-local/scripts/team-db-api.mjs +496 -67
- package/presets/_shared/ai-local/scripts/team-db-dashboard.mjs +816 -5
- package/presets/_shared/ai-local/scripts/team-db-openapi.mjs +761 -6
- package/presets/_shared/ai-local/scripts/team-db-project.mjs +10 -0
- package/presets/_shared/ai-local/scripts/team-db-scheduler.mjs +2360 -0
- package/presets/_shared/ai-local/scripts/team-db-schema.mjs +87 -0
- package/presets/_shared/ai-local/scripts/team-db.mjs +151 -9
- package/presets/_shared/ai-local/scripts/upstream-research.mjs +2961 -0
- package/presets/_shared/core/agent-team/agent-artifact-contracts.md +17 -0
- package/presets/_shared/core/agent-team/agent-team-intake.md +1 -0
- package/presets/_shared/core/agent-team/agent-team-orchestrator.md +5 -2
- package/presets/_shared/core/meta/preset-pr-checklist.md +4 -4
- package/presets/_shared/core/meta/preset-twin-sync.md +1 -1
- package/presets/_shared/hooks/README.md +23 -3
- package/presets/_shared/hooks/chain-team-phases.sh.tmpl +57 -3
- package/presets/_shared/hooks/check-preset-update.mjs +4 -3
- package/presets/{claude/nuxt/hooks/guard-shell-command.sh → _shared/hooks/guard-shell-command.mjs.tmpl} +29 -35
- package/presets/_shared/hooks/run-hook.mjs +102 -0
- package/presets/claude/android-kotlin/hooks/README.md +4 -3
- package/presets/claude/android-kotlin/hooks/chain-team-phases.sh +57 -3
- package/presets/claude/android-kotlin/hooks/check-preset-update.mjs +4 -3
- package/presets/claude/android-kotlin/hooks/examples/README.md +2 -2
- package/presets/claude/android-kotlin/hooks/guard-shell-command.mjs +96 -0
- package/presets/claude/android-kotlin/hooks/run-hook.mjs +102 -0
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-intake.md +1 -0
- package/presets/claude/android-kotlin/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
- package/presets/claude/android-kotlin/rules/tooling-and-review/preset-pr-checklist.md +4 -4
- package/presets/claude/android-kotlin/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/android-kotlin/settings.json +2 -2
- package/presets/claude/android-kotlin/team/README.md +5 -0
- package/presets/claude/go/hooks/README.md +4 -3
- package/presets/claude/go/hooks/chain-team-phases.sh +57 -3
- package/presets/claude/go/hooks/check-preset-update.mjs +4 -3
- package/presets/claude/go/hooks/examples/README.md +2 -2
- package/presets/claude/go/hooks/guard-shell-command.mjs +95 -0
- package/presets/claude/go/hooks/run-hook.mjs +102 -0
- package/presets/claude/go/rules/tooling-and-review/agent-team-intake.md +1 -0
- package/presets/claude/go/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
- package/presets/claude/go/rules/tooling-and-review/preset-pr-checklist.md +4 -4
- package/presets/claude/go/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/go/settings.json +2 -2
- package/presets/claude/go/team/README.md +5 -0
- package/presets/claude/ios-swift/hooks/README.md +4 -3
- package/presets/claude/ios-swift/hooks/chain-team-phases.sh +57 -3
- package/presets/claude/ios-swift/hooks/check-preset-update.mjs +4 -3
- package/presets/claude/ios-swift/hooks/examples/README.md +2 -2
- package/presets/claude/ios-swift/hooks/guard-shell-command.mjs +95 -0
- package/presets/claude/ios-swift/hooks/run-hook.mjs +102 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-intake.md +1 -0
- package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
- package/presets/claude/ios-swift/rules/tooling-and-review/preset-pr-checklist.md +4 -4
- package/presets/claude/ios-swift/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/ios-swift/settings.json +2 -2
- package/presets/claude/ios-swift/team/README.md +5 -0
- package/presets/claude/java/hooks/README.md +4 -3
- package/presets/claude/java/hooks/chain-team-phases.sh +57 -3
- package/presets/claude/java/hooks/check-preset-update.mjs +4 -3
- package/presets/claude/java/hooks/examples/README.md +2 -2
- package/presets/claude/java/hooks/{guard-shell-command.sh → guard-shell-command.mjs} +31 -38
- package/presets/claude/java/hooks/run-hook.mjs +102 -0
- package/presets/claude/java/rules/tooling-and-review/agent-team-intake.md +1 -0
- package/presets/claude/java/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
- package/presets/claude/java/rules/tooling-and-review/preset-pr-checklist.md +4 -4
- package/presets/claude/java/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/java/settings.json +2 -2
- package/presets/claude/java/team/README.md +5 -0
- package/presets/claude/mcp-ts/hooks/README.md +4 -3
- package/presets/claude/mcp-ts/hooks/chain-team-phases.sh +57 -3
- package/presets/claude/mcp-ts/hooks/check-preset-update.mjs +4 -3
- package/presets/claude/mcp-ts/hooks/examples/README.md +1 -1
- package/presets/claude/mcp-ts/hooks/guard-shell-command.mjs +95 -0
- package/presets/claude/mcp-ts/hooks/run-hook.mjs +102 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-intake.md +1 -0
- package/presets/claude/mcp-ts/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
- package/presets/claude/mcp-ts/rules/tooling-and-review/preset-pr-checklist.md +4 -4
- package/presets/claude/mcp-ts/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/mcp-ts/settings.json +2 -2
- package/presets/claude/mcp-ts/team/README.md +5 -0
- package/presets/claude/mol/hooks/README.md +20 -0
- package/presets/claude/mol/hooks/chain-team-phases.sh +57 -3
- package/presets/claude/mol/hooks/check-preset-update.mjs +4 -3
- package/presets/claude/{svelte/hooks/guard-shell-command.sh → mol/hooks/guard-shell-command.mjs} +29 -35
- package/presets/claude/mol/hooks/run-hook.mjs +102 -0
- package/presets/claude/mol/rules/tooling-and-review/agent-team-intake.md +1 -0
- package/presets/claude/mol/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
- package/presets/claude/mol/rules/tooling-and-review/preset-pr-checklist.md +4 -4
- package/presets/claude/mol/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/mol/settings.json +2 -2
- package/presets/claude/mol/team/README.md +5 -0
- package/presets/claude/next/agents/build-verifier.md +18 -3
- package/presets/claude/next/agents/code-reviewer.md +2 -0
- package/presets/claude/next/agents/feature-developer.md +3 -1
- package/presets/claude/next/agents/task-analyst.md +6 -0
- package/presets/claude/next/agents/task-router.md +5 -3
- package/presets/claude/next/commands/README.md +1 -0
- package/presets/claude/next/commands/task-continue.md +1 -1
- package/presets/claude/next/commands/upstream-research.md +23 -0
- package/presets/claude/next/hooks/README.md +4 -3
- package/presets/claude/next/hooks/chain-team-phases.sh +57 -3
- package/presets/claude/next/hooks/check-preset-update.mjs +4 -3
- package/presets/claude/next/hooks/examples/README.md +2 -2
- package/presets/claude/next/hooks/guard-shell-command.mjs +94 -0
- package/presets/claude/next/hooks/run-hook.mjs +102 -0
- package/presets/claude/next/rules/tooling-and-review/agent-team-intake.md +1 -0
- package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
- package/presets/claude/next/rules/tooling-and-review/preset-pr-checklist.md +4 -4
- package/presets/claude/next/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/next/settings.json +2 -2
- package/presets/claude/next/team/README.md +23 -0
- package/presets/claude/next/team/upstream/config.json +31 -0
- package/presets/claude/next/team/upstream/digest-template.md +55 -0
- package/presets/claude/next/team/upstream/opencode.json +34 -0
- package/presets/claude/next/team/upstream/projects.json +4 -0
- package/presets/claude/next/team/upstream/prompt.md +77 -0
- package/presets/claude/next/team/upstream/signatures.json +9 -0
- package/presets/claude/nuxt/hooks/README.md +4 -3
- package/presets/claude/nuxt/hooks/chain-team-phases.sh +57 -3
- package/presets/claude/nuxt/hooks/check-preset-update.mjs +4 -3
- package/presets/claude/nuxt/hooks/examples/README.md +2 -2
- package/presets/claude/{ios-swift/hooks/guard-shell-command.sh → nuxt/hooks/guard-shell-command.mjs} +29 -37
- package/presets/claude/nuxt/hooks/run-hook.mjs +102 -0
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-intake.md +1 -0
- package/presets/claude/nuxt/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
- package/presets/claude/nuxt/rules/tooling-and-review/preset-pr-checklist.md +4 -4
- package/presets/claude/nuxt/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/nuxt/settings.json +2 -2
- package/presets/claude/nuxt/team/README.md +5 -0
- package/presets/claude/php-hexagonal/hooks/README.md +4 -3
- package/presets/claude/php-hexagonal/hooks/chain-team-phases.sh +57 -3
- package/presets/claude/php-hexagonal/hooks/check-preset-update.mjs +4 -3
- package/presets/claude/php-hexagonal/hooks/examples/README.md +2 -2
- package/presets/claude/php-hexagonal/hooks/guard-shell-command.mjs +96 -0
- package/presets/claude/php-hexagonal/hooks/run-hook.mjs +102 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-intake.md +1 -0
- package/presets/claude/php-hexagonal/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
- package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-pr-checklist.md +4 -4
- package/presets/claude/php-hexagonal/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/php-hexagonal/settings.json +2 -2
- package/presets/claude/php-hexagonal/team/README.md +5 -0
- package/presets/claude/php-laravel/hooks/README.md +4 -3
- package/presets/claude/php-laravel/hooks/chain-team-phases.sh +57 -3
- package/presets/claude/php-laravel/hooks/check-preset-update.mjs +4 -3
- package/presets/claude/php-laravel/hooks/examples/README.md +2 -2
- package/presets/claude/php-laravel/hooks/guard-shell-command.mjs +96 -0
- package/presets/claude/php-laravel/hooks/run-hook.mjs +102 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-intake.md +1 -0
- package/presets/claude/php-laravel/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
- package/presets/claude/php-laravel/rules/tooling-and-review/preset-pr-checklist.md +4 -4
- package/presets/claude/php-laravel/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/php-laravel/settings.json +2 -2
- package/presets/claude/php-laravel/team/README.md +5 -0
- package/presets/claude/svelte/hooks/README.md +4 -3
- package/presets/claude/svelte/hooks/chain-team-phases.sh +57 -3
- package/presets/claude/svelte/hooks/check-preset-update.mjs +4 -3
- package/presets/claude/svelte/hooks/examples/README.md +2 -2
- package/presets/claude/svelte/hooks/guard-shell-command.mjs +94 -0
- package/presets/claude/svelte/hooks/run-hook.mjs +102 -0
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-intake.md +1 -0
- package/presets/claude/svelte/rules/tooling-and-review/agent-team-orchestrator.md +5 -2
- package/presets/claude/svelte/rules/tooling-and-review/preset-pr-checklist.md +4 -4
- package/presets/claude/svelte/rules/tooling-and-review/preset-twin-sync.md +1 -1
- package/presets/claude/svelte/settings.json +2 -2
- package/presets/claude/svelte/team/README.md +5 -0
- package/presets/cursor/android-kotlin/hooks/README.md +2 -1
- package/presets/cursor/android-kotlin/hooks/chain-team-phases.sh +57 -3
- package/presets/cursor/android-kotlin/hooks/check-preset-update.mjs +4 -3
- package/presets/cursor/android-kotlin/hooks/examples/README.md +1 -1
- package/presets/cursor/android-kotlin/hooks/guard-shell-command.mjs +96 -0
- package/presets/cursor/android-kotlin/hooks/run-hook.mjs +102 -0
- package/presets/cursor/android-kotlin/hooks.json +2 -2
- package/presets/cursor/android-kotlin/rules/agent-team-intake.mdc +1 -0
- package/presets/cursor/android-kotlin/rules/agent-team-orchestrator.mdc +2 -1
- package/presets/cursor/android-kotlin/rules/preset-pr-checklist.mdc +4 -4
- package/presets/cursor/android-kotlin/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/android-kotlin/team/README.md +5 -0
- package/presets/cursor/go/hooks/README.md +2 -1
- package/presets/cursor/go/hooks/chain-team-phases.sh +57 -3
- package/presets/cursor/go/hooks/check-preset-update.mjs +4 -3
- package/presets/cursor/go/hooks/examples/README.md +1 -1
- package/presets/cursor/go/hooks/guard-shell-command.mjs +95 -0
- package/presets/cursor/go/hooks/run-hook.mjs +102 -0
- package/presets/cursor/go/hooks.json +2 -2
- package/presets/cursor/go/rules/agent-team-intake.mdc +1 -0
- package/presets/cursor/go/rules/agent-team-orchestrator.mdc +2 -1
- package/presets/cursor/go/rules/preset-pr-checklist.mdc +4 -4
- package/presets/cursor/go/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/go/team/README.md +5 -0
- package/presets/cursor/ios-swift/hooks/README.md +2 -1
- package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +57 -3
- package/presets/cursor/ios-swift/hooks/check-preset-update.mjs +4 -3
- package/presets/cursor/ios-swift/hooks/examples/README.md +1 -1
- package/presets/cursor/ios-swift/hooks/guard-shell-command.mjs +95 -0
- package/presets/cursor/ios-swift/hooks/run-hook.mjs +102 -0
- package/presets/cursor/ios-swift/hooks.json +2 -2
- package/presets/cursor/ios-swift/rules/agent-team-intake.mdc +1 -0
- package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +2 -1
- package/presets/cursor/ios-swift/rules/preset-pr-checklist.mdc +4 -4
- package/presets/cursor/ios-swift/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/ios-swift/team/README.md +5 -0
- package/presets/cursor/java/hooks/README.md +2 -1
- package/presets/cursor/java/hooks/chain-team-phases.sh +57 -3
- package/presets/cursor/java/hooks/check-preset-update.mjs +4 -3
- package/presets/cursor/java/hooks/examples/README.md +1 -1
- package/presets/cursor/java/hooks/guard-shell-command.mjs +96 -0
- package/presets/cursor/java/hooks/run-hook.mjs +102 -0
- package/presets/cursor/java/hooks.json +2 -2
- package/presets/cursor/java/rules/agent-team-intake.mdc +1 -0
- package/presets/cursor/java/rules/agent-team-orchestrator.mdc +2 -1
- package/presets/cursor/java/rules/preset-pr-checklist.mdc +4 -4
- package/presets/cursor/java/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/java/team/README.md +5 -0
- package/presets/cursor/mcp-ts/hooks/README.md +2 -1
- package/presets/cursor/mcp-ts/hooks/chain-team-phases.sh +57 -3
- package/presets/cursor/mcp-ts/hooks/check-preset-update.mjs +4 -3
- package/presets/cursor/mcp-ts/hooks/guard-shell-command.mjs +95 -0
- package/presets/cursor/mcp-ts/hooks/run-hook.mjs +102 -0
- package/presets/cursor/mcp-ts/hooks.json +2 -2
- package/presets/cursor/mcp-ts/rules/agent-team-intake.mdc +1 -0
- package/presets/cursor/mcp-ts/rules/agent-team-orchestrator.mdc +2 -1
- package/presets/cursor/mcp-ts/rules/preset-pr-checklist.mdc +4 -4
- package/presets/cursor/mcp-ts/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/mcp-ts/team/README.md +5 -0
- package/presets/cursor/mol/hooks/README.md +2 -1
- package/presets/cursor/mol/hooks/chain-team-phases.sh +57 -3
- package/presets/cursor/mol/hooks/check-preset-update.mjs +4 -3
- package/presets/cursor/mol/hooks/examples/README.md +1 -1
- package/presets/{claude/next/hooks/guard-shell-command.sh → cursor/mol/hooks/guard-shell-command.mjs} +29 -35
- package/presets/cursor/mol/hooks/run-hook.mjs +102 -0
- package/presets/cursor/mol/hooks.json +2 -2
- package/presets/cursor/mol/rules/agent-team-intake.mdc +1 -0
- package/presets/cursor/mol/rules/agent-team-orchestrator.mdc +2 -1
- package/presets/cursor/mol/rules/preset-pr-checklist.mdc +4 -4
- package/presets/cursor/mol/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/mol/team/README.md +5 -0
- package/presets/cursor/next/agents/build-verifier.md +18 -3
- package/presets/cursor/next/agents/code-reviewer.md +2 -0
- package/presets/cursor/next/agents/feature-developer.md +3 -1
- package/presets/cursor/next/agents/task-analyst.md +6 -0
- package/presets/cursor/next/agents/task-router.md +5 -3
- package/presets/cursor/next/commands/README.md +1 -0
- package/presets/cursor/next/commands/task-continue.md +1 -1
- package/presets/cursor/next/commands/upstream-research.md +23 -0
- package/presets/cursor/next/hooks/README.md +2 -1
- package/presets/cursor/next/hooks/chain-team-phases.sh +57 -3
- package/presets/cursor/next/hooks/check-preset-update.mjs +4 -3
- package/presets/cursor/next/hooks/examples/README.md +1 -1
- package/presets/cursor/next/hooks/guard-shell-command.mjs +94 -0
- package/presets/cursor/next/hooks/run-hook.mjs +102 -0
- package/presets/cursor/next/hooks.json +2 -2
- package/presets/cursor/next/rules/agent-team-intake.mdc +1 -0
- package/presets/cursor/next/rules/agent-team-orchestrator.mdc +2 -1
- package/presets/cursor/next/rules/preset-pr-checklist.mdc +4 -4
- package/presets/cursor/next/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/next/team/README.md +23 -0
- package/presets/cursor/next/team/upstream/config.json +31 -0
- package/presets/cursor/next/team/upstream/digest-template.md +55 -0
- package/presets/cursor/next/team/upstream/opencode.json +34 -0
- package/presets/cursor/next/team/upstream/projects.json +4 -0
- package/presets/cursor/next/team/upstream/prompt.md +77 -0
- package/presets/cursor/next/team/upstream/signatures.json +9 -0
- package/presets/cursor/nuxt/hooks/README.md +2 -1
- package/presets/cursor/nuxt/hooks/chain-team-phases.sh +57 -3
- package/presets/cursor/nuxt/hooks/check-preset-update.mjs +4 -3
- package/presets/cursor/nuxt/hooks/examples/README.md +1 -1
- package/presets/cursor/nuxt/hooks/guard-shell-command.mjs +94 -0
- package/presets/cursor/nuxt/hooks/run-hook.mjs +102 -0
- package/presets/cursor/nuxt/hooks.json +2 -2
- package/presets/cursor/nuxt/rules/agent-team-intake.mdc +1 -0
- package/presets/cursor/nuxt/rules/agent-team-orchestrator.mdc +2 -1
- package/presets/cursor/nuxt/rules/preset-pr-checklist.mdc +4 -4
- package/presets/cursor/nuxt/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/nuxt/team/README.md +5 -0
- package/presets/cursor/php-hexagonal/hooks/README.md +2 -1
- package/presets/cursor/php-hexagonal/hooks/chain-team-phases.sh +57 -3
- package/presets/cursor/php-hexagonal/hooks/check-preset-update.mjs +4 -3
- package/presets/cursor/php-hexagonal/hooks/examples/README.md +1 -1
- package/presets/cursor/php-hexagonal/hooks/guard-shell-command.mjs +96 -0
- package/presets/cursor/php-hexagonal/hooks/run-hook.mjs +102 -0
- package/presets/cursor/php-hexagonal/hooks.json +2 -2
- package/presets/cursor/php-hexagonal/rules/agent-team-intake.mdc +1 -0
- package/presets/cursor/php-hexagonal/rules/agent-team-orchestrator.mdc +2 -1
- package/presets/cursor/php-hexagonal/rules/preset-pr-checklist.mdc +4 -4
- package/presets/cursor/php-hexagonal/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/php-hexagonal/team/README.md +5 -0
- package/presets/cursor/php-laravel/hooks/README.md +2 -1
- package/presets/cursor/php-laravel/hooks/chain-team-phases.sh +57 -3
- package/presets/cursor/php-laravel/hooks/check-preset-update.mjs +4 -3
- package/presets/cursor/php-laravel/hooks/examples/README.md +1 -1
- package/presets/cursor/php-laravel/hooks/guard-shell-command.mjs +96 -0
- package/presets/cursor/php-laravel/hooks/run-hook.mjs +102 -0
- package/presets/cursor/php-laravel/hooks.json +2 -2
- package/presets/cursor/php-laravel/rules/agent-team-intake.mdc +1 -0
- package/presets/cursor/php-laravel/rules/agent-team-orchestrator.mdc +2 -1
- package/presets/cursor/php-laravel/rules/preset-pr-checklist.mdc +4 -4
- package/presets/cursor/php-laravel/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/php-laravel/team/README.md +5 -0
- package/presets/cursor/svelte/hooks/README.md +2 -1
- package/presets/cursor/svelte/hooks/chain-team-phases.sh +57 -3
- package/presets/cursor/svelte/hooks/check-preset-update.mjs +4 -3
- package/presets/cursor/svelte/hooks/examples/README.md +1 -1
- package/presets/cursor/svelte/hooks/guard-shell-command.mjs +94 -0
- package/presets/cursor/svelte/hooks/run-hook.mjs +102 -0
- package/presets/cursor/svelte/hooks.json +2 -2
- package/presets/cursor/svelte/rules/agent-team-intake.mdc +1 -0
- package/presets/cursor/svelte/rules/agent-team-orchestrator.mdc +2 -1
- package/presets/cursor/svelte/rules/preset-pr-checklist.mdc +4 -4
- package/presets/cursor/svelte/rules/preset-twin-sync.mdc +1 -1
- package/presets/cursor/svelte/team/README.md +5 -0
- package/presets/mavis/android-kotlin/adapter-map.json +11 -3
- package/presets/mavis/android-kotlin/hooks/README.md +2 -1
- package/presets/mavis/android-kotlin/hooks/chain-team-phases.sh +57 -3
- package/presets/mavis/android-kotlin/hooks/check-preset-update.mjs +4 -3
- package/presets/mavis/android-kotlin/rules/agent-team-intake.md +1 -0
- package/presets/mavis/android-kotlin/rules/agent-team-orchestrator.md +5 -2
- package/presets/mavis/android-kotlin/rules/preset-pr-checklist.md +4 -4
- package/presets/mavis/android-kotlin/rules/preset-twin-sync.md +1 -1
- package/presets/mavis/android-kotlin/team/README.md +5 -0
- package/presets/mavis/go/adapter-map.json +11 -3
- package/presets/mavis/go/hooks/README.md +2 -1
- package/presets/mavis/go/hooks/chain-team-phases.sh +57 -3
- package/presets/mavis/go/hooks/check-preset-update.mjs +4 -3
- package/presets/mavis/go/rules/agent-team-intake.md +1 -0
- package/presets/mavis/go/rules/agent-team-orchestrator.md +5 -2
- package/presets/mavis/go/rules/preset-pr-checklist.md +4 -4
- package/presets/mavis/go/rules/preset-twin-sync.md +1 -1
- package/presets/mavis/go/team/README.md +5 -0
- package/presets/mavis/ios-swift/adapter-map.json +11 -3
- package/presets/mavis/ios-swift/hooks/README.md +2 -1
- package/presets/mavis/ios-swift/hooks/chain-team-phases.sh +57 -3
- package/presets/mavis/ios-swift/hooks/check-preset-update.mjs +4 -3
- package/presets/mavis/ios-swift/rules/agent-team-intake.md +1 -0
- package/presets/mavis/ios-swift/rules/agent-team-orchestrator.md +5 -2
- package/presets/mavis/ios-swift/rules/preset-pr-checklist.md +4 -4
- package/presets/mavis/ios-swift/rules/preset-twin-sync.md +1 -1
- package/presets/mavis/ios-swift/team/README.md +5 -0
- package/presets/mavis/java/adapter-map.json +11 -3
- package/presets/mavis/java/hooks/README.md +2 -1
- package/presets/mavis/java/hooks/chain-team-phases.sh +57 -3
- package/presets/mavis/java/hooks/check-preset-update.mjs +4 -3
- package/presets/mavis/java/rules/agent-team-intake.md +1 -0
- package/presets/mavis/java/rules/agent-team-orchestrator.md +5 -2
- package/presets/mavis/java/rules/preset-pr-checklist.md +4 -4
- package/presets/mavis/java/rules/preset-twin-sync.md +1 -1
- package/presets/mavis/java/team/README.md +5 -0
- package/presets/mavis/mcp-ts/adapter-map.json +11 -3
- package/presets/mavis/mcp-ts/hooks/README.md +2 -1
- package/presets/mavis/mcp-ts/hooks/chain-team-phases.sh +57 -3
- package/presets/mavis/mcp-ts/hooks/check-preset-update.mjs +4 -3
- package/presets/mavis/mcp-ts/rules/agent-team-intake.md +1 -0
- package/presets/mavis/mcp-ts/rules/agent-team-orchestrator.md +5 -2
- package/presets/mavis/mcp-ts/rules/preset-pr-checklist.md +4 -4
- package/presets/mavis/mcp-ts/rules/preset-twin-sync.md +1 -1
- package/presets/mavis/mcp-ts/team/README.md +5 -0
- package/presets/mavis/mol/adapter-map.json +11 -3
- package/presets/mavis/mol/hooks/README.md +2 -1
- package/presets/mavis/mol/hooks/chain-team-phases.sh +57 -3
- package/presets/mavis/mol/hooks/check-preset-update.mjs +4 -3
- package/presets/mavis/mol/rules/agent-team-intake.md +1 -0
- package/presets/mavis/mol/rules/agent-team-orchestrator.md +5 -2
- package/presets/mavis/mol/rules/preset-pr-checklist.md +4 -4
- package/presets/mavis/mol/rules/preset-twin-sync.md +1 -1
- package/presets/mavis/mol/team/README.md +5 -0
- package/presets/mavis/next/adapter-map.json +67 -3
- package/presets/mavis/next/agents/build-verifier.md +18 -3
- package/presets/mavis/next/agents/code-reviewer.md +2 -0
- package/presets/mavis/next/agents/feature-developer.md +3 -1
- package/presets/mavis/next/agents/task-analyst.md +6 -0
- package/presets/mavis/next/agents/task-router.md +5 -3
- package/presets/mavis/next/commands/README.md +1 -0
- package/presets/mavis/next/commands/task-continue.md +1 -1
- package/presets/mavis/next/commands/upstream-research.md +18 -0
- package/presets/mavis/next/hooks/README.md +2 -1
- package/presets/mavis/next/hooks/chain-team-phases.sh +57 -3
- package/presets/mavis/next/hooks/check-preset-update.mjs +4 -3
- package/presets/mavis/next/rules/agent-team-intake.md +1 -0
- package/presets/mavis/next/rules/agent-team-orchestrator.md +5 -2
- package/presets/mavis/next/rules/preset-pr-checklist.md +4 -4
- package/presets/mavis/next/rules/preset-twin-sync.md +1 -1
- package/presets/mavis/next/team/README.md +23 -0
- package/presets/mavis/next/team/upstream/config.json +31 -0
- package/presets/mavis/next/team/upstream/digest-template.md +55 -0
- package/presets/mavis/next/team/upstream/opencode.json +34 -0
- package/presets/mavis/next/team/upstream/projects.json +4 -0
- package/presets/mavis/next/team/upstream/prompt.md +77 -0
- package/presets/mavis/next/team/upstream/signatures.json +9 -0
- package/presets/mavis/nuxt/adapter-map.json +11 -3
- package/presets/mavis/nuxt/hooks/README.md +2 -1
- package/presets/mavis/nuxt/hooks/chain-team-phases.sh +57 -3
- package/presets/mavis/nuxt/hooks/check-preset-update.mjs +4 -3
- package/presets/mavis/nuxt/rules/agent-team-intake.md +1 -0
- package/presets/mavis/nuxt/rules/agent-team-orchestrator.md +5 -2
- package/presets/mavis/nuxt/rules/preset-pr-checklist.md +4 -4
- package/presets/mavis/nuxt/rules/preset-twin-sync.md +1 -1
- package/presets/mavis/nuxt/team/README.md +5 -0
- package/presets/mavis/php-hexagonal/adapter-map.json +11 -3
- package/presets/mavis/php-hexagonal/hooks/README.md +2 -1
- package/presets/mavis/php-hexagonal/hooks/chain-team-phases.sh +57 -3
- package/presets/mavis/php-hexagonal/hooks/check-preset-update.mjs +4 -3
- package/presets/mavis/php-hexagonal/rules/agent-team-intake.md +1 -0
- package/presets/mavis/php-hexagonal/rules/agent-team-orchestrator.md +5 -2
- package/presets/mavis/php-hexagonal/rules/preset-pr-checklist.md +4 -4
- package/presets/mavis/php-hexagonal/rules/preset-twin-sync.md +1 -1
- package/presets/mavis/php-hexagonal/team/README.md +5 -0
- package/presets/mavis/php-laravel/adapter-map.json +11 -3
- package/presets/mavis/php-laravel/hooks/README.md +2 -1
- package/presets/mavis/php-laravel/hooks/chain-team-phases.sh +57 -3
- package/presets/mavis/php-laravel/hooks/check-preset-update.mjs +4 -3
- package/presets/mavis/php-laravel/rules/agent-team-intake.md +1 -0
- package/presets/mavis/php-laravel/rules/agent-team-orchestrator.md +5 -2
- package/presets/mavis/php-laravel/rules/preset-pr-checklist.md +4 -4
- package/presets/mavis/php-laravel/rules/preset-twin-sync.md +1 -1
- package/presets/mavis/php-laravel/team/README.md +5 -0
- package/presets/mavis/svelte/adapter-map.json +11 -3
- package/presets/mavis/svelte/hooks/README.md +2 -1
- package/presets/mavis/svelte/hooks/chain-team-phases.sh +57 -3
- package/presets/mavis/svelte/hooks/check-preset-update.mjs +4 -3
- package/presets/mavis/svelte/rules/agent-team-intake.md +1 -0
- package/presets/mavis/svelte/rules/agent-team-orchestrator.md +5 -2
- package/presets/mavis/svelte/rules/preset-pr-checklist.md +4 -4
- package/presets/mavis/svelte/rules/preset-twin-sync.md +1 -1
- package/presets/mavis/svelte/team/README.md +5 -0
- package/presets/opencode/android-kotlin/OPENCODE.md +1 -1
- package/presets/opencode/android-kotlin/README.md +1 -1
- package/presets/opencode/android-kotlin/adapter-map.json +11 -3
- package/presets/opencode/android-kotlin/hooks/README.md +3 -2
- package/presets/opencode/android-kotlin/hooks/chain-team-phases.sh +57 -3
- package/presets/opencode/android-kotlin/hooks/check-preset-update.mjs +4 -3
- package/presets/opencode/android-kotlin/rules/agent-team-intake.md +1 -0
- package/presets/opencode/android-kotlin/rules/agent-team-orchestrator.md +5 -2
- package/presets/opencode/android-kotlin/rules/preset-pr-checklist.md +4 -4
- package/presets/opencode/android-kotlin/rules/preset-twin-sync.md +1 -1
- package/presets/opencode/android-kotlin/team/README.md +5 -0
- package/presets/opencode/go/OPENCODE.md +1 -1
- package/presets/opencode/go/README.md +1 -1
- package/presets/opencode/go/adapter-map.json +11 -3
- package/presets/opencode/go/hooks/README.md +3 -2
- package/presets/opencode/go/hooks/chain-team-phases.sh +57 -3
- package/presets/opencode/go/hooks/check-preset-update.mjs +4 -3
- package/presets/opencode/go/rules/agent-team-intake.md +1 -0
- package/presets/opencode/go/rules/agent-team-orchestrator.md +5 -2
- package/presets/opencode/go/rules/preset-pr-checklist.md +4 -4
- package/presets/opencode/go/rules/preset-twin-sync.md +1 -1
- package/presets/opencode/go/team/README.md +5 -0
- package/presets/opencode/ios-swift/OPENCODE.md +1 -1
- package/presets/opencode/ios-swift/README.md +1 -1
- package/presets/opencode/ios-swift/adapter-map.json +11 -3
- package/presets/opencode/ios-swift/hooks/README.md +3 -2
- package/presets/opencode/ios-swift/hooks/chain-team-phases.sh +57 -3
- package/presets/opencode/ios-swift/hooks/check-preset-update.mjs +4 -3
- package/presets/opencode/ios-swift/rules/agent-team-intake.md +1 -0
- package/presets/opencode/ios-swift/rules/agent-team-orchestrator.md +5 -2
- package/presets/opencode/ios-swift/rules/preset-pr-checklist.md +4 -4
- package/presets/opencode/ios-swift/rules/preset-twin-sync.md +1 -1
- package/presets/opencode/ios-swift/team/README.md +5 -0
- package/presets/opencode/java/OPENCODE.md +1 -1
- package/presets/opencode/java/README.md +1 -1
- package/presets/opencode/java/adapter-map.json +11 -3
- package/presets/opencode/java/hooks/README.md +3 -2
- package/presets/opencode/java/hooks/chain-team-phases.sh +57 -3
- package/presets/opencode/java/hooks/check-preset-update.mjs +4 -3
- package/presets/opencode/java/rules/agent-team-intake.md +1 -0
- package/presets/opencode/java/rules/agent-team-orchestrator.md +5 -2
- package/presets/opencode/java/rules/preset-pr-checklist.md +4 -4
- package/presets/opencode/java/rules/preset-twin-sync.md +1 -1
- package/presets/opencode/java/team/README.md +5 -0
- package/presets/opencode/mcp-ts/OPENCODE.md +1 -1
- package/presets/opencode/mcp-ts/README.md +1 -1
- package/presets/opencode/mcp-ts/adapter-map.json +11 -3
- package/presets/opencode/mcp-ts/hooks/README.md +3 -2
- package/presets/opencode/mcp-ts/hooks/chain-team-phases.sh +57 -3
- package/presets/opencode/mcp-ts/hooks/check-preset-update.mjs +4 -3
- package/presets/opencode/mcp-ts/rules/agent-team-intake.md +1 -0
- package/presets/opencode/mcp-ts/rules/agent-team-orchestrator.md +5 -2
- package/presets/opencode/mcp-ts/rules/preset-pr-checklist.md +4 -4
- package/presets/opencode/mcp-ts/rules/preset-twin-sync.md +1 -1
- package/presets/opencode/mcp-ts/team/README.md +5 -0
- package/presets/opencode/mol/OPENCODE.md +1 -1
- package/presets/opencode/mol/README.md +1 -1
- package/presets/opencode/mol/adapter-map.json +11 -3
- package/presets/opencode/mol/hooks/README.md +3 -2
- package/presets/opencode/mol/hooks/chain-team-phases.sh +57 -3
- package/presets/opencode/mol/hooks/check-preset-update.mjs +4 -3
- package/presets/opencode/mol/rules/agent-team-intake.md +1 -0
- package/presets/opencode/mol/rules/agent-team-orchestrator.md +5 -2
- package/presets/opencode/mol/rules/preset-pr-checklist.md +4 -4
- package/presets/opencode/mol/rules/preset-twin-sync.md +1 -1
- package/presets/opencode/mol/team/README.md +5 -0
- package/presets/opencode/next/OPENCODE.md +1 -1
- package/presets/opencode/next/README.md +1 -1
- package/presets/opencode/next/adapter-map.json +67 -3
- package/presets/opencode/next/agents/build-verifier.md +18 -3
- package/presets/opencode/next/agents/code-reviewer.md +2 -0
- package/presets/opencode/next/agents/feature-developer.md +3 -1
- package/presets/opencode/next/agents/task-analyst.md +6 -0
- package/presets/opencode/next/agents/task-router.md +5 -3
- package/presets/opencode/next/commands/README.md +1 -0
- package/presets/opencode/next/commands/task-continue.md +1 -1
- package/presets/opencode/next/commands/upstream-research.md +26 -0
- package/presets/opencode/next/hooks/README.md +3 -2
- package/presets/opencode/next/hooks/chain-team-phases.sh +57 -3
- package/presets/opencode/next/hooks/check-preset-update.mjs +4 -3
- package/presets/opencode/next/rules/agent-team-intake.md +1 -0
- package/presets/opencode/next/rules/agent-team-orchestrator.md +5 -2
- package/presets/opencode/next/rules/preset-pr-checklist.md +4 -4
- package/presets/opencode/next/rules/preset-twin-sync.md +1 -1
- package/presets/opencode/next/team/README.md +23 -0
- package/presets/opencode/next/team/upstream/config.json +31 -0
- package/presets/opencode/next/team/upstream/digest-template.md +55 -0
- package/presets/opencode/next/team/upstream/opencode.json +34 -0
- package/presets/opencode/next/team/upstream/projects.json +4 -0
- package/presets/opencode/next/team/upstream/prompt.md +77 -0
- package/presets/opencode/next/team/upstream/signatures.json +9 -0
- package/presets/opencode/nuxt/OPENCODE.md +1 -1
- package/presets/opencode/nuxt/README.md +1 -1
- package/presets/opencode/nuxt/adapter-map.json +11 -3
- package/presets/opencode/nuxt/hooks/README.md +3 -2
- package/presets/opencode/nuxt/hooks/chain-team-phases.sh +57 -3
- package/presets/opencode/nuxt/hooks/check-preset-update.mjs +4 -3
- package/presets/opencode/nuxt/rules/agent-team-intake.md +1 -0
- package/presets/opencode/nuxt/rules/agent-team-orchestrator.md +5 -2
- package/presets/opencode/nuxt/rules/preset-pr-checklist.md +4 -4
- package/presets/opencode/nuxt/rules/preset-twin-sync.md +1 -1
- package/presets/opencode/nuxt/team/README.md +5 -0
- package/presets/opencode/php-hexagonal/OPENCODE.md +1 -1
- package/presets/opencode/php-hexagonal/README.md +1 -1
- package/presets/opencode/php-hexagonal/adapter-map.json +11 -3
- package/presets/opencode/php-hexagonal/hooks/README.md +3 -2
- package/presets/opencode/php-hexagonal/hooks/chain-team-phases.sh +57 -3
- package/presets/opencode/php-hexagonal/hooks/check-preset-update.mjs +4 -3
- package/presets/opencode/php-hexagonal/rules/agent-team-intake.md +1 -0
- package/presets/opencode/php-hexagonal/rules/agent-team-orchestrator.md +5 -2
- package/presets/opencode/php-hexagonal/rules/preset-pr-checklist.md +4 -4
- package/presets/opencode/php-hexagonal/rules/preset-twin-sync.md +1 -1
- package/presets/opencode/php-hexagonal/team/README.md +5 -0
- package/presets/opencode/php-laravel/OPENCODE.md +1 -1
- package/presets/opencode/php-laravel/README.md +1 -1
- package/presets/opencode/php-laravel/adapter-map.json +11 -3
- package/presets/opencode/php-laravel/hooks/README.md +3 -2
- package/presets/opencode/php-laravel/hooks/chain-team-phases.sh +57 -3
- package/presets/opencode/php-laravel/hooks/check-preset-update.mjs +4 -3
- package/presets/opencode/php-laravel/rules/agent-team-intake.md +1 -0
- package/presets/opencode/php-laravel/rules/agent-team-orchestrator.md +5 -2
- package/presets/opencode/php-laravel/rules/preset-pr-checklist.md +4 -4
- package/presets/opencode/php-laravel/rules/preset-twin-sync.md +1 -1
- package/presets/opencode/php-laravel/team/README.md +5 -0
- package/presets/opencode/svelte/OPENCODE.md +1 -1
- package/presets/opencode/svelte/README.md +1 -1
- package/presets/opencode/svelte/adapter-map.json +11 -3
- package/presets/opencode/svelte/hooks/README.md +3 -2
- package/presets/opencode/svelte/hooks/chain-team-phases.sh +57 -3
- package/presets/opencode/svelte/hooks/check-preset-update.mjs +4 -3
- package/presets/opencode/svelte/rules/agent-team-intake.md +1 -0
- package/presets/opencode/svelte/rules/agent-team-orchestrator.md +5 -2
- package/presets/opencode/svelte/rules/preset-pr-checklist.md +4 -4
- package/presets/opencode/svelte/rules/preset-twin-sync.md +1 -1
- package/presets/opencode/svelte/team/README.md +5 -0
- package/presets/zcode/android-kotlin/adapter-map.json +11 -3
- package/presets/zcode/android-kotlin/hooks/README.md +2 -1
- package/presets/zcode/android-kotlin/hooks/chain-team-phases.sh +57 -3
- package/presets/zcode/android-kotlin/hooks/check-preset-update.mjs +4 -3
- package/presets/zcode/android-kotlin/rules/agent-team-intake.md +1 -0
- package/presets/zcode/android-kotlin/rules/agent-team-orchestrator.md +5 -2
- package/presets/zcode/android-kotlin/rules/preset-pr-checklist.md +4 -4
- package/presets/zcode/android-kotlin/rules/preset-twin-sync.md +1 -1
- package/presets/zcode/android-kotlin/team/README.md +5 -0
- package/presets/zcode/go/adapter-map.json +11 -3
- package/presets/zcode/go/hooks/README.md +2 -1
- package/presets/zcode/go/hooks/chain-team-phases.sh +57 -3
- package/presets/zcode/go/hooks/check-preset-update.mjs +4 -3
- package/presets/zcode/go/rules/agent-team-intake.md +1 -0
- package/presets/zcode/go/rules/agent-team-orchestrator.md +5 -2
- package/presets/zcode/go/rules/preset-pr-checklist.md +4 -4
- package/presets/zcode/go/rules/preset-twin-sync.md +1 -1
- package/presets/zcode/go/team/README.md +5 -0
- package/presets/zcode/ios-swift/adapter-map.json +11 -3
- package/presets/zcode/ios-swift/hooks/README.md +2 -1
- package/presets/zcode/ios-swift/hooks/chain-team-phases.sh +57 -3
- package/presets/zcode/ios-swift/hooks/check-preset-update.mjs +4 -3
- package/presets/zcode/ios-swift/rules/agent-team-intake.md +1 -0
- package/presets/zcode/ios-swift/rules/agent-team-orchestrator.md +5 -2
- package/presets/zcode/ios-swift/rules/preset-pr-checklist.md +4 -4
- package/presets/zcode/ios-swift/rules/preset-twin-sync.md +1 -1
- package/presets/zcode/ios-swift/team/README.md +5 -0
- package/presets/zcode/java/adapter-map.json +11 -3
- package/presets/zcode/java/hooks/README.md +2 -1
- package/presets/zcode/java/hooks/chain-team-phases.sh +57 -3
- package/presets/zcode/java/hooks/check-preset-update.mjs +4 -3
- package/presets/zcode/java/rules/agent-team-intake.md +1 -0
- package/presets/zcode/java/rules/agent-team-orchestrator.md +5 -2
- package/presets/zcode/java/rules/preset-pr-checklist.md +4 -4
- package/presets/zcode/java/rules/preset-twin-sync.md +1 -1
- package/presets/zcode/java/team/README.md +5 -0
- package/presets/zcode/mcp-ts/adapter-map.json +11 -3
- package/presets/zcode/mcp-ts/hooks/README.md +2 -1
- package/presets/zcode/mcp-ts/hooks/chain-team-phases.sh +57 -3
- package/presets/zcode/mcp-ts/hooks/check-preset-update.mjs +4 -3
- package/presets/zcode/mcp-ts/rules/agent-team-intake.md +1 -0
- package/presets/zcode/mcp-ts/rules/agent-team-orchestrator.md +5 -2
- package/presets/zcode/mcp-ts/rules/preset-pr-checklist.md +4 -4
- package/presets/zcode/mcp-ts/rules/preset-twin-sync.md +1 -1
- package/presets/zcode/mcp-ts/team/README.md +5 -0
- package/presets/zcode/mol/adapter-map.json +11 -3
- package/presets/zcode/mol/hooks/README.md +2 -1
- package/presets/zcode/mol/hooks/chain-team-phases.sh +57 -3
- package/presets/zcode/mol/hooks/check-preset-update.mjs +4 -3
- package/presets/zcode/mol/rules/agent-team-intake.md +1 -0
- package/presets/zcode/mol/rules/agent-team-orchestrator.md +5 -2
- package/presets/zcode/mol/rules/preset-pr-checklist.md +4 -4
- package/presets/zcode/mol/rules/preset-twin-sync.md +1 -1
- package/presets/zcode/mol/team/README.md +5 -0
- package/presets/zcode/next/adapter-map.json +67 -3
- package/presets/zcode/next/agents/build-verifier.md +18 -3
- package/presets/zcode/next/agents/code-reviewer.md +2 -0
- package/presets/zcode/next/agents/feature-developer.md +3 -1
- package/presets/zcode/next/agents/task-analyst.md +6 -0
- package/presets/zcode/next/agents/task-router.md +5 -3
- package/presets/zcode/next/commands/README.md +1 -0
- package/presets/zcode/next/commands/task-continue.md +1 -1
- package/presets/zcode/next/commands/upstream-research.md +26 -0
- package/presets/zcode/next/hooks/README.md +2 -1
- package/presets/zcode/next/hooks/chain-team-phases.sh +57 -3
- package/presets/zcode/next/hooks/check-preset-update.mjs +4 -3
- package/presets/zcode/next/rules/agent-team-intake.md +1 -0
- package/presets/zcode/next/rules/agent-team-orchestrator.md +5 -2
- package/presets/zcode/next/rules/preset-pr-checklist.md +4 -4
- package/presets/zcode/next/rules/preset-twin-sync.md +1 -1
- package/presets/zcode/next/team/README.md +23 -0
- package/presets/zcode/next/team/upstream/config.json +31 -0
- package/presets/zcode/next/team/upstream/digest-template.md +55 -0
- package/presets/zcode/next/team/upstream/opencode.json +34 -0
- package/presets/zcode/next/team/upstream/projects.json +4 -0
- package/presets/zcode/next/team/upstream/prompt.md +77 -0
- package/presets/zcode/next/team/upstream/signatures.json +9 -0
- package/presets/zcode/nuxt/adapter-map.json +11 -3
- package/presets/zcode/nuxt/hooks/README.md +2 -1
- package/presets/zcode/nuxt/hooks/chain-team-phases.sh +57 -3
- package/presets/zcode/nuxt/hooks/check-preset-update.mjs +4 -3
- package/presets/zcode/nuxt/rules/agent-team-intake.md +1 -0
- package/presets/zcode/nuxt/rules/agent-team-orchestrator.md +5 -2
- package/presets/zcode/nuxt/rules/preset-pr-checklist.md +4 -4
- package/presets/zcode/nuxt/rules/preset-twin-sync.md +1 -1
- package/presets/zcode/nuxt/team/README.md +5 -0
- package/presets/zcode/php-hexagonal/adapter-map.json +11 -3
- package/presets/zcode/php-hexagonal/hooks/README.md +2 -1
- package/presets/zcode/php-hexagonal/hooks/chain-team-phases.sh +57 -3
- package/presets/zcode/php-hexagonal/hooks/check-preset-update.mjs +4 -3
- package/presets/zcode/php-hexagonal/rules/agent-team-intake.md +1 -0
- package/presets/zcode/php-hexagonal/rules/agent-team-orchestrator.md +5 -2
- package/presets/zcode/php-hexagonal/rules/preset-pr-checklist.md +4 -4
- package/presets/zcode/php-hexagonal/rules/preset-twin-sync.md +1 -1
- package/presets/zcode/php-hexagonal/team/README.md +5 -0
- package/presets/zcode/php-laravel/adapter-map.json +11 -3
- package/presets/zcode/php-laravel/hooks/README.md +2 -1
- package/presets/zcode/php-laravel/hooks/chain-team-phases.sh +57 -3
- package/presets/zcode/php-laravel/hooks/check-preset-update.mjs +4 -3
- package/presets/zcode/php-laravel/rules/agent-team-intake.md +1 -0
- package/presets/zcode/php-laravel/rules/agent-team-orchestrator.md +5 -2
- package/presets/zcode/php-laravel/rules/preset-pr-checklist.md +4 -4
- package/presets/zcode/php-laravel/rules/preset-twin-sync.md +1 -1
- package/presets/zcode/php-laravel/team/README.md +5 -0
- package/presets/zcode/svelte/adapter-map.json +11 -3
- package/presets/zcode/svelte/hooks/README.md +2 -1
- package/presets/zcode/svelte/hooks/chain-team-phases.sh +57 -3
- package/presets/zcode/svelte/hooks/check-preset-update.mjs +4 -3
- package/presets/zcode/svelte/rules/agent-team-intake.md +1 -0
- package/presets/zcode/svelte/rules/agent-team-orchestrator.md +5 -2
- package/presets/zcode/svelte/rules/preset-pr-checklist.md +4 -4
- package/presets/zcode/svelte/rules/preset-twin-sync.md +1 -1
- package/presets/zcode/svelte/team/README.md +5 -0
- package/presets/claude/android-kotlin/hooks/guard-shell-command.sh +0 -103
- package/presets/claude/go/hooks/guard-shell-command.sh +0 -102
- package/presets/claude/mcp-ts/hooks/guard-shell-command.sh +0 -102
- package/presets/claude/php-hexagonal/hooks/guard-shell-command.sh +0 -103
- package/presets/claude/php-laravel/hooks/guard-shell-command.sh +0 -103
- package/presets/cursor/android-kotlin/hooks/guard-shell-command.sh +0 -80
- package/presets/cursor/go/hooks/guard-shell-command.sh +0 -79
- package/presets/cursor/ios-swift/hooks/guard-shell-command.sh +0 -79
- package/presets/cursor/java/hooks/guard-shell-command.sh +0 -80
- package/presets/cursor/mcp-ts/hooks/guard-shell-command.sh +0 -79
- package/presets/cursor/mol/hooks/guard-shell-command.sh +0 -77
- package/presets/cursor/next/hooks/guard-shell-command.sh +0 -77
- package/presets/cursor/nuxt/hooks/guard-shell-command.sh +0 -77
- package/presets/cursor/php-hexagonal/hooks/guard-shell-command.sh +0 -80
- package/presets/cursor/php-laravel/hooks/guard-shell-command.sh +0 -80
- package/presets/cursor/svelte/hooks/guard-shell-command.sh +0 -77
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `node:http` only. The surface is loopback-only by default, sends no CORS
|
|
5
5
|
* header, and reads files through SQLite rows (never through a request path).
|
|
6
|
-
* The
|
|
7
|
-
* delete
|
|
8
|
-
*
|
|
9
|
-
* is
|
|
6
|
+
* The six mutating operations — the idempotent rescan, the confirmed task
|
|
7
|
+
* delete, and the four job writes (create, update, delete, run-now) — each run
|
|
8
|
+
* one bounded child process; the server itself never opens a writable
|
|
9
|
+
* connection and the kill switch stops every mutation before a child is
|
|
10
|
+
* spawned.
|
|
10
11
|
*
|
|
11
12
|
* Every SQL statement in this module is a static string with bound parameters.
|
|
12
13
|
* The only interpolated fragments are the module-level constants `TASK_FILTER`,
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
import fs from 'node:fs';
|
|
18
19
|
import http from 'node:http';
|
|
19
20
|
import path from 'node:path';
|
|
20
|
-
import {
|
|
21
|
+
import { spawn } from 'node:child_process';
|
|
21
22
|
import { fileURLToPath } from 'node:url';
|
|
22
23
|
|
|
23
24
|
import {
|
|
@@ -44,6 +45,21 @@ import {
|
|
|
44
45
|
serializeOpenApiDocument,
|
|
45
46
|
} from './team-db-openapi.mjs';
|
|
46
47
|
import { DASHBOARD_CSS, DASHBOARD_HTML, DASHBOARD_JS } from './team-db-dashboard.mjs';
|
|
48
|
+
import {
|
|
49
|
+
DEFAULT_LOG_LIMIT,
|
|
50
|
+
JOB_ID_RE,
|
|
51
|
+
MAX_JOBS,
|
|
52
|
+
MAX_LOG_LIMIT,
|
|
53
|
+
MIN_LOG_LIMIT,
|
|
54
|
+
RUN_ID_RE,
|
|
55
|
+
RUN_STATES,
|
|
56
|
+
TERMINAL_RUN_STATES,
|
|
57
|
+
jobDueInstants,
|
|
58
|
+
nextFireAt,
|
|
59
|
+
readLease,
|
|
60
|
+
readLogChunk,
|
|
61
|
+
readStateFile,
|
|
62
|
+
} from './team-db-scheduler.mjs';
|
|
47
63
|
|
|
48
64
|
export const DEFAULT_HOST = '127.0.0.1';
|
|
49
65
|
export const DEFAULT_PORT = 4178;
|
|
@@ -56,6 +72,11 @@ export const MAX_REQUEST_BODY_BYTES = 1024;
|
|
|
56
72
|
export const MAX_EXPORT_BYTES = 5 * 1024 * 1024;
|
|
57
73
|
export const SYNC_CHILD_TIMEOUT_MS = 30000;
|
|
58
74
|
export const SYNC_CHILD_DEADLINE_MS = 25000;
|
|
75
|
+
export const JOB_BODY_MAX = 65536;
|
|
76
|
+
export const JOB_WRITE_CHILD_TIMEOUT_MS = 10000;
|
|
77
|
+
export const JOB_DELETE_CHILD_TIMEOUT_MS = 30000;
|
|
78
|
+
export const JOB_RUN_CHILD_TIMEOUT_MS = 10000;
|
|
79
|
+
export const SCHEDULER_HINT = 'start team-db.mjs schedule';
|
|
59
80
|
export const LOOPBACK_HOSTS = ['127.0.0.1', 'localhost', '::1'];
|
|
60
81
|
const CLIENT_HEADERS = {
|
|
61
82
|
'X-Content-Type-Options': 'nosniff',
|
|
@@ -87,6 +108,8 @@ const CODE_STATUS_ROWS = [
|
|
|
87
108
|
['E_DOC_BINARY', 410],
|
|
88
109
|
['E_DOC_CONTENT_OMITTED', 409],
|
|
89
110
|
['E_ACTIVE_TASK', 409],
|
|
111
|
+
['E_CONFLICT', 409],
|
|
112
|
+
['E_SCHEDULER_OFFLINE', 409],
|
|
90
113
|
['E_RANGE', 416],
|
|
91
114
|
['E_DISABLED', 503],
|
|
92
115
|
['E_DB_MISSING', 503],
|
|
@@ -271,6 +294,17 @@ const SQL = {
|
|
|
271
294
|
listSyncRuns: `SELECT run_id, mode, started_at, finished_at, inserted, updated, unchanged, failed, absent, pruned, rebuilt, exit_code, error
|
|
272
295
|
FROM sync_runs ORDER BY started_at DESC, run_id DESC LIMIT ?1 OFFSET ?2`,
|
|
273
296
|
maxSyncRun: 'SELECT max(run_id) AS run_id FROM sync_runs',
|
|
297
|
+
listJobs: `SELECT * FROM scheduled_jobs WHERE absent_at IS NULL ORDER BY id ASC LIMIT ?1`,
|
|
298
|
+
getJob: 'SELECT * FROM scheduled_jobs WHERE id = ?1 AND absent_at IS NULL',
|
|
299
|
+
countJobRuns: `SELECT count(*) AS total FROM job_runs
|
|
300
|
+
WHERE job_id = ?1 AND (json_array_length(?2) = 0 OR state IN (SELECT value FROM json_each(?2)))`,
|
|
301
|
+
listJobRuns: `SELECT * FROM job_runs
|
|
302
|
+
WHERE job_id = ?1 AND (json_array_length(?2) = 0 OR state IN (SELECT value FROM json_each(?2)))
|
|
303
|
+
ORDER BY started_at DESC, run_id DESC LIMIT ?3 OFFSET ?4`,
|
|
304
|
+
getJobRun: 'SELECT * FROM job_runs WHERE job_id = ?1 AND run_id = ?2',
|
|
305
|
+
listJobRunEvents: 'SELECT seq, at, state, code, message FROM job_run_events WHERE run_id = ?1 ORDER BY seq ASC',
|
|
306
|
+
lastJobRun: `SELECT run_id, state, finished_at, duration_ms FROM job_runs
|
|
307
|
+
WHERE job_id = ?1 ORDER BY started_at DESC, run_id DESC LIMIT 1`,
|
|
274
308
|
healthTotals: 'SELECT count(*) AS total, COALESCE(SUM(CASE WHEN absent_at IS NOT NULL THEN 1 ELSE 0 END), 0) AS absent, max(projected_at) AS projected_at FROM tasks',
|
|
275
309
|
searchFts: `SELECT DISTINCT task_slug AS slug FROM search_fts WHERE search_fts MATCH ?1 LIMIT ?2`,
|
|
276
310
|
searchLike: `SELECT DISTINCT task_slug AS slug FROM documents
|
|
@@ -892,6 +926,22 @@ const getHealth = (handle, settings) => {
|
|
|
892
926
|
const connection = handle.db;
|
|
893
927
|
const totals = connection.prepare(SQL.healthTotals).get();
|
|
894
928
|
const stored = readSchemaMeta(connection, 'fingerprint');
|
|
929
|
+
// The scheduler signal comes from the lease file, never from SQL: a runtime
|
|
930
|
+
// that cannot schedule still answers, and its absence is discoverable.
|
|
931
|
+
const lease = readLease(settings.teamRoot);
|
|
932
|
+
const state = readStateFile(settings.teamRoot);
|
|
933
|
+
const now = Date.now();
|
|
934
|
+
const jobsDue = connection
|
|
935
|
+
.prepare(SQL.listJobs)
|
|
936
|
+
.all(MAX_JOBS)
|
|
937
|
+
.map(jobRowToDefinition)
|
|
938
|
+
.filter((job) => job.enabled)
|
|
939
|
+
.filter((job) => {
|
|
940
|
+
const recorded = state.lastFireAt?.[job.id];
|
|
941
|
+
const lastFireAt =
|
|
942
|
+
typeof recorded === 'string' && !Number.isNaN(Date.parse(recorded)) ? Date.parse(recorded) : null;
|
|
943
|
+
return jobDueInstants(job, lastFireAt, now, 1000).length > 0;
|
|
944
|
+
}).length;
|
|
895
945
|
return {
|
|
896
946
|
status: 'ok',
|
|
897
947
|
db: {
|
|
@@ -903,7 +953,18 @@ const getHealth = (handle, settings) => {
|
|
|
903
953
|
},
|
|
904
954
|
tasks: { total: Number(totals.total), absent: Number(totals.absent) },
|
|
905
955
|
projectedAt: totals.projected_at ?? null,
|
|
906
|
-
capabilities: ['sync', 'delete'],
|
|
956
|
+
capabilities: ['sync', 'delete', 'jobs', 'schedule'],
|
|
957
|
+
scheduler: {
|
|
958
|
+
state: lease.state,
|
|
959
|
+
pid: lease.lease?.pid === undefined ? null : Number(lease.lease.pid),
|
|
960
|
+
startedAt: lease.lease?.startedAt ?? null,
|
|
961
|
+
heartbeatAt: lease.lease?.heartbeatAt ?? null,
|
|
962
|
+
nextTickAt:
|
|
963
|
+
lease.state === 'running' && lease.lease?.heartbeatAt
|
|
964
|
+
? new Date(Date.parse(lease.lease.heartbeatAt) + 1000).toISOString()
|
|
965
|
+
: null,
|
|
966
|
+
jobsDue,
|
|
967
|
+
},
|
|
907
968
|
};
|
|
908
969
|
};
|
|
909
970
|
|
|
@@ -928,6 +989,353 @@ const getMeta = (handle) => {
|
|
|
928
989
|
};
|
|
929
990
|
};
|
|
930
991
|
|
|
992
|
+
/* ---------------------------------- jobs ---------------------------------- */
|
|
993
|
+
|
|
994
|
+
const JOBS_SORT = new Set(['id', '-id', 'updatedAt', '-updatedAt', 'nextFireAt', '-nextFireAt']);
|
|
995
|
+
|
|
996
|
+
/** One `scheduled_jobs` row back into the definition the file holds. */
|
|
997
|
+
const jobRowToDefinition = (row) => ({
|
|
998
|
+
id: String(row.id),
|
|
999
|
+
title: String(row.title),
|
|
1000
|
+
enabled: row.enabled === 1,
|
|
1001
|
+
// The response omits the key that belongs to the other `kind`, exactly like
|
|
1002
|
+
// `payload_json`: the write validator refuses a null sibling, so a
|
|
1003
|
+
// `JobDetail.job` can be sent straight back as a `PUT` body.
|
|
1004
|
+
schedule:
|
|
1005
|
+
row.schedule_kind === 'cron'
|
|
1006
|
+
? { kind: 'cron', expression: row.cron, timezone: String(row.timezone) }
|
|
1007
|
+
: { kind: 'interval', everySeconds: Number(row.every_seconds), timezone: String(row.timezone) },
|
|
1008
|
+
payload: JSON.parse(row.payload_json),
|
|
1009
|
+
cwd: String(row.cwd),
|
|
1010
|
+
envPassthrough: JSON.parse(row.env_json),
|
|
1011
|
+
timeoutMs: Number(row.timeout_ms),
|
|
1012
|
+
concurrency: String(row.concurrency),
|
|
1013
|
+
misfire: String(row.misfire),
|
|
1014
|
+
createdAt: String(row.created_at),
|
|
1015
|
+
updatedAt: String(row.updated_at),
|
|
1016
|
+
revision: Number(row.revision),
|
|
1017
|
+
});
|
|
1018
|
+
|
|
1019
|
+
const runRowToJson = (row) => ({
|
|
1020
|
+
runId: String(row.run_id),
|
|
1021
|
+
jobId: String(row.job_id),
|
|
1022
|
+
trigger: String(row.trigger),
|
|
1023
|
+
state: String(row.state),
|
|
1024
|
+
reasonCode: row.reason_code ?? null,
|
|
1025
|
+
exitCode: row.exit_code === null ? null : Number(row.exit_code),
|
|
1026
|
+
signal: row.signal ?? null,
|
|
1027
|
+
pid: row.pid === null ? null : Number(row.pid),
|
|
1028
|
+
startedAt: String(row.started_at),
|
|
1029
|
+
finishedAt: row.finished_at ?? null,
|
|
1030
|
+
durationMs: row.duration_ms === null ? null : Number(row.duration_ms),
|
|
1031
|
+
stdoutBytes: Number(row.stdout_bytes ?? 0),
|
|
1032
|
+
stderrBytes: Number(row.stderr_bytes ?? 0),
|
|
1033
|
+
stdoutTruncated: row.stdout_truncated === 1,
|
|
1034
|
+
stderrTruncated: row.stderr_truncated === 1,
|
|
1035
|
+
parseError: row.parse_error ?? null,
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1038
|
+
const jobDetail = (db, settings, row, now) => {
|
|
1039
|
+
const definition = jobRowToDefinition(row);
|
|
1040
|
+
const state = readStateFile(settings.teamRoot);
|
|
1041
|
+
const recorded = state.lastFireAt?.[definition.id];
|
|
1042
|
+
const lastFireAt = typeof recorded === 'string' && !Number.isNaN(Date.parse(recorded)) ? Date.parse(recorded) : null;
|
|
1043
|
+
const last = db.prepare(SQL.lastJobRun).get(definition.id);
|
|
1044
|
+
return {
|
|
1045
|
+
job: definition,
|
|
1046
|
+
nextFireAt: nextFireAt(definition, { now, lastFireAt }),
|
|
1047
|
+
lastRun: last
|
|
1048
|
+
? {
|
|
1049
|
+
runId: String(last.run_id),
|
|
1050
|
+
state: String(last.state),
|
|
1051
|
+
finishedAt: last.finished_at ?? null,
|
|
1052
|
+
durationMs: last.duration_ms === null ? null : Number(last.duration_ms),
|
|
1053
|
+
}
|
|
1054
|
+
: null,
|
|
1055
|
+
};
|
|
1056
|
+
};
|
|
1057
|
+
|
|
1058
|
+
const requireJobRow = (db, id) => {
|
|
1059
|
+
const row = db.prepare(SQL.getJob).get(id);
|
|
1060
|
+
if (!row) fail('E_NOT_FOUND', 404, `no job "${id}"`);
|
|
1061
|
+
return row;
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
const parseJobId = (value) => {
|
|
1065
|
+
if (typeof value !== 'string' || value.length > 64 || !JOB_ID_RE.test(value)) {
|
|
1066
|
+
fail('E_VALIDATION', 422, 'the job id has an invalid shape', { parameter: 'id' });
|
|
1067
|
+
}
|
|
1068
|
+
return value;
|
|
1069
|
+
};
|
|
1070
|
+
|
|
1071
|
+
const parseRunId = (value) => {
|
|
1072
|
+
if (typeof value !== 'string' || !RUN_ID_RE.test(value)) {
|
|
1073
|
+
fail('E_VALIDATION', 422, 'the run id has an invalid shape', { parameter: 'runId' });
|
|
1074
|
+
}
|
|
1075
|
+
return value;
|
|
1076
|
+
};
|
|
1077
|
+
|
|
1078
|
+
const listJobs = (db, settings, query) => {
|
|
1079
|
+
const limit = parseInteger(query.get('limit'), 'limit', { min: 1, max: MAX_LIMIT, fallback: DEFAULT_LIMIT });
|
|
1080
|
+
const offset = parseInteger(query.get('offset'), 'offset', { min: 0, max: MAX_OFFSET, fallback: 0 });
|
|
1081
|
+
const enabled = parseBoolean(query.get('enabled'), 'enabled', null);
|
|
1082
|
+
const sort = parseEnum(query.get('sort'), 'sort', JOBS_SORT, 'id');
|
|
1083
|
+
const now = Date.now();
|
|
1084
|
+
// At most MAX_JOBS definitions are read, so `sort=nextFireAt` is exact while
|
|
1085
|
+
// the SQL stays a plain ordered read by id.
|
|
1086
|
+
const rows = db.prepare(SQL.listJobs).all(MAX_JOBS);
|
|
1087
|
+
const items = rows
|
|
1088
|
+
.map((row) => jobDetail(db, settings, row, now))
|
|
1089
|
+
.filter((entry) => enabled === null || entry.job.enabled === enabled);
|
|
1090
|
+
const compare = {
|
|
1091
|
+
id: (left, right) => left.job.id.localeCompare(right.job.id),
|
|
1092
|
+
updatedAt: (left, right) => String(left.job.updatedAt).localeCompare(String(right.job.updatedAt)),
|
|
1093
|
+
nextFireAt: (left, right) => String(left.nextFireAt ?? '9999').localeCompare(String(right.nextFireAt ?? '9999')),
|
|
1094
|
+
}[sort.replace(/^-/, '')];
|
|
1095
|
+
const direction = sort.startsWith('-') ? -1 : 1;
|
|
1096
|
+
items.sort((left, right) => direction * compare(left, right));
|
|
1097
|
+
const total = items.length;
|
|
1098
|
+
return {
|
|
1099
|
+
items: items.slice(offset, offset + limit),
|
|
1100
|
+
total,
|
|
1101
|
+
limit,
|
|
1102
|
+
offset,
|
|
1103
|
+
nextOffset: offset + limit < total ? offset + limit : null,
|
|
1104
|
+
};
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
const listJobRuns = (db, id, query) => {
|
|
1108
|
+
requireJobRow(db, id);
|
|
1109
|
+
const limit = parseInteger(query.get('limit'), 'limit', { min: 1, max: MAX_LIMIT, fallback: DEFAULT_LIMIT });
|
|
1110
|
+
const offset = parseInteger(query.get('offset'), 'offset', { min: 0, max: MAX_OFFSET, fallback: 0 });
|
|
1111
|
+
const states = parseCsv(query.get('state'), 'state', new Set(RUN_STATES));
|
|
1112
|
+
const total = Number(db.prepare(SQL.countJobRuns).get(id, JSON.stringify(states)).total);
|
|
1113
|
+
const rows = db.prepare(SQL.listJobRuns).all(id, JSON.stringify(states), limit, offset);
|
|
1114
|
+
return {
|
|
1115
|
+
items: rows.map(runRowToJson),
|
|
1116
|
+
total,
|
|
1117
|
+
limit,
|
|
1118
|
+
offset,
|
|
1119
|
+
nextOffset: offset + limit < total ? offset + limit : null,
|
|
1120
|
+
};
|
|
1121
|
+
};
|
|
1122
|
+
|
|
1123
|
+
const getJobRun = (db, id, runId) => {
|
|
1124
|
+
requireJobRow(db, id);
|
|
1125
|
+
const row = db.prepare(SQL.getJobRun).get(id, runId);
|
|
1126
|
+
if (!row) fail('E_NOT_FOUND', 404, `no run "${runId}" for job "${id}"`);
|
|
1127
|
+
const events = db
|
|
1128
|
+
.prepare(SQL.listJobRunEvents)
|
|
1129
|
+
.all(runId)
|
|
1130
|
+
.map((event) => ({
|
|
1131
|
+
seq: Number(event.seq),
|
|
1132
|
+
at: String(event.at),
|
|
1133
|
+
state: String(event.state),
|
|
1134
|
+
code: event.code ?? null,
|
|
1135
|
+
message: event.message ?? null,
|
|
1136
|
+
}));
|
|
1137
|
+
return {
|
|
1138
|
+
run: runRowToJson(row),
|
|
1139
|
+
events,
|
|
1140
|
+
child: {
|
|
1141
|
+
pid: row.pid === null ? null : Number(row.pid),
|
|
1142
|
+
exitCode: row.exit_code === null ? null : Number(row.exit_code),
|
|
1143
|
+
signal: row.signal ?? null,
|
|
1144
|
+
timedOut: String(row.state) === 'timeout',
|
|
1145
|
+
},
|
|
1146
|
+
logs: {
|
|
1147
|
+
stdout: {
|
|
1148
|
+
bytes: Number(row.stdout_bytes ?? 0),
|
|
1149
|
+
sha256: row.stdout_sha256 ?? null,
|
|
1150
|
+
truncated: row.stdout_truncated === 1,
|
|
1151
|
+
},
|
|
1152
|
+
stderr: {
|
|
1153
|
+
bytes: Number(row.stderr_bytes ?? 0),
|
|
1154
|
+
sha256: row.stderr_sha256 ?? null,
|
|
1155
|
+
truncated: row.stderr_truncated === 1,
|
|
1156
|
+
},
|
|
1157
|
+
},
|
|
1158
|
+
};
|
|
1159
|
+
};
|
|
1160
|
+
|
|
1161
|
+
const getJobRunLog = (db, settings, id, runId, query) => {
|
|
1162
|
+
requireJobRow(db, id);
|
|
1163
|
+
const row = db.prepare(SQL.getJobRun).get(id, runId);
|
|
1164
|
+
if (!row) fail('E_NOT_FOUND', 404, `no run "${runId}" for job "${id}"`);
|
|
1165
|
+
const stream = query.get('stream');
|
|
1166
|
+
if (stream !== null && stream !== 'stdout' && stream !== 'stderr') {
|
|
1167
|
+
fail('E_VALIDATION', 422, 'stream must be stdout or stderr', { parameter: 'stream' });
|
|
1168
|
+
}
|
|
1169
|
+
const offset = parseInteger(query.get('offset'), 'offset', { min: 0, max: MAX_DOC_LIMIT, fallback: 0 });
|
|
1170
|
+
const limit = parseInteger(query.get('limit'), 'limit', {
|
|
1171
|
+
min: MIN_LOG_LIMIT,
|
|
1172
|
+
max: MAX_LOG_LIMIT,
|
|
1173
|
+
fallback: DEFAULT_LOG_LIMIT,
|
|
1174
|
+
});
|
|
1175
|
+
return readLogChunk(settings.teamRoot, row, { stream: stream ?? 'stdout', offset, limit });
|
|
1176
|
+
};
|
|
1177
|
+
|
|
1178
|
+
/* ----------------------------- write children ----------------------------- */
|
|
1179
|
+
|
|
1180
|
+
const runTeamDbChild = (args, options) =>
|
|
1181
|
+
new Promise((resolve, reject) => {
|
|
1182
|
+
if (isKillSwitchSet()) fail('E_DISABLED', 503, 'the projection is disabled by AI_RULES_TEAM_DB_DISABLE');
|
|
1183
|
+
const script = path.join(moduleDirectory, 'team-db.mjs');
|
|
1184
|
+
if (!fs.existsSync(script)) fail('E_DB_MISSING', 503, 'team-db.mjs is not installed next to the server');
|
|
1185
|
+
const { settings, timeoutMs, input, label } = options;
|
|
1186
|
+
let child;
|
|
1187
|
+
try {
|
|
1188
|
+
child = spawn(
|
|
1189
|
+
process.execPath,
|
|
1190
|
+
[script, ...args, '--json', '--root', settings.teamRoot],
|
|
1191
|
+
{
|
|
1192
|
+
cwd: settings.cwd,
|
|
1193
|
+
env: { ...process.env, AI_RULES_TEAM_DB_PATH: settings.dbPath },
|
|
1194
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
1195
|
+
},
|
|
1196
|
+
);
|
|
1197
|
+
} catch {
|
|
1198
|
+
fail('E_INTERNAL', 500, `the ${label} child could not start`);
|
|
1199
|
+
}
|
|
1200
|
+
let stdout = '';
|
|
1201
|
+
let stderr = '';
|
|
1202
|
+
let timedOut = false;
|
|
1203
|
+
let settled = false;
|
|
1204
|
+
const timer = setTimeout(() => {
|
|
1205
|
+
timedOut = true;
|
|
1206
|
+
try {
|
|
1207
|
+
child.kill('SIGKILL');
|
|
1208
|
+
} catch {
|
|
1209
|
+
/* the child may have exited between the timer and the signal */
|
|
1210
|
+
}
|
|
1211
|
+
}, timeoutMs);
|
|
1212
|
+
const settle = (fn, value) => {
|
|
1213
|
+
if (settled) return;
|
|
1214
|
+
settled = true;
|
|
1215
|
+
clearTimeout(timer);
|
|
1216
|
+
fn(value);
|
|
1217
|
+
};
|
|
1218
|
+
child.stdout.on('data', (chunk) => {
|
|
1219
|
+
stdout += chunk;
|
|
1220
|
+
});
|
|
1221
|
+
child.stderr.on('data', (chunk) => {
|
|
1222
|
+
stderr += chunk;
|
|
1223
|
+
});
|
|
1224
|
+
child.on('error', () => {
|
|
1225
|
+
settle(reject, new ApiError('E_INTERNAL', 500, `the ${label} child could not start`));
|
|
1226
|
+
});
|
|
1227
|
+
child.on('close', (code) => {
|
|
1228
|
+
if (timedOut) {
|
|
1229
|
+
settle(reject, new ApiError('E_BUSY', 503, `the ${label} exceeded ${Math.round(timeoutMs / 1000)} s and was killed`));
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1232
|
+
let parsed = null;
|
|
1233
|
+
try {
|
|
1234
|
+
parsed = JSON.parse(String(stdout || '').trim());
|
|
1235
|
+
} catch {
|
|
1236
|
+
parsed = null;
|
|
1237
|
+
}
|
|
1238
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
1239
|
+
// One `path: reason` line, never prompt content, so an operator can act.
|
|
1240
|
+
const detail = String(stderr || '')
|
|
1241
|
+
.split('\n')
|
|
1242
|
+
.map((line) => line.trim())
|
|
1243
|
+
.find((line) => line.length > 0);
|
|
1244
|
+
settle(
|
|
1245
|
+
reject,
|
|
1246
|
+
new ApiError(
|
|
1247
|
+
'E_INTERNAL',
|
|
1248
|
+
500,
|
|
1249
|
+
`the ${label} exited ${code} without a parseable result${detail ? ` (${detail.slice(0, 300)})` : ''}`,
|
|
1250
|
+
),
|
|
1251
|
+
);
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1254
|
+
settle(resolve, parsed);
|
|
1255
|
+
});
|
|
1256
|
+
if (input !== undefined) child.stdin.write(input);
|
|
1257
|
+
child.stdin.end();
|
|
1258
|
+
});
|
|
1259
|
+
|
|
1260
|
+
const requireJsonBody = (context) => {
|
|
1261
|
+
const text = context.body.toString('utf8').trim();
|
|
1262
|
+
if (text === '') fail('E_VALIDATION', 422, 'a job body is required', { parameter: 'body' });
|
|
1263
|
+
try {
|
|
1264
|
+
return JSON.parse(text);
|
|
1265
|
+
} catch {
|
|
1266
|
+
fail('E_VALIDATION', 422, 'the job body is not valid JSON', { parameter: 'body' });
|
|
1267
|
+
}
|
|
1268
|
+
return null;
|
|
1269
|
+
};
|
|
1270
|
+
|
|
1271
|
+
const createOrUpdateJob = async (context, mode) => {
|
|
1272
|
+
const parsed = requireJsonBody(context);
|
|
1273
|
+
const id = mode === 'update' ? parseJobId(context.params.id) : undefined;
|
|
1274
|
+
if (mode === 'update' && parsed && parsed.id !== undefined && parsed.id !== id) {
|
|
1275
|
+
fail('E_CONFLICT', 409, 'the body id differs from the path id; the id is immutable');
|
|
1276
|
+
}
|
|
1277
|
+
const body = JSON.stringify(mode === 'update' ? { ...parsed, id } : parsed);
|
|
1278
|
+
const result = await runTeamDbChild(['jobs', 'put', '--file', '-'], {
|
|
1279
|
+
settings: context.settings,
|
|
1280
|
+
timeoutMs: JOB_WRITE_CHILD_TIMEOUT_MS,
|
|
1281
|
+
input: body,
|
|
1282
|
+
label: 'job write',
|
|
1283
|
+
});
|
|
1284
|
+
if (result.ok !== true) {
|
|
1285
|
+
const code = typeof result.code === 'string' ? result.code : 'E_INTERNAL';
|
|
1286
|
+
const details = typeof result.parameter === 'string' ? { parameter: result.parameter } : undefined;
|
|
1287
|
+
fail(mapTeamDbCode(code), mapTeamDbCode(code, true), String(result.message ?? 'the job write was refused'), details);
|
|
1288
|
+
}
|
|
1289
|
+
const db = context.db();
|
|
1290
|
+
const row = requireJobRow(db, result.job.id);
|
|
1291
|
+
return { json: jobDetail(db, context.settings, row, Date.now()) };
|
|
1292
|
+
};
|
|
1293
|
+
|
|
1294
|
+
const deleteJob = async (context) => {
|
|
1295
|
+
const id = parseJobId(context.params.id);
|
|
1296
|
+
requireJobRow(context.db(), id);
|
|
1297
|
+
const result = await runTeamDbChild(['jobs', 'delete', id], {
|
|
1298
|
+
settings: context.settings,
|
|
1299
|
+
timeoutMs: JOB_DELETE_CHILD_TIMEOUT_MS,
|
|
1300
|
+
label: 'job delete',
|
|
1301
|
+
});
|
|
1302
|
+
if (result.ok !== true) {
|
|
1303
|
+
const code = typeof result.code === 'string' ? result.code : 'E_INTERNAL';
|
|
1304
|
+
fail(mapTeamDbCode(code), mapTeamDbCode(code, true), String(result.message ?? `the delete of ${id} was refused`));
|
|
1305
|
+
}
|
|
1306
|
+
return { json: { ok: true, id: String(result.id ?? id), runsRemoved: Number(result.runsRemoved ?? 0) } };
|
|
1307
|
+
};
|
|
1308
|
+
|
|
1309
|
+
/**
|
|
1310
|
+
* Run-now is refused **before any enqueue** when no scheduler holds a fresh
|
|
1311
|
+
* lease: the request could never be claimed, and "requested" with no run is
|
|
1312
|
+
* the failure N-3 exists to prevent.
|
|
1313
|
+
*/
|
|
1314
|
+
const runJobNow = async (context) => {
|
|
1315
|
+
const id = parseJobId(context.params.id);
|
|
1316
|
+
requireJobRow(context.db(), id);
|
|
1317
|
+
if (readLease(context.settings.teamRoot).state !== 'running') {
|
|
1318
|
+
fail('E_SCHEDULER_OFFLINE', 409, 'no scheduler holds the lease, so the request could not be claimed', {
|
|
1319
|
+
hint: SCHEDULER_HINT,
|
|
1320
|
+
});
|
|
1321
|
+
}
|
|
1322
|
+
const result = await runTeamDbChild(['jobs', 'run', '--id', id], {
|
|
1323
|
+
settings: context.settings,
|
|
1324
|
+
timeoutMs: JOB_RUN_CHILD_TIMEOUT_MS,
|
|
1325
|
+
label: 'job run request',
|
|
1326
|
+
});
|
|
1327
|
+
if (result.requested !== true) {
|
|
1328
|
+
fail('E_INTERNAL', 500, 'the run request reported neither an acceptance nor a documented refusal');
|
|
1329
|
+
}
|
|
1330
|
+
return {
|
|
1331
|
+
json: {
|
|
1332
|
+
requested: true,
|
|
1333
|
+
requestedAt: String(result.requestedAt ?? new Date().toISOString()),
|
|
1334
|
+
schedulerOnline: result.schedulerOnline !== false,
|
|
1335
|
+
},
|
|
1336
|
+
};
|
|
1337
|
+
};
|
|
1338
|
+
|
|
931
1339
|
/* --------------------------------- rescan ---------------------------------- */
|
|
932
1340
|
|
|
933
1341
|
const syncSettings = (settings) => ({
|
|
@@ -935,33 +1343,18 @@ const syncSettings = (settings) => ({
|
|
|
935
1343
|
dbPath: settings.dbPath,
|
|
936
1344
|
});
|
|
937
1345
|
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
1346
|
+
/**
|
|
1347
|
+
* Rescan through the canonical CLI in a bounded, asynchronous child: no
|
|
1348
|
+
* request path ever blocks the event loop (AC-4.3).
|
|
1349
|
+
*/
|
|
1350
|
+
const runSyncChild = async (context) => {
|
|
1351
|
+
const { settings } = context;
|
|
1352
|
+
const parsed = await runTeamDbChild(
|
|
1353
|
+
['sync', '--quiet', '--deadline-ms', String(SYNC_CHILD_DEADLINE_MS)],
|
|
1354
|
+
{ settings, timeoutMs: SYNC_CHILD_TIMEOUT_MS, label: 'rescan' },
|
|
946
1355
|
);
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
let parsed = null;
|
|
950
|
-
try {
|
|
951
|
-
parsed = JSON.parse(String(child.stdout || '').trim());
|
|
952
|
-
} catch {
|
|
953
|
-
parsed = null;
|
|
954
|
-
}
|
|
955
|
-
if (!parsed) {
|
|
956
|
-
// One `path: reason` line, never prompt content, so an operator can act.
|
|
957
|
-
const detail = String(child.stderr || '')
|
|
958
|
-
.split('\n')
|
|
959
|
-
.map((line) => line.trim())
|
|
960
|
-
.find((line) => line.length > 0);
|
|
961
|
-
fail('E_INTERNAL', 500, `the rescan exited ${child.status} without a parseable result${detail ? ` (${detail.slice(0, 300)})` : ''}`);
|
|
962
|
-
}
|
|
963
|
-
const connection = db();
|
|
964
|
-
const row = connection.prepare(SQL.maxSyncRun).get();
|
|
1356
|
+
const db = context.db();
|
|
1357
|
+
const row = db.prepare(SQL.maxSyncRun).get();
|
|
965
1358
|
const runId = row && row.run_id !== null ? Number(row.run_id) : null;
|
|
966
1359
|
return {
|
|
967
1360
|
runId,
|
|
@@ -991,31 +1384,12 @@ const runSyncChild = (db, settings) => {
|
|
|
991
1384
|
* unspecified code ever leaks. The 30 s `SIGKILL` bound and the sanitized
|
|
992
1385
|
* one-line stderr detail are the rescan child's own.
|
|
993
1386
|
*/
|
|
994
|
-
const runDeleteChild = (slug,
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
[script, 'delete', '--slug', slug, '--json', '--root', settings.teamRoot],
|
|
1001
|
-
{ cwd: settings.cwd, env: { ...process.env, AI_RULES_TEAM_DB_PATH: settings.dbPath }, encoding: 'utf8', timeout: SYNC_CHILD_TIMEOUT_MS, killSignal: 'SIGKILL', stdio: ['ignore', 'pipe', 'pipe'] },
|
|
1002
|
-
);
|
|
1003
|
-
if (child.error && child.error.code === 'ETIMEDOUT') fail('E_BUSY', 503, `the delete of ${slug} exceeded 30 s and was killed`);
|
|
1004
|
-
if (child.error) fail('E_INTERNAL', 500, 'the delete child could not start');
|
|
1005
|
-
let parsed = null;
|
|
1006
|
-
try {
|
|
1007
|
-
parsed = JSON.parse(String(child.stdout || '').trim());
|
|
1008
|
-
} catch {
|
|
1009
|
-
parsed = null;
|
|
1010
|
-
}
|
|
1011
|
-
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
1012
|
-
// One `path: reason` line, never prompt content, so an operator can act.
|
|
1013
|
-
const detail = String(child.stderr || '')
|
|
1014
|
-
.split('\n')
|
|
1015
|
-
.map((line) => line.trim())
|
|
1016
|
-
.find((line) => line.length > 0);
|
|
1017
|
-
fail('E_INTERNAL', 500, `the delete exited ${child.status} without a parseable result${detail ? ` (${detail.slice(0, 300)})` : ''}`);
|
|
1018
|
-
}
|
|
1387
|
+
const runDeleteChild = async (slug, context) => {
|
|
1388
|
+
const parsed = await runTeamDbChild(['delete', '--slug', slug], {
|
|
1389
|
+
settings: context.settings,
|
|
1390
|
+
timeoutMs: SYNC_CHILD_TIMEOUT_MS,
|
|
1391
|
+
label: `delete of ${slug}`,
|
|
1392
|
+
});
|
|
1019
1393
|
if (parsed.ok === false) {
|
|
1020
1394
|
const code = typeof parsed.code === 'string' ? parsed.code : 'E_INTERNAL';
|
|
1021
1395
|
// The guard fires only when the target is the active slug, so the detail
|
|
@@ -1031,11 +1405,13 @@ const runDeleteChild = (slug, settings) => {
|
|
|
1031
1405
|
|
|
1032
1406
|
/* --------------------------------- routing -------------------------------- */
|
|
1033
1407
|
|
|
1034
|
-
const route = (method, routePath, operationId, handler) => ({
|
|
1408
|
+
const route = (method, routePath, operationId, handler, options = {}) => ({
|
|
1035
1409
|
method,
|
|
1036
1410
|
path: routePath,
|
|
1037
1411
|
operationId,
|
|
1038
1412
|
handler,
|
|
1413
|
+
bodyLimit: options.bodyLimit ?? MAX_REQUEST_BODY_BYTES,
|
|
1414
|
+
requireJson: Boolean(options.requireJson),
|
|
1039
1415
|
pattern: new RegExp(
|
|
1040
1416
|
`^${routePath
|
|
1041
1417
|
.split('/')
|
|
@@ -1071,12 +1447,12 @@ export const ROUTES = [
|
|
|
1071
1447
|
route('GET', '/api/v1/tasks/{slug}', 'getTask', (context) => ({
|
|
1072
1448
|
json: getTaskDetail(context.db(), context.params.slug),
|
|
1073
1449
|
})),
|
|
1074
|
-
route('DELETE', '/api/v1/tasks/{slug}', 'deleteTask', (context) => {
|
|
1450
|
+
route('DELETE', '/api/v1/tasks/{slug}', 'deleteTask', async (context) => {
|
|
1075
1451
|
// The kill switch answers before any read or child spawn; the existence
|
|
1076
1452
|
// pre-read fast-fails an unknown slug through the read-only handle.
|
|
1077
1453
|
if (isKillSwitchSet()) fail('E_DISABLED', 503, 'the projection is disabled by AI_RULES_TEAM_DB_DISABLE');
|
|
1078
1454
|
requireTask(context.db(), context.params.slug);
|
|
1079
|
-
return { json: runDeleteChild(context.params.slug, context
|
|
1455
|
+
return { json: await runDeleteChild(context.params.slug, context) };
|
|
1080
1456
|
}),
|
|
1081
1457
|
taskRoute('getTaskPipeline', { path: 'pipeline', handler: getPipeline }),
|
|
1082
1458
|
taskRoute('listTaskAttempts', { path: 'attempts', handler: listAttempts }),
|
|
@@ -1091,7 +1467,47 @@ export const ROUTES = [
|
|
|
1091
1467
|
taskRoute('exportTask', { path: 'export', handler: exportTask }),
|
|
1092
1468
|
route('GET', '/api/v1/stats', 'getStats', (context) => ({ json: getStats(context.db(), context.query) })),
|
|
1093
1469
|
route('GET', '/api/v1/sync-runs', 'listSyncRuns', (context) => ({ json: listSyncRuns(context.db(), context.query) })),
|
|
1094
|
-
route('POST', '/api/v1/sync', 'triggerSync', (context) =>
|
|
1470
|
+
route('POST', '/api/v1/sync', 'triggerSync', async (context) => {
|
|
1471
|
+
const text = context.body.toString('utf8').trim();
|
|
1472
|
+
if (text !== '' && text !== '{}') {
|
|
1473
|
+
fail('E_VALIDATION', 422, 'the rescan accepts no request body', { parameter: 'body' });
|
|
1474
|
+
}
|
|
1475
|
+
return { json: await runSyncChild(context) };
|
|
1476
|
+
}),
|
|
1477
|
+
// The job entries sit after every task entry and before the stats route, so
|
|
1478
|
+
// `/api/v1/jobs/{id}` can never shadow `/api/v1/jobs/{id}/runs`.
|
|
1479
|
+
route('GET', '/api/v1/jobs', 'listJobs', (context) => ({ json: listJobs(context.db(), context.settings, context.query) })),
|
|
1480
|
+
route('POST', '/api/v1/jobs', 'createJob', (context) => createOrUpdateJob(context, 'create'), {
|
|
1481
|
+
bodyLimit: JOB_BODY_MAX,
|
|
1482
|
+
requireJson: true,
|
|
1483
|
+
}),
|
|
1484
|
+
route('GET', '/api/v1/jobs/{id}', 'getJob', (context) => {
|
|
1485
|
+
const row = requireJobRow(context.db(), parseJobId(context.params.id));
|
|
1486
|
+
return { json: jobDetail(context.db(), context.settings, row, Date.now()) };
|
|
1487
|
+
}),
|
|
1488
|
+
route('PUT', '/api/v1/jobs/{id}', 'updateJob', (context) => createOrUpdateJob(context, 'update'), {
|
|
1489
|
+
bodyLimit: JOB_BODY_MAX,
|
|
1490
|
+
requireJson: true,
|
|
1491
|
+
}),
|
|
1492
|
+
route('DELETE', '/api/v1/jobs/{id}', 'deleteJob', (context) => deleteJob(context), { bodyLimit: MAX_REQUEST_BODY_BYTES }),
|
|
1493
|
+
route('GET', '/api/v1/jobs/{id}/runs', 'listJobRuns', (context) => ({
|
|
1494
|
+
json: listJobRuns(context.db(), parseJobId(context.params.id), context.query),
|
|
1495
|
+
})),
|
|
1496
|
+
route('GET', '/api/v1/jobs/{id}/runs/{runId}', 'getJobRun', (context) => ({
|
|
1497
|
+
json: getJobRun(context.db(), parseJobId(context.params.id), parseRunId(context.params.runId)),
|
|
1498
|
+
})),
|
|
1499
|
+
route('GET', '/api/v1/jobs/{id}/runs/{runId}/log', 'getJobRunLog', (context) => ({
|
|
1500
|
+
json: getJobRunLog(
|
|
1501
|
+
context.db(),
|
|
1502
|
+
context.settings,
|
|
1503
|
+
parseJobId(context.params.id),
|
|
1504
|
+
parseRunId(context.params.runId),
|
|
1505
|
+
context.query,
|
|
1506
|
+
),
|
|
1507
|
+
})),
|
|
1508
|
+
route('POST', '/api/v1/jobs/{id}/run', 'runJobNow', (context) => runJobNow(context), {
|
|
1509
|
+
bodyLimit: MAX_REQUEST_BODY_BYTES,
|
|
1510
|
+
}),
|
|
1095
1511
|
];
|
|
1096
1512
|
|
|
1097
1513
|
/** The documented `METHOD path` pairs, for the contract gate's route parity. */
|
|
@@ -1230,12 +1646,18 @@ const handle = async (req, res, settings) => {
|
|
|
1230
1646
|
return;
|
|
1231
1647
|
}
|
|
1232
1648
|
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1649
|
+
// Every method that may carry a body drains it against the route's own
|
|
1650
|
+
// bound; the rescan keeps its "no body" semantics in its handler.
|
|
1651
|
+
const body = ['POST', 'PUT', 'DELETE'].includes(entry.method)
|
|
1652
|
+
? await readBody(req, entry.bodyLimit)
|
|
1653
|
+
: Buffer.alloc(0);
|
|
1654
|
+
if (entry.requireJson && body.length > 0) {
|
|
1655
|
+
const contentType = String(req.headers['content-type'] ?? '').toLowerCase();
|
|
1656
|
+
if (!contentType.startsWith('application/json')) {
|
|
1657
|
+
// The closed code table maps `E_VALIDATION` to 422 only: a media-type
|
|
1658
|
+
// refusal is a validation answer, never an undocumented 415.
|
|
1237
1659
|
sendJson(req, res, 422, {
|
|
1238
|
-
error: { code: 'E_VALIDATION', message: '
|
|
1660
|
+
error: { code: 'E_VALIDATION', message: 'job bodies require application/json', details: { parameter: 'content-type' } },
|
|
1239
1661
|
});
|
|
1240
1662
|
return;
|
|
1241
1663
|
}
|
|
@@ -1264,7 +1686,14 @@ const handle = async (req, res, settings) => {
|
|
|
1264
1686
|
};
|
|
1265
1687
|
const dbOnce = () => handleOnce().db;
|
|
1266
1688
|
try {
|
|
1267
|
-
const result = entry.handler({
|
|
1689
|
+
const result = await entry.handler({
|
|
1690
|
+
settings,
|
|
1691
|
+
params,
|
|
1692
|
+
query: url.searchParams,
|
|
1693
|
+
body,
|
|
1694
|
+
db: dbOnce,
|
|
1695
|
+
handle: handleOnce,
|
|
1696
|
+
});
|
|
1268
1697
|
if (result.json !== undefined) {
|
|
1269
1698
|
sendJson(req, res, 200, result.json);
|
|
1270
1699
|
return;
|