@josstei/maestro 1.6.4-rc.1
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/.agents/plugins/marketplace.json +20 -0
- package/CHANGELOG.md +485 -0
- package/EXAMPLES.md +255 -0
- package/GEMINI.md +231 -0
- package/LICENSE +201 -0
- package/QWEN.md +241 -0
- package/README.md +220 -0
- package/agents/accessibility_specialist.md +20 -0
- package/agents/analytics_engineer.md +22 -0
- package/agents/api_designer.md +19 -0
- package/agents/architect.md +19 -0
- package/agents/cloud_architect.md +19 -0
- package/agents/cobol_engineer.md +22 -0
- package/agents/code_reviewer.md +17 -0
- package/agents/coder.md +22 -0
- package/agents/compliance_reviewer.md +19 -0
- package/agents/content_strategist.md +19 -0
- package/agents/copywriter.md +19 -0
- package/agents/data_engineer.md +22 -0
- package/agents/database_administrator.md +21 -0
- package/agents/db2_dba.md +21 -0
- package/agents/debugger.md +19 -0
- package/agents/design_system_engineer.md +22 -0
- package/agents/devops_engineer.md +23 -0
- package/agents/hlasm_assembler_specialist.md +22 -0
- package/agents/i18n_specialist.md +21 -0
- package/agents/ibm_i_specialist.md +22 -0
- package/agents/integration_engineer.md +23 -0
- package/agents/ml_engineer.md +23 -0
- package/agents/mlops_engineer.md +23 -0
- package/agents/mobile_engineer.md +23 -0
- package/agents/observability_engineer.md +23 -0
- package/agents/performance_engineer.md +21 -0
- package/agents/platform_engineer.md +24 -0
- package/agents/product_manager.md +20 -0
- package/agents/prompt_engineer.md +22 -0
- package/agents/refactor.md +22 -0
- package/agents/release_manager.md +22 -0
- package/agents/security_engineer.md +21 -0
- package/agents/seo_specialist.md +21 -0
- package/agents/site_reliability_engineer.md +21 -0
- package/agents/solutions_architect.md +19 -0
- package/agents/technical_writer.md +21 -0
- package/agents/tester.md +23 -0
- package/agents/ux_designer.md +20 -0
- package/agents/zos_sysprog.md +21 -0
- package/bin/maestro-mcp-server.js +10 -0
- package/claude/.claude-plugin/plugin.json +21 -0
- package/claude/.mcp.json +11 -0
- package/claude/README.md +191 -0
- package/claude/agents/accessibility-specialist.md +36 -0
- package/claude/agents/analytics-engineer.md +38 -0
- package/claude/agents/api-designer.md +33 -0
- package/claude/agents/architect.md +33 -0
- package/claude/agents/cloud-architect.md +33 -0
- package/claude/agents/cobol-engineer.md +38 -0
- package/claude/agents/code-reviewer.md +31 -0
- package/claude/agents/coder.md +38 -0
- package/claude/agents/compliance-reviewer.md +33 -0
- package/claude/agents/content-strategist.md +33 -0
- package/claude/agents/copywriter.md +33 -0
- package/claude/agents/data-engineer.md +37 -0
- package/claude/agents/database-administrator.md +37 -0
- package/claude/agents/db2-dba.md +37 -0
- package/claude/agents/debugger.md +32 -0
- package/claude/agents/design-system-engineer.md +38 -0
- package/claude/agents/devops-engineer.md +39 -0
- package/claude/agents/hlasm-assembler-specialist.md +38 -0
- package/claude/agents/i18n-specialist.md +37 -0
- package/claude/agents/ibm-i-specialist.md +38 -0
- package/claude/agents/integration-engineer.md +39 -0
- package/claude/agents/ml-engineer.md +39 -0
- package/claude/agents/mlops-engineer.md +39 -0
- package/claude/agents/mobile-engineer.md +39 -0
- package/claude/agents/observability-engineer.md +39 -0
- package/claude/agents/performance-engineer.md +34 -0
- package/claude/agents/platform-engineer.md +40 -0
- package/claude/agents/product-manager.md +34 -0
- package/claude/agents/prompt-engineer.md +38 -0
- package/claude/agents/refactor.md +38 -0
- package/claude/agents/release-manager.md +38 -0
- package/claude/agents/security-engineer.md +37 -0
- package/claude/agents/seo-specialist.md +37 -0
- package/claude/agents/site-reliability-engineer.md +37 -0
- package/claude/agents/solutions-architect.md +33 -0
- package/claude/agents/technical-writer.md +37 -0
- package/claude/agents/tester.md +39 -0
- package/claude/agents/ux-designer.md +34 -0
- package/claude/agents/zos-sysprog.md +37 -0
- package/claude/hooks/claude-hooks.json +48 -0
- package/claude/mcp/maestro-server.js +9 -0
- package/claude/mcp-config.example.json +9 -0
- package/claude/scripts/adapters/claude-adapter.js +7 -0
- package/claude/scripts/hook-runner.js +8 -0
- package/claude/scripts/policy-enforcer.js +294 -0
- package/claude/skills/a11y-audit/SKILL.md +26 -0
- package/claude/skills/archive/SKILL.md +24 -0
- package/claude/skills/code-review/SKILL.md +7 -0
- package/claude/skills/compliance-check/SKILL.md +26 -0
- package/claude/skills/debug-workflow/SKILL.md +27 -0
- package/claude/skills/delegation/SKILL.md +7 -0
- package/claude/skills/design-dialogue/SKILL.md +7 -0
- package/claude/skills/execute/SKILL.md +38 -0
- package/claude/skills/execution/SKILL.md +7 -0
- package/claude/skills/implementation-planning/SKILL.md +7 -0
- package/claude/skills/orchestrate/SKILL.md +38 -0
- package/claude/skills/perf-check/SKILL.md +26 -0
- package/claude/skills/resume-session/SKILL.md +38 -0
- package/claude/skills/review-code/SKILL.md +27 -0
- package/claude/skills/security-audit/SKILL.md +28 -0
- package/claude/skills/seo-audit/SKILL.md +26 -0
- package/claude/skills/session-management/SKILL.md +7 -0
- package/claude/skills/status/SKILL.md +22 -0
- package/claude/skills/validation/SKILL.md +7 -0
- package/claude/src/agents/accessibility-specialist.md +163 -0
- package/claude/src/agents/analytics-engineer.md +182 -0
- package/claude/src/agents/api-designer.md +124 -0
- package/claude/src/agents/architect.md +120 -0
- package/claude/src/agents/cloud-architect.md +134 -0
- package/claude/src/agents/cobol-engineer.md +127 -0
- package/claude/src/agents/code-reviewer.md +123 -0
- package/claude/src/agents/coder.md +132 -0
- package/claude/src/agents/compliance-reviewer.md +219 -0
- package/claude/src/agents/content-strategist.md +111 -0
- package/claude/src/agents/copywriter.md +113 -0
- package/claude/src/agents/data-engineer.md +130 -0
- package/claude/src/agents/database-administrator.md +126 -0
- package/claude/src/agents/db2-dba.md +124 -0
- package/claude/src/agents/debugger.md +133 -0
- package/claude/src/agents/design-system-engineer.md +258 -0
- package/claude/src/agents/devops-engineer.md +138 -0
- package/claude/src/agents/hlasm-assembler-specialist.md +134 -0
- package/claude/src/agents/i18n-specialist.md +241 -0
- package/claude/src/agents/ibm-i-specialist.md +132 -0
- package/claude/src/agents/integration-engineer.md +133 -0
- package/claude/src/agents/ml-engineer.md +115 -0
- package/claude/src/agents/mlops-engineer.md +116 -0
- package/claude/src/agents/mobile-engineer.md +115 -0
- package/claude/src/agents/observability-engineer.md +133 -0
- package/claude/src/agents/performance-engineer.md +139 -0
- package/claude/src/agents/platform-engineer.md +129 -0
- package/claude/src/agents/product-manager.md +170 -0
- package/claude/src/agents/prompt-engineer.md +129 -0
- package/claude/src/agents/refactor.md +138 -0
- package/claude/src/agents/release-manager.md +132 -0
- package/claude/src/agents/security-engineer.md +143 -0
- package/claude/src/agents/seo-specialist.md +129 -0
- package/claude/src/agents/site-reliability-engineer.md +131 -0
- package/claude/src/agents/solutions-architect.md +137 -0
- package/claude/src/agents/technical-writer.md +129 -0
- package/claude/src/agents/tester.md +135 -0
- package/claude/src/agents/ux-designer.md +168 -0
- package/claude/src/agents/zos-sysprog.md +134 -0
- package/claude/src/config/setting-resolver.js +32 -0
- package/claude/src/core/agent-registry.js +67 -0
- package/claude/src/core/canonical-source.js +39 -0
- package/claude/src/core/env-file-parser.js +82 -0
- package/claude/src/core/feature-blocks.js +34 -0
- package/claude/src/core/logger.js +12 -0
- package/claude/src/core/markdown-state.js +36 -0
- package/claude/src/core/policy-rules.js +32 -0
- package/claude/src/core/project-root-resolver.js +184 -0
- package/claude/src/core/stdin-reader.js +77 -0
- package/claude/src/core/version.js +50 -0
- package/claude/src/entry-points/core-command-registry.js +37 -0
- package/claude/src/entry-points/preamble-builders.js +54 -0
- package/claude/src/entry-points/registry.js +199 -0
- package/claude/src/entry-points/templates/claude-core-command.md.tmpl +38 -0
- package/claude/src/entry-points/templates/claude-skill.md.tmpl +18 -0
- package/claude/src/entry-points/templates/codex-core-command.md.tmpl +16 -0
- package/claude/src/entry-points/templates/codex-skill.md.tmpl +11 -0
- package/claude/src/entry-points/templates/gemini-command.toml.tmpl +17 -0
- package/claude/src/entry-points/templates/gemini-core-command.toml.tmpl +30 -0
- package/claude/src/generated/agent-registry.json +630 -0
- package/claude/src/generated/hook-registry.json +18 -0
- package/claude/src/generated/resource-registry.json +16 -0
- package/claude/src/hooks/logic/after-agent-logic.js +54 -0
- package/claude/src/hooks/logic/before-agent-logic.js +57 -0
- package/claude/src/hooks/logic/hook-state.js +127 -0
- package/claude/src/hooks/logic/session-end-logic.js +17 -0
- package/claude/src/hooks/logic/session-start-logic.js +25 -0
- package/claude/src/lib/discovery/index.js +172 -0
- package/claude/src/lib/errors/index.js +104 -0
- package/claude/src/lib/framework-detection.js +50 -0
- package/claude/src/lib/frontmatter/index.js +262 -0
- package/claude/src/lib/io/index.js +96 -0
- package/claude/src/lib/naming/index.js +94 -0
- package/claude/src/lib/validation/index.js +124 -0
- package/claude/src/lib/yaml-emit.js +38 -0
- package/claude/src/mcp/content/provider.js +68 -0
- package/claude/src/mcp/content/runtime-content.js +188 -0
- package/claude/src/mcp/contracts/cache-path-rejector.js +39 -0
- package/claude/src/mcp/contracts/downstream-context.js +106 -0
- package/claude/src/mcp/contracts/plan-schema.js +148 -0
- package/claude/src/mcp/contracts/workspace-marker.js +61 -0
- package/claude/src/mcp/core/create-server.js +76 -0
- package/claude/src/mcp/core/line-reader.js +35 -0
- package/claude/src/mcp/core/project-root-cache.js +120 -0
- package/claude/src/mcp/core/protocol-dispatcher.js +274 -0
- package/claude/src/mcp/core/recovery-hints.js +43 -0
- package/claude/src/mcp/core/tool-outcome.js +77 -0
- package/claude/src/mcp/core/tool-registry.js +82 -0
- package/claude/src/mcp/handlers/assess-task-complexity.js +108 -0
- package/claude/src/mcp/handlers/blocker-parser.js +34 -0
- package/claude/src/mcp/handlers/design-gate.js +393 -0
- package/claude/src/mcp/handlers/get-agent.js +54 -0
- package/claude/src/mcp/handlers/get-runtime-context.js +49 -0
- package/claude/src/mcp/handlers/get-skill-content.js +51 -0
- package/claude/src/mcp/handlers/initialize-workspace.js +45 -0
- package/claude/src/mcp/handlers/reconciliation.js +224 -0
- package/claude/src/mcp/handlers/resolve-settings.js +39 -0
- package/claude/src/mcp/handlers/session-state-core.js +108 -0
- package/claude/src/mcp/handlers/session-state-tools.js +562 -0
- package/claude/src/mcp/handlers/validate-plan.js +76 -0
- package/claude/src/mcp/maestro-server.js +122 -0
- package/claude/src/mcp/runtime/runtime-config-map.js +70 -0
- package/claude/src/mcp/tool-packs/content/index.js +80 -0
- package/claude/src/mcp/tool-packs/contracts.js +30 -0
- package/claude/src/mcp/tool-packs/index.js +15 -0
- package/claude/src/mcp/tool-packs/session/index.js +243 -0
- package/claude/src/mcp/tool-packs/workspace/index.js +98 -0
- package/claude/src/mcp/utils/extension-root.js +31 -0
- package/claude/src/mcp/validation/agent-checker.js +81 -0
- package/claude/src/mcp/validation/dag-checker.js +214 -0
- package/claude/src/mcp/validation/file-overlap-checker.js +63 -0
- package/claude/src/mcp/validation/schema-checker.js +108 -0
- package/claude/src/platforms/claude/runtime-config.js +60 -0
- package/claude/src/platforms/shared/adapters/claude-adapter.js +36 -0
- package/claude/src/platforms/shared/adapters/conventions.js +29 -0
- package/claude/src/platforms/shared/adapters/exit-codes.js +6 -0
- package/claude/src/platforms/shared/adapters/factory.js +40 -0
- package/claude/src/platforms/shared/agent-names.js +10 -0
- package/claude/src/platforms/shared/hook-runner.js +52 -0
- package/claude/src/references/architecture.md +139 -0
- package/claude/src/references/orchestration-steps.md +193 -0
- package/claude/src/skills/shared/code-review/SKILL.md +145 -0
- package/claude/src/skills/shared/delegation/SKILL.md +370 -0
- package/claude/src/skills/shared/delegation/protocols/agent-base-protocol.md +145 -0
- package/claude/src/skills/shared/delegation/protocols/filesystem-safety-protocol.md +31 -0
- package/claude/src/skills/shared/design-dialogue/SKILL.md +284 -0
- package/claude/src/skills/shared/execution/SKILL.md +258 -0
- package/claude/src/skills/shared/implementation-planning/SKILL.md +303 -0
- package/claude/src/skills/shared/session-management/SKILL.md +314 -0
- package/claude/src/skills/shared/validation/SKILL.md +204 -0
- package/claude/src/state/session-state.js +113 -0
- package/claude/src/templates/design-document.md +95 -0
- package/claude/src/templates/implementation-plan.md +86 -0
- package/claude/src/templates/session-state.md +68 -0
- package/claude/src/version.json +3 -0
- package/commands/maestro/a11y-audit.toml +22 -0
- package/commands/maestro/archive.toml +23 -0
- package/commands/maestro/compliance-check.toml +22 -0
- package/commands/maestro/debug.toml +23 -0
- package/commands/maestro/execute.toml +30 -0
- package/commands/maestro/orchestrate.toml +30 -0
- package/commands/maestro/perf-check.toml +22 -0
- package/commands/maestro/resume.toml +38 -0
- package/commands/maestro/review.toml +23 -0
- package/commands/maestro/security-audit.toml +24 -0
- package/commands/maestro/seo-audit.toml +22 -0
- package/commands/maestro/status.toml +21 -0
- package/docs/architecture.md +310 -0
- package/docs/cicd.md +647 -0
- package/docs/flow.md +255 -0
- package/docs/maestro-cheatsheet.md +199 -0
- package/docs/overview.md +141 -0
- package/docs/runtime-claude.md +190 -0
- package/docs/runtime-codex.md +197 -0
- package/docs/runtime-gemini.md +170 -0
- package/docs/runtime-qwen.md +147 -0
- package/docs/usage.md +312 -0
- package/gemini-extension.json +55 -0
- package/hooks/adapters/gemini-adapter.js +2 -0
- package/hooks/adapters/qwen-adapter.js +2 -0
- package/hooks/hook-runner.js +3 -0
- package/hooks/hooks.json +56 -0
- package/mcp/maestro-server.js +4 -0
- package/package.json +93 -0
- package/plugins/maestro/.app.json +3 -0
- package/plugins/maestro/.codex-plugin/plugin.json +41 -0
- package/plugins/maestro/.mcp.json +16 -0
- package/plugins/maestro/README.md +57 -0
- package/plugins/maestro/references/runtime-guide.md +125 -0
- package/plugins/maestro/skills/a11y-audit/SKILL.md +16 -0
- package/plugins/maestro/skills/archive/SKILL.md +16 -0
- package/plugins/maestro/skills/code-review/SKILL.md +6 -0
- package/plugins/maestro/skills/compliance-check/SKILL.md +16 -0
- package/plugins/maestro/skills/debug-workflow/SKILL.md +16 -0
- package/plugins/maestro/skills/delegation/SKILL.md +6 -0
- package/plugins/maestro/skills/design-dialogue/SKILL.md +6 -0
- package/plugins/maestro/skills/execute/SKILL.md +16 -0
- package/plugins/maestro/skills/execution/SKILL.md +6 -0
- package/plugins/maestro/skills/implementation-planning/SKILL.md +6 -0
- package/plugins/maestro/skills/orchestrate/SKILL.md +16 -0
- package/plugins/maestro/skills/perf-check/SKILL.md +16 -0
- package/plugins/maestro/skills/resume-session/SKILL.md +16 -0
- package/plugins/maestro/skills/review-code/SKILL.md +16 -0
- package/plugins/maestro/skills/security-audit/SKILL.md +16 -0
- package/plugins/maestro/skills/seo-audit/SKILL.md +16 -0
- package/plugins/maestro/skills/session-management/SKILL.md +6 -0
- package/plugins/maestro/skills/status/SKILL.md +14 -0
- package/plugins/maestro/skills/validation/SKILL.md +6 -0
- package/plugins/maestro/src/agents/accessibility-specialist.md +163 -0
- package/plugins/maestro/src/agents/analytics-engineer.md +182 -0
- package/plugins/maestro/src/agents/api-designer.md +124 -0
- package/plugins/maestro/src/agents/architect.md +120 -0
- package/plugins/maestro/src/agents/cloud-architect.md +134 -0
- package/plugins/maestro/src/agents/cobol-engineer.md +127 -0
- package/plugins/maestro/src/agents/code-reviewer.md +123 -0
- package/plugins/maestro/src/agents/coder.md +132 -0
- package/plugins/maestro/src/agents/compliance-reviewer.md +219 -0
- package/plugins/maestro/src/agents/content-strategist.md +111 -0
- package/plugins/maestro/src/agents/copywriter.md +113 -0
- package/plugins/maestro/src/agents/data-engineer.md +130 -0
- package/plugins/maestro/src/agents/database-administrator.md +126 -0
- package/plugins/maestro/src/agents/db2-dba.md +124 -0
- package/plugins/maestro/src/agents/debugger.md +133 -0
- package/plugins/maestro/src/agents/design-system-engineer.md +258 -0
- package/plugins/maestro/src/agents/devops-engineer.md +138 -0
- package/plugins/maestro/src/agents/hlasm-assembler-specialist.md +134 -0
- package/plugins/maestro/src/agents/i18n-specialist.md +241 -0
- package/plugins/maestro/src/agents/ibm-i-specialist.md +132 -0
- package/plugins/maestro/src/agents/integration-engineer.md +133 -0
- package/plugins/maestro/src/agents/ml-engineer.md +115 -0
- package/plugins/maestro/src/agents/mlops-engineer.md +116 -0
- package/plugins/maestro/src/agents/mobile-engineer.md +115 -0
- package/plugins/maestro/src/agents/observability-engineer.md +133 -0
- package/plugins/maestro/src/agents/performance-engineer.md +139 -0
- package/plugins/maestro/src/agents/platform-engineer.md +129 -0
- package/plugins/maestro/src/agents/product-manager.md +170 -0
- package/plugins/maestro/src/agents/prompt-engineer.md +129 -0
- package/plugins/maestro/src/agents/refactor.md +138 -0
- package/plugins/maestro/src/agents/release-manager.md +132 -0
- package/plugins/maestro/src/agents/security-engineer.md +143 -0
- package/plugins/maestro/src/agents/seo-specialist.md +129 -0
- package/plugins/maestro/src/agents/site-reliability-engineer.md +131 -0
- package/plugins/maestro/src/agents/solutions-architect.md +137 -0
- package/plugins/maestro/src/agents/technical-writer.md +129 -0
- package/plugins/maestro/src/agents/tester.md +135 -0
- package/plugins/maestro/src/agents/ux-designer.md +168 -0
- package/plugins/maestro/src/agents/zos-sysprog.md +134 -0
- package/plugins/maestro/src/config/setting-resolver.js +32 -0
- package/plugins/maestro/src/core/agent-registry.js +67 -0
- package/plugins/maestro/src/core/canonical-source.js +39 -0
- package/plugins/maestro/src/core/env-file-parser.js +82 -0
- package/plugins/maestro/src/core/feature-blocks.js +34 -0
- package/plugins/maestro/src/core/logger.js +12 -0
- package/plugins/maestro/src/core/markdown-state.js +36 -0
- package/plugins/maestro/src/core/policy-rules.js +32 -0
- package/plugins/maestro/src/core/project-root-resolver.js +184 -0
- package/plugins/maestro/src/core/stdin-reader.js +77 -0
- package/plugins/maestro/src/core/version.js +50 -0
- package/plugins/maestro/src/entry-points/core-command-registry.js +37 -0
- package/plugins/maestro/src/entry-points/preamble-builders.js +54 -0
- package/plugins/maestro/src/entry-points/registry.js +199 -0
- package/plugins/maestro/src/entry-points/templates/claude-core-command.md.tmpl +38 -0
- package/plugins/maestro/src/entry-points/templates/claude-skill.md.tmpl +18 -0
- package/plugins/maestro/src/entry-points/templates/codex-core-command.md.tmpl +16 -0
- package/plugins/maestro/src/entry-points/templates/codex-skill.md.tmpl +11 -0
- package/plugins/maestro/src/entry-points/templates/gemini-command.toml.tmpl +17 -0
- package/plugins/maestro/src/entry-points/templates/gemini-core-command.toml.tmpl +30 -0
- package/plugins/maestro/src/generated/agent-registry.json +630 -0
- package/plugins/maestro/src/generated/hook-registry.json +18 -0
- package/plugins/maestro/src/generated/resource-registry.json +16 -0
- package/plugins/maestro/src/hooks/logic/after-agent-logic.js +54 -0
- package/plugins/maestro/src/hooks/logic/before-agent-logic.js +57 -0
- package/plugins/maestro/src/hooks/logic/hook-state.js +127 -0
- package/plugins/maestro/src/hooks/logic/session-end-logic.js +17 -0
- package/plugins/maestro/src/hooks/logic/session-start-logic.js +25 -0
- package/plugins/maestro/src/lib/discovery/index.js +172 -0
- package/plugins/maestro/src/lib/errors/index.js +104 -0
- package/plugins/maestro/src/lib/framework-detection.js +50 -0
- package/plugins/maestro/src/lib/frontmatter/index.js +262 -0
- package/plugins/maestro/src/lib/io/index.js +96 -0
- package/plugins/maestro/src/lib/naming/index.js +94 -0
- package/plugins/maestro/src/lib/validation/index.js +124 -0
- package/plugins/maestro/src/lib/yaml-emit.js +38 -0
- package/plugins/maestro/src/mcp/content/provider.js +68 -0
- package/plugins/maestro/src/mcp/content/runtime-content.js +188 -0
- package/plugins/maestro/src/mcp/contracts/cache-path-rejector.js +39 -0
- package/plugins/maestro/src/mcp/contracts/downstream-context.js +106 -0
- package/plugins/maestro/src/mcp/contracts/plan-schema.js +148 -0
- package/plugins/maestro/src/mcp/contracts/workspace-marker.js +61 -0
- package/plugins/maestro/src/mcp/core/create-server.js +76 -0
- package/plugins/maestro/src/mcp/core/line-reader.js +35 -0
- package/plugins/maestro/src/mcp/core/project-root-cache.js +120 -0
- package/plugins/maestro/src/mcp/core/protocol-dispatcher.js +274 -0
- package/plugins/maestro/src/mcp/core/recovery-hints.js +43 -0
- package/plugins/maestro/src/mcp/core/tool-outcome.js +77 -0
- package/plugins/maestro/src/mcp/core/tool-registry.js +82 -0
- package/plugins/maestro/src/mcp/handlers/assess-task-complexity.js +108 -0
- package/plugins/maestro/src/mcp/handlers/blocker-parser.js +34 -0
- package/plugins/maestro/src/mcp/handlers/design-gate.js +393 -0
- package/plugins/maestro/src/mcp/handlers/get-agent.js +54 -0
- package/plugins/maestro/src/mcp/handlers/get-runtime-context.js +49 -0
- package/plugins/maestro/src/mcp/handlers/get-skill-content.js +51 -0
- package/plugins/maestro/src/mcp/handlers/initialize-workspace.js +45 -0
- package/plugins/maestro/src/mcp/handlers/reconciliation.js +224 -0
- package/plugins/maestro/src/mcp/handlers/resolve-settings.js +39 -0
- package/plugins/maestro/src/mcp/handlers/session-state-core.js +108 -0
- package/plugins/maestro/src/mcp/handlers/session-state-tools.js +562 -0
- package/plugins/maestro/src/mcp/handlers/validate-plan.js +76 -0
- package/plugins/maestro/src/mcp/maestro-server.js +122 -0
- package/plugins/maestro/src/mcp/runtime/runtime-config-map.js +70 -0
- package/plugins/maestro/src/mcp/tool-packs/content/index.js +80 -0
- package/plugins/maestro/src/mcp/tool-packs/contracts.js +30 -0
- package/plugins/maestro/src/mcp/tool-packs/index.js +15 -0
- package/plugins/maestro/src/mcp/tool-packs/session/index.js +243 -0
- package/plugins/maestro/src/mcp/tool-packs/workspace/index.js +98 -0
- package/plugins/maestro/src/mcp/utils/extension-root.js +31 -0
- package/plugins/maestro/src/mcp/validation/agent-checker.js +81 -0
- package/plugins/maestro/src/mcp/validation/dag-checker.js +214 -0
- package/plugins/maestro/src/mcp/validation/file-overlap-checker.js +63 -0
- package/plugins/maestro/src/mcp/validation/schema-checker.js +108 -0
- package/plugins/maestro/src/platforms/codex/runtime-config.js +58 -0
- package/plugins/maestro/src/platforms/shared/adapters/conventions.js +29 -0
- package/plugins/maestro/src/platforms/shared/adapters/exit-codes.js +6 -0
- package/plugins/maestro/src/platforms/shared/adapters/factory.js +40 -0
- package/plugins/maestro/src/platforms/shared/agent-names.js +10 -0
- package/plugins/maestro/src/platforms/shared/hook-runner.js +52 -0
- package/plugins/maestro/src/references/architecture.md +139 -0
- package/plugins/maestro/src/references/orchestration-steps.md +193 -0
- package/plugins/maestro/src/skills/shared/code-review/SKILL.md +145 -0
- package/plugins/maestro/src/skills/shared/delegation/SKILL.md +370 -0
- package/plugins/maestro/src/skills/shared/delegation/protocols/agent-base-protocol.md +145 -0
- package/plugins/maestro/src/skills/shared/delegation/protocols/filesystem-safety-protocol.md +31 -0
- package/plugins/maestro/src/skills/shared/design-dialogue/SKILL.md +284 -0
- package/plugins/maestro/src/skills/shared/execution/SKILL.md +258 -0
- package/plugins/maestro/src/skills/shared/implementation-planning/SKILL.md +303 -0
- package/plugins/maestro/src/skills/shared/session-management/SKILL.md +314 -0
- package/plugins/maestro/src/skills/shared/validation/SKILL.md +204 -0
- package/plugins/maestro/src/state/session-state.js +113 -0
- package/plugins/maestro/src/templates/design-document.md +95 -0
- package/plugins/maestro/src/templates/implementation-plan.md +86 -0
- package/plugins/maestro/src/templates/session-state.md +68 -0
- package/plugins/maestro/src/version.json +3 -0
- package/policies/maestro.toml +44 -0
- package/qwen/agents/accessibility_specialist.md +18 -0
- package/qwen/agents/analytics_engineer.md +20 -0
- package/qwen/agents/api_designer.md +17 -0
- package/qwen/agents/architect.md +17 -0
- package/qwen/agents/cloud_architect.md +17 -0
- package/qwen/agents/cobol_engineer.md +20 -0
- package/qwen/agents/code_reviewer.md +15 -0
- package/qwen/agents/coder.md +20 -0
- package/qwen/agents/compliance_reviewer.md +17 -0
- package/qwen/agents/content_strategist.md +17 -0
- package/qwen/agents/copywriter.md +17 -0
- package/qwen/agents/data_engineer.md +20 -0
- package/qwen/agents/database_administrator.md +19 -0
- package/qwen/agents/db2_dba.md +19 -0
- package/qwen/agents/debugger.md +17 -0
- package/qwen/agents/design_system_engineer.md +20 -0
- package/qwen/agents/devops_engineer.md +21 -0
- package/qwen/agents/hlasm_assembler_specialist.md +20 -0
- package/qwen/agents/i18n_specialist.md +19 -0
- package/qwen/agents/ibm_i_specialist.md +20 -0
- package/qwen/agents/integration_engineer.md +21 -0
- package/qwen/agents/ml_engineer.md +21 -0
- package/qwen/agents/mlops_engineer.md +21 -0
- package/qwen/agents/mobile_engineer.md +21 -0
- package/qwen/agents/observability_engineer.md +21 -0
- package/qwen/agents/performance_engineer.md +19 -0
- package/qwen/agents/platform_engineer.md +22 -0
- package/qwen/agents/product_manager.md +18 -0
- package/qwen/agents/prompt_engineer.md +20 -0
- package/qwen/agents/refactor.md +20 -0
- package/qwen/agents/release_manager.md +20 -0
- package/qwen/agents/security_engineer.md +19 -0
- package/qwen/agents/seo_specialist.md +19 -0
- package/qwen/agents/site_reliability_engineer.md +19 -0
- package/qwen/agents/solutions_architect.md +17 -0
- package/qwen/agents/technical_writer.md +19 -0
- package/qwen/agents/tester.md +21 -0
- package/qwen/agents/ux_designer.md +18 -0
- package/qwen/agents/zos_sysprog.md +19 -0
- package/qwen/hooks.json +56 -0
- package/qwen-extension.json +55 -0
- package/scripts/check-layer-boundaries.js +74 -0
- package/scripts/generate.js +155 -0
- package/scripts/install-codex-plugin.js +167 -0
- package/scripts/install-git-hooks.js +43 -0
- package/scripts/npm-publish-idempotent.js +150 -0
- package/scripts/package-release-artifacts.js +156 -0
- package/scripts/release-artifact-manifest.js +378 -0
- package/scripts/release-version-metadata.js +129 -0
- package/scripts/update-versions.js +33 -0
- package/scripts/verify-npm-pack.js +85 -0
- package/scripts/verify-release-artifacts.js +95 -0
- package/src/agents/accessibility-specialist.md +163 -0
- package/src/agents/analytics-engineer.md +182 -0
- package/src/agents/api-designer.md +124 -0
- package/src/agents/architect.md +120 -0
- package/src/agents/cloud-architect.md +134 -0
- package/src/agents/cobol-engineer.md +127 -0
- package/src/agents/code-reviewer.md +123 -0
- package/src/agents/coder.md +132 -0
- package/src/agents/compliance-reviewer.md +219 -0
- package/src/agents/content-strategist.md +111 -0
- package/src/agents/copywriter.md +113 -0
- package/src/agents/data-engineer.md +130 -0
- package/src/agents/database-administrator.md +126 -0
- package/src/agents/db2-dba.md +124 -0
- package/src/agents/debugger.md +133 -0
- package/src/agents/design-system-engineer.md +258 -0
- package/src/agents/devops-engineer.md +138 -0
- package/src/agents/hlasm-assembler-specialist.md +134 -0
- package/src/agents/i18n-specialist.md +241 -0
- package/src/agents/ibm-i-specialist.md +132 -0
- package/src/agents/integration-engineer.md +133 -0
- package/src/agents/ml-engineer.md +115 -0
- package/src/agents/mlops-engineer.md +116 -0
- package/src/agents/mobile-engineer.md +115 -0
- package/src/agents/observability-engineer.md +133 -0
- package/src/agents/performance-engineer.md +139 -0
- package/src/agents/platform-engineer.md +129 -0
- package/src/agents/product-manager.md +170 -0
- package/src/agents/prompt-engineer.md +129 -0
- package/src/agents/refactor.md +138 -0
- package/src/agents/release-manager.md +132 -0
- package/src/agents/security-engineer.md +143 -0
- package/src/agents/seo-specialist.md +129 -0
- package/src/agents/site-reliability-engineer.md +131 -0
- package/src/agents/solutions-architect.md +137 -0
- package/src/agents/technical-writer.md +129 -0
- package/src/agents/tester.md +135 -0
- package/src/agents/ux-designer.md +168 -0
- package/src/agents/zos-sysprog.md +134 -0
- package/src/config/setting-resolver.js +32 -0
- package/src/core/agent-registry.js +67 -0
- package/src/core/canonical-source.js +39 -0
- package/src/core/env-file-parser.js +82 -0
- package/src/core/feature-blocks.js +34 -0
- package/src/core/logger.js +12 -0
- package/src/core/markdown-state.js +36 -0
- package/src/core/policy-rules.js +32 -0
- package/src/core/project-root-resolver.js +184 -0
- package/src/core/stdin-reader.js +77 -0
- package/src/core/version.js +50 -0
- package/src/entry-points/core-command-registry.js +37 -0
- package/src/entry-points/preamble-builders.js +54 -0
- package/src/entry-points/registry.js +199 -0
- package/src/entry-points/templates/claude-core-command.md.tmpl +38 -0
- package/src/entry-points/templates/claude-skill.md.tmpl +18 -0
- package/src/entry-points/templates/codex-core-command.md.tmpl +16 -0
- package/src/entry-points/templates/codex-skill.md.tmpl +11 -0
- package/src/entry-points/templates/gemini-command.toml.tmpl +17 -0
- package/src/entry-points/templates/gemini-core-command.toml.tmpl +30 -0
- package/src/generated/agent-registry.json +630 -0
- package/src/generated/hook-registry.json +18 -0
- package/src/generated/resource-registry.json +16 -0
- package/src/generator/entry-point-expander.js +182 -0
- package/src/generator/file-writer.js +167 -0
- package/src/generator/generation-session.js +62 -0
- package/src/generator/manifest-curator.js +31 -0
- package/src/generator/manifest-expander.js +256 -0
- package/src/generator/payload-builder.js +217 -0
- package/src/generator/registry-scanner.js +130 -0
- package/src/generator/stale-pruner.js +101 -0
- package/src/hooks/logic/after-agent-logic.js +54 -0
- package/src/hooks/logic/before-agent-logic.js +57 -0
- package/src/hooks/logic/hook-state.js +127 -0
- package/src/hooks/logic/session-end-logic.js +17 -0
- package/src/hooks/logic/session-start-logic.js +25 -0
- package/src/lib/discovery/index.js +172 -0
- package/src/lib/errors/index.js +104 -0
- package/src/lib/framework-detection.js +50 -0
- package/src/lib/frontmatter/index.js +262 -0
- package/src/lib/io/index.js +96 -0
- package/src/lib/naming/index.js +94 -0
- package/src/lib/validation/index.js +124 -0
- package/src/lib/yaml-emit.js +38 -0
- package/src/manifest.js +11 -0
- package/src/mcp/content/provider.js +68 -0
- package/src/mcp/content/runtime-content.js +188 -0
- package/src/mcp/contracts/cache-path-rejector.js +39 -0
- package/src/mcp/contracts/downstream-context.js +106 -0
- package/src/mcp/contracts/plan-schema.js +148 -0
- package/src/mcp/contracts/workspace-marker.js +61 -0
- package/src/mcp/core/create-server.js +76 -0
- package/src/mcp/core/line-reader.js +35 -0
- package/src/mcp/core/project-root-cache.js +120 -0
- package/src/mcp/core/protocol-dispatcher.js +274 -0
- package/src/mcp/core/recovery-hints.js +43 -0
- package/src/mcp/core/tool-outcome.js +77 -0
- package/src/mcp/core/tool-registry.js +82 -0
- package/src/mcp/handlers/assess-task-complexity.js +108 -0
- package/src/mcp/handlers/blocker-parser.js +34 -0
- package/src/mcp/handlers/design-gate.js +393 -0
- package/src/mcp/handlers/get-agent.js +54 -0
- package/src/mcp/handlers/get-runtime-context.js +49 -0
- package/src/mcp/handlers/get-skill-content.js +51 -0
- package/src/mcp/handlers/initialize-workspace.js +45 -0
- package/src/mcp/handlers/reconciliation.js +224 -0
- package/src/mcp/handlers/resolve-settings.js +39 -0
- package/src/mcp/handlers/session-state-core.js +108 -0
- package/src/mcp/handlers/session-state-tools.js +562 -0
- package/src/mcp/handlers/validate-plan.js +76 -0
- package/src/mcp/maestro-server.js +122 -0
- package/src/mcp/runtime/runtime-config-map.js +70 -0
- package/src/mcp/tool-packs/content/index.js +80 -0
- package/src/mcp/tool-packs/contracts.js +30 -0
- package/src/mcp/tool-packs/index.js +15 -0
- package/src/mcp/tool-packs/session/index.js +243 -0
- package/src/mcp/tool-packs/workspace/index.js +98 -0
- package/src/mcp/utils/extension-root.js +31 -0
- package/src/mcp/validation/agent-checker.js +81 -0
- package/src/mcp/validation/dag-checker.js +214 -0
- package/src/mcp/validation/file-overlap-checker.js +63 -0
- package/src/mcp/validation/schema-checker.js +108 -0
- package/src/platforms/claude/metadata.js +96 -0
- package/src/platforms/claude/runtime-config.js +60 -0
- package/src/platforms/codex/metadata.js +107 -0
- package/src/platforms/codex/runtime-config.js +58 -0
- package/src/platforms/gemini/metadata.js +27 -0
- package/src/platforms/gemini/runtime-config.js +62 -0
- package/src/platforms/metadata-shared.js +131 -0
- package/src/platforms/metadata.js +29 -0
- package/src/platforms/qwen/metadata.js +27 -0
- package/src/platforms/qwen/runtime-config.js +62 -0
- package/src/platforms/shared/adapters/claude-adapter.js +36 -0
- package/src/platforms/shared/adapters/conventions.js +29 -0
- package/src/platforms/shared/adapters/exit-codes.js +6 -0
- package/src/platforms/shared/adapters/factory.js +40 -0
- package/src/platforms/shared/adapters/gemini-adapter.js +34 -0
- package/src/platforms/shared/adapters/qwen-adapter.js +93 -0
- package/src/platforms/shared/agent-names.js +10 -0
- package/src/platforms/shared/hook-runner.js +52 -0
- package/src/references/architecture.md +139 -0
- package/src/references/orchestration-steps.md +193 -0
- package/src/scripts/ensure-workspace.js +14 -0
- package/src/scripts/read-active-session.js +26 -0
- package/src/scripts/read-setting.js +18 -0
- package/src/scripts/read-state.js +17 -0
- package/src/scripts/write-state.js +22 -0
- package/src/skills/shared/code-review/SKILL.md +145 -0
- package/src/skills/shared/delegation/SKILL.md +370 -0
- package/src/skills/shared/delegation/protocols/agent-base-protocol.md +145 -0
- package/src/skills/shared/delegation/protocols/filesystem-safety-protocol.md +31 -0
- package/src/skills/shared/design-dialogue/SKILL.md +284 -0
- package/src/skills/shared/execution/SKILL.md +258 -0
- package/src/skills/shared/implementation-planning/SKILL.md +303 -0
- package/src/skills/shared/session-management/SKILL.md +314 -0
- package/src/skills/shared/validation/SKILL.md +204 -0
- package/src/state/session-state.js +113 -0
- package/src/templates/design-document.md +95 -0
- package/src/templates/implementation-plan.md +86 -0
- package/src/templates/session-state.md +68 -0
- package/src/transforms/agent-stub.js +29 -0
- package/src/transforms/extract-examples.js +63 -0
- package/src/transforms/index.js +35 -0
- package/src/transforms/parse-frontmatter.js +23 -0
- package/src/transforms/rebuild-frontmatter.js +147 -0
- package/src/transforms/skill-discovery-stub.js +27 -0
- package/src/transforms/skill-metadata.js +14 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const fs = require('node:fs');
|
|
5
|
+
const { toTitleCase } = require('../lib/naming');
|
|
6
|
+
const { emitInlineQuotedList } = require('../lib/yaml-emit');
|
|
7
|
+
|
|
8
|
+
const DEFAULT_SRC = path.resolve(__dirname, '..');
|
|
9
|
+
|
|
10
|
+
// Host platform names that must never appear as public skill names.
|
|
11
|
+
// Confirmed: Claude /review shadows the built-in PR review command.
|
|
12
|
+
// Confirmed: Codex review, debug, resume conflict with built-in commands.
|
|
13
|
+
// Defensive: Claude debug and resume preemptively reserved.
|
|
14
|
+
const HOST_RESERVED_NAMES = {
|
|
15
|
+
codex: new Set(['review', 'debug', 'resume']),
|
|
16
|
+
claude: new Set(['review', 'debug', 'resume']),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const ENTRY_POINT_CONFIG = {
|
|
20
|
+
gemini: {
|
|
21
|
+
templateFile: 'gemini-command.toml.tmpl',
|
|
22
|
+
outputPath: (e) => `commands/maestro/${e.name}.toml`,
|
|
23
|
+
preamblePlaceholder: 'skills_block',
|
|
24
|
+
},
|
|
25
|
+
claude: {
|
|
26
|
+
templateFile: 'claude-skill.md.tmpl',
|
|
27
|
+
outputPath: (e) => `claude/skills/${e.name}/SKILL.md`,
|
|
28
|
+
preamblePlaceholder: 'protocol_block',
|
|
29
|
+
},
|
|
30
|
+
codex: {
|
|
31
|
+
templateFile: 'codex-skill.md.tmpl',
|
|
32
|
+
outputPath: (e) => `plugins/maestro/skills/${e.name}/SKILL.md`,
|
|
33
|
+
preamblePlaceholder: 'refs_list',
|
|
34
|
+
},
|
|
35
|
+
qwen: null,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const CORE_COMMAND_CONFIG = {
|
|
39
|
+
gemini: {
|
|
40
|
+
templateFile: 'gemini-core-command.toml.tmpl',
|
|
41
|
+
outputPath: (e) => `commands/maestro/${e.name}.toml`,
|
|
42
|
+
},
|
|
43
|
+
claude: {
|
|
44
|
+
templateFile: 'claude-core-command.md.tmpl',
|
|
45
|
+
outputPath: (e) => `claude/skills/${e.name}/SKILL.md`,
|
|
46
|
+
},
|
|
47
|
+
codex: {
|
|
48
|
+
templateFile: 'codex-core-command.md.tmpl',
|
|
49
|
+
outputPath: (e) => `plugins/maestro/skills/${e.name}/SKILL.md`,
|
|
50
|
+
},
|
|
51
|
+
qwen: null,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const GEMINI_SESSION_STATE_BLOCK = `The current session state is provided below:
|
|
55
|
+
|
|
56
|
+
<session-state>
|
|
57
|
+
!{extension_root="\${MAESTRO_EXTENSION_PATH:-$HOME/.gemini/extensions/maestro}"; script="$extension_root/src/scripts/read-active-session.js"; if [[ -f "$script" ]]; then node "$script"; else echo "No active session"; fi}
|
|
58
|
+
</session-state>
|
|
59
|
+
|
|
60
|
+
Use the injected session state above as the source of truth for resume position.
|
|
61
|
+
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @param {{ name: string, runtimeNames?: Record<string, string> }} entry
|
|
66
|
+
* @param {string} runtimeName
|
|
67
|
+
* @returns {string}
|
|
68
|
+
*/
|
|
69
|
+
function getEntryPointRuntimeName(entry, runtimeName) {
|
|
70
|
+
return entry.runtimeNames?.[runtimeName] || entry.name;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @param {string} resolvedName
|
|
75
|
+
* @param {string} runtimeName
|
|
76
|
+
* @throws {Error}
|
|
77
|
+
*/
|
|
78
|
+
function assertNotHostReserved(resolvedName, runtimeName) {
|
|
79
|
+
const reserved = HOST_RESERVED_NAMES[runtimeName];
|
|
80
|
+
if (reserved && reserved.has(resolvedName)) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
`Reserved ${runtimeName} host command name "${resolvedName}" conflicts with a built-in — ` +
|
|
83
|
+
'add a runtimeNames entry to the registry to remap it'
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function applySubstitutions(template, substitutions) {
|
|
89
|
+
let content = template;
|
|
90
|
+
for (const [key, value] of Object.entries(substitutions)) {
|
|
91
|
+
const pattern = new RegExp(`\\{\\{${key}\\}\\}`, 'g');
|
|
92
|
+
content = content.replace(pattern, value);
|
|
93
|
+
}
|
|
94
|
+
return content;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function runTemplateExpansion({ runtimeName, registry, templatePath, outputPathFn, buildSubstitutions }) {
|
|
98
|
+
const template = fs.readFileSync(templatePath, 'utf8');
|
|
99
|
+
return registry.map((entry) => {
|
|
100
|
+
const runtimeEntry = {
|
|
101
|
+
...entry,
|
|
102
|
+
name: getEntryPointRuntimeName(entry, runtimeName),
|
|
103
|
+
};
|
|
104
|
+
assertNotHostReserved(runtimeEntry.name, runtimeName);
|
|
105
|
+
return {
|
|
106
|
+
outputPath: outputPathFn(runtimeEntry),
|
|
107
|
+
content: applySubstitutions(template, buildSubstitutions(runtimeEntry)),
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function resolveRuntimeConfig(configMap, runtimeName, kind) {
|
|
113
|
+
const config = configMap[runtimeName];
|
|
114
|
+
if (config === null) return null;
|
|
115
|
+
if (!config) {
|
|
116
|
+
throw new Error(`Unknown runtime for ${kind} expansion: "${runtimeName}"`);
|
|
117
|
+
}
|
|
118
|
+
return config;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @param {string} runtimeName
|
|
123
|
+
* @param {string} [srcDir]
|
|
124
|
+
* @returns {Array<{ outputPath: string, content: string }>}
|
|
125
|
+
*/
|
|
126
|
+
function expandEntryPoints(runtimeName, srcDir = DEFAULT_SRC) {
|
|
127
|
+
const config = resolveRuntimeConfig(ENTRY_POINT_CONFIG, runtimeName, 'entry-point');
|
|
128
|
+
if (!config) return [];
|
|
129
|
+
|
|
130
|
+
const registry = require(path.join(srcDir, 'entry-points', 'registry'));
|
|
131
|
+
const preambleBuilders = require(path.join(srcDir, 'entry-points', 'preamble-builders'));
|
|
132
|
+
const templatePath = path.join(srcDir, 'entry-points', 'templates', config.templateFile);
|
|
133
|
+
const buildPreamble = preambleBuilders[runtimeName];
|
|
134
|
+
|
|
135
|
+
return runTemplateExpansion({
|
|
136
|
+
runtimeName,
|
|
137
|
+
registry,
|
|
138
|
+
templatePath,
|
|
139
|
+
outputPathFn: config.outputPath,
|
|
140
|
+
buildSubstitutions: (runtimeEntry) => ({
|
|
141
|
+
name: runtimeEntry.name,
|
|
142
|
+
Name: toTitleCase(runtimeEntry.name),
|
|
143
|
+
description: runtimeEntry.description,
|
|
144
|
+
workflow_numbered: runtimeEntry.workflow.map((step, i) => `${i + 1}. ${step}`).join('\n'),
|
|
145
|
+
constraints_list: (runtimeEntry.constraints || []).map((c) => `- ${c}`).join('\n'),
|
|
146
|
+
[config.preamblePlaceholder]: buildPreamble(runtimeEntry),
|
|
147
|
+
}),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @param {string} runtimeName
|
|
153
|
+
* @param {string} [srcDir]
|
|
154
|
+
* @returns {Array<{ outputPath: string, content: string }>}
|
|
155
|
+
*/
|
|
156
|
+
function expandCoreCommands(runtimeName, srcDir = DEFAULT_SRC) {
|
|
157
|
+
const config = resolveRuntimeConfig(CORE_COMMAND_CONFIG, runtimeName, 'core-command');
|
|
158
|
+
if (!config) return [];
|
|
159
|
+
|
|
160
|
+
const registry = require(path.join(srcDir, 'entry-points', 'core-command-registry'));
|
|
161
|
+
const templatePath = path.join(srcDir, 'entry-points', 'templates', config.templateFile);
|
|
162
|
+
|
|
163
|
+
return runTemplateExpansion({
|
|
164
|
+
runtimeName,
|
|
165
|
+
registry,
|
|
166
|
+
templatePath,
|
|
167
|
+
outputPathFn: config.outputPath,
|
|
168
|
+
buildSubstitutions: (runtimeEntry) => ({
|
|
169
|
+
name: runtimeEntry.name,
|
|
170
|
+
description: runtimeEntry.description,
|
|
171
|
+
firstLine: runtimeEntry.firstLine,
|
|
172
|
+
requestType: runtimeEntry.requestType,
|
|
173
|
+
executeInstructions: runtimeEntry.executeInstructions,
|
|
174
|
+
preloadList: emitInlineQuotedList(runtimeEntry.preload),
|
|
175
|
+
sessionStateBlock: (runtimeName === 'gemini' && runtimeEntry.geminiSessionStateInjection)
|
|
176
|
+
? GEMINI_SESSION_STATE_BLOCK
|
|
177
|
+
: '',
|
|
178
|
+
}),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
module.exports = { expandEntryPoints, expandCoreCommands };
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const fs = require('node:fs');
|
|
5
|
+
const { execFileSync } = require('node:child_process');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} relativePath
|
|
9
|
+
* @param {string} rootDir
|
|
10
|
+
* @returns {string}
|
|
11
|
+
* @throws {Error} If the resolved path escapes the root directory
|
|
12
|
+
*/
|
|
13
|
+
function safeResolve(relativePath, rootDir) {
|
|
14
|
+
const resolved = path.resolve(rootDir, relativePath);
|
|
15
|
+
if (!resolved.startsWith(rootDir + path.sep) && resolved !== rootDir) {
|
|
16
|
+
throw new Error(`Path traversal detected: "${relativePath}" resolves outside project root`);
|
|
17
|
+
}
|
|
18
|
+
return resolved;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {string} absOutputPath
|
|
23
|
+
* @param {string} content
|
|
24
|
+
* @param {string} displayPath
|
|
25
|
+
*/
|
|
26
|
+
function executeDiff(absOutputPath, content, displayPath) {
|
|
27
|
+
if (!fs.existsSync(absOutputPath)) {
|
|
28
|
+
console.log(`+++ NEW: ${displayPath}`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const current = fs.readFileSync(absOutputPath, 'utf8');
|
|
33
|
+
if (current === content) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const tmpPath = absOutputPath + '.gen-tmp';
|
|
38
|
+
fs.writeFileSync(tmpPath, content, 'utf8');
|
|
39
|
+
try {
|
|
40
|
+
execFileSync('diff', ['-u', absOutputPath, tmpPath], { encoding: 'utf8' });
|
|
41
|
+
} catch (err) {
|
|
42
|
+
console.log(`--- ${displayPath}`);
|
|
43
|
+
console.log(err.stdout);
|
|
44
|
+
} finally {
|
|
45
|
+
fs.unlinkSync(tmpPath);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @param {string} absOutputPath
|
|
51
|
+
* @param {string} content
|
|
52
|
+
* @param {string} displayPath
|
|
53
|
+
*/
|
|
54
|
+
function executeDryRun(absOutputPath, content, displayPath) {
|
|
55
|
+
const exists = fs.existsSync(absOutputPath);
|
|
56
|
+
const current = exists ? fs.readFileSync(absOutputPath, 'utf8') : null;
|
|
57
|
+
|
|
58
|
+
let status;
|
|
59
|
+
if (!exists) {
|
|
60
|
+
status = 'CREATE';
|
|
61
|
+
} else if (current === content) {
|
|
62
|
+
status = 'UNCHANGED';
|
|
63
|
+
} else {
|
|
64
|
+
status = 'UPDATE';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
console.log(`[${status}] ${displayPath}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @param {string} absOutputPath
|
|
72
|
+
* @param {string} content
|
|
73
|
+
* @param {{ written: number, unchanged: number, errors: number }} stats
|
|
74
|
+
*/
|
|
75
|
+
function executeWrite(absOutputPath, content, stats) {
|
|
76
|
+
fs.mkdirSync(path.dirname(absOutputPath), { recursive: true });
|
|
77
|
+
|
|
78
|
+
const exists = fs.existsSync(absOutputPath);
|
|
79
|
+
const current = exists ? fs.readFileSync(absOutputPath, 'utf8') : null;
|
|
80
|
+
|
|
81
|
+
if (current === content) {
|
|
82
|
+
stats.unchanged++;
|
|
83
|
+
} else {
|
|
84
|
+
fs.writeFileSync(absOutputPath, content, 'utf8');
|
|
85
|
+
stats.written++;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @typedef {Object} FileWriterOptions
|
|
91
|
+
* @property {string} rootDir - Absolute path to the project root directory
|
|
92
|
+
* @property {boolean} [dryRun=false] - Log intended actions without writing files
|
|
93
|
+
* @property {boolean} [diffMode=false] - Show unified diffs against existing files
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @typedef {Object} FileWriterStats
|
|
98
|
+
* @property {number} written - Number of files written (new or changed)
|
|
99
|
+
* @property {number} unchanged - Number of files skipped (content identical)
|
|
100
|
+
* @property {number} errors - Number of files that failed to write
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @typedef {Object} FileWriter
|
|
105
|
+
* @property {(outputPath: string, content: string) => void} write
|
|
106
|
+
* @property {(outputPaths: string[]) => void} clean
|
|
107
|
+
* @property {() => FileWriterStats} getStats
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Creates a file writer that handles write, diff, dry-run, and clean operations.
|
|
112
|
+
*
|
|
113
|
+
* @param {FileWriterOptions} opts
|
|
114
|
+
* @returns {FileWriter}
|
|
115
|
+
*/
|
|
116
|
+
function createFileWriter(opts) {
|
|
117
|
+
const { rootDir, dryRun = false, diffMode = false } = opts;
|
|
118
|
+
const stats = { written: 0, unchanged: 0, errors: 0 };
|
|
119
|
+
const readOnlyMode = dryRun || diffMode;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @param {string} outputPath - Relative path from rootDir
|
|
123
|
+
* @param {string} content - File content to write
|
|
124
|
+
*/
|
|
125
|
+
function write(outputPath, content) {
|
|
126
|
+
try {
|
|
127
|
+
const absOutputPath = safeResolve(outputPath, rootDir);
|
|
128
|
+
if (diffMode) {
|
|
129
|
+
executeDiff(absOutputPath, content, outputPath);
|
|
130
|
+
} else if (dryRun) {
|
|
131
|
+
executeDryRun(absOutputPath, content, outputPath);
|
|
132
|
+
} else {
|
|
133
|
+
executeWrite(absOutputPath, content, stats);
|
|
134
|
+
}
|
|
135
|
+
} catch (err) {
|
|
136
|
+
console.error(`ERROR writing ${outputPath}: ${err.message}`);
|
|
137
|
+
stats.errors++;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @param {string[]} outputPaths - Relative paths from rootDir to delete
|
|
143
|
+
*/
|
|
144
|
+
function clean(outputPaths) {
|
|
145
|
+
if (readOnlyMode) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
for (const outputPath of outputPaths) {
|
|
150
|
+
const absPath = safeResolve(outputPath, rootDir);
|
|
151
|
+
if (fs.existsSync(absPath)) {
|
|
152
|
+
fs.unlinkSync(absPath);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @returns {FileWriterStats}
|
|
159
|
+
*/
|
|
160
|
+
function getStats() {
|
|
161
|
+
return { written: stats.written, unchanged: stats.unchanged, errors: stats.errors };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return { write, clean, getStats };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
module.exports = { createFileWriter, safeResolve };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { createFileWriter } = require('./file-writer');
|
|
4
|
+
|
|
5
|
+
function createGenerationSession({ rootDir, dryRun = false, diffMode = false }) {
|
|
6
|
+
const writer = createFileWriter({ rootDir, dryRun, diffMode });
|
|
7
|
+
const processingErrors = [];
|
|
8
|
+
const readOnlyMode = dryRun || diffMode;
|
|
9
|
+
|
|
10
|
+
function reportError(message, error) {
|
|
11
|
+
const formatted =
|
|
12
|
+
error && error.message ? `${message}: ${error.message}` : message;
|
|
13
|
+
console.error(`ERROR: ${formatted}`);
|
|
14
|
+
processingErrors.push(formatted);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function write(outputPath, content) {
|
|
18
|
+
writer.write(outputPath, content);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function writeAll(outputs) {
|
|
22
|
+
for (const output of outputs) {
|
|
23
|
+
write(output.outputPath, output.content);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function clean(outputPaths) {
|
|
28
|
+
try {
|
|
29
|
+
writer.clean(outputPaths);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
reportError('cleaning generated files', error);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getStats() {
|
|
36
|
+
const fileStats = writer.getStats();
|
|
37
|
+
return {
|
|
38
|
+
written: fileStats.written,
|
|
39
|
+
unchanged: fileStats.unchanged,
|
|
40
|
+
errors: fileStats.errors + processingErrors.length,
|
|
41
|
+
write_errors: fileStats.errors,
|
|
42
|
+
processing_errors: processingErrors.slice(),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
diffMode,
|
|
48
|
+
dryRun,
|
|
49
|
+
clean,
|
|
50
|
+
getStats,
|
|
51
|
+
isReadOnlyMode() {
|
|
52
|
+
return readOnlyMode;
|
|
53
|
+
},
|
|
54
|
+
reportError,
|
|
55
|
+
write,
|
|
56
|
+
writeAll,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = {
|
|
61
|
+
createGenerationSession,
|
|
62
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Collect every output path a generation run is expected to produce.
|
|
5
|
+
*
|
|
6
|
+
* Combines manifest-entry outputs with entry-point expander outputs so callers
|
|
7
|
+
* (e.g. the stale-pruner) can reason about the full artifact surface without
|
|
8
|
+
* re-implementing the expander iteration.
|
|
9
|
+
*
|
|
10
|
+
* @param {Array<{ outputs: Record<string, string> }>} manifest - Expanded manifest entries
|
|
11
|
+
* @param {Record<string, object>} runtimes - Runtime configs keyed by name
|
|
12
|
+
* @param {string} srcDir - Absolute path to the source directory
|
|
13
|
+
* @param {Array<Function>} entryPointExpanders - Expander fns, each (runtimeName, srcDir) => [{ outputPath }, ...]
|
|
14
|
+
* @returns {Set<string>} All output paths produced by this run
|
|
15
|
+
*/
|
|
16
|
+
function collectManifestPaths(manifest, runtimes, srcDir, entryPointExpanders) {
|
|
17
|
+
const paths = new Set();
|
|
18
|
+
for (const entry of manifest) {
|
|
19
|
+
for (const p of Object.values(entry.outputs)) paths.add(p);
|
|
20
|
+
}
|
|
21
|
+
for (const fn of entryPointExpanders) {
|
|
22
|
+
for (const rt of Object.keys(runtimes)) {
|
|
23
|
+
for (const { outputPath } of fn(rt, srcDir)) paths.add(outputPath);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return paths;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = {
|
|
30
|
+
collectManifestPaths,
|
|
31
|
+
};
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
const fs = require('node:fs');
|
|
5
|
+
const { toSnakeCase } = require('../lib/naming');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Expand a glob pattern relative to srcDir.
|
|
9
|
+
* Supports `*` (wildcard within a single directory) and `**` (recursive).
|
|
10
|
+
* Returns sorted relative paths (posix separators).
|
|
11
|
+
* @param {string} pattern - Glob pattern to expand
|
|
12
|
+
* @param {string} srcDir - Absolute path to source directory
|
|
13
|
+
* @returns {string[]} Sorted array of matched relative paths
|
|
14
|
+
*/
|
|
15
|
+
function expandGlob(pattern, srcDir) {
|
|
16
|
+
const segments = pattern.split('/');
|
|
17
|
+
const results = [];
|
|
18
|
+
|
|
19
|
+
function walk(dir, segIndex) {
|
|
20
|
+
if (segIndex >= segments.length) return;
|
|
21
|
+
|
|
22
|
+
const segment = segments[segIndex];
|
|
23
|
+
const isLast = segIndex === segments.length - 1;
|
|
24
|
+
|
|
25
|
+
if (segment === '**') {
|
|
26
|
+
walk(dir, segIndex + 1);
|
|
27
|
+
let entries;
|
|
28
|
+
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; }
|
|
29
|
+
for (const entry of entries) {
|
|
30
|
+
if (entry.isDirectory()) {
|
|
31
|
+
walk(path.join(dir, entry.name), segIndex);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
const re = new RegExp(
|
|
36
|
+
'^' + segment.replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '[^/]*') + '$'
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
let entries;
|
|
40
|
+
try { entries = fs.readdirSync(dir, { withFileTypes: true }); } catch { return; }
|
|
41
|
+
for (const entry of entries) {
|
|
42
|
+
if (!re.test(entry.name)) continue;
|
|
43
|
+
|
|
44
|
+
const fullPath = path.join(dir, entry.name);
|
|
45
|
+
if (isLast) {
|
|
46
|
+
if (entry.isFile()) {
|
|
47
|
+
results.push(path.relative(srcDir, fullPath));
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
if (entry.isDirectory()) {
|
|
51
|
+
walk(fullPath, segIndex + 1);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
walk(srcDir, 0);
|
|
59
|
+
return results.sort();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Apply the path-shape rewrites that differ per runtime but do NOT
|
|
64
|
+
* prepend outputDir. Handles skills/shared flattening and snake_case
|
|
65
|
+
* agent renaming.
|
|
66
|
+
* @param {string} srcRelPath
|
|
67
|
+
* @param {{ agentNaming?: string }} runtime
|
|
68
|
+
* @returns {string}
|
|
69
|
+
*/
|
|
70
|
+
function normalizeSrcRelPath(srcRelPath, runtime) {
|
|
71
|
+
let outPath = srcRelPath;
|
|
72
|
+
|
|
73
|
+
if (outPath.startsWith('skills/shared/')) {
|
|
74
|
+
outPath = 'skills/' + outPath.slice('skills/shared/'.length);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (outPath.startsWith('agents/') && runtime.agentNaming === 'snake_case') {
|
|
78
|
+
const dir = path.dirname(outPath);
|
|
79
|
+
const base = path.basename(outPath);
|
|
80
|
+
outPath = dir + '/' + toSnakeCase(base);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return outPath;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Compute the output path for a source-relative path in a given runtime.
|
|
88
|
+
* Composes the name-shape rewrites with outputDir prepending.
|
|
89
|
+
* @param {string} srcRelPath - Source-relative path
|
|
90
|
+
* @param {{ agentNaming?: string, outputDir?: string }} runtime - Runtime configuration
|
|
91
|
+
* @returns {string} Computed output path
|
|
92
|
+
*/
|
|
93
|
+
function computeOutputPath(srcRelPath, runtime) {
|
|
94
|
+
return buildRuntimeOutputPath(runtime, normalizeSrcRelPath(srcRelPath, runtime));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Normalize an outputBase value for a given runtime.
|
|
99
|
+
* Accepts string, per-runtime object, or null/undefined.
|
|
100
|
+
* @param {string | Record<string, string> | null | undefined} outputBase - Base path specification
|
|
101
|
+
* @param {string} runtimeName - Name of the target runtime
|
|
102
|
+
* @returns {string} Normalized base path
|
|
103
|
+
*/
|
|
104
|
+
function normalizeOutputBase(outputBase, runtimeName) {
|
|
105
|
+
if (!outputBase) {
|
|
106
|
+
return '';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (typeof outputBase === 'string') {
|
|
110
|
+
return outputBase;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (typeof outputBase === 'object') {
|
|
114
|
+
return outputBase[runtimeName] || '';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
throw new Error(`Invalid outputBase: ${JSON.stringify(outputBase)}`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Join a base path with a relative path using posix separators.
|
|
122
|
+
* Returns the relative path unchanged when base is empty.
|
|
123
|
+
* @param {string} base - Base path prefix
|
|
124
|
+
* @param {string} relativePath - Path to append
|
|
125
|
+
* @returns {string} Joined path
|
|
126
|
+
*/
|
|
127
|
+
function joinRelativePath(base, relativePath) {
|
|
128
|
+
if (!base) {
|
|
129
|
+
return relativePath;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return path.posix.join(base, relativePath);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Prepend a runtime's outputDir to a relative path.
|
|
137
|
+
* Skips prepending when outputDir is absent or './'.
|
|
138
|
+
* @param {{ outputDir?: string }} runtime - Runtime configuration
|
|
139
|
+
* @param {string} relativePath - Path to prepend to
|
|
140
|
+
* @returns {string} Path with outputDir prepended
|
|
141
|
+
*/
|
|
142
|
+
function buildRuntimeOutputPath(runtime, relativePath) {
|
|
143
|
+
if (!runtime.outputDir || runtime.outputDir === './') {
|
|
144
|
+
return relativePath;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return runtime.outputDir + relativePath;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Validate that no manifest entries produce forbidden output paths.
|
|
152
|
+
* Throws if any entry targets a path reserved for src-first mode.
|
|
153
|
+
* @param {Array<{ outputs: Record<string, string> }>} manifest - Expanded manifest entries
|
|
154
|
+
*/
|
|
155
|
+
function assertNoMirroredSharedOutputs(manifest) {
|
|
156
|
+
for (const entry of manifest) {
|
|
157
|
+
for (const outputPath of Object.values(entry.outputs)) {
|
|
158
|
+
if (
|
|
159
|
+
outputPath === 'mcp/maestro-server-core.js' ||
|
|
160
|
+
outputPath === 'claude/mcp/maestro-server-core.js' ||
|
|
161
|
+
outputPath === 'plugins/maestro/mcp/maestro-server-core.js' ||
|
|
162
|
+
outputPath === 'lib/mcp/generated/resource-registry.js' ||
|
|
163
|
+
outputPath === 'plugins/maestro/lib/mcp/generated/resource-registry.js' ||
|
|
164
|
+
outputPath === 'plugins/maestro/lib/mcp/generated/agent-registry.js' ||
|
|
165
|
+
outputPath.startsWith('lib/') ||
|
|
166
|
+
outputPath.startsWith('claude/lib/') ||
|
|
167
|
+
outputPath.startsWith('plugins/maestro/lib/')
|
|
168
|
+
) {
|
|
169
|
+
throw new Error(`Manifest output is not allowed in src-first mode: "${outputPath}"`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Expand convention-based manifest rules into explicit entries.
|
|
177
|
+
*
|
|
178
|
+
* Three rule formats:
|
|
179
|
+
* 1. Legacy: has `outputs` field -- passed through unchanged
|
|
180
|
+
* 2. Explicit src + runtimes: has `src` and `runtimes` (no `glob`) -- expands to outputs per runtime
|
|
181
|
+
* 3. Glob: has `glob` and `runtimes` -- scans srcDir, produces one entry per matched file
|
|
182
|
+
*
|
|
183
|
+
* Does NOT merge entries for the same source file -- different rules may have different transforms.
|
|
184
|
+
* @param {Array<Object>} rules - Manifest rules to expand
|
|
185
|
+
* @param {Record<string, Object>} runtimes - Runtime configurations keyed by name
|
|
186
|
+
* @param {string} srcDir - Absolute path to source directory
|
|
187
|
+
* @returns {Array<{ src: string, transforms: string[], outputs: Record<string, string> }>}
|
|
188
|
+
*/
|
|
189
|
+
function expandManifest(rules, runtimes, srcDir) {
|
|
190
|
+
const entries = [];
|
|
191
|
+
|
|
192
|
+
for (const rule of rules) {
|
|
193
|
+
if (rule.outputs) {
|
|
194
|
+
entries.push(rule);
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (!rule.runtimes || !Array.isArray(rule.runtimes)) {
|
|
199
|
+
throw new Error(`Manifest rule missing "runtimes": ${JSON.stringify(rule)}`);
|
|
200
|
+
}
|
|
201
|
+
if (!rule.glob && !rule.src) {
|
|
202
|
+
throw new Error(`Manifest rule needs "glob" or "src": ${JSON.stringify(rule)}`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
let srcFiles;
|
|
206
|
+
if (rule.glob) {
|
|
207
|
+
srcFiles = expandGlob(rule.glob, srcDir);
|
|
208
|
+
if (rule.exclude) {
|
|
209
|
+
const excludeSet = new Set(rule.exclude);
|
|
210
|
+
srcFiles = srcFiles.filter((f) => !excludeSet.has(f));
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
srcFiles = [rule.src];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
for (const srcRelPath of srcFiles) {
|
|
217
|
+
const outputs = {};
|
|
218
|
+
for (const runtimeName of rule.runtimes) {
|
|
219
|
+
const runtime = runtimes[runtimeName];
|
|
220
|
+
if (rule.outputName) {
|
|
221
|
+
outputs[runtimeName] = buildRuntimeOutputPath(runtime, rule.outputName);
|
|
222
|
+
} else if (rule.preserveSourcePath) {
|
|
223
|
+
const outputBase = normalizeOutputBase(rule.outputBase, runtimeName);
|
|
224
|
+
outputs[runtimeName] = buildRuntimeOutputPath(
|
|
225
|
+
runtime,
|
|
226
|
+
joinRelativePath(outputBase, srcRelPath)
|
|
227
|
+
);
|
|
228
|
+
} else {
|
|
229
|
+
const outputBase = normalizeOutputBase(rule.outputBase, runtimeName);
|
|
230
|
+
outputs[runtimeName] = buildRuntimeOutputPath(
|
|
231
|
+
runtime,
|
|
232
|
+
joinRelativePath(outputBase, normalizeSrcRelPath(srcRelPath, runtime))
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
entries.push({
|
|
237
|
+
src: srcRelPath,
|
|
238
|
+
transforms: rule.transforms,
|
|
239
|
+
outputs,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return entries;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
module.exports = {
|
|
248
|
+
expandGlob,
|
|
249
|
+
normalizeSrcRelPath,
|
|
250
|
+
computeOutputPath,
|
|
251
|
+
normalizeOutputBase,
|
|
252
|
+
joinRelativePath,
|
|
253
|
+
buildRuntimeOutputPath,
|
|
254
|
+
assertNoMirroredSharedOutputs,
|
|
255
|
+
expandManifest,
|
|
256
|
+
};
|