@codyswann/lisa 7.1.4 → 8.0.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/all/copy-overwrite/scripts/check-npm-publish-landed.mjs +0 -2
- package/all/copy-overwrite/scripts/lib/push-timing.mjs +3 -6
- package/all/copy-overwrite/scripts/lisa-enforcement-fallback.sh +31 -32
- package/all/copy-overwrite/scripts/lisa-hooks/block-managed-file-edits.sh +201 -20
- package/all/copy-overwrite/scripts/npm-updater-helper-graph.json +3 -2
- package/dist/cli/admit-cmd.d.ts.map +1 -1
- package/dist/cli/admit-cmd.js +16 -10
- package/dist/cli/admit-cmd.js.map +1 -1
- package/dist/cli/apply.d.ts.map +1 -1
- package/dist/cli/apply.js +2 -2
- package/dist/cli/apply.js.map +1 -1
- package/dist/cli/check-cmd.d.ts.map +1 -1
- package/dist/cli/check-cmd.js +8 -4
- package/dist/cli/check-cmd.js.map +1 -1
- package/dist/cli/doctor-coderabbit.js +2 -2
- package/dist/cli/doctor-coderabbit.js.map +1 -1
- package/dist/cli/doctor-readiness-supply-chain-python.d.ts +5 -1
- package/dist/cli/doctor-readiness-supply-chain-python.d.ts.map +1 -1
- package/dist/cli/doctor-readiness-supply-chain-python.js +44 -10
- package/dist/cli/doctor-readiness-supply-chain-python.js.map +1 -1
- package/dist/cli/doctor-readiness.js +2 -2
- package/dist/cli/doctor-readiness.js.map +1 -1
- package/dist/cli/doctor-worker-journey.js +2 -2
- package/dist/cli/doctor-worker-journey.js.map +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +7 -4
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/file-upstream-cmd.d.ts.map +1 -1
- package/dist/cli/file-upstream-cmd.js +20 -25
- package/dist/cli/file-upstream-cmd.js.map +1 -1
- package/dist/cli/gh-cli.d.ts +2 -2
- package/dist/cli/gh-cli.d.ts.map +1 -1
- package/dist/cli/gh-cli.js +13 -6
- package/dist/cli/gh-cli.js.map +1 -1
- package/dist/cli/health-cmd.d.ts.map +1 -1
- package/dist/cli/health-cmd.js +7 -19
- package/dist/cli/health-cmd.js.map +1 -1
- package/dist/cli/lisa-test-run-jest-merge.js +5 -5
- package/dist/cli/lisa-test-run-jest-merge.js.map +1 -1
- package/dist/cli/lisa-test-run.js +8 -4
- package/dist/cli/lisa-test-run.js.map +1 -1
- package/dist/cli/pr-landing.js +2 -2
- package/dist/cli/pr-landing.js.map +1 -1
- package/dist/cli/update-check.d.ts.map +1 -1
- package/dist/cli/update-check.js +7 -4
- package/dist/cli/update-check.js.map +1 -1
- package/dist/cli/update-cmd.d.ts.map +1 -1
- package/dist/cli/update-cmd.js +7 -4
- package/dist/cli/update-cmd.js.map +1 -1
- package/dist/cli/worktree-ownership.d.ts.map +1 -1
- package/dist/cli/worktree-ownership.js +3 -3
- package/dist/cli/worktree-ownership.js.map +1 -1
- package/dist/codex/hooks-catalog.d.ts +151 -0
- package/dist/codex/hooks-catalog.d.ts.map +1 -0
- package/dist/codex/hooks-catalog.js +315 -0
- package/dist/codex/hooks-catalog.js.map +1 -0
- package/dist/codex/hooks-compatibility.d.ts +14 -0
- package/dist/codex/hooks-compatibility.d.ts.map +1 -0
- package/dist/codex/hooks-compatibility.js +196 -0
- package/dist/codex/hooks-compatibility.js.map +1 -0
- package/dist/codex/hooks-installer.d.ts +2 -49
- package/dist/codex/hooks-installer.d.ts.map +1 -1
- package/dist/codex/hooks-installer.js +5 -546
- package/dist/codex/hooks-installer.js.map +1 -1
- package/dist/codex/hooks-source-links.d.ts +11 -0
- package/dist/codex/hooks-source-links.d.ts.map +1 -0
- package/dist/codex/hooks-source-links.js +74 -0
- package/dist/codex/hooks-source-links.js.map +1 -0
- package/dist/codex/scripts/block-migration-edits.sh +2 -2
- package/dist/codex/scripts/block-suppress-directives.sh +3 -3
- package/dist/codex/scripts/format-on-edit.sh +2 -2
- package/dist/codex/scripts/lint-on-edit.sh +2 -2
- package/dist/codex/scripts/lisa-edit-gate.sh +19 -15
- package/dist/codex/scripts/rubocop-on-edit.sh +2 -2
- package/dist/codex/scripts/sg-scan-on-edit.sh +2 -2
- package/dist/configs/coverage-scope.d.ts +0 -23
- package/dist/configs/coverage-scope.d.ts.map +1 -1
- package/dist/configs/coverage-scope.js +2 -3
- package/dist/configs/coverage-scope.js.map +1 -1
- package/dist/configs/eslint/base.d.ts +2 -113
- package/dist/configs/eslint/base.d.ts.map +1 -1
- package/dist/configs/eslint/base.js +2 -165
- package/dist/configs/eslint/base.js.map +1 -1
- package/dist/configs/eslint/cdk.d.ts.map +1 -1
- package/dist/configs/eslint/cdk.js +82 -66
- package/dist/configs/eslint/cdk.js.map +1 -1
- package/dist/configs/eslint/expo-overrides.d.ts +103 -0
- package/dist/configs/eslint/expo-overrides.d.ts.map +1 -0
- package/dist/configs/eslint/expo-overrides.js +187 -0
- package/dist/configs/eslint/expo-overrides.js.map +1 -0
- package/dist/configs/eslint/expo.d.ts +2 -7
- package/dist/configs/eslint/expo.d.ts.map +1 -1
- package/dist/configs/eslint/expo.js +186 -258
- package/dist/configs/eslint/expo.js.map +1 -1
- package/dist/configs/eslint/nestjs.d.ts.map +1 -1
- package/dist/configs/eslint/nestjs.js +86 -70
- package/dist/configs/eslint/nestjs.js.map +1 -1
- package/dist/configs/eslint/process-environment-bans.d.ts +41 -0
- package/dist/configs/eslint/process-environment-bans.d.ts.map +1 -0
- package/dist/configs/eslint/process-environment-bans.js +50 -0
- package/dist/configs/eslint/process-environment-bans.js.map +1 -0
- package/dist/configs/eslint/shared-rules.d.ts +130 -0
- package/dist/configs/eslint/shared-rules.d.ts.map +1 -0
- package/dist/configs/eslint/shared-rules.js +233 -0
- package/dist/configs/eslint/shared-rules.js.map +1 -0
- package/dist/configs/eslint/typescript.d.ts.map +1 -1
- package/dist/configs/eslint/typescript.js +2 -4
- package/dist/configs/eslint/typescript.js.map +1 -1
- package/dist/configs/vitest/base.d.ts +2 -2
- package/dist/configs/vitest/base.d.ts.map +1 -1
- package/dist/configs/vitest/base.js +5 -5
- package/dist/configs/vitest/base.js.map +1 -1
- package/dist/configs/vitest/coverage-reports-directory.d.ts.map +1 -1
- package/dist/configs/vitest/coverage-reports-directory.js +3 -2
- package/dist/configs/vitest/coverage-reports-directory.js.map +1 -1
- package/dist/configs/vitest/refusal-announcement.js +2 -2
- package/dist/configs/vitest/refusal-announcement.js.map +1 -1
- package/dist/core/admission-lock.js +2 -3
- package/dist/core/admission-lock.js.map +1 -1
- package/dist/core/admission-state.d.ts.map +1 -1
- package/dist/core/admission-state.js +11 -5
- package/dist/core/admission-state.js.map +1 -1
- package/dist/core/admission.d.ts.map +1 -1
- package/dist/core/admission.js +2 -2
- package/dist/core/admission.js.map +1 -1
- package/dist/core/bootstrap-environment.d.ts.map +1 -1
- package/dist/core/bootstrap-environment.js +8 -5
- package/dist/core/bootstrap-environment.js.map +1 -1
- package/dist/core/downstream-names.d.ts.map +1 -1
- package/dist/core/downstream-names.js +48 -47
- package/dist/core/downstream-names.js.map +1 -1
- package/dist/core/effectiveness-store.d.ts.map +1 -1
- package/dist/core/effectiveness-store.js +3 -5
- package/dist/core/effectiveness-store.js.map +1 -1
- package/dist/core/gate-declaration-drift.d.ts.map +1 -1
- package/dist/core/gate-declaration-drift.js +46 -27
- package/dist/core/gate-declaration-drift.js.map +1 -1
- package/dist/core/kane-cli-process.d.ts.map +1 -1
- package/dist/core/kane-cli-process.js +46 -33
- package/dist/core/kane-cli-process.js.map +1 -1
- package/dist/core/kane-cli.d.ts.map +1 -1
- package/dist/core/kane-cli.js +3 -4
- package/dist/core/kane-cli.js.map +1 -1
- package/dist/core/lisa-agent-emit-extra.d.ts +75 -0
- package/dist/core/lisa-agent-emit-extra.d.ts.map +1 -0
- package/dist/core/lisa-agent-emit-extra.js +231 -0
- package/dist/core/lisa-agent-emit-extra.js.map +1 -0
- package/dist/core/lisa-agent-emit.d.ts +79 -0
- package/dist/core/lisa-agent-emit.d.ts.map +1 -0
- package/dist/core/lisa-agent-emit.js +224 -0
- package/dist/core/lisa-agent-emit.js.map +1 -0
- package/dist/core/lisa-deletions.d.ts +116 -0
- package/dist/core/lisa-deletions.d.ts.map +1 -0
- package/dist/core/lisa-deletions.js +316 -0
- package/dist/core/lisa-deletions.js.map +1 -0
- package/dist/core/lisa-file-results.d.ts +58 -0
- package/dist/core/lisa-file-results.d.ts.map +1 -0
- package/dist/core/lisa-file-results.js +173 -0
- package/dist/core/lisa-file-results.js.map +1 -0
- package/dist/core/lisa-maintenance.d.ts +139 -0
- package/dist/core/lisa-maintenance.d.ts.map +1 -0
- package/dist/core/lisa-maintenance.js +324 -0
- package/dist/core/lisa-maintenance.js.map +1 -0
- package/dist/core/lisa-owned-hash-ledger.d.ts +7 -5
- package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
- package/dist/core/lisa-owned-hash-ledger.js +44 -6036
- package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
- package/dist/core/lisa-owned-hash-ledger.json +6021 -0
- package/dist/core/lisa-plugin-sync.d.ts +96 -0
- package/dist/core/lisa-plugin-sync.d.ts.map +1 -0
- package/dist/core/lisa-plugin-sync.js +216 -0
- package/dist/core/lisa-plugin-sync.js.map +1 -0
- package/dist/core/lisa-plugins.d.ts +42 -0
- package/dist/core/lisa-plugins.d.ts.map +1 -0
- package/dist/core/lisa-plugins.js +155 -0
- package/dist/core/lisa-plugins.js.map +1 -0
- package/dist/core/lisa-state.d.ts +202 -0
- package/dist/core/lisa-state.d.ts.map +1 -0
- package/dist/core/lisa-state.js +205 -0
- package/dist/core/lisa-state.js.map +1 -0
- package/dist/core/lisa-summary-stats.d.ts +74 -0
- package/dist/core/lisa-summary-stats.d.ts.map +1 -0
- package/dist/core/lisa-summary-stats.js +189 -0
- package/dist/core/lisa-summary-stats.js.map +1 -0
- package/dist/core/lisa-summary.d.ts +34 -0
- package/dist/core/lisa-summary.d.ts.map +1 -0
- package/dist/core/lisa-summary.js +144 -0
- package/dist/core/lisa-summary.js.map +1 -0
- package/dist/core/lisa-templates.d.ts +98 -0
- package/dist/core/lisa-templates.d.ts.map +1 -0
- package/dist/core/lisa-templates.js +251 -0
- package/dist/core/lisa-templates.js.map +1 -0
- package/dist/core/lisa.d.ts +14 -903
- package/dist/core/lisa.d.ts.map +1 -1
- package/dist/core/lisa.js +30 -2275
- package/dist/core/lisa.js.map +1 -1
- package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
- package/dist/core/plugin-command.d.ts.map +1 -1
- package/dist/core/plugin-command.js +117 -61
- package/dist/core/plugin-command.js.map +1 -1
- package/dist/core/template-ownership.d.ts.map +1 -1
- package/dist/core/template-ownership.js +0 -1
- package/dist/core/template-ownership.js.map +1 -1
- package/dist/core/upstream-attribution-body.d.ts +4 -11
- package/dist/core/upstream-attribution-body.d.ts.map +1 -1
- package/dist/core/upstream-attribution-body.js +61 -373
- package/dist/core/upstream-attribution-body.js.map +1 -1
- package/dist/core/upstream-attribution-fields.d.ts +40 -0
- package/dist/core/upstream-attribution-fields.d.ts.map +1 -0
- package/dist/core/upstream-attribution-fields.js +167 -0
- package/dist/core/upstream-attribution-fields.js.map +1 -0
- package/dist/core/upstream-attribution-files.d.ts +15 -0
- package/dist/core/upstream-attribution-files.d.ts.map +1 -0
- package/dist/core/upstream-attribution-files.js +156 -0
- package/dist/core/upstream-attribution-files.js.map +1 -0
- package/dist/core/upstream-attribution-guards.d.ts +80 -0
- package/dist/core/upstream-attribution-guards.d.ts.map +1 -0
- package/dist/core/upstream-attribution-guards.js +284 -0
- package/dist/core/upstream-attribution-guards.js.map +1 -0
- package/dist/core/upstream-evidence-manifest.d.ts +1 -1
- package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
- package/dist/core/upstream-evidence-manifest.js +67 -30420
- package/dist/core/upstream-evidence-manifest.js.map +1 -1
- package/dist/core/upstream-evidence-manifest.json +30518 -0
- package/dist/health/agentic-contract.d.ts +94 -0
- package/dist/health/agentic-contract.d.ts.map +1 -0
- package/dist/health/agentic-contract.js +2 -0
- package/dist/health/agentic-contract.js.map +1 -0
- package/dist/health/agentic-evidence.d.ts +16 -0
- package/dist/health/agentic-evidence.d.ts.map +1 -0
- package/dist/health/agentic-evidence.js +213 -0
- package/dist/health/agentic-evidence.js.map +1 -0
- package/dist/health/agentic.d.ts +11 -74
- package/dist/health/agentic.d.ts.map +1 -1
- package/dist/health/agentic.js +42 -216
- package/dist/health/agentic.js.map +1 -1
- package/dist/health/deadline.d.ts +4 -1
- package/dist/health/deadline.d.ts.map +1 -1
- package/dist/health/deadline.js +4 -3
- package/dist/health/deadline.js.map +1 -1
- package/dist/health/deterministic-inputs.d.ts.map +1 -1
- package/dist/health/deterministic-inputs.js +3 -11
- package/dist/health/deterministic-inputs.js.map +1 -1
- package/dist/health/deterministic-probes.d.ts +52 -0
- package/dist/health/deterministic-probes.d.ts.map +1 -0
- package/dist/health/deterministic-probes.js +142 -0
- package/dist/health/deterministic-probes.js.map +1 -0
- package/dist/health/deterministic.d.ts +2 -25
- package/dist/health/deterministic.d.ts.map +1 -1
- package/dist/health/deterministic.js +14 -106
- package/dist/health/deterministic.js.map +1 -1
- package/dist/health/finding-utils.d.ts +4 -3
- package/dist/health/finding-utils.d.ts.map +1 -1
- package/dist/health/finding-utils.js +4 -4
- package/dist/health/finding-utils.js.map +1 -1
- package/dist/health/governance-probes.d.ts +29 -24
- package/dist/health/governance-probes.d.ts.map +1 -1
- package/dist/health/governance-probes.js +29 -25
- package/dist/health/governance-probes.js.map +1 -1
- package/dist/health/hook-inspection.d.ts +4 -3
- package/dist/health/hook-inspection.d.ts.map +1 -1
- package/dist/health/hook-inspection.js +17 -11
- package/dist/health/hook-inspection.js.map +1 -1
- package/dist/health/plugin-inspection.d.ts +6 -4
- package/dist/health/plugin-inspection.d.ts.map +1 -1
- package/dist/health/plugin-inspection.js +10 -9
- package/dist/health/plugin-inspection.js.map +1 -1
- package/dist/health/prepare.js +24 -8
- package/dist/health/prepare.js.map +1 -1
- package/dist/health/project-probes.d.ts +14 -7
- package/dist/health/project-probes.d.ts.map +1 -1
- package/dist/health/project-probes.js +14 -9
- package/dist/health/project-probes.js.map +1 -1
- package/dist/health/ruleset-compare.d.ts +30 -0
- package/dist/health/ruleset-compare.d.ts.map +1 -0
- package/dist/health/ruleset-compare.js +143 -0
- package/dist/health/ruleset-compare.js.map +1 -0
- package/dist/health/ruleset-config-checks.d.ts +66 -0
- package/dist/health/ruleset-config-checks.d.ts.map +1 -0
- package/dist/health/ruleset-config-checks.js +190 -0
- package/dist/health/ruleset-config-checks.js.map +1 -0
- package/dist/health/ruleset-expected.d.ts +39 -0
- package/dist/health/ruleset-expected.d.ts.map +1 -0
- package/dist/health/ruleset-expected.js +181 -0
- package/dist/health/ruleset-expected.js.map +1 -0
- package/dist/health/ruleset-gh.d.ts +85 -0
- package/dist/health/ruleset-gh.d.ts.map +1 -0
- package/dist/health/ruleset-gh.js +177 -0
- package/dist/health/ruleset-gh.js.map +1 -0
- package/dist/health/ruleset-inspection.d.ts +13 -117
- package/dist/health/ruleset-inspection.d.ts.map +1 -1
- package/dist/health/ruleset-inspection.js +8 -738
- package/dist/health/ruleset-inspection.js.map +1 -1
- package/dist/health/ruleset-normalize.d.ts +32 -0
- package/dist/health/ruleset-normalize.d.ts.map +1 -0
- package/dist/health/ruleset-normalize.js +160 -0
- package/dist/health/ruleset-normalize.js.map +1 -0
- package/dist/health/template-compose.d.ts +9 -0
- package/dist/health/template-compose.d.ts.map +1 -0
- package/dist/health/template-compose.js +105 -0
- package/dist/health/template-compose.js.map +1 -0
- package/dist/health/template-inspection.d.ts +5 -52
- package/dist/health/template-inspection.d.ts.map +1 -1
- package/dist/health/template-inspection.js +13 -435
- package/dist/health/template-inspection.js.map +1 -1
- package/dist/health/template-plan.d.ts +33 -0
- package/dist/health/template-plan.d.ts.map +1 -0
- package/dist/health/template-plan.js +154 -0
- package/dist/health/template-plan.js.map +1 -0
- package/dist/health/template-shape.d.ts +19 -0
- package/dist/health/template-shape.d.ts.map +1 -0
- package/dist/health/template-shape.js +122 -0
- package/dist/health/template-shape.js.map +1 -0
- package/dist/health/workflow-excerpt.d.ts +15 -0
- package/dist/health/workflow-excerpt.d.ts.map +1 -0
- package/dist/health/workflow-excerpt.js +88 -0
- package/dist/health/workflow-excerpt.js.map +1 -0
- package/dist/health/workflow-inputs-inspection.d.ts +16 -0
- package/dist/health/workflow-inputs-inspection.d.ts.map +1 -0
- package/dist/health/workflow-inputs-inspection.js +116 -0
- package/dist/health/workflow-inputs-inspection.js.map +1 -0
- package/dist/opencode/plugin-templates/block-managed-file-edits.sh +201 -20
- package/dist/standards/capture.d.ts.map +1 -1
- package/dist/standards/capture.js +73 -25
- package/dist/standards/capture.js.map +1 -1
- package/dist/standards/contract.d.ts.map +1 -1
- package/dist/standards/contract.js +26 -9
- package/dist/standards/contract.js.map +1 -1
- package/dist/standards/git-state.d.ts.map +1 -1
- package/dist/standards/git-state.js +2 -2
- package/dist/standards/git-state.js.map +1 -1
- package/dist/standards/registry-checks.d.ts +34 -0
- package/dist/standards/registry-checks.d.ts.map +1 -0
- package/dist/standards/registry-checks.js +137 -0
- package/dist/standards/registry-checks.js.map +1 -0
- package/dist/standards/registry.d.ts +3 -13
- package/dist/standards/registry.d.ts.map +1 -1
- package/dist/standards/registry.js +105 -194
- package/dist/standards/registry.js.map +1 -1
- package/dist/standards/storage.js +8 -10
- package/dist/standards/storage.js.map +1 -1
- package/dist/strategies/deduplicate-arrays.d.ts +18 -0
- package/dist/strategies/deduplicate-arrays.d.ts.map +1 -0
- package/dist/strategies/deduplicate-arrays.js +25 -0
- package/dist/strategies/deduplicate-arrays.js.map +1 -0
- package/dist/strategies/package-lisa-detect.d.ts +10 -0
- package/dist/strategies/package-lisa-detect.d.ts.map +1 -0
- package/dist/strategies/package-lisa-detect.js +178 -0
- package/dist/strategies/package-lisa-detect.js.map +1 -0
- package/dist/strategies/package-lisa-direct-floors.d.ts +16 -0
- package/dist/strategies/package-lisa-direct-floors.d.ts.map +1 -0
- package/dist/strategies/package-lisa-direct-floors.js +37 -0
- package/dist/strategies/package-lisa-direct-floors.js.map +1 -0
- package/dist/strategies/package-lisa-host-pins.d.ts +43 -0
- package/dist/strategies/package-lisa-host-pins.d.ts.map +1 -0
- package/dist/strategies/package-lisa-host-pins.js +254 -0
- package/dist/strategies/package-lisa-host-pins.js.map +1 -0
- package/dist/strategies/package-lisa-manifest-guards.d.ts +59 -0
- package/dist/strategies/package-lisa-manifest-guards.d.ts.map +1 -0
- package/dist/strategies/package-lisa-manifest-guards.js +234 -0
- package/dist/strategies/package-lisa-manifest-guards.js.map +1 -0
- package/dist/strategies/package-lisa-pin-alignment.d.ts +34 -0
- package/dist/strategies/package-lisa-pin-alignment.d.ts.map +1 -0
- package/dist/strategies/package-lisa-pin-alignment.js +106 -0
- package/dist/strategies/package-lisa-pin-alignment.js.map +1 -0
- package/dist/strategies/package-lisa-script-notes.d.ts +19 -0
- package/dist/strategies/package-lisa-script-notes.d.ts.map +1 -0
- package/dist/strategies/package-lisa-script-notes.js +145 -0
- package/dist/strategies/package-lisa-script-notes.js.map +1 -0
- package/dist/strategies/package-lisa-template-apply.d.ts +53 -0
- package/dist/strategies/package-lisa-template-apply.d.ts.map +1 -0
- package/dist/strategies/package-lisa-template-apply.js +216 -0
- package/dist/strategies/package-lisa-template-apply.js.map +1 -0
- package/dist/strategies/package-lisa-template-merge.d.ts +42 -0
- package/dist/strategies/package-lisa-template-merge.d.ts.map +1 -0
- package/dist/strategies/package-lisa-template-merge.js +202 -0
- package/dist/strategies/package-lisa-template-merge.js.map +1 -0
- package/dist/strategies/package-lisa-types.d.ts +5 -0
- package/dist/strategies/package-lisa-types.d.ts.map +1 -1
- package/dist/strategies/package-lisa.d.ts +1 -195
- package/dist/strategies/package-lisa.d.ts.map +1 -1
- package/dist/strategies/package-lisa.js +27 -1333
- package/dist/strategies/package-lisa.js.map +1 -1
- package/dist/strategies/tagged-merge-sections.d.ts +68 -0
- package/dist/strategies/tagged-merge-sections.d.ts.map +1 -0
- package/dist/strategies/tagged-merge-sections.js +113 -0
- package/dist/strategies/tagged-merge-sections.js.map +1 -0
- package/dist/strategies/tagged-merge.d.ts +1 -90
- package/dist/strategies/tagged-merge.d.ts.map +1 -1
- package/dist/strategies/tagged-merge.js +19 -190
- package/dist/strategies/tagged-merge.js.map +1 -1
- package/dist/utils/bounded-stream.d.ts +30 -0
- package/dist/utils/bounded-stream.d.ts.map +1 -0
- package/dist/utils/bounded-stream.js +63 -0
- package/dist/utils/bounded-stream.js.map +1 -0
- package/dist/utils/fibonacci.d.ts +3 -3
- package/dist/utils/fibonacci.d.ts.map +1 -1
- package/dist/utils/fibonacci.js +48 -10
- package/dist/utils/fibonacci.js.map +1 -1
- package/dist/utils/memo.d.ts +25 -0
- package/dist/utils/memo.d.ts.map +1 -0
- package/dist/utils/memo.js +32 -0
- package/dist/utils/memo.js.map +1 -0
- package/dist/utils/postinstall-trampoline.d.ts.map +1 -1
- package/dist/utils/postinstall-trampoline.js +3 -20
- package/dist/utils/postinstall-trampoline.js.map +1 -1
- package/dist/utils/process-environment.d.ts +42 -0
- package/dist/utils/process-environment.d.ts.map +1 -0
- package/dist/utils/process-environment.js +52 -0
- package/dist/utils/process-environment.js.map +1 -0
- package/dist/utils/resolve-executable.d.ts +89 -0
- package/dist/utils/resolve-executable.d.ts.map +1 -0
- package/dist/utils/resolve-executable.js +224 -0
- package/dist/utils/resolve-executable.js.map +1 -0
- package/dist/utils/shell-command-line.d.ts +9 -0
- package/dist/utils/shell-command-line.d.ts.map +1 -0
- package/dist/utils/shell-command-line.js +43 -0
- package/dist/utils/shell-command-line.js.map +1 -0
- package/dist/utils/usage-accounting-totals.d.ts +19 -0
- package/dist/utils/usage-accounting-totals.d.ts.map +1 -0
- package/dist/utils/usage-accounting-totals.js +145 -0
- package/dist/utils/usage-accounting-totals.js.map +1 -0
- package/dist/utils/usage-accounting.d.ts +2 -14
- package/dist/utils/usage-accounting.d.ts.map +1 -1
- package/dist/utils/usage-accounting.js +2 -169
- package/dist/utils/usage-accounting.js.map +1 -1
- package/eslint-plugin-code-organization/__tests__/enforce-statement-order-react-violations.test.js +213 -0
- package/eslint-plugin-code-organization/__tests__/enforce-statement-order-valid.test.js +251 -0
- package/eslint-plugin-code-organization/__tests__/enforce-statement-order-violations.test.js +222 -0
- package/eslint-plugin-code-organization/__tests__/statement-order-tester.js +42 -0
- package/eslint-plugin-code-organization/rules/enforce-statement-order.js +6 -8
- package/expo/copy-overwrite/jest.setup.ts +11 -10
- package/expo/create-only/scripts/zap-baseline.sh +6 -18
- package/harper-fabric/create-only/scripts/zap-baseline.sh +7 -9
- package/nestjs/create-only/scripts/zap-baseline.sh +6 -7
- package/package.json +4 -4
- package/phaser/copy-overwrite/.husky/pre-push.verify +2 -0
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/skills/lisa-setup-remote-env/assets/session-start.sh +18 -5
- package/plugins/lisa/hooks/block-managed-file-edits.sh +201 -20
- package/plugins/lisa/hooks/block-masked-exit-status.sh +1 -1
- package/plugins/lisa/hooks/block-no-verify.agy.sh +1 -1
- package/plugins/lisa/hooks/enforce-verification-gate.sh +1 -2
- package/plugins/lisa/hooks/ticket-sync-reminder.sh +2 -17
- package/plugins/lisa/hooks/track-plan-sessions.sh +7 -131
- package/plugins/lisa/scripts/remote-agent-aws-setup.sh +3 -1
- package/plugins/lisa/skills/lisa-setup-remote-env/assets/session-start.sh +18 -5
- package/plugins/lisa-agy/hooks/block-managed-file-edits.sh +201 -20
- package/plugins/lisa-agy/hooks/block-no-verify.agy.sh +1 -1
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-agy/scripts/remote-agent-aws-setup.sh +3 -1
- package/plugins/lisa-agy/skills/lisa-setup-remote-env/assets/session-start.sh +18 -5
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/hooks/block-managed-file-edits.sh +201 -20
- package/plugins/lisa-copilot/hooks/block-masked-exit-status.sh +1 -1
- package/plugins/lisa-copilot/hooks/enforce-verification-gate.sh +1 -2
- package/plugins/lisa-copilot/scripts/remote-agent-aws-setup.sh +3 -1
- package/plugins/lisa-copilot/skills/lisa-setup-remote-env/assets/session-start.sh +18 -5
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/hooks/block-managed-file-edits.sh +201 -20
- package/plugins/lisa-cursor/hooks/block-masked-exit-status.sh +1 -1
- package/plugins/lisa-cursor/hooks/enforce-verification-gate.sh +1 -2
- package/plugins/lisa-cursor/scripts/remote-agent-aws-setup.sh +3 -1
- package/plugins/lisa-cursor/skills/lisa-setup-remote-env/assets/session-start.sh +18 -5
- package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-devin/hooks/block-managed-file-edits.sh +201 -20
- package/plugins/lisa-devin/hooks/block-masked-exit-status.sh +1 -1
- package/plugins/lisa-devin/hooks/enforce-verification-gate.sh +1 -2
- package/plugins/lisa-devin/scripts/remote-agent-aws-setup.sh +3 -1
- package/plugins/lisa-devin/skills/lisa-setup-remote-env/assets/session-start.sh +18 -5
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/skills/building-native-ui/references/webgpu-three.md +19 -9
- package/plugins/lisa-expo/.codex-plugin/skills/expo-tailwind-setup/SKILL.md +15 -4
- package/plugins/lisa-expo/skills/building-native-ui/references/webgpu-three.md +19 -9
- package/plugins/lisa-expo/skills/expo-tailwind-setup/SKILL.md +15 -4
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-agy/skills/building-native-ui/references/webgpu-three.md +19 -9
- package/plugins/lisa-expo-agy/skills/expo-tailwind-setup/SKILL.md +15 -4
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/skills/building-native-ui/references/webgpu-three.md +19 -9
- package/plugins/lisa-expo-copilot/skills/expo-tailwind-setup/SKILL.md +15 -4
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/skills/building-native-ui/references/webgpu-three.md +19 -9
- package/plugins/lisa-expo-cursor/skills/expo-tailwind-setup/SKILL.md +15 -4
- package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-devin/skills/building-native-ui/references/webgpu-three.md +19 -9
- package/plugins/lisa-expo-devin/skills/expo-tailwind-setup/SKILL.md +15 -4
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/hooks/block-generated-artifact-edits.sh +196 -11
- package/plugins/lisa-harper-fabric/hooks/enforce-config-extensions.sh +1 -1
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/hooks/block-generated-artifact-edits.sh +196 -11
- package/plugins/lisa-harper-fabric-copilot/hooks/enforce-config-extensions.sh +1 -1
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/hooks/block-generated-artifact-edits.sh +196 -11
- package/plugins/lisa-harper-fabric-cursor/hooks/enforce-config-extensions.sh +1 -1
- package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-devin/hooks/block-generated-artifact-edits.sh +196 -11
- package/plugins/lisa-harper-fabric-devin/hooks/enforce-config-extensions.sh +1 -1
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/skills/nestjs-rules/SKILL.md +39 -26
- package/plugins/lisa-nestjs/.codex-plugin/skills/typeorm-patterns/references/observability-patterns.md +18 -58
- package/plugins/lisa-nestjs/hooks/block-migration-edits.sh +1 -1
- package/plugins/lisa-nestjs/hooks/lisa-edit-gate.sh +19 -15
- package/plugins/lisa-nestjs/skills/nestjs-rules/SKILL.md +39 -26
- package/plugins/lisa-nestjs/skills/typeorm-patterns/references/observability-patterns.md +18 -58
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/skills/nestjs-rules/SKILL.md +39 -26
- package/plugins/lisa-nestjs-agy/skills/typeorm-patterns/references/observability-patterns.md +18 -58
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/hooks/block-migration-edits.sh +1 -1
- package/plugins/lisa-nestjs-copilot/hooks/lisa-edit-gate.sh +19 -15
- package/plugins/lisa-nestjs-copilot/skills/nestjs-rules/SKILL.md +39 -26
- package/plugins/lisa-nestjs-copilot/skills/typeorm-patterns/references/observability-patterns.md +18 -58
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/hooks/block-migration-edits.sh +1 -1
- package/plugins/lisa-nestjs-cursor/hooks/lisa-edit-gate.sh +19 -15
- package/plugins/lisa-nestjs-cursor/skills/nestjs-rules/SKILL.md +39 -26
- package/plugins/lisa-nestjs-cursor/skills/typeorm-patterns/references/observability-patterns.md +18 -58
- package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-devin/hooks/block-migration-edits.sh +1 -1
- package/plugins/lisa-nestjs-devin/hooks/lisa-edit-gate.sh +19 -15
- package/plugins/lisa-nestjs-devin/skills/nestjs-rules/SKILL.md +39 -26
- package/plugins/lisa-nestjs-devin/skills/typeorm-patterns/references/observability-patterns.md +18 -58
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/hooks/lisa-edit-gate.sh +19 -15
- package/plugins/lisa-rails/hooks/rubocop-on-edit.sh +2 -2
- package/plugins/lisa-rails/hooks/sg-scan-on-edit.sh +3 -3
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/hooks/lisa-edit-gate.sh +19 -15
- package/plugins/lisa-rails-copilot/hooks/rubocop-on-edit.sh +2 -2
- package/plugins/lisa-rails-copilot/hooks/sg-scan-on-edit.sh +3 -3
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/hooks/lisa-edit-gate.sh +19 -15
- package/plugins/lisa-rails-cursor/hooks/rubocop-on-edit.sh +2 -2
- package/plugins/lisa-rails-cursor/hooks/sg-scan-on-edit.sh +3 -3
- package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-devin/hooks/lisa-edit-gate.sh +19 -15
- package/plugins/lisa-rails-devin/hooks/rubocop-on-edit.sh +2 -2
- package/plugins/lisa-rails-devin/hooks/sg-scan-on-edit.sh +3 -3
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/hooks/block-suppress-directives.sh +2 -2
- package/plugins/lisa-typescript/hooks/format-on-edit.sh +2 -2
- package/plugins/lisa-typescript/hooks/lint-on-edit.sh +2 -2
- package/plugins/lisa-typescript/hooks/lisa-edit-gate.sh +19 -15
- package/plugins/lisa-typescript/hooks/sg-scan-on-edit.sh +3 -3
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/hooks/block-suppress-directives.sh +2 -2
- package/plugins/lisa-typescript-copilot/hooks/format-on-edit.sh +2 -2
- package/plugins/lisa-typescript-copilot/hooks/lint-on-edit.sh +2 -2
- package/plugins/lisa-typescript-copilot/hooks/lisa-edit-gate.sh +19 -15
- package/plugins/lisa-typescript-copilot/hooks/sg-scan-on-edit.sh +3 -3
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/hooks/block-suppress-directives.sh +2 -2
- package/plugins/lisa-typescript-cursor/hooks/format-on-edit.sh +2 -2
- package/plugins/lisa-typescript-cursor/hooks/lint-on-edit.sh +2 -2
- package/plugins/lisa-typescript-cursor/hooks/lisa-edit-gate.sh +19 -15
- package/plugins/lisa-typescript-cursor/hooks/sg-scan-on-edit.sh +3 -3
- package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-devin/hooks/block-suppress-directives.sh +2 -2
- package/plugins/lisa-typescript-devin/hooks/format-on-edit.sh +2 -2
- package/plugins/lisa-typescript-devin/hooks/lint-on-edit.sh +2 -2
- package/plugins/lisa-typescript-devin/hooks/lisa-edit-gate.sh +19 -15
- package/plugins/lisa-typescript-devin/hooks/sg-scan-on-edit.sh +3 -3
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
- package/plugins/src/base/hooks/block-managed-file-edits.sh +201 -20
- package/plugins/src/base/hooks/block-masked-exit-status.sh +1 -1
- package/plugins/src/base/hooks/block-no-verify.agy.sh +1 -1
- package/plugins/src/base/hooks/enforce-verification-gate.sh +1 -2
- package/plugins/src/base/hooks/ticket-sync-reminder.sh +2 -17
- package/plugins/src/base/hooks/track-plan-sessions.sh +7 -131
- package/plugins/src/base/scripts/remote-agent-aws-setup.sh +3 -1
- package/plugins/src/base/skills/lisa-setup-remote-env/assets/session-start.sh +18 -5
- package/plugins/src/expo/skills/building-native-ui/references/webgpu-three.md +19 -9
- package/plugins/src/expo/skills/expo-tailwind-setup/SKILL.md +15 -4
- package/plugins/src/harper-fabric/hooks/block-generated-artifact-edits.sh +196 -11
- package/plugins/src/harper-fabric/hooks/enforce-config-extensions.sh +1 -1
- package/plugins/src/nestjs/hooks/block-migration-edits.sh +1 -1
- package/plugins/src/nestjs/hooks/lisa-edit-gate.sh +19 -15
- package/plugins/src/nestjs/skills/nestjs-rules/SKILL.md +39 -26
- package/plugins/src/nestjs/skills/typeorm-patterns/references/observability-patterns.md +18 -58
- package/plugins/src/rails/hooks/lisa-edit-gate.sh +19 -15
- package/plugins/src/rails/hooks/rubocop-on-edit.sh +2 -2
- package/plugins/src/rails/hooks/sg-scan-on-edit.sh +3 -3
- package/plugins/src/typescript/hooks/block-suppress-directives.sh +2 -2
- package/plugins/src/typescript/hooks/format-on-edit.sh +2 -2
- package/plugins/src/typescript/hooks/lint-on-edit.sh +2 -2
- package/plugins/src/typescript/hooks/lisa-edit-gate.sh +19 -15
- package/plugins/src/typescript/hooks/sg-scan-on-edit.sh +3 -3
- package/scripts/build-plugins.sh +1 -1
- package/scripts/check-derived-artifacts.mjs +2 -2
- package/scripts/check-generated-artifact-merge-coverage.mjs +45 -4
- package/scripts/check-orphan-test-processes.mjs +0 -1
- package/scripts/check-self-dependency-pin.mjs +0 -2
- package/scripts/claude-remote-setup.sh +12 -7
- package/scripts/cleanup-amplify-branches.sh +0 -1
- package/scripts/generate-export-surface.mjs +131 -61
- package/scripts/generate-lisa-owned-hash-ledger.mjs +87 -102
- package/scripts/generate-upstream-evidence-manifest.mjs +56 -49
- package/scripts/github-status-check.sh +5 -25
- package/scripts/install-claude-plugins.sh +10 -8
- package/scripts/lib/merge-generated-json.mjs +274 -0
- package/scripts/lib/upstream-manifest-staleness.mjs +38 -34
- package/scripts/lib/upstream-public-commits.mjs +35 -18
- package/scripts/lisa-commit-and-pr-local.sh +1 -1
- package/scripts/lisa-enforcement-fallback.sh +31 -32
- package/scripts/lisa-github-environments.sh +5 -1
- package/scripts/lisa-github-repo-settings.sh +5 -1
- package/scripts/lisa-github-repo-setup.sh +1 -2
- package/scripts/lisa-github-rulesets.sh +8 -8
- package/scripts/lisa-remote-env/session-start.sh +18 -5
- package/scripts/lisa-rollback-release.mjs +0 -2
- package/scripts/lisa-update-local.sh +1 -1
- package/scripts/merge-generated-artifact.mjs +18 -6
- package/scripts/raise-self-dependency-pin.mjs +0 -2
- package/scripts/run-artifact-checks.mjs +1 -1
- package/scripts/verify-packed-learnings-contract.mjs +36 -3
- package/scripts/verify-self-pin-raise.mjs +0 -2
- package/typescript/copy-contents/.husky/commit-msg +8 -2
- package/typescript/copy-contents/.husky/post-checkout +2 -0
- package/typescript/copy-contents/.husky/post-merge +2 -0
- package/typescript/copy-contents/.husky/pre-commit +10 -3
- package/typescript/copy-contents/.husky/pre-push +29 -16
- package/typescript/copy-contents/.husky/prepare-commit-msg +2 -0
- package/typescript/create-only/.husky/pre-push.local +2 -0
- package/eslint-plugin-code-organization/__tests__/enforce-statement-order.test.js +0 -643
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
/* eslint-disable max-lines -- Package merge strategy is intentionally comprehensive */
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
-
import * as fse from "fs-extra";
|
|
4
1
|
import path from "node:path";
|
|
5
|
-
import
|
|
2
|
+
import * as fse from "fs-extra";
|
|
6
3
|
import { isPostinstallSafeApply } from "../core/apply-mode.js";
|
|
7
|
-
import {
|
|
8
|
-
import { PROJECT_TYPE_HIERARCHY, PROJECT_TYPE_ORDER } from "../core/config.js";
|
|
9
|
-
import { ensureParentDir } from "../utils/file-operations.js";
|
|
10
|
-
import { readJson, writeJson, deepMerge, readJsonOrNull, } from "../utils/json-utils.js";
|
|
11
|
-
import { JsonMergeError } from "../errors/index.js";
|
|
12
|
-
import { raiseDirectRangesToLisaFloors } from "../core/direct-range-raise.js";
|
|
13
|
-
import { applyDirectMinimums, describeDirectMinimumConflicts, describeDirectMinimumRaise, } from "../core/direct-minimums.js";
|
|
14
|
-
import { asRecord, auditSelfReferenceRewrites, collectDirectDependencyNames, describeSelfReferenceRemedy, DIRECT_DEPENDENCY_SECTIONS, OVERRIDE_SECTIONS, } from "../core/override-floors.js";
|
|
4
|
+
import { auditSelfReferenceRewrites, } from "../core/override-floors.js";
|
|
15
5
|
import { LISA_PACKAGE_NAME } from "../core/self-apply.js";
|
|
16
|
-
import { findMentionedPackages } from "./package-mentions.js";
|
|
17
6
|
import { getPackageVersion } from "../cli/version.js";
|
|
18
|
-
import {
|
|
7
|
+
import { JsonMergeError } from "../errors/index.js";
|
|
8
|
+
import { ensureParentDir } from "../utils/file-operations.js";
|
|
9
|
+
import { readJson, readJsonOrNull, writeJson } from "../utils/json-utils.js";
|
|
10
|
+
import { detectProjectTypes } from "./package-lisa-detect.js";
|
|
11
|
+
import { assertManifestIsInstallable, countTemplateFloors, planSelfReferencingOverrideNormalization, } from "./package-lisa-manifest-guards.js";
|
|
12
|
+
import { adoptableDependencies, applyHostFittedTemplate, applyTemplate, declaredDependencies, } from "./package-lisa-template-apply.js";
|
|
13
|
+
import { loadAndMergeTemplates, restrictToSecurityPins, } from "./package-lisa-template-merge.js";
|
|
14
|
+
import { fitDirectRangesToLisaFloors } from "./package-lisa-direct-floors.js";
|
|
15
|
+
import { findMentionedPackages } from "./package-mentions.js";
|
|
19
16
|
/**
|
|
20
17
|
* Package.lisa.json strategy: Manage package.json via separate template files
|
|
21
18
|
* - Loads templates from all applicable types in inheritance chain
|
|
@@ -36,13 +33,6 @@ export class PackageLisaStrategy {
|
|
|
36
33
|
this.readApplyingVersion = readApplyingVersion;
|
|
37
34
|
}
|
|
38
35
|
PACKAGE_JSON = "package.json";
|
|
39
|
-
TSCONFIG_JSON = "tsconfig.json";
|
|
40
|
-
APP_JSON = "app.json";
|
|
41
|
-
EAS_JSON = "eas.json";
|
|
42
|
-
NEST_CLI_JSON = "nest-cli.json";
|
|
43
|
-
CDK_JSON = CDK_APP_MARKER;
|
|
44
|
-
HARPER_APP_CONFIG = path.join("harper-app", "config.yaml");
|
|
45
|
-
HARPER_APP_SCHEMA = path.join("harper-app", "schema.graphql");
|
|
46
36
|
/**
|
|
47
37
|
* Produce the exact package.json result from already-safe project inputs.
|
|
48
38
|
* @param projectJson - Parsed host package.json
|
|
@@ -56,11 +46,11 @@ export class PackageLisaStrategy {
|
|
|
56
46
|
* @returns Package document that apply would persist
|
|
57
47
|
*/
|
|
58
48
|
async planPackageJson(projectJson, detectedTypes, lisaDir, securityPinsOnly = false, projectDir, invokingPackageManager) {
|
|
59
|
-
const merged = await
|
|
49
|
+
const merged = await loadAndMergeTemplates(lisaDir, detectedTypes);
|
|
60
50
|
const restricted = securityPinsOnly || projectJson.name === LISA_PACKAGE_NAME;
|
|
61
|
-
const effective = restricted ?
|
|
62
|
-
const forced =
|
|
63
|
-
const result = planSelfReferencingOverrideNormalization(
|
|
51
|
+
const effective = restricted ? restrictToSecurityPins(merged) : merged;
|
|
52
|
+
const forced = applyHostFittedTemplate(projectJson, effective, restricted, projectDir, this.readApplyingVersion, invokingPackageManager, await findMentionedPackages(projectDir, adoptableDependencies(projectJson, effective), declaredDependencies(projectJson)));
|
|
53
|
+
const result = planSelfReferencingOverrideNormalization(fitDirectRangesToLisaFloors(forced.packageJson, effective, this.PACKAGE_JSON).packageJson, this.PACKAGE_JSON);
|
|
64
54
|
assertManifestIsInstallable(result.packageJson, this.PACKAGE_JSON);
|
|
65
55
|
return result.packageJson;
|
|
66
56
|
}
|
|
@@ -86,8 +76,8 @@ export class PackageLisaStrategy {
|
|
|
86
76
|
*/
|
|
87
77
|
async auditOverrideFloors(projectDir, lisaDir) {
|
|
88
78
|
const projectJson = (await readJsonOrNull(path.join(projectDir, this.PACKAGE_JSON))) ?? {};
|
|
89
|
-
const detectedTypes = await
|
|
90
|
-
const merged = await
|
|
79
|
+
const detectedTypes = await detectProjectTypes(projectDir);
|
|
80
|
+
const merged = await loadAndMergeTemplates(lisaDir, detectedTypes);
|
|
91
81
|
return {
|
|
92
82
|
lisaFloors: countTemplateFloors(merged),
|
|
93
83
|
detectedTypes,
|
|
@@ -107,12 +97,12 @@ export class PackageLisaStrategy {
|
|
|
107
97
|
*/
|
|
108
98
|
auditOneApplyPath(projectJson, merged, applyPath) {
|
|
109
99
|
const restricted = applyPath === "postinstall" || projectJson.name === LISA_PACKAGE_NAME;
|
|
110
|
-
const effective = restricted ?
|
|
100
|
+
const effective = restricted ? restrictToSecurityPins(merged) : merged;
|
|
111
101
|
try {
|
|
112
|
-
const forced =
|
|
102
|
+
const forced = applyTemplate(projectJson, effective, this.PACKAGE_JSON, restricted, this.readApplyingVersion);
|
|
113
103
|
return {
|
|
114
104
|
applyPath,
|
|
115
|
-
audit: auditSelfReferenceRewrites(
|
|
105
|
+
audit: auditSelfReferenceRewrites(fitDirectRangesToLisaFloors(forced.packageJson, effective, this.PACKAGE_JSON).packageJson),
|
|
116
106
|
error: null,
|
|
117
107
|
};
|
|
118
108
|
}
|
|
@@ -254,1314 +244,18 @@ export class PackageLisaStrategy {
|
|
|
254
244
|
const lisaDir = context.config.lisaDir;
|
|
255
245
|
const projectDir = path.dirname(packageJsonPath);
|
|
256
246
|
// Get detected project types by analyzing the project structure
|
|
257
|
-
const detectedTypes = await
|
|
258
|
-
const merged = await
|
|
247
|
+
const detectedTypes = await detectProjectTypes(projectDir);
|
|
248
|
+
const merged = await loadAndMergeTemplates(lisaDir, detectedTypes);
|
|
259
249
|
const restricted = securityPinsOnly || projectJson.name === LISA_PACKAGE_NAME;
|
|
260
|
-
const effective = restricted ?
|
|
261
|
-
const forced =
|
|
262
|
-
const
|
|
263
|
-
const
|
|
264
|
-
const plan = planSelfReferencingOverrideNormalization(raised.packageJson, this.PACKAGE_JSON);
|
|
250
|
+
const effective = restricted ? restrictToSecurityPins(merged) : merged;
|
|
251
|
+
const forced = applyHostFittedTemplate(projectJson, effective, restricted, projectDir, this.readApplyingVersion, context.config.invokingPackageManager, await findMentionedPackages(projectDir, adoptableDependencies(projectJson, effective), declaredDependencies(projectJson)));
|
|
252
|
+
const fitted = fitDirectRangesToLisaFloors(forced.packageJson, effective, this.PACKAGE_JSON);
|
|
253
|
+
const plan = planSelfReferencingOverrideNormalization(fitted.packageJson, this.PACKAGE_JSON);
|
|
265
254
|
assertManifestIsInstallable(plan.packageJson, this.PACKAGE_JSON);
|
|
266
255
|
return {
|
|
267
256
|
...plan,
|
|
268
|
-
notes: [
|
|
269
|
-
...forced.notes,
|
|
270
|
-
...held.raises.map(describeDirectMinimumRaise),
|
|
271
|
-
...raised.raises.map(raise => `Raised ${raise.section}.${raise.name} from ${JSON.stringify(raise.from)} to ` +
|
|
272
|
-
`${JSON.stringify(raise.to)} to meet Lisa's floor ` +
|
|
273
|
-
`${JSON.stringify(raise.floorRange)}.`),
|
|
274
|
-
...plan.notes,
|
|
275
|
-
],
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Reduce a resolved template to only the security-critical sections —
|
|
280
|
-
* `force.resolutions` and `force.overrides`, plus the retirements aimed at
|
|
281
|
-
* those same two sections — dropping force.scripts, defaults, merge, and
|
|
282
|
-
* every other retirement. Used during skip-git-check (postinstall) applies so
|
|
283
|
-
* dependency pins still apply without clobbering host config.
|
|
284
|
-
*
|
|
285
|
-
* Retiring an override is as security-critical as writing one, so it travels
|
|
286
|
-
* with them. Dropping it left a pin that turns out to be harmful with no way
|
|
287
|
-
* to reach a host through postinstall: the template stops forcing the key,
|
|
288
|
-
* but the copy already written into the host's package.json stays. That is
|
|
289
|
-
* how `brace-expansion >=5.0.9` would have survived its own removal.
|
|
290
|
-
* Retirements aimed at other sections stay behind, because deleting host
|
|
291
|
-
* scripts or dependencies is exactly the config clobbering this path avoids.
|
|
292
|
-
*
|
|
293
|
-
* The retained overrides/resolutions may contain `$name` self-references or
|
|
294
|
-
* literal pins that normalize to `$name` later. Both resolve against a direct
|
|
295
|
-
* dependency of that name. If the restricted template drops the backing direct
|
|
296
|
-
* dep, postinstall can validate against the host's wider range and fail the
|
|
297
|
-
* normalization guard. So we also pull the package's forced pin from
|
|
298
|
-
* force.dependencies / force.devDependencies into the restricted set.
|
|
299
|
-
* @param template - Fully merged template from the type hierarchy
|
|
300
|
-
* @returns Template carrying force.resolutions/force.overrides, the direct
|
|
301
|
-
* dependencies that back any direct-dependency override within them, and
|
|
302
|
-
* the retirements aimed at those same two sections
|
|
303
|
-
* @private
|
|
304
|
-
*/
|
|
305
|
-
restrictToSecurityPins(template) {
|
|
306
|
-
const force = {};
|
|
307
|
-
if (template.force.resolutions !== undefined) {
|
|
308
|
-
force.resolutions = template.force.resolutions;
|
|
309
|
-
}
|
|
310
|
-
if (template.force.overrides !== undefined) {
|
|
311
|
-
force.overrides = template.force.overrides;
|
|
312
|
-
}
|
|
313
|
-
this.includeBackingDirectDeps(template, force);
|
|
314
|
-
const remove = Object.fromEntries(OVERRIDE_SECTIONS.filter(section => template.remove[section] !== undefined).map(section => [section, template.remove[section]]));
|
|
315
|
-
// `adopt` reclaims a key so `defaults` can rewrite it, and `defaults` is
|
|
316
|
-
// dropped here — carrying it alone would delete a host script and put
|
|
317
|
-
// nothing back.
|
|
318
|
-
// A minimum is a library choice, not a security pin, so the postinstall
|
|
319
|
-
// path leaves it to the full apply.
|
|
320
|
-
return {
|
|
321
|
-
force,
|
|
322
|
-
defaults: {},
|
|
323
|
-
merge: {},
|
|
324
|
-
remove,
|
|
325
|
-
adopt: {},
|
|
326
|
-
minimums: {},
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
/**
|
|
330
|
-
* For every direct-dependency override in the restricted overrides/resolutions,
|
|
331
|
-
* copy the forced pin for `name` from the full template's force.dependencies /
|
|
332
|
-
* force.devDependencies into the restricted force section so the backing direct
|
|
333
|
-
* dependency is materialized. A devDependencies pin wins over dependencies when
|
|
334
|
-
* both exist.
|
|
335
|
-
* @param template - Fully merged template (source of the forced dep pins)
|
|
336
|
-
* @param force - Restricted force section being assembled (mutated in place)
|
|
337
|
-
* @private
|
|
338
|
-
*/
|
|
339
|
-
includeBackingDirectDeps(template, force) {
|
|
340
|
-
const referenced = new Set([
|
|
341
|
-
...collectDollarReferences([force.resolutions, force.overrides]),
|
|
342
|
-
...collectLiteralOverrideNames([force.resolutions, force.overrides]),
|
|
343
|
-
]);
|
|
344
|
-
if (referenced.size === 0) {
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
const forceDeps = asRecord(template.force.dependencies);
|
|
348
|
-
const forceDevDeps = asRecord(template.force.devDependencies);
|
|
349
|
-
const backed = Array.from(referenced).filter(name => forceDevDeps[name] !== undefined || forceDeps[name] !== undefined);
|
|
350
|
-
if (backed.length === 0) {
|
|
351
|
-
return;
|
|
352
|
-
}
|
|
353
|
-
const deps = {};
|
|
354
|
-
const devDeps = {};
|
|
355
|
-
for (const name of backed) {
|
|
356
|
-
if (forceDevDeps[name] !== undefined) {
|
|
357
|
-
devDeps[name] = forceDevDeps[name];
|
|
358
|
-
}
|
|
359
|
-
else {
|
|
360
|
-
deps[name] = forceDeps[name];
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
if (Object.keys(devDeps).length > 0) {
|
|
364
|
-
force.devDependencies = {
|
|
365
|
-
...asRecord(force.devDependencies),
|
|
366
|
-
...devDeps,
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
if (Object.keys(deps).length > 0) {
|
|
370
|
-
force.dependencies = { ...asRecord(force.dependencies), ...deps };
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* Detect which project types apply to this project
|
|
375
|
-
* (TypeScript, Expo, NestJS, CDK, Harper/Fabric, npm-package)
|
|
376
|
-
* @param projectDir - Root directory of the project
|
|
377
|
-
* @returns Array of detected project types
|
|
378
|
-
* @private
|
|
379
|
-
*/
|
|
380
|
-
async detectProjectTypes(projectDir) {
|
|
381
|
-
const types = [];
|
|
382
|
-
// TypeScript detection
|
|
383
|
-
const hasTypeScript = (await fse.pathExists(path.join(projectDir, this.TSCONFIG_JSON))) ||
|
|
384
|
-
(await this.packageJsonHasDependency(projectDir, "typescript"));
|
|
385
|
-
if (hasTypeScript)
|
|
386
|
-
types.push("typescript");
|
|
387
|
-
// Expo detection
|
|
388
|
-
const hasExpo = (await fse.pathExists(path.join(projectDir, this.APP_JSON))) ||
|
|
389
|
-
(await fse.pathExists(path.join(projectDir, this.EAS_JSON))) ||
|
|
390
|
-
(await this.packageJsonHasDependency(projectDir, "expo"));
|
|
391
|
-
if (hasExpo)
|
|
392
|
-
types.push("expo");
|
|
393
|
-
// NestJS detection
|
|
394
|
-
const hasNestJS = (await fse.pathExists(path.join(projectDir, this.NEST_CLI_JSON))) ||
|
|
395
|
-
(await this.packageJsonHasDependencyPrefix(projectDir, "@nestjs"));
|
|
396
|
-
if (hasNestJS)
|
|
397
|
-
types.push("nestjs");
|
|
398
|
-
// CDK detection. cdk.json only: an `aws-cdk*` dependency means the project
|
|
399
|
-
// uses CDK constructs, not that it is a CDK app with the preset's layout.
|
|
400
|
-
const hasCDK = await fse.pathExists(path.join(projectDir, this.CDK_JSON));
|
|
401
|
-
if (hasCDK)
|
|
402
|
-
types.push("cdk");
|
|
403
|
-
// Harper/Fabric detection
|
|
404
|
-
const hasHarperFabric = (await fse.pathExists(path.join(projectDir, this.HARPER_APP_CONFIG))) &&
|
|
405
|
-
(await fse.pathExists(path.join(projectDir, this.HARPER_APP_SCHEMA))) &&
|
|
406
|
-
((await this.harperConfigHasComponentSignals(projectDir)) ||
|
|
407
|
-
(await this.packageJsonHasDependency(projectDir, "harperdb")));
|
|
408
|
-
if (hasHarperFabric)
|
|
409
|
-
types.push("harper-fabric");
|
|
410
|
-
// Phaser detection
|
|
411
|
-
const hasPhaser = await this.packageJsonHasDependency(projectDir, "phaser");
|
|
412
|
-
if (hasPhaser)
|
|
413
|
-
types.push("phaser");
|
|
414
|
-
// npm-package detection
|
|
415
|
-
const isPrivate = await this.packageJsonField(projectDir, "private");
|
|
416
|
-
const hasPublishField = (await this.packageJsonField(projectDir, "main")) !== undefined ||
|
|
417
|
-
(await this.packageJsonField(projectDir, "bin")) !== undefined ||
|
|
418
|
-
(await this.packageJsonField(projectDir, "exports")) !== undefined ||
|
|
419
|
-
(await this.packageJsonField(projectDir, "files")) !== undefined;
|
|
420
|
-
if (!isPrivate && hasPublishField) {
|
|
421
|
-
types.push("npm-package");
|
|
422
|
-
}
|
|
423
|
-
return types;
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Check whether harper-app/config.yaml declares the expected Harper component
|
|
427
|
-
* resource keys.
|
|
428
|
-
* @param projectDir - The project directory to check
|
|
429
|
-
* @returns True if the config has Harper/Fabric component signals
|
|
430
|
-
* @private
|
|
431
|
-
*/
|
|
432
|
-
async harperConfigHasComponentSignals(projectDir) {
|
|
433
|
-
try {
|
|
434
|
-
const content = await readFile(path.join(projectDir, this.HARPER_APP_CONFIG), "utf8");
|
|
435
|
-
return (content.includes("graphqlSchema:") &&
|
|
436
|
-
content.includes("jsResource:") &&
|
|
437
|
-
content.includes("static:"));
|
|
438
|
-
}
|
|
439
|
-
catch {
|
|
440
|
-
return false;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
/**
|
|
444
|
-
* Check if package.json dependencies/devDependencies contain a specific package
|
|
445
|
-
* @param projectDir - The project directory to check
|
|
446
|
-
* @param packageName - The exact package name to check for (e.g., "typescript", "expo")
|
|
447
|
-
* @returns True if the package is in dependencies or devDependencies, false otherwise
|
|
448
|
-
* @private
|
|
449
|
-
*/
|
|
450
|
-
async packageJsonHasDependency(projectDir, packageName) {
|
|
451
|
-
const packageJson = await readJsonOrNull(path.join(projectDir, this.PACKAGE_JSON));
|
|
452
|
-
if (!packageJson)
|
|
453
|
-
return false;
|
|
454
|
-
return (packageJson.dependencies?.[packageName] !== undefined ||
|
|
455
|
-
packageJson.devDependencies?.[packageName] !== undefined);
|
|
456
|
-
}
|
|
457
|
-
/**
|
|
458
|
-
* Check if package.json dependencies/devDependencies contain a package starting with prefix
|
|
459
|
-
* @param projectDir - The project directory to check
|
|
460
|
-
* @param prefix - The prefix to check for (e.g., "@nestjs", "aws-cdk")
|
|
461
|
-
* @returns True if any dependency starts with the given prefix, false otherwise
|
|
462
|
-
* @private
|
|
463
|
-
*/
|
|
464
|
-
async packageJsonHasDependencyPrefix(projectDir, prefix) {
|
|
465
|
-
const packageJson = await readJsonOrNull(path.join(projectDir, this.PACKAGE_JSON));
|
|
466
|
-
if (!packageJson)
|
|
467
|
-
return false;
|
|
468
|
-
const deps = packageJson.dependencies ?? {};
|
|
469
|
-
const devDeps = packageJson.devDependencies ?? {};
|
|
470
|
-
return (Object.keys(deps).some(key => key.startsWith(prefix)) ||
|
|
471
|
-
Object.keys(devDeps).some(key => key.startsWith(prefix)));
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* Get a field value from package.json
|
|
475
|
-
* @param projectDir - The project directory containing the package.json
|
|
476
|
-
* @param fieldName - The field name to retrieve from package.json
|
|
477
|
-
* @returns The field value if found, undefined if not found or if package.json doesn't exist
|
|
478
|
-
* @private
|
|
479
|
-
*/
|
|
480
|
-
async packageJsonField(projectDir, fieldName) {
|
|
481
|
-
const packageJson = await readJsonOrNull(path.join(projectDir, this.PACKAGE_JSON));
|
|
482
|
-
if (!packageJson)
|
|
483
|
-
return undefined;
|
|
484
|
-
return packageJson[fieldName];
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* Load and merge all package.lisa.json templates from type hierarchy
|
|
488
|
-
* @remarks
|
|
489
|
-
* Inheritance chain: all → typescript → specific types (expo, nestjs, cdk, npm-package)
|
|
490
|
-
* Child types override parent types in force, defaults, and merge sections.
|
|
491
|
-
* @param lisaDir - Root Lisa directory path
|
|
492
|
-
* @param detectedTypes - Project types to load templates for
|
|
493
|
-
* @returns Merged template with force, defaults, merge sections
|
|
494
|
-
* @private
|
|
495
|
-
*/
|
|
496
|
-
async loadAndMergeTemplates(lisaDir, detectedTypes) {
|
|
497
|
-
const initial = {
|
|
498
|
-
force: {},
|
|
499
|
-
defaults: {},
|
|
500
|
-
merge: {},
|
|
501
|
-
remove: {},
|
|
502
|
-
adopt: {},
|
|
503
|
-
minimums: {},
|
|
504
|
-
};
|
|
505
|
-
// Expand types to include parents (e.g., expo includes typescript)
|
|
506
|
-
const allTypes = this.expandTypeHierarchy(detectedTypes);
|
|
507
|
-
// Process types in order: all, then typescript, then specific types
|
|
508
|
-
const typesToProcess = ["all", ...allTypes];
|
|
509
|
-
// Load and merge all templates using reduce
|
|
510
|
-
// eslint-disable-next-line functional/no-let -- Reassignment needed for async loop
|
|
511
|
-
let accumulator = initial;
|
|
512
|
-
for (const type of typesToProcess) {
|
|
513
|
-
const templatePath = path.join(lisaDir, type, "package-lisa", "package.lisa.json");
|
|
514
|
-
const template = await readJsonOrNull(templatePath);
|
|
515
|
-
if (!template) {
|
|
516
|
-
// Template doesn't exist for this type; skip
|
|
517
|
-
continue;
|
|
518
|
-
}
|
|
519
|
-
// Merge template into accumulated template (child overrides parent)
|
|
520
|
-
accumulator = this.mergeTemplates(accumulator, template);
|
|
521
|
-
}
|
|
522
|
-
return accumulator;
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* Expand project types to include parent types, sorted by hierarchy order
|
|
526
|
-
* @remarks
|
|
527
|
-
* Type hierarchy: expo/nestjs/cdk/npm-package inherit from typescript
|
|
528
|
-
* This expands a list to include parents and sorts by PROJECT_TYPE_ORDER
|
|
529
|
-
* so parents are processed before children (enabling child overrides).
|
|
530
|
-
* Example: [cdk] → [typescript, cdk]
|
|
531
|
-
* @param types - Project types detected
|
|
532
|
-
* @returns Expanded types including parents, sorted parents-first
|
|
533
|
-
* @private
|
|
534
|
-
*/
|
|
535
|
-
expandTypeHierarchy(types) {
|
|
536
|
-
const allTypes = new Set(types);
|
|
537
|
-
for (const type of types) {
|
|
538
|
-
const parent = PROJECT_TYPE_HIERARCHY[type];
|
|
539
|
-
if (parent) {
|
|
540
|
-
allTypes.add(parent);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
// Sort by PROJECT_TYPE_ORDER to ensure parents are processed before children
|
|
544
|
-
return Array.from(allTypes).sort((a, b) => PROJECT_TYPE_ORDER.indexOf(a) - PROJECT_TYPE_ORDER.indexOf(b));
|
|
545
|
-
}
|
|
546
|
-
/**
|
|
547
|
-
* Merge two template objects
|
|
548
|
-
* Child template (override) values win in force and defaults.
|
|
549
|
-
* Merge and remove arrays are concatenated without deduplication at merge time.
|
|
550
|
-
* @param parent - Parent template (e.g., "all" or "typescript")
|
|
551
|
-
* @param child - Child template (e.g., "expo") that overrides parent
|
|
552
|
-
* @returns Merged template
|
|
553
|
-
* @private
|
|
554
|
-
*/
|
|
555
|
-
mergeTemplates(parent, child) {
|
|
556
|
-
return {
|
|
557
|
-
force: deepMerge(parent.force, child.force || {}),
|
|
558
|
-
defaults: deepMerge(parent.defaults, child.defaults || {}),
|
|
559
|
-
merge: this.mergeMergeSections(parent.merge, child.merge || {}),
|
|
560
|
-
remove: this.mergeMergeSections(parent.remove, child.remove || {}),
|
|
561
|
-
adopt: mergeAdoptSections(parent.adopt, child.adopt || {}),
|
|
562
|
-
minimums: { ...parent.minimums, ...child.minimums },
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
/**
|
|
566
|
-
* Merge two merge-section objects
|
|
567
|
-
* Arrays are concatenated (deduplication happens later when applied to package.json)
|
|
568
|
-
* @param parent - Parent merge sections
|
|
569
|
-
* @param child - Child merge sections
|
|
570
|
-
* @returns Merged sections
|
|
571
|
-
* @private
|
|
572
|
-
*/
|
|
573
|
-
mergeMergeSections(parent, child) {
|
|
574
|
-
const result = { ...parent };
|
|
575
|
-
for (const [key, value] of Object.entries(child)) {
|
|
576
|
-
if (key in result) {
|
|
577
|
-
// Concatenate arrays
|
|
578
|
-
const existing = result[key];
|
|
579
|
-
result[key] = [...existing, ...value];
|
|
580
|
-
}
|
|
581
|
-
else {
|
|
582
|
-
result[key] = value;
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
return result;
|
|
586
|
-
}
|
|
587
|
-
/**
|
|
588
|
-
* Apply the template after fitting its forced package-manager floor to the
|
|
589
|
-
* host's manager, so a bun host never receives an npm floor (#4848).
|
|
590
|
-
* @param projectJson - Current project's package.json
|
|
591
|
-
* @param template - Merged package.lisa.json template
|
|
592
|
-
* @param restricted - True when the template was reduced to security pins
|
|
593
|
-
* @param projectDir - Host directory, or undefined when no tree is available
|
|
594
|
-
* @param invokingPackageManager - Manager that launched this apply, if any
|
|
595
|
-
* @param mentioned - Packages the host names outside its manifest, which a
|
|
596
|
-
* dependency `adopt` entry must never delete
|
|
597
|
-
* @returns Modified package.json plus operator-visible notes
|
|
598
|
-
* @private
|
|
599
|
-
*/
|
|
600
|
-
applyHostFittedTemplate(projectJson, template, restricted, projectDir, invokingPackageManager, mentioned) {
|
|
601
|
-
const fitted = fitDevEnginesToHost(template, detectHostPackageManager(projectDir, projectJson, invokingPackageManager), projectJson);
|
|
602
|
-
const applied = this.applyTemplate(projectJson, fitted.template, this.PACKAGE_JSON, restricted, mentioned);
|
|
603
|
-
return fitted.retire
|
|
604
|
-
? { ...applied, packageJson: retireDevEnginesFloor(applied.packageJson) }
|
|
605
|
-
: applied;
|
|
606
|
-
}
|
|
607
|
-
/**
|
|
608
|
-
* Apply force/defaults/merge/remove logic to project's package.json
|
|
609
|
-
* @remarks
|
|
610
|
-
* Processing order:
|
|
611
|
-
* 1. Apply force: Deep merge with Lisa values winning (entire section replaced)
|
|
612
|
-
* 2. Apply defaults: Deep merge with project values winning (only set if missing)
|
|
613
|
-
* 3. Apply merge: Concatenate arrays and deduplicate
|
|
614
|
-
* 4. Apply remove: Delete retired keys from their sections (runs last so an
|
|
615
|
-
* earlier phase cannot reintroduce a removed key)
|
|
616
|
-
* @param projectJson - Current project's package.json
|
|
617
|
-
* @param template - Merged package.lisa.json template
|
|
618
|
-
* @param fileName - Basename used in error messages
|
|
619
|
-
* @param restricted - True when the template was reduced to security pins,
|
|
620
|
-
* which is the postinstall path and Lisa's own repository
|
|
621
|
-
* @param mentioned - Packages the host names outside its manifest. Omitted,
|
|
622
|
-
* every package counts as mentioned and no dependency is reclaimed.
|
|
623
|
-
* @returns Modified package.json plus operator-visible notes
|
|
624
|
-
* @private
|
|
625
|
-
*/
|
|
626
|
-
applyTemplate(projectJson, template, fileName, restricted = false, mentioned) {
|
|
627
|
-
// Phase 1: Apply force (Lisa's values completely replace project's), then
|
|
628
|
-
// restore any dependency pin the host had raised ABOVE Lisa's floor.
|
|
629
|
-
const afterForce = preserveHigherHostPins(projectJson, deepMerge(projectJson, template.force), fileName);
|
|
630
|
-
// Phase 1.5: Reclaim keys still carrying a value Lisa itself wrote, so the
|
|
631
|
-
// defaults phase can install the current one. A host value Lisa does not
|
|
632
|
-
// recognise as its own is left alone — that is the whole point.
|
|
633
|
-
const afterAdopt = applyAdoptSections(afterForce.packageJson, template, name => mentioned === undefined || mentioned.has(name));
|
|
634
|
-
// Phase 2: Apply defaults (project's values preserved, Lisa provides fallback)
|
|
635
|
-
const afterDefaults = deepMerge(template.defaults, afterAdopt);
|
|
636
|
-
// Phase 3: Apply merge (concatenate and deduplicate arrays)
|
|
637
|
-
const afterMerge = this.applyMergeSections(afterDefaults, template.merge);
|
|
638
|
-
// Phase 4: Apply remove (delete retired keys from their sections)
|
|
639
|
-
const afterRemove = this.applyRemoveSections(afterMerge, template.remove);
|
|
640
|
-
// Phase 5: Make the host's pin name the version that wrote these templates.
|
|
641
|
-
// A restricted apply is the postinstall path, where the installed package
|
|
642
|
-
// IS the applying version, so there is nothing to reconcile — and rewriting
|
|
643
|
-
// the host's manifest from inside their `install` is not this phase's to do.
|
|
644
|
-
const pinned = restricted
|
|
645
|
-
? { packageJson: afterRemove, notes: [] }
|
|
646
|
-
: alignLisaPin(afterRemove, this.readApplyingVersion());
|
|
647
|
-
// Phase 6: Say out loud what the host lost, and which gates nothing runs.
|
|
648
|
-
return {
|
|
649
|
-
packageJson: pinned.packageJson,
|
|
650
|
-
notes: [
|
|
651
|
-
...afterForce.notes,
|
|
652
|
-
...pinned.notes,
|
|
653
|
-
...describeScriptChanges(projectJson, pinned.packageJson, template),
|
|
654
|
-
],
|
|
257
|
+
notes: [...forced.notes, ...fitted.notes, ...plan.notes],
|
|
655
258
|
};
|
|
656
259
|
}
|
|
657
|
-
/**
|
|
658
|
-
* Delete retired keys from their package.json sections
|
|
659
|
-
* @remarks
|
|
660
|
-
* Used to clean up keys Lisa previously forced and has since renamed or
|
|
661
|
-
* retired (e.g. the "knip" script renamed to "knip:check"). Runs after
|
|
662
|
-
* force/defaults/merge so a removed key cannot be reintroduced within the
|
|
663
|
-
* same apply. Sections that don't exist or aren't objects are left alone.
|
|
664
|
-
* @param packageJson - Current package.json after force/defaults/merge applied
|
|
665
|
-
* @param removeSections - Map of section name to keys to delete from it
|
|
666
|
-
* @returns Package.json with retired keys removed
|
|
667
|
-
* @private
|
|
668
|
-
*/
|
|
669
|
-
applyRemoveSections(packageJson, removeSections) {
|
|
670
|
-
const result = { ...packageJson };
|
|
671
|
-
for (const [sectionName, keysToRemove] of Object.entries(removeSections)) {
|
|
672
|
-
const section = result[sectionName];
|
|
673
|
-
if (!section || typeof section !== "object" || Array.isArray(section)) {
|
|
674
|
-
// Section missing or not a plain object; nothing to remove
|
|
675
|
-
continue;
|
|
676
|
-
}
|
|
677
|
-
const cleaned = Object.fromEntries(Object.entries(section).filter(([key]) => !keysToRemove.includes(key)));
|
|
678
|
-
result[sectionName] = cleaned;
|
|
679
|
-
}
|
|
680
|
-
return result;
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* Apply merge-section arrays to package.json
|
|
684
|
-
* Concatenates Lisa's items and project's items, deduplicated by JSON.stringify equality.
|
|
685
|
-
* @param packageJson - Current package.json after force/defaults applied
|
|
686
|
-
* @param mergeSections - Merge sections from template
|
|
687
|
-
* @returns Package.json with merge sections applied
|
|
688
|
-
* @private
|
|
689
|
-
*/
|
|
690
|
-
applyMergeSections(packageJson, mergeSections) {
|
|
691
|
-
const result = { ...packageJson };
|
|
692
|
-
for (const [key, lisaItems] of Object.entries(mergeSections)) {
|
|
693
|
-
const projectItems = result[key] || [];
|
|
694
|
-
if (!Array.isArray(projectItems)) {
|
|
695
|
-
// If the field exists but isn't an array, replace it with Lisa's items
|
|
696
|
-
result[key] = lisaItems;
|
|
697
|
-
continue;
|
|
698
|
-
}
|
|
699
|
-
// Concatenate and deduplicate: Lisa items first, then project's unique items
|
|
700
|
-
result[key] = this.deduplicateArrays(lisaItems, projectItems);
|
|
701
|
-
}
|
|
702
|
-
return result;
|
|
703
|
-
}
|
|
704
|
-
/**
|
|
705
|
-
* Concatenate two arrays and remove duplicates
|
|
706
|
-
* Uses JSON.stringify for value equality comparison.
|
|
707
|
-
* Lisa items come first, then project's unique items.
|
|
708
|
-
* @param lisaItems - Lisa's items (come first)
|
|
709
|
-
* @param projectItems - Project's items (added if not already present)
|
|
710
|
-
* @returns Deduplicated array
|
|
711
|
-
* @private
|
|
712
|
-
*/
|
|
713
|
-
deduplicateArrays(lisaItems, projectItems) {
|
|
714
|
-
const seen = new Set();
|
|
715
|
-
const result = [];
|
|
716
|
-
// Add Lisa items first
|
|
717
|
-
for (const item of lisaItems) {
|
|
718
|
-
const key = JSON.stringify(item);
|
|
719
|
-
if (!seen.has(key)) {
|
|
720
|
-
seen.add(key);
|
|
721
|
-
result.push(item);
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
// Add project's unique items
|
|
725
|
-
for (const item of projectItems) {
|
|
726
|
-
const key = JSON.stringify(item);
|
|
727
|
-
if (!seen.has(key)) {
|
|
728
|
-
seen.add(key);
|
|
729
|
-
result.push(item);
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
return result;
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
/**
|
|
736
|
-
* Dependency sections a host may declare `@codyswann/lisa` in, most-specific
|
|
737
|
-
* first: a runtime dependency is the unusual choice, so finding one there means
|
|
738
|
-
* the host meant it.
|
|
739
|
-
*/
|
|
740
|
-
const LISA_PIN_SECTIONS = ["dependencies", "devDependencies"];
|
|
741
|
-
/** Where a pin goes on a host that does not have one yet. */
|
|
742
|
-
const DEFAULT_LISA_PIN_SECTION = "devDependencies";
|
|
743
|
-
/**
|
|
744
|
-
* Specs that name a LOCATION rather than a registry version.
|
|
745
|
-
* @remarks
|
|
746
|
-
* `file:` / `link:` / `portal:` / `workspace:` and the git forms all mean
|
|
747
|
-
* somebody is developing against a checkout instead of a release. Replacing one
|
|
748
|
-
* with a version number breaks that setup, so the apply reports the skew rather
|
|
749
|
-
* than resolving it — which is the branch the second acceptance scenario is
|
|
750
|
-
* about.
|
|
751
|
-
*/
|
|
752
|
-
const NON_REGISTRY_SPEC = /^(?:file|link|portal|workspace|git|git\+[a-z]+|github|https?|npm):/i;
|
|
753
|
-
/**
|
|
754
|
-
* Does this spec point at a location rather than name a registry version?
|
|
755
|
-
* @param spec - The version spec the host declared
|
|
756
|
-
* @returns True when the spec resolves outside the registry
|
|
757
|
-
*/
|
|
758
|
-
function isNonRegistrySpec(spec) {
|
|
759
|
-
return NON_REGISTRY_SPEC.test(spec);
|
|
760
|
-
}
|
|
761
|
-
/**
|
|
762
|
-
* Where the host declares its Lisa pin, and what it currently says.
|
|
763
|
-
* @param packageJson - The manifest as the merge phases left it
|
|
764
|
-
* @returns The section to write into and the spec already there, if any
|
|
765
|
-
*/
|
|
766
|
-
function locateLisaPin(packageJson) {
|
|
767
|
-
const declared = LISA_PIN_SECTIONS.map(section => ({
|
|
768
|
-
section,
|
|
769
|
-
current: asRecord(packageJson[section])[LISA_PACKAGE_NAME],
|
|
770
|
-
})).find(found => typeof found.current === "string");
|
|
771
|
-
return declared === undefined
|
|
772
|
-
? { section: DEFAULT_LISA_PIN_SECTION, current: undefined }
|
|
773
|
-
: { section: declared.section, current: declared.current };
|
|
774
|
-
}
|
|
775
|
-
/**
|
|
776
|
-
* Make the host's `@codyswann/lisa` pin name the version doing the applying.
|
|
777
|
-
* @remarks
|
|
778
|
-
* An apply writes templates that call into the package's own API, so the
|
|
779
|
-
* applied version and the INSTALLED version are two halves of one thing. When
|
|
780
|
-
* they drift, a config file calls an export the installed package does not have
|
|
781
|
-
* and every run of the tool that loads it dies at config load — while the apply
|
|
782
|
-
* itself reports success, and `postinstall`'s `tsc || true` swallows the only
|
|
783
|
-
* local signal. The failure then surfaces at the next
|
|
784
|
-
* lint run, detached from the apply that caused it (#2953).
|
|
785
|
-
*
|
|
786
|
-
* A range is rewritten as readily as an exact pin, and deliberately so: a caret
|
|
787
|
-
* range ADMITS the applying version without requiring it, so a lockfile still
|
|
788
|
-
* resolving an older build produces exactly the skew this closes.
|
|
789
|
-
*
|
|
790
|
-
* Lisa applying to its own repository never reaches here: that path is
|
|
791
|
-
* restricted to security pins, and a package cannot depend on itself.
|
|
792
|
-
*
|
|
793
|
-
* The consequence, recorded because it was twice discovered rather than read
|
|
794
|
-
* (#3768): Lisa's own manifest DOES carry a `@codyswann/lisa` devDependency —
|
|
795
|
-
* the fixture its templates resolve against — and this phase is the only thing
|
|
796
|
-
* that would keep such a pin current. Skipping it here means **the single
|
|
797
|
-
* repository whose pin no automation will ever correct is the one that ships
|
|
798
|
-
* the automation.** That pin rotted two majors twice, in #2279 and again in
|
|
799
|
-
* #3662, each time found only because somebody read a version string. The
|
|
800
|
-
* reader that replaces them is `scripts/check-self-dependency-pin.mjs`, run as
|
|
801
|
-
* a required CI step; this exemption stays as written, and is now watched.
|
|
802
|
-
* @param packageJson - The manifest as the merge phases left it
|
|
803
|
-
* @param applyingVersion - Version of the Lisa performing this apply
|
|
804
|
-
* @returns The manifest with the pin aligned, plus operator-visible notes
|
|
805
|
-
*/
|
|
806
|
-
function alignLisaPin(packageJson, applyingVersion) {
|
|
807
|
-
const { section, current } = locateLisaPin(packageJson);
|
|
808
|
-
if (current === applyingVersion)
|
|
809
|
-
return { packageJson, notes: [] };
|
|
810
|
-
if (current !== undefined && isNonRegistrySpec(current)) {
|
|
811
|
-
return {
|
|
812
|
-
packageJson,
|
|
813
|
-
notes: [
|
|
814
|
-
`Left ${LISA_PACKAGE_NAME} at "${current}", which points at a local copy rather than a release, but this apply is ${applyingVersion}. If that copy is older, the files just written may call something it does not have and every lint run will fail before it checks anything.`,
|
|
815
|
-
],
|
|
816
|
-
};
|
|
817
|
-
}
|
|
818
|
-
const note = current === undefined
|
|
819
|
-
? `Added ${LISA_PACKAGE_NAME} ${applyingVersion} to ${section}. The files this apply just wrote come from ${applyingVersion} and call into it, so install it before your next lint run.`
|
|
820
|
-
: `Pinned ${LISA_PACKAGE_NAME} to ${applyingVersion}; it was ${current}. The files this apply just wrote come from ${applyingVersion} and call into it, so the two have to be the same version — install it before your next lint run.`;
|
|
821
|
-
return {
|
|
822
|
-
packageJson: {
|
|
823
|
-
...packageJson,
|
|
824
|
-
[section]: {
|
|
825
|
-
...asRecord(packageJson[section]),
|
|
826
|
-
[LISA_PACKAGE_NAME]: applyingVersion,
|
|
827
|
-
},
|
|
828
|
-
},
|
|
829
|
-
notes: [note],
|
|
830
|
-
};
|
|
831
|
-
}
|
|
832
|
-
/** The package.json section whose overwrites are reported to the operator. */
|
|
833
|
-
const SCRIPTS_SECTION = "scripts";
|
|
834
|
-
/**
|
|
835
|
-
* Suffix naming the Lisa-owned half of a split script.
|
|
836
|
-
*
|
|
837
|
-
* A governed gate is shipped as a PAIR: `lint:lisa` carries Lisa's own command
|
|
838
|
-
* and stays in `force`, so a host can neither delete nor weaken it; `lint` is
|
|
839
|
-
* only a `defaults` entry invoking it, so the host owns the composition point
|
|
840
|
-
* and anything chained onto it survives every apply.
|
|
841
|
-
*/
|
|
842
|
-
const RESERVED_BASE_SUFFIX = ":lisa";
|
|
843
|
-
/** How much of a script value an operator note quotes before eliding. */
|
|
844
|
-
const NOTE_VALUE_BUDGET = 140;
|
|
845
|
-
/** Sections whose keys name packages a host's code may import. */
|
|
846
|
-
const DEPENDENCY_SECTIONS = new Set([
|
|
847
|
-
"dependencies",
|
|
848
|
-
"devDependencies",
|
|
849
|
-
"optionalDependencies",
|
|
850
|
-
"peerDependencies",
|
|
851
|
-
]);
|
|
852
|
-
/**
|
|
853
|
-
* Every package a manifest declares, in any dependency section.
|
|
854
|
-
* @param projectJson - Host package.json as read
|
|
855
|
-
* @returns Package names, each at most once
|
|
856
|
-
*/
|
|
857
|
-
function declaredDependencies(projectJson) {
|
|
858
|
-
return [
|
|
859
|
-
...new Set([...DEPENDENCY_SECTIONS].flatMap(section => Object.keys(asRecord(projectJson[section])))),
|
|
860
|
-
];
|
|
861
|
-
}
|
|
862
|
-
/**
|
|
863
|
-
* Dependencies an `adopt` entry would delete, before the mention check runs.
|
|
864
|
-
* @remarks
|
|
865
|
-
* Only these are worth asking git about: a key the template forces is never
|
|
866
|
-
* reclaimed, and one holding a value Lisa did not write is the host's own.
|
|
867
|
-
* @param projectJson - Host package.json as read
|
|
868
|
-
* @param template - Resolved template carrying the adopt section
|
|
869
|
-
* @returns Package names, each at most once
|
|
870
|
-
*/
|
|
871
|
-
function adoptableDependencies(projectJson, template) {
|
|
872
|
-
const names = Object.entries(template.adopt)
|
|
873
|
-
.filter(([sectionName]) => DEPENDENCY_SECTIONS.has(sectionName))
|
|
874
|
-
.flatMap(([sectionName, recognised]) => {
|
|
875
|
-
const forcedHere = asRecord(asRecord(template.force)[sectionName]);
|
|
876
|
-
return Object.entries(asRecord(projectJson[sectionName])).flatMap(([key, value]) => typeof value === "string" &&
|
|
877
|
-
!(key in forcedHere) &&
|
|
878
|
-
(recognised[key] ?? []).includes(value)
|
|
879
|
-
? [key]
|
|
880
|
-
: []);
|
|
881
|
-
});
|
|
882
|
-
return [...new Set(names)];
|
|
883
|
-
}
|
|
884
|
-
/**
|
|
885
|
-
* Merge two `adopt` sections, taking the UNION of the recognised values.
|
|
886
|
-
* @remarks
|
|
887
|
-
* Union, not child-overrides-parent as `force` and `defaults` use. Every entry
|
|
888
|
-
* is a value Lisa is known to have written, and a host may have taken any of
|
|
889
|
-
* them from any layer of the chain it has passed through. Dropping the parent's
|
|
890
|
-
* list would stop recognising a value Lisa really did author, and the cost of
|
|
891
|
-
* that is not cosmetic: the host gets warned that it customised something it
|
|
892
|
-
* never touched, and stops tracking the template.
|
|
893
|
-
* @param parent - Parent template's adopt section
|
|
894
|
-
* @param child - Child template's adopt section
|
|
895
|
-
* @returns Per-section, per-key union of the two, order-preserving and deduped
|
|
896
|
-
*/
|
|
897
|
-
function mergeAdoptSections(parent, child) {
|
|
898
|
-
const sections = new Set([...Object.keys(parent), ...Object.keys(child)]);
|
|
899
|
-
return Object.fromEntries(Array.from(sections).map(section => {
|
|
900
|
-
const parentKeys = parent[section] ?? {};
|
|
901
|
-
const childKeys = child[section] ?? {};
|
|
902
|
-
const keys = new Set([
|
|
903
|
-
...Object.keys(parentKeys),
|
|
904
|
-
...Object.keys(childKeys),
|
|
905
|
-
]);
|
|
906
|
-
return [
|
|
907
|
-
section,
|
|
908
|
-
Object.fromEntries(Array.from(keys).map(key => [
|
|
909
|
-
key,
|
|
910
|
-
Array.from(new Set([...(parentKeys[key] ?? []), ...(childKeys[key] ?? [])])),
|
|
911
|
-
])),
|
|
912
|
-
];
|
|
913
|
-
}));
|
|
914
|
-
}
|
|
915
|
-
/**
|
|
916
|
-
* Drop every key still carrying a value Lisa itself wrote.
|
|
917
|
-
* @remarks
|
|
918
|
-
* The deletion is what lets the `defaults` phase, which never overwrites, reach
|
|
919
|
-
* a key Lisa used to force. Nothing else is touched: a value absent from the
|
|
920
|
-
* adopt list is the host's own work by definition, and keeping it is the entire
|
|
921
|
-
* behaviour this exists to provide.
|
|
922
|
-
*
|
|
923
|
-
* A dependency needs one more proof than a script. Keeping the version Lisa
|
|
924
|
-
* wrote says nothing about whether the host imports the package, so a
|
|
925
|
-
* dependency key is cleared only when the host also never mentions it
|
|
926
|
-
* (CodySwannGT/lisa#4932, `package-mentions.ts`).
|
|
927
|
-
* @param packageJson - The document as the force phase left it
|
|
928
|
-
* @param template - Resolved template carrying the adopt section
|
|
929
|
-
* @param isMentioned - Whether the host names a package outside its manifest
|
|
930
|
-
* @returns The document with Lisa-authored values cleared
|
|
931
|
-
*/
|
|
932
|
-
function applyAdoptSections(packageJson, template, isMentioned) {
|
|
933
|
-
return Object.entries(template.adopt).reduce((document, [sectionName, recognised]) => {
|
|
934
|
-
const section = document[sectionName];
|
|
935
|
-
if (section === null ||
|
|
936
|
-
typeof section !== "object" ||
|
|
937
|
-
Array.isArray(section)) {
|
|
938
|
-
return document;
|
|
939
|
-
}
|
|
940
|
-
// A key the template also FORCES already holds Lisa's current value.
|
|
941
|
-
// Clearing it would delete what force just wrote and leave the key to
|
|
942
|
-
// whatever `defaults` happens to carry — so force wins, and adopt is a
|
|
943
|
-
// no-op there. Adopt only has meaning for a key Lisa has handed back.
|
|
944
|
-
const forcedHere = asRecord(asRecord(template.force)[sectionName]);
|
|
945
|
-
const guarded = DEPENDENCY_SECTIONS.has(sectionName);
|
|
946
|
-
const entries = Object.entries(section);
|
|
947
|
-
const kept = entries.filter(([key, value]) => typeof value !== "string" ||
|
|
948
|
-
key in forcedHere ||
|
|
949
|
-
!(recognised[key] ?? []).includes(value) ||
|
|
950
|
-
(guarded && isMentioned(key)));
|
|
951
|
-
if (kept.length === entries.length) {
|
|
952
|
-
return document;
|
|
953
|
-
}
|
|
954
|
-
return { ...document, [sectionName]: Object.fromEntries(kept) };
|
|
955
|
-
}, packageJson);
|
|
956
|
-
}
|
|
957
|
-
/**
|
|
958
|
-
* Quote a script value for an operator note without flooding the terminal.
|
|
959
|
-
* @param value - The script value being quoted
|
|
960
|
-
* @returns The value, elided past the note budget
|
|
961
|
-
*/
|
|
962
|
-
function quoteScript(value) {
|
|
963
|
-
return value.length <= NOTE_VALUE_BUDGET
|
|
964
|
-
? `"${value}"`
|
|
965
|
-
: `"${value.slice(0, NOTE_VALUE_BUDGET)}…"`;
|
|
966
|
-
}
|
|
967
|
-
/**
|
|
968
|
-
* Report what an apply did to the host's scripts, and what it left inert.
|
|
969
|
-
* @remarks
|
|
970
|
-
* The defect this answers was invisible rather than wrong-looking. One script
|
|
971
|
-
* value changed inside a `package.json` diff dominated by key reordering, and
|
|
972
|
-
* nothing said so, so five chained CI gates became dead code while the Lint
|
|
973
|
-
* check kept reporting green.
|
|
974
|
-
*
|
|
975
|
-
* Every key of the host's `scripts` is walked. Deliberately not a curated list
|
|
976
|
-
* of interesting names: the review that nearly shipped this defect compared a
|
|
977
|
-
* GUESSED subset and concluded "ordering only". A subset is not a method.
|
|
978
|
-
* @param projectJson - The host manifest as it was before the apply
|
|
979
|
-
* @param packageJson - The manifest the apply is about to write
|
|
980
|
-
* @param template - Resolved template, for the reserved-base pairing
|
|
981
|
-
* @returns Operator-readable lines, empty when nothing was lost
|
|
982
|
-
*/
|
|
983
|
-
function describeScriptChanges(projectJson, packageJson, template) {
|
|
984
|
-
const before = asRecord(projectJson[SCRIPTS_SECTION]);
|
|
985
|
-
const after = asRecord(packageJson[SCRIPTS_SECTION]);
|
|
986
|
-
const adopted = asRecord(template.adopt[SCRIPTS_SECTION]);
|
|
987
|
-
return [
|
|
988
|
-
...describeOverwrittenScripts(before, after, adopted),
|
|
989
|
-
...describeUnrunGates(after, template),
|
|
990
|
-
];
|
|
991
|
-
}
|
|
992
|
-
/**
|
|
993
|
-
* Was this host value one Lisa itself wrote into that key?
|
|
994
|
-
* @param adopted - The resolved adopt list for the scripts section
|
|
995
|
-
* @param name - Script name being reported on
|
|
996
|
-
* @param hostValue - The value the host carried before the apply
|
|
997
|
-
* @returns True when the value is Lisa's own rather than the host's work
|
|
998
|
-
*/
|
|
999
|
-
function isLisaAuthored(adopted, name, hostValue) {
|
|
1000
|
-
const recognised = adopted[name];
|
|
1001
|
-
return Array.isArray(recognised) && recognised.includes(hostValue);
|
|
1002
|
-
}
|
|
1003
|
-
/**
|
|
1004
|
-
* Name every host script value this apply replaced or deleted.
|
|
1005
|
-
* @remarks
|
|
1006
|
-
* A value on the `adopt` list is Lisa's own, so replacing it discards nothing
|
|
1007
|
-
* of the host's and must not be reported as a loss. That is not cosmetic: the
|
|
1008
|
-
* split hands six gate names back at once, so loss-shaped wording there puts
|
|
1009
|
-
* six false alarms in front of every operator on their first upgrade and a
|
|
1010
|
-
* REAL loss stops standing out — the precise failure this change exists to
|
|
1011
|
-
* end. Those keys get a handover line instead, because the operator does need
|
|
1012
|
-
* to learn that the composition point is now theirs to extend.
|
|
1013
|
-
* @param before - The host's scripts before the apply
|
|
1014
|
-
* @param after - The scripts the apply is about to write
|
|
1015
|
-
* @param adopted - Resolved adopt list, naming the values Lisa authored
|
|
1016
|
-
* @returns One line per script whose host value did not survive
|
|
1017
|
-
*/
|
|
1018
|
-
function describeOverwrittenScripts(before, after, adopted) {
|
|
1019
|
-
return Object.entries(before).flatMap(([name, hostValue]) => {
|
|
1020
|
-
if (typeof hostValue !== "string")
|
|
1021
|
-
return [];
|
|
1022
|
-
const applied = after[name];
|
|
1023
|
-
if (applied === hostValue)
|
|
1024
|
-
return [];
|
|
1025
|
-
if (applied === undefined) {
|
|
1026
|
-
return [
|
|
1027
|
-
`Removed scripts.${name}; it ran ${quoteScript(hostValue)}. Nothing in your project runs that any more.`,
|
|
1028
|
-
];
|
|
1029
|
-
}
|
|
1030
|
-
if (typeof applied !== "string")
|
|
1031
|
-
return [];
|
|
1032
|
-
const base = `${name}${RESERVED_BASE_SUFFIX}`;
|
|
1033
|
-
// The handover wording names the reserved base, so it is only truthful
|
|
1034
|
-
// when the value being written actually invokes one.
|
|
1035
|
-
if (isLisaAuthored(adopted, name, hostValue) && applied.includes(base)) {
|
|
1036
|
-
return [
|
|
1037
|
-
`Moved Lisa's ${name} checks into scripts.${base}; scripts.${name} now calls it, so anything you add there survives the next apply.`,
|
|
1038
|
-
];
|
|
1039
|
-
}
|
|
1040
|
-
return [
|
|
1041
|
-
`Replaced scripts.${name}: it ran ${quoteScript(hostValue)} and now runs ${quoteScript(applied)}.`,
|
|
1042
|
-
];
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
/**
|
|
1046
|
-
* Name every Lisa gate the host's own composition point does not run.
|
|
1047
|
-
* @remarks
|
|
1048
|
-
* `lint:lisa` being force-installed proves the gate EXISTS; it proves nothing
|
|
1049
|
-
* about whether anything invokes it, and CI invokes `lint`. A host is free to
|
|
1050
|
-
* decline a gate, but declining it silently is the failure mode this whole
|
|
1051
|
-
* change is about, so the apply says which gate went unrun.
|
|
1052
|
-
*
|
|
1053
|
-
* A composition point that inlines Lisa's current base verbatim — the shape
|
|
1054
|
-
* every host was left in before the split existed — does run the gate, so it is
|
|
1055
|
-
* not warned about. It is nudged instead: an inlined copy stops tracking the
|
|
1056
|
-
* template the next time the base changes.
|
|
1057
|
-
* @param after - The scripts the apply is about to write
|
|
1058
|
-
* @param template - Resolved template carrying the forced reserved bases
|
|
1059
|
-
* @returns One line per gate nothing invokes, plus migration nudges
|
|
1060
|
-
*/
|
|
1061
|
-
function describeUnrunGates(after, template) {
|
|
1062
|
-
const forcedScripts = asRecord(asRecord(template.force)[SCRIPTS_SECTION]);
|
|
1063
|
-
return Object.keys(forcedScripts).flatMap(base => {
|
|
1064
|
-
if (!base.endsWith(RESERVED_BASE_SUFFIX))
|
|
1065
|
-
return [];
|
|
1066
|
-
const composed = base.slice(0, -RESERVED_BASE_SUFFIX.length);
|
|
1067
|
-
const hostValue = after[composed];
|
|
1068
|
-
if (typeof hostValue !== "string" || hostValue.includes(base))
|
|
1069
|
-
return [];
|
|
1070
|
-
const baseValue = forcedScripts[base];
|
|
1071
|
-
if (typeof baseValue === "string" && hostValue.includes(baseValue)) {
|
|
1072
|
-
return [
|
|
1073
|
-
`Kept your scripts.${composed}. It spells out Lisa's ${composed} checks instead of calling ${base}, so it will not pick up changes to them; run ${base} from it to stay current.`,
|
|
1074
|
-
];
|
|
1075
|
-
}
|
|
1076
|
-
return [
|
|
1077
|
-
`Kept your scripts.${composed}, but nothing invokes ${base}, so Lisa's ${composed} checks do not run. Add ${base} to scripts.${composed} to turn them back on.`,
|
|
1078
|
-
];
|
|
1079
|
-
});
|
|
1080
|
-
}
|
|
1081
|
-
/**
|
|
1082
|
-
* Every section whose forced values are a version FLOOR rather than an
|
|
1083
|
-
* assignment, and which therefore may never be merged downwards.
|
|
1084
|
-
* @remarks
|
|
1085
|
-
* `overrides`/`resolutions` alone was the original list, and it left the hole
|
|
1086
|
-
* this exists to close: `overrides.tar` is `"$tar"`, npm's self-reference, so
|
|
1087
|
-
* its effective floor IS `dependencies.tar`. Guarding only the override
|
|
1088
|
-
* sections preserved a `$tar` that had quietly come to mean something weaker —
|
|
1089
|
-
* the protection intact and hollow at the same time, with a test asserting the
|
|
1090
|
-
* override survived passing either way.
|
|
1091
|
-
*/
|
|
1092
|
-
const FLOOR_SECTIONS = [
|
|
1093
|
-
...DIRECT_DEPENDENCY_SECTIONS,
|
|
1094
|
-
...OVERRIDE_SECTIONS,
|
|
1095
|
-
];
|
|
1096
|
-
/**
|
|
1097
|
-
* Restore host dependency pins that sit ABOVE Lisa's template.
|
|
1098
|
-
* @remarks
|
|
1099
|
-
* Every `force` pin exists to push a project PAST a CVE, so it is a security
|
|
1100
|
-
* FLOOR — not an assignment. Phase 1 applies it with `deepMerge`, where Lisa's
|
|
1101
|
-
* value wins unconditionally, and that is only correct while the template is the
|
|
1102
|
-
* higher of the two. The moment a host raises a pin beyond the template (or the
|
|
1103
|
-
* template simply lags a fresh advisory), the same "security write" silently
|
|
1104
|
-
* walks the host BACKWARDS into the vulnerable range it had already escaped.
|
|
1105
|
-
*
|
|
1106
|
-
* This is not hypothetical: a caller repo in the portfolio pinned at
|
|
1107
|
-
* `dependencies.tar >=7.5.21` was reverted to `>=7.5.19` on every `bun install`,
|
|
1108
|
-
* readmitting the two releases GHSA-r292-9mhp-454m covers. A floor can only be
|
|
1109
|
-
* right by coincidence when it is written as an overwrite.
|
|
1110
|
-
*
|
|
1111
|
-
* The decision is deliberately narrow, because Lisa must be able to PROVE the
|
|
1112
|
-
* host is ahead — the same standard `preserveIfHostAhead` holds the file lane
|
|
1113
|
-
* to, applied to the strictly easier case where a semver range makes "ahead"
|
|
1114
|
-
* decidable rather than merely suspected:
|
|
1115
|
-
*
|
|
1116
|
-
* - Host floor not above Lisa's: Lisa is raising, which is the whole point of
|
|
1117
|
-
* the mechanism. Phase 1 stands.
|
|
1118
|
-
* - Host floor above Lisa's AND the host range is a subset of Lisa's: the host
|
|
1119
|
-
* admits only versions Lisa allows, so it is provably the stricter of the
|
|
1120
|
-
* two. Keep the host.
|
|
1121
|
-
* - Host floor above Lisa's and neither range contains the other: both sides
|
|
1122
|
-
* carry a constraint the other drops. Lisa cannot decide it, so it REFUSES
|
|
1123
|
-
* and names both rather than picking one — silently picking one is how a
|
|
1124
|
-
* lowered floor shipped in the first place.
|
|
1125
|
-
*
|
|
1126
|
-
* A value that cannot be parsed — npm's `"$name"` self-references, git URLs,
|
|
1127
|
-
* `workspace:*` — is left as Phase 1 produced it, so this can only ever RAISE
|
|
1128
|
-
* a pin or stop.
|
|
1129
|
-
* @param projectJson - The host package.json as it was before Phase 1.
|
|
1130
|
-
* @param afterForce - The result of Phase 1's force merge.
|
|
1131
|
-
* @param fileName - Basename used in error messages.
|
|
1132
|
-
* @throws JsonMergeError when a host pin is higher but the two ranges are
|
|
1133
|
-
* incomparable.
|
|
1134
|
-
* @returns `afterForce` with host-side higher pins restored, plus notes.
|
|
1135
|
-
*/
|
|
1136
|
-
function preserveHigherHostPins(projectJson, afterForce, fileName) {
|
|
1137
|
-
return FLOOR_SECTIONS.reduce((plan, section) => {
|
|
1138
|
-
const forcedSection = asRecord(plan.packageJson[section]);
|
|
1139
|
-
const preserved = collectPreservedPins(section, asRecord(projectJson[section]), forcedSection, fileName);
|
|
1140
|
-
if (preserved.length === 0) {
|
|
1141
|
-
return plan;
|
|
1142
|
-
}
|
|
1143
|
-
return {
|
|
1144
|
-
packageJson: {
|
|
1145
|
-
...plan.packageJson,
|
|
1146
|
-
[section]: {
|
|
1147
|
-
...forcedSection,
|
|
1148
|
-
...Object.fromEntries(preserved.map(pin => [pin.name, pin.hostRange])),
|
|
1149
|
-
},
|
|
1150
|
-
},
|
|
1151
|
-
notes: [...plan.notes, ...preserved.map(formatPreservedPinNote)],
|
|
1152
|
-
};
|
|
1153
|
-
}, { packageJson: afterForce, notes: [] });
|
|
1154
|
-
}
|
|
1155
|
-
/**
|
|
1156
|
-
* Find every host pin in one section that must survive Phase 1's force merge.
|
|
1157
|
-
* @param section - Section name, used in notes and error messages
|
|
1158
|
-
* @param hostSection - The host's entries for this section, pre-merge
|
|
1159
|
-
* @param forcedSection - The entries Phase 1 produced for this section
|
|
1160
|
-
* @param fileName - Basename used in error messages
|
|
1161
|
-
* @throws JsonMergeError on the first incomparable pin
|
|
1162
|
-
* @returns Pins whose host value must be restored
|
|
1163
|
-
*/
|
|
1164
|
-
function collectPreservedPins(section, hostSection, forcedSection, fileName) {
|
|
1165
|
-
return Object.entries(hostSection).flatMap(([name, hostValue]) => {
|
|
1166
|
-
const forcedValue = forcedSection[name];
|
|
1167
|
-
const verdict = classifyHostPin(hostValue, forcedValue);
|
|
1168
|
-
if (verdict === "template") {
|
|
1169
|
-
return [];
|
|
1170
|
-
}
|
|
1171
|
-
const pin = {
|
|
1172
|
-
section,
|
|
1173
|
-
name,
|
|
1174
|
-
hostRange: hostValue,
|
|
1175
|
-
forcedRange: forcedValue,
|
|
1176
|
-
};
|
|
1177
|
-
if (verdict === "incomparable") {
|
|
1178
|
-
throw new JsonMergeError(fileName, formatIncomparablePinMessage(pin));
|
|
1179
|
-
}
|
|
1180
|
-
return [pin];
|
|
1181
|
-
});
|
|
1182
|
-
}
|
|
1183
|
-
/**
|
|
1184
|
-
* Decide what to do with one dependency where host and template disagree.
|
|
1185
|
-
* @param hostValue - The host's range for this dependency.
|
|
1186
|
-
* @param forcedValue - The range Phase 1 wrote for the same dependency.
|
|
1187
|
-
* @returns Which side wins, or `incomparable` when neither can be proven ahead.
|
|
1188
|
-
*/
|
|
1189
|
-
function classifyHostPin(hostValue, forcedValue) {
|
|
1190
|
-
if (typeof hostValue !== "string" || typeof forcedValue !== "string") {
|
|
1191
|
-
return "template";
|
|
1192
|
-
}
|
|
1193
|
-
const hostFloor = rangeFloor(hostValue);
|
|
1194
|
-
const forcedFloor = rangeFloor(forcedValue);
|
|
1195
|
-
if (hostFloor === null ||
|
|
1196
|
-
forcedFloor === null ||
|
|
1197
|
-
!semver.gt(hostFloor, forcedFloor)) {
|
|
1198
|
-
return "template";
|
|
1199
|
-
}
|
|
1200
|
-
return rangeContains(forcedValue, hostValue) ? "host" : "incomparable";
|
|
1201
|
-
}
|
|
1202
|
-
/**
|
|
1203
|
-
* npm's exclusive-ceiling convention: the lowest possible prerelease of the
|
|
1204
|
-
* excluded version, so that no prerelease of it is admitted.
|
|
1205
|
-
*/
|
|
1206
|
-
const CEILING_PRERELEASE_SENTINEL = "-0";
|
|
1207
|
-
/**
|
|
1208
|
-
* Rewrite a range's bare `<X.Y.Z` ceilings into npm's `<X.Y.Z-0` form.
|
|
1209
|
-
* @remarks
|
|
1210
|
-
* `semver` desugars `^5.0.1` to `>=5.0.1 <6.0.0-0` — the `-0` sentinel excludes
|
|
1211
|
-
* every prerelease of the ceiling. A hand-written `>=5.0.9 <6.0.0` carries no
|
|
1212
|
-
* sentinel, and since `6.0.0-0 < 6.0.0`, its interval is strictly the taller of
|
|
1213
|
-
* the two: it contains the points `6.0.0-0` and `6.0.0-alpha.1` that the caret
|
|
1214
|
-
* form excludes. `semver.subset` is pure interval algebra, so it answers `false`
|
|
1215
|
-
* for `subset(">=5.0.9 <6.0.0", "^5.0.1")` — correctly, for the intervals as
|
|
1216
|
-
* literally written. That is not a `semver` defect and there is nothing upstream
|
|
1217
|
-
* to wait for.
|
|
1218
|
-
*
|
|
1219
|
-
* It is still the wrong answer to the question this module is asking. Those
|
|
1220
|
-
* extra points are not versions any install can select: `satisfies` excludes
|
|
1221
|
-
* prereleases unless a comparator names the same `major.minor.patch` with its
|
|
1222
|
-
* own prerelease tag, so `6.0.0-alpha.1` satisfies NEITHER range. The two
|
|
1223
|
-
* spellings admit exactly the same installable versions, and the disagreement is
|
|
1224
|
-
* an artifact of which spelling the operator reached for — which is precisely
|
|
1225
|
-
* the symptom: `^5.0.9` was accepted while the identical interval written as
|
|
1226
|
-
* `>=5.0.9 <6.0.0` was refused, telling the operator the guard was broken rather
|
|
1227
|
-
* than the range wrong.
|
|
1228
|
-
*
|
|
1229
|
-
* `includePrerelease: true` does not fix it — it widens BOTH sides, so the
|
|
1230
|
-
* ceilings stay unequal and the subset test still fails. Putting both sides into
|
|
1231
|
-
* one convention is what makes them comparable.
|
|
1232
|
-
*
|
|
1233
|
-
* Only a bare `<` ceiling is rewritten. `<=X.Y.Z` is left alone because it
|
|
1234
|
-
* genuinely admits `X.Y.Z` itself, and a ceiling that already carries a
|
|
1235
|
-
* prerelease tag already says what it means. A range with no `<` comparator at
|
|
1236
|
-
* all — an unbounded `>=5.0.9`, or `*` — comes back untouched and stays
|
|
1237
|
-
* incomparable, which is the bite that protects a hardened floor.
|
|
1238
|
-
* @param range - An npm version range.
|
|
1239
|
-
* @returns The same range with bare exclusive ceilings carrying the sentinel.
|
|
1240
|
-
*/
|
|
1241
|
-
function normalizeRangeCeilings(range) {
|
|
1242
|
-
return new semver.Range(range).set
|
|
1243
|
-
.map(comparators => comparators.map(comparator => formatCeiling(comparator)).join(" "))
|
|
1244
|
-
.join(" || ");
|
|
1245
|
-
}
|
|
1246
|
-
/**
|
|
1247
|
-
* Render one comparator, adding the prerelease sentinel to a bare `<` ceiling.
|
|
1248
|
-
* @param comparator - A single parsed comparator from a range's comparator set.
|
|
1249
|
-
* @returns The comparator's source text, or its sentinel-carrying equivalent.
|
|
1250
|
-
*/
|
|
1251
|
-
function formatCeiling(comparator) {
|
|
1252
|
-
const version = comparator.semver;
|
|
1253
|
-
if (comparator.operator !== "<" ||
|
|
1254
|
-
version === undefined ||
|
|
1255
|
-
version === null ||
|
|
1256
|
-
version.prerelease.length > 0) {
|
|
1257
|
-
return comparator.value;
|
|
1258
|
-
}
|
|
1259
|
-
return `<${version.major}.${version.minor}.${version.patch}${CEILING_PRERELEASE_SENTINEL}`;
|
|
1260
|
-
}
|
|
1261
|
-
/**
|
|
1262
|
-
* Decide whether every version one range admits is admitted by another.
|
|
1263
|
-
* @remarks
|
|
1264
|
-
* Both sides are put into one ceiling convention first — see
|
|
1265
|
-
* {@link normalizeRangeCeilings} — so that a caret and the compound range that
|
|
1266
|
-
* desugars to the same interval reach the same verdict. Normalizing can only
|
|
1267
|
-
* LOWER a bare ceiling, so it can only turn a `false` into a `true`; the
|
|
1268
|
-
* direction is safe here because this branch KEEPS a host pin whose floor is
|
|
1269
|
-
* already proven higher, and keeping a higher floor can never lower one.
|
|
1270
|
-
*
|
|
1271
|
-
* A value `semver` cannot parse at all — `"$name"` self-references, `npm:`
|
|
1272
|
-
* aliases, `workspace:`, `file:` and git specs — throws here and is reported as
|
|
1273
|
-
* "does not contain", exactly as before.
|
|
1274
|
-
* @param outer - The wider candidate range.
|
|
1275
|
-
* @param inner - The narrower candidate range.
|
|
1276
|
-
* @returns True when `inner` admits nothing `outer` forbids.
|
|
1277
|
-
*/
|
|
1278
|
-
function rangeContains(outer, inner) {
|
|
1279
|
-
try {
|
|
1280
|
-
return semver.subset(normalizeRangeCeilings(inner), normalizeRangeCeilings(outer));
|
|
1281
|
-
}
|
|
1282
|
-
catch {
|
|
1283
|
-
return false;
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
/**
|
|
1287
|
-
* Format the operator-visible explanation for a preserved host pin.
|
|
1288
|
-
* @param pin - The pin that was kept, with both ranges
|
|
1289
|
-
* @returns Human-readable note for apply output
|
|
1290
|
-
*/
|
|
1291
|
-
function formatPreservedPinNote(pin) {
|
|
1292
|
-
return (`Kept host ${pin.section}.${pin.name} ${JSON.stringify(pin.hostRange)}: ` +
|
|
1293
|
-
`it admits only versions Lisa's ${JSON.stringify(pin.forcedRange)} allows ` +
|
|
1294
|
-
`and starts higher, so applying the template would lower the host's floor.`);
|
|
1295
|
-
}
|
|
1296
|
-
/**
|
|
1297
|
-
* Format the refusal for a host pin Lisa cannot prove itself ahead of.
|
|
1298
|
-
* @param pin - The pin that could not be decided, with both ranges
|
|
1299
|
-
* @returns Human-readable error message naming both ranges
|
|
1300
|
-
*/
|
|
1301
|
-
function formatIncomparablePinMessage(pin) {
|
|
1302
|
-
return (`${pin.section}.${pin.name} cannot be merged: the host range ` +
|
|
1303
|
-
`${JSON.stringify(pin.hostRange)} starts above Lisa's ` +
|
|
1304
|
-
`${JSON.stringify(pin.forcedRange)}, but neither range contains the other, ` +
|
|
1305
|
-
`so each admits versions the other forbids and Lisa cannot prove which is ` +
|
|
1306
|
-
`correct. Overwriting the host here is how a hardened floor gets silently ` +
|
|
1307
|
-
`lowered, so this apply stops instead. Reconcile the two by hand: pick one ` +
|
|
1308
|
-
`range in the host package.json that satisfies both constraints, or raise ` +
|
|
1309
|
-
`Lisa's template pin to cover the host's.`);
|
|
1310
|
-
}
|
|
1311
|
-
/**
|
|
1312
|
-
* Resolve the lowest version a range admits.
|
|
1313
|
-
* @param range - An npm version range.
|
|
1314
|
-
* @returns The minimum version, or null when the range is not comparable.
|
|
1315
|
-
*/
|
|
1316
|
-
function rangeFloor(range) {
|
|
1317
|
-
try {
|
|
1318
|
-
return semver.minVersion(range)?.version ?? null;
|
|
1319
|
-
}
|
|
1320
|
-
catch {
|
|
1321
|
-
return null;
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
/**
|
|
1325
|
-
* Hold a host's direct ranges at or above Lisa's minimums, refusing a raise
|
|
1326
|
-
* that would cross a major.
|
|
1327
|
-
* @param pkg - Merged package.json about to be persisted
|
|
1328
|
-
* @param minimums - The merged template's minimums
|
|
1329
|
-
* @param fileName - Basename used in error messages
|
|
1330
|
-
* @throws {JsonMergeError} naming every range no same-major raise reaches
|
|
1331
|
-
* @returns The manifest with raised ranges, and each raise made
|
|
1332
|
-
*/
|
|
1333
|
-
function holdDirectMinimums(pkg, minimums, fileName) {
|
|
1334
|
-
const held = applyDirectMinimums(pkg, minimums);
|
|
1335
|
-
const [first, ...rest] = held.conflicts;
|
|
1336
|
-
if (first !== undefined) {
|
|
1337
|
-
throw new JsonMergeError(fileName, describeDirectMinimumConflicts([first, ...rest]));
|
|
1338
|
-
}
|
|
1339
|
-
return held;
|
|
1340
|
-
}
|
|
1341
|
-
/**
|
|
1342
|
-
* Rewrite literal `overrides`/`resolutions` entries into npm's `"$name"`
|
|
1343
|
-
* self-reference form when the overridden package is also a direct dependency.
|
|
1344
|
-
* @remarks
|
|
1345
|
-
* npm rejects a manifest with `EOVERRIDE` when an `overrides`/`resolutions` key
|
|
1346
|
-
* that is also a direct dependency carries a literal version instead of the
|
|
1347
|
-
* `"$name"` self-reference — e.g. a security remediation force-bumping
|
|
1348
|
-
* `prettier` in `overrides` while `prettier` stays a direct devDependency. npm
|
|
1349
|
-
* runs this validation before doing anything, so the broken manifest fails every
|
|
1350
|
-
* `npx`/`npm` invocation in the project directory (including plugin MCP servers
|
|
1351
|
-
* spawned via `npx`), not just installs. Normalizing to `$name` — the same form
|
|
1352
|
-
* Lisa's own templates use (e.g. `"vite": "$vite"`) — resolves the override
|
|
1353
|
-
* against the direct dependency and satisfies npm, healing a hand-injected or
|
|
1354
|
-
* agent-injected override on the next apply without touching the project by hand.
|
|
1355
|
-
*
|
|
1356
|
-
* Only top-level string entries are rewritten: those are what trigger EOVERRIDE.
|
|
1357
|
-
* Existing `$name` references and nested (parent-scoped) override objects are
|
|
1358
|
-
* left untouched. Overrides for packages that are NOT direct dependencies are
|
|
1359
|
-
* also left as literals — those are legitimate transitive pins.
|
|
1360
|
-
* @param pkg - Merged package.json about to be persisted
|
|
1361
|
-
* @param fileName - Basename used in error messages
|
|
1362
|
-
* @throws JsonMergeError when a rewrite would make the effective override wider
|
|
1363
|
-
* than the literal constraint it replaced.
|
|
1364
|
-
* @returns Planned package.json plus operator-visible notes.
|
|
1365
|
-
*/
|
|
1366
|
-
function planSelfReferencingOverrideNormalization(pkg, fileName) {
|
|
1367
|
-
const audit = auditSelfReferenceRewrites(pkg);
|
|
1368
|
-
const refused = audit.conflicts[0];
|
|
1369
|
-
if (refused !== undefined) {
|
|
1370
|
-
throw new JsonMergeError(fileName, formatSelfReferenceRefusal(refused));
|
|
1371
|
-
}
|
|
1372
|
-
if (audit.rewritable.length === 0) {
|
|
1373
|
-
return { packageJson: pkg, notes: [] };
|
|
1374
|
-
}
|
|
1375
|
-
const sections = OVERRIDE_SECTIONS.flatMap(section => {
|
|
1376
|
-
const rewrites = audit.rewritable.filter(rewrite => rewrite.section === section);
|
|
1377
|
-
if (rewrites.length === 0) {
|
|
1378
|
-
return [];
|
|
1379
|
-
}
|
|
1380
|
-
const normalized = Object.fromEntries(Object.entries(asRecord(pkg[section])).map(([name, value]) => rewrites.some(rewrite => rewrite.name === name)
|
|
1381
|
-
? [name, `$${name}`]
|
|
1382
|
-
: [name, value]));
|
|
1383
|
-
return [[section, normalized]];
|
|
1384
|
-
});
|
|
1385
|
-
return {
|
|
1386
|
-
packageJson: { ...pkg, ...Object.fromEntries(sections) },
|
|
1387
|
-
notes: audit.rewritable.map(formatSelfReferenceRewriteNote),
|
|
1388
|
-
};
|
|
1389
|
-
}
|
|
1390
|
-
/**
|
|
1391
|
-
* Explain a refused `$name` rewrite, ending with a remedy Lisa has TESTED.
|
|
1392
|
-
* @remarks
|
|
1393
|
-
* The old message ended "Pin the direct dependency to <the override> or choose
|
|
1394
|
-
* a direct range that is no wider" — advice naming no concrete range which, for
|
|
1395
|
-
* a bounded floor, is not satisfiable by the obvious reading of it. An operator
|
|
1396
|
-
* who follows a refusal's own instructions and is refused a second time
|
|
1397
|
-
* concludes the guard is broken rather than the range wrong
|
|
1398
|
-
* (CodySwannGT/lisa#3191), which is how a correct security control gets routed
|
|
1399
|
-
* around. The replacement names ONE range and has run it back through the same
|
|
1400
|
-
* predicate that produced the refusal.
|
|
1401
|
-
* @param conflict - The conflict that stopped the apply
|
|
1402
|
-
* @returns Human-readable refusal naming both ranges and the verified raise
|
|
1403
|
-
*/
|
|
1404
|
-
function formatSelfReferenceRefusal(conflict) {
|
|
1405
|
-
const remedy = describeSelfReferenceRemedy(conflict);
|
|
1406
|
-
if (conflict.verdict === "unprovable") {
|
|
1407
|
-
return (`${conflict.section}.${conflict.name} cannot be rewritten to ` +
|
|
1408
|
-
`"$${conflict.name}" because Lisa cannot prove the direct dependency ` +
|
|
1409
|
-
`range ${JSON.stringify(conflict.directRange)} is no wider than the ` +
|
|
1410
|
-
`literal override ${JSON.stringify(conflict.floorRange)}. ${remedy}`);
|
|
1411
|
-
}
|
|
1412
|
-
return (`${conflict.section}.${conflict.name} would widen if rewritten to ` +
|
|
1413
|
-
`"$${conflict.name}": the literal override ` +
|
|
1414
|
-
`${JSON.stringify(conflict.floorRange)} would resolve to direct ` +
|
|
1415
|
-
`dependency range ${JSON.stringify(conflict.directRange)}. ${remedy}`);
|
|
1416
|
-
}
|
|
1417
|
-
/**
|
|
1418
|
-
* Format the operator-visible explanation for a safe `$name` rewrite.
|
|
1419
|
-
* @param rewrite - Rewrite metadata
|
|
1420
|
-
* @returns Human-readable note for apply output
|
|
1421
|
-
*/
|
|
1422
|
-
function formatSelfReferenceRewriteNote(rewrite) {
|
|
1423
|
-
return (`Normalized ${rewrite.section}.${rewrite.name}: replaced literal ` +
|
|
1424
|
-
`${JSON.stringify(rewrite.floorRange)} with "$${rewrite.name}" ` +
|
|
1425
|
-
`resolving to direct dependency range ` +
|
|
1426
|
-
`${JSON.stringify(rewrite.directRange)}.`);
|
|
1427
|
-
}
|
|
1428
|
-
/**
|
|
1429
|
-
* Recursively collect every `$name` reference found in a single JSON value. npm
|
|
1430
|
-
* overrides/resolutions use a `"$name"` string value to mean "resolve to the
|
|
1431
|
-
* version of the direct dependency `name`", and the reference may appear at any
|
|
1432
|
-
* nesting depth (npm allows nested override objects).
|
|
1433
|
-
* @param value - JSON value to scan
|
|
1434
|
-
* @returns Referenced package names (without the leading `$`), possibly with dups
|
|
1435
|
-
*/
|
|
1436
|
-
function collectRefsFromValue(value) {
|
|
1437
|
-
if (typeof value === "string") {
|
|
1438
|
-
const match = /^\$(.+)$/.exec(value);
|
|
1439
|
-
return match?.[1] !== undefined ? [match[1]] : [];
|
|
1440
|
-
}
|
|
1441
|
-
if (Array.isArray(value)) {
|
|
1442
|
-
return value.flatMap(collectRefsFromValue);
|
|
1443
|
-
}
|
|
1444
|
-
if (value !== null && typeof value === "object") {
|
|
1445
|
-
return Object.values(value).flatMap(collectRefsFromValue);
|
|
1446
|
-
}
|
|
1447
|
-
return [];
|
|
1448
|
-
}
|
|
1449
|
-
/**
|
|
1450
|
-
* Collect the distinct `$name` references across the given sections (typically
|
|
1451
|
-
* overrides and resolutions).
|
|
1452
|
-
* @param sections - Values to scan
|
|
1453
|
-
* @returns Set of referenced package names (without the leading `$`)
|
|
1454
|
-
*/
|
|
1455
|
-
function collectDollarReferences(sections) {
|
|
1456
|
-
return new Set(sections.flatMap(collectRefsFromValue));
|
|
1457
|
-
}
|
|
1458
|
-
/**
|
|
1459
|
-
* Collect top-level literal override keys that may later normalize to `$name`.
|
|
1460
|
-
* @param sections - Override/resolution sections to inspect
|
|
1461
|
-
* @returns Set of package names with non-empty literal string entries
|
|
1462
|
-
*/
|
|
1463
|
-
function collectLiteralOverrideNames(sections) {
|
|
1464
|
-
return new Set(sections.flatMap(section => {
|
|
1465
|
-
const entries = asRecord(section);
|
|
1466
|
-
return Object.entries(entries).flatMap(([name, value]) => typeof value === "string" && value.length > 0 && !value.startsWith("$")
|
|
1467
|
-
? [name]
|
|
1468
|
-
: []);
|
|
1469
|
-
}));
|
|
1470
|
-
}
|
|
1471
|
-
/**
|
|
1472
|
-
* Fail the apply when the merged package.json carries a `$name` self-reference
|
|
1473
|
-
* in overrides/resolutions without the backing direct dependency. Writing such
|
|
1474
|
-
* a file leaves a dangling $ref that passes local checks but breaks `npm ci` in
|
|
1475
|
-
* CI only. Throwing here surfaces the misconfiguration at apply time instead.
|
|
1476
|
-
* @param pkg - Merged package.json about to be written
|
|
1477
|
-
* @param fileName - Basename used in the error message
|
|
1478
|
-
* @throws JsonMergeError when any `$name` reference lacks a matching direct dep
|
|
1479
|
-
*/
|
|
1480
|
-
function assertNoDanglingDollarRefs(pkg, fileName) {
|
|
1481
|
-
const referenced = collectDollarReferences([pkg.overrides, pkg.resolutions]);
|
|
1482
|
-
if (referenced.size === 0) {
|
|
1483
|
-
return;
|
|
1484
|
-
}
|
|
1485
|
-
const directDeps = collectDirectDependencyNames(pkg);
|
|
1486
|
-
const missing = Array.from(referenced).filter(name => !directDeps.has(name));
|
|
1487
|
-
if (missing.length === 0) {
|
|
1488
|
-
return;
|
|
1489
|
-
}
|
|
1490
|
-
const refs = missing.map(name => `$${name}`).join(", ");
|
|
1491
|
-
const isPlural = missing.length > 1;
|
|
1492
|
-
throw new JsonMergeError(fileName, `Dangling ${refs} in overrides/resolutions: a "$name" self-reference ` +
|
|
1493
|
-
`requires "name" to be a direct dependency, but ${missing.join(", ")} ` +
|
|
1494
|
-
`${isPlural ? "are" : "is"} not present in ` +
|
|
1495
|
-
`dependencies/devDependencies. Add a force.devDependencies entry for ` +
|
|
1496
|
-
`${isPlural ? "each" : "it"} in package.lisa.json, or drop the reference.`);
|
|
1497
|
-
}
|
|
1498
|
-
/**
|
|
1499
|
-
* Fail the apply when a dependency section carries an unsubstituted `$name`
|
|
1500
|
-
* placeholder instead of a version range.
|
|
1501
|
-
* @remarks
|
|
1502
|
-
* `$name` is real npm syntax, but only as an `overrides`/`resolutions` value,
|
|
1503
|
-
* where it means "resolve to the version of the direct dependency `name`".
|
|
1504
|
-
* A dependency section is not one of those places: npm reads the value as a
|
|
1505
|
-
* literal dist-tag and refuses the whole manifest before doing any work —
|
|
1506
|
-
* `EINVALIDTAGNAME: Invalid tag name "$tar" of package "tar@$tar"`. Every
|
|
1507
|
-
* `npm`/`npx` in the project directory fails from then on, including the
|
|
1508
|
-
* plugin MCP servers Lisa spawns via `npx`.
|
|
1509
|
-
*
|
|
1510
|
-
* So a `$name` here is never a self-reference npm will resolve; it is a
|
|
1511
|
-
* placeholder something failed to substitute. Throwing at apply time keeps the
|
|
1512
|
-
* failure attached to the thing that caused it, instead of leaving an
|
|
1513
|
-
* uninstallable manifest for whoever runs the next install to discover.
|
|
1514
|
-
*
|
|
1515
|
-
* This also catches the reference-to-a-reference case the dangling-$ref guard
|
|
1516
|
-
* cannot: that check is presence-only, so `dependencies.tar = "$tar"` reads as
|
|
1517
|
-
* a valid backing dependency for `overrides.tar = "$tar"` even though npm can
|
|
1518
|
-
* resolve neither. Only dependency sections are inspected — `scripts` values
|
|
1519
|
-
* like `$npm_execpath` are shell variables and are left alone.
|
|
1520
|
-
* @param pkg - Merged package.json about to be written
|
|
1521
|
-
* @param fileName - Basename used in the error message
|
|
1522
|
-
* @throws JsonMergeError when any dependency section value is a `$name` token
|
|
1523
|
-
*/
|
|
1524
|
-
function assertNoUnsubstitutedDollarTokens(pkg, fileName) {
|
|
1525
|
-
const offenders = DIRECT_DEPENDENCY_SECTIONS.flatMap(section => Object.entries(asRecord(pkg[section])).flatMap(([name, value]) => typeof value === "string" && value.startsWith("$")
|
|
1526
|
-
? [`${section}.${name} = ${JSON.stringify(value)}`]
|
|
1527
|
-
: []));
|
|
1528
|
-
if (offenders.length === 0) {
|
|
1529
|
-
return;
|
|
1530
|
-
}
|
|
1531
|
-
const isPlural = offenders.length > 1;
|
|
1532
|
-
throw new JsonMergeError(fileName, `Unsubstituted placeholder${isPlural ? "s" : ""} in dependency ` +
|
|
1533
|
-
`${isPlural ? "sections" : "section"}: ${offenders.join(", ")}. ` +
|
|
1534
|
-
`A "$name" value is only valid inside overrides/resolutions, where npm ` +
|
|
1535
|
-
`resolves it to the version of the direct dependency "name". In ` +
|
|
1536
|
-
`dependencies/devDependencies/optionalDependencies/peerDependencies npm ` +
|
|
1537
|
-
`reads it as a literal version tag and rejects the whole manifest with ` +
|
|
1538
|
-
`EINVALIDTAGNAME, so every npm and npx command in the project fails. ` +
|
|
1539
|
-
`Replace ${isPlural ? "each placeholder" : "the placeholder"} with a real ` +
|
|
1540
|
-
`version range.`);
|
|
1541
|
-
}
|
|
1542
|
-
/**
|
|
1543
|
-
* Refuse to persist a package.json npm could not install. Single choke point:
|
|
1544
|
-
* every path that writes a manifest runs this, so a new writer cannot pick up
|
|
1545
|
-
* one half of the validation and miss the other.
|
|
1546
|
-
* @param pkg - Merged package.json about to be written
|
|
1547
|
-
* @param fileName - Basename used in error messages
|
|
1548
|
-
* @throws JsonMergeError when the manifest carries an unresolvable `$name`
|
|
1549
|
-
*/
|
|
1550
|
-
function assertManifestIsInstallable(pkg, fileName) {
|
|
1551
|
-
assertNoUnsubstitutedDollarTokens(pkg, fileName);
|
|
1552
|
-
assertNoDanglingDollarRefs(pkg, fileName);
|
|
1553
|
-
}
|
|
1554
|
-
/* eslint-enable max-lines -- Re-enable after comprehensive package merge strategy */
|
|
1555
|
-
/**
|
|
1556
|
-
* Count the literal version floors a resolved template would write.
|
|
1557
|
-
*
|
|
1558
|
-
* A `$name` entry is not counted: it carries no floor of its own, so it can
|
|
1559
|
-
* never be the thing a host range resolves below.
|
|
1560
|
-
* @param template - Fully resolved package.lisa.json template
|
|
1561
|
-
* @returns Number of literal entries across force.overrides and force.resolutions
|
|
1562
|
-
*/
|
|
1563
|
-
function countTemplateFloors(template) {
|
|
1564
|
-
return OVERRIDE_SECTIONS.reduce((total, section) => total +
|
|
1565
|
-
Object.values(asRecord(template.force[section])).filter(value => typeof value === "string" && !value.startsWith("$")).length, 0);
|
|
1566
260
|
}
|
|
1567
261
|
//# sourceMappingURL=package-lisa.js.map
|