@lesliechan721/aw 0.1.0-beta.93 → 0.1.0-beta.95
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/dist/authoring/scripts/add-skill.mjs +1 -1
- package/dist/authoring/scripts/init-plugin.mjs +2 -2
- package/dist/authoring/scripts/lib/skill-scaffold.d.mts +1 -1
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +1 -1
- package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
- package/dist/authoring/scripts/validate-plugin.mjs +0 -10
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
- package/dist/scripts/test-plugin-scripts.js +2 -2
- package/dist/scripts/test-plugin-scripts.js.map +1 -1
- package/dist/src/commands/deployment-confirmation.js +13 -0
- package/dist/src/commands/deployment-confirmation.js.map +1 -1
- package/dist/src/commands/offline-cleanup-evidence.d.ts +1 -1
- package/dist/src/commands/offline-cleanup-evidence.js +30 -31
- package/dist/src/commands/offline-cleanup-evidence.js.map +1 -1
- package/dist/src/commands/operation-plan.d.ts +5 -0
- package/dist/src/commands/operation-plan.js +2 -0
- package/dist/src/commands/operation-plan.js.map +1 -1
- package/dist/src/commands/public-lifecycle-result.js +16 -0
- package/dist/src/commands/public-lifecycle-result.js.map +1 -1
- package/dist/src/commands/public-lifecycle.js +3 -1
- package/dist/src/commands/public-lifecycle.js.map +1 -1
- package/dist/src/commands/rebuild-command.d.ts +9 -16
- package/dist/src/commands/rebuild-command.js +149 -92
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +1 -0
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +1 -0
- package/dist/src/commands/rebuild-platform-integration.js +26 -15
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
- package/dist/src/commands/status-v6.js +7 -4
- package/dist/src/commands/status-v6.js.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/platforms/contracts.d.ts +23 -1
- package/dist/src/platforms/discovery.d.ts +2 -0
- package/dist/src/platforms/discovery.js.map +1 -1
- package/dist/src/platforms/inspection-native.d.ts +4 -2
- package/dist/src/platforms/inspection-native.js +228 -24
- package/dist/src/platforms/inspection-native.js.map +1 -1
- package/dist/src/platforms/layout.js +15 -0
- package/dist/src/platforms/layout.js.map +1 -1
- package/dist/src/platforms/lifecycle-native-services.js +68 -2
- package/dist/src/platforms/lifecycle-native-services.js.map +1 -1
- package/dist/src/platforms/lifecycle-native.js +12 -1
- package/dist/src/platforms/lifecycle-native.js.map +1 -1
- package/dist/src/platforms/lifecycle.d.ts +3 -1
- package/dist/src/platforms/lifecycle.js +133 -12
- package/dist/src/platforms/lifecycle.js.map +1 -1
- package/dist/src/platforms/retirement-native.d.ts +6 -0
- package/dist/src/platforms/retirement-native.js +95 -0
- package/dist/src/platforms/retirement-native.js.map +1 -0
- package/dist/src/portable/materializer.js +4 -1
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/recovery/receipt.d.ts +2 -0
- package/dist/src/recovery/receipt.js.map +1 -1
- package/dist/src/recovery/retirement.js +58 -22
- package/dist/src/recovery/retirement.js.map +1 -1
- package/dist/src/recovery/status.js +12 -2
- package/dist/src/recovery/status.js.map +1 -1
- package/dist/src/tui/catalog-generation.d.ts +4 -1
- package/dist/src/tui/catalog-generation.js +34 -0
- package/dist/src/tui/catalog-generation.js.map +1 -1
- package/dist/src/tui/console-app-v4.js +50 -13
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/controller-runtime.js +16 -8
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +2 -1
- package/dist/src/tui/controller.js +14 -5
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/deployment-view.d.ts +1 -0
- package/dist/src/tui/deployment-view.js +21 -3
- package/dist/src/tui/deployment-view.js.map +1 -1
- package/dist/src/tui/entity-cards.js +7 -1
- package/dist/src/tui/entity-cards.js.map +1 -1
- package/dist/src/tui/model.d.ts +6 -1
- package/dist/src/tui/model.js +18 -5
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/tui/scoped-inventory.d.ts +9 -1
- package/dist/src/tui/scoped-inventory.js +16 -1
- package/dist/src/tui/scoped-inventory.js.map +1 -1
- package/dist/src/utils/catalog-source-references.d.ts +37 -1
- package/dist/src/utils/catalog-source-references.js +361 -94
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/codex-config.d.ts +3 -0
- package/dist/src/utils/codex-config.js +7 -0
- package/dist/src/utils/codex-config.js.map +1 -1
- package/dist/src/utils/local-marketplace.d.ts +2 -0
- package/dist/src/utils/local-marketplace.js +12 -0
- package/dist/src/utils/local-marketplace.js.map +1 -1
- package/dist/src/utils/skill-validation.js +0 -5
- package/dist/src/utils/skill-validation.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import crypto from 'node:crypto';
|
|
2
|
-
import {
|
|
2
|
+
import { isCanonicalCodexMarketplaceRegistration } from './codex-shared-native.js';
|
|
3
3
|
import { readIntentReferences } from '../recovery/demand.js';
|
|
4
4
|
import { resolveIntentPath } from '../intent/intent-store.js';
|
|
5
5
|
import path from 'node:path';
|
|
@@ -12,21 +12,132 @@ import { readJsonFileIfExists } from './json.js';
|
|
|
12
12
|
import { getClaudeHome, getCodexHome, canonicalizePathThroughExistingAncestorSync, resolveAwHome, resolveAwHomeCanonical, resolveRepoRootSync, } from './state-paths.js';
|
|
13
13
|
import { OWNED_TEXT_HEADER_PREFIX, SHARED_OWNER_TOKEN_PREFIX, inspectOwnedComponents, parseSharedOwnerToken, parseOwnedTextHeader, readSkillOwnerMarker, SKILL_OWNER_MARKER, } from './ownership.js';
|
|
14
14
|
import { sanitizeCatalogSourceErrorMessage } from './catalog-public-error.js';
|
|
15
|
-
import { readStrictNamespacedMarketplaceRoot } from './local-marketplace.js';
|
|
16
|
-
import { getDeploymentLayout, getInvocationPolicyPhysicalKey, isAntigravityProjectDirectory } from '../platforms/layout.js';
|
|
15
|
+
import { canonicalMarketplaceRegistrationPath, readStrictNamespacedMarketplaceRoot } from './local-marketplace.js';
|
|
16
|
+
import { getDeploymentLayout, getManagedPlatformRoot, getInvocationPolicyPhysicalKey, isAntigravityProjectDirectory } from '../platforms/layout.js';
|
|
17
17
|
import { deploymentPackageComponent } from '../platforms/inspection.js';
|
|
18
|
-
import { getPhysicalKey, identityDigest } from '../platforms/identity.js';
|
|
18
|
+
import { canonicalNamespaceRoot, getPhysicalKey, identityDigest } from '../platforms/identity.js';
|
|
19
19
|
import { offlinePermissionComponents } from '../platforms/permission-ownership.js';
|
|
20
20
|
import { resolvePlatformConfigRoot } from '../platforms/discovery.js';
|
|
21
21
|
import { readPlatformPackageContentDigest } from './platform-empty-state.js';
|
|
22
|
-
export function
|
|
22
|
+
export function legacyCanonicalMarketplaceRegistrationNames(references, sourceId) {
|
|
23
23
|
return [...new Set(references.flatMap((reference) => reference.kind === 'namespacedMarketplace'
|
|
24
24
|
&& reference.sourceId === sourceId
|
|
25
25
|
&& reference.pluginName === undefined
|
|
26
|
+
&& reference.platform === undefined
|
|
27
|
+
&& reference.marketplaceRoot
|
|
26
28
|
&& reference.marketplaceName
|
|
27
29
|
? [reference.marketplaceName]
|
|
28
30
|
: []))];
|
|
29
31
|
}
|
|
32
|
+
function isNativeMarketplaceConsumer(reference) {
|
|
33
|
+
return !reference.disabledNativeActivation && !reference.marketplaceManifestEntry;
|
|
34
|
+
}
|
|
35
|
+
/** Raw host consumers and their canonical inventory copies can describe the
|
|
36
|
+
* same registration. Ignore that duplicate only when its binding is resolved. */
|
|
37
|
+
export function scopedCleanupMarketplaceEvidence(options) {
|
|
38
|
+
const { references, pluginName, platform, scope } = options;
|
|
39
|
+
const registrations = references.filter((reference) => reference.kind === 'namespacedMarketplace'
|
|
40
|
+
&& reference.platform === platform && reference.pluginName === undefined
|
|
41
|
+
&& reference.marketplaceRegistrationPath !== undefined
|
|
42
|
+
&& (reference.scope === undefined || reference.scope === 'user' || reference.scope === scope));
|
|
43
|
+
const consumers = references.filter((reference) => reference.kind === 'namespacedMarketplace'
|
|
44
|
+
&& reference.pluginName === pluginName && reference.platform === platform
|
|
45
|
+
&& reference.scope === scope && reference.marketplaceName);
|
|
46
|
+
const nativeConsumers = consumers.filter(isNativeMarketplaceConsumer);
|
|
47
|
+
const unboundConsumers = nativeConsumers.filter((consumer) => {
|
|
48
|
+
if (consumer.sourceId !== undefined)
|
|
49
|
+
return false;
|
|
50
|
+
const boundRoots = new Set(nativeConsumers.flatMap((bound) => bound.sourceId && bound.sourceIdentity && bound.marketplaceRoot
|
|
51
|
+
&& bound.marketplaceName === consumer.marketplaceName && bound.projectKey === consumer.projectKey
|
|
52
|
+
? [bound.marketplaceRoot] : []));
|
|
53
|
+
const observedPaths = new Set(registrations.filter((entry) => entry.marketplaceName === consumer.marketplaceName)
|
|
54
|
+
.map((entry) => entry.marketplaceRegistrationPath));
|
|
55
|
+
return observedPaths.size === 0 ? boundRoots.size !== 1
|
|
56
|
+
: observedPaths.size !== 1 || [...observedPaths].some((location) => !location || !boundRoots.has(location));
|
|
57
|
+
});
|
|
58
|
+
return { registrations, consumers, unboundConsumers };
|
|
59
|
+
}
|
|
60
|
+
/** Resolve the same scope-local identity for offline preview and execution. A root
|
|
61
|
+
* identifies a marketplace, not a package or permission to remove that package. */
|
|
62
|
+
export function resolveCleanupMarketplaceIdentity(options) {
|
|
63
|
+
const { references, sourceId, sourceIdentity, pluginName, platform, scope } = options;
|
|
64
|
+
if (platform !== 'codex' && platform !== 'claude' && platform !== 'copilot')
|
|
65
|
+
return {};
|
|
66
|
+
const { registrations, consumers, unboundConsumers } = scopedCleanupMarketplaceEvidence(options);
|
|
67
|
+
const roots = references.filter((reference) => reference.kind === 'namespacedMarketplace'
|
|
68
|
+
&& reference.pluginName === undefined && reference.marketplaceRoot && reference.marketplaceName
|
|
69
|
+
&& (reference.platform === platform || platform !== 'copilot' && reference.platform === undefined));
|
|
70
|
+
const matchedConsumers = consumers.filter((reference) => reference.sourceId === sourceId);
|
|
71
|
+
const candidates = references.filter((reference) => reference.sourceId === sourceId
|
|
72
|
+
&& reference.sourceIdentity === sourceIdentity && reference.pluginName === pluginName
|
|
73
|
+
&& reference.platform === platform && reference.scope === scope
|
|
74
|
+
&& reference.recoveryCandidate?.evidence === 'verified' && reference.marketplaceRoot);
|
|
75
|
+
const liveNames = new Set(matchedConsumers.map((reference) => reference.marketplaceName));
|
|
76
|
+
const provenNames = new Map();
|
|
77
|
+
const addName = (name, root) => {
|
|
78
|
+
const paths = provenNames.get(name) ?? new Set();
|
|
79
|
+
paths.add(root);
|
|
80
|
+
provenNames.set(name, paths);
|
|
81
|
+
};
|
|
82
|
+
for (const reference of candidates) {
|
|
83
|
+
const candidate = reference.recoveryCandidate;
|
|
84
|
+
const id = candidate.nativeIdentity?.registrationId;
|
|
85
|
+
const separator = id?.lastIndexOf('@') ?? -1;
|
|
86
|
+
if (id && separator > 0 && candidate.binding.platform === platform && candidate.binding.scope.kind === scope
|
|
87
|
+
&& candidate.binding.plugin.sourceId === sourceId && candidate.binding.plugin.sourceIdentity === sourceIdentity
|
|
88
|
+
&& id.slice(0, separator) === pluginName && id.slice(separator + 1)
|
|
89
|
+
&& candidate.nativeIdentity?.sourceLocation === path.join(reference.marketplaceRoot, 'plugins', pluginName)) {
|
|
90
|
+
const name = id.slice(separator + 1);
|
|
91
|
+
liveNames.add(name);
|
|
92
|
+
addName(name, reference.marketplaceRoot);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const hasVerifiedCandidate = provenNames.size > 0;
|
|
96
|
+
for (const root of roots) {
|
|
97
|
+
if (root.sourceId !== sourceId || root.sourceIdentity !== sourceIdentity)
|
|
98
|
+
continue;
|
|
99
|
+
if (liveNames.size === 0 || liveNames.has(root.marketplaceName))
|
|
100
|
+
addName(root.marketplaceName, root.marketplaceRoot);
|
|
101
|
+
}
|
|
102
|
+
const unresolved = () => ({ marketplaceIdentityUnresolved: true });
|
|
103
|
+
if (liveNames.size > 1 || provenNames.size > 1)
|
|
104
|
+
return unresolved();
|
|
105
|
+
if (provenNames.size === 0)
|
|
106
|
+
return unboundConsumers.length > 0 || matchedConsumers.some(isNativeMarketplaceConsumer)
|
|
107
|
+
|| references.some((reference) => reference.sourceId === sourceId
|
|
108
|
+
&& reference.sourceIdentity === sourceIdentity && reference.pluginName === pluginName
|
|
109
|
+
&& reference.platform === platform && reference.scope === scope && reference.recoveryCandidate?.evidence === 'verified')
|
|
110
|
+
? unresolved() : {};
|
|
111
|
+
const [marketplaceName, paths] = [...provenNames][0];
|
|
112
|
+
if (liveNames.size === 1 && !liveNames.has(marketplaceName))
|
|
113
|
+
return unresolved();
|
|
114
|
+
const observed = registrations.filter((registration) => registration.marketplaceName === marketplaceName);
|
|
115
|
+
// An empty canonical root alone does not resolve some other, unbound
|
|
116
|
+
// marketplace's same-name activation. Preserve it and report the ambiguity.
|
|
117
|
+
if (!observed.length && !hasVerifiedCandidate && unboundConsumers.some((consumer) => consumer.marketplaceName !== marketplaceName))
|
|
118
|
+
return unresolved();
|
|
119
|
+
// Multiple physical markets sharing a name cannot be disambiguated by the name alone.
|
|
120
|
+
// An actual host registration can conclusively select one of those roots.
|
|
121
|
+
if (observed.some((registration) => !registration.marketplaceRegistrationPath
|
|
122
|
+
|| !paths.has(registration.marketplaceRegistrationPath)))
|
|
123
|
+
return unresolved();
|
|
124
|
+
const selectedPaths = observed.length ? new Set(observed.map((registration) => registration.marketplaceRegistrationPath)) : paths;
|
|
125
|
+
if (selectedPaths.size !== 1)
|
|
126
|
+
return unresolved();
|
|
127
|
+
const selectedRoot = [...selectedPaths][0];
|
|
128
|
+
if (candidates.some((candidate) => candidate.marketplaceRoot !== selectedRoot))
|
|
129
|
+
return unresolved();
|
|
130
|
+
if (!observed.length && roots.some((root) => root.marketplaceName === marketplaceName
|
|
131
|
+
&& root.marketplaceRoot !== selectedRoot))
|
|
132
|
+
return unresolved();
|
|
133
|
+
if (roots.some((root) => root.marketplaceRoot === selectedRoot
|
|
134
|
+
&& (root.sourceId !== sourceId || root.sourceIdentity !== sourceIdentity || root.marketplaceName !== marketplaceName)))
|
|
135
|
+
return unresolved();
|
|
136
|
+
const matchingActivation = consumers.some((consumer) => isNativeMarketplaceConsumer(consumer) && !consumer.managedNativeRegistration
|
|
137
|
+
&& consumer.marketplaceName === marketplaceName
|
|
138
|
+
&& (consumer.sourceId === undefined || consumer.sourceId === sourceId && consumer.sourceIdentity === sourceIdentity));
|
|
139
|
+
return { marketplaceName, ...(matchingActivation ? { nativeRegistration: true } : {}) };
|
|
140
|
+
}
|
|
30
141
|
function pluginNameFromMarketplaceId(pluginId, marketplaceName) {
|
|
31
142
|
const suffix = `@${marketplaceName}`;
|
|
32
143
|
return pluginId.endsWith(suffix) && pluginId.length > suffix.length
|
|
@@ -37,10 +148,11 @@ function claudeConsumersFromSettings(value, marketplaceName, scope) {
|
|
|
37
148
|
if (!value)
|
|
38
149
|
return [];
|
|
39
150
|
const output = [];
|
|
40
|
-
for (const pluginId of Object.
|
|
151
|
+
for (const [pluginId, enabled] of Object.entries(isRecord(value.enabledPlugins) ? value.enabledPlugins : {})) {
|
|
41
152
|
const pluginName = pluginNameFromMarketplaceId(pluginId, marketplaceName);
|
|
42
153
|
if (pluginName)
|
|
43
|
-
output.push({ pluginName, platform: 'claude', scope
|
|
154
|
+
output.push({ pluginName, platform: 'claude', scope,
|
|
155
|
+
...(enabled === false ? { disabledNativeActivation: true } : {}) });
|
|
44
156
|
}
|
|
45
157
|
const plugins = isRecord(value.plugins) && isRecord(value.plugins.installed)
|
|
46
158
|
? value.plugins.installed
|
|
@@ -55,7 +167,7 @@ function claudeConsumersFromSettings(value, marketplaceName, scope) {
|
|
|
55
167
|
}
|
|
56
168
|
return output;
|
|
57
169
|
}
|
|
58
|
-
function claudeConsumersFromInstalled(value, marketplaceName, currentProject, includeHistoricalProjects = false) {
|
|
170
|
+
function claudeConsumersFromInstalled(value, marketplaceName, currentProject, includeHistoricalProjects = false, includeManaged = false) {
|
|
59
171
|
const output = [];
|
|
60
172
|
if (value !== null && !isRecord(value)) {
|
|
61
173
|
throw new Error('Claude installed_plugins must be a JSON object.');
|
|
@@ -79,12 +191,17 @@ function claudeConsumersFromInstalled(value, marketplaceName, currentProject, in
|
|
|
79
191
|
if (item.scope !== undefined
|
|
80
192
|
&& item.scope !== 'user'
|
|
81
193
|
&& item.scope !== 'project'
|
|
82
|
-
&& item.scope !== 'local'
|
|
194
|
+
&& item.scope !== 'local'
|
|
195
|
+
&& item.scope !== 'managed') {
|
|
83
196
|
throw new Error(`Claude installed_plugins record ${key} has an invalid scope.`);
|
|
84
197
|
}
|
|
85
198
|
if (item.projectPath !== undefined && typeof item.projectPath !== 'string') {
|
|
86
199
|
throw new Error(`Claude installed_plugins record ${key} has an invalid projectPath.`);
|
|
87
200
|
}
|
|
201
|
+
// Managed policy is a host-global residual clue, but is never an AW
|
|
202
|
+
// user registration or an independent project reference.
|
|
203
|
+
if (item.scope === 'managed' && !includeManaged)
|
|
204
|
+
continue;
|
|
88
205
|
const itemMarketplace = typeof item.marketplace === 'string'
|
|
89
206
|
? item.marketplace
|
|
90
207
|
: pluginNameFromMarketplaceId(key, marketplaceName) ? marketplaceName : undefined;
|
|
@@ -103,7 +220,8 @@ function claudeConsumersFromInstalled(value, marketplaceName, currentProject, in
|
|
|
103
220
|
const pluginName = typeof item.name === 'string'
|
|
104
221
|
? item.name
|
|
105
222
|
: pluginNameFromMarketplaceId(key, marketplaceName) ?? key;
|
|
106
|
-
output.push({ pluginName, platform: 'claude', scope, ...(scope === 'project' ? { projectKey } : {})
|
|
223
|
+
output.push({ pluginName, platform: 'claude', scope, ...(scope === 'project' ? { projectKey } : {}),
|
|
224
|
+
...(item.scope === 'managed' ? { managedNativeRegistration: true } : {}) });
|
|
107
225
|
}
|
|
108
226
|
}
|
|
109
227
|
return output;
|
|
@@ -138,6 +256,7 @@ function inventoryErrorRelevance(location, env, cwd) {
|
|
|
138
256
|
[path.join(repoRoot, '.codex'), 'codex'],
|
|
139
257
|
[path.join(repoRoot, '.agents'), 'codex'],
|
|
140
258
|
[path.join(repoRoot, '.claude'), 'claude'],
|
|
259
|
+
[path.join(repoRoot, '.github', 'copilot'), 'copilot'],
|
|
141
260
|
];
|
|
142
261
|
for (const [root, platform] of projectRoots) {
|
|
143
262
|
if (pathSegmentsWithin(root, location) !== null) {
|
|
@@ -155,7 +274,16 @@ function inventoryErrorRelevance(location, env, cwd) {
|
|
|
155
274
|
if (pathSegmentsWithin(getClaudeHome(env), location) !== null) {
|
|
156
275
|
return { global: false, platform: 'claude', scope: 'user' };
|
|
157
276
|
}
|
|
277
|
+
const copilotRoot = resolvePlatformConfigRoot('copilot', { env, cwd });
|
|
278
|
+
if (pathSegmentsWithin(copilotRoot, location) !== null) {
|
|
279
|
+
return { global: false, platform: 'copilot', scope: 'user' };
|
|
280
|
+
}
|
|
158
281
|
for (const root of new Set([awHome, canonicalAwHome])) {
|
|
282
|
+
const platformPath = pathSegmentsWithin(path.join(root, 'platforms'), location);
|
|
283
|
+
if (platformPath && (platformPath.length <= 2 || platformPath[2] === 'marketplaces')
|
|
284
|
+
&& (platformPath[0] === 'codex' || platformPath[0] === 'claude' || platformPath[0] === 'copilot')) {
|
|
285
|
+
return { global: false, platform: platformPath[0], ...(platformPath[3] ? { sourceId: platformPath[3] } : {}) };
|
|
286
|
+
}
|
|
159
287
|
const marketplace = pathSegmentsWithin(path.join(root, 'marketplaces'), location);
|
|
160
288
|
if (marketplace?.[0])
|
|
161
289
|
return { global: false, sourceId: marketplace[0] };
|
|
@@ -189,7 +317,7 @@ function isAbsentState(error) {
|
|
|
189
317
|
}
|
|
190
318
|
function inventoryError(error, location, kind, env, cwd, relevance) {
|
|
191
319
|
const message = error instanceof Error ? error.message : String(error);
|
|
192
|
-
const sensitiveRoots = [getCodexHome(env), getClaudeHome(env), resolveRepoRootSync(cwd)];
|
|
320
|
+
const sensitiveRoots = [getCodexHome(env), getClaudeHome(env), resolvePlatformConfigRoot('copilot', { env, cwd }), resolveRepoRootSync(cwd)];
|
|
193
321
|
return {
|
|
194
322
|
code: 'stateInventoryFailed',
|
|
195
323
|
kind,
|
|
@@ -743,6 +871,7 @@ async function oldMarketplaceReferences(env, cwd, errors, includePlatformHistori
|
|
|
743
871
|
const claudeInstalledPath = path.join(getClaudeHome(env), 'plugins', 'installed_plugins.json');
|
|
744
872
|
const output = [];
|
|
745
873
|
const marketplacesRoot = path.join(resolveAwHome(env), 'marketplaces');
|
|
874
|
+
const canonicalLegacyRoot = path.join(await canonicalNamespaceRoot(resolveAwHome(env)), 'marketplaces');
|
|
746
875
|
const namespacedPrimaryRoots = new Set();
|
|
747
876
|
const marketplaceEntries = await inventoryCanonicalDirectoryEntries({
|
|
748
877
|
errors, location: marketplacesRoot, kind: 'marketplaceDirectoryRead', env, cwd,
|
|
@@ -765,6 +894,7 @@ async function oldMarketplaceReferences(env, cwd, errors, includePlatformHistori
|
|
|
765
894
|
});
|
|
766
895
|
if (manifest?.name === 'aw' && config?.schemaVersion === 2 && config.sourceId === entry.name) {
|
|
767
896
|
namespacedPrimaryRoots.add(path.normalize(path.join(marketplacesRoot, entry.name)));
|
|
897
|
+
namespacedPrimaryRoots.add(path.join(canonicalLegacyRoot, entry.name));
|
|
768
898
|
}
|
|
769
899
|
}
|
|
770
900
|
const codex = await inventoryRead({
|
|
@@ -804,11 +934,13 @@ async function oldMarketplaceReferences(env, cwd, errors, includePlatformHistori
|
|
|
804
934
|
const claudeAwIsNamespaced = declarationPaths.length > 0
|
|
805
935
|
&& declarationPaths.every((entry) => namespacedPrimaryRoots.has(path.normalize(entry)));
|
|
806
936
|
if ((settings && (Object.hasOwn(settings.extraKnownMarketplaces ?? {}, 'aw')
|
|
807
|
-
||
|
|
937
|
+
|| Object.entries(settings.enabledPlugins ?? {}).some(([key, enabled]) => isAwPluginConsumerKey(key) && enabled !== false)
|
|
808
938
|
|| hasAwPluginConsumerKeys(settings.plugins?.installed)
|
|
809
939
|
|| hasClaudeMarketplaceConsumer(settings.plugins?.installed))) && !claudeAwIsNamespaced) {
|
|
810
940
|
output.push({ kind: 'legacyMarketplace', location: claudeSettingsPath });
|
|
811
941
|
for (const consumer of claudeConsumersFromSettings(settings, 'aw', 'user')) {
|
|
942
|
+
if (consumer.disabledNativeActivation)
|
|
943
|
+
continue;
|
|
812
944
|
output.push({ kind: 'legacyMarketplace', location: claudeSettingsPath, ...consumer });
|
|
813
945
|
}
|
|
814
946
|
}
|
|
@@ -845,6 +977,8 @@ async function oldMarketplaceReferences(env, cwd, errors, includePlatformHistori
|
|
|
845
977
|
});
|
|
846
978
|
if (!claudeAwIsNamespaced) {
|
|
847
979
|
for (const consumer of claudeConsumersFromSettings(projectSettings, 'aw', 'project')) {
|
|
980
|
+
if (consumer.disabledNativeActivation)
|
|
981
|
+
continue;
|
|
848
982
|
output.push({ kind: 'legacyMarketplace', location: projectSettingsPath, ...consumer });
|
|
849
983
|
}
|
|
850
984
|
}
|
|
@@ -884,13 +1018,41 @@ function sourceIdFromCanonicalMarketplacePath(candidate, marketplacesRoot) {
|
|
|
884
1018
|
const sourceId = path.basename(resolved);
|
|
885
1019
|
return sourceId !== '' && sourceId !== '.' && sourceId !== '..' ? sourceId : null;
|
|
886
1020
|
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
const
|
|
892
|
-
|
|
893
|
-
}
|
|
1021
|
+
const MARKETPLACE_PLATFORMS = ['codex', 'claude', 'copilot'];
|
|
1022
|
+
async function managedMarketplaceDirectories(awRoot, cwd, env) {
|
|
1023
|
+
const directories = new Map();
|
|
1024
|
+
for (const platform of MARKETPLACE_PLATFORMS) {
|
|
1025
|
+
const configRoot = await canonicalNamespaceRoot(resolvePlatformConfigRoot(platform, { cwd, env }));
|
|
1026
|
+
directories.set(platform, path.join(getManagedPlatformRoot(awRoot, platform, `${platform}-marketplace`, configRoot), 'marketplaces'));
|
|
1027
|
+
}
|
|
1028
|
+
return directories;
|
|
1029
|
+
}
|
|
1030
|
+
function pluginMarketplaceName(pluginId) {
|
|
1031
|
+
const separator = pluginId.lastIndexOf('@');
|
|
1032
|
+
return separator > 0 && separator < pluginId.length - 1 ? pluginId.slice(separator + 1) : undefined;
|
|
1033
|
+
}
|
|
1034
|
+
/** A missing package container is valid after removal; a foreign container is not. */
|
|
1035
|
+
async function assertMarketplacePluginsContainer(root) {
|
|
1036
|
+
const pluginsRoot = path.join(root, 'plugins');
|
|
1037
|
+
const stat = await fs.lstat(pluginsRoot).catch((error) => {
|
|
1038
|
+
if (isAbsentState(error))
|
|
1039
|
+
return null;
|
|
1040
|
+
throw error;
|
|
1041
|
+
});
|
|
1042
|
+
if (stat && (!stat.isDirectory() || stat.isSymbolicLink()))
|
|
1043
|
+
throw new Error('Marketplace plugins container must be a canonical directory.');
|
|
1044
|
+
}
|
|
1045
|
+
async function readEnabledPluginsInventory(location) {
|
|
1046
|
+
const value = await readJsonFileIfExists(location);
|
|
1047
|
+
if (value === null || value === undefined)
|
|
1048
|
+
return {};
|
|
1049
|
+
if (!isRecord(value) || value.enabledPlugins !== undefined && !isRecord(value.enabledPlugins)) {
|
|
1050
|
+
throw new Error('Native settings enabledPlugins must be a JSON object.');
|
|
1051
|
+
}
|
|
1052
|
+
if (isRecord(value.enabledPlugins) && Object.values(value.enabledPlugins).some((enabled) => typeof enabled !== 'boolean')) {
|
|
1053
|
+
throw new Error('Native settings enabledPlugins entries must be boolean.');
|
|
1054
|
+
}
|
|
1055
|
+
return isRecord(value.enabledPlugins) ? value.enabledPlugins : {};
|
|
894
1056
|
}
|
|
895
1057
|
/** Operation-local fingerprints bind reviewed output bytes; they do not confer ownership. */
|
|
896
1058
|
export async function offlineOwnedPathEvidence(location) {
|
|
@@ -978,7 +1140,7 @@ async function nativeOwnedReferences(options, errors) {
|
|
|
978
1140
|
add(path.join(projectRoot, '.grok/plugins'), platform, 'project', 'grok-directory', hostRoot);
|
|
979
1141
|
}
|
|
980
1142
|
}
|
|
981
|
-
const awRoot = resolveAwHome(options.env);
|
|
1143
|
+
const awRoot = await canonicalNamespaceRoot(resolveAwHome(options.env));
|
|
982
1144
|
const managed = path.join(awRoot, 'platforms');
|
|
983
1145
|
for (const platform of NATIVE_PLATFORM_TARGETS) {
|
|
984
1146
|
const namespaces = await inventoryCanonicalDirectoryEntries({ location: path.join(managed, platform),
|
|
@@ -1079,9 +1241,13 @@ async function nativeOwnedReferences(options, errors) {
|
|
|
1079
1241
|
nativeIdentity: scopedLayout.nativeIdentity, evidence: antigravityCopy && !inspectCopy ? 'unknown' : 'verified' };
|
|
1080
1242
|
// A copied marker is a native recovery clue, never direct filesystem
|
|
1081
1243
|
// removal authority for the cache or ownership of the AW source path.
|
|
1244
|
+
const currentMarketplaceRoot = scopedLayout.marketplaceRoot && descriptor.managed
|
|
1245
|
+
? path.join(getManagedPlatformRoot(awRoot, descriptor.platform, descriptor.route, await canonicalNamespaceRoot(descriptor.hostRoot)), 'marketplaces', marker.sourceId) : null;
|
|
1082
1246
|
references.push({ kind: antigravityCopy ? 'namespacedMarketplace' : 'namespacedOwner', location: markerPath, sourceId: marker.sourceId,
|
|
1083
1247
|
sourceIdentity: marker.sourceIdentity, pluginName: marker.plugin, platform: descriptor.platform, scope,
|
|
1084
|
-
...(!antigravityCopy ? { ownedComponent: component } : {}), recoveryCandidate, pathEvidence
|
|
1248
|
+
...(!antigravityCopy ? { ownedComponent: component } : {}), recoveryCandidate, pathEvidence,
|
|
1249
|
+
...(currentMarketplaceRoot && scopedLayout.marketplaceRoot === currentMarketplaceRoot
|
|
1250
|
+
? { marketplaceRoot: currentMarketplaceRoot } : {}) });
|
|
1085
1251
|
}
|
|
1086
1252
|
}
|
|
1087
1253
|
catch (error) {
|
|
@@ -1267,56 +1433,162 @@ export async function inventoryCatalogSourceReferences(options) {
|
|
|
1267
1433
|
const marketplaceEntries = await inventoryCanonicalDirectoryEntries({
|
|
1268
1434
|
errors, location: marketplacesRoot, kind: 'marketplaceDirectoryRead', env, cwd: options.cwd,
|
|
1269
1435
|
});
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1436
|
+
const canonicalAwRoot = await canonicalNamespaceRoot(awHome);
|
|
1437
|
+
const managedDirectories = await managedMarketplaceDirectories(canonicalAwRoot, options.cwd, env);
|
|
1438
|
+
const canonicalLegacyRoot = path.join(canonicalAwRoot, 'marketplaces');
|
|
1439
|
+
const projectClaudeLocalSettingsPath = path.join(resolveRepoRootSync(options.cwd), '.claude', 'settings.local.json');
|
|
1440
|
+
const projectClaudeLocalSettings = await inventoryRead({
|
|
1441
|
+
operation: () => readJsonFileIfExists(projectClaudeLocalSettingsPath), absent: null, errors,
|
|
1442
|
+
location: projectClaudeLocalSettingsPath, kind: 'nativeStateRead', env, cwd: options.cwd,
|
|
1443
|
+
});
|
|
1444
|
+
const nativeConsumers = [];
|
|
1445
|
+
const addConsumer = (location, marketplaceName, consumer) => {
|
|
1446
|
+
nativeConsumers.push({ kind: 'namespacedMarketplace', location, marketplaceName, ...consumer });
|
|
1447
|
+
};
|
|
1448
|
+
for (const [location, plugins, platform, scope] of [
|
|
1449
|
+
[codexConfigPath, codexConfig?.snapshot.plugins ?? {}, 'codex', 'user'],
|
|
1450
|
+
[projectCodexConfigPath, projectCodexConfig?.snapshot.plugins ?? {}, 'codex', 'project'],
|
|
1451
|
+
...await Promise.all(['user', 'project'].map(async (scope) => {
|
|
1452
|
+
const location = scope === 'user'
|
|
1453
|
+
? path.join(resolvePlatformConfigRoot('copilot', { cwd: options.cwd, env }), 'settings.json')
|
|
1454
|
+
: path.join(resolveRepoRootSync(options.cwd), '.github', 'copilot', 'settings.local.json');
|
|
1455
|
+
const plugins = await inventoryRead({ operation: () => readEnabledPluginsInventory(location), absent: {}, errors,
|
|
1456
|
+
location, kind: 'nativeStateRead', env, cwd: options.cwd });
|
|
1457
|
+
return [location, plugins, 'copilot', scope];
|
|
1458
|
+
})),
|
|
1459
|
+
]) {
|
|
1460
|
+
for (const pluginId of Object.keys(plugins)) {
|
|
1461
|
+
const marketplaceName = pluginMarketplaceName(pluginId);
|
|
1462
|
+
if (marketplaceName)
|
|
1463
|
+
addConsumer(location, marketplaceName, {
|
|
1464
|
+
pluginName: pluginNameFromMarketplaceId(pluginId, marketplaceName), platform, scope,
|
|
1465
|
+
});
|
|
1466
|
+
}
|
|
1282
1467
|
}
|
|
1283
|
-
for (const
|
|
1284
|
-
|
|
1285
|
-
|
|
1468
|
+
for (const [location, settings, scope] of [
|
|
1469
|
+
[userClaudeSettingsPath, userClaudeSettings, 'user'],
|
|
1470
|
+
[projectClaudeSettingsPath, projectClaudeSettings, 'project'],
|
|
1471
|
+
[projectClaudeLocalSettingsPath, projectClaudeLocalSettings, 'project'],
|
|
1472
|
+
]) {
|
|
1473
|
+
if (!settings)
|
|
1286
1474
|
continue;
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1475
|
+
const installed = isRecord(settings.plugins) && isRecord(settings.plugins.installed) ? settings.plugins.installed : {};
|
|
1476
|
+
const names = new Set([
|
|
1477
|
+
...Object.keys(isRecord(settings.enabledPlugins) ? settings.enabledPlugins : {}).map(pluginMarketplaceName),
|
|
1478
|
+
...Object.values(installed).flatMap((entry) => isRecord(entry) && typeof entry.marketplace === 'string' ? [entry.marketplace] : []),
|
|
1479
|
+
].filter((name) => !!name));
|
|
1480
|
+
for (const name of names)
|
|
1481
|
+
for (const consumer of claudeConsumersFromSettings(settings, name, scope))
|
|
1482
|
+
addConsumer(location, name, consumer);
|
|
1295
1483
|
}
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1484
|
+
const installedClaudeNames = new Set();
|
|
1485
|
+
if (isRecord(claudeInstalled?.plugins))
|
|
1486
|
+
for (const [id, raw] of Object.entries(claudeInstalled.plugins)) {
|
|
1487
|
+
const name = pluginMarketplaceName(id);
|
|
1488
|
+
if (name)
|
|
1489
|
+
installedClaudeNames.add(name);
|
|
1490
|
+
for (const entry of Array.isArray(raw) ? raw : [raw]) {
|
|
1491
|
+
if (isRecord(entry) && typeof entry.marketplace === 'string')
|
|
1492
|
+
installedClaudeNames.add(entry.marketplace);
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
try {
|
|
1496
|
+
if (installedClaudeNames.size === 0)
|
|
1497
|
+
claudeConsumersFromInstalled(claudeInstalled, '', path.normalize(canonicalProjectRoot));
|
|
1498
|
+
for (const name of installedClaudeNames)
|
|
1499
|
+
for (const consumer of claudeConsumersFromInstalled(claudeInstalled, name, path.normalize(canonicalProjectRoot), options.includePlatformHistoricalProjects === true, true))
|
|
1500
|
+
addConsumer(claudeInstalledPath, name, consumer);
|
|
1501
|
+
}
|
|
1502
|
+
catch (error) {
|
|
1503
|
+
errors.push(inventoryError(error, claudeInstalledPath, 'nativeStateRead', env, options.cwd));
|
|
1504
|
+
}
|
|
1505
|
+
references.push(...nativeConsumers);
|
|
1506
|
+
// Host paths are matched lexically against only the legacy root and the current
|
|
1507
|
+
// platform/route namespace. Never adopt a host's foreign directory or another namespace.
|
|
1508
|
+
const registrations = [];
|
|
1509
|
+
const appendRegistration = (platform, location, marketplaceName, registrationPath, scope) => {
|
|
1510
|
+
const sourceId = registrationPath
|
|
1511
|
+
? (sourceIdFromCanonicalMarketplacePath(registrationPath, canonicalLegacyRoot)
|
|
1512
|
+
?? sourceIdFromCanonicalMarketplacePath(registrationPath, managedDirectories.get(platform)))
|
|
1513
|
+
: null;
|
|
1514
|
+
registrations.push({ kind: 'namespacedMarketplace', location, platform, marketplaceName,
|
|
1515
|
+
...(sourceId ? { sourceId } : {}), ...(scope ? { scope } : {}), marketplaceRegistrationPath: registrationPath });
|
|
1516
|
+
};
|
|
1517
|
+
for (const [location, config, scope] of [
|
|
1518
|
+
[codexConfigPath, codexConfig, 'user'], [projectCodexConfigPath, projectCodexConfig, 'project'],
|
|
1312
1519
|
]) {
|
|
1313
|
-
for (const
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1520
|
+
for (const [name, marketplace] of Object.entries(config?.snapshot.marketplaces ?? {})) {
|
|
1521
|
+
const source = marketplace.sourceType === 'local' && !marketplace.sourcePointsToManifest ? marketplace.source : undefined;
|
|
1522
|
+
appendRegistration('codex', location, name, canonicalMarketplaceRegistrationPath(source, awHome, canonicalAwRoot), scope);
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
for (const [location, declarations, scope] of [
|
|
1526
|
+
[userClaudeSettingsPath, userClaudeSettings?.extraKnownMarketplaces, 'user'],
|
|
1527
|
+
[projectClaudeSettingsPath, projectClaudeSettings?.extraKnownMarketplaces, 'project'],
|
|
1528
|
+
[projectClaudeLocalSettingsPath, projectClaudeLocalSettings?.extraKnownMarketplaces, 'project'],
|
|
1529
|
+
[claudeKnownPath, claudeKnown, undefined], [claudeKnownPath, claudeKnown?.marketplaces, undefined],
|
|
1530
|
+
]) {
|
|
1531
|
+
if (!isRecord(declarations))
|
|
1532
|
+
continue;
|
|
1533
|
+
for (const [name, declaration] of Object.entries(declarations)) {
|
|
1534
|
+
if (name === 'marketplaces' && location === claudeKnownPath)
|
|
1535
|
+
continue;
|
|
1536
|
+
const declaredSource = isRecord(declaration) ? declaration.source : undefined;
|
|
1537
|
+
const foreignSource = typeof declaredSource === 'string' && declaredSource !== 'directory' && !path.isAbsolute(declaredSource)
|
|
1538
|
+
|| isRecord(declaredSource) && declaredSource.source !== undefined && declaredSource.source !== 'directory';
|
|
1539
|
+
const paths = [...new Set(collectMarketplaceDeclarationPaths(declaration)
|
|
1540
|
+
.map((candidate) => canonicalMarketplaceRegistrationPath(candidate, awHome, canonicalAwRoot)))];
|
|
1541
|
+
appendRegistration('claude', location, name, !foreignSource && paths.length === 1 ? paths[0] ?? null : null, scope);
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
references.push(...registrations);
|
|
1545
|
+
for (const [platform, directory] of managedDirectories) {
|
|
1546
|
+
const root = await inventoryCanonicalDescendantDirectory({ root: canonicalAwRoot,
|
|
1547
|
+
segments: path.relative(canonicalAwRoot, directory).split(path.sep), errors,
|
|
1548
|
+
kind: 'marketplaceDirectoryRead', env, cwd: options.cwd });
|
|
1549
|
+
const entries = root ? await inventoryCanonicalDirectoryEntries({ errors, location: root,
|
|
1550
|
+
kind: 'marketplaceDirectoryRead', env, cwd: options.cwd }) : [];
|
|
1551
|
+
const registeredIds = registrations.filter((registration) => registration.platform === platform && registration.marketplaceRegistrationPath
|
|
1552
|
+
&& sourceIdFromCanonicalMarketplacePath(registration.marketplaceRegistrationPath, directory) !== null)
|
|
1553
|
+
.flatMap((registration) => registration.sourceId ? [registration.sourceId] : []);
|
|
1554
|
+
for (const sourceId of new Set([...entries.map((entry) => entry.name), ...registeredIds])) {
|
|
1555
|
+
const marketplaceRoot = path.join(directory, sourceId);
|
|
1556
|
+
const configPath = path.join(marketplaceRoot, 'config.json');
|
|
1557
|
+
const strictRoot = root ? await inventoryRead({ operation: async () => {
|
|
1558
|
+
if (!await inventoryCanonicalDirectory({ errors, location: marketplaceRoot, kind: 'marketplaceRootValidation', env, cwd: options.cwd }))
|
|
1559
|
+
return null;
|
|
1560
|
+
await assertMarketplacePluginsContainer(marketplaceRoot);
|
|
1561
|
+
const manifestPath = path.join(marketplaceRoot, platform === 'codex' ? '.agents/plugins/marketplace.json'
|
|
1562
|
+
: platform === 'claude' ? '.claude-plugin/marketplace.json' : '.github/plugin/marketplace.json');
|
|
1563
|
+
for (const location of [configPath, manifestPath]) {
|
|
1564
|
+
if (await canonicalNamespaceRoot(location) !== location)
|
|
1565
|
+
throw new Error('Marketplace path contains a symbolic link.');
|
|
1566
|
+
}
|
|
1567
|
+
return readStrictNamespacedMarketplaceRoot({ rootDir: marketplaceRoot, sourceId, platform, trustedMarketplaceRoot: directory });
|
|
1568
|
+
}, absent: null, reportAbsent: true, errors, location: marketplaceRoot, kind: 'marketplaceRootValidation', env, cwd: options.cwd }) : null;
|
|
1569
|
+
const names = new Set(registrations.filter((registration) => registration.platform === platform
|
|
1570
|
+
&& registration.marketplaceRegistrationPath === marketplaceRoot).flatMap((registration) => registration.marketplaceName ? [registration.marketplaceName] : []));
|
|
1571
|
+
if (strictRoot) {
|
|
1572
|
+
const { marketplaceName, sourceIdentity } = strictRoot.config;
|
|
1573
|
+
names.add(marketplaceName);
|
|
1574
|
+
references.push({ kind: 'namespacedMarketplace', sourceId, sourceIdentity, marketplaceName, marketplaceRoot, platform, location: configPath });
|
|
1575
|
+
for (const entry of strictRoot.manifest.plugins) {
|
|
1576
|
+
if (!isRecord(entry) || typeof entry.name !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/u.test(entry.name)
|
|
1577
|
+
|| entry.source !== `./plugins/${entry.name}`)
|
|
1578
|
+
continue;
|
|
1579
|
+
references.push({ kind: 'namespacedMarketplace', sourceId, sourceIdentity, marketplaceName, marketplaceRoot, platform,
|
|
1580
|
+
location: configPath, pluginName: entry.name, scope: 'user', marketplaceManifestEntry: true });
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
for (const consumer of nativeConsumers) {
|
|
1584
|
+
if (consumer.platform !== platform || consumer.disabledNativeActivation
|
|
1585
|
+
|| !consumer.marketplaceName || !names.has(consumer.marketplaceName))
|
|
1586
|
+
continue;
|
|
1587
|
+
const exact = strictRoot?.config.marketplaceName === consumer.marketplaceName;
|
|
1588
|
+
references.push({ ...consumer, location: configPath, sourceId,
|
|
1589
|
+
...(exact ? { sourceIdentity: strictRoot.config.sourceIdentity, marketplaceRoot } : {}) });
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1320
1592
|
}
|
|
1321
1593
|
for (const sourceEntry of marketplaceEntries) {
|
|
1322
1594
|
const marketplaceRoot = path.join(marketplacesRoot, sourceEntry.name);
|
|
@@ -1331,10 +1603,16 @@ export async function inventoryCatalogSourceReferences(options) {
|
|
|
1331
1603
|
});
|
|
1332
1604
|
const strictRoot = canonicalRoot
|
|
1333
1605
|
? await inventoryRead({
|
|
1334
|
-
operation: () =>
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1606
|
+
operation: async () => {
|
|
1607
|
+
await assertMarketplacePluginsContainer(marketplaceRoot);
|
|
1608
|
+
const expectedRoot = path.join(canonicalLegacyRoot, sourceEntry.name);
|
|
1609
|
+
for (const location of [marketplaceRoot, configPath, agentsManifestPath, path.join(marketplaceRoot, '.claude-plugin/marketplace.json')]) {
|
|
1610
|
+
const expected = path.join(expectedRoot, path.relative(marketplaceRoot, location));
|
|
1611
|
+
if (await canonicalNamespaceRoot(location) !== expected)
|
|
1612
|
+
throw new Error('Marketplace path contains a symbolic link.');
|
|
1613
|
+
}
|
|
1614
|
+
return readStrictNamespacedMarketplaceRoot({ rootDir: marketplaceRoot, sourceId: sourceEntry.name });
|
|
1615
|
+
},
|
|
1338
1616
|
absent: null,
|
|
1339
1617
|
reportAbsent: true,
|
|
1340
1618
|
errors,
|
|
@@ -1384,28 +1662,10 @@ export async function inventoryCatalogSourceReferences(options) {
|
|
|
1384
1662
|
? codexConfig?.snapshot.marketplaces[marketplaceName]
|
|
1385
1663
|
: undefined;
|
|
1386
1664
|
const codexMarketplaceIsCanonical = isCanonicalCodexMarketplaceRegistration(codexMarketplace, marketplaceRoot);
|
|
1387
|
-
const consumers =
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
if (pluginName)
|
|
1392
|
-
consumers.push({ pluginName, platform: 'codex', scope: 'user' });
|
|
1393
|
-
}
|
|
1394
|
-
for (const pluginId of Object.keys(projectCodexConfig?.snapshot.plugins ?? {})) {
|
|
1395
|
-
const pluginName = pluginNameFromMarketplaceId(pluginId, marketplaceName);
|
|
1396
|
-
if (pluginName)
|
|
1397
|
-
consumers.push({ pluginName, platform: 'codex', scope: 'project' });
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
|
-
if (marketplaceName !== null) {
|
|
1401
|
-
consumers.push(...claudeConsumersFromSettings(userClaudeSettings, marketplaceName, 'user'), ...claudeConsumersFromSettings(projectClaudeSettings, marketplaceName, 'project'));
|
|
1402
|
-
try {
|
|
1403
|
-
consumers.push(...claudeConsumersFromInstalled(claudeInstalled, marketplaceName, path.normalize(canonicalProjectRoot), options.includePlatformHistoricalProjects === true));
|
|
1404
|
-
}
|
|
1405
|
-
catch (error) {
|
|
1406
|
-
errors.push(inventoryError(error, claudeInstalledPath, 'nativeStateRead', env, options.cwd));
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1665
|
+
const consumers = nativeConsumers.filter((consumer) => consumer.platform !== 'copilot'
|
|
1666
|
+
&& !consumer.disabledNativeActivation
|
|
1667
|
+
&& consumer.marketplaceName === marketplaceName
|
|
1668
|
+
&& (consumer.platform !== 'codex' || strictRoot !== null || codexMarketplaceIsCanonical));
|
|
1409
1669
|
if (marketplaceName !== null && strictRoot !== null) {
|
|
1410
1670
|
references.push({
|
|
1411
1671
|
kind: 'namespacedMarketplace',
|
|
@@ -1413,17 +1673,19 @@ export async function inventoryCatalogSourceReferences(options) {
|
|
|
1413
1673
|
sourceId: sourceEntry.name,
|
|
1414
1674
|
...(sourceIdentity ? { sourceIdentity } : {}),
|
|
1415
1675
|
marketplaceName,
|
|
1676
|
+
marketplaceRoot: path.join(canonicalLegacyRoot, sourceEntry.name),
|
|
1416
1677
|
});
|
|
1417
1678
|
}
|
|
1418
1679
|
if (marketplaceName !== null) {
|
|
1419
1680
|
for (const consumer of consumers)
|
|
1420
1681
|
references.push({
|
|
1682
|
+
...consumer,
|
|
1421
1683
|
kind: 'namespacedMarketplace',
|
|
1422
1684
|
location: configPath,
|
|
1423
1685
|
sourceId: sourceEntry.name,
|
|
1424
1686
|
...(sourceIdentity ? { sourceIdentity } : {}),
|
|
1425
1687
|
marketplaceName,
|
|
1426
|
-
...
|
|
1688
|
+
...(strictRoot ? { marketplaceRoot: path.join(canonicalLegacyRoot, sourceEntry.name) } : {}),
|
|
1427
1689
|
});
|
|
1428
1690
|
}
|
|
1429
1691
|
}
|
|
@@ -1442,6 +1704,11 @@ export async function inventoryCatalogSourceReferences(options) {
|
|
|
1442
1704
|
reference.scope ?? '',
|
|
1443
1705
|
reference.marketplaceName ?? '',
|
|
1444
1706
|
reference.projectKey ?? '',
|
|
1707
|
+
reference.marketplaceRoot ?? '',
|
|
1708
|
+
reference.marketplaceRegistrationPath ?? '',
|
|
1709
|
+
reference.marketplaceManifestEntry ? 'manifest' : '',
|
|
1710
|
+
reference.managedNativeRegistration ? 'managed' : '',
|
|
1711
|
+
reference.disabledNativeActivation ? 'disabled' : '',
|
|
1445
1712
|
].join('\0'), reference])).values()];
|
|
1446
1713
|
unique.sort((left, right) => left.location.localeCompare(right.location));
|
|
1447
1714
|
const knownNames = [...new Set([...(options.knownPluginNames ?? []), ...unique.flatMap((reference) => reference.kind.startsWith('namespaced') && reference.pluginName ? [reference.pluginName] : [])])];
|