@opengsd/gsd-core 1.2.0 → 1.3.0
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/README.ja-JP.md +46 -791
- package/README.ko-KR.md +44 -780
- package/README.md +42 -218
- package/README.pt-BR.md +47 -414
- package/README.zh-CN.md +46 -763
- package/agents/gsd-ai-researcher.md +2 -2
- package/agents/gsd-debug-session-manager.md +1 -1
- package/agents/gsd-debugger.md +8 -8
- package/agents/gsd-doc-writer.md +7 -6
- package/agents/gsd-domain-researcher.md +15 -2
- package/agents/gsd-eval-auditor.md +1 -1
- package/agents/gsd-eval-planner.md +2 -2
- package/agents/gsd-executor.md +21 -8
- package/agents/gsd-framework-selector.md +1 -1
- package/agents/gsd-intel-updater.md +4 -4
- package/agents/gsd-phase-researcher.md +19 -6
- package/agents/gsd-plan-checker.md +3 -3
- package/agents/gsd-planner.md +36 -23
- package/agents/gsd-project-researcher.md +13 -0
- package/agents/gsd-research-synthesizer.md +6 -2
- package/agents/gsd-roadmapper.md +6 -6
- package/agents/gsd-ui-researcher.md +16 -3
- package/agents/gsd-user-profiler.md +2 -2
- package/agents/gsd-verifier.md +8 -8
- package/assets/gsd-logo-2000-transparent.png +0 -0
- package/assets/gsd-logo-2000-transparent.svg +17 -0
- package/assets/gsd-logo-2000.png +0 -0
- package/assets/gsd-logo-2000.svg +21 -0
- package/assets/terminal.svg +68 -0
- package/bin/install.js +255 -103
- package/commands/gsd/add-tests.md +1 -1
- package/commands/gsd/ai-integration-phase.md +3 -3
- package/commands/gsd/audit-fix.md +1 -1
- package/commands/gsd/audit-milestone.md +1 -1
- package/commands/gsd/audit-uat.md +1 -1
- package/commands/gsd/autonomous.md +2 -2
- package/commands/gsd/capture.md +6 -6
- package/commands/gsd/cleanup.md +1 -1
- package/commands/gsd/code-review.md +1 -1
- package/commands/gsd/complete-milestone.md +2 -2
- package/commands/gsd/config.md +3 -3
- package/commands/gsd/debug.md +1 -1
- package/commands/gsd/discuss-phase.md +5 -4
- package/commands/gsd/docs-update.md +1 -1
- package/commands/gsd/eval-review.md +2 -2
- package/commands/gsd/execute-phase.md +2 -2
- package/commands/gsd/explore.md +1 -1
- package/commands/gsd/extract-learnings.md +2 -2
- package/commands/gsd/fast.md +1 -1
- package/commands/gsd/forensics.md +1 -1
- package/commands/gsd/graphify.md +9 -9
- package/commands/gsd/health.md +1 -1
- package/commands/gsd/help.md +2 -2
- package/commands/gsd/import.md +5 -5
- package/commands/gsd/inbox.md +1 -1
- package/commands/gsd/ingest-docs.md +4 -4
- package/commands/gsd/manager.md +3 -3
- package/commands/gsd/map-codebase.md +1 -1
- package/commands/gsd/milestone-summary.md +1 -1
- package/commands/gsd/mvp-phase.md +4 -4
- package/commands/gsd/new-milestone.md +5 -5
- package/commands/gsd/new-project.md +5 -5
- package/commands/gsd/pause-work.md +2 -2
- package/commands/gsd/phase.md +4 -4
- package/commands/gsd/plan-phase.md +2 -2
- package/commands/gsd/plan-review-convergence.md +4 -4
- package/commands/gsd/pr-branch.md +1 -1
- package/commands/gsd/profile-user.md +2 -2
- package/commands/gsd/progress.md +4 -4
- package/commands/gsd/quick.md +1 -1
- package/commands/gsd/resume-work.md +1 -1
- package/commands/gsd/review.md +3 -2
- package/commands/gsd/secure-phase.md +1 -1
- package/commands/gsd/settings.md +1 -1
- package/commands/gsd/ship.md +2 -2
- package/commands/gsd/sketch.md +7 -7
- package/commands/gsd/spec-phase.md +2 -2
- package/commands/gsd/spike.md +3 -3
- package/commands/gsd/stats.md +1 -1
- package/commands/gsd/surface.md +4 -4
- package/commands/gsd/thread.md +1 -1
- package/commands/gsd/ui-phase.md +2 -2
- package/commands/gsd/ui-review.md +2 -2
- package/commands/gsd/ultraplan-phase.md +2 -2
- package/commands/gsd/undo.md +3 -3
- package/commands/gsd/update.md +3 -3
- package/commands/gsd/validate-phase.md +1 -1
- package/commands/gsd/verify-work.md +2 -2
- package/commands/gsd/workspace.md +4 -4
- package/{get-shit-done → gsd-core}/bin/check-latest-version.cjs +1 -1
- package/{get-shit-done → gsd-core}/bin/gsd-tools.cjs +50 -4
- package/gsd-core/bin/lib/active-workstream-store.cjs +291 -0
- package/gsd-core/bin/lib/adr-parser.cjs +399 -0
- package/gsd-core/bin/lib/agent-command-router.cjs +68 -0
- package/gsd-core/bin/lib/artifacts.cjs +51 -0
- package/gsd-core/bin/lib/audit.cjs +743 -0
- package/gsd-core/bin/lib/check-command-router.cjs +342 -0
- package/gsd-core/bin/lib/cjs-command-router-adapter.cjs +81 -0
- package/gsd-core/bin/lib/clock.cjs +95 -0
- package/gsd-core/bin/lib/clusters.cjs +128 -0
- package/gsd-core/bin/lib/code-review-flags.cjs +59 -0
- package/gsd-core/bin/lib/command-aliases.cjs +809 -0
- package/gsd-core/bin/lib/command-arg-projection.cjs +55 -0
- package/gsd-core/bin/lib/command-routing-hub.cjs +300 -0
- package/gsd-core/bin/lib/commands.cjs +1202 -0
- package/gsd-core/bin/lib/config-schema.cjs +29 -0
- package/gsd-core/bin/lib/config-types.cjs +19 -0
- package/gsd-core/bin/lib/config.cjs +714 -0
- package/{get-shit-done → gsd-core}/bin/lib/configuration.cjs +76 -85
- package/gsd-core/bin/lib/context-utilization.cjs +48 -0
- package/gsd-core/bin/lib/core.cjs +2007 -0
- package/{get-shit-done → gsd-core}/bin/lib/decisions.cjs +9 -7
- package/gsd-core/bin/lib/docs.cjs +252 -0
- package/gsd-core/bin/lib/drift.cjs +364 -0
- package/gsd-core/bin/lib/fallow-runner.cjs +115 -0
- package/gsd-core/bin/lib/frontmatter.cjs +442 -0
- package/gsd-core/bin/lib/gap-checker.cjs +257 -0
- package/gsd-core/bin/lib/graphify.cjs +496 -0
- package/gsd-core/bin/lib/gsd2-import.cjs +456 -0
- package/gsd-core/bin/lib/init-command-router.cjs +62 -0
- package/gsd-core/bin/lib/init.cjs +1799 -0
- package/gsd-core/bin/lib/install-profiles.cjs +526 -0
- package/gsd-core/bin/lib/installer-migration-authoring.cjs +122 -0
- package/gsd-core/bin/lib/installer-migration-report.cjs +347 -0
- package/gsd-core/bin/lib/installer-migrations/000-first-time-baseline.cjs +218 -0
- package/gsd-core/bin/lib/installer-migrations/001-legacy-orphan-files.cjs +48 -0
- package/gsd-core/bin/lib/installer-migrations/002-codex-legacy-hooks-json.cjs +94 -0
- package/gsd-core/bin/lib/installer-migrations/003-rename-get-shit-done-to-gsd-core.cjs +108 -0
- package/gsd-core/bin/lib/installer-migrations.cjs +784 -0
- package/gsd-core/bin/lib/intel.cjs +607 -0
- package/gsd-core/bin/lib/learnings.cjs +270 -0
- package/gsd-core/bin/lib/legacy-cleanup.cjs +253 -0
- package/gsd-core/bin/lib/milestone.cjs +373 -0
- package/gsd-core/bin/lib/model-catalog.cjs +154 -0
- package/gsd-core/bin/lib/model-profiles.cjs +24 -0
- package/gsd-core/bin/lib/observability/event.cjs +51 -0
- package/gsd-core/bin/lib/observability/logger.cjs +146 -0
- package/{get-shit-done → gsd-core}/bin/lib/observability/redaction.cjs +19 -21
- package/{get-shit-done → gsd-core}/bin/lib/package-identity.cjs +5 -1
- package/gsd-core/bin/lib/phase-command-router.cjs +189 -0
- package/gsd-core/bin/lib/phase-lifecycle.cjs +74 -0
- package/gsd-core/bin/lib/phase.cjs +1307 -0
- package/gsd-core/bin/lib/phases-command-router.cjs +43 -0
- package/{get-shit-done → gsd-core}/bin/lib/plan-scan.cjs +18 -24
- package/gsd-core/bin/lib/planning-workspace.cjs +245 -0
- package/gsd-core/bin/lib/profile-output.cjs +1120 -0
- package/gsd-core/bin/lib/profile-pipeline.cjs +517 -0
- package/gsd-core/bin/lib/project-root.cjs +119 -0
- package/gsd-core/bin/lib/prompt-budget.cjs +305 -0
- package/gsd-core/bin/lib/review-reviewer-selection.cjs +121 -0
- package/gsd-core/bin/lib/roadmap-command-router.cjs +166 -0
- package/gsd-core/bin/lib/roadmap-upgrade.cjs +491 -0
- package/gsd-core/bin/lib/roadmap.cjs +600 -0
- package/gsd-core/bin/lib/runtime-artifact-layout.cjs +254 -0
- package/gsd-core/bin/lib/runtime-homes.cjs +169 -0
- package/gsd-core/bin/lib/runtime-name-policy.cjs +96 -0
- package/gsd-core/bin/lib/runtime-slash.cjs +119 -0
- package/{get-shit-done → gsd-core}/bin/lib/schema-detect.cjs +20 -26
- package/gsd-core/bin/lib/secrets.cjs +34 -0
- package/gsd-core/bin/lib/security.cjs +407 -0
- package/gsd-core/bin/lib/semver-compare.cjs +42 -0
- package/gsd-core/bin/lib/shell-command-projection.cjs +524 -0
- package/gsd-core/bin/lib/state-command-router.cjs +160 -0
- package/{get-shit-done → gsd-core}/bin/lib/state-document.cjs +78 -82
- package/gsd-core/bin/lib/state.cjs +2010 -0
- package/gsd-core/bin/lib/surface.cjs +406 -0
- package/gsd-core/bin/lib/task-command-router.cjs +85 -0
- package/gsd-core/bin/lib/template.cjs +237 -0
- package/gsd-core/bin/lib/uat.cjs +297 -0
- package/gsd-core/bin/lib/ui-safety-gate.cjs +98 -0
- package/gsd-core/bin/lib/update-context.cjs +218 -0
- package/gsd-core/bin/lib/validate-command-router.cjs +91 -0
- package/gsd-core/bin/lib/validate.cjs +112 -0
- package/gsd-core/bin/lib/verify-command-router.cjs +44 -0
- package/gsd-core/bin/lib/verify.cjs +1451 -0
- package/{get-shit-done → gsd-core}/bin/lib/workstream-inventory-builder.cjs +19 -12
- package/gsd-core/bin/lib/workstream-inventory.cjs +147 -0
- package/{get-shit-done → gsd-core}/bin/lib/workstream-name-policy.cjs +28 -31
- package/gsd-core/bin/lib/workstream.cjs +380 -0
- package/gsd-core/bin/lib/worktree-safety.cjs +912 -0
- package/{get-shit-done → gsd-core}/bin/shared/config-defaults.manifest.json +1 -0
- package/{get-shit-done → gsd-core}/bin/shared/config-schema.manifest.json +17 -1
- package/{get-shit-done → gsd-core}/bin/shared/model-catalog.json +27 -0
- package/{get-shit-done → gsd-core}/references/artifact-types.md +1 -1
- package/{get-shit-done → gsd-core}/references/checkpoints.md +1 -1
- package/{get-shit-done → gsd-core}/references/few-shot-examples/plan-checker.md +2 -2
- package/{get-shit-done → gsd-core}/references/few-shot-examples/verifier.md +12 -12
- package/{get-shit-done → gsd-core}/references/model-profile-resolution.md +1 -1
- package/{get-shit-done → gsd-core}/references/mvp-concepts.md +1 -1
- package/{get-shit-done → gsd-core}/references/planner-graphify-auto-update.md +2 -2
- package/{get-shit-done → gsd-core}/references/planner-human-verify-mode.md +1 -1
- package/{get-shit-done → gsd-core}/references/planner-mvp-mode.md +1 -1
- package/{get-shit-done → gsd-core}/references/ui-brand.md +4 -2
- package/{get-shit-done → gsd-core}/references/verification-patterns.md +1 -1
- package/gsd-core/references/worktree-branch-check.md +38 -0
- package/{get-shit-done → gsd-core}/references/worktree-path-safety.md +4 -26
- package/{get-shit-done → gsd-core}/templates/README.md +2 -2
- package/{get-shit-done → gsd-core}/templates/codebase/structure.md +10 -10
- package/{get-shit-done → gsd-core}/templates/copilot-instructions.md +1 -1
- package/{get-shit-done → gsd-core}/templates/phase-prompt.md +10 -10
- package/gsd-core/workflows/_runtime-launcher.snippet.sh +1 -0
- package/{get-shit-done → gsd-core}/workflows/add-backlog.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/add-phase.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/add-tests.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/add-todo.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/ai-integration-phase.md +4 -4
- package/{get-shit-done → gsd-core}/workflows/audit-fix.md +2 -2
- package/{get-shit-done → gsd-core}/workflows/audit-milestone.md +3 -1
- package/{get-shit-done → gsd-core}/workflows/audit-uat.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/autonomous.md +10 -8
- package/{get-shit-done → gsd-core}/workflows/check-todos.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/cleanup.md +44 -4
- package/{get-shit-done → gsd-core}/workflows/code-review-fix.md +4 -4
- package/{get-shit-done → gsd-core}/workflows/code-review.md +6 -4
- package/{get-shit-done → gsd-core}/workflows/complete-milestone.md +2 -2
- package/{get-shit-done → gsd-core}/workflows/debug.md +7 -2
- package/{get-shit-done → gsd-core}/workflows/diagnose-issues.md +6 -2
- package/{get-shit-done → gsd-core}/workflows/discovery-phase.md +5 -5
- package/{get-shit-done → gsd-core}/workflows/discuss-phase/modes/advisor.md +5 -5
- package/{get-shit-done → gsd-core}/workflows/discuss-phase/modes/auto.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/discuss-phase/modes/chain.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/discuss-phase/modes/power.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/discuss-phase-assumptions.md +4 -4
- package/{get-shit-done → gsd-core}/workflows/discuss-phase.md +6 -6
- package/{get-shit-done → gsd-core}/workflows/do.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/docs-update.md +19 -5
- package/{get-shit-done → gsd-core}/workflows/edit-phase.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/eval-review.md +3 -3
- package/{get-shit-done → gsd-core}/workflows/execute-phase/steps/codebase-drift-gate.md +16 -3
- package/{get-shit-done → gsd-core}/workflows/execute-phase/steps/post-merge-gate.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/execute-phase.md +89 -57
- package/{get-shit-done → gsd-core}/workflows/execute-plan.md +8 -8
- package/{get-shit-done → gsd-core}/workflows/explore.md +5 -3
- package/{get-shit-done → gsd-core}/workflows/extract-learnings.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/forensics.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/graduation.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/health.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/help/modes/default.md +3 -3
- package/{get-shit-done → gsd-core}/workflows/help/modes/full.md +6 -6
- package/{get-shit-done → gsd-core}/workflows/import.md +3 -1
- package/{get-shit-done → gsd-core}/workflows/ingest-docs.md +5 -5
- package/{get-shit-done → gsd-core}/workflows/insert-phase.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/list-workspaces.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/manager.md +3 -3
- package/{get-shit-done → gsd-core}/workflows/map-codebase.md +3 -1
- package/{get-shit-done → gsd-core}/workflows/milestone-summary.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/mvp-phase.md +7 -7
- package/{get-shit-done → gsd-core}/workflows/new-milestone.md +5 -5
- package/{get-shit-done → gsd-core}/workflows/new-project.md +8 -8
- package/{get-shit-done → gsd-core}/workflows/new-workspace.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/next.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/pause-work.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/plan-milestone-gaps.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/plan-phase.md +29 -28
- package/{get-shit-done → gsd-core}/workflows/plan-review-convergence.md +10 -10
- package/{get-shit-done → gsd-core}/workflows/plant-seed.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/profile-user.md +11 -11
- package/{get-shit-done → gsd-core}/workflows/progress.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/quick.md +7 -29
- package/{get-shit-done → gsd-core}/workflows/reapply-patches.md +2 -2
- package/{get-shit-done → gsd-core}/workflows/remove-phase.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/remove-workspace.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/resume-project.md +2 -2
- package/{get-shit-done → gsd-core}/workflows/review.md +110 -2
- package/{get-shit-done → gsd-core}/workflows/scan.md +3 -1
- package/{get-shit-done → gsd-core}/workflows/secure-phase.md +5 -3
- package/{get-shit-done → gsd-core}/workflows/settings-advanced.md +196 -6
- package/{get-shit-done → gsd-core}/workflows/settings-integrations.md +2 -2
- package/{get-shit-done → gsd-core}/workflows/settings.md +16 -2
- package/{get-shit-done → gsd-core}/workflows/ship.md +56 -4
- package/{get-shit-done → gsd-core}/workflows/sketch-wrap-up.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/sketch.md +5 -5
- package/{get-shit-done → gsd-core}/workflows/spec-phase.md +2 -2
- package/{get-shit-done → gsd-core}/workflows/spike-wrap-up.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/spike.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/stats.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/sync-skills.md +3 -3
- package/{get-shit-done → gsd-core}/workflows/thread.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/transition.md +2 -2
- package/{get-shit-done → gsd-core}/workflows/ui-phase.md +5 -5
- package/{get-shit-done → gsd-core}/workflows/ui-review.md +3 -3
- package/{get-shit-done → gsd-core}/workflows/ultraplan-phase.md +1 -1
- package/{get-shit-done → gsd-core}/workflows/undo.md +2 -2
- package/{get-shit-done → gsd-core}/workflows/update.md +41 -16
- package/{get-shit-done → gsd-core}/workflows/validate-phase.md +5 -3
- package/{get-shit-done → gsd-core}/workflows/verify-phase.md +4 -4
- package/{get-shit-done → gsd-core}/workflows/verify-work.md +7 -7
- package/hooks/dist/gsd-check-update-worker.js +16 -3
- package/hooks/dist/gsd-check-update.js +7 -5
- package/hooks/dist/gsd-context-monitor.js +2 -2
- package/hooks/dist/gsd-statusline.js +39 -21
- package/hooks/dist/gsd-update-banner.js +6 -2
- package/hooks/dist/gsd-worktree-path-guard.js +169 -0
- package/hooks/dist/managed-hooks-registry.cjs +35 -0
- package/hooks/gsd-check-update-worker.js +16 -3
- package/hooks/gsd-check-update.js +7 -5
- package/hooks/gsd-context-monitor.js +2 -2
- package/hooks/gsd-statusline.js +39 -21
- package/hooks/gsd-update-banner.js +6 -2
- package/hooks/gsd-worktree-path-guard.js +169 -0
- package/hooks/managed-hooks-registry.cjs +1 -0
- package/package.json +17 -11
- package/scripts/affected-tests-lib.cjs +1 -1
- package/scripts/base64-scan.sh +12 -0
- package/scripts/build-hooks.js +5 -1
- package/scripts/changeset/cli.cjs +2 -2
- package/scripts/changeset/github-release-notes.cjs +1 -1
- package/scripts/changeset/lint.cjs +1 -1
- package/scripts/check-alias-drift.cjs +8 -8
- package/scripts/check-env.cjs +5 -1
- package/scripts/ci-test-scope.cjs +34 -9
- package/scripts/command-contract-helpers.cjs +1 -1
- package/scripts/fix-slash-commands.cjs +5 -5
- package/scripts/gen-inventory-manifest.cjs +3 -3
- package/scripts/generate-package-identity.cjs +28 -7
- package/scripts/lib/allowlist-ratchet.cjs +136 -0
- package/scripts/lint-command-contract.cjs +1 -1
- package/scripts/lint-legacy-dir-name.cjs +156 -0
- package/scripts/lint-package-identity-drift.cjs +8 -8
- package/scripts/lint-pr-check-project-dir.cjs +0 -1
- package/scripts/lint-shell-command-projection-drift.cjs +1 -1
- package/scripts/lint-skill-deps.cjs +1 -1
- package/scripts/lint-test-file-count.allowlist.json +129 -32
- package/scripts/lint-test-file-count.cjs +85 -30
- package/scripts/mutation-matrix.cjs +219 -0
- package/scripts/prompt-injection-scan.sh +5 -1
- package/scripts/release-notes/format-github-release-notes.cjs +256 -0
- package/scripts/release-tarball-smoke.cjs +9 -9
- package/scripts/run-tests.cjs +34 -2
- package/scripts/strip-prose-atrefs.cjs +2 -2
- package/scripts/sync-runtime-launcher.cjs +2 -2
- package/scripts/verify-npm-publish.cjs +252 -0
- package/get-shit-done/bin/lib/active-workstream-store.cjs +0 -302
- package/get-shit-done/bin/lib/adr-parser.cjs +0 -394
- package/get-shit-done/bin/lib/agent-command-router.cjs +0 -65
- package/get-shit-done/bin/lib/artifacts.cjs +0 -53
- package/get-shit-done/bin/lib/audit.cjs +0 -755
- package/get-shit-done/bin/lib/check-command-router.cjs +0 -333
- package/get-shit-done/bin/lib/cjs-command-router-adapter.cjs +0 -118
- package/get-shit-done/bin/lib/clock.cjs +0 -96
- package/get-shit-done/bin/lib/clusters.cjs +0 -135
- package/get-shit-done/bin/lib/code-review-flags.cjs +0 -74
- package/get-shit-done/bin/lib/command-aliases.cjs +0 -815
- package/get-shit-done/bin/lib/command-arg-projection.cjs +0 -62
- package/get-shit-done/bin/lib/command-routing-hub.cjs +0 -388
- package/get-shit-done/bin/lib/commands.cjs +0 -1188
- package/get-shit-done/bin/lib/config-schema.cjs +0 -31
- package/get-shit-done/bin/lib/config.cjs +0 -728
- package/get-shit-done/bin/lib/context-utilization.cjs +0 -47
- package/get-shit-done/bin/lib/core.cjs +0 -2121
- package/get-shit-done/bin/lib/docs.cjs +0 -270
- package/get-shit-done/bin/lib/drift.cjs +0 -388
- package/get-shit-done/bin/lib/fallow-runner.cjs +0 -109
- package/get-shit-done/bin/lib/frontmatter.cjs +0 -389
- package/get-shit-done/bin/lib/gap-checker.cjs +0 -205
- package/get-shit-done/bin/lib/graphify.cjs +0 -592
- package/get-shit-done/bin/lib/gsd2-import.cjs +0 -514
- package/get-shit-done/bin/lib/init-command-router.cjs +0 -58
- package/get-shit-done/bin/lib/init.cjs +0 -2112
- package/get-shit-done/bin/lib/install-profiles.cjs +0 -603
- package/get-shit-done/bin/lib/installer-migration-authoring.cjs +0 -117
- package/get-shit-done/bin/lib/installer-migration-report.cjs +0 -354
- package/get-shit-done/bin/lib/installer-migrations/000-first-time-baseline.cjs +0 -220
- package/get-shit-done/bin/lib/installer-migrations/001-legacy-orphan-files.cjs +0 -41
- package/get-shit-done/bin/lib/installer-migrations/002-codex-legacy-hooks-json.cjs +0 -80
- package/get-shit-done/bin/lib/installer-migrations.cjs +0 -778
- package/get-shit-done/bin/lib/intel.cjs +0 -708
- package/get-shit-done/bin/lib/learnings.cjs +0 -421
- package/get-shit-done/bin/lib/milestone.cjs +0 -314
- package/get-shit-done/bin/lib/model-catalog.cjs +0 -212
- package/get-shit-done/bin/lib/model-profiles.cjs +0 -31
- package/get-shit-done/bin/lib/observability/event.cjs +0 -82
- package/get-shit-done/bin/lib/observability/logger.cjs +0 -174
- package/get-shit-done/bin/lib/phase-command-router.cjs +0 -191
- package/get-shit-done/bin/lib/phase-lifecycle.cjs +0 -80
- package/get-shit-done/bin/lib/phase.cjs +0 -1607
- package/get-shit-done/bin/lib/phases-command-router.cjs +0 -39
- package/get-shit-done/bin/lib/planning-workspace.cjs +0 -238
- package/get-shit-done/bin/lib/profile-output.cjs +0 -1141
- package/get-shit-done/bin/lib/profile-pipeline.cjs +0 -539
- package/get-shit-done/bin/lib/project-root.cjs +0 -112
- package/get-shit-done/bin/lib/prompt-budget.cjs +0 -399
- package/get-shit-done/bin/lib/review-reviewer-selection.cjs +0 -125
- package/get-shit-done/bin/lib/roadmap-command-router.cjs +0 -28
- package/get-shit-done/bin/lib/roadmap.cjs +0 -650
- package/get-shit-done/bin/lib/runtime-artifact-layout.cjs +0 -301
- package/get-shit-done/bin/lib/runtime-homes.cjs +0 -222
- package/get-shit-done/bin/lib/runtime-name-policy.cjs +0 -83
- package/get-shit-done/bin/lib/runtime-slash.cjs +0 -112
- package/get-shit-done/bin/lib/secrets.cjs +0 -32
- package/get-shit-done/bin/lib/security.cjs +0 -600
- package/get-shit-done/bin/lib/semver-compare.cjs +0 -35
- package/get-shit-done/bin/lib/shell-command-projection.cjs +0 -500
- package/get-shit-done/bin/lib/state-command-router.cjs +0 -252
- package/get-shit-done/bin/lib/state.cjs +0 -2038
- package/get-shit-done/bin/lib/surface.cjs +0 -470
- package/get-shit-done/bin/lib/task-command-router.cjs +0 -81
- package/get-shit-done/bin/lib/template.cjs +0 -228
- package/get-shit-done/bin/lib/uat.cjs +0 -289
- package/get-shit-done/bin/lib/update-context.cjs +0 -209
- package/get-shit-done/bin/lib/validate-command-router.cjs +0 -83
- package/get-shit-done/bin/lib/validate.cjs +0 -92
- package/get-shit-done/bin/lib/verify-command-router.cjs +0 -40
- package/get-shit-done/bin/lib/verify.cjs +0 -1511
- package/get-shit-done/bin/lib/workstream-inventory.cjs +0 -146
- package/get-shit-done/bin/lib/workstream.cjs +0 -389
- package/get-shit-done/bin/lib/worktree-safety.cjs +0 -985
- package/get-shit-done/workflows/_runtime-launcher.snippet.sh +0 -1
- package/scripts/lint-no-source-grep-extras.cjs +0 -81
- package/scripts/lint-no-source-grep.cjs +0 -174
- package/scripts/lint-shared-module-handsync.cjs +0 -388
- package/scripts/shared-module-handsync-allowlist.json +0 -183
- /package/{get-shit-done → gsd-core}/bin/shared/runtime-aliases.manifest.json +0 -0
- /package/{get-shit-done → gsd-core}/bin/verify-reapply-patches.cjs +0 -0
- /package/{get-shit-done → gsd-core}/contexts/dev.md +0 -0
- /package/{get-shit-done → gsd-core}/contexts/research.md +0 -0
- /package/{get-shit-done → gsd-core}/contexts/review.md +0 -0
- /package/{get-shit-done → gsd-core}/references/agent-contracts.md +0 -0
- /package/{get-shit-done → gsd-core}/references/ai-evals.md +0 -0
- /package/{get-shit-done → gsd-core}/references/ai-frameworks.md +0 -0
- /package/{get-shit-done → gsd-core}/references/autonomous-smart-discuss.md +0 -0
- /package/{get-shit-done → gsd-core}/references/common-bug-patterns.md +0 -0
- /package/{get-shit-done → gsd-core}/references/context-budget.md +0 -0
- /package/{get-shit-done → gsd-core}/references/continuation-format.md +0 -0
- /package/{get-shit-done → gsd-core}/references/debugger-philosophy.md +0 -0
- /package/{get-shit-done → gsd-core}/references/decimal-phase-calculation.md +0 -0
- /package/{get-shit-done → gsd-core}/references/doc-conflict-engine.md +0 -0
- /package/{get-shit-done → gsd-core}/references/domain-probes.md +0 -0
- /package/{get-shit-done → gsd-core}/references/execute-mvp-tdd.md +0 -0
- /package/{get-shit-done → gsd-core}/references/executor-examples.md +0 -0
- /package/{get-shit-done → gsd-core}/references/gate-prompts.md +0 -0
- /package/{get-shit-done → gsd-core}/references/gates.md +0 -0
- /package/{get-shit-done → gsd-core}/references/git-integration.md +0 -0
- /package/{get-shit-done → gsd-core}/references/git-planning-commit.md +0 -0
- /package/{get-shit-done → gsd-core}/references/ios-scaffold.md +0 -0
- /package/{get-shit-done → gsd-core}/references/mandatory-initial-read.md +0 -0
- /package/{get-shit-done → gsd-core}/references/model-profiles.md +0 -0
- /package/{get-shit-done → gsd-core}/references/phase-argument-parsing.md +0 -0
- /package/{get-shit-done → gsd-core}/references/planner-antipatterns.md +0 -0
- /package/{get-shit-done → gsd-core}/references/planner-chunked.md +0 -0
- /package/{get-shit-done → gsd-core}/references/planner-gap-closure.md +0 -0
- /package/{get-shit-done → gsd-core}/references/planner-interface-context.md +0 -0
- /package/{get-shit-done → gsd-core}/references/planner-reviews.md +0 -0
- /package/{get-shit-done → gsd-core}/references/planner-revision.md +0 -0
- /package/{get-shit-done → gsd-core}/references/planner-source-audit.md +0 -0
- /package/{get-shit-done → gsd-core}/references/planning-config.md +0 -0
- /package/{get-shit-done → gsd-core}/references/project-skills-discovery.md +0 -0
- /package/{get-shit-done → gsd-core}/references/questioning.md +0 -0
- /package/{get-shit-done → gsd-core}/references/revision-loop.md +0 -0
- /package/{get-shit-done → gsd-core}/references/scout-codebase.md +0 -0
- /package/{get-shit-done → gsd-core}/references/skeleton-template.md +0 -0
- /package/{get-shit-done → gsd-core}/references/sketch-interactivity.md +0 -0
- /package/{get-shit-done → gsd-core}/references/sketch-theme-system.md +0 -0
- /package/{get-shit-done → gsd-core}/references/sketch-tooling.md +0 -0
- /package/{get-shit-done → gsd-core}/references/sketch-variant-patterns.md +0 -0
- /package/{get-shit-done → gsd-core}/references/spidr-splitting.md +0 -0
- /package/{get-shit-done → gsd-core}/references/tdd.md +0 -0
- /package/{get-shit-done → gsd-core}/references/thinking-models-debug.md +0 -0
- /package/{get-shit-done → gsd-core}/references/thinking-models-execution.md +0 -0
- /package/{get-shit-done → gsd-core}/references/thinking-models-planning.md +0 -0
- /package/{get-shit-done → gsd-core}/references/thinking-models-research.md +0 -0
- /package/{get-shit-done → gsd-core}/references/thinking-models-verification.md +0 -0
- /package/{get-shit-done → gsd-core}/references/thinking-partner.md +0 -0
- /package/{get-shit-done → gsd-core}/references/universal-anti-patterns.md +0 -0
- /package/{get-shit-done → gsd-core}/references/user-profiling.md +0 -0
- /package/{get-shit-done → gsd-core}/references/user-story-template.md +0 -0
- /package/{get-shit-done → gsd-core}/references/verification-overrides.md +0 -0
- /package/{get-shit-done → gsd-core}/references/verify-mvp-mode.md +0 -0
- /package/{get-shit-done → gsd-core}/references/workstream-flag.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/AI-SPEC.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/DEBUG.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/SECURITY.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/UAT.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/UI-SPEC.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/VALIDATION.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/claude-md.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/codebase/architecture.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/codebase/concerns.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/codebase/conventions.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/codebase/integrations.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/codebase/stack.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/codebase/testing.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/config.json +0 -0
- /package/{get-shit-done → gsd-core}/templates/context.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/continue-here.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/debug-subagent-prompt.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/dev-preferences.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/discovery.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/discussion-log.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/milestone-archive.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/milestone.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/planner-subagent-prompt.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/project.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/requirements.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/research-project/ARCHITECTURE.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/research-project/FEATURES.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/research-project/PITFALLS.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/research-project/STACK.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/research-project/SUMMARY.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/research.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/retrospective.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/roadmap.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/spec.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/state.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/summary-complex.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/summary-minimal.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/summary-standard.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/summary.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/user-profile.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/user-setup.md +0 -0
- /package/{get-shit-done → gsd-core}/templates/verification-report.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/analyze-dependencies.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/discuss-phase/modes/all.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/discuss-phase/modes/analyze.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/discuss-phase/modes/batch.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/discuss-phase/modes/default.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/discuss-phase/modes/text.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/discuss-phase/templates/checkpoint.json +0 -0
- /package/{get-shit-done → gsd-core}/workflows/discuss-phase/templates/context.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/discuss-phase/templates/discussion-log.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/discuss-phase-power.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/execute-phase/steps/per-plan-worktree-gate.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/fast.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/help/modes/brief.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/help/modes/topic.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/help.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/inbox.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/list-phase-assumptions.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/node-repair.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/note.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/pr-branch.md +0 -0
- /package/{get-shit-done → gsd-core}/workflows/session-report.md +0 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Skill Surface Budget Module — single source of truth for which skills/agents
|
|
4
|
+
* are written to the runtime config dirs (ADR-0011).
|
|
5
|
+
*
|
|
6
|
+
* ADR-457 build-at-publish: the hand-written bin/lib/install-profiles.cjs collapsed
|
|
7
|
+
* to a TypeScript source of truth. Behaviour is preserved byte-for-behaviour
|
|
8
|
+
* from the prior hand-written .cjs; only types are added.
|
|
9
|
+
*/
|
|
10
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
+
};
|
|
13
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
14
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
15
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
16
|
+
const shell_command_projection_cjs_1 = require("./shell-command-projection.cjs");
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
// Profile definitions
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
/**
|
|
21
|
+
* PROFILES maps profile name → base skill set (array) or '*' sentinel (full).
|
|
22
|
+
*
|
|
23
|
+
* The effective set for any profile is CLOSURE(base, requires: manifest).
|
|
24
|
+
* standard is a superset of core; full is the identity (all skills).
|
|
25
|
+
*
|
|
26
|
+
* Composition: --profile=core,audit resolves to union(closure(core), closure(audit)).
|
|
27
|
+
*/
|
|
28
|
+
const PROFILES = Object.freeze({
|
|
29
|
+
core: Object.freeze([
|
|
30
|
+
'new-project',
|
|
31
|
+
'discuss-phase',
|
|
32
|
+
'plan-phase',
|
|
33
|
+
'execute-phase',
|
|
34
|
+
'phase',
|
|
35
|
+
'help',
|
|
36
|
+
'update',
|
|
37
|
+
'surface',
|
|
38
|
+
]),
|
|
39
|
+
standard: Object.freeze([
|
|
40
|
+
// Core loop
|
|
41
|
+
'new-project',
|
|
42
|
+
'discuss-phase',
|
|
43
|
+
'plan-phase',
|
|
44
|
+
'execute-phase',
|
|
45
|
+
'help',
|
|
46
|
+
'update',
|
|
47
|
+
'surface',
|
|
48
|
+
// Phase management (hot nodes from audit — required by 38+ skills)
|
|
49
|
+
'phase',
|
|
50
|
+
'review',
|
|
51
|
+
'config',
|
|
52
|
+
'progress',
|
|
53
|
+
// Workspace / state
|
|
54
|
+
'resume-work',
|
|
55
|
+
'pause-work',
|
|
56
|
+
'workspace',
|
|
57
|
+
]),
|
|
58
|
+
full: '*',
|
|
59
|
+
});
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
// Manifest parsing
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
/**
|
|
64
|
+
* Parse the requires: field from YAML frontmatter.
|
|
65
|
+
* Handles: "requires: [a, b, c]" (flow style) and absent field.
|
|
66
|
+
* Returns string[] — empty array if no requires: field.
|
|
67
|
+
*
|
|
68
|
+
* No external YAML parser dependency — hand-parse the single line
|
|
69
|
+
* since GSD enforces flow-style arrays for requires:.
|
|
70
|
+
*/
|
|
71
|
+
function parseRequires(content) {
|
|
72
|
+
const fmMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/m);
|
|
73
|
+
if (!fmMatch)
|
|
74
|
+
return [];
|
|
75
|
+
const fm = fmMatch[1];
|
|
76
|
+
const line = fm.match(/^requires:\s*(.+)$/m);
|
|
77
|
+
if (!line)
|
|
78
|
+
return [];
|
|
79
|
+
const val = line[1].trim();
|
|
80
|
+
// Flow-style: [a, b, c]
|
|
81
|
+
if (val.startsWith('[') && val.endsWith(']')) {
|
|
82
|
+
const inner = val.slice(1, -1).trim();
|
|
83
|
+
if (!inner)
|
|
84
|
+
return [];
|
|
85
|
+
return inner.split(',').map((s) => s.trim()).filter(Boolean);
|
|
86
|
+
}
|
|
87
|
+
// Single bare value (not currently used, but defensive)
|
|
88
|
+
return val ? [val] : [];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Parse agent references from a skill file's body text.
|
|
92
|
+
* Scans the full content for `gsd-<stem>` patterns that correspond to
|
|
93
|
+
* real agent files. Returns all unique `gsd-*` stems found in the body.
|
|
94
|
+
*
|
|
95
|
+
* The caller is responsible for filtering by which agents actually exist —
|
|
96
|
+
* this function returns all syntactically valid `gsd-*` matches.
|
|
97
|
+
*/
|
|
98
|
+
function parseCallsAgents(content) {
|
|
99
|
+
// Match word-boundary gsd-<stem> patterns; stems are lowercase letters and hyphens.
|
|
100
|
+
// We use a regex that matches `gsd-` followed by one or more lowercase-alpha-or-hyphen chars.
|
|
101
|
+
// This catches `gsd-planner`, `gsd-plan-checker`, etc. in prose and code.
|
|
102
|
+
const matches = content.match(/\bgsd-[a-z][a-z-]*/g);
|
|
103
|
+
if (!matches)
|
|
104
|
+
return [];
|
|
105
|
+
// Deduplicate
|
|
106
|
+
return [...new Set(matches)];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Load the requires: dependency graph from a commands/gsd directory.
|
|
110
|
+
* Also derives calls_agents for each skill by scanning the body text for
|
|
111
|
+
* `gsd-*` agent name references. Agent stems are stored under the special
|
|
112
|
+
* key `_calls_agents_<stem>` so they don't conflict with skill stems.
|
|
113
|
+
*/
|
|
114
|
+
function loadSkillsManifest(commandsDir) {
|
|
115
|
+
const manifest = new Map();
|
|
116
|
+
if (!node_fs_1.default.existsSync(commandsDir))
|
|
117
|
+
return manifest;
|
|
118
|
+
const entries = node_fs_1.default.readdirSync(commandsDir, { withFileTypes: true });
|
|
119
|
+
for (const entry of entries) {
|
|
120
|
+
if (!entry.isFile())
|
|
121
|
+
continue;
|
|
122
|
+
if (!entry.name.endsWith('.md'))
|
|
123
|
+
continue;
|
|
124
|
+
const stem = entry.name.slice(0, -3);
|
|
125
|
+
try {
|
|
126
|
+
const content = node_fs_1.default.readFileSync(node_path_1.default.join(commandsDir, entry.name), 'utf8');
|
|
127
|
+
manifest.set(stem, parseRequires(content));
|
|
128
|
+
// Derive agent references from body text
|
|
129
|
+
const agentRefs = parseCallsAgents(content);
|
|
130
|
+
manifest.set(`_calls_agents_${stem}`, agentRefs);
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
manifest.set(stem, []);
|
|
134
|
+
manifest.set(`_calls_agents_${stem}`, []);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return manifest;
|
|
138
|
+
}
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
// Profile resolution (transitive closure)
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
/**
|
|
143
|
+
* Compute the transitive closure of a set of skill stems over the manifest.
|
|
144
|
+
*/
|
|
145
|
+
function computeClosure(base, manifest) {
|
|
146
|
+
const closed = new Set(base);
|
|
147
|
+
const queue = [...closed];
|
|
148
|
+
while (queue.length > 0) {
|
|
149
|
+
const stem = queue.pop();
|
|
150
|
+
const deps = manifest.get(stem) || [];
|
|
151
|
+
for (const dep of deps) {
|
|
152
|
+
if (!closed.has(dep)) {
|
|
153
|
+
closed.add(dep);
|
|
154
|
+
queue.push(dep);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return closed;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Resolve a profile (or composed profiles) to a typed result object.
|
|
162
|
+
*/
|
|
163
|
+
function resolveProfile({ modes, manifest, _profilesOverride } = {}) {
|
|
164
|
+
const profiles = _profilesOverride || PROFILES;
|
|
165
|
+
const activeModes = (modes && modes.length > 0) ? modes : ['full'];
|
|
166
|
+
const normalizedModes = activeModes
|
|
167
|
+
.flatMap((mode) => String(mode).split(','))
|
|
168
|
+
.map((mode) => mode.trim())
|
|
169
|
+
.filter(Boolean);
|
|
170
|
+
const modesToResolve = normalizedModes.length > 0 ? normalizedModes : ['full'];
|
|
171
|
+
// If any mode is 'full', the result is the full sentinel
|
|
172
|
+
if (modesToResolve.includes('full')) {
|
|
173
|
+
return { name: 'full', skills: '*', agents: new Set() };
|
|
174
|
+
}
|
|
175
|
+
const validModes = modesToResolve.filter((mode) => Object.prototype.hasOwnProperty.call(profiles, mode));
|
|
176
|
+
if (validModes.length === 0) {
|
|
177
|
+
// Invalid/corrupt marker fallback: avoid empty installs by defaulting to full.
|
|
178
|
+
return { name: 'full', skills: '*', agents: new Set() };
|
|
179
|
+
}
|
|
180
|
+
const man = manifest || new Map();
|
|
181
|
+
const unionSkills = new Set();
|
|
182
|
+
for (const mode of validModes) {
|
|
183
|
+
const base = profiles[mode];
|
|
184
|
+
if (base === '*') {
|
|
185
|
+
// This profile is full — sentinel short-circuit
|
|
186
|
+
return { name: 'full', skills: '*', agents: new Set() };
|
|
187
|
+
}
|
|
188
|
+
const closure = computeClosure(base, man);
|
|
189
|
+
for (const s of closure)
|
|
190
|
+
unionSkills.add(s);
|
|
191
|
+
}
|
|
192
|
+
// Derive agents: union of all agent names referenced in the body text of
|
|
193
|
+
// every skill in unionSkills. Agent names are stored in the manifest under
|
|
194
|
+
// _calls_agents_<stem> keys (populated by loadSkillsManifest).
|
|
195
|
+
const unionAgents = new Set();
|
|
196
|
+
for (const skillStem of unionSkills) {
|
|
197
|
+
const agentRefs = man.get(`_calls_agents_${skillStem}`) || [];
|
|
198
|
+
for (const agentStem of agentRefs) {
|
|
199
|
+
unionAgents.add(agentStem);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const name = validModes.length === 1 ? validModes[0] : validModes.join(',');
|
|
203
|
+
return { name, skills: unionSkills, agents: unionAgents };
|
|
204
|
+
}
|
|
205
|
+
// ---------------------------------------------------------------------------
|
|
206
|
+
// Staging — skills
|
|
207
|
+
// ---------------------------------------------------------------------------
|
|
208
|
+
// Stage dirs created during this process — cleaned up on exit.
|
|
209
|
+
// 13 runtime dispatch sites in install.js can each call stageSkillsForMode,
|
|
210
|
+
// so accumulating them in a single set avoids leaks without forcing each
|
|
211
|
+
// site to track its own cleanup handle.
|
|
212
|
+
const STAGED_DIRS = new Set();
|
|
213
|
+
let exitHandlerRegistered = false;
|
|
214
|
+
function cleanupStagedSkills() {
|
|
215
|
+
for (const dir of STAGED_DIRS) {
|
|
216
|
+
try {
|
|
217
|
+
node_fs_1.default.rmSync(dir, { recursive: true, force: true });
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
// Best-effort: missing dir or permission error shouldn't crash a
|
|
221
|
+
// successful install. The OS reaps tmpdir eventually.
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
STAGED_DIRS.clear();
|
|
225
|
+
}
|
|
226
|
+
// Signals we register a cleanup handler for in addition to the natural
|
|
227
|
+
// 'exit' event. `process.on('exit')` does NOT fire on these — an installer
|
|
228
|
+
// is exactly the kind of process users abort mid-run, so without explicit
|
|
229
|
+
// signal handling Ctrl+C would leave staged tmp dirs behind.
|
|
230
|
+
const CLEANUP_SIGNALS = ['SIGINT', 'SIGTERM', 'SIGHUP'];
|
|
231
|
+
function ensureExitCleanup() {
|
|
232
|
+
if (exitHandlerRegistered)
|
|
233
|
+
return;
|
|
234
|
+
exitHandlerRegistered = true;
|
|
235
|
+
process.on('exit', cleanupStagedSkills);
|
|
236
|
+
for (const sig of CLEANUP_SIGNALS) {
|
|
237
|
+
// `once` so re-raising the signal below isn't intercepted by us a second
|
|
238
|
+
// time — the OS-default handler should take over and exit with the right
|
|
239
|
+
// status code (so CI sees the abort, scripts see 130 for SIGINT, etc.).
|
|
240
|
+
process.once(sig, () => {
|
|
241
|
+
cleanupStagedSkills();
|
|
242
|
+
process.kill(process.pid, sig);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Stage a filtered copy of commands/gsd for a resolved profile.
|
|
248
|
+
* In full mode (skills === '*') returns srcDir unchanged (no-op).
|
|
249
|
+
*/
|
|
250
|
+
function stageSkillsForProfile(srcDir, resolvedProfile) {
|
|
251
|
+
if (resolvedProfile.skills === '*')
|
|
252
|
+
return srcDir;
|
|
253
|
+
if (!node_fs_1.default.existsSync(srcDir))
|
|
254
|
+
return srcDir;
|
|
255
|
+
const stageDir = node_fs_1.default.mkdtempSync(node_path_1.default.join(node_os_1.default.tmpdir(), 'gsd-profile-skills-'));
|
|
256
|
+
try {
|
|
257
|
+
const entries = node_fs_1.default.readdirSync(srcDir, { withFileTypes: true });
|
|
258
|
+
for (const entry of entries) {
|
|
259
|
+
if (!entry.isFile())
|
|
260
|
+
continue;
|
|
261
|
+
if (!entry.name.endsWith('.md'))
|
|
262
|
+
continue;
|
|
263
|
+
const stem = entry.name.slice(0, -3);
|
|
264
|
+
if (!(resolvedProfile.skills).has(stem))
|
|
265
|
+
continue;
|
|
266
|
+
node_fs_1.default.copyFileSync(node_path_1.default.join(srcDir, entry.name), node_path_1.default.join(stageDir, entry.name));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
catch (err) {
|
|
270
|
+
try {
|
|
271
|
+
node_fs_1.default.rmSync(stageDir, { recursive: true, force: true });
|
|
272
|
+
}
|
|
273
|
+
catch { /* best-effort */ }
|
|
274
|
+
throw err;
|
|
275
|
+
}
|
|
276
|
+
STAGED_DIRS.add(stageDir);
|
|
277
|
+
ensureExitCleanup();
|
|
278
|
+
return stageDir;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Stage a filtered copy of the agents directory for a resolved profile.
|
|
282
|
+
* For 'full', returns srcAgentsDir unchanged.
|
|
283
|
+
* For tiered profiles, copies only agents whose full stem (e.g. 'gsd-planner')
|
|
284
|
+
* is in resolvedProfile.agents — which is populated by resolveProfile() from
|
|
285
|
+
* the _calls_agents_* entries in the manifest.
|
|
286
|
+
*/
|
|
287
|
+
function stageAgentsForProfile(srcAgentsDir, resolvedProfile) {
|
|
288
|
+
if (resolvedProfile.skills === '*')
|
|
289
|
+
return srcAgentsDir;
|
|
290
|
+
if (!node_fs_1.default.existsSync(srcAgentsDir))
|
|
291
|
+
return srcAgentsDir;
|
|
292
|
+
const stageDir = node_fs_1.default.mkdtempSync(node_path_1.default.join(node_os_1.default.tmpdir(), 'gsd-profile-agents-'));
|
|
293
|
+
try {
|
|
294
|
+
if (resolvedProfile.agents instanceof Set && resolvedProfile.agents.size > 0) {
|
|
295
|
+
const entries = node_fs_1.default.readdirSync(srcAgentsDir, { withFileTypes: true });
|
|
296
|
+
for (const entry of entries) {
|
|
297
|
+
if (!entry.isFile())
|
|
298
|
+
continue;
|
|
299
|
+
if (!entry.name.endsWith('.md'))
|
|
300
|
+
continue;
|
|
301
|
+
// Agent stem is the full filename without extension, e.g. "gsd-planner"
|
|
302
|
+
const stem = entry.name.slice(0, -3);
|
|
303
|
+
if (!resolvedProfile.agents.has(stem))
|
|
304
|
+
continue;
|
|
305
|
+
node_fs_1.default.copyFileSync(node_path_1.default.join(srcAgentsDir, entry.name), node_path_1.default.join(stageDir, entry.name));
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
// If agents is empty Set, we produce an empty stageDir (no agents for this profile)
|
|
309
|
+
}
|
|
310
|
+
catch (err) {
|
|
311
|
+
try {
|
|
312
|
+
node_fs_1.default.rmSync(stageDir, { recursive: true, force: true });
|
|
313
|
+
}
|
|
314
|
+
catch { /* best-effort */ }
|
|
315
|
+
throw err;
|
|
316
|
+
}
|
|
317
|
+
STAGED_DIRS.add(stageDir);
|
|
318
|
+
ensureExitCleanup();
|
|
319
|
+
return stageDir;
|
|
320
|
+
}
|
|
321
|
+
function stageSkillsForRuntimeAsSkills(srcCommandsDir, resolvedProfile, converter, prefix) {
|
|
322
|
+
if (!node_fs_1.default.existsSync(srcCommandsDir))
|
|
323
|
+
return srcCommandsDir;
|
|
324
|
+
const stageDir = node_fs_1.default.mkdtempSync(node_path_1.default.join(node_os_1.default.tmpdir(), 'gsd-profile-runtime-skills-'));
|
|
325
|
+
try {
|
|
326
|
+
const entries = node_fs_1.default.readdirSync(srcCommandsDir, { withFileTypes: true });
|
|
327
|
+
for (const entry of entries) {
|
|
328
|
+
if (!entry.isFile())
|
|
329
|
+
continue;
|
|
330
|
+
if (!entry.name.endsWith('.md'))
|
|
331
|
+
continue;
|
|
332
|
+
const stem = entry.name.slice(0, -3);
|
|
333
|
+
if (resolvedProfile.skills !== '*' && !(resolvedProfile.skills).has(stem))
|
|
334
|
+
continue;
|
|
335
|
+
const content = node_fs_1.default.readFileSync(node_path_1.default.join(srcCommandsDir, entry.name), 'utf8');
|
|
336
|
+
const skillName = `${prefix}${stem}`;
|
|
337
|
+
const converted = converter(content, skillName);
|
|
338
|
+
const destDir = node_path_1.default.join(stageDir, skillName);
|
|
339
|
+
node_fs_1.default.mkdirSync(destDir, { recursive: true });
|
|
340
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(destDir, 'SKILL.md'), converted);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
catch (err) {
|
|
344
|
+
try {
|
|
345
|
+
node_fs_1.default.rmSync(stageDir, { recursive: true, force: true });
|
|
346
|
+
}
|
|
347
|
+
catch { /* best-effort */ }
|
|
348
|
+
throw err;
|
|
349
|
+
}
|
|
350
|
+
STAGED_DIRS.add(stageDir);
|
|
351
|
+
ensureExitCleanup();
|
|
352
|
+
return stageDir;
|
|
353
|
+
}
|
|
354
|
+
// ---------------------------------------------------------------------------
|
|
355
|
+
// Profile marker persistence
|
|
356
|
+
// ---------------------------------------------------------------------------
|
|
357
|
+
const PROFILE_MARKER_NAME = '.gsd-profile';
|
|
358
|
+
/**
|
|
359
|
+
* Read the active profile from a runtime config directory.
|
|
360
|
+
*/
|
|
361
|
+
function readActiveProfile(runtimeConfigDir) {
|
|
362
|
+
const markerPath = node_path_1.default.join(runtimeConfigDir, PROFILE_MARKER_NAME);
|
|
363
|
+
try {
|
|
364
|
+
const raw = node_fs_1.default.readFileSync(markerPath, 'utf8').trim();
|
|
365
|
+
if (!raw)
|
|
366
|
+
return null;
|
|
367
|
+
// Validate that it looks like a profile name (alphanumeric + hyphens + commas)
|
|
368
|
+
if (!/^[a-z0-9,_-]+$/i.test(raw))
|
|
369
|
+
return null;
|
|
370
|
+
return raw;
|
|
371
|
+
}
|
|
372
|
+
catch {
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Persist the active profile to a runtime config directory.
|
|
378
|
+
*/
|
|
379
|
+
function writeActiveProfile(runtimeConfigDir, profileName) {
|
|
380
|
+
(0, shell_command_projection_cjs_1.platformWriteSync)(node_path_1.default.join(runtimeConfigDir, PROFILE_MARKER_NAME), profileName + '\n');
|
|
381
|
+
}
|
|
382
|
+
// ---------------------------------------------------------------------------
|
|
383
|
+
// Profile resolution helpers for install / update flows
|
|
384
|
+
// ---------------------------------------------------------------------------
|
|
385
|
+
/**
|
|
386
|
+
* Rank ordering for profiles (lower index = more restrictive / smaller skill set).
|
|
387
|
+
* Unknown profiles default to the permissive end (treated as 'full').
|
|
388
|
+
*/
|
|
389
|
+
const PROFILE_RANK = Object.freeze(['core', 'standard', 'full']);
|
|
390
|
+
/**
|
|
391
|
+
* Given an array of profile names (one per runtime), return the most-restrictive
|
|
392
|
+
* profile — i.e. the one with the smallest effective skill set.
|
|
393
|
+
*
|
|
394
|
+
* Ordering (most to least restrictive): core < standard < full.
|
|
395
|
+
* Composed profiles (e.g. 'core,audit') and unknown profiles are treated as
|
|
396
|
+
* 'full' for this comparison.
|
|
397
|
+
*/
|
|
398
|
+
function mostRestrictiveProfile(profileNames) {
|
|
399
|
+
if (!profileNames || profileNames.length === 0)
|
|
400
|
+
return 'full';
|
|
401
|
+
// Initialize with the least-restrictive rank (one past the end of PROFILE_RANK)
|
|
402
|
+
let bestRank = PROFILE_RANK.length;
|
|
403
|
+
let bestName = 'full';
|
|
404
|
+
for (const name of profileNames) {
|
|
405
|
+
const rank = PROFILE_RANK.indexOf(name);
|
|
406
|
+
// Unknown/composed profiles are treated as the permissive 'full' rank.
|
|
407
|
+
const effectiveRank = rank === -1 ? PROFILE_RANK.indexOf('full') : rank;
|
|
408
|
+
if (effectiveRank < bestRank) {
|
|
409
|
+
bestRank = effectiveRank;
|
|
410
|
+
bestName = rank === -1 ? 'full' : name;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return bestName;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Resolve the effective profile name for an install() run.
|
|
417
|
+
*
|
|
418
|
+
* Priority:
|
|
419
|
+
* 1. Explicit flag (requestedProfileName != null) → use it as-is.
|
|
420
|
+
* 2. Marker exists in targetDir and is not 'full' → use marker.
|
|
421
|
+
* 3. Else → 'full' (back-compat for fresh non-interactive installs).
|
|
422
|
+
*/
|
|
423
|
+
function resolveEffectiveProfile({ requestedProfileName, targetDir }) {
|
|
424
|
+
// 1. Explicit flag overrides everything
|
|
425
|
+
if (requestedProfileName != null)
|
|
426
|
+
return requestedProfileName;
|
|
427
|
+
// 2. Marker-driven (gsd update path)
|
|
428
|
+
const marker = readActiveProfile(targetDir);
|
|
429
|
+
if (marker && marker !== 'full')
|
|
430
|
+
return marker;
|
|
431
|
+
// 3. Default
|
|
432
|
+
return 'full';
|
|
433
|
+
}
|
|
434
|
+
// ---------------------------------------------------------------------------
|
|
435
|
+
// Back-compat shims (deprecated — use profile-based API instead)
|
|
436
|
+
// ---------------------------------------------------------------------------
|
|
437
|
+
/**
|
|
438
|
+
* @deprecated Use PROFILES.core instead.
|
|
439
|
+
* Preserved for callers in install.js and existing tests.
|
|
440
|
+
*/
|
|
441
|
+
const MINIMAL_SKILL_ALLOWLIST = Object.freeze([...PROFILES.core]);
|
|
442
|
+
const MINIMAL_ALLOWLIST_SET = new Set(MINIMAL_SKILL_ALLOWLIST);
|
|
443
|
+
/**
|
|
444
|
+
* @deprecated Use resolveProfile({ modes: ['core'] }) instead.
|
|
445
|
+
*/
|
|
446
|
+
function isMinimalMode(mode) {
|
|
447
|
+
return mode === 'minimal' || mode === 'core-only';
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Overloaded for back-compat.
|
|
451
|
+
* - If resolvedProfileOrMode is a string: legacy mode check (full/minimal)
|
|
452
|
+
* - If resolvedProfileOrMode is an object with .skills: new profile API
|
|
453
|
+
*
|
|
454
|
+
* @deprecated String-mode form; use resolvedProfile object form instead.
|
|
455
|
+
*/
|
|
456
|
+
function shouldInstallSkill(skillBaseName, resolvedProfileOrMode) {
|
|
457
|
+
if (typeof resolvedProfileOrMode === 'object' && resolvedProfileOrMode !== null) {
|
|
458
|
+
const { skills } = resolvedProfileOrMode;
|
|
459
|
+
if (skills === '*')
|
|
460
|
+
return true;
|
|
461
|
+
return skills instanceof Set && skills.has(skillBaseName);
|
|
462
|
+
}
|
|
463
|
+
// Legacy string mode
|
|
464
|
+
const mode = resolvedProfileOrMode;
|
|
465
|
+
if (!isMinimalMode(mode))
|
|
466
|
+
return true;
|
|
467
|
+
return MINIMAL_ALLOWLIST_SET.has(skillBaseName);
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Stage a filtered copy of the source commands/gsd directory.
|
|
471
|
+
* Back-compat wrapper: maps 'minimal' → core profile, 'full' → full.
|
|
472
|
+
*
|
|
473
|
+
* @deprecated Use stageSkillsForProfile with a resolved profile instead.
|
|
474
|
+
*/
|
|
475
|
+
function stageSkillsForMode(srcDir, mode) {
|
|
476
|
+
if (!isMinimalMode(mode))
|
|
477
|
+
return srcDir;
|
|
478
|
+
if (!node_fs_1.default.existsSync(srcDir))
|
|
479
|
+
return srcDir;
|
|
480
|
+
const stageDir = node_fs_1.default.mkdtempSync(node_path_1.default.join(node_os_1.default.tmpdir(), 'gsd-minimal-skills-'));
|
|
481
|
+
try {
|
|
482
|
+
const entries = node_fs_1.default.readdirSync(srcDir, { withFileTypes: true });
|
|
483
|
+
for (const entry of entries) {
|
|
484
|
+
if (!entry.isFile())
|
|
485
|
+
continue;
|
|
486
|
+
if (!entry.name.endsWith('.md'))
|
|
487
|
+
continue;
|
|
488
|
+
const baseName = entry.name.replace(/\.md$/, '');
|
|
489
|
+
if (!shouldInstallSkill(baseName, mode))
|
|
490
|
+
continue;
|
|
491
|
+
node_fs_1.default.copyFileSync(node_path_1.default.join(srcDir, entry.name), node_path_1.default.join(stageDir, entry.name));
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
catch (err) {
|
|
495
|
+
try {
|
|
496
|
+
node_fs_1.default.rmSync(stageDir, { recursive: true, force: true });
|
|
497
|
+
}
|
|
498
|
+
catch { /* best-effort */ }
|
|
499
|
+
throw err;
|
|
500
|
+
}
|
|
501
|
+
STAGED_DIRS.add(stageDir);
|
|
502
|
+
ensureExitCleanup();
|
|
503
|
+
return stageDir;
|
|
504
|
+
}
|
|
505
|
+
module.exports = {
|
|
506
|
+
// New profile API (ADR-0011)
|
|
507
|
+
PROFILES,
|
|
508
|
+
PROFILE_RANK,
|
|
509
|
+
loadSkillsManifest,
|
|
510
|
+
resolveProfile,
|
|
511
|
+
resolveEffectiveProfile,
|
|
512
|
+
mostRestrictiveProfile,
|
|
513
|
+
stageSkillsForProfile,
|
|
514
|
+
stageAgentsForProfile,
|
|
515
|
+
stageSkillsForRuntimeAsSkills,
|
|
516
|
+
STAGED_DIRS,
|
|
517
|
+
readActiveProfile,
|
|
518
|
+
writeActiveProfile,
|
|
519
|
+
// Shared internals
|
|
520
|
+
cleanupStagedSkills,
|
|
521
|
+
// Back-compat / deprecated
|
|
522
|
+
MINIMAL_SKILL_ALLOWLIST,
|
|
523
|
+
isMinimalMode,
|
|
524
|
+
shouldInstallSkill,
|
|
525
|
+
stageSkillsForMode,
|
|
526
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Installer Migration Authoring — validation helpers for installer migration records and actions.
|
|
4
|
+
*
|
|
5
|
+
* ADR-457 build-at-publish: the hand-written
|
|
6
|
+
* bin/lib/installer-migration-authoring.cjs collapsed to a TypeScript source
|
|
7
|
+
* of truth. Behaviour is preserved byte-for-behaviour from the prior
|
|
8
|
+
* hand-written .cjs; only types are added.
|
|
9
|
+
*/
|
|
10
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.validateInstallerMigrationRecord = validateInstallerMigrationRecord;
|
|
15
|
+
exports.validateInstallerMigrationActions = validateInstallerMigrationActions;
|
|
16
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
17
|
+
function getStr(record, field) {
|
|
18
|
+
const v = record[field];
|
|
19
|
+
return typeof v === 'string' ? v : '';
|
|
20
|
+
}
|
|
21
|
+
function requireNonEmptyString(record, field, source) {
|
|
22
|
+
const v = record[field];
|
|
23
|
+
if (typeof v !== 'string' || v.trim() === '') {
|
|
24
|
+
throw new Error(`migration record must include a non-empty ${field}: ${source}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function isNonEmptyStringArray(arr) {
|
|
28
|
+
return Array.isArray(arr) && arr.length > 0 && arr.every((v) => typeof v === 'string' && v.trim() !== '');
|
|
29
|
+
}
|
|
30
|
+
function validateStringArray(record, field, source) {
|
|
31
|
+
if (record[field] === undefined)
|
|
32
|
+
return;
|
|
33
|
+
if (!isNonEmptyStringArray(record[field])) {
|
|
34
|
+
throw new Error(`migration record ${field} must be a non-empty string array when provided: ${source}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function requireStringArray(record, field, source) {
|
|
38
|
+
if (!isNonEmptyStringArray(record[field])) {
|
|
39
|
+
throw new Error(`migration record ${field} must be a non-empty string array: ${source}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function recordSource(record, fallback) {
|
|
43
|
+
const id = getStr(record, 'id');
|
|
44
|
+
return fallback ?? (id.trim() ? id : '<unknown>');
|
|
45
|
+
}
|
|
46
|
+
function actionSource(migration, action) {
|
|
47
|
+
const migrationId = getStr(migration, 'id') || '<unknown>';
|
|
48
|
+
const relPath = getStr(action, 'relPath') || '<unknown>';
|
|
49
|
+
return `${migrationId} ${relPath}`;
|
|
50
|
+
}
|
|
51
|
+
function requireActionEvidence(action, field, migration) {
|
|
52
|
+
const v = action[field];
|
|
53
|
+
if (typeof v !== 'string' || v.trim() === '') {
|
|
54
|
+
throw new Error(`migration action ${getStr(action, 'type')} must include ${field}: ${actionSource(migration, action)}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function validateSafeRelPath(relPath, migration, actionType) {
|
|
58
|
+
const source = actionSource(migration, { relPath });
|
|
59
|
+
const normalized = relPath.replace(/\\/g, '/');
|
|
60
|
+
if (node_path_1.default.isAbsolute(normalized) || node_path_1.default.win32.isAbsolute(normalized)) {
|
|
61
|
+
throw new Error(`migration action ${actionType} relPath must stay inside configDir: ${source}`);
|
|
62
|
+
}
|
|
63
|
+
const segments = normalized.split('/');
|
|
64
|
+
if (segments.some((segment) => segment === '' || segment === '.' || segment === '..')) {
|
|
65
|
+
throw new Error(`migration action ${actionType} relPath must stay inside configDir: ${source}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function validateInstallerMigrationRecord(record, source) {
|
|
69
|
+
const rec = record;
|
|
70
|
+
const displaySource = recordSource(rec, source);
|
|
71
|
+
if (!record || typeof record !== 'object') {
|
|
72
|
+
throw new Error(`migration record must export an object: ${displaySource}`);
|
|
73
|
+
}
|
|
74
|
+
// Authoring contract follows docs/installer-migrations.md#authoring-workflow
|
|
75
|
+
// and docs/adr/0008-installer-migration-module.md#decision.
|
|
76
|
+
requireNonEmptyString(rec, 'id', displaySource);
|
|
77
|
+
requireNonEmptyString(rec, 'title', displaySource);
|
|
78
|
+
requireNonEmptyString(rec, 'description', displaySource);
|
|
79
|
+
requireNonEmptyString(rec, 'introducedIn', displaySource);
|
|
80
|
+
if (typeof rec['destructive'] !== 'boolean') {
|
|
81
|
+
throw new Error(`migration record must declare destructive as a boolean: ${displaySource}`);
|
|
82
|
+
}
|
|
83
|
+
validateStringArray(rec, 'runtimes', displaySource);
|
|
84
|
+
requireStringArray(rec, 'scopes', displaySource);
|
|
85
|
+
if (typeof rec['plan'] !== 'function') {
|
|
86
|
+
throw new Error(`migration record must include a plan function: ${displaySource}`);
|
|
87
|
+
}
|
|
88
|
+
return rec;
|
|
89
|
+
}
|
|
90
|
+
function validateInstallerMigrationActions(actions, migration) {
|
|
91
|
+
if (!Array.isArray(actions)) {
|
|
92
|
+
throw new Error(`migration ${getStr(migration, 'id')} plan must return an array`);
|
|
93
|
+
}
|
|
94
|
+
for (const action of actions) {
|
|
95
|
+
if (!action || typeof action !== 'object') {
|
|
96
|
+
throw new Error(`migration action must be an object: ${getStr(migration, 'id')}`);
|
|
97
|
+
}
|
|
98
|
+
const act = action;
|
|
99
|
+
const actType = getStr(act, 'type');
|
|
100
|
+
const actRelPath = getStr(act, 'relPath');
|
|
101
|
+
if (!actType || actType.trim() === '') {
|
|
102
|
+
throw new Error(`migration action must include a non-empty type: ${getStr(migration, 'id')}`);
|
|
103
|
+
}
|
|
104
|
+
if (!actRelPath || actRelPath.trim() === '') {
|
|
105
|
+
throw new Error(`migration action ${actType} must include a non-empty relPath: ${getStr(migration, 'id')}`);
|
|
106
|
+
}
|
|
107
|
+
validateSafeRelPath(actRelPath, migration, actType);
|
|
108
|
+
// Ownership and runtime-contract evidence are required by
|
|
109
|
+
// docs/installer-migrations.md#action-types and
|
|
110
|
+
// docs/adr/0008-installer-migration-module.md#runtime-contract-decision.
|
|
111
|
+
if (actType === 'remove-managed' || actType === 'rewrite-json') {
|
|
112
|
+
requireActionEvidence(act, 'ownershipEvidence', migration);
|
|
113
|
+
}
|
|
114
|
+
if (actType === 'rewrite-json') {
|
|
115
|
+
const rc = getStr(migration, 'runtimeContract');
|
|
116
|
+
if (!rc || rc.trim() === '') {
|
|
117
|
+
throw new Error(`migration action rewrite-json requires migration runtimeContract: ${actionSource(migration, act)}`);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return actions;
|
|
122
|
+
}
|