@unbrained/pm-cli 2026.5.18 → 2026.5.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +953 -472
- package/README.md +4 -11
- package/dist/cli/bootstrap-args.d.ts +18 -1
- package/dist/cli/bootstrap-args.js +143 -3
- package/dist/cli/bootstrap-args.js.map +1 -1
- package/dist/cli/commander-usage.js +147 -10
- package/dist/cli/commander-usage.js.map +1 -1
- package/dist/cli/commands/annotation-command.d.ts +49 -0
- package/dist/cli/commands/annotation-command.js +135 -0
- package/dist/cli/commands/annotation-command.js.map +1 -0
- package/dist/cli/commands/append.js +5 -8
- package/dist/cli/commands/append.js.map +1 -1
- package/dist/cli/commands/calendar.js +3 -6
- package/dist/cli/commands/calendar.js.map +1 -1
- package/dist/cli/commands/claim.js +15 -24
- package/dist/cli/commands/claim.js.map +1 -1
- package/dist/cli/commands/close.js +63 -10
- package/dist/cli/commands/close.js.map +1 -1
- package/dist/cli/commands/comments.d.ts +5 -0
- package/dist/cli/commands/comments.js +27 -117
- package/dist/cli/commands/comments.js.map +1 -1
- package/dist/cli/commands/completion.d.ts +2 -2
- package/dist/cli/commands/completion.js +203 -63
- package/dist/cli/commands/completion.js.map +1 -1
- package/dist/cli/commands/config.d.ts +1 -1
- package/dist/cli/commands/config.js +82 -4
- package/dist/cli/commands/config.js.map +1 -1
- package/dist/cli/commands/context.js +4 -10
- package/dist/cli/commands/context.js.map +1 -1
- package/dist/cli/commands/contracts.js +168 -36
- package/dist/cli/commands/contracts.js.map +1 -1
- package/dist/cli/commands/create.js +53 -313
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/commands/dedupe-audit.js +7 -4
- package/dist/cli/commands/dedupe-audit.js.map +1 -1
- package/dist/cli/commands/delete.d.ts +3 -0
- package/dist/cli/commands/delete.js +11 -9
- package/dist/cli/commands/delete.js.map +1 -1
- package/dist/cli/commands/docs.d.ts +2 -12
- package/dist/cli/commands/docs.js +8 -316
- package/dist/cli/commands/docs.js.map +1 -1
- package/dist/cli/commands/event-validation-messages.d.ts +3 -0
- package/dist/cli/commands/event-validation-messages.js +44 -0
- package/dist/cli/commands/event-validation-messages.js.map +1 -0
- package/dist/cli/commands/extension/bundled-catalog.d.ts +14 -0
- package/dist/cli/commands/extension/bundled-catalog.js +268 -0
- package/dist/cli/commands/extension/bundled-catalog.js.map +1 -0
- package/dist/cli/commands/extension/doctor.d.ts +31 -0
- package/dist/cli/commands/extension/doctor.js +345 -0
- package/dist/cli/commands/extension/doctor.js.map +1 -0
- package/dist/cli/commands/extension/install-sources.d.ts +37 -0
- package/dist/cli/commands/extension/install-sources.js +384 -0
- package/dist/cli/commands/extension/install-sources.js.map +1 -0
- package/dist/cli/commands/extension/managed-state.d.ts +48 -0
- package/dist/cli/commands/extension/managed-state.js +172 -0
- package/dist/cli/commands/extension/managed-state.js.map +1 -0
- package/dist/cli/commands/extension/scaffold.d.ts +14 -0
- package/dist/cli/commands/extension/scaffold.js +169 -0
- package/dist/cli/commands/extension/scaffold.js.map +1 -0
- package/dist/cli/commands/extension/shared.d.ts +14 -0
- package/dist/cli/commands/extension/shared.js +106 -0
- package/dist/cli/commands/extension/shared.js.map +1 -0
- package/dist/cli/commands/extension.d.ts +37 -68
- package/dist/cli/commands/extension.js +157 -1319
- package/dist/cli/commands/extension.js.map +1 -1
- package/dist/cli/commands/files.d.ts +1 -12
- package/dist/cli/commands/files.js +14 -318
- package/dist/cli/commands/files.js.map +1 -1
- package/dist/cli/commands/gc.js +17 -4
- package/dist/cli/commands/gc.js.map +1 -1
- package/dist/cli/commands/get.d.ts +3 -2
- package/dist/cli/commands/get.js +52 -9
- package/dist/cli/commands/get.js.map +1 -1
- package/dist/cli/commands/health.d.ts +10 -0
- package/dist/cli/commands/health.js +269 -76
- package/dist/cli/commands/health.js.map +1 -1
- package/dist/cli/commands/history-redact.d.ts +8 -0
- package/dist/cli/commands/history-redact.js +35 -113
- package/dist/cli/commands/history-redact.js.map +1 -1
- package/dist/cli/commands/history-repair.d.ts +33 -0
- package/dist/cli/commands/history-repair.js +172 -0
- package/dist/cli/commands/history-repair.js.map +1 -0
- package/dist/cli/commands/history.d.ts +4 -4
- package/dist/cli/commands/history.js +10 -88
- package/dist/cli/commands/history.js.map +1 -1
- package/dist/cli/commands/index.d.ts +3 -1
- package/dist/cli/commands/index.js +5 -3
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/init.d.ts +28 -0
- package/dist/cli/commands/init.js +23 -2
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/learnings.js +20 -119
- package/dist/cli/commands/learnings.js.map +1 -1
- package/dist/cli/commands/legacy-none-tokens.d.ts +3 -0
- package/dist/cli/commands/legacy-none-tokens.js +39 -0
- package/dist/cli/commands/legacy-none-tokens.js.map +1 -0
- package/dist/cli/commands/linked-artifacts.d.ts +96 -0
- package/dist/cli/commands/linked-artifacts.js +335 -0
- package/dist/cli/commands/linked-artifacts.js.map +1 -0
- package/dist/cli/commands/linked-test-entry.d.ts +3 -0
- package/dist/cli/commands/linked-test-entry.js +62 -0
- package/dist/cli/commands/linked-test-entry.js.map +1 -0
- package/dist/cli/commands/linked-test-parsers.d.ts +28 -0
- package/dist/cli/commands/linked-test-parsers.js +192 -0
- package/dist/cli/commands/linked-test-parsers.js.map +1 -0
- package/dist/cli/commands/list.js +49 -24
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/normalize.js +4 -3
- package/dist/cli/commands/normalize.js.map +1 -1
- package/dist/cli/commands/notes.js +20 -119
- package/dist/cli/commands/notes.js.map +1 -1
- package/dist/cli/commands/plan.d.ts +3 -0
- package/dist/cli/commands/plan.js +184 -22
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/recurrence-parsers.d.ts +26 -0
- package/dist/cli/commands/recurrence-parsers.js +98 -0
- package/dist/cli/commands/recurrence-parsers.js.map +1 -0
- package/dist/cli/commands/restore.js +24 -56
- package/dist/cli/commands/restore.js.map +1 -1
- package/dist/cli/commands/schema.d.ts +31 -0
- package/dist/cli/commands/schema.js +98 -0
- package/dist/cli/commands/schema.js.map +1 -0
- package/dist/cli/commands/search.js +154 -42
- package/dist/cli/commands/search.js.map +1 -1
- package/dist/cli/commands/templates.d.ts +4 -0
- package/dist/cli/commands/templates.js +89 -17
- package/dist/cli/commands/templates.js.map +1 -1
- package/dist/cli/commands/test/linked-command-detection.d.ts +37 -0
- package/dist/cli/commands/test/linked-command-detection.js +200 -0
- package/dist/cli/commands/test/linked-command-detection.js.map +1 -0
- package/dist/cli/commands/test-all.js +4 -8
- package/dist/cli/commands/test-all.js.map +1 -1
- package/dist/cli/commands/test.d.ts +2 -2
- package/dist/cli/commands/test.js +12 -357
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/commands/update-many.js +6 -9
- package/dist/cli/commands/update-many.js.map +1 -1
- package/dist/cli/commands/update.js +167 -401
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/commands/validate.d.ts +3 -1
- package/dist/cli/commands/validate.js +23 -71
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/error-guidance.d.ts +1 -0
- package/dist/cli/error-guidance.js +100 -6
- package/dist/cli/error-guidance.js.map +1 -1
- package/dist/cli/extension-command-help.d.ts +0 -1
- package/dist/cli/extension-command-help.js +2 -13
- package/dist/cli/extension-command-help.js.map +1 -1
- package/dist/cli/extension-command-options.d.ts +1 -0
- package/dist/cli/extension-command-options.js +106 -7
- package/dist/cli/extension-command-options.js.map +1 -1
- package/dist/cli/help-content.d.ts +0 -1
- package/dist/cli/help-content.js +13 -9
- package/dist/cli/help-content.js.map +1 -1
- package/dist/cli/help-json-payload.d.ts +1 -0
- package/dist/cli/help-json-payload.js +33 -3
- package/dist/cli/help-json-payload.js.map +1 -1
- package/dist/cli/main.d.ts +11 -0
- package/dist/cli/main.js +109 -55
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/register-list-query.d.ts +5 -2
- package/dist/cli/register-list-query.js +254 -192
- package/dist/cli/register-list-query.js.map +1 -1
- package/dist/cli/register-mutation.d.ts +1 -1
- package/dist/cli/register-mutation.js +247 -64
- package/dist/cli/register-mutation.js.map +1 -1
- package/dist/cli/register-operations.js +17 -12
- package/dist/cli/register-operations.js.map +1 -1
- package/dist/cli/register-setup.js +33 -16
- package/dist/cli/register-setup.js.map +1 -1
- package/dist/cli/registration-helpers.d.ts +0 -2
- package/dist/cli/registration-helpers.js +14 -40
- package/dist/cli/registration-helpers.js.map +1 -1
- package/dist/cli.js +25 -4
- package/dist/cli.js.map +1 -1
- package/dist/core/config/positional-value.d.ts +44 -0
- package/dist/core/config/positional-value.js +109 -0
- package/dist/core/config/positional-value.js.map +1 -0
- package/dist/core/extensions/extension-capability-aliases.d.ts +14 -0
- package/dist/core/extensions/extension-capability-aliases.js +159 -0
- package/dist/core/extensions/extension-capability-aliases.js.map +1 -0
- package/dist/core/extensions/extension-hook-runtime.d.ts +13 -0
- package/dist/core/extensions/extension-hook-runtime.js +414 -0
- package/dist/core/extensions/extension-hook-runtime.js.map +1 -0
- package/dist/core/extensions/extension-policy.d.ts +69 -0
- package/dist/core/extensions/extension-policy.js +481 -0
- package/dist/core/extensions/extension-policy.js.map +1 -0
- package/dist/core/extensions/extension-registries.d.ts +8 -0
- package/dist/core/extensions/extension-registries.js +52 -0
- package/dist/core/extensions/extension-registries.js.map +1 -0
- package/dist/core/extensions/extension-runtime-helpers.d.ts +6 -0
- package/dist/core/extensions/extension-runtime-helpers.js +29 -0
- package/dist/core/extensions/extension-runtime-helpers.js.map +1 -0
- package/dist/core/extensions/extension-types.d.ts +13 -39
- package/dist/core/extensions/extension-types.js +34 -2
- package/dist/core/extensions/extension-types.js.map +1 -1
- package/dist/core/extensions/index.d.ts +7 -1
- package/dist/core/extensions/index.js +11 -14
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +4 -22
- package/dist/core/extensions/loader.js +23 -1146
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/fs/path-utils.d.ts +1 -0
- package/dist/core/fs/path-utils.js +12 -0
- package/dist/core/fs/path-utils.js.map +1 -0
- package/dist/core/history/drift-scan.d.ts +22 -0
- package/dist/core/history/drift-scan.js +149 -0
- package/dist/core/history/drift-scan.js.map +1 -0
- package/dist/core/history/history-rewrite.d.ts +43 -0
- package/dist/core/history/history-rewrite.js +48 -0
- package/dist/core/history/history-rewrite.js.map +1 -0
- package/dist/core/history/history.js +5 -4
- package/dist/core/history/history.js.map +1 -1
- package/dist/core/history/replay.d.ts +82 -0
- package/dist/core/history/replay.js +250 -0
- package/dist/core/history/replay.js.map +1 -0
- package/dist/core/item/item-format.js +11 -8
- package/dist/core/item/item-format.js.map +1 -1
- package/dist/core/item/item-record.d.ts +19 -0
- package/dist/core/item/item-record.js +24 -0
- package/dist/core/item/item-record.js.map +1 -0
- package/dist/core/item/item-type-definition.d.ts +52 -0
- package/dist/core/item/item-type-definition.js +123 -0
- package/dist/core/item/item-type-definition.js.map +1 -0
- package/dist/core/item/parse.js +3 -2
- package/dist/core/item/parse.js.map +1 -1
- package/dist/core/item/priority.d.ts +23 -0
- package/dist/core/item/priority.js +55 -0
- package/dist/core/item/priority.js.map +1 -0
- package/dist/core/item/status.d.ts +14 -1
- package/dist/core/item/status.js +22 -2
- package/dist/core/item/status.js.map +1 -1
- package/dist/core/item/toon-decode.d.ts +19 -0
- package/dist/core/item/toon-decode.js +69 -0
- package/dist/core/item/toon-decode.js.map +1 -0
- package/dist/core/item/type-registry.js +13 -84
- package/dist/core/item/type-registry.js.map +1 -1
- package/dist/core/output/mutation-projection.d.ts +31 -0
- package/dist/core/output/mutation-projection.js +103 -0
- package/dist/core/output/mutation-projection.js.map +1 -0
- package/dist/core/output/output.d.ts +2 -0
- package/dist/core/output/output.js +5 -3
- package/dist/core/output/output.js.map +1 -1
- package/dist/core/packages/manifest.js +3 -9
- package/dist/core/packages/manifest.js.map +1 -1
- package/dist/core/schema/item-types-file.d.ts +85 -0
- package/dist/core/schema/item-types-file.js +243 -0
- package/dist/core/schema/item-types-file.js.map +1 -0
- package/dist/core/schema/runtime-schema.d.ts +2 -1
- package/dist/core/schema/runtime-schema.js +17 -45
- package/dist/core/schema/runtime-schema.js.map +1 -1
- package/dist/core/search/semantic-defaults.js +3 -3
- package/dist/core/search/semantic-defaults.js.map +1 -1
- package/dist/core/search/vector-stores.js +46 -9
- package/dist/core/search/vector-stores.js.map +1 -1
- package/dist/core/sentry/helpers.d.ts +1 -1
- package/dist/core/sentry/helpers.js +20 -3
- package/dist/core/sentry/helpers.js.map +1 -1
- package/dist/core/shared/author.d.ts +1 -0
- package/dist/core/shared/author.js +9 -0
- package/dist/core/shared/author.js.map +1 -0
- package/dist/core/shared/command-types.d.ts +1 -0
- package/dist/core/shared/command-types.js +2 -2
- package/dist/core/shared/command-types.js.map +1 -1
- package/dist/core/shared/constants.d.ts +10 -1
- package/dist/core/shared/constants.js +56 -58
- package/dist/core/shared/constants.js.map +1 -1
- package/dist/core/shared/lazy-module.d.ts +1 -0
- package/dist/core/shared/lazy-module.js +11 -0
- package/dist/core/shared/lazy-module.js.map +1 -0
- package/dist/core/shared/option-alias-visibility.d.ts +44 -0
- package/dist/core/shared/option-alias-visibility.js +76 -0
- package/dist/core/shared/option-alias-visibility.js.map +1 -0
- package/dist/core/shared/primitives.d.ts +23 -0
- package/dist/core/shared/primitives.js +39 -2
- package/dist/core/shared/primitives.js.map +1 -1
- package/dist/core/shared/text-normalization.d.ts +0 -1
- package/dist/core/shared/text-normalization.js +2 -5
- package/dist/core/shared/text-normalization.js.map +1 -1
- package/dist/core/store/front-matter-cache.d.ts +16 -2
- package/dist/core/store/front-matter-cache.js +99 -33
- package/dist/core/store/front-matter-cache.js.map +1 -1
- package/dist/core/store/item-store.d.ts +2 -0
- package/dist/core/store/item-store.js +76 -110
- package/dist/core/store/item-store.js.map +1 -1
- package/dist/core/store/settings-validator.d.ts +106 -0
- package/dist/core/store/settings-validator.js +279 -0
- package/dist/core/store/settings-validator.js.map +1 -0
- package/dist/core/store/settings.js +6 -343
- package/dist/core/store/settings.js.map +1 -1
- package/dist/core/telemetry/runtime.js +5 -3
- package/dist/core/telemetry/runtime.js.map +1 -1
- package/dist/mcp/server.js +138 -39
- package/dist/mcp/server.js.map +1 -1
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +20 -0
- package/dist/sdk/cli-contracts/enum-contracts.js +156 -0
- package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -0
- package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +14 -0
- package/dist/sdk/cli-contracts/tool-option-contracts.js +243 -0
- package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -0
- package/dist/sdk/cli-contracts/tool-parameter-tables.d.ts +11 -0
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +901 -0
- package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -0
- package/dist/sdk/cli-contracts.d.ts +18 -33
- package/dist/sdk/cli-contracts.js +96 -1238
- package/dist/sdk/cli-contracts.js.map +1 -1
- package/dist/sdk/package-import-adapters.d.ts +74 -0
- package/dist/sdk/package-import-adapters.js +186 -0
- package/dist/sdk/package-import-adapters.js.map +1 -0
- package/dist/sdk/package-runtime-options.d.ts +26 -0
- package/dist/sdk/package-runtime-options.js +71 -0
- package/dist/sdk/package-runtime-options.js.map +1 -0
- package/dist/sdk/runtime.d.ts +27 -1
- package/dist/sdk/runtime.js +48 -3
- package/dist/sdk/runtime.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.js +10 -2
- package/dist/types.js.map +1 -1
- package/docs/AGENT_GUIDE.md +13 -11
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/CLAUDE_CODE_PLUGIN.md +5 -28
- package/docs/CODEX_PLUGIN.md +5 -5
- package/docs/COMMANDS.md +58 -9
- package/docs/CONFIGURATION.md +16 -1
- package/docs/EXTENSIONS.md +4 -63
- package/docs/RELEASING.md +12 -8
- package/docs/SDK.md +11 -2
- package/marketplace.json +7 -3
- package/package.json +18 -14
- package/packages/pm-beads/extensions/beads/index.js +2 -49
- package/packages/pm-beads/extensions/beads/index.ts +2 -54
- package/packages/pm-beads/extensions/beads/runtime-loader.js +86 -0
- package/packages/pm-beads/extensions/beads/runtime-loader.ts +88 -0
- package/packages/pm-beads/extensions/beads/runtime.js +26 -115
- package/packages/pm-beads/extensions/beads/runtime.ts +33 -132
- package/packages/pm-calendar/README.md +3 -1
- package/packages/pm-calendar/extensions/calendar/index.js +66 -2
- package/packages/pm-calendar/extensions/calendar/index.ts +71 -2
- package/packages/pm-calendar/extensions/calendar/runtime.js +1 -0
- package/packages/pm-calendar/extensions/calendar/runtime.ts +1 -0
- package/packages/pm-governance-audit/extensions/governance-audit/runtime.js +14 -41
- package/packages/pm-governance-audit/extensions/governance-audit/runtime.ts +25 -41
- package/packages/pm-guide-shell/extensions/guide-shell/runtime.js +10 -50
- package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +17 -50
- package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/runtime.js +8 -40
- package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/runtime.ts +10 -40
- package/packages/pm-search-advanced/README.md +8 -0
- package/packages/pm-search-advanced/extensions/search-advanced/index.js +75 -1
- package/packages/pm-search-advanced/extensions/search-advanced/index.ts +74 -0
- package/packages/pm-search-advanced/extensions/search-advanced/runtime.js +58 -33
- package/packages/pm-search-advanced/extensions/search-advanced/runtime.ts +60 -33
- package/packages/pm-templates/extensions/templates/runtime.js +11 -202
- package/packages/pm-templates/extensions/templates/runtime.ts +38 -230
- package/packages/pm-todos/extensions/todos/index.js +3 -50
- package/packages/pm-todos/extensions/todos/index.ts +3 -55
- package/packages/pm-todos/extensions/todos/runtime-loader.js +86 -0
- package/packages/pm-todos/extensions/todos/runtime-loader.ts +88 -0
- package/packages/pm-todos/extensions/todos/runtime.js +24 -117
- package/packages/pm-todos/extensions/todos/runtime.ts +32 -129
- package/plugins/pm-claude/README.md +2 -2
- package/plugins/pm-claude/commands/pm-planner.md +1 -15
- package/plugins/pm-claude/scripts/pm-mcp-server.mjs +5 -2
- package/plugins/pm-claude/skills/pm-planner/SKILL.md +3 -21
- package/plugins/pm-codex/scripts/pm-mcp-server.mjs +15 -6
- package/plugins/pm-codex/skills/pm-native/SKILL.md +1 -13
- package/PRD.md +0 -1734
- package/dist/core/output/command-aware.d.ts +0 -1
- package/dist/core/output/command-aware.js +0 -397
- package/dist/core/output/command-aware.js.map +0 -1
|
@@ -1,679 +1,33 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4fba8687-0797-5479-afc8-12f1a2e5a954")}catch(e){}}();
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
6
|
import { pathExists } from "../fs/fs-utils.js";
|
|
7
|
+
import { isPathWithinDirectory } from "../fs/path-utils.js";
|
|
7
8
|
import { resolveGlobalPmRoot } from "../store/paths.js";
|
|
8
|
-
import {
|
|
9
|
+
import { asRecordLoose } from "../shared/primitives.js";
|
|
10
|
+
// Cohesive helper groups now live in sibling modules. They are imported for the
|
|
11
|
+
// discovery/activation code that stays here and re-exported below so existing
|
|
12
|
+
// import sites (sdk/index.ts, commands/extension.ts, health.ts, tests, …) keep
|
|
13
|
+
// importing everything from "./loader.js" unchanged.
|
|
14
|
+
import { normalizeNames, isKnownExtensionCapability, collectUnknownExtensionCapabilities, normalizeManifestCapabilities, formatUnknownExtensionCapabilityWarning, formatLegacyExtensionCapabilityAliasWarning, } from "./extension-capability-aliases.js";
|
|
15
|
+
import { normalizeExtensionPolicy, serializeExtensionPolicy, hydrateExtensionPolicy, normalizePolicySandboxProfile, evaluateExtensionPolicyForExtension, evaluateExtensionPolicyForCapability, evaluateExtensionPolicyForRegistration, } from "./extension-policy.js";
|
|
16
|
+
import { createEmptyExtensionHookRegistry, createEmptyExtensionCommandRegistry, createEmptyExtensionParserRegistry, createEmptyExtensionPreflightRegistry, createEmptyExtensionServiceRegistry, createEmptyExtensionRendererRegistry, createEmptyExtensionRegistrationRegistry, } from "./extension-registries.js";
|
|
17
|
+
import { normalizeCommandName, cloneContextSnapshot, } from "./extension-runtime-helpers.js";
|
|
18
|
+
export { parseUnknownExtensionCapabilityWarning, parseLegacyExtensionCapabilityAliasWarning, } from "./extension-capability-aliases.js";
|
|
19
|
+
export { createEmptyExtensionHookRegistry, createEmptyExtensionCommandRegistry, createEmptyExtensionParserRegistry, createEmptyExtensionPreflightRegistry, createEmptyExtensionServiceRegistry, createEmptyExtensionRendererRegistry, createEmptyExtensionRegistrationRegistry, } from "./extension-registries.js";
|
|
20
|
+
export { runBeforeCommandHooks, runAfterCommandHooks, runOnWriteHooks, runOnReadHooks, runOnIndexHooks, runCommandHandler, runParserOverride, runPreflightOverride, runServiceOverrideSync, runServiceOverride, runCommandOverride, runRendererOverride, } from "./extension-hook-runtime.js";
|
|
21
|
+
import { KNOWN_EXTENSION_SERVICE_NAMES, createDefaultExtensionGovernancePolicy, } from "./extension-types.js";
|
|
9
22
|
export * from "./extension-types.js";
|
|
10
23
|
const DEFAULT_EXTENSION_PRIORITY = 100;
|
|
11
24
|
/* Types now in extension-types.ts - re-exported via `export * from "./extension-types.js"` above */
|
|
12
|
-
|
|
13
|
-
return [...new Set(values.map((value) => value.trim()).filter((value) => value.length > 0))].sort((a, b) => a.localeCompare(b));
|
|
14
|
-
}
|
|
15
|
-
function isKnownExtensionCapability(value) {
|
|
16
|
-
return KNOWN_EXTENSION_CAPABILITIES.includes(value);
|
|
17
|
-
}
|
|
18
|
-
function collectUnknownExtensionCapabilities(capabilities) {
|
|
19
|
-
return capabilities.filter((capability) => !isKnownExtensionCapability(capability));
|
|
20
|
-
}
|
|
21
|
-
const DEFAULT_EXTENSION_POLICY = Object.freeze({
|
|
22
|
-
mode: "off",
|
|
23
|
-
trust_mode: "off",
|
|
24
|
-
require_provenance: false,
|
|
25
|
-
trusted_extensions: [],
|
|
26
|
-
default_sandbox_profile: "none",
|
|
27
|
-
allowed_extensions: [],
|
|
28
|
-
blocked_extensions: [],
|
|
29
|
-
allowed_capabilities: [],
|
|
30
|
-
blocked_capabilities: [],
|
|
31
|
-
allowed_surfaces: [],
|
|
32
|
-
blocked_surfaces: [],
|
|
33
|
-
allowed_commands: [],
|
|
34
|
-
blocked_commands: [],
|
|
35
|
-
allowed_actions: [],
|
|
36
|
-
blocked_actions: [],
|
|
37
|
-
allowed_services: [],
|
|
38
|
-
blocked_services: [],
|
|
39
|
-
extension_overrides: [],
|
|
40
|
-
});
|
|
25
|
+
const DEFAULT_EXTENSION_POLICY = Object.freeze(createDefaultExtensionGovernancePolicy());
|
|
41
26
|
let extensionReloadEpoch = 0;
|
|
42
27
|
export function nextExtensionReloadToken(seed = Date.now()) {
|
|
43
28
|
extensionReloadEpoch += 1;
|
|
44
29
|
return `${extensionReloadEpoch}-${seed}`;
|
|
45
30
|
}
|
|
46
|
-
function normalizePolicyName(value) {
|
|
47
|
-
if (typeof value !== "string") {
|
|
48
|
-
return "";
|
|
49
|
-
}
|
|
50
|
-
return value.trim().toLowerCase();
|
|
51
|
-
}
|
|
52
|
-
function normalizePolicyStringSet(values) {
|
|
53
|
-
return new Set((values ?? [])
|
|
54
|
-
.map((value) => value.trim().toLowerCase())
|
|
55
|
-
.filter((value) => value.length > 0));
|
|
56
|
-
}
|
|
57
|
-
function normalizePolicySurfaceToken(value) {
|
|
58
|
-
const normalized = value.trim().toLowerCase();
|
|
59
|
-
if (normalized.length === 0) {
|
|
60
|
-
return "";
|
|
61
|
-
}
|
|
62
|
-
const segments = normalized
|
|
63
|
-
.split(/[.:/]/)
|
|
64
|
-
.map((segment) => segment.replace(/[\s_-]+/g, ""))
|
|
65
|
-
.filter((segment) => segment.length > 0);
|
|
66
|
-
if (segments.length === 0) {
|
|
67
|
-
return "";
|
|
68
|
-
}
|
|
69
|
-
if (segments.length === 1) {
|
|
70
|
-
return segments[0];
|
|
71
|
-
}
|
|
72
|
-
return `${segments[0]}.${segments.slice(1).join("")}`;
|
|
73
|
-
}
|
|
74
|
-
function normalizePolicySurfaceSet(values) {
|
|
75
|
-
return new Set((values ?? [])
|
|
76
|
-
.map((value) => normalizePolicySurfaceToken(value))
|
|
77
|
-
.filter((value) => value.length > 0));
|
|
78
|
-
}
|
|
79
|
-
function normalizePolicyMode(value) {
|
|
80
|
-
const normalized = normalizePolicyName(value);
|
|
81
|
-
if (KNOWN_EXTENSION_POLICY_MODES.includes(normalized)) {
|
|
82
|
-
return normalized;
|
|
83
|
-
}
|
|
84
|
-
return "off";
|
|
85
|
-
}
|
|
86
|
-
function normalizePolicyTrustMode(value) {
|
|
87
|
-
const normalized = normalizePolicyName(value);
|
|
88
|
-
if (KNOWN_EXTENSION_TRUST_MODES.includes(normalized)) {
|
|
89
|
-
return normalized;
|
|
90
|
-
}
|
|
91
|
-
return "off";
|
|
92
|
-
}
|
|
93
|
-
function normalizePolicySandboxProfile(value) {
|
|
94
|
-
const normalized = normalizePolicyName(value);
|
|
95
|
-
if (KNOWN_EXTENSION_SANDBOX_PROFILES.includes(normalized)) {
|
|
96
|
-
return normalized;
|
|
97
|
-
}
|
|
98
|
-
return "none";
|
|
99
|
-
}
|
|
100
|
-
function toSortedList(values) {
|
|
101
|
-
return [...new Set(values)].sort((left, right) => left.localeCompare(right));
|
|
102
|
-
}
|
|
103
|
-
function normalizeExtensionPolicy(settings) {
|
|
104
|
-
const policy = settings.extensions.policy;
|
|
105
|
-
const mode = normalizePolicyMode(policy?.mode);
|
|
106
|
-
const trustMode = normalizePolicyTrustMode(policy?.trust_mode);
|
|
107
|
-
const requireProvenance = policy?.require_provenance === true;
|
|
108
|
-
const trustedExtensions = normalizePolicyStringSet(policy?.trusted_extensions);
|
|
109
|
-
const defaultSandboxProfile = normalizePolicySandboxProfile(policy?.default_sandbox_profile);
|
|
110
|
-
const allowedExtensions = normalizePolicyStringSet(policy?.allowed_extensions);
|
|
111
|
-
const blockedExtensions = normalizePolicyStringSet(policy?.blocked_extensions);
|
|
112
|
-
const allowedCapabilities = normalizePolicyStringSet(policy?.allowed_capabilities);
|
|
113
|
-
const blockedCapabilities = normalizePolicyStringSet(policy?.blocked_capabilities);
|
|
114
|
-
const allowedSurfaces = normalizePolicySurfaceSet(policy?.allowed_surfaces);
|
|
115
|
-
const blockedSurfaces = normalizePolicySurfaceSet(policy?.blocked_surfaces);
|
|
116
|
-
const allowedCommands = normalizePolicyStringSet(policy?.allowed_commands);
|
|
117
|
-
const blockedCommands = normalizePolicyStringSet(policy?.blocked_commands);
|
|
118
|
-
const allowedActions = normalizePolicyStringSet(policy?.allowed_actions);
|
|
119
|
-
const blockedActions = normalizePolicyStringSet(policy?.blocked_actions);
|
|
120
|
-
const allowedServices = normalizePolicyStringSet(policy?.allowed_services);
|
|
121
|
-
const blockedServices = normalizePolicyStringSet(policy?.blocked_services);
|
|
122
|
-
const overridesByName = new Map();
|
|
123
|
-
for (const rawOverride of policy?.extension_overrides ?? []) {
|
|
124
|
-
const name = normalizePolicyName(rawOverride.name);
|
|
125
|
-
if (name.length === 0) {
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
overridesByName.set(name, {
|
|
129
|
-
name,
|
|
130
|
-
disabled: rawOverride.disabled === true,
|
|
131
|
-
requireTrusted: rawOverride.require_trusted === true,
|
|
132
|
-
requireProvenance: rawOverride.require_provenance === true,
|
|
133
|
-
sandboxProfile: rawOverride.sandbox_profile !== undefined
|
|
134
|
-
? normalizePolicySandboxProfile(rawOverride.sandbox_profile)
|
|
135
|
-
: undefined,
|
|
136
|
-
allowedCapabilities: normalizePolicyStringSet(rawOverride.allowed_capabilities),
|
|
137
|
-
blockedCapabilities: normalizePolicyStringSet(rawOverride.blocked_capabilities),
|
|
138
|
-
allowedSurfaces: normalizePolicySurfaceSet(rawOverride.allowed_surfaces),
|
|
139
|
-
blockedSurfaces: normalizePolicySurfaceSet(rawOverride.blocked_surfaces),
|
|
140
|
-
allowedCommands: normalizePolicyStringSet(rawOverride.allowed_commands),
|
|
141
|
-
blockedCommands: normalizePolicyStringSet(rawOverride.blocked_commands),
|
|
142
|
-
allowedActions: normalizePolicyStringSet(rawOverride.allowed_actions),
|
|
143
|
-
blockedActions: normalizePolicyStringSet(rawOverride.blocked_actions),
|
|
144
|
-
allowedServices: normalizePolicyStringSet(rawOverride.allowed_services),
|
|
145
|
-
blockedServices: normalizePolicyStringSet(rawOverride.blocked_services),
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
const warnings = [];
|
|
149
|
-
for (const capability of toSortedList([...allowedCapabilities, ...blockedCapabilities])) {
|
|
150
|
-
if (!isKnownExtensionCapability(capability)) {
|
|
151
|
-
warnings.push(`extension_policy_unknown_capability:${capability}`);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
for (const override of [...overridesByName.values()].sort((left, right) => left.name.localeCompare(right.name))) {
|
|
155
|
-
for (const capability of toSortedList([...override.allowedCapabilities, ...override.blockedCapabilities])) {
|
|
156
|
-
if (!isKnownExtensionCapability(capability)) {
|
|
157
|
-
warnings.push(`extension_policy_unknown_capability:${override.name}:${capability}`);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
const knownSurfaces = new Set(KNOWN_EXTENSION_POLICY_SURFACES);
|
|
162
|
-
for (const surface of toSortedList([...allowedSurfaces, ...blockedSurfaces])) {
|
|
163
|
-
if (!knownSurfaces.has(surface)) {
|
|
164
|
-
warnings.push(`extension_policy_unknown_surface:${surface}`);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
for (const override of [...overridesByName.values()].sort((left, right) => left.name.localeCompare(right.name))) {
|
|
168
|
-
for (const surface of toSortedList([...override.allowedSurfaces, ...override.blockedSurfaces])) {
|
|
169
|
-
if (!knownSurfaces.has(surface)) {
|
|
170
|
-
warnings.push(`extension_policy_unknown_surface:${override.name}:${surface}`);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return {
|
|
175
|
-
mode,
|
|
176
|
-
trustMode,
|
|
177
|
-
requireProvenance,
|
|
178
|
-
trustedExtensions,
|
|
179
|
-
defaultSandboxProfile,
|
|
180
|
-
allowedExtensions,
|
|
181
|
-
blockedExtensions,
|
|
182
|
-
allowedCapabilities,
|
|
183
|
-
blockedCapabilities,
|
|
184
|
-
allowedSurfaces,
|
|
185
|
-
blockedSurfaces,
|
|
186
|
-
allowedCommands,
|
|
187
|
-
blockedCommands,
|
|
188
|
-
allowedActions,
|
|
189
|
-
blockedActions,
|
|
190
|
-
allowedServices,
|
|
191
|
-
blockedServices,
|
|
192
|
-
overridesByName,
|
|
193
|
-
warnings: [...new Set(warnings)].sort((left, right) => left.localeCompare(right)),
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
function serializeExtensionPolicy(policy) {
|
|
197
|
-
const overrides = [...policy.overridesByName.values()]
|
|
198
|
-
.sort((left, right) => left.name.localeCompare(right.name))
|
|
199
|
-
.map((override) => ({
|
|
200
|
-
name: override.name,
|
|
201
|
-
...(override.disabled ? { disabled: true } : {}),
|
|
202
|
-
...(override.requireTrusted ? { require_trusted: true } : {}),
|
|
203
|
-
...(override.requireProvenance ? { require_provenance: true } : {}),
|
|
204
|
-
...(override.sandboxProfile ? { sandbox_profile: override.sandboxProfile } : {}),
|
|
205
|
-
...(override.allowedCapabilities.size > 0 ? { allowed_capabilities: toSortedList(override.allowedCapabilities) } : {}),
|
|
206
|
-
...(override.blockedCapabilities.size > 0 ? { blocked_capabilities: toSortedList(override.blockedCapabilities) } : {}),
|
|
207
|
-
...(override.allowedSurfaces.size > 0 ? { allowed_surfaces: toSortedList(override.allowedSurfaces) } : {}),
|
|
208
|
-
...(override.blockedSurfaces.size > 0 ? { blocked_surfaces: toSortedList(override.blockedSurfaces) } : {}),
|
|
209
|
-
...(override.allowedCommands.size > 0 ? { allowed_commands: toSortedList(override.allowedCommands) } : {}),
|
|
210
|
-
...(override.blockedCommands.size > 0 ? { blocked_commands: toSortedList(override.blockedCommands) } : {}),
|
|
211
|
-
...(override.allowedActions.size > 0 ? { allowed_actions: toSortedList(override.allowedActions) } : {}),
|
|
212
|
-
...(override.blockedActions.size > 0 ? { blocked_actions: toSortedList(override.blockedActions) } : {}),
|
|
213
|
-
...(override.allowedServices.size > 0 ? { allowed_services: toSortedList(override.allowedServices) } : {}),
|
|
214
|
-
...(override.blockedServices.size > 0 ? { blocked_services: toSortedList(override.blockedServices) } : {}),
|
|
215
|
-
}));
|
|
216
|
-
return {
|
|
217
|
-
mode: policy.mode,
|
|
218
|
-
trust_mode: policy.trustMode,
|
|
219
|
-
require_provenance: policy.requireProvenance,
|
|
220
|
-
trusted_extensions: toSortedList(policy.trustedExtensions),
|
|
221
|
-
default_sandbox_profile: policy.defaultSandboxProfile,
|
|
222
|
-
allowed_extensions: toSortedList(policy.allowedExtensions),
|
|
223
|
-
blocked_extensions: toSortedList(policy.blockedExtensions),
|
|
224
|
-
allowed_capabilities: toSortedList(policy.allowedCapabilities),
|
|
225
|
-
blocked_capabilities: toSortedList(policy.blockedCapabilities),
|
|
226
|
-
allowed_surfaces: toSortedList(policy.allowedSurfaces),
|
|
227
|
-
blocked_surfaces: toSortedList(policy.blockedSurfaces),
|
|
228
|
-
allowed_commands: toSortedList(policy.allowedCommands),
|
|
229
|
-
blocked_commands: toSortedList(policy.blockedCommands),
|
|
230
|
-
allowed_actions: toSortedList(policy.allowedActions),
|
|
231
|
-
blocked_actions: toSortedList(policy.blockedActions),
|
|
232
|
-
allowed_services: toSortedList(policy.allowedServices),
|
|
233
|
-
blocked_services: toSortedList(policy.blockedServices),
|
|
234
|
-
extension_overrides: overrides,
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
function hydrateExtensionPolicy(policy) {
|
|
238
|
-
const overridesByName = new Map();
|
|
239
|
-
for (const rawOverride of policy.extension_overrides ?? []) {
|
|
240
|
-
const name = normalizePolicyName(rawOverride.name);
|
|
241
|
-
if (name.length === 0) {
|
|
242
|
-
continue;
|
|
243
|
-
}
|
|
244
|
-
overridesByName.set(name, {
|
|
245
|
-
name,
|
|
246
|
-
disabled: rawOverride.disabled === true,
|
|
247
|
-
requireTrusted: rawOverride.require_trusted === true,
|
|
248
|
-
requireProvenance: rawOverride.require_provenance === true,
|
|
249
|
-
sandboxProfile: rawOverride.sandbox_profile !== undefined
|
|
250
|
-
? normalizePolicySandboxProfile(rawOverride.sandbox_profile)
|
|
251
|
-
: undefined,
|
|
252
|
-
allowedCapabilities: normalizePolicyStringSet(rawOverride.allowed_capabilities),
|
|
253
|
-
blockedCapabilities: normalizePolicyStringSet(rawOverride.blocked_capabilities),
|
|
254
|
-
allowedSurfaces: normalizePolicySurfaceSet(rawOverride.allowed_surfaces),
|
|
255
|
-
blockedSurfaces: normalizePolicySurfaceSet(rawOverride.blocked_surfaces),
|
|
256
|
-
allowedCommands: normalizePolicyStringSet(rawOverride.allowed_commands),
|
|
257
|
-
blockedCommands: normalizePolicyStringSet(rawOverride.blocked_commands),
|
|
258
|
-
allowedActions: normalizePolicyStringSet(rawOverride.allowed_actions),
|
|
259
|
-
blockedActions: normalizePolicyStringSet(rawOverride.blocked_actions),
|
|
260
|
-
allowedServices: normalizePolicyStringSet(rawOverride.allowed_services),
|
|
261
|
-
blockedServices: normalizePolicyStringSet(rawOverride.blocked_services),
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
return {
|
|
265
|
-
mode: normalizePolicyMode(policy.mode),
|
|
266
|
-
trustMode: normalizePolicyTrustMode(policy.trust_mode),
|
|
267
|
-
requireProvenance: policy.require_provenance === true,
|
|
268
|
-
trustedExtensions: normalizePolicyStringSet(policy.trusted_extensions),
|
|
269
|
-
defaultSandboxProfile: normalizePolicySandboxProfile(policy.default_sandbox_profile),
|
|
270
|
-
allowedExtensions: normalizePolicyStringSet(policy.allowed_extensions),
|
|
271
|
-
blockedExtensions: normalizePolicyStringSet(policy.blocked_extensions),
|
|
272
|
-
allowedCapabilities: normalizePolicyStringSet(policy.allowed_capabilities),
|
|
273
|
-
blockedCapabilities: normalizePolicyStringSet(policy.blocked_capabilities),
|
|
274
|
-
allowedSurfaces: normalizePolicySurfaceSet(policy.allowed_surfaces),
|
|
275
|
-
blockedSurfaces: normalizePolicySurfaceSet(policy.blocked_surfaces),
|
|
276
|
-
allowedCommands: normalizePolicyStringSet(policy.allowed_commands),
|
|
277
|
-
blockedCommands: normalizePolicyStringSet(policy.blocked_commands),
|
|
278
|
-
allowedActions: normalizePolicyStringSet(policy.allowed_actions),
|
|
279
|
-
blockedActions: normalizePolicyStringSet(policy.blocked_actions),
|
|
280
|
-
allowedServices: normalizePolicyStringSet(policy.allowed_services),
|
|
281
|
-
blockedServices: normalizePolicyStringSet(policy.blocked_services),
|
|
282
|
-
overridesByName,
|
|
283
|
-
warnings: [],
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
function resolvePolicyOverride(policy, extensionName) {
|
|
287
|
-
return policy.overridesByName.get(normalizePolicyName(extensionName)) ?? null;
|
|
288
|
-
}
|
|
289
|
-
function evaluatePolicySet(allowed, blocked, value, notAllowlistedReason, blockedReason) {
|
|
290
|
-
if (blocked.has(value)) {
|
|
291
|
-
return blockedReason;
|
|
292
|
-
}
|
|
293
|
-
if (allowed.size > 0 && !allowed.has(value)) {
|
|
294
|
-
return notAllowlistedReason;
|
|
295
|
-
}
|
|
296
|
-
return null;
|
|
297
|
-
}
|
|
298
|
-
function resolvePolicyCapabilityReason(policy, extension, capability) {
|
|
299
|
-
const normalizedCapability = capability.trim().toLowerCase();
|
|
300
|
-
const override = resolvePolicyOverride(policy, extension.name);
|
|
301
|
-
const allowed = override && override.allowedCapabilities.size > 0 ? override.allowedCapabilities : policy.allowedCapabilities;
|
|
302
|
-
const blocked = new Set([
|
|
303
|
-
...policy.blockedCapabilities,
|
|
304
|
-
...(override ? override.blockedCapabilities : []),
|
|
305
|
-
]);
|
|
306
|
-
return evaluatePolicySet(allowed, blocked, normalizedCapability, "capability_not_allowlisted", "capability_blocked");
|
|
307
|
-
}
|
|
308
|
-
function resolvePolicySurfaceReason(policy, extension, surface) {
|
|
309
|
-
const override = resolvePolicyOverride(policy, extension.name);
|
|
310
|
-
const allowed = override && override.allowedSurfaces.size > 0 ? override.allowedSurfaces : policy.allowedSurfaces;
|
|
311
|
-
const blocked = new Set([
|
|
312
|
-
...policy.blockedSurfaces,
|
|
313
|
-
...(override ? override.blockedSurfaces : []),
|
|
314
|
-
]);
|
|
315
|
-
return evaluatePolicySet(allowed, blocked, surface, "surface_not_allowlisted", "surface_blocked");
|
|
316
|
-
}
|
|
317
|
-
function resolvePolicyCommandReason(policy, extension, command) {
|
|
318
|
-
const normalizedCommand = normalizeCommandName(command);
|
|
319
|
-
if (normalizedCommand.length === 0) {
|
|
320
|
-
return null;
|
|
321
|
-
}
|
|
322
|
-
const override = resolvePolicyOverride(policy, extension.name);
|
|
323
|
-
const allowed = override && override.allowedCommands.size > 0 ? override.allowedCommands : policy.allowedCommands;
|
|
324
|
-
const blocked = new Set([
|
|
325
|
-
...policy.blockedCommands,
|
|
326
|
-
...(override ? override.blockedCommands : []),
|
|
327
|
-
]);
|
|
328
|
-
return evaluatePolicySet(allowed, blocked, normalizedCommand, "command_not_allowlisted", "command_blocked");
|
|
329
|
-
}
|
|
330
|
-
function resolvePolicyActionReason(policy, extension, action) {
|
|
331
|
-
const normalizedAction = normalizePolicyName(action).replace(/\s+/g, "-");
|
|
332
|
-
if (normalizedAction.length === 0) {
|
|
333
|
-
return null;
|
|
334
|
-
}
|
|
335
|
-
const override = resolvePolicyOverride(policy, extension.name);
|
|
336
|
-
const allowed = override && override.allowedActions.size > 0 ? override.allowedActions : policy.allowedActions;
|
|
337
|
-
const blocked = new Set([
|
|
338
|
-
...policy.blockedActions,
|
|
339
|
-
...(override ? override.blockedActions : []),
|
|
340
|
-
]);
|
|
341
|
-
return evaluatePolicySet(allowed, blocked, normalizedAction, "action_not_allowlisted", "action_blocked");
|
|
342
|
-
}
|
|
343
|
-
function resolvePolicyServiceReason(policy, extension, service) {
|
|
344
|
-
const normalizedService = normalizePolicyName(service);
|
|
345
|
-
if (normalizedService.length === 0) {
|
|
346
|
-
return null;
|
|
347
|
-
}
|
|
348
|
-
const override = resolvePolicyOverride(policy, extension.name);
|
|
349
|
-
const allowed = override && override.allowedServices.size > 0 ? override.allowedServices : policy.allowedServices;
|
|
350
|
-
const blocked = new Set([
|
|
351
|
-
...policy.blockedServices,
|
|
352
|
-
...(override ? override.blockedServices : []),
|
|
353
|
-
]);
|
|
354
|
-
return evaluatePolicySet(allowed, blocked, normalizedService, "service_not_allowlisted", "service_blocked");
|
|
355
|
-
}
|
|
356
|
-
function resolvePolicyExtensionReason(policy, extension) {
|
|
357
|
-
const name = normalizePolicyName(extension.name);
|
|
358
|
-
const override = resolvePolicyOverride(policy, extension.name);
|
|
359
|
-
if (override?.disabled === true) {
|
|
360
|
-
return "extension_override_disabled";
|
|
361
|
-
}
|
|
362
|
-
return evaluatePolicySet(policy.allowedExtensions, policy.blockedExtensions, name, "extension_not_allowlisted", "extension_blocked");
|
|
363
|
-
}
|
|
364
|
-
function resolvePolicyTrustReason(policy, extension) {
|
|
365
|
-
if (policy.trustMode === "off") {
|
|
366
|
-
return null;
|
|
367
|
-
}
|
|
368
|
-
const override = resolvePolicyOverride(policy, extension.name);
|
|
369
|
-
const name = normalizePolicyName(extension.name);
|
|
370
|
-
const trusted = extension.trusted === true;
|
|
371
|
-
const provenanceVerified = extension.provenanceVerified === true;
|
|
372
|
-
if (policy.trustedExtensions.size > 0 && !policy.trustedExtensions.has(name)) {
|
|
373
|
-
return "extension_not_trusted";
|
|
374
|
-
}
|
|
375
|
-
if ((override?.requireTrusted === true || policy.trustMode === "warn" || policy.trustMode === "enforce") && !trusted) {
|
|
376
|
-
return "extension_untrusted";
|
|
377
|
-
}
|
|
378
|
-
if ((policy.requireProvenance || override?.requireProvenance === true) && !provenanceVerified) {
|
|
379
|
-
return "provenance_missing_or_unverified";
|
|
380
|
-
}
|
|
381
|
-
return null;
|
|
382
|
-
}
|
|
383
|
-
function resolvePolicySandboxReason(policy, extension) {
|
|
384
|
-
if (policy.mode === "off") {
|
|
385
|
-
return null;
|
|
386
|
-
}
|
|
387
|
-
const override = resolvePolicyOverride(policy, extension.name);
|
|
388
|
-
const profile = override?.sandboxProfile ?? extension.sandboxProfile ?? policy.defaultSandboxProfile;
|
|
389
|
-
if (profile === "none") {
|
|
390
|
-
return null;
|
|
391
|
-
}
|
|
392
|
-
const permissions = extension.permissions;
|
|
393
|
-
if (!permissions) {
|
|
394
|
-
return "sandbox_permissions_missing";
|
|
395
|
-
}
|
|
396
|
-
const hasPermission = (name) => permissions[name] === true;
|
|
397
|
-
if (profile === "restricted") {
|
|
398
|
-
if (hasPermission("process_spawn")) {
|
|
399
|
-
return "sandbox_restricted_disallows_process_spawn";
|
|
400
|
-
}
|
|
401
|
-
if (hasPermission("env_write")) {
|
|
402
|
-
return "sandbox_restricted_disallows_env_write";
|
|
403
|
-
}
|
|
404
|
-
return null;
|
|
405
|
-
}
|
|
406
|
-
if (profile === "strict") {
|
|
407
|
-
if (hasPermission("process_spawn")) {
|
|
408
|
-
return "sandbox_strict_disallows_process_spawn";
|
|
409
|
-
}
|
|
410
|
-
if (hasPermission("network")) {
|
|
411
|
-
return "sandbox_strict_disallows_network";
|
|
412
|
-
}
|
|
413
|
-
if (hasPermission("fs_write")) {
|
|
414
|
-
return "sandbox_strict_disallows_fs_write";
|
|
415
|
-
}
|
|
416
|
-
if (hasPermission("env_write")) {
|
|
417
|
-
return "sandbox_strict_disallows_env_write";
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
return null;
|
|
421
|
-
}
|
|
422
|
-
function buildPolicyWarning(mode, scope, extension, reason, details = {}) {
|
|
423
|
-
const tokens = Object.entries(details)
|
|
424
|
-
.sort((left, right) => left[0].localeCompare(right[0]))
|
|
425
|
-
.map(([key, value]) => `${key}=${value}`)
|
|
426
|
-
.join(":");
|
|
427
|
-
const suffix = tokens.length > 0 ? `:${tokens}` : "";
|
|
428
|
-
return `extension_policy_${mode}_${scope}:${extension.layer}:${extension.name}:reason=${reason}${suffix}`;
|
|
429
|
-
}
|
|
430
|
-
function evaluateExtensionPolicyForExtension(policy, extension) {
|
|
431
|
-
if (policy.mode === "off" && policy.trustMode === "off") {
|
|
432
|
-
return { allowed: true, warning: null };
|
|
433
|
-
}
|
|
434
|
-
const reason = resolvePolicyExtensionReason(policy, extension);
|
|
435
|
-
const trustReason = resolvePolicyTrustReason(policy, extension);
|
|
436
|
-
const sandboxReason = resolvePolicySandboxReason(policy, extension);
|
|
437
|
-
const extensionEnforced = reason && policy.mode === "enforce";
|
|
438
|
-
const trustEnforced = trustReason && policy.trustMode === "enforce";
|
|
439
|
-
const sandboxEnforced = sandboxReason && policy.mode === "enforce";
|
|
440
|
-
if (!reason && !trustReason && !sandboxReason) {
|
|
441
|
-
return { allowed: true, warning: null };
|
|
442
|
-
}
|
|
443
|
-
if (extensionEnforced) {
|
|
444
|
-
return {
|
|
445
|
-
allowed: false,
|
|
446
|
-
warning: buildPolicyWarning("blocked", "extension", extension, reason),
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
if (trustEnforced) {
|
|
450
|
-
return {
|
|
451
|
-
allowed: false,
|
|
452
|
-
warning: buildPolicyWarning("blocked", "trust", extension, trustReason),
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
if (sandboxEnforced) {
|
|
456
|
-
return {
|
|
457
|
-
allowed: false,
|
|
458
|
-
warning: buildPolicyWarning("blocked", "extension", extension, sandboxReason),
|
|
459
|
-
};
|
|
460
|
-
}
|
|
461
|
-
if (reason && policy.mode === "warn") {
|
|
462
|
-
return {
|
|
463
|
-
allowed: true,
|
|
464
|
-
warning: buildPolicyWarning("violation", "extension", extension, reason),
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
if (trustReason && policy.trustMode === "warn") {
|
|
468
|
-
return {
|
|
469
|
-
allowed: true,
|
|
470
|
-
warning: buildPolicyWarning("violation", "trust", extension, trustReason),
|
|
471
|
-
};
|
|
472
|
-
}
|
|
473
|
-
if (sandboxReason && policy.mode === "warn") {
|
|
474
|
-
return {
|
|
475
|
-
allowed: true,
|
|
476
|
-
warning: buildPolicyWarning("violation", "extension", extension, sandboxReason),
|
|
477
|
-
};
|
|
478
|
-
}
|
|
479
|
-
return {
|
|
480
|
-
allowed: true,
|
|
481
|
-
warning: null,
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
function evaluateExtensionPolicyForCapability(policy, extension, capability) {
|
|
485
|
-
if (policy.mode === "off") {
|
|
486
|
-
return { allowed: true, warning: null };
|
|
487
|
-
}
|
|
488
|
-
const reason = resolvePolicyCapabilityReason(policy, extension, capability);
|
|
489
|
-
if (!reason) {
|
|
490
|
-
return { allowed: true, warning: null };
|
|
491
|
-
}
|
|
492
|
-
return {
|
|
493
|
-
allowed: policy.mode === "warn",
|
|
494
|
-
warning: buildPolicyWarning(policy.mode === "warn" ? "violation" : "blocked", "capability", extension, reason, { capability: capability.trim().toLowerCase() }),
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
function evaluateExtensionPolicyForRegistration(policy, extension, surface, method, capability, details) {
|
|
498
|
-
if (policy.mode === "off") {
|
|
499
|
-
return { allowed: true, warning: null };
|
|
500
|
-
}
|
|
501
|
-
const capabilityReason = typeof capability === "string" ? resolvePolicyCapabilityReason(policy, extension, capability) : null;
|
|
502
|
-
const surfaceReason = resolvePolicySurfaceReason(policy, extension, surface);
|
|
503
|
-
const commandReason = details?.command ? resolvePolicyCommandReason(policy, extension, details.command) : null;
|
|
504
|
-
const actionReason = details?.action ? resolvePolicyActionReason(policy, extension, details.action) : null;
|
|
505
|
-
const serviceReason = details?.service ? resolvePolicyServiceReason(policy, extension, details.service) : null;
|
|
506
|
-
const reason = capabilityReason ?? surfaceReason ?? commandReason ?? actionReason ?? serviceReason;
|
|
507
|
-
if (!reason) {
|
|
508
|
-
return { allowed: true, warning: null };
|
|
509
|
-
}
|
|
510
|
-
const warningDetails = {
|
|
511
|
-
method: normalizePolicyName(method).replace(/\s+/g, "_"),
|
|
512
|
-
surface,
|
|
513
|
-
};
|
|
514
|
-
if (capability) {
|
|
515
|
-
warningDetails.capability = capability;
|
|
516
|
-
}
|
|
517
|
-
if (details?.command) {
|
|
518
|
-
warningDetails.command = normalizeCommandName(details.command);
|
|
519
|
-
}
|
|
520
|
-
if (details?.action) {
|
|
521
|
-
warningDetails.action = normalizePolicyName(details.action).replace(/\s+/g, "-");
|
|
522
|
-
}
|
|
523
|
-
if (details?.service) {
|
|
524
|
-
warningDetails.service = normalizePolicyName(details.service);
|
|
525
|
-
}
|
|
526
|
-
const warning = buildPolicyWarning(policy.mode === "warn" ? "violation" : "blocked", "registration", extension, reason, warningDetails);
|
|
527
|
-
return {
|
|
528
|
-
allowed: policy.mode === "warn",
|
|
529
|
-
warning,
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
function resolveLegacyExtensionCapabilityAlias(capability) {
|
|
533
|
-
const normalized = capability.trim().toLowerCase();
|
|
534
|
-
if (normalized.length === 0) {
|
|
535
|
-
return null;
|
|
536
|
-
}
|
|
537
|
-
return EXTENSION_CAPABILITY_LEGACY_ALIASES[normalized] ?? null;
|
|
538
|
-
}
|
|
539
|
-
function normalizeManifestCapabilities(rawCapabilities) {
|
|
540
|
-
const normalizedCapabilities = normalizeNames([...rawCapabilities].map((value) => value.toLowerCase()));
|
|
541
|
-
const remappedCapabilities = [];
|
|
542
|
-
const legacyAliases = [];
|
|
543
|
-
for (const capability of normalizedCapabilities) {
|
|
544
|
-
const legacyAliasTarget = resolveLegacyExtensionCapabilityAlias(capability);
|
|
545
|
-
if (legacyAliasTarget) {
|
|
546
|
-
remappedCapabilities.push(legacyAliasTarget);
|
|
547
|
-
legacyAliases.push({
|
|
548
|
-
alias: capability,
|
|
549
|
-
target: legacyAliasTarget,
|
|
550
|
-
});
|
|
551
|
-
continue;
|
|
552
|
-
}
|
|
553
|
-
remappedCapabilities.push(capability);
|
|
554
|
-
}
|
|
555
|
-
const dedupedLegacyAliases = [...new Map(legacyAliases.map((entry) => [`${entry.alias}>${entry.target}`, entry])).values()].sort((left, right) => left.alias.localeCompare(right.alias));
|
|
556
|
-
return {
|
|
557
|
-
capabilities: normalizeNames(remappedCapabilities),
|
|
558
|
-
legacy_aliases: dedupedLegacyAliases,
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
function levenshteinDistance(left, right) {
|
|
562
|
-
if (left === right) {
|
|
563
|
-
return 0;
|
|
564
|
-
}
|
|
565
|
-
if (left.length === 0) {
|
|
566
|
-
return right.length;
|
|
567
|
-
}
|
|
568
|
-
if (right.length === 0) {
|
|
569
|
-
return left.length;
|
|
570
|
-
}
|
|
571
|
-
const previous = new Array(right.length + 1);
|
|
572
|
-
const current = new Array(right.length + 1);
|
|
573
|
-
for (let j = 0; j <= right.length; j += 1) {
|
|
574
|
-
previous[j] = j;
|
|
575
|
-
}
|
|
576
|
-
for (let i = 1; i <= left.length; i += 1) {
|
|
577
|
-
current[0] = i;
|
|
578
|
-
for (let j = 1; j <= right.length; j += 1) {
|
|
579
|
-
const substitutionCost = left[i - 1] === right[j - 1] ? 0 : 1;
|
|
580
|
-
current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + substitutionCost);
|
|
581
|
-
}
|
|
582
|
-
for (let j = 0; j <= right.length; j += 1) {
|
|
583
|
-
previous[j] = current[j];
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
return previous[right.length] ?? left.length;
|
|
587
|
-
}
|
|
588
|
-
function suggestKnownExtensionCapability(capability) {
|
|
589
|
-
const normalized = capability.trim().toLowerCase();
|
|
590
|
-
if (normalized.length === 0) {
|
|
591
|
-
return null;
|
|
592
|
-
}
|
|
593
|
-
const legacyAlias = resolveLegacyExtensionCapabilityAlias(normalized);
|
|
594
|
-
if (legacyAlias) {
|
|
595
|
-
return legacyAlias;
|
|
596
|
-
}
|
|
597
|
-
let bestMatch = null;
|
|
598
|
-
let bestDistance = Number.POSITIVE_INFINITY;
|
|
599
|
-
for (const candidate of KNOWN_EXTENSION_CAPABILITIES) {
|
|
600
|
-
const distance = levenshteinDistance(normalized, candidate);
|
|
601
|
-
if (distance < bestDistance) {
|
|
602
|
-
bestDistance = distance;
|
|
603
|
-
bestMatch = candidate;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
const maxDistance = Math.max(1, Math.floor(normalized.length * 0.34));
|
|
607
|
-
return bestMatch !== null && bestDistance <= maxDistance ? bestMatch : null;
|
|
608
|
-
}
|
|
609
|
-
function formatUnknownExtensionCapabilityWarning(layer, name, capability) {
|
|
610
|
-
const allowed = KNOWN_EXTENSION_CAPABILITIES.join(",");
|
|
611
|
-
const suggested = suggestKnownExtensionCapability(capability) ?? "none";
|
|
612
|
-
return `extension_capability_unknown:${layer}:${name}:${capability}:allowed=${allowed}:suggested=${suggested}`;
|
|
613
|
-
}
|
|
614
|
-
function formatLegacyExtensionCapabilityAliasWarning(layer, name, aliases) {
|
|
615
|
-
const aliasesToken = aliases.map((entry) => `${entry.alias}>${entry.target}`).join(",");
|
|
616
|
-
return `extension_capability_legacy_alias:${layer}:${name}:aliases=${aliasesToken}`;
|
|
617
|
-
}
|
|
618
|
-
export function parseUnknownExtensionCapabilityWarning(warning) {
|
|
619
|
-
const match = /^extension_capability_unknown:(global|project):([^:]+):([^:]+):allowed=([^:]+):suggested=([^:]+)$/.exec(warning.trim());
|
|
620
|
-
if (!match) {
|
|
621
|
-
return null;
|
|
622
|
-
}
|
|
623
|
-
const [, layerRaw, name, capability, allowedRaw, suggestedRaw] = match;
|
|
624
|
-
const layer = layerRaw;
|
|
625
|
-
const allowed_capabilities = allowedRaw
|
|
626
|
-
.split(",")
|
|
627
|
-
.map((value) => value.trim())
|
|
628
|
-
.filter((value) => value.length > 0);
|
|
629
|
-
const legacyAlias = resolveLegacyExtensionCapabilityAlias(capability);
|
|
630
|
-
const suggestedFromWarning = suggestedRaw === "none" ? undefined : suggestedRaw;
|
|
631
|
-
const suggested_capability = suggestedFromWarning ?? legacyAlias ?? undefined;
|
|
632
|
-
const suggestion_source = suggested_capability
|
|
633
|
-
? legacyAlias === suggested_capability
|
|
634
|
-
? "legacy_alias"
|
|
635
|
-
: "nearest_match"
|
|
636
|
-
: undefined;
|
|
637
|
-
return {
|
|
638
|
-
layer,
|
|
639
|
-
name,
|
|
640
|
-
capability,
|
|
641
|
-
allowed_capabilities,
|
|
642
|
-
capability_contract_version: EXTENSION_CAPABILITY_CONTRACT_VERSION,
|
|
643
|
-
suggested_capability,
|
|
644
|
-
suggestion_source,
|
|
645
|
-
legacy_alias_target: legacyAlias ?? undefined,
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
export function parseLegacyExtensionCapabilityAliasWarning(warning) {
|
|
649
|
-
const match = /^extension_capability_legacy_alias:(global|project):([^:]+):aliases=(.+)$/.exec(warning.trim());
|
|
650
|
-
if (!match) {
|
|
651
|
-
return [];
|
|
652
|
-
}
|
|
653
|
-
const [, layerRaw, name, aliasesRaw] = match;
|
|
654
|
-
const layer = layerRaw;
|
|
655
|
-
const allowedCapabilities = [...KNOWN_EXTENSION_CAPABILITIES];
|
|
656
|
-
const parsed = [];
|
|
657
|
-
for (const token of aliasesRaw.split(",")) {
|
|
658
|
-
const [rawAlias, rawTarget] = token.split(">");
|
|
659
|
-
const alias = rawAlias?.trim();
|
|
660
|
-
const target = rawTarget?.trim().toLowerCase();
|
|
661
|
-
if (!alias || !target || !isKnownExtensionCapability(target)) {
|
|
662
|
-
continue;
|
|
663
|
-
}
|
|
664
|
-
parsed.push({
|
|
665
|
-
layer,
|
|
666
|
-
name,
|
|
667
|
-
capability: alias,
|
|
668
|
-
allowed_capabilities: allowedCapabilities,
|
|
669
|
-
capability_contract_version: EXTENSION_CAPABILITY_CONTRACT_VERSION,
|
|
670
|
-
suggested_capability: target,
|
|
671
|
-
suggestion_source: "legacy_alias",
|
|
672
|
-
legacy_alias_target: target,
|
|
673
|
-
});
|
|
674
|
-
}
|
|
675
|
-
return parsed;
|
|
676
|
-
}
|
|
677
31
|
function parseManifest(raw) {
|
|
678
32
|
if (typeof raw !== "object" || raw === null) {
|
|
679
33
|
return null;
|
|
@@ -722,7 +76,7 @@ function parseManifest(raw) {
|
|
|
722
76
|
}
|
|
723
77
|
let provenance;
|
|
724
78
|
if ("provenance" in candidate && candidate.provenance !== undefined && candidate.provenance !== null) {
|
|
725
|
-
const provenanceRecord =
|
|
79
|
+
const provenanceRecord = asRecordLoose(candidate.provenance);
|
|
726
80
|
if (!provenanceRecord) {
|
|
727
81
|
return null;
|
|
728
82
|
}
|
|
@@ -752,7 +106,7 @@ function parseManifest(raw) {
|
|
|
752
106
|
}
|
|
753
107
|
let permissions;
|
|
754
108
|
if ("permissions" in candidate && candidate.permissions !== undefined && candidate.permissions !== null) {
|
|
755
|
-
const permissionsRecord =
|
|
109
|
+
const permissionsRecord = asRecordLoose(candidate.permissions);
|
|
756
110
|
if (!permissionsRecord) {
|
|
757
111
|
return null;
|
|
758
112
|
}
|
|
@@ -807,12 +161,6 @@ function parseManifest(raw) {
|
|
|
807
161
|
legacy_capability_aliases: legacyCapabilityAliases.length > 0 ? legacyCapabilityAliases : undefined,
|
|
808
162
|
};
|
|
809
163
|
}
|
|
810
|
-
function asRecord(value) {
|
|
811
|
-
if (typeof value !== "object" || value === null) {
|
|
812
|
-
return null;
|
|
813
|
-
}
|
|
814
|
-
return value;
|
|
815
|
-
}
|
|
816
164
|
function shouldEnable(name, enabled, disabled) {
|
|
817
165
|
if (disabled.has(name)) {
|
|
818
166
|
return false;
|
|
@@ -822,13 +170,6 @@ function shouldEnable(name, enabled, disabled) {
|
|
|
822
170
|
}
|
|
823
171
|
return enabled.has(name);
|
|
824
172
|
}
|
|
825
|
-
function isPathWithinDirectory(directory, targetPath) {
|
|
826
|
-
const relative = path.relative(directory, targetPath);
|
|
827
|
-
if (relative.length === 0) {
|
|
828
|
-
return true;
|
|
829
|
-
}
|
|
830
|
-
return !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
831
|
-
}
|
|
832
173
|
async function isCanonicalPathWithinDirectory(directory, targetPath) {
|
|
833
174
|
const [resolvedDirectory, resolvedTargetPath] = await Promise.all([fs.realpath(directory), fs.realpath(targetPath)]);
|
|
834
175
|
return isPathWithinDirectory(resolvedDirectory, resolvedTargetPath);
|
|
@@ -839,54 +180,6 @@ export function resolveExtensionRoots(pmRoot, cwd = process.cwd()) {
|
|
|
839
180
|
project: path.join(pmRoot, "extensions"),
|
|
840
181
|
};
|
|
841
182
|
}
|
|
842
|
-
export function createEmptyExtensionHookRegistry() {
|
|
843
|
-
return {
|
|
844
|
-
beforeCommand: [],
|
|
845
|
-
afterCommand: [],
|
|
846
|
-
onWrite: [],
|
|
847
|
-
onRead: [],
|
|
848
|
-
onIndex: [],
|
|
849
|
-
};
|
|
850
|
-
}
|
|
851
|
-
export function createEmptyExtensionCommandRegistry() {
|
|
852
|
-
return {
|
|
853
|
-
overrides: [],
|
|
854
|
-
handlers: [],
|
|
855
|
-
};
|
|
856
|
-
}
|
|
857
|
-
export function createEmptyExtensionParserRegistry() {
|
|
858
|
-
return {
|
|
859
|
-
overrides: [],
|
|
860
|
-
};
|
|
861
|
-
}
|
|
862
|
-
export function createEmptyExtensionPreflightRegistry() {
|
|
863
|
-
return {
|
|
864
|
-
overrides: [],
|
|
865
|
-
};
|
|
866
|
-
}
|
|
867
|
-
export function createEmptyExtensionServiceRegistry() {
|
|
868
|
-
return {
|
|
869
|
-
overrides: [],
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
export function createEmptyExtensionRendererRegistry() {
|
|
873
|
-
return {
|
|
874
|
-
overrides: [],
|
|
875
|
-
};
|
|
876
|
-
}
|
|
877
|
-
export function createEmptyExtensionRegistrationRegistry() {
|
|
878
|
-
return {
|
|
879
|
-
commands: [],
|
|
880
|
-
flags: [],
|
|
881
|
-
item_fields: [],
|
|
882
|
-
item_types: [],
|
|
883
|
-
migrations: [],
|
|
884
|
-
importers: [],
|
|
885
|
-
exporters: [],
|
|
886
|
-
search_providers: [],
|
|
887
|
-
vector_store_adapters: [],
|
|
888
|
-
};
|
|
889
|
-
}
|
|
890
183
|
async function listExtensionDirectories(extensionsRoot) {
|
|
891
184
|
try {
|
|
892
185
|
const entries = await fs.readdir(extensionsRoot, { withFileTypes: true });
|
|
@@ -1188,7 +481,7 @@ export async function loadExtensions(options) {
|
|
|
1188
481
|
};
|
|
1189
482
|
}
|
|
1190
483
|
function resolveActivatableExtension(module) {
|
|
1191
|
-
const moduleRecord =
|
|
484
|
+
const moduleRecord = asRecordLoose(module);
|
|
1192
485
|
if (!moduleRecord) {
|
|
1193
486
|
return null;
|
|
1194
487
|
}
|
|
@@ -1197,7 +490,7 @@ function resolveActivatableExtension(module) {
|
|
|
1197
490
|
activate: moduleRecord.activate,
|
|
1198
491
|
};
|
|
1199
492
|
}
|
|
1200
|
-
const defaultExport =
|
|
493
|
+
const defaultExport = asRecordLoose(moduleRecord.default);
|
|
1201
494
|
if (defaultExport && typeof defaultExport.activate === "function") {
|
|
1202
495
|
return {
|
|
1203
496
|
activate: defaultExport.activate,
|
|
@@ -1205,46 +498,11 @@ function resolveActivatableExtension(module) {
|
|
|
1205
498
|
}
|
|
1206
499
|
return null;
|
|
1207
500
|
}
|
|
1208
|
-
function normalizeCommandName(command) {
|
|
1209
|
-
return command
|
|
1210
|
-
.trim()
|
|
1211
|
-
.toLowerCase()
|
|
1212
|
-
.split(/\s+/)
|
|
1213
|
-
.filter((part) => part.length > 0)
|
|
1214
|
-
.join(" ");
|
|
1215
|
-
}
|
|
1216
|
-
function defaultGlobalOptions() {
|
|
1217
|
-
return {
|
|
1218
|
-
json: false,
|
|
1219
|
-
quiet: false,
|
|
1220
|
-
noExtensions: false,
|
|
1221
|
-
profile: false,
|
|
1222
|
-
};
|
|
1223
|
-
}
|
|
1224
|
-
function cloneCommandOptionsSnapshot(options) {
|
|
1225
|
-
return options ? cloneContextSnapshot(options) : {};
|
|
1226
|
-
}
|
|
1227
|
-
function cloneGlobalOptionsSnapshot(options) {
|
|
1228
|
-
return options ? cloneContextSnapshot(options) : defaultGlobalOptions();
|
|
1229
|
-
}
|
|
1230
|
-
function cloneContextSnapshot(value) {
|
|
1231
|
-
return structuredClone(value);
|
|
1232
|
-
}
|
|
1233
501
|
function isOutputRendererFormat(value) {
|
|
1234
502
|
return value === "toon" || value === "json";
|
|
1235
503
|
}
|
|
1236
|
-
const EXTENSION_SERVICE_NAMES = [
|
|
1237
|
-
"output_format",
|
|
1238
|
-
"error_format",
|
|
1239
|
-
"help_format",
|
|
1240
|
-
"lock_acquire",
|
|
1241
|
-
"lock_release",
|
|
1242
|
-
"history_append",
|
|
1243
|
-
"item_store_write",
|
|
1244
|
-
"item_store_delete",
|
|
1245
|
-
];
|
|
1246
504
|
function isExtensionServiceName(value) {
|
|
1247
|
-
return
|
|
505
|
+
return KNOWN_EXTENSION_SERVICE_NAMES.includes(value);
|
|
1248
506
|
}
|
|
1249
507
|
function assertHookHandler(hookName, hook) {
|
|
1250
508
|
if (typeof hook !== "function") {
|
|
@@ -1748,7 +1006,7 @@ function createExtensionApi(extension, hooks, commands, parsers, preflight, serv
|
|
|
1748
1006
|
assertExtensionCapability(extension, "services", "registerService");
|
|
1749
1007
|
const normalizedService = String(service).trim().toLowerCase();
|
|
1750
1008
|
if (!isExtensionServiceName(normalizedService)) {
|
|
1751
|
-
throw new TypeError(`registerService service must be one of: ${
|
|
1009
|
+
throw new TypeError(`registerService service must be one of: ${KNOWN_EXTENSION_SERVICE_NAMES.join(", ")}`);
|
|
1752
1010
|
}
|
|
1753
1011
|
if (!allowRegistration("services.override", "registerService", "services", { service: normalizedService })) {
|
|
1754
1012
|
return;
|
|
@@ -2006,18 +1264,6 @@ function createExtensionApi(extension, hooks, commands, parsers, preflight, serv
|
|
|
2006
1264
|
},
|
|
2007
1265
|
};
|
|
2008
1266
|
}
|
|
2009
|
-
async function executeRegisteredHooks(entries, hookName, context) {
|
|
2010
|
-
const warnings = [];
|
|
2011
|
-
for (const entry of entries) {
|
|
2012
|
-
try {
|
|
2013
|
-
await entry.run(cloneContextSnapshot(context));
|
|
2014
|
-
}
|
|
2015
|
-
catch {
|
|
2016
|
-
warnings.push(`extension_hook_failed:${entry.layer}:${entry.name}:${hookName}`);
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
return warnings;
|
|
2020
|
-
}
|
|
2021
1267
|
function getRegistrationCounts(registrations) {
|
|
2022
1268
|
const commandCount = registrations.commands.length;
|
|
2023
1269
|
const flagCount = registrations.flags.reduce((total, entry) => total + entry.flags.length, 0);
|
|
@@ -2206,374 +1452,5 @@ export async function activateExtensions(loadResult) {
|
|
|
2206
1452
|
registration_counts: getRegistrationCounts(registrations),
|
|
2207
1453
|
};
|
|
2208
1454
|
}
|
|
2209
|
-
export async function runBeforeCommandHooks(hooks, context) {
|
|
2210
|
-
return executeRegisteredHooks(hooks.beforeCommand, "beforeCommand", context);
|
|
2211
|
-
}
|
|
2212
|
-
export async function runAfterCommandHooks(hooks, context) {
|
|
2213
|
-
return executeRegisteredHooks(hooks.afterCommand, "afterCommand", context);
|
|
2214
|
-
}
|
|
2215
|
-
export async function runOnWriteHooks(hooks, context) {
|
|
2216
|
-
return executeRegisteredHooks(hooks.onWrite, "onWrite", context);
|
|
2217
|
-
}
|
|
2218
|
-
export async function runOnReadHooks(hooks, context) {
|
|
2219
|
-
return executeRegisteredHooks(hooks.onRead, "onRead", context);
|
|
2220
|
-
}
|
|
2221
|
-
export async function runOnIndexHooks(hooks, context) {
|
|
2222
|
-
return executeRegisteredHooks(hooks.onIndex, "onIndex", context);
|
|
2223
|
-
}
|
|
2224
|
-
export async function runCommandHandler(commands, context) {
|
|
2225
|
-
const command = normalizeCommandName(context.command);
|
|
2226
|
-
if (command.length === 0) {
|
|
2227
|
-
return {
|
|
2228
|
-
handled: false,
|
|
2229
|
-
result: null,
|
|
2230
|
-
warnings: [],
|
|
2231
|
-
};
|
|
2232
|
-
}
|
|
2233
|
-
const matched = [...commands.handlers].reverse().find((entry) => entry.command === command);
|
|
2234
|
-
if (!matched) {
|
|
2235
|
-
return {
|
|
2236
|
-
handled: false,
|
|
2237
|
-
result: null,
|
|
2238
|
-
warnings: [],
|
|
2239
|
-
};
|
|
2240
|
-
}
|
|
2241
|
-
try {
|
|
2242
|
-
const result = await matched.run({
|
|
2243
|
-
command,
|
|
2244
|
-
args: cloneContextSnapshot(context.args),
|
|
2245
|
-
options: cloneContextSnapshot(context.options),
|
|
2246
|
-
global: cloneContextSnapshot(context.global),
|
|
2247
|
-
pm_root: context.pm_root,
|
|
2248
|
-
});
|
|
2249
|
-
return {
|
|
2250
|
-
handled: true,
|
|
2251
|
-
result,
|
|
2252
|
-
warnings: [],
|
|
2253
|
-
};
|
|
2254
|
-
}
|
|
2255
|
-
catch (error) {
|
|
2256
|
-
const exitCode = typeof error === "object" && error !== null && "exitCode" in error
|
|
2257
|
-
? error.exitCode
|
|
2258
|
-
: undefined;
|
|
2259
|
-
if (typeof exitCode === "number" && Number.isFinite(exitCode)) {
|
|
2260
|
-
throw error;
|
|
2261
|
-
}
|
|
2262
|
-
return {
|
|
2263
|
-
handled: false,
|
|
2264
|
-
result: null,
|
|
2265
|
-
warnings: [`extension_command_handler_failed:${matched.layer}:${matched.name}:${matched.command}`],
|
|
2266
|
-
};
|
|
2267
|
-
}
|
|
2268
|
-
}
|
|
2269
|
-
export async function runParserOverride(parsers, context) {
|
|
2270
|
-
const command = normalizeCommandName(context.command);
|
|
2271
|
-
if (command.length === 0) {
|
|
2272
|
-
return {
|
|
2273
|
-
overridden: false,
|
|
2274
|
-
context: {
|
|
2275
|
-
command,
|
|
2276
|
-
args: cloneContextSnapshot(context.args),
|
|
2277
|
-
options: cloneCommandOptionsSnapshot(context.options),
|
|
2278
|
-
global: cloneGlobalOptionsSnapshot(context.global),
|
|
2279
|
-
pm_root: context.pm_root,
|
|
2280
|
-
},
|
|
2281
|
-
warnings: [],
|
|
2282
|
-
};
|
|
2283
|
-
}
|
|
2284
|
-
const matched = [...parsers.overrides].reverse().find((entry) => entry.command === command);
|
|
2285
|
-
if (!matched) {
|
|
2286
|
-
return {
|
|
2287
|
-
overridden: false,
|
|
2288
|
-
context: {
|
|
2289
|
-
command,
|
|
2290
|
-
args: cloneContextSnapshot(context.args),
|
|
2291
|
-
options: cloneCommandOptionsSnapshot(context.options),
|
|
2292
|
-
global: cloneGlobalOptionsSnapshot(context.global),
|
|
2293
|
-
pm_root: context.pm_root,
|
|
2294
|
-
},
|
|
2295
|
-
warnings: [],
|
|
2296
|
-
};
|
|
2297
|
-
}
|
|
2298
|
-
try {
|
|
2299
|
-
const delta = (await Promise.resolve(matched.run({
|
|
2300
|
-
command,
|
|
2301
|
-
args: cloneContextSnapshot(context.args),
|
|
2302
|
-
options: cloneCommandOptionsSnapshot(context.options),
|
|
2303
|
-
global: cloneGlobalOptionsSnapshot(context.global),
|
|
2304
|
-
pm_root: context.pm_root,
|
|
2305
|
-
}))) ?? {};
|
|
2306
|
-
const nextArgs = Array.isArray(delta.args) ? cloneContextSnapshot(delta.args) : cloneContextSnapshot(context.args);
|
|
2307
|
-
const nextOptions = delta.options ? cloneCommandOptionsSnapshot(delta.options) : cloneCommandOptionsSnapshot(context.options);
|
|
2308
|
-
const nextGlobal = delta.global ? cloneGlobalOptionsSnapshot(delta.global) : cloneGlobalOptionsSnapshot(context.global);
|
|
2309
|
-
return {
|
|
2310
|
-
overridden: true,
|
|
2311
|
-
context: {
|
|
2312
|
-
command,
|
|
2313
|
-
args: nextArgs,
|
|
2314
|
-
options: nextOptions,
|
|
2315
|
-
global: nextGlobal,
|
|
2316
|
-
pm_root: context.pm_root,
|
|
2317
|
-
},
|
|
2318
|
-
warnings: [],
|
|
2319
|
-
};
|
|
2320
|
-
}
|
|
2321
|
-
catch {
|
|
2322
|
-
return {
|
|
2323
|
-
overridden: false,
|
|
2324
|
-
context: {
|
|
2325
|
-
command,
|
|
2326
|
-
args: cloneContextSnapshot(context.args),
|
|
2327
|
-
options: cloneCommandOptionsSnapshot(context.options),
|
|
2328
|
-
global: cloneGlobalOptionsSnapshot(context.global),
|
|
2329
|
-
pm_root: context.pm_root,
|
|
2330
|
-
},
|
|
2331
|
-
warnings: [`extension_parser_override_failed:${matched.layer}:${matched.name}:${matched.command}`],
|
|
2332
|
-
};
|
|
2333
|
-
}
|
|
2334
|
-
}
|
|
2335
|
-
export async function runPreflightOverride(preflight, context) {
|
|
2336
|
-
const matched = [...preflight.overrides].reverse()[0];
|
|
2337
|
-
const baseContext = {
|
|
2338
|
-
command: normalizeCommandName(context.command),
|
|
2339
|
-
args: cloneContextSnapshot(context.args),
|
|
2340
|
-
options: cloneCommandOptionsSnapshot(context.options),
|
|
2341
|
-
global: cloneGlobalOptionsSnapshot(context.global),
|
|
2342
|
-
pm_root: context.pm_root,
|
|
2343
|
-
};
|
|
2344
|
-
const baseDecision = cloneContextSnapshot(context.decision);
|
|
2345
|
-
if (!matched) {
|
|
2346
|
-
return {
|
|
2347
|
-
overridden: false,
|
|
2348
|
-
context: baseContext,
|
|
2349
|
-
decision: baseDecision,
|
|
2350
|
-
warnings: [],
|
|
2351
|
-
};
|
|
2352
|
-
}
|
|
2353
|
-
try {
|
|
2354
|
-
const delta = (await Promise.resolve(matched.run({
|
|
2355
|
-
command: baseContext.command,
|
|
2356
|
-
args: cloneContextSnapshot(baseContext.args),
|
|
2357
|
-
options: cloneCommandOptionsSnapshot(baseContext.options),
|
|
2358
|
-
global: cloneGlobalOptionsSnapshot(baseContext.global),
|
|
2359
|
-
pm_root: baseContext.pm_root,
|
|
2360
|
-
decision: cloneContextSnapshot(baseDecision),
|
|
2361
|
-
}))) ?? {};
|
|
2362
|
-
const nextContext = {
|
|
2363
|
-
command: baseContext.command,
|
|
2364
|
-
args: Array.isArray(delta.args) ? cloneContextSnapshot(delta.args) : baseContext.args,
|
|
2365
|
-
options: delta.options ? cloneCommandOptionsSnapshot(delta.options) : baseContext.options,
|
|
2366
|
-
global: delta.global ? cloneGlobalOptionsSnapshot(delta.global) : baseContext.global,
|
|
2367
|
-
pm_root: baseContext.pm_root,
|
|
2368
|
-
};
|
|
2369
|
-
const nextDecision = {
|
|
2370
|
-
enforce_item_format_gate: typeof delta.enforce_item_format_gate === "boolean"
|
|
2371
|
-
? delta.enforce_item_format_gate
|
|
2372
|
-
: baseDecision.enforce_item_format_gate,
|
|
2373
|
-
run_preflight_item_format_sync: typeof delta.run_preflight_item_format_sync === "boolean"
|
|
2374
|
-
? delta.run_preflight_item_format_sync
|
|
2375
|
-
: baseDecision.run_preflight_item_format_sync,
|
|
2376
|
-
run_extension_migrations: typeof delta.run_extension_migrations === "boolean"
|
|
2377
|
-
? delta.run_extension_migrations
|
|
2378
|
-
: baseDecision.run_extension_migrations,
|
|
2379
|
-
enforce_mandatory_migration_gate: typeof delta.enforce_mandatory_migration_gate === "boolean"
|
|
2380
|
-
? delta.enforce_mandatory_migration_gate
|
|
2381
|
-
: baseDecision.enforce_mandatory_migration_gate,
|
|
2382
|
-
};
|
|
2383
|
-
return {
|
|
2384
|
-
overridden: true,
|
|
2385
|
-
context: nextContext,
|
|
2386
|
-
decision: nextDecision,
|
|
2387
|
-
warnings: [],
|
|
2388
|
-
};
|
|
2389
|
-
}
|
|
2390
|
-
catch {
|
|
2391
|
-
return {
|
|
2392
|
-
overridden: false,
|
|
2393
|
-
context: baseContext,
|
|
2394
|
-
decision: baseDecision,
|
|
2395
|
-
warnings: [`extension_preflight_override_failed:${matched.layer}:${matched.name}`],
|
|
2396
|
-
};
|
|
2397
|
-
}
|
|
2398
|
-
}
|
|
2399
|
-
function resolveDefaultServiceResult(context) {
|
|
2400
|
-
return {
|
|
2401
|
-
handled: false,
|
|
2402
|
-
result: context.payload,
|
|
2403
|
-
warnings: [],
|
|
2404
|
-
};
|
|
2405
|
-
}
|
|
2406
|
-
export function runServiceOverrideSync(services, context) {
|
|
2407
|
-
const matches = [...services.overrides].reverse().filter((entry) => entry.service === context.service);
|
|
2408
|
-
if (matches.length === 0) {
|
|
2409
|
-
return resolveDefaultServiceResult(context);
|
|
2410
|
-
}
|
|
2411
|
-
const warnings = [];
|
|
2412
|
-
for (const matched of matches) {
|
|
2413
|
-
try {
|
|
2414
|
-
const serviceContext = {
|
|
2415
|
-
service: context.service,
|
|
2416
|
-
command: context.command ? normalizeCommandName(context.command) : undefined,
|
|
2417
|
-
args: context.args ? cloneContextSnapshot(context.args) : undefined,
|
|
2418
|
-
options: context.options ? cloneCommandOptionsSnapshot(context.options) : undefined,
|
|
2419
|
-
global: context.global ? cloneGlobalOptionsSnapshot(context.global) : undefined,
|
|
2420
|
-
pm_root: context.pm_root,
|
|
2421
|
-
payload: cloneContextSnapshot(context.payload),
|
|
2422
|
-
};
|
|
2423
|
-
const result = matched.run(serviceContext);
|
|
2424
|
-
if (result instanceof Promise) {
|
|
2425
|
-
warnings.push(`extension_service_override_async_unsupported:${matched.layer}:${matched.name}:${matched.service}`);
|
|
2426
|
-
continue;
|
|
2427
|
-
}
|
|
2428
|
-
if (context.service === "output_format" && (result === null || result === undefined || result === serviceContext.payload)) {
|
|
2429
|
-
continue;
|
|
2430
|
-
}
|
|
2431
|
-
return {
|
|
2432
|
-
handled: true,
|
|
2433
|
-
result,
|
|
2434
|
-
warnings,
|
|
2435
|
-
};
|
|
2436
|
-
}
|
|
2437
|
-
catch {
|
|
2438
|
-
warnings.push(`extension_service_override_failed:${matched.layer}:${matched.name}:${matched.service}`);
|
|
2439
|
-
}
|
|
2440
|
-
}
|
|
2441
|
-
return {
|
|
2442
|
-
handled: false,
|
|
2443
|
-
result: context.payload,
|
|
2444
|
-
warnings,
|
|
2445
|
-
};
|
|
2446
|
-
}
|
|
2447
|
-
export async function runServiceOverride(services, context) {
|
|
2448
|
-
const matches = [...services.overrides].reverse().filter((entry) => entry.service === context.service);
|
|
2449
|
-
if (matches.length === 0) {
|
|
2450
|
-
return resolveDefaultServiceResult(context);
|
|
2451
|
-
}
|
|
2452
|
-
const warnings = [];
|
|
2453
|
-
for (const matched of matches) {
|
|
2454
|
-
try {
|
|
2455
|
-
const serviceContext = {
|
|
2456
|
-
service: context.service,
|
|
2457
|
-
command: context.command ? normalizeCommandName(context.command) : undefined,
|
|
2458
|
-
args: context.args ? cloneContextSnapshot(context.args) : undefined,
|
|
2459
|
-
options: context.options ? cloneCommandOptionsSnapshot(context.options) : undefined,
|
|
2460
|
-
global: context.global ? cloneGlobalOptionsSnapshot(context.global) : undefined,
|
|
2461
|
-
pm_root: context.pm_root,
|
|
2462
|
-
payload: cloneContextSnapshot(context.payload),
|
|
2463
|
-
};
|
|
2464
|
-
const result = await Promise.resolve(matched.run(serviceContext));
|
|
2465
|
-
if (context.service === "output_format" && (result === null || result === undefined || result === serviceContext.payload)) {
|
|
2466
|
-
continue;
|
|
2467
|
-
}
|
|
2468
|
-
return {
|
|
2469
|
-
handled: true,
|
|
2470
|
-
result,
|
|
2471
|
-
warnings,
|
|
2472
|
-
};
|
|
2473
|
-
}
|
|
2474
|
-
catch {
|
|
2475
|
-
warnings.push(`extension_service_override_failed:${matched.layer}:${matched.name}:${matched.service}`);
|
|
2476
|
-
}
|
|
2477
|
-
}
|
|
2478
|
-
return {
|
|
2479
|
-
handled: false,
|
|
2480
|
-
result: context.payload,
|
|
2481
|
-
warnings,
|
|
2482
|
-
};
|
|
2483
|
-
}
|
|
2484
|
-
export function runCommandOverride(commands, context) {
|
|
2485
|
-
const command = normalizeCommandName(context.command);
|
|
2486
|
-
if (command.length === 0) {
|
|
2487
|
-
return {
|
|
2488
|
-
overridden: false,
|
|
2489
|
-
result: context.result,
|
|
2490
|
-
warnings: [],
|
|
2491
|
-
};
|
|
2492
|
-
}
|
|
2493
|
-
const matched = [...commands.overrides].reverse().find((entry) => entry.command === command);
|
|
2494
|
-
if (!matched) {
|
|
2495
|
-
return {
|
|
2496
|
-
overridden: false,
|
|
2497
|
-
result: context.result,
|
|
2498
|
-
warnings: [],
|
|
2499
|
-
};
|
|
2500
|
-
}
|
|
2501
|
-
try {
|
|
2502
|
-
const overrideOptions = cloneCommandOptionsSnapshot(context.options);
|
|
2503
|
-
const overrideGlobal = cloneGlobalOptionsSnapshot(context.global);
|
|
2504
|
-
const overrideResult = matched.run({
|
|
2505
|
-
command,
|
|
2506
|
-
args: cloneContextSnapshot(context.args),
|
|
2507
|
-
options: overrideOptions,
|
|
2508
|
-
global: overrideGlobal,
|
|
2509
|
-
pm_root: context.pm_root,
|
|
2510
|
-
result: cloneContextSnapshot(context.result),
|
|
2511
|
-
});
|
|
2512
|
-
if (overrideResult instanceof Promise) {
|
|
2513
|
-
return {
|
|
2514
|
-
overridden: false,
|
|
2515
|
-
result: context.result,
|
|
2516
|
-
warnings: [`extension_command_override_async_unsupported:${matched.layer}:${matched.name}:${matched.command}`],
|
|
2517
|
-
};
|
|
2518
|
-
}
|
|
2519
|
-
return {
|
|
2520
|
-
overridden: true,
|
|
2521
|
-
result: overrideResult,
|
|
2522
|
-
warnings: [],
|
|
2523
|
-
};
|
|
2524
|
-
}
|
|
2525
|
-
catch {
|
|
2526
|
-
return {
|
|
2527
|
-
overridden: false,
|
|
2528
|
-
result: context.result,
|
|
2529
|
-
warnings: [`extension_command_override_failed:${matched.layer}:${matched.name}:${matched.command}`],
|
|
2530
|
-
};
|
|
2531
|
-
}
|
|
2532
|
-
}
|
|
2533
|
-
export function runRendererOverride(renderers, context) {
|
|
2534
|
-
const matched = [...renderers.overrides].reverse().find((entry) => entry.format === context.format);
|
|
2535
|
-
if (!matched) {
|
|
2536
|
-
return {
|
|
2537
|
-
overridden: false,
|
|
2538
|
-
rendered: null,
|
|
2539
|
-
warnings: [],
|
|
2540
|
-
};
|
|
2541
|
-
}
|
|
2542
|
-
try {
|
|
2543
|
-
const rendererCommand = typeof context.command === "string" ? normalizeCommandName(context.command) : "";
|
|
2544
|
-
const rendererArgs = Array.isArray(context.args) ? cloneContextSnapshot(context.args) : [];
|
|
2545
|
-
const rendererOptions = cloneCommandOptionsSnapshot(context.options);
|
|
2546
|
-
const rendererGlobal = cloneGlobalOptionsSnapshot(context.global);
|
|
2547
|
-
const rendererPmRoot = typeof context.pm_root === "string" ? context.pm_root : "";
|
|
2548
|
-
const rendered = matched.run({
|
|
2549
|
-
format: context.format,
|
|
2550
|
-
command: rendererCommand,
|
|
2551
|
-
args: rendererArgs,
|
|
2552
|
-
options: rendererOptions,
|
|
2553
|
-
global: rendererGlobal,
|
|
2554
|
-
pm_root: rendererPmRoot,
|
|
2555
|
-
result: cloneContextSnapshot(context.result),
|
|
2556
|
-
});
|
|
2557
|
-
if (typeof rendered !== "string") {
|
|
2558
|
-
return {
|
|
2559
|
-
overridden: false,
|
|
2560
|
-
rendered: null,
|
|
2561
|
-
warnings: [`extension_renderer_invalid_result:${matched.layer}:${matched.name}:${matched.format}`],
|
|
2562
|
-
};
|
|
2563
|
-
}
|
|
2564
|
-
return {
|
|
2565
|
-
overridden: true,
|
|
2566
|
-
rendered,
|
|
2567
|
-
warnings: [],
|
|
2568
|
-
};
|
|
2569
|
-
}
|
|
2570
|
-
catch {
|
|
2571
|
-
return {
|
|
2572
|
-
overridden: false,
|
|
2573
|
-
rendered: null,
|
|
2574
|
-
warnings: [`extension_renderer_failed:${matched.layer}:${matched.name}:${matched.format}`],
|
|
2575
|
-
};
|
|
2576
|
-
}
|
|
2577
|
-
}
|
|
2578
1455
|
//# sourceMappingURL=loader.js.map
|
|
2579
|
-
//# debugId=
|
|
1456
|
+
//# debugId=4fba8687-0797-5479-afc8-12f1a2e5a954
|