@unbrained/pm-cli 2026.5.24 → 2026.5.28
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 -522
- package/README.md +2 -10
- 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 +134 -11
- package/dist/cli/commander-usage.js.map +1 -1
- package/dist/cli/commands/append.js +4 -3
- package/dist/cli/commands/append.js.map +1 -1
- package/dist/cli/commands/claim.js +5 -4
- package/dist/cli/commands/claim.js.map +1 -1
- package/dist/cli/commands/close.d.ts +3 -0
- package/dist/cli/commands/close.js +26 -3
- package/dist/cli/commands/close.js.map +1 -1
- package/dist/cli/commands/completion.d.ts +2 -2
- package/dist/cli/commands/completion.js +109 -56
- 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/create.js +7 -272
- package/dist/cli/commands/create.js.map +1 -1
- package/dist/cli/commands/delete.js +4 -3
- package/dist/cli/commands/delete.js.map +1 -1
- package/dist/cli/commands/docs.d.ts +1 -12
- package/dist/cli/commands/docs.js +8 -312
- package/dist/cli/commands/docs.js.map +1 -1
- 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 +202 -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 +36 -68
- package/dist/cli/commands/extension.js +143 -1422
- package/dist/cli/commands/extension.js.map +1 -1
- package/dist/cli/commands/files.d.ts +1 -12
- package/dist/cli/commands/files.js +11 -308
- package/dist/cli/commands/files.js.map +1 -1
- package/dist/cli/commands/get.js +4 -3
- package/dist/cli/commands/get.js.map +1 -1
- package/dist/cli/commands/health.js +17 -3
- package/dist/cli/commands/health.js.map +1 -1
- package/dist/cli/commands/history-redact.js +23 -18
- package/dist/cli/commands/history-redact.js.map +1 -1
- package/dist/cli/commands/history-repair.js +24 -18
- package/dist/cli/commands/history-repair.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-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 +19 -5
- 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/plan.d.ts +5 -0
- package/dist/cli/commands/plan.js +56 -8
- 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 +19 -8
- package/dist/cli/commands/restore.js.map +1 -1
- package/dist/cli/commands/search.js +5 -8
- package/dist/cli/commands/search.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.d.ts +1 -2
- package/dist/cli/commands/test.js +8 -350
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/commands/update-many.js +4 -3
- package/dist/cli/commands/update-many.js.map +1 -1
- package/dist/cli/commands/update.js +83 -356
- package/dist/cli/commands/update.js.map +1 -1
- package/dist/cli/commands/validate.js +32 -12
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/cli/error-guidance.d.ts +1 -0
- package/dist/cli/error-guidance.js +6 -2
- package/dist/cli/error-guidance.js.map +1 -1
- package/dist/cli/main.d.ts +11 -0
- package/dist/cli/main.js +76 -28
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/register-list-query.d.ts +4 -1
- package/dist/cli/register-list-query.js +242 -203
- package/dist/cli/register-list-query.js.map +1 -1
- package/dist/cli/register-mutation.js +73 -11
- package/dist/cli/register-mutation.js.map +1 -1
- package/dist/cli/register-operations.js +3 -3
- package/dist/cli/register-operations.js.map +1 -1
- package/dist/cli/register-setup.js +12 -7
- package/dist/cli/register-setup.js.map +1 -1
- package/dist/cli/registration-helpers.js +3 -2
- package/dist/cli/registration-helpers.js.map +1 -1
- package/dist/cli.js +4 -3
- 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 -0
- package/dist/core/extensions/index.js +11 -2
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +4 -22
- package/dist/core/extensions/loader.js +22 -1139
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/history/drift-scan.d.ts +11 -0
- package/dist/core/history/drift-scan.js +114 -32
- package/dist/core/history/drift-scan.js.map +1 -1
- 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.js +4 -3
- package/dist/core/history/replay.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/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/schema/runtime-schema.js +8 -38
- package/dist/core/schema/runtime-schema.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/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/levenshtein.js +23 -7
- package/dist/core/shared/levenshtein.js.map +1 -1
- 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/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.js +8 -73
- package/dist/core/store/item-store.js.map +1 -1
- package/dist/mcp/server.js +76 -28
- 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 +11 -33
- package/dist/sdk/cli-contracts.js +30 -1356
- 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 +2 -0
- package/dist/sdk/runtime.js +4 -2
- package/dist/sdk/runtime.js.map +1 -1
- package/docs/AGENT_GUIDE.md +6 -10
- package/docs/CLAUDE_CODE_PLUGIN.md +5 -28
- package/docs/CODEX_PLUGIN.md +5 -5
- package/docs/COMMANDS.md +19 -3
- package/docs/CONFIGURATION.md +15 -0
- package/docs/EXTENSIONS.md +4 -63
- package/docs/RELEASING.md +4 -4
- package/marketplace.json +7 -3
- package/package.json +9 -6
- 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/extensions/calendar/index.js +47 -2
- package/packages/pm-calendar/extensions/calendar/index.ts +52 -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/extensions/search-advanced/index.js +1 -1
- package/packages/pm-search-advanced/extensions/search-advanced/runtime.js +4 -37
- package/packages/pm-search-advanced/extensions/search-advanced/runtime.ts +6 -37
- 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
|
@@ -0,0 +1,159 @@
|
|
|
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]="05fd9473-dd6f-5618-89e3-8746ce68e4e0")}catch(e){}}();
|
|
3
|
+
import { KNOWN_EXTENSION_CAPABILITIES, EXTENSION_CAPABILITY_CONTRACT_VERSION, EXTENSION_CAPABILITY_LEGACY_ALIASES, } from "./extension-types.js";
|
|
4
|
+
export function normalizeNames(values) {
|
|
5
|
+
return [...new Set(values.map((value) => value.trim()).filter((value) => value.length > 0))].sort((a, b) => a.localeCompare(b));
|
|
6
|
+
}
|
|
7
|
+
export function isKnownExtensionCapability(value) {
|
|
8
|
+
return KNOWN_EXTENSION_CAPABILITIES.includes(value);
|
|
9
|
+
}
|
|
10
|
+
export function collectUnknownExtensionCapabilities(capabilities) {
|
|
11
|
+
return capabilities.filter((capability) => !isKnownExtensionCapability(capability));
|
|
12
|
+
}
|
|
13
|
+
export function resolveLegacyExtensionCapabilityAlias(capability) {
|
|
14
|
+
const normalized = capability.trim().toLowerCase();
|
|
15
|
+
if (normalized.length === 0) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return EXTENSION_CAPABILITY_LEGACY_ALIASES[normalized] ?? null;
|
|
19
|
+
}
|
|
20
|
+
export function normalizeManifestCapabilities(rawCapabilities) {
|
|
21
|
+
const normalizedCapabilities = normalizeNames([...rawCapabilities].map((value) => value.toLowerCase()));
|
|
22
|
+
const remappedCapabilities = [];
|
|
23
|
+
const legacyAliases = [];
|
|
24
|
+
for (const capability of normalizedCapabilities) {
|
|
25
|
+
const legacyAliasTarget = resolveLegacyExtensionCapabilityAlias(capability);
|
|
26
|
+
if (legacyAliasTarget) {
|
|
27
|
+
remappedCapabilities.push(legacyAliasTarget);
|
|
28
|
+
legacyAliases.push({
|
|
29
|
+
alias: capability,
|
|
30
|
+
target: legacyAliasTarget,
|
|
31
|
+
});
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
remappedCapabilities.push(capability);
|
|
35
|
+
}
|
|
36
|
+
const dedupedLegacyAliases = [...new Map(legacyAliases.map((entry) => [`${entry.alias}>${entry.target}`, entry])).values()].sort((left, right) => left.alias.localeCompare(right.alias));
|
|
37
|
+
return {
|
|
38
|
+
capabilities: normalizeNames(remappedCapabilities),
|
|
39
|
+
legacy_aliases: dedupedLegacyAliases,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function levenshteinDistance(left, right) {
|
|
43
|
+
if (left === right) {
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
if (left.length === 0) {
|
|
47
|
+
return right.length;
|
|
48
|
+
}
|
|
49
|
+
if (right.length === 0) {
|
|
50
|
+
return left.length;
|
|
51
|
+
}
|
|
52
|
+
const previous = new Array(right.length + 1);
|
|
53
|
+
const current = new Array(right.length + 1);
|
|
54
|
+
for (let j = 0; j <= right.length; j += 1) {
|
|
55
|
+
previous[j] = j;
|
|
56
|
+
}
|
|
57
|
+
for (let i = 1; i <= left.length; i += 1) {
|
|
58
|
+
current[0] = i;
|
|
59
|
+
for (let j = 1; j <= right.length; j += 1) {
|
|
60
|
+
const substitutionCost = left[i - 1] === right[j - 1] ? 0 : 1;
|
|
61
|
+
current[j] = Math.min(previous[j] + 1, current[j - 1] + 1, previous[j - 1] + substitutionCost);
|
|
62
|
+
}
|
|
63
|
+
for (let j = 0; j <= right.length; j += 1) {
|
|
64
|
+
previous[j] = current[j];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return previous[right.length] ?? left.length;
|
|
68
|
+
}
|
|
69
|
+
export function suggestKnownExtensionCapability(capability) {
|
|
70
|
+
const normalized = capability.trim().toLowerCase();
|
|
71
|
+
if (normalized.length === 0) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
const legacyAlias = resolveLegacyExtensionCapabilityAlias(normalized);
|
|
75
|
+
if (legacyAlias) {
|
|
76
|
+
return legacyAlias;
|
|
77
|
+
}
|
|
78
|
+
let bestMatch = null;
|
|
79
|
+
let bestDistance = Number.POSITIVE_INFINITY;
|
|
80
|
+
for (const candidate of KNOWN_EXTENSION_CAPABILITIES) {
|
|
81
|
+
const distance = levenshteinDistance(normalized, candidate);
|
|
82
|
+
if (distance < bestDistance) {
|
|
83
|
+
bestDistance = distance;
|
|
84
|
+
bestMatch = candidate;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const maxDistance = Math.max(1, Math.floor(normalized.length * 0.34));
|
|
88
|
+
return bestMatch !== null && bestDistance <= maxDistance ? bestMatch : null;
|
|
89
|
+
}
|
|
90
|
+
export function formatUnknownExtensionCapabilityWarning(layer, name, capability) {
|
|
91
|
+
const allowed = KNOWN_EXTENSION_CAPABILITIES.join(",");
|
|
92
|
+
const suggested = suggestKnownExtensionCapability(capability) ?? "none";
|
|
93
|
+
return `extension_capability_unknown:${layer}:${name}:${capability}:allowed=${allowed}:suggested=${suggested}`;
|
|
94
|
+
}
|
|
95
|
+
export function formatLegacyExtensionCapabilityAliasWarning(layer, name, aliases) {
|
|
96
|
+
const aliasesToken = aliases.map((entry) => `${entry.alias}>${entry.target}`).join(",");
|
|
97
|
+
return `extension_capability_legacy_alias:${layer}:${name}:aliases=${aliasesToken}`;
|
|
98
|
+
}
|
|
99
|
+
export function parseUnknownExtensionCapabilityWarning(warning) {
|
|
100
|
+
const match = /^extension_capability_unknown:(global|project):([^:]+):([^:]+):allowed=([^:]+):suggested=([^:]+)$/.exec(warning.trim());
|
|
101
|
+
if (!match) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const [, layerRaw, name, capability, allowedRaw, suggestedRaw] = match;
|
|
105
|
+
const layer = layerRaw;
|
|
106
|
+
const allowed_capabilities = allowedRaw
|
|
107
|
+
.split(",")
|
|
108
|
+
.map((value) => value.trim())
|
|
109
|
+
.filter((value) => value.length > 0);
|
|
110
|
+
const legacyAlias = resolveLegacyExtensionCapabilityAlias(capability);
|
|
111
|
+
const suggestedFromWarning = suggestedRaw === "none" ? undefined : suggestedRaw;
|
|
112
|
+
const suggested_capability = suggestedFromWarning ?? legacyAlias ?? undefined;
|
|
113
|
+
const suggestion_source = suggested_capability
|
|
114
|
+
? legacyAlias === suggested_capability
|
|
115
|
+
? "legacy_alias"
|
|
116
|
+
: "nearest_match"
|
|
117
|
+
: undefined;
|
|
118
|
+
return {
|
|
119
|
+
layer,
|
|
120
|
+
name,
|
|
121
|
+
capability,
|
|
122
|
+
allowed_capabilities,
|
|
123
|
+
capability_contract_version: EXTENSION_CAPABILITY_CONTRACT_VERSION,
|
|
124
|
+
suggested_capability,
|
|
125
|
+
suggestion_source,
|
|
126
|
+
legacy_alias_target: legacyAlias ?? undefined,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export function parseLegacyExtensionCapabilityAliasWarning(warning) {
|
|
130
|
+
const match = /^extension_capability_legacy_alias:(global|project):([^:]+):aliases=(.+)$/.exec(warning.trim());
|
|
131
|
+
if (!match) {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
const [, layerRaw, name, aliasesRaw] = match;
|
|
135
|
+
const layer = layerRaw;
|
|
136
|
+
const allowedCapabilities = [...KNOWN_EXTENSION_CAPABILITIES];
|
|
137
|
+
const parsed = [];
|
|
138
|
+
for (const token of aliasesRaw.split(",")) {
|
|
139
|
+
const [rawAlias, rawTarget] = token.split(">");
|
|
140
|
+
const alias = rawAlias?.trim();
|
|
141
|
+
const target = rawTarget?.trim().toLowerCase();
|
|
142
|
+
if (!alias || !target || !isKnownExtensionCapability(target)) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
parsed.push({
|
|
146
|
+
layer,
|
|
147
|
+
name,
|
|
148
|
+
capability: alias,
|
|
149
|
+
allowed_capabilities: allowedCapabilities,
|
|
150
|
+
capability_contract_version: EXTENSION_CAPABILITY_CONTRACT_VERSION,
|
|
151
|
+
suggested_capability: target,
|
|
152
|
+
suggestion_source: "legacy_alias",
|
|
153
|
+
legacy_alias_target: target,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return parsed;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=extension-capability-aliases.js.map
|
|
159
|
+
//# debugId=05fd9473-dd6f-5618-89e3-8746ce68e4e0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-capability-aliases.js","sources":["core/extensions/extension-capability-aliases.ts"],"sourceRoot":"/","sourcesContent":["import {\n KNOWN_EXTENSION_CAPABILITIES,\n EXTENSION_CAPABILITY_CONTRACT_VERSION,\n EXTENSION_CAPABILITY_LEGACY_ALIASES,\n type ExtensionCapability,\n type ExtensionLayer,\n type LegacyExtensionCapabilityAliasMapping,\n type UnknownExtensionCapabilityWarningDetails,\n} from \"./extension-types.js\";\n\nexport function normalizeNames(values: string[]): string[] {\n return [...new Set(values.map((value) => value.trim()).filter((value) => value.length > 0))].sort((a, b) =>\n a.localeCompare(b),\n );\n}\n\nexport function isKnownExtensionCapability(value: string): value is ExtensionCapability {\n return (KNOWN_EXTENSION_CAPABILITIES as readonly string[]).includes(value);\n}\n\nexport function collectUnknownExtensionCapabilities(capabilities: readonly string[]): string[] {\n return capabilities.filter((capability) => !isKnownExtensionCapability(capability));\n}\n\nexport function resolveLegacyExtensionCapabilityAlias(capability: string): ExtensionCapability | null {\n const normalized = capability.trim().toLowerCase();\n if (normalized.length === 0) {\n return null;\n }\n return EXTENSION_CAPABILITY_LEGACY_ALIASES[normalized] ?? null;\n}\n\nexport function normalizeManifestCapabilities(rawCapabilities: readonly string[]): {\n capabilities: string[];\n legacy_aliases: LegacyExtensionCapabilityAliasMapping[];\n} {\n const normalizedCapabilities = normalizeNames([...rawCapabilities].map((value) => value.toLowerCase()));\n const remappedCapabilities: string[] = [];\n const legacyAliases: LegacyExtensionCapabilityAliasMapping[] = [];\n for (const capability of normalizedCapabilities) {\n const legacyAliasTarget = resolveLegacyExtensionCapabilityAlias(capability);\n if (legacyAliasTarget) {\n remappedCapabilities.push(legacyAliasTarget);\n legacyAliases.push({\n alias: capability,\n target: legacyAliasTarget,\n });\n continue;\n }\n remappedCapabilities.push(capability);\n }\n const dedupedLegacyAliases = [...new Map(legacyAliases.map((entry) => [`${entry.alias}>${entry.target}`, entry])).values()].sort(\n (left, right) => left.alias.localeCompare(right.alias),\n );\n return {\n capabilities: normalizeNames(remappedCapabilities),\n legacy_aliases: dedupedLegacyAliases,\n };\n}\n\nfunction levenshteinDistance(left: string, right: string): number {\n if (left === right) {\n return 0;\n }\n if (left.length === 0) {\n return right.length;\n }\n if (right.length === 0) {\n return left.length;\n }\n const previous = new Array<number>(right.length + 1);\n const current = new Array<number>(right.length + 1);\n for (let j = 0; j <= right.length; j += 1) {\n previous[j] = j;\n }\n for (let i = 1; i <= left.length; i += 1) {\n current[0] = i;\n for (let j = 1; j <= right.length; j += 1) {\n const substitutionCost = left[i - 1] === right[j - 1] ? 0 : 1;\n current[j] = Math.min(\n previous[j] + 1,\n current[j - 1] + 1,\n previous[j - 1] + substitutionCost,\n );\n }\n for (let j = 0; j <= right.length; j += 1) {\n previous[j] = current[j];\n }\n }\n return previous[right.length] ?? left.length;\n}\n\nexport function suggestKnownExtensionCapability(capability: string): string | null {\n const normalized = capability.trim().toLowerCase();\n if (normalized.length === 0) {\n return null;\n }\n const legacyAlias = resolveLegacyExtensionCapabilityAlias(normalized);\n if (legacyAlias) {\n return legacyAlias;\n }\n let bestMatch: string | null = null;\n let bestDistance = Number.POSITIVE_INFINITY;\n for (const candidate of KNOWN_EXTENSION_CAPABILITIES) {\n const distance = levenshteinDistance(normalized, candidate);\n if (distance < bestDistance) {\n bestDistance = distance;\n bestMatch = candidate;\n }\n }\n const maxDistance = Math.max(1, Math.floor(normalized.length * 0.34));\n return bestMatch !== null && bestDistance <= maxDistance ? bestMatch : null;\n}\n\nexport function formatUnknownExtensionCapabilityWarning(layer: ExtensionLayer, name: string, capability: string): string {\n const allowed = KNOWN_EXTENSION_CAPABILITIES.join(\",\");\n const suggested = suggestKnownExtensionCapability(capability) ?? \"none\";\n return `extension_capability_unknown:${layer}:${name}:${capability}:allowed=${allowed}:suggested=${suggested}`;\n}\n\nexport function formatLegacyExtensionCapabilityAliasWarning(\n layer: ExtensionLayer,\n name: string,\n aliases: readonly LegacyExtensionCapabilityAliasMapping[],\n): string {\n const aliasesToken = aliases.map((entry) => `${entry.alias}>${entry.target}`).join(\",\");\n return `extension_capability_legacy_alias:${layer}:${name}:aliases=${aliasesToken}`;\n}\n\n\nexport function parseUnknownExtensionCapabilityWarning(\n warning: string,\n): UnknownExtensionCapabilityWarningDetails | null {\n const match = /^extension_capability_unknown:(global|project):([^:]+):([^:]+):allowed=([^:]+):suggested=([^:]+)$/.exec(\n warning.trim(),\n );\n if (!match) {\n return null;\n }\n const [, layerRaw, name, capability, allowedRaw, suggestedRaw] = match;\n const layer = layerRaw as ExtensionLayer;\n const allowed_capabilities = allowedRaw\n .split(\",\")\n .map((value) => value.trim())\n .filter((value) => value.length > 0);\n const legacyAlias = resolveLegacyExtensionCapabilityAlias(capability);\n const suggestedFromWarning = suggestedRaw === \"none\" ? undefined : suggestedRaw;\n const suggested_capability = suggestedFromWarning ?? legacyAlias ?? undefined;\n const suggestion_source = suggested_capability\n ? legacyAlias === suggested_capability\n ? \"legacy_alias\"\n : \"nearest_match\"\n : undefined;\n return {\n layer,\n name,\n capability,\n allowed_capabilities,\n capability_contract_version: EXTENSION_CAPABILITY_CONTRACT_VERSION,\n suggested_capability,\n suggestion_source,\n legacy_alias_target: legacyAlias ?? undefined,\n };\n}\n\nexport function parseLegacyExtensionCapabilityAliasWarning(warning: string): UnknownExtensionCapabilityWarningDetails[] {\n const match = /^extension_capability_legacy_alias:(global|project):([^:]+):aliases=(.+)$/.exec(warning.trim());\n if (!match) {\n return [];\n }\n const [, layerRaw, name, aliasesRaw] = match;\n const layer = layerRaw as ExtensionLayer;\n const allowedCapabilities = [...KNOWN_EXTENSION_CAPABILITIES];\n const parsed: UnknownExtensionCapabilityWarningDetails[] = [];\n for (const token of aliasesRaw.split(\",\")) {\n const [rawAlias, rawTarget] = token.split(\">\");\n const alias = rawAlias?.trim();\n const target = rawTarget?.trim().toLowerCase();\n if (!alias || !target || !isKnownExtensionCapability(target)) {\n continue;\n }\n parsed.push({\n layer,\n name,\n capability: alias,\n allowed_capabilities: allowedCapabilities,\n capability_contract_version: EXTENSION_CAPABILITY_CONTRACT_VERSION,\n suggested_capability: target,\n suggestion_source: \"legacy_alias\",\n legacy_alias_target: target,\n });\n }\n return parsed;\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EACL,4BAA4B,EAC5B,qCAAqC,EACrC,mCAAmC,GAKpC,MAAM,sBAAsB,CAAC;AAE9B,MAAM,UAAU,cAAc,CAAC,MAAgB;IAC7C,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,C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,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC;IAC7C,MAAM,KAAK,GAAG,QAA0B,CAAC;IACzC,MAAM,mBAAmB,GAAG,CAAC,GAAG,4BAA4B,CAAC,CAAC;IAC9D,MAAM,MAAM,GAA+C,EAAE,CAAC;IAC9D,KAAK,MAAM,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1C,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/C,MAAM,KAAK,GAAG,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC/C,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7D,SAAS;QACX,CAAC;QACD,MAAM,CAAC,IAAI,CAAC;YACV,KAAK;YACL,IAAI;YACJ,UAAU,EAAE,KAAK;YACjB,oBAAoB,EAAE,mBAAmB;YACzC,2BAA2B,EAAE,qCAAqC;YAClE,oBAAoB,EAAE,MAAM;YAC5B,iBAAiB,EAAE,cAAc;YACjC,mBAAmB,EAAE,MAAM;SAC5B,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","debugId":"05fd9473-dd6f-5618-89e3-8746ce68e4e0"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ExtensionHookRegistry, BeforeCommandHookContext, AfterCommandHookContext, OnWriteHookContext, OnReadHookContext, OnIndexHookContext, ExtensionCommandRegistry, CommandHandlerContext, CommandHandlerResult, ExtensionParserRegistry, ParserOverrideContext, ParserOverrideResult, ExtensionPreflightRegistry, PreflightOverrideContext, PreflightOverrideResult, ExtensionServiceRegistry, ServiceOverrideContext, ServiceOverrideResult, CommandOverrideContext, CommandOverrideResult, ExtensionRendererRegistry, RendererOverrideContext, RendererOverrideResult } from "./extension-types.js";
|
|
2
|
+
export declare function runBeforeCommandHooks(hooks: ExtensionHookRegistry, context: BeforeCommandHookContext): Promise<string[]>;
|
|
3
|
+
export declare function runAfterCommandHooks(hooks: ExtensionHookRegistry, context: AfterCommandHookContext): Promise<string[]>;
|
|
4
|
+
export declare function runOnWriteHooks(hooks: ExtensionHookRegistry, context: OnWriteHookContext): Promise<string[]>;
|
|
5
|
+
export declare function runOnReadHooks(hooks: ExtensionHookRegistry, context: OnReadHookContext): Promise<string[]>;
|
|
6
|
+
export declare function runOnIndexHooks(hooks: ExtensionHookRegistry, context: OnIndexHookContext): Promise<string[]>;
|
|
7
|
+
export declare function runCommandHandler(commands: ExtensionCommandRegistry, context: CommandHandlerContext): Promise<CommandHandlerResult>;
|
|
8
|
+
export declare function runParserOverride(parsers: ExtensionParserRegistry, context: ParserOverrideContext): Promise<ParserOverrideResult>;
|
|
9
|
+
export declare function runPreflightOverride(preflight: ExtensionPreflightRegistry, context: PreflightOverrideContext): Promise<PreflightOverrideResult>;
|
|
10
|
+
export declare function runServiceOverrideSync(services: ExtensionServiceRegistry, context: ServiceOverrideContext): ServiceOverrideResult;
|
|
11
|
+
export declare function runServiceOverride(services: ExtensionServiceRegistry, context: ServiceOverrideContext): Promise<ServiceOverrideResult>;
|
|
12
|
+
export declare function runCommandOverride(commands: ExtensionCommandRegistry, context: CommandOverrideContext): CommandOverrideResult;
|
|
13
|
+
export declare function runRendererOverride(renderers: ExtensionRendererRegistry, context: RendererOverrideContext): RendererOverrideResult;
|
|
@@ -0,0 +1,414 @@
|
|
|
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]="015da859-473a-5b98-b534-a4edbfae0dd7")}catch(e){}}();
|
|
3
|
+
import { cloneCommandOptionsSnapshot, cloneContextSnapshot, cloneGlobalOptionsSnapshot, normalizeCommandName, } from "./extension-runtime-helpers.js";
|
|
4
|
+
async function executeRegisteredHooks(entries, hookName, context) {
|
|
5
|
+
const warnings = [];
|
|
6
|
+
for (const entry of entries) {
|
|
7
|
+
try {
|
|
8
|
+
await entry.run(cloneContextSnapshot(context));
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
warnings.push(`extension_hook_failed:${entry.layer}:${entry.name}:${hookName}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return warnings;
|
|
15
|
+
}
|
|
16
|
+
export async function runBeforeCommandHooks(hooks, context) {
|
|
17
|
+
return executeRegisteredHooks(hooks.beforeCommand, "beforeCommand", context);
|
|
18
|
+
}
|
|
19
|
+
export async function runAfterCommandHooks(hooks, context) {
|
|
20
|
+
return executeRegisteredHooks(hooks.afterCommand, "afterCommand", context);
|
|
21
|
+
}
|
|
22
|
+
export async function runOnWriteHooks(hooks, context) {
|
|
23
|
+
return executeRegisteredHooks(hooks.onWrite, "onWrite", context);
|
|
24
|
+
}
|
|
25
|
+
export async function runOnReadHooks(hooks, context) {
|
|
26
|
+
return executeRegisteredHooks(hooks.onRead, "onRead", context);
|
|
27
|
+
}
|
|
28
|
+
export async function runOnIndexHooks(hooks, context) {
|
|
29
|
+
return executeRegisteredHooks(hooks.onIndex, "onIndex", context);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Normalize an extension handler failure into a single-line, length-bounded
|
|
33
|
+
* message so the real cause can be surfaced to the user/CI without leaking
|
|
34
|
+
* multi-line stack noise or unbounded payloads.
|
|
35
|
+
*/
|
|
36
|
+
function describeHandlerError(error) {
|
|
37
|
+
let raw = "";
|
|
38
|
+
if (error instanceof Error && typeof error.message === "string") {
|
|
39
|
+
raw = error.message;
|
|
40
|
+
}
|
|
41
|
+
else if (typeof error === "string") {
|
|
42
|
+
raw = error;
|
|
43
|
+
}
|
|
44
|
+
else if (typeof error === "object" &&
|
|
45
|
+
error !== null &&
|
|
46
|
+
typeof error.message === "string") {
|
|
47
|
+
// Extensions may throw plain/serialized objects that carry a message but do
|
|
48
|
+
// not inherit from the base Error class.
|
|
49
|
+
raw = error.message;
|
|
50
|
+
}
|
|
51
|
+
const normalized = raw.replace(/\s+/gu, " ").trim();
|
|
52
|
+
if (normalized.length === 0) {
|
|
53
|
+
return "";
|
|
54
|
+
}
|
|
55
|
+
const maxLength = 300;
|
|
56
|
+
return normalized.length > maxLength ? `${normalized.slice(0, maxLength - 1)}…` : normalized;
|
|
57
|
+
}
|
|
58
|
+
export async function runCommandHandler(commands, context) {
|
|
59
|
+
const command = normalizeCommandName(context.command);
|
|
60
|
+
if (command.length === 0) {
|
|
61
|
+
return {
|
|
62
|
+
handled: false,
|
|
63
|
+
result: null,
|
|
64
|
+
warnings: [],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const matched = [...commands.handlers].reverse().find((entry) => entry.command === command);
|
|
68
|
+
if (!matched) {
|
|
69
|
+
return {
|
|
70
|
+
handled: false,
|
|
71
|
+
result: null,
|
|
72
|
+
warnings: [],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
const result = await matched.run({
|
|
77
|
+
command,
|
|
78
|
+
args: cloneContextSnapshot(context.args),
|
|
79
|
+
options: cloneContextSnapshot(context.options),
|
|
80
|
+
global: cloneContextSnapshot(context.global),
|
|
81
|
+
pm_root: context.pm_root,
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
handled: true,
|
|
85
|
+
result,
|
|
86
|
+
warnings: [],
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const exitCode = typeof error === "object" && error !== null && "exitCode" in error
|
|
91
|
+
? error.exitCode
|
|
92
|
+
: undefined;
|
|
93
|
+
if (typeof exitCode === "number" && Number.isFinite(exitCode)) {
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
handled: false,
|
|
98
|
+
result: null,
|
|
99
|
+
warnings: [`extension_command_handler_failed:${matched.layer}:${matched.name}:${matched.command}`],
|
|
100
|
+
errorMessage: describeHandlerError(error),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export async function runParserOverride(parsers, context) {
|
|
105
|
+
const command = normalizeCommandName(context.command);
|
|
106
|
+
if (command.length === 0) {
|
|
107
|
+
return {
|
|
108
|
+
overridden: false,
|
|
109
|
+
context: {
|
|
110
|
+
command,
|
|
111
|
+
args: cloneContextSnapshot(context.args),
|
|
112
|
+
options: cloneCommandOptionsSnapshot(context.options),
|
|
113
|
+
global: cloneGlobalOptionsSnapshot(context.global),
|
|
114
|
+
pm_root: context.pm_root,
|
|
115
|
+
},
|
|
116
|
+
warnings: [],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
const matched = [...parsers.overrides].reverse().find((entry) => entry.command === command);
|
|
120
|
+
if (!matched) {
|
|
121
|
+
return {
|
|
122
|
+
overridden: false,
|
|
123
|
+
context: {
|
|
124
|
+
command,
|
|
125
|
+
args: cloneContextSnapshot(context.args),
|
|
126
|
+
options: cloneCommandOptionsSnapshot(context.options),
|
|
127
|
+
global: cloneGlobalOptionsSnapshot(context.global),
|
|
128
|
+
pm_root: context.pm_root,
|
|
129
|
+
},
|
|
130
|
+
warnings: [],
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
const delta = (await Promise.resolve(matched.run({
|
|
135
|
+
command,
|
|
136
|
+
args: cloneContextSnapshot(context.args),
|
|
137
|
+
options: cloneCommandOptionsSnapshot(context.options),
|
|
138
|
+
global: cloneGlobalOptionsSnapshot(context.global),
|
|
139
|
+
pm_root: context.pm_root,
|
|
140
|
+
}))) ?? {};
|
|
141
|
+
const nextArgs = Array.isArray(delta.args) ? cloneContextSnapshot(delta.args) : cloneContextSnapshot(context.args);
|
|
142
|
+
const nextOptions = delta.options ? cloneCommandOptionsSnapshot(delta.options) : cloneCommandOptionsSnapshot(context.options);
|
|
143
|
+
const nextGlobal = delta.global ? cloneGlobalOptionsSnapshot(delta.global) : cloneGlobalOptionsSnapshot(context.global);
|
|
144
|
+
return {
|
|
145
|
+
overridden: true,
|
|
146
|
+
context: {
|
|
147
|
+
command,
|
|
148
|
+
args: nextArgs,
|
|
149
|
+
options: nextOptions,
|
|
150
|
+
global: nextGlobal,
|
|
151
|
+
pm_root: context.pm_root,
|
|
152
|
+
},
|
|
153
|
+
warnings: [],
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
return {
|
|
158
|
+
overridden: false,
|
|
159
|
+
context: {
|
|
160
|
+
command,
|
|
161
|
+
args: cloneContextSnapshot(context.args),
|
|
162
|
+
options: cloneCommandOptionsSnapshot(context.options),
|
|
163
|
+
global: cloneGlobalOptionsSnapshot(context.global),
|
|
164
|
+
pm_root: context.pm_root,
|
|
165
|
+
},
|
|
166
|
+
warnings: [`extension_parser_override_failed:${matched.layer}:${matched.name}:${matched.command}`],
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
export async function runPreflightOverride(preflight, context) {
|
|
171
|
+
const matched = [...preflight.overrides].reverse()[0];
|
|
172
|
+
const baseContext = {
|
|
173
|
+
command: normalizeCommandName(context.command),
|
|
174
|
+
args: cloneContextSnapshot(context.args),
|
|
175
|
+
options: cloneCommandOptionsSnapshot(context.options),
|
|
176
|
+
global: cloneGlobalOptionsSnapshot(context.global),
|
|
177
|
+
pm_root: context.pm_root,
|
|
178
|
+
};
|
|
179
|
+
const baseDecision = cloneContextSnapshot(context.decision);
|
|
180
|
+
if (!matched) {
|
|
181
|
+
return {
|
|
182
|
+
overridden: false,
|
|
183
|
+
context: baseContext,
|
|
184
|
+
decision: baseDecision,
|
|
185
|
+
warnings: [],
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
const delta = (await Promise.resolve(matched.run({
|
|
190
|
+
command: baseContext.command,
|
|
191
|
+
args: cloneContextSnapshot(baseContext.args),
|
|
192
|
+
options: cloneCommandOptionsSnapshot(baseContext.options),
|
|
193
|
+
global: cloneGlobalOptionsSnapshot(baseContext.global),
|
|
194
|
+
pm_root: baseContext.pm_root,
|
|
195
|
+
decision: cloneContextSnapshot(baseDecision),
|
|
196
|
+
}))) ?? {};
|
|
197
|
+
const nextContext = {
|
|
198
|
+
command: baseContext.command,
|
|
199
|
+
args: Array.isArray(delta.args) ? cloneContextSnapshot(delta.args) : baseContext.args,
|
|
200
|
+
options: delta.options ? cloneCommandOptionsSnapshot(delta.options) : baseContext.options,
|
|
201
|
+
global: delta.global ? cloneGlobalOptionsSnapshot(delta.global) : baseContext.global,
|
|
202
|
+
pm_root: baseContext.pm_root,
|
|
203
|
+
};
|
|
204
|
+
const nextDecision = {
|
|
205
|
+
enforce_item_format_gate: typeof delta.enforce_item_format_gate === "boolean"
|
|
206
|
+
? delta.enforce_item_format_gate
|
|
207
|
+
: baseDecision.enforce_item_format_gate,
|
|
208
|
+
run_preflight_item_format_sync: typeof delta.run_preflight_item_format_sync === "boolean"
|
|
209
|
+
? delta.run_preflight_item_format_sync
|
|
210
|
+
: baseDecision.run_preflight_item_format_sync,
|
|
211
|
+
run_extension_migrations: typeof delta.run_extension_migrations === "boolean"
|
|
212
|
+
? delta.run_extension_migrations
|
|
213
|
+
: baseDecision.run_extension_migrations,
|
|
214
|
+
enforce_mandatory_migration_gate: typeof delta.enforce_mandatory_migration_gate === "boolean"
|
|
215
|
+
? delta.enforce_mandatory_migration_gate
|
|
216
|
+
: baseDecision.enforce_mandatory_migration_gate,
|
|
217
|
+
};
|
|
218
|
+
return {
|
|
219
|
+
overridden: true,
|
|
220
|
+
context: nextContext,
|
|
221
|
+
decision: nextDecision,
|
|
222
|
+
warnings: [],
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
return {
|
|
227
|
+
overridden: false,
|
|
228
|
+
context: baseContext,
|
|
229
|
+
decision: baseDecision,
|
|
230
|
+
warnings: [`extension_preflight_override_failed:${matched.layer}:${matched.name}`],
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function resolveDefaultServiceResult(context) {
|
|
235
|
+
return {
|
|
236
|
+
handled: false,
|
|
237
|
+
result: context.payload,
|
|
238
|
+
warnings: [],
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
export function runServiceOverrideSync(services, context) {
|
|
242
|
+
const matches = [...services.overrides].reverse().filter((entry) => entry.service === context.service);
|
|
243
|
+
if (matches.length === 0) {
|
|
244
|
+
return resolveDefaultServiceResult(context);
|
|
245
|
+
}
|
|
246
|
+
const warnings = [];
|
|
247
|
+
for (const matched of matches) {
|
|
248
|
+
try {
|
|
249
|
+
const serviceContext = {
|
|
250
|
+
service: context.service,
|
|
251
|
+
command: context.command ? normalizeCommandName(context.command) : undefined,
|
|
252
|
+
args: context.args ? cloneContextSnapshot(context.args) : undefined,
|
|
253
|
+
options: context.options ? cloneCommandOptionsSnapshot(context.options) : undefined,
|
|
254
|
+
global: context.global ? cloneGlobalOptionsSnapshot(context.global) : undefined,
|
|
255
|
+
pm_root: context.pm_root,
|
|
256
|
+
payload: cloneContextSnapshot(context.payload),
|
|
257
|
+
};
|
|
258
|
+
const result = matched.run(serviceContext);
|
|
259
|
+
if (result instanceof Promise) {
|
|
260
|
+
warnings.push(`extension_service_override_async_unsupported:${matched.layer}:${matched.name}:${matched.service}`);
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (context.service === "output_format" && (result === null || result === undefined || result === serviceContext.payload)) {
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
return {
|
|
267
|
+
handled: true,
|
|
268
|
+
result,
|
|
269
|
+
warnings,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
catch {
|
|
273
|
+
warnings.push(`extension_service_override_failed:${matched.layer}:${matched.name}:${matched.service}`);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
handled: false,
|
|
278
|
+
result: context.payload,
|
|
279
|
+
warnings,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
export async function runServiceOverride(services, context) {
|
|
283
|
+
const matches = [...services.overrides].reverse().filter((entry) => entry.service === context.service);
|
|
284
|
+
if (matches.length === 0) {
|
|
285
|
+
return resolveDefaultServiceResult(context);
|
|
286
|
+
}
|
|
287
|
+
const warnings = [];
|
|
288
|
+
for (const matched of matches) {
|
|
289
|
+
try {
|
|
290
|
+
const serviceContext = {
|
|
291
|
+
service: context.service,
|
|
292
|
+
command: context.command ? normalizeCommandName(context.command) : undefined,
|
|
293
|
+
args: context.args ? cloneContextSnapshot(context.args) : undefined,
|
|
294
|
+
options: context.options ? cloneCommandOptionsSnapshot(context.options) : undefined,
|
|
295
|
+
global: context.global ? cloneGlobalOptionsSnapshot(context.global) : undefined,
|
|
296
|
+
pm_root: context.pm_root,
|
|
297
|
+
payload: cloneContextSnapshot(context.payload),
|
|
298
|
+
};
|
|
299
|
+
const result = await Promise.resolve(matched.run(serviceContext));
|
|
300
|
+
if (context.service === "output_format" && (result === null || result === undefined || result === serviceContext.payload)) {
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
return {
|
|
304
|
+
handled: true,
|
|
305
|
+
result,
|
|
306
|
+
warnings,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
warnings.push(`extension_service_override_failed:${matched.layer}:${matched.name}:${matched.service}`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return {
|
|
314
|
+
handled: false,
|
|
315
|
+
result: context.payload,
|
|
316
|
+
warnings,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
export function runCommandOverride(commands, context) {
|
|
320
|
+
const command = normalizeCommandName(context.command);
|
|
321
|
+
if (command.length === 0) {
|
|
322
|
+
return {
|
|
323
|
+
overridden: false,
|
|
324
|
+
result: context.result,
|
|
325
|
+
warnings: [],
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
const matched = [...commands.overrides].reverse().find((entry) => entry.command === command);
|
|
329
|
+
if (!matched) {
|
|
330
|
+
return {
|
|
331
|
+
overridden: false,
|
|
332
|
+
result: context.result,
|
|
333
|
+
warnings: [],
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
try {
|
|
337
|
+
const overrideOptions = cloneCommandOptionsSnapshot(context.options);
|
|
338
|
+
const overrideGlobal = cloneGlobalOptionsSnapshot(context.global);
|
|
339
|
+
const overrideResult = matched.run({
|
|
340
|
+
command,
|
|
341
|
+
args: cloneContextSnapshot(context.args),
|
|
342
|
+
options: overrideOptions,
|
|
343
|
+
global: overrideGlobal,
|
|
344
|
+
pm_root: context.pm_root,
|
|
345
|
+
result: cloneContextSnapshot(context.result),
|
|
346
|
+
});
|
|
347
|
+
if (overrideResult instanceof Promise) {
|
|
348
|
+
return {
|
|
349
|
+
overridden: false,
|
|
350
|
+
result: context.result,
|
|
351
|
+
warnings: [`extension_command_override_async_unsupported:${matched.layer}:${matched.name}:${matched.command}`],
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
return {
|
|
355
|
+
overridden: true,
|
|
356
|
+
result: overrideResult,
|
|
357
|
+
warnings: [],
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
catch {
|
|
361
|
+
return {
|
|
362
|
+
overridden: false,
|
|
363
|
+
result: context.result,
|
|
364
|
+
warnings: [`extension_command_override_failed:${matched.layer}:${matched.name}:${matched.command}`],
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
export function runRendererOverride(renderers, context) {
|
|
369
|
+
const matched = [...renderers.overrides].reverse().find((entry) => entry.format === context.format);
|
|
370
|
+
if (!matched) {
|
|
371
|
+
return {
|
|
372
|
+
overridden: false,
|
|
373
|
+
rendered: null,
|
|
374
|
+
warnings: [],
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
try {
|
|
378
|
+
const rendererCommand = typeof context.command === "string" ? normalizeCommandName(context.command) : "";
|
|
379
|
+
const rendererArgs = Array.isArray(context.args) ? cloneContextSnapshot(context.args) : [];
|
|
380
|
+
const rendererOptions = cloneCommandOptionsSnapshot(context.options);
|
|
381
|
+
const rendererGlobal = cloneGlobalOptionsSnapshot(context.global);
|
|
382
|
+
const rendererPmRoot = typeof context.pm_root === "string" ? context.pm_root : "";
|
|
383
|
+
const rendered = matched.run({
|
|
384
|
+
format: context.format,
|
|
385
|
+
command: rendererCommand,
|
|
386
|
+
args: rendererArgs,
|
|
387
|
+
options: rendererOptions,
|
|
388
|
+
global: rendererGlobal,
|
|
389
|
+
pm_root: rendererPmRoot,
|
|
390
|
+
result: cloneContextSnapshot(context.result),
|
|
391
|
+
});
|
|
392
|
+
if (typeof rendered !== "string") {
|
|
393
|
+
return {
|
|
394
|
+
overridden: false,
|
|
395
|
+
rendered: null,
|
|
396
|
+
warnings: [`extension_renderer_invalid_result:${matched.layer}:${matched.name}:${matched.format}`],
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
return {
|
|
400
|
+
overridden: true,
|
|
401
|
+
rendered,
|
|
402
|
+
warnings: [],
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
catch {
|
|
406
|
+
return {
|
|
407
|
+
overridden: false,
|
|
408
|
+
rendered: null,
|
|
409
|
+
warnings: [`extension_renderer_failed:${matched.layer}:${matched.name}:${matched.format}`],
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
//# sourceMappingURL=extension-hook-runtime.js.map
|
|
414
|
+
//# debugId=015da859-473a-5b98-b534-a4edbfae0dd7
|