@lesliechan721/aw 0.1.0-beta.102 → 0.1.0-beta.104
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/src/commands/catalog-generation.d.ts +2 -5
- package/dist/src/commands/catalog-generation.js +2 -4
- package/dist/src/commands/catalog-generation.js.map +1 -1
- package/dist/src/commands/lifecycle-command-package.d.ts +1 -1
- package/dist/src/commands/lifecycle-command-package.js +40 -2
- package/dist/src/commands/lifecycle-command-package.js.map +1 -1
- package/dist/src/commands/managed-commands.d.ts +2 -1
- package/dist/src/commands/managed-commands.js +4 -2
- package/dist/src/commands/managed-commands.js.map +1 -1
- package/dist/src/commands/operation-plan.d.ts +2 -8
- package/dist/src/commands/operation-plan.js.map +1 -1
- package/dist/src/commands/public-config-confirmation.d.ts +16 -10
- package/dist/src/commands/public-config-confirmation.js +87 -52
- package/dist/src/commands/public-config-confirmation.js.map +1 -1
- package/dist/src/commands/public-lifecycle.d.ts +1 -1
- package/dist/src/commands/public-lifecycle.js +36 -8
- package/dist/src/commands/public-lifecycle.js.map +1 -1
- package/dist/src/commands/public-plugin-query.js +6 -4
- package/dist/src/commands/public-plugin-query.js.map +1 -1
- package/dist/src/commands/rebuild-command.d.ts +22 -6
- package/dist/src/commands/rebuild-command.js +273 -557
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +12 -39
- package/dist/src/commands/rebuild-integration.js +67 -303
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +0 -4
- package/dist/src/commands/rebuild-operations.js +9 -8
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +14 -6
- package/dist/src/commands/rebuild-platform-integration.js +310 -101
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
- package/dist/src/commands/status-v6.d.ts +3 -117
- package/dist/src/commands/status-v6.js +0 -2886
- package/dist/src/commands/status-v6.js.map +1 -1
- package/dist/src/commands/write-commands.js +0 -3
- package/dist/src/commands/write-commands.js.map +1 -1
- package/dist/src/index.js +44 -36
- package/dist/src/index.js.map +1 -1
- package/dist/src/intent/deployment-preferences.js +4 -3
- package/dist/src/intent/deployment-preferences.js.map +1 -1
- package/dist/src/intent/intent-store.js +3 -2
- package/dist/src/intent/intent-store.js.map +1 -1
- package/dist/src/output/command-receipt.d.ts +0 -6
- package/dist/src/output/command-receipt.js +0 -15
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/output/receipt-projection.js +2 -1
- package/dist/src/output/receipt-projection.js.map +1 -1
- package/dist/src/platforms/capabilities.js +8 -2
- package/dist/src/platforms/capabilities.js.map +1 -1
- package/dist/src/platforms/contracts.d.ts +2 -0
- package/dist/src/platforms/discovery.d.ts +2 -0
- package/dist/src/platforms/discovery.js +95 -49
- package/dist/src/platforms/discovery.js.map +1 -1
- package/dist/src/platforms/inspection-native.d.ts +7 -1
- package/dist/src/platforms/inspection-native.js +6 -3
- package/dist/src/platforms/inspection-native.js.map +1 -1
- package/dist/src/platforms/inspection-query.d.ts +28 -14
- package/dist/src/platforms/inspection-query.js +102 -8
- package/dist/src/platforms/inspection-query.js.map +1 -1
- package/dist/src/platforms/lifecycle-native-services.d.ts +1 -1
- package/dist/src/platforms/lifecycle-native-services.js +7 -2
- package/dist/src/platforms/lifecycle-native-services.js.map +1 -1
- package/dist/src/platforms/lifecycle-native.js +20 -3
- package/dist/src/platforms/lifecycle-native.js.map +1 -1
- package/dist/src/platforms/lifecycle.js +5 -0
- package/dist/src/platforms/lifecycle.js.map +1 -1
- package/dist/src/platforms/supplement-state.js +11 -2
- package/dist/src/platforms/supplement-state.js.map +1 -1
- package/dist/src/portable/commands.d.ts +1 -0
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/materializer.d.ts +2 -0
- package/dist/src/portable/materializer.js +4 -4
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery.d.ts +1 -0
- package/dist/src/portable/recovery.js +3 -2
- package/dist/src/portable/recovery.js.map +1 -1
- package/dist/src/recovery/coordinator.d.ts +6 -1
- package/dist/src/recovery/coordinator.js +113 -108
- package/dist/src/recovery/coordinator.js.map +1 -1
- package/dist/src/recovery/demand.d.ts +1 -2
- package/dist/src/recovery/demand.js +4 -11
- package/dist/src/recovery/demand.js.map +1 -1
- package/dist/src/recovery/install-concurrency.d.ts +12 -0
- package/dist/src/recovery/install-concurrency.js +39 -0
- package/dist/src/recovery/install-concurrency.js.map +1 -1
- package/dist/src/recovery/joint-coordinator.d.ts +3 -4
- package/dist/src/recovery/joint-coordinator.js +324 -188
- package/dist/src/recovery/joint-coordinator.js.map +1 -1
- package/dist/src/recovery/joint-demand.js +4 -3
- package/dist/src/recovery/joint-demand.js.map +1 -1
- package/dist/src/recovery/joint-install-execution.js +46 -2
- package/dist/src/recovery/joint-install-execution.js.map +1 -1
- package/dist/src/recovery/joint-install-native-rebase.js +5 -2
- package/dist/src/recovery/joint-install-native-rebase.js.map +1 -1
- package/dist/src/recovery/locked-prepared-execution.d.ts +32 -0
- package/dist/src/recovery/locked-prepared-execution.js +67 -0
- package/dist/src/recovery/locked-prepared-execution.js.map +1 -0
- package/dist/src/recovery/status.d.ts +20 -6
- package/dist/src/recovery/status.js +153 -98
- package/dist/src/recovery/status.js.map +1 -1
- package/dist/src/review/skill-materialization.d.ts +1 -0
- package/dist/src/review/skill-materialization.js.map +1 -1
- package/dist/src/tui/console-app-v4.js +4 -14
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/controller-runtime.js +201 -57
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +8 -9
- package/dist/src/tui/controller.js +5 -6
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/operation-review-planner.js +14 -103
- package/dist/src/tui/operation-review-planner.js.map +1 -1
- package/dist/src/types.d.ts +5 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/agent-version.js +1 -0
- package/dist/src/utils/agent-version.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +10 -0
- package/dist/src/utils/artifact-renderer.js +28 -2
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/aw-home-mutation-lock.d.ts +8 -0
- package/dist/src/utils/aw-home-mutation-lock.js +44 -8
- package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
- package/dist/src/utils/bundle-integrity.js +126 -33
- package/dist/src/utils/bundle-integrity.js.map +1 -1
- package/dist/src/utils/catalog-generation-resolver.d.ts +4 -0
- package/dist/src/utils/catalog-generation-resolver.js +4 -0
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
- package/dist/src/utils/catalog-generation-service.d.ts +50 -11
- package/dist/src/utils/catalog-generation-service.js +276 -130
- package/dist/src/utils/catalog-generation-service.js.map +1 -1
- package/dist/src/utils/catalog-generation-state.js +6 -1
- package/dist/src/utils/catalog-generation-state.js.map +1 -1
- package/dist/src/utils/catalog-generation-store.d.ts +5 -0
- package/dist/src/utils/catalog-generation-store.js +36 -13
- package/dist/src/utils/catalog-generation-store.js.map +1 -1
- package/dist/src/utils/catalog-operation-context.d.ts +17 -3
- package/dist/src/utils/catalog-operation-context.js +220 -22
- package/dist/src/utils/catalog-operation-context.js.map +1 -1
- package/dist/src/utils/catalog-performance.d.ts +3 -0
- package/dist/src/utils/catalog-performance.js +26 -0
- package/dist/src/utils/catalog-performance.js.map +1 -0
- package/dist/src/utils/catalog-snapshot.d.ts +5 -2
- package/dist/src/utils/catalog-snapshot.js +3 -2
- package/dist/src/utils/catalog-snapshot.js.map +1 -1
- package/dist/src/utils/catalog-source-impact.d.ts +2 -1
- package/dist/src/utils/catalog-source-impact.js +2 -2
- package/dist/src/utils/catalog-source-impact.js.map +1 -1
- package/dist/src/utils/catalog-source-references.d.ts +2 -0
- package/dist/src/utils/catalog-source-references.js +284 -148
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/codex-executable-discovery.js +1 -0
- package/dist/src/utils/codex-executable-discovery.js.map +1 -1
- package/dist/src/utils/codex-manager.js +1 -0
- package/dist/src/utils/codex-manager.js.map +1 -1
- package/dist/src/utils/codex-native-observation.d.ts +5 -2
- package/dist/src/utils/codex-native-observation.js +8 -4
- package/dist/src/utils/codex-native-observation.js.map +1 -1
- package/dist/src/utils/component-command-preparation.d.ts +1 -0
- package/dist/src/utils/component-command-preparation.js.map +1 -1
- package/dist/src/utils/git-catalog-provider.d.ts +38 -5
- package/dist/src/utils/git-catalog-provider.js +365 -156
- package/dist/src/utils/git-catalog-provider.js.map +1 -1
- package/dist/src/utils/managed-command-closure.d.ts +3 -1
- package/dist/src/utils/managed-command-closure.js +10 -5
- package/dist/src/utils/managed-command-closure.js.map +1 -1
- package/dist/src/utils/managed-command-materialization.d.ts +2 -0
- package/dist/src/utils/managed-command-materialization.js +4 -3
- package/dist/src/utils/managed-command-materialization.js.map +1 -1
- package/dist/src/utils/managed-command-preparation.js +1 -1
- package/dist/src/utils/managed-command-preparation.js.map +1 -1
- package/dist/src/utils/multi-source-catalog.d.ts +1 -1
- package/dist/src/utils/multi-source-catalog.js +3 -3
- package/dist/src/utils/multi-source-catalog.js.map +1 -1
- package/dist/src/utils/native-cli.d.ts +6 -1
- package/dist/src/utils/native-cli.js +67 -32
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/platform-empty-state.d.ts +2 -0
- package/dist/src/utils/platform-empty-state.js +5 -5
- package/dist/src/utils/platform-empty-state.js.map +1 -1
- package/dist/src/utils/plugin-config-command-apply.d.ts +14 -4
- package/dist/src/utils/plugin-config-command-apply.js +49 -5
- package/dist/src/utils/plugin-config-command-apply.js.map +1 -1
- package/dist/src/utils/plugin-config-impact.d.ts +42 -0
- package/dist/src/utils/plugin-config-impact.js +170 -14
- package/dist/src/utils/plugin-config-impact.js.map +1 -1
- package/dist/src/utils/plugin-config-references.d.ts +3 -1
- package/dist/src/utils/plugin-config-references.js +3 -5
- package/dist/src/utils/plugin-config-references.js.map +1 -1
- package/dist/src/utils/plugin-config-write.d.ts +14 -5
- package/dist/src/utils/plugin-config-write.js +213 -117
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +2 -0
- package/dist/src/utils/plugin-config.js.map +1 -1
- package/dist/src/utils/plugin-scripts.d.ts +2 -0
- package/dist/src/utils/plugin-scripts.js +102 -3
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/package.json +3 -3
- package/dist/src/utils/codex-reconciler.d.ts +0 -123
- package/dist/src/utils/codex-reconciler.js +0 -322
- package/dist/src/utils/codex-reconciler.js.map +0 -1
|
@@ -1,38 +1,3 @@
|
|
|
1
|
-
import { isCanonicalCodexMarketplaceRegistration } from '../utils/codex-shared-native.js';
|
|
2
|
-
import { selectAgents } from '../intent/deployment-preferences.js';
|
|
3
|
-
import { resolveActiveConfigPlatforms } from '../utils/config-platforms.js';
|
|
4
|
-
import { configStatusDiagnostics } from '../utils/plugin-config-diagnostics.js';
|
|
5
|
-
import { createScopeContext } from '../intent/scope-context.js';
|
|
6
|
-
import { inspectPortableExtraInstalled } from '../portable/recovery.js';
|
|
7
|
-
import { readDemand, demandNativeProjection } from '../recovery/demand.js';
|
|
8
|
-
import { deriveJointDemand } from '../recovery/joint-demand.js';
|
|
9
|
-
import fs from 'node:fs';
|
|
10
|
-
import path from 'node:path';
|
|
11
|
-
import { analyzeCodexSurface } from '../utils/codex-surface-analysis.js';
|
|
12
|
-
import { catalogSourceErrorCode, sanitizeCatalogSourceError, } from '../utils/catalog-public-error.js';
|
|
13
|
-
import { calculateCatalogSourceIdentity } from '../utils/catalog-source-identity.js';
|
|
14
|
-
import { legacyCanonicalMarketplaceRegistrationNames, inventoryCatalogSourceReferences, inventoryLegacyOwnerReferences, } from '../utils/catalog-source-references.js';
|
|
15
|
-
import { readStrictNamespacedMarketplaceRoot } from '../utils/local-marketplace.js';
|
|
16
|
-
import { readCatalogSourcesConfigSnapshot, resolveCatalogSourceRef } from '../utils/catalog-sources.js';
|
|
17
|
-
import { formatPluginId, parsePluginId, planPluginSelectorSourceIds, withResolvedMultiSourceCatalog, } from '../utils/multi-source-catalog.js';
|
|
18
|
-
import { assertStrictSemVer, checkAwCapabilitySupport, compareStrictSemVer, readPluginManifest, tryParseStrictSemVer, } from '../utils/manifest.js';
|
|
19
|
-
import { resolveCliPackageRoot, resolveCodexPaths } from '../utils/paths.js';
|
|
20
|
-
import { resolveSupportedPlatforms, supportsPlatform } from '../utils/platform-support.js';
|
|
21
|
-
import { parsePlatformValue, parseScopeValue } from './options.js';
|
|
22
|
-
import { inspectCodexPluginRegistrationLive, inspectCodexSharedNativeLive, inspectRebuildTarget, } from './rebuild-integration.js';
|
|
23
|
-
import { createNoopReporter } from '../output/reporter.js';
|
|
24
|
-
import { createNoopDebugLogger } from '../output/debug-log.js';
|
|
25
|
-
import { bindNativeCliRunnerSignal, getDefaultNativeCliRunner } from '../utils/native-cli.js';
|
|
26
|
-
import { createCodexNativeObservationSession, } from '../utils/codex-native-observation.js';
|
|
27
|
-
import { resolveAwHome } from '../utils/paths.js';
|
|
28
|
-
import { codexProjectConfigAliasesUserHome, createProjectLocationKey, getClaudeHome, getCodexHome, resolveAwHomeCanonical, resolveRequiredCanonicalRepoRoot, } from '../utils/state-paths.js';
|
|
29
|
-
import { resolveEffectivePluginConfig, resolveProjectArtifactRenderConfig, } from '../utils/plugin-config.js';
|
|
30
|
-
import { readCodexConfigFile } from '../utils/codex-config.js';
|
|
31
|
-
import { createEmptyNativeDemandView } from '../utils/native-demand.js';
|
|
32
|
-
import { IMPLEMENTED_AW_CAPABILITIES } from './aw-capabilities.js';
|
|
33
|
-
import { createDependencyPlacementPlan } from './dependency-operation-plan.js';
|
|
34
|
-
import { getCodexOperationRequirement } from '../utils/agent-version.js';
|
|
35
|
-
import { inspectSystemCodex, } from '../utils/codex-manager.js';
|
|
36
1
|
export function statusTargetPlacements(target) {
|
|
37
2
|
if (target.platform === 'claude')
|
|
38
3
|
return [target];
|
|
@@ -66,45 +31,6 @@ export function statusTargetHasLiveConfigConsumer(target) {
|
|
|
66
31
|
&& target.components.some((component) => component.kind === 'activation'
|
|
67
32
|
&& component.key === target.scope && component.state === 'enabled'));
|
|
68
33
|
}
|
|
69
|
-
export function projectStatusSharedNativeReasons(sharedNative, existingReasonCodes = [], desiredEnabled = false) {
|
|
70
|
-
if (!sharedNative)
|
|
71
|
-
return [];
|
|
72
|
-
const warning = (code, message) => ({
|
|
73
|
-
code,
|
|
74
|
-
message: `${code}: ${message}`,
|
|
75
|
-
severity: 'warning',
|
|
76
|
-
});
|
|
77
|
-
const blocking = (code, message) => ({
|
|
78
|
-
code,
|
|
79
|
-
message: `${code}: ${message}`,
|
|
80
|
-
severity: 'blocking',
|
|
81
|
-
});
|
|
82
|
-
return [
|
|
83
|
-
...(sharedNative.state === 'blocked' && sharedNative.reason === 'foreign'
|
|
84
|
-
&& !existingReasonCodes.includes('codexSharedNativeForeign')
|
|
85
|
-
? [blocking('codexSharedNativeForeign', `${sharedNative.pluginId} is foreign and was preserved.`)]
|
|
86
|
-
: []),
|
|
87
|
-
...(sharedNative.state === 'blocked' && sharedNative.reason === 'unreadable'
|
|
88
|
-
&& !existingReasonCodes.includes('codexSharedNativeCorrupt')
|
|
89
|
-
? [blocking('codexSharedNativeCorrupt', `${sharedNative.pluginId} is unreadable.`)]
|
|
90
|
-
: []),
|
|
91
|
-
...(sharedNative.state === 'replaceable' && sharedNative.reason === 'damaged'
|
|
92
|
-
? [warning('codexSharedNativeCorrupt', `${sharedNative.pluginId} shared generated content is missing or damaged and can be replaced.`)]
|
|
93
|
-
: []),
|
|
94
|
-
...(sharedNative.state === 'replaceable' && sharedNative.reason === 'outdated'
|
|
95
|
-
? [warning('codexSharedNativeUpdateRequired', `${sharedNative.pluginId} requires a shared update.`)]
|
|
96
|
-
: []),
|
|
97
|
-
...(sharedNative.state === 'replaceable' && sharedNative.reason === 'renderDrift'
|
|
98
|
-
? [warning('codexSharedNativeRenderDrift', `${sharedNative.pluginId} shared generated content does not match the current render inputs and can be replaced.`)]
|
|
99
|
-
: []),
|
|
100
|
-
...(sharedNative.staleCacheObserved
|
|
101
|
-
? [warning('staleCacheObserved', `${sharedNative.pluginId} has non-blocking stale Codex cache residue.`)]
|
|
102
|
-
: []),
|
|
103
|
-
...(sharedNative.state === 'unobserved' && desiredEnabled
|
|
104
|
-
? [warning('codexSharedNativeUnobserved', `${sharedNative.pluginId} was not observed by a compatible Codex consumer.`)]
|
|
105
|
-
: []),
|
|
106
|
-
];
|
|
107
|
-
}
|
|
108
34
|
function statusComponent(target, kind, key) {
|
|
109
35
|
return [...target.components, ...(target.sharedComponents ?? [])].find((component) => component.kind === kind && (key === undefined || component.key === key));
|
|
110
36
|
}
|
|
@@ -219,2816 +145,4 @@ export function statusTargetExtensions(target) {
|
|
|
219
145
|
: [];
|
|
220
146
|
return { state: component.state, kinds };
|
|
221
147
|
}
|
|
222
|
-
function resolveCatalogEntrySupportedPlatforms(policy) {
|
|
223
|
-
return resolveSupportedPlatforms({ marketplace: { policy } });
|
|
224
|
-
}
|
|
225
|
-
let dependencyInspectionHookForTests;
|
|
226
|
-
export function setStatusDependencyInspectionHookForTests(hook) {
|
|
227
|
-
dependencyInspectionHookForTests = hook;
|
|
228
|
-
}
|
|
229
|
-
export async function loadConsoleItemsResult(options = {}, runtime = {}) {
|
|
230
|
-
const result = await statusCommandV8({
|
|
231
|
-
cwd: options.cwd ?? process.cwd(),
|
|
232
|
-
env: runtime.env,
|
|
233
|
-
platform: options.platform,
|
|
234
|
-
scope: options.scope,
|
|
235
|
-
verbose: options.verbose,
|
|
236
|
-
});
|
|
237
|
-
const groups = new Map();
|
|
238
|
-
const summaries = new Map(result.pluginSummaries.map((summary) => [summary.pluginId, summary]));
|
|
239
|
-
for (const target of result.payload.targets) {
|
|
240
|
-
const summary = summaries.get(target.pluginId);
|
|
241
|
-
let pluginSummary;
|
|
242
|
-
if (summary !== undefined) {
|
|
243
|
-
const { pluginName: _pluginName, pluginId: _pluginId, ...projected } = summary;
|
|
244
|
-
pluginSummary = projected;
|
|
245
|
-
}
|
|
246
|
-
const current = groups.get(target.pluginId) ?? {
|
|
247
|
-
pluginName: target.pluginId,
|
|
248
|
-
...(target.version ? { version: target.version } : {}),
|
|
249
|
-
...(pluginSummary ? { pluginSummary } : {}),
|
|
250
|
-
targets: [],
|
|
251
|
-
};
|
|
252
|
-
current.targets.push(...statusTargetPlacements(target));
|
|
253
|
-
groups.set(target.pluginId, current);
|
|
254
|
-
}
|
|
255
|
-
const allSourcesFailed = result.payload.catalog.sources.length > 0
|
|
256
|
-
&& result.payload.catalog.sources.every((source) => source.error !== undefined);
|
|
257
|
-
return {
|
|
258
|
-
items: [...groups.values()].sort((left, right) => left.pluginName.localeCompare(right.pluginName)),
|
|
259
|
-
catalogUnavailable: allSourcesFailed,
|
|
260
|
-
status: result.payload,
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
export async function loadConsoleItems(options = {}, runtime = {}) {
|
|
264
|
-
return (await loadConsoleItemsResult(options, runtime)).items;
|
|
265
|
-
}
|
|
266
|
-
function projectStateInventoryError(error, env, cwd) {
|
|
267
|
-
const sanitized = sanitizeCatalogSourceError(error, env, [
|
|
268
|
-
getCodexHome(env),
|
|
269
|
-
getClaudeHome(env),
|
|
270
|
-
path.resolve(cwd),
|
|
271
|
-
]);
|
|
272
|
-
const native = /(?:Codex|Claude|config\.toml|settings|installed_plugins)/iu.test(sanitized.message);
|
|
273
|
-
const code = native ? 'nativeStateUnreadable' : 'stateInventoryFailed';
|
|
274
|
-
return { code, message: `${code}: ${sanitized.message}`, relevance: { global: true } };
|
|
275
|
-
}
|
|
276
|
-
function inventoryErrorMatchesSelection(options) {
|
|
277
|
-
const relevance = options.error.relevance;
|
|
278
|
-
if (relevance.global)
|
|
279
|
-
return true;
|
|
280
|
-
if (relevance.projectLocationKey
|
|
281
|
-
&& (!options.currentProjectLocationKey
|
|
282
|
-
|| relevance.projectLocationKey !== options.currentProjectLocationKey))
|
|
283
|
-
return false;
|
|
284
|
-
if (options.platformExplicit && relevance.platform
|
|
285
|
-
&& !options.platforms.includes(relevance.platform))
|
|
286
|
-
return false;
|
|
287
|
-
if (options.scopeExplicit && relevance.scope
|
|
288
|
-
&& !options.scopes.includes(relevance.scope))
|
|
289
|
-
return false;
|
|
290
|
-
if (options.selectors.length === 0 || (!relevance.sourceId && !relevance.pluginName))
|
|
291
|
-
return true;
|
|
292
|
-
return options.selectors.some((selector) => (!relevance.pluginName || selector.parsed.pluginName === relevance.pluginName)
|
|
293
|
-
&& (!relevance.sourceId
|
|
294
|
-
|| selector.parsed.sourceId === undefined
|
|
295
|
-
|| selector.parsed.sourceId === relevance.sourceId));
|
|
296
|
-
}
|
|
297
|
-
function finalizeTargetError(error, targetState) {
|
|
298
|
-
return {
|
|
299
|
-
...error,
|
|
300
|
-
severity: error.code === 'artifactCollision'
|
|
301
|
-
|| error.code === 'dependencyGraphInvalid'
|
|
302
|
-
|| (targetState === 'error'
|
|
303
|
-
&& error.dependencyPluginId === undefined)
|
|
304
|
-
? 'blocking'
|
|
305
|
-
: 'warning',
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
function projectTargetError(error, env, cwd, targetState) {
|
|
309
|
-
const sanitized = sanitizeCatalogSourceError(new Error(error.message), env, [
|
|
310
|
-
getCodexHome(env),
|
|
311
|
-
getClaudeHome(env),
|
|
312
|
-
path.resolve(cwd),
|
|
313
|
-
]);
|
|
314
|
-
return finalizeTargetError({ ...error, message: sanitized.message }, targetState);
|
|
315
|
-
}
|
|
316
|
-
function sourceRequestedRef(source, cliVersion) {
|
|
317
|
-
return source.type === 'git' ? resolveCatalogSourceRef(source.refPolicy, cliVersion) : 'path';
|
|
318
|
-
}
|
|
319
|
-
function selectedPlatforms(value) {
|
|
320
|
-
const selection = value === undefined ? 'both' : parsePlatformValue(value);
|
|
321
|
-
if (selection === 'both')
|
|
322
|
-
return ['codex', 'claude'];
|
|
323
|
-
if (selection === 'codex' || selection === 'claude')
|
|
324
|
-
return [selection];
|
|
325
|
-
throw new Error('statusPlatformAdapterRequired: use recovery status for this platform.');
|
|
326
|
-
}
|
|
327
|
-
function selectedScopes(value) {
|
|
328
|
-
return value === undefined ? ['user', 'project'] : [parseScopeValue(value)];
|
|
329
|
-
}
|
|
330
|
-
const emptyIntent = createEmptyNativeDemandView;
|
|
331
|
-
function desiredTargetKey(pluginId, platform) {
|
|
332
|
-
return `${pluginId}\0${platform}`;
|
|
333
|
-
}
|
|
334
|
-
function calculateDesiredTargetStates(options) {
|
|
335
|
-
const desired = new Map();
|
|
336
|
-
const add = (pluginId, platform, scope, relation) => {
|
|
337
|
-
const key = desiredTargetKey(pluginId, platform);
|
|
338
|
-
const current = desired.get(key) ?? { scopes: new Set(), relation: 'none' };
|
|
339
|
-
current.scopes.add(scope);
|
|
340
|
-
if (relation === 'root' || (relation === 'dependency' && current.relation !== 'root')) {
|
|
341
|
-
current.relation = relation;
|
|
342
|
-
}
|
|
343
|
-
desired.set(key, current);
|
|
344
|
-
};
|
|
345
|
-
const byId = new Map(options.available.map((entry) => [
|
|
346
|
-
formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }),
|
|
347
|
-
entry,
|
|
348
|
-
]));
|
|
349
|
-
for (const [scope, intent] of [
|
|
350
|
-
['user', options.userIntent],
|
|
351
|
-
['project', options.projectIntent],
|
|
352
|
-
]) {
|
|
353
|
-
for (const root of intent.roots) {
|
|
354
|
-
for (const platform of root.platforms)
|
|
355
|
-
add(root.pluginId, platform, scope, 'root');
|
|
356
|
-
}
|
|
357
|
-
for (const platform of ['codex', 'claude']) {
|
|
358
|
-
const platformRoots = intent.roots.filter((root) => root.platforms.includes(platform) && byId.has(root.pluginId));
|
|
359
|
-
const closure = new Set();
|
|
360
|
-
const visit = (pluginId) => {
|
|
361
|
-
if (closure.has(pluginId))
|
|
362
|
-
return;
|
|
363
|
-
closure.add(pluginId);
|
|
364
|
-
const entry = byId.get(pluginId);
|
|
365
|
-
if (!entry)
|
|
366
|
-
return;
|
|
367
|
-
for (const dependency of entry.dependencies) {
|
|
368
|
-
visit(formatPluginId({ sourceId: entry.source.id, pluginName: dependency }));
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
for (const root of platformRoots)
|
|
372
|
-
visit(root.pluginId);
|
|
373
|
-
const nodes = [...closure].flatMap((pluginId) => {
|
|
374
|
-
const entry = byId.get(pluginId);
|
|
375
|
-
if (!entry || !entry.targets[platform].user && !entry.targets[platform].project)
|
|
376
|
-
return [];
|
|
377
|
-
const allowedScopes = [
|
|
378
|
-
...(entry.targets[platform].project
|
|
379
|
-
&& (platform !== 'codex' || options.codexProjectAllowed) ? ['project'] : []),
|
|
380
|
-
...(entry.targets[platform].user ? ['user'] : []),
|
|
381
|
-
];
|
|
382
|
-
return allowedScopes.length === 0 ? [] : [{
|
|
383
|
-
pluginId,
|
|
384
|
-
pluginName: entry.name,
|
|
385
|
-
platform,
|
|
386
|
-
relation: platformRoots.some((root) => root.pluginId === pluginId)
|
|
387
|
-
? 'requested'
|
|
388
|
-
: 'dependency',
|
|
389
|
-
depth: platformRoots.some((root) => root.pluginId === pluginId) ? 0 : 1,
|
|
390
|
-
allowedScopes,
|
|
391
|
-
...(scope === 'project'
|
|
392
|
-
&& !platformRoots.some((root) => root.pluginId === pluginId)
|
|
393
|
-
&& entry.states?.[platform]?.user?.state === 'present'
|
|
394
|
-
&& !entry.states[platform]?.user?.errors.some((error) => error.severity === 'blocking')
|
|
395
|
-
? { preferredScope: 'user', preferredScopeReason: 'existingWiderTarget' }
|
|
396
|
-
: {}),
|
|
397
|
-
}];
|
|
398
|
-
});
|
|
399
|
-
const nodeIds = new Set(nodes.map((node) => node.pluginId));
|
|
400
|
-
const roots = platformRoots.flatMap((root) => nodeIds.has(root.pluginId)
|
|
401
|
-
? [{ pluginId: root.pluginId, platform, scope }]
|
|
402
|
-
: []);
|
|
403
|
-
if (roots.length === 0)
|
|
404
|
-
continue;
|
|
405
|
-
const edges = nodes.flatMap((node) => {
|
|
406
|
-
const entry = byId.get(node.pluginId);
|
|
407
|
-
return entry.dependencies.flatMap((dependency) => {
|
|
408
|
-
const dependencyId = formatPluginId({
|
|
409
|
-
sourceId: entry.source.id,
|
|
410
|
-
pluginName: dependency,
|
|
411
|
-
});
|
|
412
|
-
return nodeIds.has(dependencyId)
|
|
413
|
-
? [{ from: node.pluginId, to: dependencyId, platform }]
|
|
414
|
-
: [];
|
|
415
|
-
});
|
|
416
|
-
});
|
|
417
|
-
const plan = createDependencyPlacementPlan({
|
|
418
|
-
requestedPluginIds: roots.map((root) => root.pluginId),
|
|
419
|
-
nodes,
|
|
420
|
-
roots,
|
|
421
|
-
dependencyEdges: edges,
|
|
422
|
-
scopeOverrides: (intent.dependencyScopeOverrides ?? []).filter((override) => nodeIds.has(override.pluginId)
|
|
423
|
-
&& (override.platform === undefined || override.platform === platform)),
|
|
424
|
-
});
|
|
425
|
-
for (const target of plan.targets) {
|
|
426
|
-
add(target.pluginId, target.platform, target.resolvedScope, target.relation === 'requested' ? 'root' : 'dependency');
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
return new Map([...desired].map(([key, value]) => [key, {
|
|
431
|
-
scopes: [...value.scopes].sort(),
|
|
432
|
-
relation: value.relation,
|
|
433
|
-
}]));
|
|
434
|
-
}
|
|
435
|
-
function projectDependencyClosureForTarget(options) {
|
|
436
|
-
const platform = options.platform;
|
|
437
|
-
if (platform !== 'codex' && platform !== 'claude')
|
|
438
|
-
return new Set();
|
|
439
|
-
const byId = new Map(options.available.map((entry) => [
|
|
440
|
-
formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }),
|
|
441
|
-
entry,
|
|
442
|
-
]));
|
|
443
|
-
const closure = new Set();
|
|
444
|
-
const visit = (pluginId) => {
|
|
445
|
-
const entry = byId.get(pluginId);
|
|
446
|
-
if (!entry)
|
|
447
|
-
return;
|
|
448
|
-
for (const dependency of entry.dependencies) {
|
|
449
|
-
const dependencyId = formatPluginId({
|
|
450
|
-
sourceId: entry.source.id,
|
|
451
|
-
pluginName: dependency,
|
|
452
|
-
});
|
|
453
|
-
const dependencyEntry = byId.get(dependencyId);
|
|
454
|
-
if (!dependencyEntry
|
|
455
|
-
|| (!dependencyEntry.targets[platform].user
|
|
456
|
-
&& !dependencyEntry.targets[platform].project)
|
|
457
|
-
|| closure.has(dependencyId)) {
|
|
458
|
-
continue;
|
|
459
|
-
}
|
|
460
|
-
closure.add(dependencyId);
|
|
461
|
-
visit(dependencyId);
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
visit(options.pluginId);
|
|
465
|
-
return closure;
|
|
466
|
-
}
|
|
467
|
-
export function statusRecovery(options) {
|
|
468
|
-
if (options.errorCodes?.includes('removedPluginCleanupRequired')) {
|
|
469
|
-
return [{
|
|
470
|
-
command: 'cleanup',
|
|
471
|
-
description: '整体清理已删除插件在两个平台、用户与当前项目中的安装、设置和遗留记录。',
|
|
472
|
-
}];
|
|
473
|
-
}
|
|
474
|
-
if (options.errorCodes?.some((code) => code === 'codexProjectPluginUnsupported' || code === 'codexSystemCliUnsupported')) {
|
|
475
|
-
return [{
|
|
476
|
-
command: 'manual',
|
|
477
|
-
description: '升级或修复官方 system Codex CLI 后重试原操作。',
|
|
478
|
-
}];
|
|
479
|
-
}
|
|
480
|
-
if (options.errorCodes?.includes('awCapabilityUnsupported')) {
|
|
481
|
-
return [{
|
|
482
|
-
command: 'manual',
|
|
483
|
-
description: '升级 AW CLI 到支持插件所需 capability 的版本后重试。',
|
|
484
|
-
}];
|
|
485
|
-
}
|
|
486
|
-
if (options.errorCodes?.includes('dependencyGraphInvalid')) {
|
|
487
|
-
return [{
|
|
488
|
-
command: 'manual',
|
|
489
|
-
description: '修复 Catalog 中的插件依赖循环后重试。',
|
|
490
|
-
}];
|
|
491
|
-
}
|
|
492
|
-
if (options.state === 'ready' || options.state === 'absent')
|
|
493
|
-
return [];
|
|
494
|
-
if (options.desired.scopes.length === 0
|
|
495
|
-
&& options.sharedNative?.state === 'replaceable'
|
|
496
|
-
&& options.sharedNative.reason === 'damaged') {
|
|
497
|
-
return [
|
|
498
|
-
...(options.actualEnabled ? [{
|
|
499
|
-
command: 'cleanup',
|
|
500
|
-
...(options.scope ? { scope: options.scope } : {}),
|
|
501
|
-
description: `仅清理 ${options.scope ?? '当前'} scope 的激活;不会修复或删除损坏的共享内容。`,
|
|
502
|
-
}] : []),
|
|
503
|
-
{
|
|
504
|
-
command: 'manual',
|
|
505
|
-
description: `共享内容已损坏。先确认本机 Agent 选择,明确 user 或 project 使用范围,再运行 aw plugin install ${options.pluginId} --scope <user|project> 重建。`,
|
|
506
|
-
},
|
|
507
|
-
];
|
|
508
|
-
}
|
|
509
|
-
if (options.state === 'orphaned') {
|
|
510
|
-
return [{ command: 'cleanup', description: '清理可证明属于 AW 的遗留输出。' }];
|
|
511
|
-
}
|
|
512
|
-
if (options.state === 'blocked' && options.errorCodes?.some((code) => code === 'sourceMissing'
|
|
513
|
-
|| code === 'catalogSourceUnavailable'
|
|
514
|
-
|| code === 'bundleUnavailable'
|
|
515
|
-
|| code === 'codexIntentSourceUnavailable')) {
|
|
516
|
-
return [
|
|
517
|
-
{ command: 'sync', description: '来源恢复后同步 desired intent。' },
|
|
518
|
-
{ command: 'cleanup', description: '来源无法恢复时清理可证明属于 AW 的输出。' },
|
|
519
|
-
];
|
|
520
|
-
}
|
|
521
|
-
if (options.state === 'blocked') {
|
|
522
|
-
if (options.desired.scopes.includes('user') && options.desired.scopes.includes('project')) {
|
|
523
|
-
return ['user', 'project'].flatMap((scope) => {
|
|
524
|
-
const retainedScope = scope === 'user' ? 'project' : 'user';
|
|
525
|
-
const retainedRoot = options.conflictRoots?.[retainedScope]?.[0];
|
|
526
|
-
if (!retainedRoot)
|
|
527
|
-
return [];
|
|
528
|
-
return (options.conflictRoots?.[scope] ?? []).map((rootPluginId) => ({
|
|
529
|
-
command: 'uninstall',
|
|
530
|
-
scope,
|
|
531
|
-
description: `运行 aw plugin remove ${rootPluginId} --only requirements --scope ${scope},再运行 aw plugin remove --only outputs ${rootPluginId} --target ${options.platform} --scope ${scope},最后运行 aw plugin sync ${retainedRoot} --target ${options.platform} --context ${retainedScope}。`,
|
|
532
|
-
}));
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
const collision = options.sharedNative?.state === 'blocked'
|
|
536
|
-
? `Codex shared native ${options.sharedNative.pluginId}`
|
|
537
|
-
: `${options.pluginId} 的 foreign extension`;
|
|
538
|
-
return [
|
|
539
|
-
{
|
|
540
|
-
command: 'sync',
|
|
541
|
-
description: `先移除或重命名 ${collision},再运行 aw plugin sync ${options.pluginId} --target ${options.platform} --context ${options.scope ?? 'user'}。cleanup 会保留 foreign 内容,不会删除该冲突。`,
|
|
542
|
-
},
|
|
543
|
-
];
|
|
544
|
-
}
|
|
545
|
-
if (options.dependencyMoves?.length) {
|
|
546
|
-
const rootScope = options.desired.scopes[0] ?? 'project';
|
|
547
|
-
const removeDependencies = options.dependencyMoves.map((move) => `aw plugin remove --only outputs ${move.pluginId} --target ${options.platform} --scope ${move.fromScope}`);
|
|
548
|
-
return [{
|
|
549
|
-
command: 'manual',
|
|
550
|
-
description: `先按依赖保护提示依次移除 ${options.dependencyMoves.map((move) => move.pluginId).join('、')} 的所有直接和间接依赖者;若命令报告 dependencyStillRequired,继续处理提示的其他依赖者。再运行 ${removeDependencies.join(',再运行 ')} 移除依赖旧位置。最后确认本机 Agent 选择,逐个按原 scope 重新添加全部已移除 root,由联合需求重新确定提供位置;当前 root 的示例命令是 aw plugin install ${options.pluginId} --scope ${rootScope}。`,
|
|
551
|
-
}];
|
|
552
|
-
}
|
|
553
|
-
return [{
|
|
554
|
-
command: options.errorCodes?.some((code) => code === 'codexSharedNativeCorrupt'
|
|
555
|
-
|| code === 'codexActivationDrift'
|
|
556
|
-
|| code === 'codexExtensionDrift') ? 'reinstall' : 'sync',
|
|
557
|
-
...(options.desired.scopes.length === 1 ? { scope: options.desired.scopes[0] } : {}),
|
|
558
|
-
description: '同步 desired intent 和当前现场;现场损坏时使用重新安装修复。',
|
|
559
|
-
}];
|
|
560
|
-
}
|
|
561
|
-
function rootIntentsForTarget(options) {
|
|
562
|
-
const byId = new Map(options.available.map((entry) => [
|
|
563
|
-
formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }),
|
|
564
|
-
entry,
|
|
565
|
-
]));
|
|
566
|
-
const result = {};
|
|
567
|
-
for (const [scope, intent] of [
|
|
568
|
-
['user', options.userIntent],
|
|
569
|
-
['project', options.projectIntent],
|
|
570
|
-
]) {
|
|
571
|
-
const roots = intent.roots.filter((root) => {
|
|
572
|
-
if (!root.platforms.includes(options.platform))
|
|
573
|
-
return false;
|
|
574
|
-
const seen = new Set();
|
|
575
|
-
const reaches = (pluginId) => {
|
|
576
|
-
if (pluginId === options.pluginId)
|
|
577
|
-
return true;
|
|
578
|
-
if (seen.has(pluginId))
|
|
579
|
-
return false;
|
|
580
|
-
seen.add(pluginId);
|
|
581
|
-
const entry = byId.get(pluginId);
|
|
582
|
-
return entry?.dependencies.some((dependency) => reaches(formatPluginId({
|
|
583
|
-
sourceId: entry.source.id,
|
|
584
|
-
pluginName: dependency,
|
|
585
|
-
}))) === true;
|
|
586
|
-
};
|
|
587
|
-
return reaches(root.pluginId);
|
|
588
|
-
}).map((root) => root.pluginId).sort();
|
|
589
|
-
if (roots.length > 0)
|
|
590
|
-
result[scope] = roots;
|
|
591
|
-
}
|
|
592
|
-
return result;
|
|
593
|
-
}
|
|
594
|
-
function projectedLiveState(options) {
|
|
595
|
-
if (options.inspection.state === 'error'
|
|
596
|
-
|| options.inspection.components.some((entry) => entry.state === 'error'))
|
|
597
|
-
return 'error';
|
|
598
|
-
const owned = options.inspection.components.filter((entry) => (entry.state === 'present' || entry.state === 'partial'));
|
|
599
|
-
if (owned.length === 0)
|
|
600
|
-
return 'absent';
|
|
601
|
-
if (owned.some((entry) => entry.state === 'partial'))
|
|
602
|
-
return 'partial';
|
|
603
|
-
const required = new Set(options.required);
|
|
604
|
-
const optional = new Set(options.optional);
|
|
605
|
-
if (options.inspection.components.some((entry) => entry.state === 'present' && !required.has(entry.component) && !optional.has(entry.component))) {
|
|
606
|
-
return 'partial';
|
|
607
|
-
}
|
|
608
|
-
if (!options.required.every((component) => options.inspection.components.some((entry) => entry.component === component && entry.state === 'present')))
|
|
609
|
-
return 'partial';
|
|
610
|
-
if (options.required.length > 0)
|
|
611
|
-
return 'present';
|
|
612
|
-
return options.optional.some((component) => options.inspection.components.some((entry) => entry.component === component && entry.state === 'present')) ? 'present' : 'absent';
|
|
613
|
-
}
|
|
614
|
-
export function projectTargetRevision(availableVersion, installedVersion) {
|
|
615
|
-
if (!availableVersion || !installedVersion
|
|
616
|
-
|| !tryParseStrictSemVer(availableVersion)
|
|
617
|
-
|| !tryParseStrictSemVer(installedVersion)) {
|
|
618
|
-
return {
|
|
619
|
-
state: 'unknown',
|
|
620
|
-
...(availableVersion ? { availableVersion } : {}),
|
|
621
|
-
...(installedVersion ? { installedVersion } : {}),
|
|
622
|
-
};
|
|
623
|
-
}
|
|
624
|
-
const relation = compareStrictSemVer(installedVersion, availableVersion);
|
|
625
|
-
if (relation === 0)
|
|
626
|
-
return { state: 'current', availableVersion, installedVersion };
|
|
627
|
-
if (relation < 0)
|
|
628
|
-
return { state: 'upgradeAvailable', availableVersion, installedVersion };
|
|
629
|
-
return { state: 'unknown', availableVersion, installedVersion };
|
|
630
|
-
}
|
|
631
|
-
function renderStatusV8(payload, verbose) {
|
|
632
|
-
const lines = [`Catalog sources: ${payload.catalog.sources.length}`];
|
|
633
|
-
for (const source of payload.catalog.sources) {
|
|
634
|
-
lines.push(`${source.primary ? '*' : '-'} ${source.id}: ${source.error ?? source.freshness ?? 'unavailable'}`);
|
|
635
|
-
}
|
|
636
|
-
for (const target of payload.targets) {
|
|
637
|
-
const reasons = target.reasons.length > 0
|
|
638
|
-
? ` [${target.reasons.map((reason) => reason.message.startsWith(`${reason.code}:`)
|
|
639
|
-
? reason.message : `${reason.code}: ${reason.message}`).join('; ')}]`
|
|
640
|
-
: '';
|
|
641
|
-
if (target.platform === 'claude') {
|
|
642
|
-
lines.push(`${target.pluginId} ${target.platform} (${target.scope}): ${target.state}${reasons}`);
|
|
643
|
-
}
|
|
644
|
-
else {
|
|
645
|
-
lines.push(`${target.pluginId} ${target.platform}: ${target.state}${reasons}`);
|
|
646
|
-
const desiredScopes = target.placements.filter((placement) => placement.components.some((component) => component.kind === 'intent' && component.metadata?.enabled === true))
|
|
647
|
-
.map((placement) => placement.scope);
|
|
648
|
-
const actualScopes = target.placements.filter((placement) => placement.components.some((component) => component.kind === 'activation'
|
|
649
|
-
&& component.key === placement.scope
|
|
650
|
-
&& component.state === 'enabled'))
|
|
651
|
-
.map((placement) => placement.scope);
|
|
652
|
-
const usage = (scopes) => scopes.length === 0
|
|
653
|
-
? 'disabled'
|
|
654
|
-
: scopes.length === 2 ? 'user+project' : scopes[0];
|
|
655
|
-
lines.push(` desired use: ${usage(desiredScopes)}`);
|
|
656
|
-
lines.push(` actual use: ${usage(actualScopes)}`);
|
|
657
|
-
const shared = target.components.find((component) => component.kind === 'sharedNative');
|
|
658
|
-
if (shared)
|
|
659
|
-
lines.push(` shared content: ${shared.state} (${shared.key})`);
|
|
660
|
-
for (const placement of target.placements) {
|
|
661
|
-
lines.push(` ${placement.scope}: ${placement.state}`);
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
if (verbose) {
|
|
665
|
-
for (const component of target.components) {
|
|
666
|
-
lines.push(` component ${component.kind}/${component.key}: ${component.state}`);
|
|
667
|
-
}
|
|
668
|
-
if (target.platform === 'codex') {
|
|
669
|
-
for (const placement of target.placements) {
|
|
670
|
-
lines.push(` placement ${placement.scope}: ${placement.state}`);
|
|
671
|
-
for (const component of placement.components) {
|
|
672
|
-
lines.push(` component ${component.kind}/${component.key}: ${component.state}`);
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
for (const action of target.recoveryActions) {
|
|
677
|
-
lines.push(` recovery ${action.command}: ${action.description}`);
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
for (const issue of payload.configIssues ?? []) {
|
|
682
|
-
lines.push(`Warning: ${issue.pluginId} config ${issue.key} has an unsupported project override; user/default is effective. Unset the project value.`);
|
|
683
|
-
}
|
|
684
|
-
for (const error of payload.errors)
|
|
685
|
-
lines.push(`Error: ${error.message}`);
|
|
686
|
-
return lines.join('\n');
|
|
687
|
-
}
|
|
688
|
-
function collisionMessage(collision) {
|
|
689
|
-
const reason = {
|
|
690
|
-
ownerMismatch: '已有内容属于其他 owner',
|
|
691
|
-
unownedContent: '已有内容没有 AW owner 标记',
|
|
692
|
-
typeMismatch: '已有内容类型与目标不匹配',
|
|
693
|
-
}[collision.reason];
|
|
694
|
-
return `artifactCollision: ${collision.artifactKind} ${collision.artifactKey}: ${reason}。请移除或迁移冲突内容后重试。`;
|
|
695
|
-
}
|
|
696
|
-
function collisionRootIssueId(options) {
|
|
697
|
-
return [
|
|
698
|
-
'artifactCollision',
|
|
699
|
-
options.pluginId,
|
|
700
|
-
options.platform,
|
|
701
|
-
options.scope,
|
|
702
|
-
options.collision.artifactKind,
|
|
703
|
-
options.collision.artifactKey,
|
|
704
|
-
].join(':');
|
|
705
|
-
}
|
|
706
|
-
async function statusCommandV8InSession(options) {
|
|
707
|
-
const throwIfCancelled = (error) => {
|
|
708
|
-
if (error instanceof Error && error.name === 'AbortError')
|
|
709
|
-
throw error;
|
|
710
|
-
options.signal?.throwIfAborted();
|
|
711
|
-
};
|
|
712
|
-
throwIfCancelled();
|
|
713
|
-
const env = options.env ?? process.env;
|
|
714
|
-
const dependencyPluginCache = new Map();
|
|
715
|
-
const dependencyInspectionCache = new Map();
|
|
716
|
-
const cliVersion = options.cliVersion ?? assertStrictSemVer(JSON.parse(fs.readFileSync(path.join(resolveCliPackageRoot(), 'package.json'), 'utf8')).version, 'packages/cli/package.json version');
|
|
717
|
-
const snapshot = await readCatalogSourcesConfigSnapshot(env);
|
|
718
|
-
throwIfCancelled();
|
|
719
|
-
const scope = options.scope === 'project' ? 'project' : 'user';
|
|
720
|
-
const demand = options.recoveryDemand ?? await readDemand({
|
|
721
|
-
scope, cwd: options.cwd, env, catalogOperationContext: options.catalogOperationContext, signal: options.signal,
|
|
722
|
-
});
|
|
723
|
-
throwIfCancelled();
|
|
724
|
-
const observedDemands = new Map([[scope, demand]]);
|
|
725
|
-
if (options.scope !== 'user') {
|
|
726
|
-
const otherScope = scope === 'user' ? 'project' : 'user';
|
|
727
|
-
try {
|
|
728
|
-
observedDemands.set(otherScope, await readDemand({ scope: otherScope, cwd: options.cwd,
|
|
729
|
-
env, catalogOperationContext: options.catalogOperationContext, signal: options.signal }));
|
|
730
|
-
}
|
|
731
|
-
catch (error) {
|
|
732
|
-
throwIfCancelled(error); /* The other scope remains unknown; current scope stays readable. */
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
const selectedPlatformsByScope = new Map();
|
|
736
|
-
for (const [demandScope, scopedDemand] of observedDemands) {
|
|
737
|
-
try {
|
|
738
|
-
selectedPlatformsByScope.set(demandScope, selectAgents({
|
|
739
|
-
preferences: scopedDemand.preferences,
|
|
740
|
-
...(demandScope === scope ? options.recoverySelection : {}),
|
|
741
|
-
}).agents.flatMap((agent) => agent === 'codex' ? ['codex']
|
|
742
|
-
: agent === 'claude' ? ['claude'] : []));
|
|
743
|
-
}
|
|
744
|
-
catch {
|
|
745
|
-
selectedPlatformsByScope.set(demandScope, []);
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
const projectObservationPlatforms = selectedPlatformsByScope.get('project') ?? [];
|
|
749
|
-
const intentErrors = [];
|
|
750
|
-
const readIntent = async (scope) => {
|
|
751
|
-
let observation;
|
|
752
|
-
const scopedDemand = observedDemands.get(scope);
|
|
753
|
-
if (scopedDemand) {
|
|
754
|
-
try {
|
|
755
|
-
const protective = demandNativeProjection(scopedDemand);
|
|
756
|
-
// A protective execution view includes every supported Native platform. Status
|
|
757
|
-
// demand is limited to selected Agents; live residue is observed separately.
|
|
758
|
-
const value = { ...protective, roots: protective.roots.flatMap((root) => {
|
|
759
|
-
const platforms = root.platforms.filter((platform) => selectedPlatformsByScope.get(scope)?.includes(platform));
|
|
760
|
-
return platforms.length ? [{ ...root, platforms }] : [];
|
|
761
|
-
}) };
|
|
762
|
-
observation = scopedDemand.intent.state === 'absent' ? { state: 'absent' }
|
|
763
|
-
: { state: 'ready', value };
|
|
764
|
-
}
|
|
765
|
-
catch {
|
|
766
|
-
observation = { state: 'invalid', code: 'pluginIntentStateInvalid', message: '声明或偏好无效。' };
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
else
|
|
770
|
-
observation = options.scope === 'user' ? { state: 'absent' }
|
|
771
|
-
: { state: 'unavailable', code: 'pluginIntentStateUnavailable', message: '另一范围需求不可读。' };
|
|
772
|
-
if (observation.state === 'invalid') {
|
|
773
|
-
intentErrors.push({
|
|
774
|
-
code: 'pluginIntentStateInvalid',
|
|
775
|
-
message: `pluginIntentStateInvalid: ${scope} plugin intent state is invalid.`,
|
|
776
|
-
});
|
|
777
|
-
}
|
|
778
|
-
return observation;
|
|
779
|
-
};
|
|
780
|
-
const [userIntentObservation, initialProjectIntentObservation] = await Promise.all([
|
|
781
|
-
readIntent('user'),
|
|
782
|
-
readIntent('project'),
|
|
783
|
-
]);
|
|
784
|
-
const userIntent = userIntentObservation.state === 'ready'
|
|
785
|
-
? userIntentObservation.value : emptyIntent();
|
|
786
|
-
let projectIntentObservation = initialProjectIntentObservation;
|
|
787
|
-
let projectIntent = projectIntentObservation.state === 'ready'
|
|
788
|
-
? projectIntentObservation.value : emptyIntent();
|
|
789
|
-
const codexConfigErrors = [];
|
|
790
|
-
const readActivationConfig = async (scope) => {
|
|
791
|
-
try {
|
|
792
|
-
return await readCodexConfigFile(resolveCodexPaths(options.cwd, scope, env).configTomlPath);
|
|
793
|
-
}
|
|
794
|
-
catch {
|
|
795
|
-
codexConfigErrors.push({
|
|
796
|
-
scope,
|
|
797
|
-
code: 'codexActivationDrift',
|
|
798
|
-
message: `codexActivationDrift: ${scope} Codex activation config is unreadable.`,
|
|
799
|
-
});
|
|
800
|
-
return undefined;
|
|
801
|
-
}
|
|
802
|
-
};
|
|
803
|
-
const codexScopePathsAlias = codexProjectConfigAliasesUserHome(options.cwd, env);
|
|
804
|
-
const [userCodexConfig, projectCodexConfig] = await Promise.all([
|
|
805
|
-
readActivationConfig('user'),
|
|
806
|
-
options.scope === 'user' || codexScopePathsAlias ? undefined : readActivationConfig('project'),
|
|
807
|
-
]);
|
|
808
|
-
let projectRoot;
|
|
809
|
-
try {
|
|
810
|
-
projectRoot = await resolveRequiredCanonicalRepoRoot(options.cwd);
|
|
811
|
-
}
|
|
812
|
-
catch (error) {
|
|
813
|
-
if (error instanceof Error && error.name === 'AbortError')
|
|
814
|
-
throw error;
|
|
815
|
-
if (options.scope === 'project') {
|
|
816
|
-
projectIntentObservation = {
|
|
817
|
-
state: 'unavailable', code: 'pluginIntentStateUnavailable',
|
|
818
|
-
message: '无法确定当前项目位置,不能读取插件声明。',
|
|
819
|
-
};
|
|
820
|
-
projectIntent = emptyIntent();
|
|
821
|
-
if (!intentErrors.some((error) => error.message.includes('project plugin intent'))) {
|
|
822
|
-
intentErrors.push({ code: 'pluginIntentStateInvalid',
|
|
823
|
-
message: 'pluginIntentStateInvalid: project plugin intent state is unavailable.' });
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
const currentProjectKey = projectRoot;
|
|
828
|
-
const currentProjectLocationKey = currentProjectKey
|
|
829
|
-
? createProjectLocationKey(currentProjectKey) : undefined;
|
|
830
|
-
const inventoryErrors = [];
|
|
831
|
-
const readInventory = options.inventoryCatalogSourceReferences
|
|
832
|
-
?? inventoryCatalogSourceReferences;
|
|
833
|
-
const ownerInventory = await readInventory({ cwd: options.cwd, env,
|
|
834
|
-
...(options.scope === 'user' ? { scope: 'user' } : { includeProjectAgentSkills: true }) }).catch(async (error) => {
|
|
835
|
-
throwIfCancelled(error);
|
|
836
|
-
inventoryErrors.push(projectStateInventoryError(error, env, options.cwd));
|
|
837
|
-
return inventoryLegacyOwnerReferences({ cwd: options.cwd, env,
|
|
838
|
-
...(options.scope === 'user' ? { scope: 'user' } : { includeProjectAgentSkills: true }) }).catch((fallbackError) => {
|
|
839
|
-
throwIfCancelled(fallbackError);
|
|
840
|
-
inventoryErrors.push(projectStateInventoryError(fallbackError, env, options.cwd));
|
|
841
|
-
return { inventorySchemaVersion: 1, references: [], errors: [] };
|
|
842
|
-
});
|
|
843
|
-
});
|
|
844
|
-
throwIfCancelled();
|
|
845
|
-
for (const error of ownerInventory.errors ?? []) {
|
|
846
|
-
const code = error.kind === 'nativeStateRead' ? 'nativeStateUnreadable' : 'stateInventoryFailed';
|
|
847
|
-
inventoryErrors.push({
|
|
848
|
-
code,
|
|
849
|
-
message: `${code}: ${error.kind}@${error.location}: ${error.message}`,
|
|
850
|
-
relevance: error.relevance,
|
|
851
|
-
});
|
|
852
|
-
}
|
|
853
|
-
const nativeCliRunner = options.nativeCliRunner ?? getDefaultNativeCliRunner();
|
|
854
|
-
let codexSystemConsumerInspection;
|
|
855
|
-
const inspectCodexSystemConsumer = (scope) => {
|
|
856
|
-
throwIfCancelled();
|
|
857
|
-
let inspection = codexSystemConsumerInspection;
|
|
858
|
-
if (!inspection) {
|
|
859
|
-
inspection = inspectSystemCodex({
|
|
860
|
-
runner: nativeCliRunner,
|
|
861
|
-
cwd: options.cwd,
|
|
862
|
-
env,
|
|
863
|
-
signal: options.signal,
|
|
864
|
-
operationRequirement: getCodexOperationRequirement(scope),
|
|
865
|
-
}).then((result) => {
|
|
866
|
-
throwIfCancelled();
|
|
867
|
-
if (result.state === 'compatible') {
|
|
868
|
-
options.codexObservationSession.setManager(result.manager);
|
|
869
|
-
}
|
|
870
|
-
return result;
|
|
871
|
-
});
|
|
872
|
-
codexSystemConsumerInspection = inspection;
|
|
873
|
-
}
|
|
874
|
-
return inspection;
|
|
875
|
-
};
|
|
876
|
-
const codexRegistrationCache = new Map();
|
|
877
|
-
const inspectCodexRegistration = async (pluginId, scope) => {
|
|
878
|
-
const consumer = await inspectCodexSystemConsumer(scope);
|
|
879
|
-
throwIfCancelled();
|
|
880
|
-
if (consumer.state !== 'compatible') {
|
|
881
|
-
return {
|
|
882
|
-
observation: { state: 'unobserved' },
|
|
883
|
-
observations: { user: false, project: false },
|
|
884
|
-
activations: {},
|
|
885
|
-
};
|
|
886
|
-
}
|
|
887
|
-
let inspection = codexRegistrationCache.get(pluginId);
|
|
888
|
-
if (!inspection) {
|
|
889
|
-
inspection = inspectCodexPluginRegistrationLive({
|
|
890
|
-
pluginId,
|
|
891
|
-
cwd: options.cwd,
|
|
892
|
-
env,
|
|
893
|
-
nativeCliRunner,
|
|
894
|
-
manager: consumer.manager,
|
|
895
|
-
scope: options.scope === 'user' ? 'user' : 'both',
|
|
896
|
-
observationSession: options.codexObservationSession,
|
|
897
|
-
});
|
|
898
|
-
codexRegistrationCache.set(pluginId, inspection);
|
|
899
|
-
}
|
|
900
|
-
return inspection;
|
|
901
|
-
};
|
|
902
|
-
const nativeProbeCache = new Map();
|
|
903
|
-
const codexDesiredUserActivationIds = new Set();
|
|
904
|
-
const readOnlyNativeProbe = (probe) => async () => {
|
|
905
|
-
const key = [
|
|
906
|
-
probe.sourceIdentity,
|
|
907
|
-
probe.pluginName,
|
|
908
|
-
probe.platform,
|
|
909
|
-
probe.scope,
|
|
910
|
-
probe.marketplaceName,
|
|
911
|
-
String(probe.desired),
|
|
912
|
-
].join('\0');
|
|
913
|
-
let value = nativeProbeCache.get(key);
|
|
914
|
-
if (!value) {
|
|
915
|
-
const hasLocalResidue = ownerInventory.references.some((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
|
|
916
|
-
&& reference.sourceId === probe.sourceId
|
|
917
|
-
&& reference.pluginName === probe.pluginName
|
|
918
|
-
&& reference.platform === probe.platform);
|
|
919
|
-
value = probe.platform === 'codex'
|
|
920
|
-
? inspectCodexRegistration(`${probe.pluginName}@${probe.marketplaceName}`, options.scope === undefined ? probe.scope : scopes[0]).then((registration) => {
|
|
921
|
-
if (registration.observation.state === 'failed') {
|
|
922
|
-
throw new Error('codexNativeObservationFailed: status requires Codex plugin list evidence.');
|
|
923
|
-
}
|
|
924
|
-
if (registration.observation.state === 'unobserved') {
|
|
925
|
-
return probe.desired || hasLocalResidue ? 'partial' : 'absent';
|
|
926
|
-
}
|
|
927
|
-
if (registration.observation.value === 'absent')
|
|
928
|
-
return 'absent';
|
|
929
|
-
if (!userCodexConfig || (probe.scope === 'project' && !projectCodexConfig)) {
|
|
930
|
-
return 'partial';
|
|
931
|
-
}
|
|
932
|
-
const configEnabled = (probe.scope === 'user'
|
|
933
|
-
? userCodexConfig
|
|
934
|
-
: projectCodexConfig)?.snapshot.plugins[`${probe.pluginName}@${probe.marketplaceName}`]?.enabled === true;
|
|
935
|
-
return configEnabled
|
|
936
|
-
? 'present'
|
|
937
|
-
: 'partial';
|
|
938
|
-
})
|
|
939
|
-
: Promise.resolve(ownerInventory.references.some((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
|
|
940
|
-
&& reference.sourceId === probe.sourceId
|
|
941
|
-
&& reference.sourceIdentity === probe.sourceIdentity
|
|
942
|
-
&& reference.pluginName === probe.pluginName
|
|
943
|
-
&& reference.platform === probe.platform
|
|
944
|
-
&& reference.scope === probe.scope
|
|
945
|
-
&& (probe.scope === 'user' || reference.projectKey === currentProjectKey))
|
|
946
|
-
? 'present'
|
|
947
|
-
: 'absent');
|
|
948
|
-
nativeProbeCache.set(key, value);
|
|
949
|
-
}
|
|
950
|
-
return value;
|
|
951
|
-
};
|
|
952
|
-
const hasCurrentCodexProjectOwner = (sourceId, pluginName) => ownerInventory.references.some((reference) => reference.kind === 'namespacedOwner'
|
|
953
|
-
&& reference.sourceId === sourceId
|
|
954
|
-
&& reference.pluginName === pluginName
|
|
955
|
-
&& reference.platform === 'codex'
|
|
956
|
-
&& reference.scope === 'project'
|
|
957
|
-
&& reference.projectKey === currentProjectKey);
|
|
958
|
-
const configured = new Map(snapshot.config.sources.map((source) => [source.id, source]));
|
|
959
|
-
const requested = options.plugins ?? [];
|
|
960
|
-
const platforms = selectedPlatforms(options.platform);
|
|
961
|
-
const coversPlatform = (value) => (value === 'codex' || value === 'claude') && platforms.includes(value);
|
|
962
|
-
const scopes = selectedScopes(options.scope);
|
|
963
|
-
const installedPortableByScope = new Map();
|
|
964
|
-
for (const scope of scopes) {
|
|
965
|
-
const preferences = observedDemands.get(scope)?.preferences;
|
|
966
|
-
if (preferences?.state !== 'valid' || !preferences.value.targets.includes('generic'))
|
|
967
|
-
continue;
|
|
968
|
-
try {
|
|
969
|
-
const context = await createScopeContext({ scope, cwd: options.cwd, env, readOnly: true });
|
|
970
|
-
try {
|
|
971
|
-
const installed = await inspectPortableExtraInstalled({ scope, context, env: context.env, signal: options.signal });
|
|
972
|
-
installedPortableByScope.set(scope, installed.targets);
|
|
973
|
-
}
|
|
974
|
-
finally {
|
|
975
|
-
await context.dispose();
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
catch (error) {
|
|
979
|
-
throwIfCancelled(error);
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
const userDemand = observedDemands.get('user');
|
|
983
|
-
const projectDemand = observedDemands.get('project');
|
|
984
|
-
const configRequirementKey = (pluginId, scope, target) => `${pluginId}\0${scope}\0${target}`;
|
|
985
|
-
const requiredConfigTargets = new Set(userDemand ? deriveJointDemand({
|
|
986
|
-
context: { context: projectDemand ? 'project' : 'user', cwd: options.cwd,
|
|
987
|
-
scopes: projectDemand ? ['user', 'project'] : ['user'], ...(projectDemand && projectRoot ? { projectRoot } : {}) },
|
|
988
|
-
user: userDemand, project: projectDemand,
|
|
989
|
-
preferences: userDemand.preferences.state === 'valid' ? userDemand.preferences.value : null,
|
|
990
|
-
}).placements.flatMap((placement) => placement.contributions.map((contribution) => configRequirementKey(placement.pluginId, contribution.scope, placement.target))) : []);
|
|
991
|
-
const selectorErrors = [];
|
|
992
|
-
const parsedSelectors = [];
|
|
993
|
-
const plannedSelectors = [];
|
|
994
|
-
const liveOnlySelectors = [];
|
|
995
|
-
for (const selector of requested) {
|
|
996
|
-
let parsed;
|
|
997
|
-
try {
|
|
998
|
-
parsed = parsePluginId(selector);
|
|
999
|
-
}
|
|
1000
|
-
catch (error) {
|
|
1001
|
-
selectorErrors.push({
|
|
1002
|
-
code: 'invalidPluginSelector',
|
|
1003
|
-
message: error instanceof Error ? error.message : String(error),
|
|
1004
|
-
});
|
|
1005
|
-
continue;
|
|
1006
|
-
}
|
|
1007
|
-
parsedSelectors.push({ raw: selector, parsed });
|
|
1008
|
-
if (parsed.sourceId !== undefined && !configured.has(parsed.sourceId)) {
|
|
1009
|
-
const hasLiveReference = ownerInventory.references.some((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
|
|
1010
|
-
&& reference.sourceId === parsed.sourceId
|
|
1011
|
-
&& reference.pluginName === parsed.pluginName
|
|
1012
|
-
&& coversPlatform(reference.platform)
|
|
1013
|
-
&& scopes.includes(reference.scope)
|
|
1014
|
-
&& (reference.scope !== 'project' || reference.projectKey === currentProjectKey));
|
|
1015
|
-
if (hasLiveReference) {
|
|
1016
|
-
liveOnlySelectors.push({ raw: selector, parsed });
|
|
1017
|
-
}
|
|
1018
|
-
else if (!inventoryErrors.some((error) => inventoryErrorMatchesSelection({
|
|
1019
|
-
error,
|
|
1020
|
-
selectors: [{ raw: selector, parsed }],
|
|
1021
|
-
platformExplicit: options.platform !== undefined,
|
|
1022
|
-
scopeExplicit: options.scope !== undefined,
|
|
1023
|
-
platforms,
|
|
1024
|
-
scopes,
|
|
1025
|
-
currentProjectLocationKey,
|
|
1026
|
-
}))) {
|
|
1027
|
-
selectorErrors.push({
|
|
1028
|
-
code: 'pluginNotFound',
|
|
1029
|
-
message: `Plugin "${selector}" was not found because catalog source "${parsed.sourceId}" is not configured.`,
|
|
1030
|
-
});
|
|
1031
|
-
}
|
|
1032
|
-
continue;
|
|
1033
|
-
}
|
|
1034
|
-
plannedSelectors.push({ raw: selector, parsed });
|
|
1035
|
-
}
|
|
1036
|
-
const selectedInventoryErrors = inventoryErrors.filter((error) => inventoryErrorMatchesSelection({
|
|
1037
|
-
error,
|
|
1038
|
-
selectors: parsedSelectors,
|
|
1039
|
-
platformExplicit: options.platform !== undefined,
|
|
1040
|
-
scopeExplicit: options.scope !== undefined,
|
|
1041
|
-
platforms,
|
|
1042
|
-
scopes,
|
|
1043
|
-
currentProjectLocationKey,
|
|
1044
|
-
}));
|
|
1045
|
-
const selectorSourceIds = requested.length === 0
|
|
1046
|
-
? undefined
|
|
1047
|
-
: planPluginSelectorSourceIds(plannedSelectors.map((selector) => selector.parsed));
|
|
1048
|
-
const plannedSourceIds = selectorSourceIds === undefined ? undefined : [...new Set([
|
|
1049
|
-
...selectorSourceIds,
|
|
1050
|
-
...(options.catalogOperationContext ? [] : [...observedDemands.values()].flatMap((entry) => entry.roots ?? []))
|
|
1051
|
-
.map((root) => root.sourceId).filter((id) => configured.has(id)),
|
|
1052
|
-
])];
|
|
1053
|
-
const selectedConfiguredSources = plannedSourceIds === undefined
|
|
1054
|
-
? snapshot.config.sources
|
|
1055
|
-
: plannedSourceIds.map((sourceId) => configured.get(sourceId));
|
|
1056
|
-
const identityEntries = await Promise.all(selectedConfiguredSources.map(async (source) => {
|
|
1057
|
-
try {
|
|
1058
|
-
return [source.id, { identity: await calculateCatalogSourceIdentity(source) }];
|
|
1059
|
-
}
|
|
1060
|
-
catch (error) {
|
|
1061
|
-
const sanitized = sanitizeCatalogSourceError(error, env);
|
|
1062
|
-
return [source.id, {
|
|
1063
|
-
error: sanitized.message,
|
|
1064
|
-
}];
|
|
1065
|
-
}
|
|
1066
|
-
}));
|
|
1067
|
-
const identities = new Map(identityEntries);
|
|
1068
|
-
const catalog = await withResolvedMultiSourceCatalog({
|
|
1069
|
-
cliVersion,
|
|
1070
|
-
configSnapshot: snapshot,
|
|
1071
|
-
...(plannedSourceIds === undefined ? {} : { sourceIds: plannedSourceIds }),
|
|
1072
|
-
...(options.catalogOperationContext
|
|
1073
|
-
? { operationContext: options.catalogOperationContext }
|
|
1074
|
-
: {}),
|
|
1075
|
-
env,
|
|
1076
|
-
signal: options.signal,
|
|
1077
|
-
consume: async (resolution) => ({
|
|
1078
|
-
primarySourceId: resolution.primarySourceId,
|
|
1079
|
-
configDigest: resolution.configDigest,
|
|
1080
|
-
compositeDigest: resolution.compositeDigest,
|
|
1081
|
-
sources: await Promise.all(resolution.sources.map(async (item) => {
|
|
1082
|
-
throwIfCancelled();
|
|
1083
|
-
const source = configured.get(item.sourceId);
|
|
1084
|
-
const identity = identities.get(item.sourceId);
|
|
1085
|
-
const base = {
|
|
1086
|
-
id: item.sourceId,
|
|
1087
|
-
identity: identity.identity ?? 'unavailable',
|
|
1088
|
-
type: source.type,
|
|
1089
|
-
primary: source.primary,
|
|
1090
|
-
requestedRef: item.resolution?.requestedRef ?? sourceRequestedRef(source, cliVersion),
|
|
1091
|
-
};
|
|
1092
|
-
if (identity.error || item.error) {
|
|
1093
|
-
const error = item.error ?? new Error(identity.error);
|
|
1094
|
-
return {
|
|
1095
|
-
...base,
|
|
1096
|
-
error: [identity.error, item.error?.message].filter(Boolean).join('; '),
|
|
1097
|
-
errorCode: catalogSourceErrorCode(error),
|
|
1098
|
-
};
|
|
1099
|
-
}
|
|
1100
|
-
try {
|
|
1101
|
-
const catalogEntriesByName = new Map(item.resolution.manifest.entries.map((entry) => [
|
|
1102
|
-
entry.name,
|
|
1103
|
-
entry,
|
|
1104
|
-
]));
|
|
1105
|
-
const cyclicDependencyPluginNames = new Set();
|
|
1106
|
-
const dependencyVisitState = new Map();
|
|
1107
|
-
const dependencyVisitStack = [];
|
|
1108
|
-
const visitDependencyGraph = (pluginName) => {
|
|
1109
|
-
const state = dependencyVisitState.get(pluginName);
|
|
1110
|
-
if (state === 'visited')
|
|
1111
|
-
return;
|
|
1112
|
-
if (state === 'visiting') {
|
|
1113
|
-
const cycleStart = dependencyVisitStack.lastIndexOf(pluginName);
|
|
1114
|
-
for (const name of dependencyVisitStack.slice(cycleStart)) {
|
|
1115
|
-
cyclicDependencyPluginNames.add(name);
|
|
1116
|
-
}
|
|
1117
|
-
return;
|
|
1118
|
-
}
|
|
1119
|
-
dependencyVisitState.set(pluginName, 'visiting');
|
|
1120
|
-
dependencyVisitStack.push(pluginName);
|
|
1121
|
-
for (const dependencyName of catalogEntriesByName.get(pluginName)?.dependencies ?? []) {
|
|
1122
|
-
if (catalogEntriesByName.has(dependencyName))
|
|
1123
|
-
visitDependencyGraph(dependencyName);
|
|
1124
|
-
}
|
|
1125
|
-
dependencyVisitStack.pop();
|
|
1126
|
-
dependencyVisitState.set(pluginName, 'visited');
|
|
1127
|
-
};
|
|
1128
|
-
for (const pluginName of catalogEntriesByName.keys())
|
|
1129
|
-
visitDependencyGraph(pluginName);
|
|
1130
|
-
const placementEntries = item.resolution.manifest.entries.map((entry) => {
|
|
1131
|
-
const supportedPlatforms = resolveCatalogEntrySupportedPlatforms(entry.policy);
|
|
1132
|
-
return {
|
|
1133
|
-
name: entry.name,
|
|
1134
|
-
dependencies: entry.dependencies,
|
|
1135
|
-
source: { id: item.resolution.sourceId },
|
|
1136
|
-
targets: {
|
|
1137
|
-
codex: {
|
|
1138
|
-
user: supportedPlatforms.has('codex'),
|
|
1139
|
-
project: supportedPlatforms.has('codex'),
|
|
1140
|
-
},
|
|
1141
|
-
claude: {
|
|
1142
|
-
user: supportedPlatforms.has('claude'),
|
|
1143
|
-
project: supportedPlatforms.has('claude'),
|
|
1144
|
-
},
|
|
1145
|
-
},
|
|
1146
|
-
};
|
|
1147
|
-
});
|
|
1148
|
-
const sourceDesired = calculateDesiredTargetStates({
|
|
1149
|
-
userIntent,
|
|
1150
|
-
projectIntent,
|
|
1151
|
-
available: placementEntries,
|
|
1152
|
-
codexProjectAllowed: !codexScopePathsAlias,
|
|
1153
|
-
});
|
|
1154
|
-
const registeredNames = legacyCanonicalMarketplaceRegistrationNames(ownerInventory.references, item.resolution.sourceId);
|
|
1155
|
-
if (registeredNames.length > 1) {
|
|
1156
|
-
throw new Error('marketplaceIdentityUnavailable: Multiple canonical native marketplace registrations match the source.');
|
|
1157
|
-
}
|
|
1158
|
-
const desiredMarketplaceName = registeredNames[0]
|
|
1159
|
-
?? (item.resolution.sourceId === resolution.primarySourceId
|
|
1160
|
-
? 'aw'
|
|
1161
|
-
: `aw-${item.resolution.sourceId}`);
|
|
1162
|
-
for (const entry of placementEntries) {
|
|
1163
|
-
const pluginId = formatPluginId({
|
|
1164
|
-
sourceId: item.resolution.sourceId,
|
|
1165
|
-
pluginName: entry.name,
|
|
1166
|
-
});
|
|
1167
|
-
if (options.scope === 'project'
|
|
1168
|
-
? userCodexConfig?.snapshot.plugins[`${entry.name}@${desiredMarketplaceName}`]?.enabled === true
|
|
1169
|
-
: sourceDesired.get(desiredTargetKey(pluginId, 'codex'))?.scopes.includes('user')) {
|
|
1170
|
-
codexDesiredUserActivationIds.add(`${entry.name}@${desiredMarketplaceName}`);
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
const plugins = await Promise.all(item.resolution.manifest.entries.map(async (entry) => {
|
|
1174
|
-
throwIfCancelled();
|
|
1175
|
-
const capabilitySupport = checkAwCapabilitySupport(entry.requires.aw.capabilities ?? [], IMPLEMENTED_AW_CAPABILITIES);
|
|
1176
|
-
if (!capabilitySupport.supported) {
|
|
1177
|
-
const supportedPlatforms = resolveCatalogEntrySupportedPlatforms(entry.policy);
|
|
1178
|
-
const states = {};
|
|
1179
|
-
const message = `awCapabilityUnsupported: ${item.resolution.sourceId}/${entry.name} requires unsupported AW capabilities: ${capabilitySupport.missing.join(', ')}.`;
|
|
1180
|
-
for (const platform of ['codex', 'claude']) {
|
|
1181
|
-
if (!supportedPlatforms.has(platform))
|
|
1182
|
-
continue;
|
|
1183
|
-
states[platform] = {};
|
|
1184
|
-
for (const scope of ['user', 'project']) {
|
|
1185
|
-
states[platform][scope] = {
|
|
1186
|
-
state: 'error',
|
|
1187
|
-
components: [],
|
|
1188
|
-
errors: [finalizeTargetError({ code: 'awCapabilityUnsupported', message }, 'error')],
|
|
1189
|
-
};
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
return {
|
|
1193
|
-
name: entry.name,
|
|
1194
|
-
version: entry.version,
|
|
1195
|
-
displayName: entry.interface?.displayName ?? entry.name,
|
|
1196
|
-
shortDescription: entry.interface?.shortDescription ?? entry.description,
|
|
1197
|
-
description: entry.description,
|
|
1198
|
-
targets: {
|
|
1199
|
-
claude: {
|
|
1200
|
-
user: supportedPlatforms.has('claude'),
|
|
1201
|
-
project: supportedPlatforms.has('claude'),
|
|
1202
|
-
},
|
|
1203
|
-
codex: {
|
|
1204
|
-
user: supportedPlatforms.has('codex'),
|
|
1205
|
-
project: supportedPlatforms.has('codex'),
|
|
1206
|
-
},
|
|
1207
|
-
},
|
|
1208
|
-
states,
|
|
1209
|
-
dependencies: entry.dependencies,
|
|
1210
|
-
missingCapabilities: capabilitySupport.missing,
|
|
1211
|
-
};
|
|
1212
|
-
}
|
|
1213
|
-
const plugin = await readPluginManifest(path.join(item.resolution.rootDir, 'plugins', entry.name), { mode: 'bundle' });
|
|
1214
|
-
const claude = supportsPlatform(plugin.manifest, 'claude');
|
|
1215
|
-
const codex = supportsPlatform(plugin.manifest, 'codex');
|
|
1216
|
-
const codexSurface = analyzeCodexSurface(plugin.manifest);
|
|
1217
|
-
plugin.sourceId = item.resolution.sourceId;
|
|
1218
|
-
plugin.sourceIdentity = item.resolution.sourceIdentity;
|
|
1219
|
-
plugin.catalogLogicalIdentity = item.resolution.logicalIdentity;
|
|
1220
|
-
plugin.pluginId = formatPluginId({ sourceId: item.resolution.sourceId, pluginName: entry.name });
|
|
1221
|
-
let configIssues;
|
|
1222
|
-
let configDiagnostic;
|
|
1223
|
-
if (plugin.manifest.config) {
|
|
1224
|
-
const issues = new Map();
|
|
1225
|
-
for (const scope of scopes) {
|
|
1226
|
-
const scopedDemand = observedDemands.get(scope);
|
|
1227
|
-
if (!scopedDemand)
|
|
1228
|
-
continue;
|
|
1229
|
-
// Strong preference errors are already reported through demand; never fall back to every platform.
|
|
1230
|
-
if (scopedDemand.preferences.state !== 'valid')
|
|
1231
|
-
continue;
|
|
1232
|
-
const active = resolveActiveConfigPlatforms(plugin.pluginId, plugin.manifest, scopedDemand.preferences);
|
|
1233
|
-
for (const platform of active) {
|
|
1234
|
-
const installed = platform === 'generic'
|
|
1235
|
-
? installedPortableByScope.get(scope)?.some((target) => target.agent === platform && target.pluginId === plugin.pluginId
|
|
1236
|
-
&& target.logicalIdentity === plugin.catalogLogicalIdentity)
|
|
1237
|
-
: ownerInventory.references.some((reference) => reference.platform === platform
|
|
1238
|
-
&& reference.sourceId === plugin.sourceId && reference.pluginName === plugin.manifest.name
|
|
1239
|
-
&& (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
|
|
1240
|
-
&& (!reference.sourceIdentity || reference.sourceIdentity === plugin.sourceIdentity)
|
|
1241
|
-
&& reference.scope === scope && (scope === 'user' || reference.projectKey === currentProjectKey));
|
|
1242
|
-
if (!installed && !requiredConfigTargets.has(configRequirementKey(plugin.pluginId, scope, platform)))
|
|
1243
|
-
continue;
|
|
1244
|
-
try {
|
|
1245
|
-
const resolved = scope === 'project'
|
|
1246
|
-
? await resolveProjectArtifactRenderConfig({
|
|
1247
|
-
sourceId: plugin.sourceId,
|
|
1248
|
-
sourceIdentity: plugin.sourceIdentity,
|
|
1249
|
-
logicalIdentity: plugin.catalogLogicalIdentity,
|
|
1250
|
-
pluginName: plugin.manifest.name,
|
|
1251
|
-
manifest: plugin.manifest,
|
|
1252
|
-
platform,
|
|
1253
|
-
cwd: options.cwd,
|
|
1254
|
-
env,
|
|
1255
|
-
})
|
|
1256
|
-
: await resolveEffectivePluginConfig({
|
|
1257
|
-
sourceId: plugin.sourceId,
|
|
1258
|
-
sourceIdentity: plugin.sourceIdentity,
|
|
1259
|
-
logicalIdentity: plugin.catalogLogicalIdentity,
|
|
1260
|
-
pluginName: plugin.manifest.name,
|
|
1261
|
-
manifest: plugin.manifest,
|
|
1262
|
-
platform,
|
|
1263
|
-
targetScope: 'user',
|
|
1264
|
-
cwd: options.cwd,
|
|
1265
|
-
env,
|
|
1266
|
-
});
|
|
1267
|
-
for (const issue of resolved.issues) {
|
|
1268
|
-
const source = issue.source ?? 'missing';
|
|
1269
|
-
const configIssue = {
|
|
1270
|
-
scope,
|
|
1271
|
-
platform,
|
|
1272
|
-
type: issue.type,
|
|
1273
|
-
key: issue.key,
|
|
1274
|
-
title: resolved.schema[issue.key]?.title ?? issue.key,
|
|
1275
|
-
source,
|
|
1276
|
-
};
|
|
1277
|
-
issues.set(`${platform}\0${scope}\0${configIssue.type}\0${configIssue.key}\0${configIssue.source}`, configIssue);
|
|
1278
|
-
}
|
|
1279
|
-
for (const override of resolved.unsupportedLayerOverrides) {
|
|
1280
|
-
const configIssue = {
|
|
1281
|
-
scope,
|
|
1282
|
-
platform,
|
|
1283
|
-
type: override.type,
|
|
1284
|
-
key: override.key,
|
|
1285
|
-
title: resolved.schema[override.key]?.title ?? override.key,
|
|
1286
|
-
source: override.source,
|
|
1287
|
-
};
|
|
1288
|
-
issues.set(`${platform}\0${scope}\0${configIssue.type}\0${configIssue.key}\0${configIssue.source}`, configIssue);
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
catch (error) {
|
|
1292
|
-
throwIfCancelled(error);
|
|
1293
|
-
configDiagnostic ??= {
|
|
1294
|
-
scope,
|
|
1295
|
-
code: 'configReadFailed',
|
|
1296
|
-
message: '插件设置当前不可读。未读取或显示设置值。',
|
|
1297
|
-
};
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
configIssues = [...issues.values()];
|
|
1302
|
-
}
|
|
1303
|
-
const states = {};
|
|
1304
|
-
const defaultMarketplaceName = item.resolution.sourceId === resolution.primarySourceId
|
|
1305
|
-
? 'aw'
|
|
1306
|
-
: `aw-${item.resolution.sourceId}`;
|
|
1307
|
-
const legacyMarketplaceRoot = path.join(await resolveAwHomeCanonical(env), 'marketplaces', item.resolution.sourceId);
|
|
1308
|
-
const marketplaceNameFor = (pluginName, platform, scope) => {
|
|
1309
|
-
const liveName = ownerInventory.references.find((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
|
|
1310
|
-
&& reference.sourceId === item.resolution.sourceId
|
|
1311
|
-
&& reference.sourceIdentity === item.resolution.sourceIdentity
|
|
1312
|
-
&& reference.pluginName === pluginName
|
|
1313
|
-
&& (reference.kind !== 'namespacedMarketplace' || !reference.marketplaceRoot
|
|
1314
|
-
|| reference.marketplaceRoot === legacyMarketplaceRoot)
|
|
1315
|
-
&& reference.platform === platform
|
|
1316
|
-
&& reference.scope === scope
|
|
1317
|
-
&& (scope === 'user' || reference.projectKey === currentProjectKey)
|
|
1318
|
-
&& reference.marketplaceName)?.marketplaceName;
|
|
1319
|
-
if (liveName)
|
|
1320
|
-
return liveName;
|
|
1321
|
-
const registeredNames = legacyCanonicalMarketplaceRegistrationNames(ownerInventory.references, item.resolution.sourceId);
|
|
1322
|
-
if (registeredNames.length > 1) {
|
|
1323
|
-
throw new Error('marketplaceIdentityUnavailable: Multiple canonical native marketplace registrations match the source.');
|
|
1324
|
-
}
|
|
1325
|
-
return registeredNames[0] ?? defaultMarketplaceName;
|
|
1326
|
-
};
|
|
1327
|
-
const marketplaceRoot = path.join(resolveAwHome(env), 'marketplaces', item.resolution.sourceId);
|
|
1328
|
-
for (const platform of ['codex', 'claude']) {
|
|
1329
|
-
states[platform] = {};
|
|
1330
|
-
for (const scope of ['user', 'project']) {
|
|
1331
|
-
throwIfCancelled();
|
|
1332
|
-
if (platform === 'codex'
|
|
1333
|
-
&& scope === 'project'
|
|
1334
|
-
&& codexScopePathsAlias
|
|
1335
|
-
&& !hasCurrentCodexProjectOwner(item.resolution.sourceId, entry.name))
|
|
1336
|
-
continue;
|
|
1337
|
-
const supported = platform === 'claude'
|
|
1338
|
-
? claude
|
|
1339
|
-
: codex && codexSurface.ok;
|
|
1340
|
-
if (!supported)
|
|
1341
|
-
continue;
|
|
1342
|
-
const changedOwner = ownerInventory.references.find((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
|
|
1343
|
-
&& reference.sourceId === item.resolution.sourceId
|
|
1344
|
-
&& reference.pluginName === entry.name
|
|
1345
|
-
&& reference.platform === platform
|
|
1346
|
-
&& reference.scope === scope
|
|
1347
|
-
&& (scope === 'user' || reference.projectKey === currentProjectKey)
|
|
1348
|
-
&& reference.sourceIdentity
|
|
1349
|
-
&& reference.sourceIdentity !== item.resolution.sourceIdentity);
|
|
1350
|
-
if (changedOwner) {
|
|
1351
|
-
states[platform][scope] = {
|
|
1352
|
-
state: 'error',
|
|
1353
|
-
components: [],
|
|
1354
|
-
errors: [finalizeTargetError({
|
|
1355
|
-
code: 'sourceChanged',
|
|
1356
|
-
message: `sourceChanged: owner at ${changedOwner.location} has a different source identity.`,
|
|
1357
|
-
}, 'error')],
|
|
1358
|
-
};
|
|
1359
|
-
continue;
|
|
1360
|
-
}
|
|
1361
|
-
try {
|
|
1362
|
-
const marketplaceName = marketplaceNameFor(entry.name, platform, scope);
|
|
1363
|
-
const inspected = await inspectRebuildTarget({
|
|
1364
|
-
sourceId: item.resolution.sourceId,
|
|
1365
|
-
sourceIdentity: item.resolution.sourceIdentity,
|
|
1366
|
-
pluginId: plugin.pluginId,
|
|
1367
|
-
marketplaceName,
|
|
1368
|
-
marketplaceRoot,
|
|
1369
|
-
plugin,
|
|
1370
|
-
platform,
|
|
1371
|
-
scope,
|
|
1372
|
-
cwd: options.cwd,
|
|
1373
|
-
catalog: {
|
|
1374
|
-
rootDir: item.resolution.rootDir,
|
|
1375
|
-
source: 'local',
|
|
1376
|
-
},
|
|
1377
|
-
context: {
|
|
1378
|
-
env,
|
|
1379
|
-
nativeCliRunner,
|
|
1380
|
-
reporter: createNoopReporter(),
|
|
1381
|
-
debugLogger: createNoopDebugLogger(),
|
|
1382
|
-
codexObservationSession: options.codexObservationSession,
|
|
1383
|
-
},
|
|
1384
|
-
userActivationDesired: codexDesiredUserActivationIds,
|
|
1385
|
-
nativeProbe: readOnlyNativeProbe({
|
|
1386
|
-
pluginName: entry.name,
|
|
1387
|
-
sourceId: item.resolution.sourceId,
|
|
1388
|
-
sourceIdentity: item.resolution.sourceIdentity,
|
|
1389
|
-
platform,
|
|
1390
|
-
scope,
|
|
1391
|
-
marketplaceName,
|
|
1392
|
-
marketplaceRoot,
|
|
1393
|
-
desired: sourceDesired.get(desiredTargetKey(plugin.pluginId, platform))
|
|
1394
|
-
?.scopes.includes(scope) === true,
|
|
1395
|
-
}),
|
|
1396
|
-
shallow: true,
|
|
1397
|
-
});
|
|
1398
|
-
const liveState = projectedLiveState({
|
|
1399
|
-
inspection: inspected.inspection,
|
|
1400
|
-
required: inspected.target.desiredOwnedComponents ?? inspected.target.ownedComponents,
|
|
1401
|
-
optional: inspected.target.optionalOwnedComponents ?? [],
|
|
1402
|
-
});
|
|
1403
|
-
const collisionErrors = inspected.inspection.components.flatMap((component) => component.collision ? [finalizeTargetError({
|
|
1404
|
-
code: 'artifactCollision',
|
|
1405
|
-
message: collisionMessage(component.collision),
|
|
1406
|
-
collision: component.collision,
|
|
1407
|
-
rootIssueId: collisionRootIssueId({
|
|
1408
|
-
pluginId: formatPluginId({
|
|
1409
|
-
sourceId: item.resolution.sourceId,
|
|
1410
|
-
pluginName: entry.name,
|
|
1411
|
-
}),
|
|
1412
|
-
platform,
|
|
1413
|
-
scope,
|
|
1414
|
-
collision: component.collision,
|
|
1415
|
-
}),
|
|
1416
|
-
rootIssueCode: 'artifactCollision',
|
|
1417
|
-
}, liveState)] : []);
|
|
1418
|
-
const dependencyErrors = [];
|
|
1419
|
-
const dependencyReadiness = [];
|
|
1420
|
-
const directDependencies = plugin.manifest.dependencies ?? [];
|
|
1421
|
-
const desiredInScope = sourceDesired.get(desiredTargetKey(plugin.pluginId, platform))?.scopes.includes(scope) === true;
|
|
1422
|
-
const codexPluginId = `${entry.name}@${marketplaceName}`;
|
|
1423
|
-
const actualCodexActivation = platform === 'codex'
|
|
1424
|
-
&& (scope === 'user' ? userCodexConfig : projectCodexConfig)
|
|
1425
|
-
?.snapshot.plugins[codexPluginId]?.enabled === true;
|
|
1426
|
-
const hasScopedExtensionResidue = platform === 'codex'
|
|
1427
|
-
&& inspected.inspection.components.some((component) => component.component.kind !== 'native-plugin'
|
|
1428
|
-
&& !component.component.identity.artifactKey.startsWith('activation-')
|
|
1429
|
-
&& !component.component.identity.artifactKey.startsWith('marketplace-')
|
|
1430
|
-
&& (component.state !== 'absent' || component.collision !== undefined));
|
|
1431
|
-
const dependencyPriority = {
|
|
1432
|
-
ready: 5,
|
|
1433
|
-
blockedByCollision: 4,
|
|
1434
|
-
incomplete: 3,
|
|
1435
|
-
error: 2,
|
|
1436
|
-
absent: 1,
|
|
1437
|
-
};
|
|
1438
|
-
function dependencyPlacementsFor(dependencyId, consumerScope) {
|
|
1439
|
-
const dependencyOverride = (consumerScope === 'project'
|
|
1440
|
-
? projectIntent
|
|
1441
|
-
: userIntent).dependencyScopeOverrides.find((override) => override.pluginId === dependencyId
|
|
1442
|
-
&& (override.platform === undefined || override.platform === platform));
|
|
1443
|
-
return dependencyOverride
|
|
1444
|
-
? [dependencyOverride.scope]
|
|
1445
|
-
: consumerScope === 'project' ? ['project', 'user'] : ['user'];
|
|
1446
|
-
}
|
|
1447
|
-
async function inspectDependencyAtScope(dependencyName, dependencyScope) {
|
|
1448
|
-
const dependencyId = formatPluginId({
|
|
1449
|
-
sourceId: item.resolution.sourceId,
|
|
1450
|
-
pluginName: dependencyName,
|
|
1451
|
-
});
|
|
1452
|
-
const inspectionCacheKey = [
|
|
1453
|
-
item.resolution.sourceIdentity,
|
|
1454
|
-
dependencyId,
|
|
1455
|
-
platform,
|
|
1456
|
-
dependencyScope,
|
|
1457
|
-
dependencyScope === 'project' ? currentProjectKey : '',
|
|
1458
|
-
].join('\0');
|
|
1459
|
-
if (cyclicDependencyPluginNames.has(dependencyName)) {
|
|
1460
|
-
return {
|
|
1461
|
-
state: 'error',
|
|
1462
|
-
dependencyScope,
|
|
1463
|
-
rootIssueId: `dependencyGraphInvalid:${dependencyId}`,
|
|
1464
|
-
rootIssueCode: 'dependencyGraphInvalid',
|
|
1465
|
-
issuePluginId: dependencyId,
|
|
1466
|
-
issueScope: dependencyScope,
|
|
1467
|
-
};
|
|
1468
|
-
}
|
|
1469
|
-
const cached = dependencyInspectionCache.get(inspectionCacheKey);
|
|
1470
|
-
if (cached)
|
|
1471
|
-
return cached;
|
|
1472
|
-
const inspection = (async () => {
|
|
1473
|
-
const dependencyEntry = item.resolution.manifest.entries.find((candidate) => candidate.name === dependencyName);
|
|
1474
|
-
if (!dependencyEntry) {
|
|
1475
|
-
return {
|
|
1476
|
-
state: 'absent',
|
|
1477
|
-
dependencyScope,
|
|
1478
|
-
rootIssueId: `dependencyMissing:${dependencyId}:${platform}:${dependencyScope}`,
|
|
1479
|
-
rootIssueCode: 'dependencyMissing',
|
|
1480
|
-
issuePluginId: dependencyId,
|
|
1481
|
-
issueScope: dependencyScope,
|
|
1482
|
-
};
|
|
1483
|
-
}
|
|
1484
|
-
const dependencySupport = checkAwCapabilitySupport(dependencyEntry.requires.aw.capabilities ?? [], IMPLEMENTED_AW_CAPABILITIES);
|
|
1485
|
-
if (!dependencySupport.supported) {
|
|
1486
|
-
return {
|
|
1487
|
-
state: 'error',
|
|
1488
|
-
dependencyScope,
|
|
1489
|
-
rootIssueId: `awCapabilityUnsupported:${dependencyId}`,
|
|
1490
|
-
rootIssueCode: 'awCapabilityUnsupported',
|
|
1491
|
-
issuePluginId: dependencyId,
|
|
1492
|
-
issueScope: dependencyScope,
|
|
1493
|
-
missingCapabilities: dependencySupport.missing,
|
|
1494
|
-
};
|
|
1495
|
-
}
|
|
1496
|
-
const pluginCacheKey = [item.resolution.sourceIdentity, dependencyId].join('\0');
|
|
1497
|
-
let dependencyPluginPromise = dependencyPluginCache.get(pluginCacheKey);
|
|
1498
|
-
if (!dependencyPluginPromise) {
|
|
1499
|
-
dependencyPluginPromise = readPluginManifest(path.join(item.resolution.rootDir, 'plugins', dependencyName), { mode: 'bundle' }).then((dependencyPlugin) => {
|
|
1500
|
-
dependencyPlugin.sourceId = item.resolution.sourceId;
|
|
1501
|
-
dependencyPlugin.sourceIdentity = item.resolution.sourceIdentity;
|
|
1502
|
-
dependencyPlugin.catalogLogicalIdentity = item.resolution.logicalIdentity;
|
|
1503
|
-
dependencyPlugin.pluginId = dependencyId;
|
|
1504
|
-
return dependencyPlugin;
|
|
1505
|
-
});
|
|
1506
|
-
dependencyPluginCache.set(pluginCacheKey, dependencyPluginPromise);
|
|
1507
|
-
}
|
|
1508
|
-
const dependencyPlugin = await dependencyPluginPromise;
|
|
1509
|
-
dependencyInspectionHookForTests?.();
|
|
1510
|
-
const dependencyMarketplaceName = marketplaceNameFor(dependencyName, platform, dependencyScope);
|
|
1511
|
-
const dependencyInspected = await inspectRebuildTarget({
|
|
1512
|
-
sourceId: item.resolution.sourceId,
|
|
1513
|
-
sourceIdentity: item.resolution.sourceIdentity,
|
|
1514
|
-
pluginId: dependencyId,
|
|
1515
|
-
marketplaceName: dependencyMarketplaceName,
|
|
1516
|
-
marketplaceRoot,
|
|
1517
|
-
plugin: dependencyPlugin,
|
|
1518
|
-
platform,
|
|
1519
|
-
scope: dependencyScope,
|
|
1520
|
-
cwd: options.cwd,
|
|
1521
|
-
catalog: { rootDir: item.resolution.rootDir, source: 'local' },
|
|
1522
|
-
context: {
|
|
1523
|
-
env,
|
|
1524
|
-
nativeCliRunner,
|
|
1525
|
-
reporter: createNoopReporter(),
|
|
1526
|
-
debugLogger: createNoopDebugLogger(),
|
|
1527
|
-
codexObservationSession: options.codexObservationSession,
|
|
1528
|
-
},
|
|
1529
|
-
userActivationDesired: codexDesiredUserActivationIds,
|
|
1530
|
-
nativeProbe: readOnlyNativeProbe({
|
|
1531
|
-
pluginName: dependencyName,
|
|
1532
|
-
sourceId: item.resolution.sourceId,
|
|
1533
|
-
sourceIdentity: item.resolution.sourceIdentity,
|
|
1534
|
-
platform,
|
|
1535
|
-
scope: dependencyScope,
|
|
1536
|
-
marketplaceName: dependencyMarketplaceName,
|
|
1537
|
-
marketplaceRoot,
|
|
1538
|
-
desired: sourceDesired.get(desiredTargetKey(dependencyId, platform))
|
|
1539
|
-
?.scopes.includes(dependencyScope) === true,
|
|
1540
|
-
}),
|
|
1541
|
-
shallow: true,
|
|
1542
|
-
});
|
|
1543
|
-
const dependencyLiveState = projectedLiveState({
|
|
1544
|
-
inspection: dependencyInspected.inspection,
|
|
1545
|
-
required: dependencyInspected.target.desiredOwnedComponents
|
|
1546
|
-
?? dependencyInspected.target.ownedComponents,
|
|
1547
|
-
optional: dependencyInspected.target.optionalOwnedComponents ?? [],
|
|
1548
|
-
});
|
|
1549
|
-
const collision = dependencyInspected.inspection.components.find((component) => component.collision)?.collision;
|
|
1550
|
-
if (collision) {
|
|
1551
|
-
return {
|
|
1552
|
-
state: 'blockedByCollision',
|
|
1553
|
-
dependencyScope,
|
|
1554
|
-
rootIssueId: collisionRootIssueId({
|
|
1555
|
-
pluginId: dependencyId,
|
|
1556
|
-
platform,
|
|
1557
|
-
scope: dependencyScope,
|
|
1558
|
-
collision,
|
|
1559
|
-
}),
|
|
1560
|
-
rootIssueCode: 'artifactCollision',
|
|
1561
|
-
issuePluginId: dependencyId,
|
|
1562
|
-
issueScope: dependencyScope,
|
|
1563
|
-
};
|
|
1564
|
-
}
|
|
1565
|
-
const requiredDependencyComponents = dependencyInspected.target
|
|
1566
|
-
.desiredOwnedComponents ?? dependencyInspected.target.ownedComponents;
|
|
1567
|
-
const desiredDependency = sourceDesired.get(desiredTargetKey(dependencyId, platform));
|
|
1568
|
-
const projectMigrationPending = dependencyScope === 'project'
|
|
1569
|
-
&& projectIntent.dependencyScopeOverrides.some((override) => override.pluginId === dependencyId
|
|
1570
|
-
&& override.scope === 'project'
|
|
1571
|
-
&& (override.platform === undefined || override.platform === platform))
|
|
1572
|
-
&& desiredDependency?.scopes.includes('project') === true
|
|
1573
|
-
&& desiredDependency.scopes.includes('user') === false
|
|
1574
|
-
&& ownerInventory.references.some((reference) => reference.kind === 'namespacedOwner'
|
|
1575
|
-
&& reference.sourceId === item.resolution.sourceId
|
|
1576
|
-
&& reference.pluginName === dependencyName
|
|
1577
|
-
&& reference.platform === platform
|
|
1578
|
-
&& reference.scope === 'user');
|
|
1579
|
-
const migrationOnlyPartial = dependencyLiveState === 'partial'
|
|
1580
|
-
&& projectMigrationPending
|
|
1581
|
-
&& dependencyInspected.inspection.components.every((component) => component.state === 'present' || component.state === 'absent')
|
|
1582
|
-
&& requiredDependencyComponents.every((required) => dependencyInspected.inspection.components.some((component) => component.component === required
|
|
1583
|
-
&& (component.state === 'present'
|
|
1584
|
-
|| component.state === 'absent'
|
|
1585
|
-
&& component.component.kind !== 'native-plugin'
|
|
1586
|
-
&& 'locator' in component.component
|
|
1587
|
-
&& component.component.locator.kind === 'codex-activation'
|
|
1588
|
-
&& component.component.locator.desired === false)));
|
|
1589
|
-
const effectiveDependencyLiveState = migrationOnlyPartial
|
|
1590
|
-
? 'present'
|
|
1591
|
-
: dependencyLiveState;
|
|
1592
|
-
if (effectiveDependencyLiveState !== 'present') {
|
|
1593
|
-
const state = effectiveDependencyLiveState === 'absent' ? 'absent'
|
|
1594
|
-
: effectiveDependencyLiveState === 'partial' ? 'incomplete'
|
|
1595
|
-
: 'error';
|
|
1596
|
-
return {
|
|
1597
|
-
state,
|
|
1598
|
-
dependencyScope,
|
|
1599
|
-
rootIssueId: state === 'absent'
|
|
1600
|
-
? `dependencyMissing:${dependencyId}:${platform}:${dependencyScope}`
|
|
1601
|
-
: state === 'incomplete'
|
|
1602
|
-
? `incompleteInstallation:${dependencyId}:${platform}:${dependencyScope}`
|
|
1603
|
-
: `diagnostic:${dependencyId}:${platform}:${dependencyScope}`,
|
|
1604
|
-
rootIssueCode: state === 'absent' ? 'dependencyMissing'
|
|
1605
|
-
: state === 'incomplete' ? 'incompleteInstallation' : 'diagnostic',
|
|
1606
|
-
issuePluginId: dependencyId,
|
|
1607
|
-
issueScope: dependencyScope,
|
|
1608
|
-
};
|
|
1609
|
-
}
|
|
1610
|
-
for (const childName of dependencyPlugin.manifest.dependencies ?? []) {
|
|
1611
|
-
const childId = formatPluginId({
|
|
1612
|
-
sourceId: item.resolution.sourceId,
|
|
1613
|
-
pluginName: childName,
|
|
1614
|
-
});
|
|
1615
|
-
let childResult;
|
|
1616
|
-
for (const childScope of dependencyPlacementsFor(childId, dependencyScope)) {
|
|
1617
|
-
const candidate = await inspectDependencyAtScope(childName, childScope);
|
|
1618
|
-
if (candidate.state === 'ready') {
|
|
1619
|
-
childResult = candidate;
|
|
1620
|
-
break;
|
|
1621
|
-
}
|
|
1622
|
-
if (!childResult
|
|
1623
|
-
|| dependencyPriority[candidate.state]
|
|
1624
|
-
> dependencyPriority[childResult.state]) {
|
|
1625
|
-
childResult = candidate;
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
if (childResult?.state !== 'ready') {
|
|
1629
|
-
return {
|
|
1630
|
-
...childResult,
|
|
1631
|
-
dependencyScope,
|
|
1632
|
-
};
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
return { state: 'ready', dependencyScope };
|
|
1636
|
-
})().catch((error) => {
|
|
1637
|
-
throwIfCancelled(error);
|
|
1638
|
-
return {
|
|
1639
|
-
state: 'error',
|
|
1640
|
-
dependencyScope,
|
|
1641
|
-
rootIssueId: `diagnostic:${dependencyId}:${platform}:${dependencyScope}`,
|
|
1642
|
-
rootIssueCode: 'diagnostic',
|
|
1643
|
-
issuePluginId: dependencyId,
|
|
1644
|
-
issueScope: dependencyScope,
|
|
1645
|
-
};
|
|
1646
|
-
});
|
|
1647
|
-
dependencyInspectionCache.set(inspectionCacheKey, inspection);
|
|
1648
|
-
return inspection;
|
|
1649
|
-
}
|
|
1650
|
-
// Inspect dependencies for returned live placements and selected project Agents.
|
|
1651
|
-
const dependencyObservationRequested = platforms.includes(platform) && scopes.includes(scope)
|
|
1652
|
-
|| scope === 'project' && projectObservationPlatforms.includes(platform);
|
|
1653
|
-
if (dependencyObservationRequested && directDependencies.length > 0
|
|
1654
|
-
&& (desiredInScope
|
|
1655
|
-
|| actualCodexActivation
|
|
1656
|
-
|| hasScopedExtensionResidue
|
|
1657
|
-
|| (platform !== 'codex'
|
|
1658
|
-
&& (liveState === 'present' || liveState === 'partial')))) {
|
|
1659
|
-
for (const dependencyName of directDependencies) {
|
|
1660
|
-
const dependencyId = formatPluginId({
|
|
1661
|
-
sourceId: item.resolution.sourceId,
|
|
1662
|
-
pluginName: dependencyName,
|
|
1663
|
-
});
|
|
1664
|
-
const dependencyEntry = item.resolution.manifest.entries.find((candidate) => candidate.name === dependencyName);
|
|
1665
|
-
if (!dependencyEntry) {
|
|
1666
|
-
const rootIssueId = `dependencyMissing:${dependencyId}:${platform}:${scope}`;
|
|
1667
|
-
dependencyReadiness.push({
|
|
1668
|
-
dependencyPluginId: dependencyId,
|
|
1669
|
-
dependencyPlatform: platform,
|
|
1670
|
-
dependencyScope: scope,
|
|
1671
|
-
dependencyProject: scope === 'project' ? 'current' : null,
|
|
1672
|
-
state: 'absent',
|
|
1673
|
-
rootIssueId,
|
|
1674
|
-
rootIssueCode: 'dependencyMissing',
|
|
1675
|
-
});
|
|
1676
|
-
dependencyErrors.push(finalizeTargetError({
|
|
1677
|
-
code: 'dependencyMissing',
|
|
1678
|
-
message: `dependencyMissing: ${dependencyId} is not available in the current source snapshot.`,
|
|
1679
|
-
dependencyPluginId: dependencyId,
|
|
1680
|
-
dependencyPlatform: platform,
|
|
1681
|
-
dependencyScope: scope,
|
|
1682
|
-
dependencyProject: scope === 'project' ? 'current' : null,
|
|
1683
|
-
rootIssueId,
|
|
1684
|
-
rootIssueCode: 'dependencyMissing',
|
|
1685
|
-
}, 'partial'));
|
|
1686
|
-
continue;
|
|
1687
|
-
}
|
|
1688
|
-
const dependencySupport = checkAwCapabilitySupport(dependencyEntry.requires.aw.capabilities ?? [], IMPLEMENTED_AW_CAPABILITIES);
|
|
1689
|
-
if (!dependencySupport.supported) {
|
|
1690
|
-
const rootIssueId = `awCapabilityUnsupported:${dependencyId}`;
|
|
1691
|
-
dependencyReadiness.push({
|
|
1692
|
-
dependencyPluginId: dependencyId,
|
|
1693
|
-
dependencyPlatform: platform,
|
|
1694
|
-
dependencyScope: scope,
|
|
1695
|
-
dependencyProject: scope === 'project' ? 'current' : null,
|
|
1696
|
-
state: 'error',
|
|
1697
|
-
rootIssueId,
|
|
1698
|
-
rootIssueCode: 'awCapabilityUnsupported',
|
|
1699
|
-
});
|
|
1700
|
-
dependencyErrors.push(finalizeTargetError({
|
|
1701
|
-
code: 'awCapabilityUnsupported',
|
|
1702
|
-
message: `awCapabilityUnsupported: ${dependencyId} requires unsupported AW capabilities: ${dependencySupport.missing.join(', ')}.`,
|
|
1703
|
-
dependencyPluginId: dependencyId,
|
|
1704
|
-
dependencyPlatform: platform,
|
|
1705
|
-
dependencyScope: scope,
|
|
1706
|
-
dependencyProject: scope === 'project' ? 'current' : null,
|
|
1707
|
-
rootIssueId,
|
|
1708
|
-
rootIssueCode: 'awCapabilityUnsupported',
|
|
1709
|
-
}, 'partial'));
|
|
1710
|
-
continue;
|
|
1711
|
-
}
|
|
1712
|
-
const placements = dependencyPlacementsFor(dependencyId, scope);
|
|
1713
|
-
let dependencyResult = {
|
|
1714
|
-
state: 'absent',
|
|
1715
|
-
};
|
|
1716
|
-
for (const dependencyScope of placements) {
|
|
1717
|
-
const candidate = await inspectDependencyAtScope(dependencyName, dependencyScope);
|
|
1718
|
-
if (candidate.state === 'ready') {
|
|
1719
|
-
dependencyResult = candidate;
|
|
1720
|
-
break;
|
|
1721
|
-
}
|
|
1722
|
-
const priority = {
|
|
1723
|
-
ready: 5,
|
|
1724
|
-
blockedByCollision: 4,
|
|
1725
|
-
incomplete: 3,
|
|
1726
|
-
error: 2,
|
|
1727
|
-
absent: 1,
|
|
1728
|
-
};
|
|
1729
|
-
if (priority[candidate.state] > priority[dependencyResult.state]) {
|
|
1730
|
-
dependencyResult = candidate;
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
if (dependencyResult.state === 'absent' && !dependencyResult.rootIssueId) {
|
|
1734
|
-
const dependencyScope = dependencyResult.dependencyScope ?? placements[0];
|
|
1735
|
-
dependencyResult = {
|
|
1736
|
-
state: 'absent',
|
|
1737
|
-
dependencyScope,
|
|
1738
|
-
rootIssueId: `dependencyMissing:${dependencyId}:${platform}:${dependencyScope}`,
|
|
1739
|
-
rootIssueCode: 'dependencyMissing',
|
|
1740
|
-
};
|
|
1741
|
-
}
|
|
1742
|
-
const dependencyScope = dependencyResult.dependencyScope ?? placements[0];
|
|
1743
|
-
dependencyReadiness.push({
|
|
1744
|
-
dependencyPluginId: dependencyId,
|
|
1745
|
-
dependencyPlatform: platform,
|
|
1746
|
-
dependencyScope,
|
|
1747
|
-
dependencyProject: dependencyScope === 'project' ? 'current' : null,
|
|
1748
|
-
state: dependencyResult.state,
|
|
1749
|
-
...(dependencyResult.rootIssueId
|
|
1750
|
-
? { rootIssueId: dependencyResult.rootIssueId }
|
|
1751
|
-
: {}),
|
|
1752
|
-
...(dependencyResult.rootIssueCode
|
|
1753
|
-
? { rootIssueCode: dependencyResult.rootIssueCode }
|
|
1754
|
-
: {}),
|
|
1755
|
-
});
|
|
1756
|
-
const issuePluginId = dependencyResult.issuePluginId ?? dependencyId;
|
|
1757
|
-
const issueScope = dependencyResult.issueScope ?? dependencyScope;
|
|
1758
|
-
if (dependencyResult.state === 'absent') {
|
|
1759
|
-
dependencyErrors.push(finalizeTargetError({
|
|
1760
|
-
code: 'dependencyMissing',
|
|
1761
|
-
message: `dependencyMissing: ${issuePluginId} is absent from its required live placement.`,
|
|
1762
|
-
dependencyPluginId: issuePluginId,
|
|
1763
|
-
dependencyPlatform: platform,
|
|
1764
|
-
dependencyScope: issueScope,
|
|
1765
|
-
dependencyProject: issueScope === 'project' ? 'current' : null,
|
|
1766
|
-
rootIssueId: dependencyResult.rootIssueId,
|
|
1767
|
-
rootIssueCode: dependencyResult.rootIssueCode,
|
|
1768
|
-
}, 'partial'));
|
|
1769
|
-
}
|
|
1770
|
-
else if (dependencyResult.state !== 'ready') {
|
|
1771
|
-
const code = dependencyResult.rootIssueCode === 'awCapabilityUnsupported'
|
|
1772
|
-
? 'awCapabilityUnsupported'
|
|
1773
|
-
: dependencyResult.rootIssueCode === 'dependencyGraphInvalid'
|
|
1774
|
-
? 'dependencyGraphInvalid'
|
|
1775
|
-
: 'dependencyNotReady';
|
|
1776
|
-
const message = code === 'awCapabilityUnsupported'
|
|
1777
|
-
? `${code}: ${issuePluginId} requires unsupported AW capabilities: ${(dependencyResult.missingCapabilities ?? []).join(', ')}.`
|
|
1778
|
-
: code === 'dependencyGraphInvalid'
|
|
1779
|
-
? `${code}: dependency cycle includes ${issuePluginId}.`
|
|
1780
|
-
: `${code}: ${issuePluginId} is not ready at its required live placement.`;
|
|
1781
|
-
dependencyErrors.push(finalizeTargetError({
|
|
1782
|
-
code,
|
|
1783
|
-
message,
|
|
1784
|
-
dependencyPluginId: issuePluginId,
|
|
1785
|
-
dependencyPlatform: platform,
|
|
1786
|
-
dependencyScope: issueScope,
|
|
1787
|
-
dependencyProject: issueScope === 'project' ? 'current' : null,
|
|
1788
|
-
...(dependencyResult.rootIssueId
|
|
1789
|
-
? { rootIssueId: dependencyResult.rootIssueId }
|
|
1790
|
-
: {}),
|
|
1791
|
-
...(dependencyResult.rootIssueCode
|
|
1792
|
-
? { rootIssueCode: dependencyResult.rootIssueCode }
|
|
1793
|
-
: {}),
|
|
1794
|
-
}, 'partial'));
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
states[platform][scope] = {
|
|
1799
|
-
state: liveState,
|
|
1800
|
-
errors: [...inspected.inspection.errors.map((error) => projectTargetError({
|
|
1801
|
-
code: 'componentInspectionFailed',
|
|
1802
|
-
message: `${error.label}: ${error.message}`,
|
|
1803
|
-
}, env, options.cwd, liveState)), ...collisionErrors, ...dependencyErrors],
|
|
1804
|
-
...(dependencyReadiness.length > 0 ? { dependencyReadiness } : {}),
|
|
1805
|
-
components: inspected.inspection.components.map((component) => {
|
|
1806
|
-
const projectedError = component.collision
|
|
1807
|
-
? projectTargetError({
|
|
1808
|
-
code: 'artifactCollision',
|
|
1809
|
-
message: collisionMessage(component.collision),
|
|
1810
|
-
collision: component.collision,
|
|
1811
|
-
}, env, options.cwd, liveState)
|
|
1812
|
-
: component.diagnostic
|
|
1813
|
-
? projectTargetError({
|
|
1814
|
-
code: 'componentInspectionFailed',
|
|
1815
|
-
message: component.diagnostic,
|
|
1816
|
-
}, env, options.cwd, liveState)
|
|
1817
|
-
: undefined;
|
|
1818
|
-
return {
|
|
1819
|
-
key: component.component.identity.artifactKey,
|
|
1820
|
-
state: component.state,
|
|
1821
|
-
...(projectedError ? { error: projectedError } : {}),
|
|
1822
|
-
};
|
|
1823
|
-
}),
|
|
1824
|
-
...(inspected.installedVersion
|
|
1825
|
-
? { installedVersion: inspected.installedVersion }
|
|
1826
|
-
: {}),
|
|
1827
|
-
};
|
|
1828
|
-
}
|
|
1829
|
-
catch (error) {
|
|
1830
|
-
throwIfCancelled(error);
|
|
1831
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
1832
|
-
const configErrorCode = platform === 'codex' && codexConfigErrors.length > 0
|
|
1833
|
-
? codexSurface.nativeKinds.length > 0
|
|
1834
|
-
? 'codexSharedNativeCorrupt'
|
|
1835
|
-
: 'codexActivationDrift'
|
|
1836
|
-
: undefined;
|
|
1837
|
-
const code = configErrorCode
|
|
1838
|
-
?? /^([A-Za-z][A-Za-z0-9]*):/u.exec(message)?.[1]
|
|
1839
|
-
?? 'targetInspectionFailed';
|
|
1840
|
-
states[platform][scope] = {
|
|
1841
|
-
state: 'error',
|
|
1842
|
-
components: [],
|
|
1843
|
-
errors: [projectTargetError({
|
|
1844
|
-
code,
|
|
1845
|
-
message: configErrorCode
|
|
1846
|
-
? `${configErrorCode}: Codex activation state is unreadable.`
|
|
1847
|
-
: message,
|
|
1848
|
-
}, env, options.cwd, 'error')],
|
|
1849
|
-
};
|
|
1850
|
-
}
|
|
1851
|
-
}
|
|
1852
|
-
}
|
|
1853
|
-
let codexStatus;
|
|
1854
|
-
if (codex && codexSurface.ok) {
|
|
1855
|
-
const marketplaceName = marketplaceNameFor(entry.name, 'codex', 'user');
|
|
1856
|
-
const codexPluginId = `${entry.name}@${marketplaceName}`;
|
|
1857
|
-
const desiredCodexScopes = sourceDesired.get(desiredTargetKey(formatPluginId({ sourceId: item.resolution.sourceId, pluginName: entry.name }), 'codex'))?.scopes ?? [];
|
|
1858
|
-
const registrationScope = options.scope !== undefined
|
|
1859
|
-
? scopes[0]
|
|
1860
|
-
: desiredCodexScopes.includes('project')
|
|
1861
|
-
? 'project'
|
|
1862
|
-
: desiredCodexScopes.includes('user') ? 'user' : 'project';
|
|
1863
|
-
const pluginRegistration = codexSurface.nativeKinds.length > 0
|
|
1864
|
-
? await inspectCodexRegistration(codexPluginId, registrationScope)
|
|
1865
|
-
: {
|
|
1866
|
-
observation: { state: 'unobserved' },
|
|
1867
|
-
observations: { user: false, project: false },
|
|
1868
|
-
activations: {},
|
|
1869
|
-
};
|
|
1870
|
-
let residueFailed = false;
|
|
1871
|
-
const hasNativeRenderTargets = plugin.manifest.artifacts !== undefined;
|
|
1872
|
-
const sharedInspection = codexSurface.nativeKinds.length > 0
|
|
1873
|
-
? await inspectCodexSharedNativeLive({
|
|
1874
|
-
pluginName: entry.name,
|
|
1875
|
-
sourceId: item.resolution.sourceId,
|
|
1876
|
-
desiredVersion: entry.version,
|
|
1877
|
-
inspectionMode: hasNativeRenderTargets ? 'payload' : 'shallow',
|
|
1878
|
-
cwd: options.cwd,
|
|
1879
|
-
env,
|
|
1880
|
-
marketplaceName,
|
|
1881
|
-
marketplaceRoot,
|
|
1882
|
-
nativeCliRunner,
|
|
1883
|
-
pluginRegistration,
|
|
1884
|
-
...(hasNativeRenderTargets ? { nativeRenderPlugin: plugin } : {}),
|
|
1885
|
-
}).catch((error) => {
|
|
1886
|
-
throwIfCancelled(error);
|
|
1887
|
-
residueFailed = true;
|
|
1888
|
-
return undefined;
|
|
1889
|
-
})
|
|
1890
|
-
: undefined;
|
|
1891
|
-
const nativeState = sharedInspection?.sharedNative;
|
|
1892
|
-
const sharedNative = residueFailed
|
|
1893
|
-
? { pluginId: codexPluginId, state: 'blocked', reason: 'unreadable' }
|
|
1894
|
-
: !nativeState
|
|
1895
|
-
? undefined
|
|
1896
|
-
: nativeState.state === 'unobserved'
|
|
1897
|
-
? {
|
|
1898
|
-
pluginId: codexPluginId,
|
|
1899
|
-
state: 'unobserved',
|
|
1900
|
-
...(nativeState.staleCacheObserved ? { staleCacheObserved: true } : {}),
|
|
1901
|
-
}
|
|
1902
|
-
: nativeState.state === 'missing'
|
|
1903
|
-
? {
|
|
1904
|
-
pluginId: codexPluginId,
|
|
1905
|
-
state: 'missing',
|
|
1906
|
-
...(nativeState.staleCacheObserved ? { staleCacheObserved: true } : {}),
|
|
1907
|
-
}
|
|
1908
|
-
: nativeState.state === 'usable'
|
|
1909
|
-
? {
|
|
1910
|
-
pluginId: codexPluginId,
|
|
1911
|
-
state: 'usable',
|
|
1912
|
-
version: nativeState.version,
|
|
1913
|
-
}
|
|
1914
|
-
: nativeState.state === 'replaceable'
|
|
1915
|
-
? {
|
|
1916
|
-
pluginId: codexPluginId,
|
|
1917
|
-
state: 'replaceable',
|
|
1918
|
-
reason: nativeState.reason,
|
|
1919
|
-
...(nativeState.version ? { version: nativeState.version } : {}),
|
|
1920
|
-
...(nativeState.desiredVersion
|
|
1921
|
-
? { desiredVersion: nativeState.desiredVersion }
|
|
1922
|
-
: {}),
|
|
1923
|
-
...(nativeState.diagnostic ? { diagnostic: nativeState.diagnostic } : {}),
|
|
1924
|
-
}
|
|
1925
|
-
: {
|
|
1926
|
-
pluginId: codexPluginId,
|
|
1927
|
-
state: 'blocked',
|
|
1928
|
-
reason: nativeState.reason,
|
|
1929
|
-
diagnostic: nativeState.diagnostic,
|
|
1930
|
-
};
|
|
1931
|
-
const configuredUserActivation = userCodexConfig
|
|
1932
|
-
?.snapshot.plugins[codexPluginId]?.enabled;
|
|
1933
|
-
const configuredProjectActivation = projectCodexConfig
|
|
1934
|
-
?.snapshot.plugins[codexPluginId]?.enabled;
|
|
1935
|
-
const userActivation = configuredUserActivation;
|
|
1936
|
-
const projectActivation = configuredProjectActivation;
|
|
1937
|
-
const activationObserved = registrationScope === 'project'
|
|
1938
|
-
? userCodexConfig !== undefined && projectCodexConfig !== undefined
|
|
1939
|
-
: userCodexConfig !== undefined;
|
|
1940
|
-
codexStatus = {
|
|
1941
|
-
pluginId: codexPluginId,
|
|
1942
|
-
nativeKinds: codexSurface.nativeKinds,
|
|
1943
|
-
extensionKinds: codexSurface.extensionKinds,
|
|
1944
|
-
...(sharedNative ? { sharedNative } : {}),
|
|
1945
|
-
activation: {
|
|
1946
|
-
...(userActivation !== undefined ? { user: userActivation } : {}),
|
|
1947
|
-
...(projectActivation !== undefined ? { project: projectActivation } : {}),
|
|
1948
|
-
...((userActivation !== undefined || projectActivation !== undefined)
|
|
1949
|
-
? { effective: (projectActivation ?? userActivation) === true }
|
|
1950
|
-
: {}),
|
|
1951
|
-
evidence: activationObserved ? 'observed' : 'assumed',
|
|
1952
|
-
},
|
|
1953
|
-
};
|
|
1954
|
-
}
|
|
1955
|
-
return {
|
|
1956
|
-
name: entry.name,
|
|
1957
|
-
version: entry.version,
|
|
1958
|
-
displayName: plugin.manifest.interface?.displayName ?? entry.name,
|
|
1959
|
-
shortDescription: plugin.manifest.interface?.shortDescription
|
|
1960
|
-
?? plugin.manifest.description,
|
|
1961
|
-
description: plugin.manifest.description,
|
|
1962
|
-
platforms: [...resolveSupportedPlatforms(plugin.manifest)],
|
|
1963
|
-
...(plugin.manifest.config?.fields
|
|
1964
|
-
? { configSchema: plugin.manifest.config.fields }
|
|
1965
|
-
: {}),
|
|
1966
|
-
...(configIssues?.length ? { configIssues } : {}),
|
|
1967
|
-
...(configDiagnostic ? { configDiagnostic } : {}),
|
|
1968
|
-
targets: {
|
|
1969
|
-
claude: { user: claude, project: claude },
|
|
1970
|
-
codex: {
|
|
1971
|
-
user: codex,
|
|
1972
|
-
project: codex
|
|
1973
|
-
&& codexSurface.ok
|
|
1974
|
-
&& codexSurface.classification !== 'empty',
|
|
1975
|
-
},
|
|
1976
|
-
},
|
|
1977
|
-
states,
|
|
1978
|
-
dependencies: plugin.manifest.dependencies ?? [],
|
|
1979
|
-
...(codexStatus ? { codex: codexStatus } : {}),
|
|
1980
|
-
};
|
|
1981
|
-
}));
|
|
1982
|
-
return {
|
|
1983
|
-
...base,
|
|
1984
|
-
resolvedCommit: item.resolution.resolvedCommit,
|
|
1985
|
-
catalogVersion: item.resolution.manifest.catalogVersion,
|
|
1986
|
-
channel: item.resolution.manifest.channel,
|
|
1987
|
-
freshness: 'active',
|
|
1988
|
-
plugins,
|
|
1989
|
-
};
|
|
1990
|
-
}
|
|
1991
|
-
catch (error) {
|
|
1992
|
-
throwIfCancelled(error);
|
|
1993
|
-
const sanitized = sanitizeCatalogSourceError(error, env);
|
|
1994
|
-
return {
|
|
1995
|
-
...base,
|
|
1996
|
-
error: sanitized.message,
|
|
1997
|
-
errorCode: catalogSourceErrorCode(sanitized),
|
|
1998
|
-
};
|
|
1999
|
-
}
|
|
2000
|
-
})),
|
|
2001
|
-
}),
|
|
2002
|
-
});
|
|
2003
|
-
const available = catalog.sources.flatMap((source) => 'plugins' in source
|
|
2004
|
-
? source.plugins.map((plugin) => ({ ...plugin, source }))
|
|
2005
|
-
: []);
|
|
2006
|
-
const removedProjectionReferences = [];
|
|
2007
|
-
for (const source of catalog.sources) {
|
|
2008
|
-
throwIfCancelled();
|
|
2009
|
-
if (!('plugins' in source))
|
|
2010
|
-
continue;
|
|
2011
|
-
const marketplaceRoot = path.join(resolveAwHome(env), 'marketplaces', source.id);
|
|
2012
|
-
try {
|
|
2013
|
-
const root = await readStrictNamespacedMarketplaceRoot({
|
|
2014
|
-
rootDir: marketplaceRoot, sourceId: source.id, sourceIdentity: source.identity,
|
|
2015
|
-
});
|
|
2016
|
-
if (!root)
|
|
2017
|
-
continue;
|
|
2018
|
-
const currentNames = new Set(source.plugins.map((plugin) => plugin.name));
|
|
2019
|
-
const candidates = new Map();
|
|
2020
|
-
const add = (name, platform) => {
|
|
2021
|
-
if (typeof name !== 'string' || currentNames.has(name))
|
|
2022
|
-
return;
|
|
2023
|
-
try {
|
|
2024
|
-
if (parsePluginId(name).sourceId !== undefined)
|
|
2025
|
-
return;
|
|
2026
|
-
}
|
|
2027
|
-
catch {
|
|
2028
|
-
return;
|
|
2029
|
-
}
|
|
2030
|
-
const supported = candidates.get(name) ?? new Set();
|
|
2031
|
-
supported.add(platform);
|
|
2032
|
-
candidates.set(name, supported);
|
|
2033
|
-
};
|
|
2034
|
-
for (const [platform, manifest] of [
|
|
2035
|
-
['codex', root.agentsManifest], ['claude', root.claudeManifest],
|
|
2036
|
-
]) {
|
|
2037
|
-
if (!Array.isArray(manifest?.plugins))
|
|
2038
|
-
continue;
|
|
2039
|
-
for (const plugin of manifest.plugins) {
|
|
2040
|
-
if (plugin && typeof plugin === 'object')
|
|
2041
|
-
add(plugin.name, platform);
|
|
2042
|
-
}
|
|
2043
|
-
}
|
|
2044
|
-
const pluginsRoot = path.join(root.rootDir, 'plugins');
|
|
2045
|
-
const pluginsStats = await fs.promises.lstat(pluginsRoot).catch((error) => {
|
|
2046
|
-
if (error.code === 'ENOENT')
|
|
2047
|
-
return undefined;
|
|
2048
|
-
throw error;
|
|
2049
|
-
});
|
|
2050
|
-
if (pluginsStats && (!pluginsStats.isDirectory() || pluginsStats.isSymbolicLink())) {
|
|
2051
|
-
throw new Error('marketplaceRootInvalid: plugin projection directory is unsafe.');
|
|
2052
|
-
}
|
|
2053
|
-
if (pluginsStats) {
|
|
2054
|
-
for (const entry of await fs.promises.readdir(pluginsRoot, { withFileTypes: true })) {
|
|
2055
|
-
if (!candidates.has(entry.name))
|
|
2056
|
-
add(entry.name, 'codex');
|
|
2057
|
-
}
|
|
2058
|
-
}
|
|
2059
|
-
const registration = userCodexConfig?.snapshot.marketplaces[root.config.marketplaceName];
|
|
2060
|
-
if (platforms.includes('codex')
|
|
2061
|
-
&& isCanonicalCodexMarketplaceRegistration(registration, root.rootDir)
|
|
2062
|
-
&& (await inspectCodexSystemConsumer(options.scope === 'project' ? 'project' : 'user')).state === 'compatible') {
|
|
2063
|
-
const observed = await options.codexObservationSession.snapshot(root.config.marketplaceName, options.scope === 'user' ? 'user' : 'both');
|
|
2064
|
-
const suffix = `@${root.config.marketplaceName}`;
|
|
2065
|
-
for (const pluginId of [...(observed.exact?.keys() ?? []), ...(observed.neutral?.keys() ?? [])]) {
|
|
2066
|
-
if (pluginId.endsWith(suffix))
|
|
2067
|
-
add(pluginId.slice(0, -suffix.length), 'codex');
|
|
2068
|
-
}
|
|
2069
|
-
}
|
|
2070
|
-
for (const [pluginName, supported] of candidates) {
|
|
2071
|
-
for (const platform of supported)
|
|
2072
|
-
removedProjectionReferences.push({
|
|
2073
|
-
kind: 'namespacedMarketplace', location: path.join(root.rootDir, 'config.json'),
|
|
2074
|
-
sourceId: source.id, sourceIdentity: source.identity,
|
|
2075
|
-
marketplaceName: root.config.marketplaceName, pluginName, platform, scope: 'user',
|
|
2076
|
-
});
|
|
2077
|
-
}
|
|
2078
|
-
}
|
|
2079
|
-
catch (error) {
|
|
2080
|
-
throwIfCancelled(error);
|
|
2081
|
-
const projected = projectStateInventoryError(error, env, options.cwd);
|
|
2082
|
-
selectedInventoryErrors.push({ ...projected, relevance: { sourceId: source.id, global: false } });
|
|
2083
|
-
}
|
|
2084
|
-
}
|
|
2085
|
-
const statusReferences = [...ownerInventory.references, ...removedProjectionReferences];
|
|
2086
|
-
const desiredTargetStates = calculateDesiredTargetStates({
|
|
2087
|
-
userIntent,
|
|
2088
|
-
projectIntent,
|
|
2089
|
-
available,
|
|
2090
|
-
codexProjectAllowed: !codexScopePathsAlias,
|
|
2091
|
-
});
|
|
2092
|
-
const failedSourceIds = new Set(catalog.sources.filter((source) => 'error' in source).map((source) => source.id));
|
|
2093
|
-
const selectedById = new Map();
|
|
2094
|
-
if (requested.length === 0) {
|
|
2095
|
-
for (const entry of available) {
|
|
2096
|
-
selectedById.set(formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }), entry);
|
|
2097
|
-
}
|
|
2098
|
-
}
|
|
2099
|
-
else {
|
|
2100
|
-
for (const selector of plannedSelectors) {
|
|
2101
|
-
if (selector.parsed.sourceId === undefined && failedSourceIds.size > 0) {
|
|
2102
|
-
selectorErrors.push({
|
|
2103
|
-
code: 'catalogSourceUnavailable',
|
|
2104
|
-
message: `Cannot resolve bare plugin selector "${selector.raw}" while catalog sources are unavailable: ${[...failedSourceIds].join(', ')}.`,
|
|
2105
|
-
});
|
|
2106
|
-
continue;
|
|
2107
|
-
}
|
|
2108
|
-
if (selector.parsed.sourceId !== undefined && failedSourceIds.has(selector.parsed.sourceId)) {
|
|
2109
|
-
selectorErrors.push({
|
|
2110
|
-
code: 'catalogSourceUnavailable',
|
|
2111
|
-
message: `Cannot resolve plugin selector "${selector.raw}" because catalog source "${selector.parsed.sourceId}" is unavailable.`,
|
|
2112
|
-
});
|
|
2113
|
-
continue;
|
|
2114
|
-
}
|
|
2115
|
-
const matches = available.filter((entry) => entry.name === selector.parsed.pluginName
|
|
2116
|
-
&& (selector.parsed.sourceId === undefined || entry.source.id === selector.parsed.sourceId));
|
|
2117
|
-
if (matches.length === 0) {
|
|
2118
|
-
const selectorHasInventoryError = selectedInventoryErrors.some((error) => inventoryErrorMatchesSelection({
|
|
2119
|
-
error,
|
|
2120
|
-
selectors: [selector],
|
|
2121
|
-
platformExplicit: options.platform !== undefined,
|
|
2122
|
-
scopeExplicit: options.scope !== undefined,
|
|
2123
|
-
platforms,
|
|
2124
|
-
scopes,
|
|
2125
|
-
currentProjectLocationKey,
|
|
2126
|
-
}));
|
|
2127
|
-
const selectorHasLiveOrIntent = statusReferences.some((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
|
|
2128
|
-
&& reference.pluginName === selector.parsed.pluginName
|
|
2129
|
-
&& reference.sourceId !== undefined
|
|
2130
|
-
&& (selector.parsed.sourceId === undefined || reference.sourceId === selector.parsed.sourceId)
|
|
2131
|
-
&& platforms.some((platform) => platform === reference.platform)
|
|
2132
|
-
&& scopes.some((scope) => scope === reference.scope)
|
|
2133
|
-
&& (reference.scope !== 'project' || reference.projectKey === currentProjectKey))
|
|
2134
|
-
|| [userIntent, projectIntent].some((intent, index) => scopes.includes(index === 0 ? 'user' : 'project')
|
|
2135
|
-
&& intent.roots.some((root) => {
|
|
2136
|
-
const parsed = parsePluginId(root.pluginId);
|
|
2137
|
-
return parsed.pluginName === selector.parsed.pluginName
|
|
2138
|
-
&& (selector.parsed.sourceId === undefined || parsed.sourceId === selector.parsed.sourceId)
|
|
2139
|
-
&& root.platforms.some(coversPlatform);
|
|
2140
|
-
}));
|
|
2141
|
-
if (!selectorHasInventoryError && !selectorHasLiveOrIntent) {
|
|
2142
|
-
selectorErrors.push({
|
|
2143
|
-
code: 'pluginNotFound',
|
|
2144
|
-
message: `Plugin "${selector.raw}" was not found in the selected catalog source set.`,
|
|
2145
|
-
});
|
|
2146
|
-
}
|
|
2147
|
-
continue;
|
|
2148
|
-
}
|
|
2149
|
-
if (selector.parsed.sourceId === undefined && matches.length > 1) {
|
|
2150
|
-
selectorErrors.push({
|
|
2151
|
-
code: 'ambiguousPlugin',
|
|
2152
|
-
message: `Plugin "${selector.raw}" is ambiguous across sources: ${matches.map((entry) => entry.source.id).join(', ')}.`,
|
|
2153
|
-
});
|
|
2154
|
-
continue;
|
|
2155
|
-
}
|
|
2156
|
-
for (const entry of matches) {
|
|
2157
|
-
selectedById.set(formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }), entry);
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
const selected = [...selectedById.values()];
|
|
2162
|
-
const explicitTargetFilter = requested.length > 0
|
|
2163
|
-
&& (options.platform !== undefined || options.scope !== undefined);
|
|
2164
|
-
const targets = selected.flatMap((entry) => platforms.flatMap((platform) => scopes.flatMap((scope) => {
|
|
2165
|
-
const target = {
|
|
2166
|
-
pluginName: entry.name,
|
|
2167
|
-
sourceId: entry.source.id,
|
|
2168
|
-
sourceIdentity: entry.source.identity,
|
|
2169
|
-
pluginId: formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }),
|
|
2170
|
-
version: entry.version,
|
|
2171
|
-
platform,
|
|
2172
|
-
scope,
|
|
2173
|
-
cwd: path.resolve(options.cwd),
|
|
2174
|
-
components: [],
|
|
2175
|
-
};
|
|
2176
|
-
if (platform === 'codex'
|
|
2177
|
-
&& scope === 'project'
|
|
2178
|
-
&& codexScopePathsAlias
|
|
2179
|
-
&& !hasCurrentCodexProjectOwner(entry.source.id, entry.name)) {
|
|
2180
|
-
if (options.scope !== 'project')
|
|
2181
|
-
return [];
|
|
2182
|
-
return [{
|
|
2183
|
-
...target,
|
|
2184
|
-
state: 'error',
|
|
2185
|
-
errors: [finalizeTargetError({
|
|
2186
|
-
code: 'codexScopePathAlias',
|
|
2187
|
-
message: 'codexScopePathAlias: Codex project config resolves to the user config directory. Run this command from an actual project directory.',
|
|
2188
|
-
}, 'error')],
|
|
2189
|
-
}];
|
|
2190
|
-
}
|
|
2191
|
-
if (entry.targets[platform][scope]) {
|
|
2192
|
-
const live = entry.states[platform]?.[scope];
|
|
2193
|
-
const dependencyIssueCount = (live?.errors ?? []).filter((error) => error.code.startsWith('dependency')
|
|
2194
|
-
|| error.code === 'awCapabilityUnsupported'
|
|
2195
|
-
|| error.code === 'sourceChanged').length;
|
|
2196
|
-
return [{
|
|
2197
|
-
...target,
|
|
2198
|
-
state: live?.state ?? 'error',
|
|
2199
|
-
components: live?.components ?? [],
|
|
2200
|
-
errors: live?.errors ?? [finalizeTargetError({
|
|
2201
|
-
code: 'targetInspectionFailed',
|
|
2202
|
-
message: `No live inspection result exists for ${entry.source.id}/${entry.name}.`,
|
|
2203
|
-
}, 'error')],
|
|
2204
|
-
...(live?.dependencyReadiness
|
|
2205
|
-
? { dependencyReadiness: live.dependencyReadiness }
|
|
2206
|
-
: {}),
|
|
2207
|
-
...(entry.dependencies.length > 0 || dependencyIssueCount > 0 ? {
|
|
2208
|
-
dependency: {
|
|
2209
|
-
directCount: entry.dependencies.length,
|
|
2210
|
-
issueCount: dependencyIssueCount,
|
|
2211
|
-
},
|
|
2212
|
-
} : {}),
|
|
2213
|
-
}];
|
|
2214
|
-
}
|
|
2215
|
-
const unsupportedLiveReference = ownerInventory.references.find((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
|
|
2216
|
-
&& reference.sourceId === entry.source.id
|
|
2217
|
-
&& reference.pluginName === entry.name
|
|
2218
|
-
&& reference.platform === platform
|
|
2219
|
-
&& reference.scope === scope
|
|
2220
|
-
&& (scope === 'user' || reference.projectKey === currentProjectKey));
|
|
2221
|
-
if (unsupportedLiveReference) {
|
|
2222
|
-
const sourceChanged = Boolean(unsupportedLiveReference.sourceIdentity
|
|
2223
|
-
&& unsupportedLiveReference.sourceIdentity !== entry.source.identity);
|
|
2224
|
-
return [{
|
|
2225
|
-
...target,
|
|
2226
|
-
state: 'error',
|
|
2227
|
-
errors: [finalizeTargetError({
|
|
2228
|
-
code: sourceChanged ? 'sourceChanged' : 'noLongerSupported',
|
|
2229
|
-
message: sourceChanged
|
|
2230
|
-
? `sourceChanged: live state for ${target.pluginId} has a different source identity.`
|
|
2231
|
-
: `noLongerSupported: ${target.pluginId} has live state for ${platform}/${scope}, but the current bundle no longer supports that target.`,
|
|
2232
|
-
}, 'error')],
|
|
2233
|
-
}];
|
|
2234
|
-
}
|
|
2235
|
-
if (!explicitTargetFilter)
|
|
2236
|
-
return [];
|
|
2237
|
-
return [{
|
|
2238
|
-
...target,
|
|
2239
|
-
state: 'error',
|
|
2240
|
-
errors: [finalizeTargetError({
|
|
2241
|
-
code: platform === 'codex' && scope === 'project'
|
|
2242
|
-
? 'codexProjectPluginUnsupported'
|
|
2243
|
-
: 'unsupportedTarget',
|
|
2244
|
-
message: platform === 'codex' && scope === 'project'
|
|
2245
|
-
? `codexProjectPluginUnsupported: ${entry.source.id}/${entry.name} cannot use the current Codex project plugin contract.`
|
|
2246
|
-
: `${entry.source.id}/${entry.name} does not support ${platform}/${scope}.`,
|
|
2247
|
-
}, 'error')],
|
|
2248
|
-
}];
|
|
2249
|
-
})));
|
|
2250
|
-
const referenceSelectors = [...plannedSelectors, ...liveOnlySelectors];
|
|
2251
|
-
const referenceSelected = (reference) => (reference.pluginName !== undefined
|
|
2252
|
-
&& reference.platform !== undefined
|
|
2253
|
-
&& reference.scope !== undefined
|
|
2254
|
-
&& coversPlatform(reference.platform)
|
|
2255
|
-
&& scopes.includes(reference.scope)
|
|
2256
|
-
&& (reference.scope !== 'project' || reference.projectKey === currentProjectKey)
|
|
2257
|
-
&& (requested.length === 0 || referenceSelectors.some((selector) => selector.parsed.pluginName === reference.pluginName
|
|
2258
|
-
&& (selector.parsed.sourceId === undefined || selector.parsed.sourceId === reference.sourceId))));
|
|
2259
|
-
const legacyOwners = ownerInventory.references.filter((reference) => (reference.kind === 'legacyOwner' || reference.kind === 'legacyMarketplace')
|
|
2260
|
-
&& reference.pluginName !== undefined
|
|
2261
|
-
&& reference.platform !== undefined
|
|
2262
|
-
&& reference.scope !== undefined
|
|
2263
|
-
&& coversPlatform(reference.platform)
|
|
2264
|
-
&& scopes.includes(reference.scope)
|
|
2265
|
-
&& (requested.length === 0 || plannedSelectors.some((selector) => selector.parsed.pluginName === reference.pluginName)));
|
|
2266
|
-
const missingSourceOwners = ownerInventory.references.filter((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
|
|
2267
|
-
&& reference.sourceId
|
|
2268
|
-
&& !configured.has(reference.sourceId)
|
|
2269
|
-
&& referenceSelected(reference));
|
|
2270
|
-
const missingTargets = [...new Map(missingSourceOwners.flatMap((reference) => {
|
|
2271
|
-
if (!reference.sourceId || !reference.pluginName
|
|
2272
|
-
|| (reference.platform !== 'codex' && reference.platform !== 'claude')
|
|
2273
|
-
|| (reference.scope !== 'user' && reference.scope !== 'project'))
|
|
2274
|
-
return [];
|
|
2275
|
-
const pluginId = formatPluginId({ sourceId: reference.sourceId, pluginName: reference.pluginName });
|
|
2276
|
-
const target = {
|
|
2277
|
-
pluginName: reference.pluginName,
|
|
2278
|
-
sourceId: reference.sourceId,
|
|
2279
|
-
sourceIdentity: reference.sourceIdentity ?? 'unavailable',
|
|
2280
|
-
pluginId,
|
|
2281
|
-
platform: reference.platform,
|
|
2282
|
-
scope: reference.scope,
|
|
2283
|
-
cwd: path.resolve(options.cwd),
|
|
2284
|
-
state: 'error',
|
|
2285
|
-
components: [],
|
|
2286
|
-
errors: [finalizeTargetError({
|
|
2287
|
-
code: 'sourceMissing',
|
|
2288
|
-
message: `sourceMissing: catalog source "${reference.sourceId}" is not configured for ${pluginId}.`,
|
|
2289
|
-
}, 'error')],
|
|
2290
|
-
};
|
|
2291
|
-
return [[`${pluginId}\0${reference.platform}\0${reference.scope}`, target]];
|
|
2292
|
-
})).values()];
|
|
2293
|
-
targets.push(...missingTargets);
|
|
2294
|
-
const unavailableSourceReferences = ownerInventory.references.filter((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
|
|
2295
|
-
&& reference.sourceId
|
|
2296
|
-
&& configured.has(reference.sourceId)
|
|
2297
|
-
&& failedSourceIds.has(reference.sourceId)
|
|
2298
|
-
&& referenceSelected(reference));
|
|
2299
|
-
const unavailableSourceTargets = [...new Map(unavailableSourceReferences.flatMap((reference) => {
|
|
2300
|
-
if (!reference.sourceId || !reference.pluginName
|
|
2301
|
-
|| (reference.platform !== 'codex' && reference.platform !== 'claude')
|
|
2302
|
-
|| (reference.scope !== 'user' && reference.scope !== 'project'))
|
|
2303
|
-
return [];
|
|
2304
|
-
const pluginId = formatPluginId({ sourceId: reference.sourceId, pluginName: reference.pluginName });
|
|
2305
|
-
const target = {
|
|
2306
|
-
pluginName: reference.pluginName,
|
|
2307
|
-
sourceId: reference.sourceId,
|
|
2308
|
-
sourceIdentity: reference.sourceIdentity ?? 'unavailable',
|
|
2309
|
-
pluginId,
|
|
2310
|
-
platform: reference.platform,
|
|
2311
|
-
scope: reference.scope,
|
|
2312
|
-
cwd: path.resolve(options.cwd),
|
|
2313
|
-
state: 'error',
|
|
2314
|
-
components: [],
|
|
2315
|
-
errors: [finalizeTargetError({
|
|
2316
|
-
code: 'catalogSourceUnavailable',
|
|
2317
|
-
message: `catalogSourceUnavailable: catalog source "${reference.sourceId}" is unavailable for ${pluginId}.`,
|
|
2318
|
-
}, 'error')],
|
|
2319
|
-
};
|
|
2320
|
-
return [[`${pluginId}\0${reference.platform}\0${reference.scope}`, target]];
|
|
2321
|
-
})).values()];
|
|
2322
|
-
targets.push(...unavailableSourceTargets);
|
|
2323
|
-
const availablePluginIds = new Set(available.map((entry) => formatPluginId({ sourceId: entry.source.id, pluginName: entry.name })));
|
|
2324
|
-
const resolvedSourceIds = new Set(catalog.sources.flatMap((source) => 'plugins' in source ? [source.id] : []));
|
|
2325
|
-
const unavailableBundleReferences = statusReferences.filter((reference) => (reference.kind === 'namespacedOwner' || reference.kind === 'namespacedMarketplace')
|
|
2326
|
-
&& reference.sourceId
|
|
2327
|
-
&& configured.has(reference.sourceId)
|
|
2328
|
-
&& resolvedSourceIds.has(reference.sourceId)
|
|
2329
|
-
&& reference.pluginName
|
|
2330
|
-
&& referenceSelected(reference)
|
|
2331
|
-
&& !availablePluginIds.has(formatPluginId({
|
|
2332
|
-
sourceId: reference.sourceId,
|
|
2333
|
-
pluginName: reference.pluginName,
|
|
2334
|
-
})));
|
|
2335
|
-
const unavailableBundleTargets = [...new Map((await Promise.all(unavailableBundleReferences.map(async (reference) => {
|
|
2336
|
-
if (!reference.sourceId || !reference.pluginName
|
|
2337
|
-
|| (reference.platform !== 'codex' && reference.platform !== 'claude')
|
|
2338
|
-
|| (reference.scope !== 'user' && reference.scope !== 'project'))
|
|
2339
|
-
return [];
|
|
2340
|
-
const pluginId = formatPluginId({ sourceId: reference.sourceId, pluginName: reference.pluginName });
|
|
2341
|
-
if (requested.length > 0 && !plannedSelectors.some((selector) => selector.parsed.pluginName === reference.pluginName
|
|
2342
|
-
&& (selector.parsed.sourceId === undefined || selector.parsed.sourceId === reference.sourceId)))
|
|
2343
|
-
return [];
|
|
2344
|
-
const registration = reference.platform === 'codex' && reference.marketplaceName
|
|
2345
|
-
? await inspectCodexRegistration(`${reference.pluginName}@${reference.marketplaceName}`, reference.scope)
|
|
2346
|
-
: undefined;
|
|
2347
|
-
const nativeUnknown = registration && registration.observation.state !== 'observed';
|
|
2348
|
-
const target = {
|
|
2349
|
-
pluginName: reference.pluginName,
|
|
2350
|
-
sourceId: reference.sourceId,
|
|
2351
|
-
sourceIdentity: reference.sourceIdentity ?? 'unavailable',
|
|
2352
|
-
pluginId,
|
|
2353
|
-
platform: reference.platform,
|
|
2354
|
-
scope: reference.scope,
|
|
2355
|
-
cwd: path.resolve(options.cwd),
|
|
2356
|
-
state: 'error',
|
|
2357
|
-
components: registration ? [{
|
|
2358
|
-
key: 'native',
|
|
2359
|
-
state: registration.observation.state !== 'observed' ? 'error'
|
|
2360
|
-
: registration.observation.value === 'installed' ? 'present' : 'absent',
|
|
2361
|
-
}] : [],
|
|
2362
|
-
errors: [finalizeTargetError({
|
|
2363
|
-
code: 'bundleUnavailable',
|
|
2364
|
-
message: `bundleUnavailable: ${pluginId} has live state but is not present in the current source snapshot.`,
|
|
2365
|
-
}, 'error'), finalizeTargetError({
|
|
2366
|
-
code: 'removedPluginCleanupRequired',
|
|
2367
|
-
message: `removedPluginCleanupRequired: ${pluginId} was removed from the current Catalog and has remaining local state.`,
|
|
2368
|
-
}, 'error'), ...(nativeUnknown ? [finalizeTargetError({
|
|
2369
|
-
code: 'codexNativeObservationFailed',
|
|
2370
|
-
message: 'codexNativeObservationFailed: the remaining native installation could not be observed.',
|
|
2371
|
-
}, 'error')] : [])],
|
|
2372
|
-
};
|
|
2373
|
-
return [[`${pluginId}\0${reference.platform}\0${reference.scope}`, target]];
|
|
2374
|
-
}))).flat()).values()];
|
|
2375
|
-
targets.push(...unavailableBundleTargets);
|
|
2376
|
-
const targetKeys = new Set(targets.map((target) => `${target.pluginId}\0${target.platform}\0${target.scope}`));
|
|
2377
|
-
for (const [scope, intent] of [
|
|
2378
|
-
['user', userIntent],
|
|
2379
|
-
['project', projectIntent],
|
|
2380
|
-
]) {
|
|
2381
|
-
for (const root of intent.roots) {
|
|
2382
|
-
const parsed = parsePluginId(root.pluginId);
|
|
2383
|
-
if (!parsed.sourceId)
|
|
2384
|
-
continue;
|
|
2385
|
-
if (requested.length > 0 && !parsedSelectors.some((selector) => selector.parsed.pluginName === parsed.pluginName
|
|
2386
|
-
&& (selector.parsed.sourceId === undefined || selector.parsed.sourceId === parsed.sourceId))) {
|
|
2387
|
-
continue;
|
|
2388
|
-
}
|
|
2389
|
-
for (const platform of root.platforms.filter(coversPlatform)) {
|
|
2390
|
-
if (!scopes.includes(scope))
|
|
2391
|
-
continue;
|
|
2392
|
-
const key = `${root.pluginId}\0${platform}\0${scope}`;
|
|
2393
|
-
if (targetKeys.has(key))
|
|
2394
|
-
continue;
|
|
2395
|
-
targets.push({
|
|
2396
|
-
pluginName: parsed.pluginName,
|
|
2397
|
-
sourceId: parsed.sourceId,
|
|
2398
|
-
sourceIdentity: identities.get(parsed.sourceId)?.identity ?? 'unavailable',
|
|
2399
|
-
pluginId: root.pluginId,
|
|
2400
|
-
platform,
|
|
2401
|
-
scope,
|
|
2402
|
-
cwd: path.resolve(options.cwd),
|
|
2403
|
-
state: 'error',
|
|
2404
|
-
components: [],
|
|
2405
|
-
errors: [finalizeTargetError({
|
|
2406
|
-
code: 'codexIntentSourceUnavailable',
|
|
2407
|
-
message: `codexIntentSourceUnavailable: desired intent for ${root.pluginId} cannot be resolved from the current Catalog.`,
|
|
2408
|
-
}, 'partial')],
|
|
2409
|
-
});
|
|
2410
|
-
targetKeys.add(key);
|
|
2411
|
-
}
|
|
2412
|
-
}
|
|
2413
|
-
}
|
|
2414
|
-
const projectedInventoryErrors = [...new Map(selectedInventoryErrors.map((error) => [
|
|
2415
|
-
`${error.code}\0${error.message}`,
|
|
2416
|
-
{ code: error.code, message: error.message },
|
|
2417
|
-
])).values()];
|
|
2418
|
-
const errors = [
|
|
2419
|
-
...projectedInventoryErrors,
|
|
2420
|
-
...selectorErrors,
|
|
2421
|
-
...intentErrors,
|
|
2422
|
-
...legacyOwners.map((reference) => projectTargetError({
|
|
2423
|
-
code: 'legacyStateUnsupported',
|
|
2424
|
-
message: `legacyStateUnsupported: legacy live ${reference.kind} at ${reference.location}`,
|
|
2425
|
-
}, env, options.cwd, 'error')),
|
|
2426
|
-
];
|
|
2427
|
-
const draftTargets = targets.map((target) => ({
|
|
2428
|
-
...target,
|
|
2429
|
-
errors: target.errors.map((error) => projectTargetError(error, env, options.cwd, target.state)),
|
|
2430
|
-
}));
|
|
2431
|
-
const selectedByPluginId = new Map(selected.map((entry) => [
|
|
2432
|
-
formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }),
|
|
2433
|
-
entry,
|
|
2434
|
-
]));
|
|
2435
|
-
const explicitScope = options.scope === undefined ? undefined : scopes[0];
|
|
2436
|
-
const warning = (code, message) => ({
|
|
2437
|
-
code,
|
|
2438
|
-
message: `${code}: ${message}`,
|
|
2439
|
-
severity: 'warning',
|
|
2440
|
-
});
|
|
2441
|
-
const blocking = (code, message) => ({
|
|
2442
|
-
code,
|
|
2443
|
-
message: `${code}: ${message}`,
|
|
2444
|
-
severity: 'blocking',
|
|
2445
|
-
});
|
|
2446
|
-
const decorateTarget = async (target, groupedScopes, groupedTargets) => {
|
|
2447
|
-
const entry = selectedByPluginId.get(target.pluginId);
|
|
2448
|
-
const codex = target.platform === 'codex' ? entry?.codex : undefined;
|
|
2449
|
-
const desiredAll = desiredTargetStates.get(desiredTargetKey(target.pluginId, target.platform))
|
|
2450
|
-
?? { scopes: [], relation: 'none' };
|
|
2451
|
-
const desired = {
|
|
2452
|
-
scopes: desiredAll.scopes.includes(target.scope) ? [target.scope] : [],
|
|
2453
|
-
relation: desiredAll.relation,
|
|
2454
|
-
};
|
|
2455
|
-
const sharedNative = codex?.sharedNative ?? target.sharedNative;
|
|
2456
|
-
const baseActivation = codex?.activation ?? target.activation;
|
|
2457
|
-
const consumerScope = desired.scopes.includes('project')
|
|
2458
|
-
? 'project'
|
|
2459
|
-
: desired.scopes.includes('user')
|
|
2460
|
-
? 'user'
|
|
2461
|
-
: explicitScope ?? (groupedScopes.includes('project') ? 'project' : 'user');
|
|
2462
|
-
const inspectSystemConsumer = target.platform === 'codex'
|
|
2463
|
-
&& baseActivation !== undefined
|
|
2464
|
-
&& ((codex?.nativeKinds.length ?? 0) > 0 || target.sharedNative !== undefined);
|
|
2465
|
-
const systemConsumer = inspectSystemConsumer
|
|
2466
|
-
? await inspectCodexSystemConsumer(consumerScope)
|
|
2467
|
-
: undefined;
|
|
2468
|
-
const activation = baseActivation && systemConsumer
|
|
2469
|
-
? {
|
|
2470
|
-
...baseActivation,
|
|
2471
|
-
evidence: systemConsumer.state === 'compatible'
|
|
2472
|
-
? 'observed'
|
|
2473
|
-
: systemConsumer.state === 'missing' ? 'assumed' : 'unobserved',
|
|
2474
|
-
systemConsumer,
|
|
2475
|
-
}
|
|
2476
|
-
: baseActivation;
|
|
2477
|
-
const observationScopes = [target.scope];
|
|
2478
|
-
const scopedTargets = groupedTargets.filter((candidate) => observationScopes.includes(candidate.scope));
|
|
2479
|
-
const observedTargets = scopedTargets.length > 0 ? scopedTargets : groupedTargets;
|
|
2480
|
-
const ownershipState = observedTargets.some((candidate) => candidate.state === 'error')
|
|
2481
|
-
? 'error'
|
|
2482
|
-
: observedTargets.some((candidate) => candidate.state === 'partial')
|
|
2483
|
-
? 'partial'
|
|
2484
|
-
: observedTargets.some((candidate) => candidate.state === 'present')
|
|
2485
|
-
? 'present'
|
|
2486
|
-
: sharedNative?.staleCacheObserved
|
|
2487
|
-
? 'partial'
|
|
2488
|
-
: 'absent';
|
|
2489
|
-
const actualScopeEnabled = target.platform === 'codex'
|
|
2490
|
-
&& baseActivation?.[target.scope] === true;
|
|
2491
|
-
const hasSourceError = observedTargets.some((candidate) => candidate.errors.some((error) => error.code === 'sourceMissing'
|
|
2492
|
-
|| error.code === 'catalogSourceUnavailable'
|
|
2493
|
-
|| error.code === 'bundleUnavailable'
|
|
2494
|
-
|| error.code === 'codexIntentSourceUnavailable'));
|
|
2495
|
-
const desiredOverlapConflict = target.platform === 'codex'
|
|
2496
|
-
&& (codex?.extensionKinds.length ?? 0) > 0
|
|
2497
|
-
&& desired.scopes.includes('user')
|
|
2498
|
-
&& desired.scopes.includes('project');
|
|
2499
|
-
const expectedEnabled = desired.scopes.includes(target.scope);
|
|
2500
|
-
const inheritedUserActivation = target.platform === 'codex'
|
|
2501
|
-
&& target.scope === 'project'
|
|
2502
|
-
&& !expectedEnabled
|
|
2503
|
-
&& desiredAll.scopes.includes('user')
|
|
2504
|
-
&& activation?.user === true
|
|
2505
|
-
&& (codex?.nativeKinds.length ?? 0) > 0;
|
|
2506
|
-
const projectDisablesUserActivation = inheritedUserActivation && activation?.project === false;
|
|
2507
|
-
const redundantProjectActivation = inheritedUserActivation && activation?.project === true
|
|
2508
|
-
&& (codex?.extensionKinds.length ?? 0) === 0;
|
|
2509
|
-
const activationDrift = target.platform === 'codex'
|
|
2510
|
-
&& (codexConfigErrors.some((error) => error.scope === 'user' || observationScopes.includes(error.scope))
|
|
2511
|
-
|| ((codex?.nativeKinds.length ?? 0) > 0
|
|
2512
|
-
&& (expectedEnabled && activation?.[target.scope] !== true
|
|
2513
|
-
|| !expectedEnabled && activation?.[target.scope] === true && !redundantProjectActivation
|
|
2514
|
-
|| projectDisablesUserActivation)));
|
|
2515
|
-
const extensionComponents = observedTargets.flatMap((candidate) => candidate.components).filter((component) => component.key !== 'native'
|
|
2516
|
-
&& !component.key.startsWith('activation-')
|
|
2517
|
-
&& !component.key.startsWith('marketplace-'));
|
|
2518
|
-
const hasScopedExtensionResidue = extensionComponents.some((component) => component.state !== 'absent' || component.error !== undefined);
|
|
2519
|
-
const extensions = target.platform !== 'codex'
|
|
2520
|
-
|| (codex?.extensionKinds.length ?? 0) === 0
|
|
2521
|
-
? undefined
|
|
2522
|
-
: {
|
|
2523
|
-
state: desiredOverlapConflict
|
|
2524
|
-
? 'conflict'
|
|
2525
|
-
: extensionComponents.some((component) => component.error?.code === 'artifactCollision')
|
|
2526
|
-
? 'conflict'
|
|
2527
|
-
: extensionComponents.some((component) => component.state === 'partial' || component.state === 'error')
|
|
2528
|
-
? 'drifted'
|
|
2529
|
-
: desired.scopes.length > 0 && (extensionComponents.length === 0
|
|
2530
|
-
|| extensionComponents.every((component) => component.state === 'absent'))
|
|
2531
|
-
? 'missing'
|
|
2532
|
-
: 'ready',
|
|
2533
|
-
kinds: codex.extensionKinds,
|
|
2534
|
-
};
|
|
2535
|
-
const desiredEnabled = desired.scopes.length > 0;
|
|
2536
|
-
const projectDependencyIds = projectIntent.roots.some((root) => root.pluginId === target.pluginId && root.platforms.includes(target.platform))
|
|
2537
|
-
? projectDependencyClosureForTarget({
|
|
2538
|
-
pluginId: target.pluginId,
|
|
2539
|
-
platform: target.platform,
|
|
2540
|
-
available,
|
|
2541
|
-
})
|
|
2542
|
-
: new Set();
|
|
2543
|
-
const dependencyMoves = projectIntent.dependencyScopeOverrides.flatMap((override) => {
|
|
2544
|
-
if (override.scope !== 'project'
|
|
2545
|
-
|| (override.platform !== undefined && override.platform !== target.platform)
|
|
2546
|
-
|| !projectDependencyIds.has(override.pluginId)) {
|
|
2547
|
-
return [];
|
|
2548
|
-
}
|
|
2549
|
-
const dependencyDesired = desiredTargetStates.get(desiredTargetKey(override.pluginId, target.platform));
|
|
2550
|
-
if (!dependencyDesired?.scopes.includes('project')
|
|
2551
|
-
|| dependencyDesired.scopes.includes('user')) {
|
|
2552
|
-
return [];
|
|
2553
|
-
}
|
|
2554
|
-
const parsed = parsePluginId(override.pluginId);
|
|
2555
|
-
const hasPreservedUserActual = ownerInventory.references.some((reference) => reference.kind === 'namespacedOwner'
|
|
2556
|
-
&& reference.sourceId === parsed.sourceId
|
|
2557
|
-
&& reference.pluginName === parsed.pluginName
|
|
2558
|
-
&& reference.platform === target.platform
|
|
2559
|
-
&& reference.scope === 'user');
|
|
2560
|
-
return hasPreservedUserActual
|
|
2561
|
-
? [{ pluginId: override.pluginId, fromScope: 'user', toScope: 'project' }]
|
|
2562
|
-
: [];
|
|
2563
|
-
}).sort((left, right) => left.pluginId.localeCompare(right.pluginId, 'en'));
|
|
2564
|
-
const consumerIssue = activation?.systemConsumer?.state === 'incompatible'
|
|
2565
|
-
|| activation?.systemConsumer?.state === 'unresolved'
|
|
2566
|
-
? activation.systemConsumer
|
|
2567
|
-
: undefined;
|
|
2568
|
-
const consumerBlocking = consumerIssue !== undefined;
|
|
2569
|
-
const baseTargetErrors = observedTargets.flatMap((candidate) => candidate.errors);
|
|
2570
|
-
const hasBlockingBaseReason = baseTargetErrors.some((reason) => reason.severity === 'blocking');
|
|
2571
|
-
const capabilityUnsupported = baseTargetErrors.some((reason) => reason.code === 'awCapabilityUnsupported');
|
|
2572
|
-
const dependencyNotReady = (target.dependencyReadiness ?? []).some((dependency) => dependency.state !== 'ready');
|
|
2573
|
-
const state = hasSourceError && desiredEnabled
|
|
2574
|
-
? 'blocked'
|
|
2575
|
-
: consumerBlocking && desiredEnabled
|
|
2576
|
-
? 'blocked'
|
|
2577
|
-
: desiredOverlapConflict
|
|
2578
|
-
? 'blocked'
|
|
2579
|
-
: sharedNative?.state === 'blocked' || hasBlockingBaseReason || capabilityUnsupported
|
|
2580
|
-
? 'blocked'
|
|
2581
|
-
: sharedNative?.state === 'replaceable' && sharedNative.reason === 'damaged'
|
|
2582
|
-
? 'needsSync'
|
|
2583
|
-
: projectDisablesUserActivation
|
|
2584
|
-
? 'needsSync'
|
|
2585
|
-
: redundantProjectActivation && sharedNative?.state === 'usable' && !hasScopedExtensionResidue
|
|
2586
|
-
? 'ready'
|
|
2587
|
-
: !desiredEnabled
|
|
2588
|
-
? (target.platform === 'codex'
|
|
2589
|
-
? actualScopeEnabled || hasScopedExtensionResidue
|
|
2590
|
-
: ownershipState !== 'absent')
|
|
2591
|
-
|| desired.relation === 'managed'
|
|
2592
|
-
? 'orphaned'
|
|
2593
|
-
: 'absent'
|
|
2594
|
-
: dependencyMoves.length > 0
|
|
2595
|
-
? 'needsSync'
|
|
2596
|
-
: dependencyNotReady
|
|
2597
|
-
? 'needsSync'
|
|
2598
|
-
: sharedNative?.state === 'missing'
|
|
2599
|
-
|| sharedNative?.state === 'replaceable'
|
|
2600
|
-
|| sharedNative?.state === 'unobserved'
|
|
2601
|
-
? 'needsSync'
|
|
2602
|
-
: activationDrift || extensions?.state === 'drifted'
|
|
2603
|
-
? 'needsSync'
|
|
2604
|
-
: extensions?.state === 'missing'
|
|
2605
|
-
|| (target.platform !== 'codex' && ownershipState === 'absent')
|
|
2606
|
-
? 'needsSync'
|
|
2607
|
-
: ownershipState === 'partial' || ownershipState === 'error'
|
|
2608
|
-
? 'needsSync'
|
|
2609
|
-
: 'ready';
|
|
2610
|
-
const stableErrors = [
|
|
2611
|
-
...projectStatusSharedNativeReasons(sharedNative, baseTargetErrors.map((error) => error.code), desiredEnabled),
|
|
2612
|
-
...(desiredOverlapConflict
|
|
2613
|
-
? [blocking('codexExtensionScopeConflict', `${target.pluginId} has AW extensions desired at user and project scope.`)]
|
|
2614
|
-
: []),
|
|
2615
|
-
...(activationDrift && sharedNative?.state !== 'missing' && sharedNative?.state !== 'unobserved'
|
|
2616
|
-
? [warning('codexActivationDrift', projectDisablesUserActivation
|
|
2617
|
-
? `${target.pluginId} is enabled for the user but disabled by the current project.`
|
|
2618
|
-
: `${target.pluginId} activation differs from desired intent: `
|
|
2619
|
-
+ `${target.scope} expected=${expectedEnabled}, `
|
|
2620
|
-
+ `actual=${activation?.[target.scope] ?? 'unset'}.`)]
|
|
2621
|
-
: []),
|
|
2622
|
-
...(extensions?.state === 'drifted'
|
|
2623
|
-
? [warning('codexExtensionDrift', `${target.pluginId} extension projection has drifted.`)]
|
|
2624
|
-
: []),
|
|
2625
|
-
...dependencyMoves.map((move) => ({
|
|
2626
|
-
...warning('dependencyScopeMigrationCleanupRequired', `${move.pluginId} has preserved user-scope output after moving to project scope.`),
|
|
2627
|
-
dependencyPluginId: move.pluginId,
|
|
2628
|
-
dependencyPlatform: target.platform,
|
|
2629
|
-
dependencyScope: move.toScope,
|
|
2630
|
-
dependencyProject: 'current',
|
|
2631
|
-
})),
|
|
2632
|
-
...(target.platform === 'codex' && hasSourceError && desiredEnabled
|
|
2633
|
-
? [warning('codexIntentSourceUnavailable', `${target.pluginId} desired intent cannot be resolved from the current Catalog.`)]
|
|
2634
|
-
: []),
|
|
2635
|
-
...(target.platform === 'codex' && consumerBlocking && desiredEnabled
|
|
2636
|
-
? [blocking(consumerIssue.code, consumerIssue.diagnostic)]
|
|
2637
|
-
: []),
|
|
2638
|
-
...(activation?.systemConsumer?.diagnostics ?? []).map((diagnostic) => warning('codexCandidateExcluded', diagnostic)),
|
|
2639
|
-
];
|
|
2640
|
-
const targetErrors = [...baseTargetErrors, ...stableErrors];
|
|
2641
|
-
const dedupedErrors = [...new Map(targetErrors.map((error) => [
|
|
2642
|
-
`${error.code}\0${error.message}`,
|
|
2643
|
-
error,
|
|
2644
|
-
])).values()];
|
|
2645
|
-
const ownershipComponents = [...new Map(observedTargets.flatMap((candidate) => candidate.components)
|
|
2646
|
-
.map((component) => [component.key, component])).values()];
|
|
2647
|
-
const representativeScope = target.scope;
|
|
2648
|
-
const representativeTarget = observedTargets.find((candidate) => candidate.scope === representativeScope) ?? target;
|
|
2649
|
-
const components = [
|
|
2650
|
-
{
|
|
2651
|
-
kind: 'intent',
|
|
2652
|
-
key: 'desired',
|
|
2653
|
-
state: desiredEnabled ? 'desired' : 'absent',
|
|
2654
|
-
metadata: {
|
|
2655
|
-
enabled: desiredEnabled,
|
|
2656
|
-
scopes: desired.scopes,
|
|
2657
|
-
relation: desired.relation,
|
|
2658
|
-
},
|
|
2659
|
-
},
|
|
2660
|
-
...ownershipComponents.map((component) => ({
|
|
2661
|
-
kind: 'ownership',
|
|
2662
|
-
key: component.key,
|
|
2663
|
-
state: component.key === 'native'
|
|
2664
|
-
&& component.state === 'absent'
|
|
2665
|
-
&& sharedNative?.staleCacheObserved
|
|
2666
|
-
? 'partial'
|
|
2667
|
-
: component.state,
|
|
2668
|
-
...(component.error ? { metadata: { errorCode: component.error.code } } : {}),
|
|
2669
|
-
})),
|
|
2670
|
-
...(sharedNative ? [{
|
|
2671
|
-
kind: 'sharedNative',
|
|
2672
|
-
key: sharedNative.pluginId,
|
|
2673
|
-
state: sharedNative.state,
|
|
2674
|
-
metadata: {
|
|
2675
|
-
shared: true,
|
|
2676
|
-
...(sharedNative.reason ? { reason: sharedNative.reason } : {}),
|
|
2677
|
-
...(sharedNative.version ? { version: sharedNative.version } : {}),
|
|
2678
|
-
...(sharedNative.desiredVersion ? { desiredVersion: sharedNative.desiredVersion } : {}),
|
|
2679
|
-
...(sharedNative.diagnostic ? { diagnostic: sharedNative.diagnostic } : {}),
|
|
2680
|
-
...(sharedNative.staleCacheObserved ? { staleCacheObserved: true } : {}),
|
|
2681
|
-
},
|
|
2682
|
-
}] : []),
|
|
2683
|
-
...['user', 'project'].flatMap((scope) => activation?.[scope] === undefined ? [] : [{
|
|
2684
|
-
kind: 'activation',
|
|
2685
|
-
key: scope,
|
|
2686
|
-
state: activation[scope] ? 'enabled' : 'disabled',
|
|
2687
|
-
metadata: {
|
|
2688
|
-
evidence: activation.evidence,
|
|
2689
|
-
...(activation.effective !== undefined ? { effective: activation.effective } : {}),
|
|
2690
|
-
},
|
|
2691
|
-
}]),
|
|
2692
|
-
...(activation?.systemConsumer ? [{
|
|
2693
|
-
kind: 'systemConsumer',
|
|
2694
|
-
key: `codex:${representativeScope}`,
|
|
2695
|
-
state: activation.systemConsumer.state,
|
|
2696
|
-
metadata: {
|
|
2697
|
-
evidence: activation.evidence,
|
|
2698
|
-
requiredMinVersion: activation.systemConsumer.requiredMinVersion,
|
|
2699
|
-
...('detectedVersion' in activation.systemConsumer
|
|
2700
|
-
? { detectedVersion: activation.systemConsumer.detectedVersion }
|
|
2701
|
-
: {}),
|
|
2702
|
-
...('code' in activation.systemConsumer ? { code: activation.systemConsumer.code } : {}),
|
|
2703
|
-
...('diagnostic' in activation.systemConsumer
|
|
2704
|
-
? { diagnostic: activation.systemConsumer.diagnostic }
|
|
2705
|
-
: {}),
|
|
2706
|
-
...(activation.systemConsumer.diagnostics?.length
|
|
2707
|
-
? { diagnostics: activation.systemConsumer.diagnostics }
|
|
2708
|
-
: {}),
|
|
2709
|
-
},
|
|
2710
|
-
}] : []),
|
|
2711
|
-
...(extensions ? [{
|
|
2712
|
-
kind: 'extension',
|
|
2713
|
-
key: 'aw',
|
|
2714
|
-
state: extensions.state,
|
|
2715
|
-
metadata: { kinds: extensions.kinds },
|
|
2716
|
-
}] : []),
|
|
2717
|
-
...(representativeTarget.dependencyReadiness ?? []).map((dependency) => ({
|
|
2718
|
-
kind: 'dependency',
|
|
2719
|
-
key: dependency.dependencyPluginId,
|
|
2720
|
-
state: dependency.state,
|
|
2721
|
-
metadata: {
|
|
2722
|
-
platform: dependency.dependencyPlatform,
|
|
2723
|
-
scope: dependency.dependencyScope,
|
|
2724
|
-
project: dependency.dependencyProject ?? 'none',
|
|
2725
|
-
...(dependency.rootIssueId ? { rootIssueId: dependency.rootIssueId } : {}),
|
|
2726
|
-
...(dependency.rootIssueCode ? { rootIssueCode: dependency.rootIssueCode } : {}),
|
|
2727
|
-
},
|
|
2728
|
-
})),
|
|
2729
|
-
];
|
|
2730
|
-
const { state: _ownershipState, components: _ownershipComponents, errors: _errors, sharedNative: _sharedNative, activation: _activation, extensions: _extensions, dependency: _dependency, dependencyReadiness: _dependencyReadiness, ...identity } = target;
|
|
2731
|
-
return {
|
|
2732
|
-
...identity,
|
|
2733
|
-
scope: representativeScope,
|
|
2734
|
-
state,
|
|
2735
|
-
components,
|
|
2736
|
-
reasons: dedupedErrors,
|
|
2737
|
-
recoveryActions: projectDisablesUserActivation && state === 'needsSync' ? [{
|
|
2738
|
-
command: 'sync', scope: 'user',
|
|
2739
|
-
description: '移除当前项目的关闭设置,恢复使用所有项目已启用的插件。',
|
|
2740
|
-
}] : statusRecovery({
|
|
2741
|
-
state,
|
|
2742
|
-
desired,
|
|
2743
|
-
platform: target.platform,
|
|
2744
|
-
pluginId: target.pluginId,
|
|
2745
|
-
...(dependencyMoves.length > 0 ? { dependencyMoves } : {}),
|
|
2746
|
-
...(sharedNative ? { sharedNative } : {}),
|
|
2747
|
-
scope: target.scope,
|
|
2748
|
-
actualEnabled: actualScopeEnabled,
|
|
2749
|
-
conflictRoots: rootIntentsForTarget({
|
|
2750
|
-
pluginId: target.pluginId,
|
|
2751
|
-
platform: target.platform,
|
|
2752
|
-
userIntent,
|
|
2753
|
-
projectIntent,
|
|
2754
|
-
available,
|
|
2755
|
-
}),
|
|
2756
|
-
errorCodes: dedupedErrors.map((error) => error.code),
|
|
2757
|
-
}).map((action) => action.command === 'manual' || action.scope
|
|
2758
|
-
? action
|
|
2759
|
-
: { ...action, scope: representativeScope }),
|
|
2760
|
-
};
|
|
2761
|
-
};
|
|
2762
|
-
const codexGroups = new Map();
|
|
2763
|
-
const projectedTargets = [];
|
|
2764
|
-
for (const target of draftTargets) {
|
|
2765
|
-
if (target.platform !== 'codex') {
|
|
2766
|
-
projectedTargets.push(await decorateTarget(target, [target.scope], [target]));
|
|
2767
|
-
continue;
|
|
2768
|
-
}
|
|
2769
|
-
const group = codexGroups.get(target.pluginId) ?? [];
|
|
2770
|
-
group.push(target);
|
|
2771
|
-
codexGroups.set(target.pluginId, group);
|
|
2772
|
-
}
|
|
2773
|
-
for (const group of codexGroups.values()) {
|
|
2774
|
-
const decorated = await Promise.all(group.map((target) => decorateTarget(target, [target.scope], [target])));
|
|
2775
|
-
const first = decorated[0];
|
|
2776
|
-
const entry = selectedByPluginId.get(first.pluginId);
|
|
2777
|
-
const desired = desiredTargetStates.get(desiredTargetKey(first.pluginId, 'codex'))
|
|
2778
|
-
?? { scopes: [], relation: 'none' };
|
|
2779
|
-
const returnedScopes = new Set(decorated.map((target) => target.scope));
|
|
2780
|
-
const desiredOverlapConflict = (entry?.codex?.extensionKinds.length ?? 0) > 0
|
|
2781
|
-
&& desired.scopes.includes('user')
|
|
2782
|
-
&& desired.scopes.includes('project')
|
|
2783
|
-
&& returnedScopes.has('user')
|
|
2784
|
-
&& returnedScopes.has('project');
|
|
2785
|
-
const sharedComponents = [...new Map(decorated.flatMap((target) => target.components)
|
|
2786
|
-
.filter((component) => component.kind === 'sharedNative' || component.kind === 'systemConsumer')
|
|
2787
|
-
.map((component) => [`${component.kind}\0${component.key}`, component])).values()];
|
|
2788
|
-
const sharedReason = (reason) => reason.code.startsWith('codexSharedNative') || reason.code === 'staleCacheObserved'
|
|
2789
|
-
|| reason.code === 'codexCandidateExcluded';
|
|
2790
|
-
const sharedReasons = decorated.flatMap((target) => target.reasons.filter(sharedReason));
|
|
2791
|
-
const placements = decorated.map((target) => ({
|
|
2792
|
-
scope: target.scope,
|
|
2793
|
-
state: target.state,
|
|
2794
|
-
components: target.components.filter((component) => component.kind !== 'sharedNative' && component.kind !== 'systemConsumer'),
|
|
2795
|
-
reasons: target.reasons.filter((reason) => !sharedReason(reason)),
|
|
2796
|
-
recoveryActions: target.recoveryActions,
|
|
2797
|
-
})).sort((left, right) => left.scope.localeCompare(right.scope, 'en'));
|
|
2798
|
-
const reasons = [...new Map([
|
|
2799
|
-
...placements.flatMap((placement) => placement.reasons),
|
|
2800
|
-
...sharedReasons,
|
|
2801
|
-
...(desiredOverlapConflict ? [blocking('codexExtensionScopeConflict', `${first.pluginId} has AW extensions desired at user and project scope.`)] : []),
|
|
2802
|
-
]
|
|
2803
|
-
.map((reason) => [`${reason.code}\0${reason.message}`, reason])).values()];
|
|
2804
|
-
const conflictRecovery = desiredOverlapConflict ? statusRecovery({
|
|
2805
|
-
state: 'blocked',
|
|
2806
|
-
desired,
|
|
2807
|
-
platform: 'codex',
|
|
2808
|
-
pluginId: first.pluginId,
|
|
2809
|
-
conflictRoots: rootIntentsForTarget({
|
|
2810
|
-
pluginId: first.pluginId,
|
|
2811
|
-
platform: 'codex',
|
|
2812
|
-
userIntent,
|
|
2813
|
-
projectIntent,
|
|
2814
|
-
available,
|
|
2815
|
-
}),
|
|
2816
|
-
errorCodes: ['codexExtensionScopeConflict'],
|
|
2817
|
-
}) : [];
|
|
2818
|
-
const recoveryActions = [...new Map((desiredOverlapConflict
|
|
2819
|
-
? conflictRecovery
|
|
2820
|
-
: placements.flatMap((placement) => placement.recoveryActions))
|
|
2821
|
-
.map((action) => [
|
|
2822
|
-
`${action.command}\0${action.scope ?? ''}\0${action.description}`,
|
|
2823
|
-
action,
|
|
2824
|
-
])).values()];
|
|
2825
|
-
const state = desiredOverlapConflict ? 'blocked'
|
|
2826
|
-
: ['blocked', 'needsSync', 'orphaned', 'ready', 'absent']
|
|
2827
|
-
.find((candidate) => placements.some((placement) => placement.state === candidate));
|
|
2828
|
-
projectedTargets.push({
|
|
2829
|
-
pluginName: first.pluginName,
|
|
2830
|
-
sourceId: first.sourceId,
|
|
2831
|
-
sourceIdentity: first.sourceIdentity,
|
|
2832
|
-
pluginId: first.pluginId,
|
|
2833
|
-
...(first.version ? { version: first.version } : {}),
|
|
2834
|
-
platform: 'codex',
|
|
2835
|
-
cwd: first.cwd,
|
|
2836
|
-
state,
|
|
2837
|
-
components: sharedComponents,
|
|
2838
|
-
reasons,
|
|
2839
|
-
recoveryActions,
|
|
2840
|
-
placements,
|
|
2841
|
-
});
|
|
2842
|
-
}
|
|
2843
|
-
projectedTargets.sort((left, right) => `${left.pluginId}\0${left.platform}`.localeCompare(`${right.pluginId}\0${right.platform}`, 'en'));
|
|
2844
|
-
const targetRevisions = projectedTargets.flatMap((target) => {
|
|
2845
|
-
const entry = selectedByPluginId.get(target.pluginId);
|
|
2846
|
-
const placements = target.platform === 'codex' ? target.placements : [target];
|
|
2847
|
-
return placements.map((placement) => ({
|
|
2848
|
-
pluginId: target.pluginId,
|
|
2849
|
-
platform: target.platform,
|
|
2850
|
-
scope: placement.scope,
|
|
2851
|
-
revision: projectTargetRevision(entry?.version, entry?.states[target.platform]?.[placement.scope]?.installedVersion),
|
|
2852
|
-
}));
|
|
2853
|
-
});
|
|
2854
|
-
const publicConfigIssues = available.flatMap((entry) => (entry.configIssues ?? [])
|
|
2855
|
-
.filter((issue) => issue.type === 'configLayerUnsupported')
|
|
2856
|
-
.map((issue) => ({
|
|
2857
|
-
pluginId: formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }),
|
|
2858
|
-
pluginName: entry.name,
|
|
2859
|
-
...issue,
|
|
2860
|
-
})));
|
|
2861
|
-
const nativeObservations = available.flatMap((entry) => ['codex', 'claude'].map((platform) => {
|
|
2862
|
-
const observed = entry.states[platform]?.[scope];
|
|
2863
|
-
const blockers = (observed?.errors ?? []).map((error) => ({
|
|
2864
|
-
code: error.code, message: `${error.code}: 项目 Native 目标尚未满足。`,
|
|
2865
|
-
}));
|
|
2866
|
-
const nativeInventoryErrors = inventoryErrors.filter((error) => inventoryErrorMatchesSelection({
|
|
2867
|
-
error,
|
|
2868
|
-
selectors: [{ raw: `${entry.source.id}/${entry.name}`, parsed: {
|
|
2869
|
-
sourceId: entry.source.id, pluginName: entry.name,
|
|
2870
|
-
} }],
|
|
2871
|
-
platformExplicit: true, scopeExplicit: true, platforms: [platform], scopes: [scope],
|
|
2872
|
-
currentProjectLocationKey,
|
|
2873
|
-
}));
|
|
2874
|
-
blockers.push(...nativeInventoryErrors.map((error) => ({
|
|
2875
|
-
code: error.code, message: `${error.code}: 无法读取项目 Native 现场。`,
|
|
2876
|
-
})));
|
|
2877
|
-
if (platform === 'codex' && codexConfigErrors.some((error) => error.scope === scope
|
|
2878
|
-
|| scope === 'project' && error.scope === 'user')) {
|
|
2879
|
-
blockers.push({ code: 'nativeStateUnreadable', message: '无法读取 Codex 激活配置。' });
|
|
2880
|
-
}
|
|
2881
|
-
const scopedPreferences = observedDemands.get(scope)?.preferences;
|
|
2882
|
-
if (entry.configDiagnostic?.scope === scope && scopedPreferences?.state === 'valid'
|
|
2883
|
-
&& resolveActiveConfigPlatforms(`${entry.source.id}/${entry.name}`, { platforms: entry.platforms }, scopedPreferences).includes(platform)) {
|
|
2884
|
-
blockers.push({ code: 'configInvalid', message: 'Plugin configuration could not be read.', detail: { reasonCode: 'configReadFailed' } });
|
|
2885
|
-
}
|
|
2886
|
-
const configBlockers = configStatusDiagnostics((entry.configIssues ?? []).flatMap((issue) => issue.scope === scope && issue.platform === platform && (issue.type === 'missing-required' || issue.type === 'invalid-config')
|
|
2887
|
-
? [{ type: issue.type, key: issue.key, message: '' }] : []));
|
|
2888
|
-
blockers.push(...configBlockers);
|
|
2889
|
-
if (observed?.state === 'error' && !blockers.some((error) => /Unsupported$|collision|conflict|foreign/iu.test(error.code))) {
|
|
2890
|
-
blockers.push({ code: 'nativeObservationFailed', message: '无法完成项目 Native 现场观察。' });
|
|
2891
|
-
}
|
|
2892
|
-
let content = !observed ? 'unknown'
|
|
2893
|
-
: observed.state === 'absent' ? 'absent'
|
|
2894
|
-
: observed.state === 'present' ? 'satisfied'
|
|
2895
|
-
: observed.state === 'partial' ? 'drifted' : 'unknown';
|
|
2896
|
-
if (blockers.some((blocker) => /collision|conflict|foreign/iu.test(blocker.code)))
|
|
2897
|
-
content = 'conflict';
|
|
2898
|
-
if (platform === 'codex' && entry.codex?.nativeKinds.length) {
|
|
2899
|
-
const shared = entry.codex.sharedNative;
|
|
2900
|
-
if (shared?.state === 'missing')
|
|
2901
|
-
content = 'absent';
|
|
2902
|
-
else if (shared?.state === 'replaceable')
|
|
2903
|
-
content = 'drifted';
|
|
2904
|
-
else if (shared?.state === 'blocked')
|
|
2905
|
-
content = shared.reason === 'foreign' ? 'conflict' : 'unknown';
|
|
2906
|
-
else if (!shared || shared.state === 'unobserved')
|
|
2907
|
-
content = 'unknown';
|
|
2908
|
-
if (content === 'satisfied' && entry.codex.activation.effective !== true)
|
|
2909
|
-
content = 'absent';
|
|
2910
|
-
}
|
|
2911
|
-
return {
|
|
2912
|
-
pluginId: `${entry.source.id}/${entry.name}`, platform, content, blockers,
|
|
2913
|
-
backend: flattenStatusTargets(projectedTargets).find((target) => target.pluginId === `${entry.source.id}/${entry.name}`
|
|
2914
|
-
&& target.platform === platform && target.scope === scope),
|
|
2915
|
-
...(platform === 'codex' && entry.codex?.activation.evidence === 'assumed'
|
|
2916
|
-
? { assumedActivation: true } : {}),
|
|
2917
|
-
};
|
|
2918
|
-
}));
|
|
2919
|
-
const payload = {
|
|
2920
|
-
schemaVersion: 8,
|
|
2921
|
-
catalog: {
|
|
2922
|
-
primarySourceId: catalog.primarySourceId,
|
|
2923
|
-
configDigest: catalog.configDigest,
|
|
2924
|
-
compositeDigest: catalog.compositeDigest,
|
|
2925
|
-
...(options.catalogOperationContext
|
|
2926
|
-
? { generationSetDigest: options.catalogOperationContext.generationSetDigest }
|
|
2927
|
-
: {}),
|
|
2928
|
-
sources: catalog.sources.map((source) => {
|
|
2929
|
-
if (!('plugins' in source))
|
|
2930
|
-
return source;
|
|
2931
|
-
const { plugins: _plugins, ...projected } = source;
|
|
2932
|
-
return projected;
|
|
2933
|
-
}),
|
|
2934
|
-
},
|
|
2935
|
-
filters: {
|
|
2936
|
-
plugins: requested,
|
|
2937
|
-
platform: options.platform === undefined ? 'both' : parsePlatformValue(options.platform),
|
|
2938
|
-
...(options.scope === undefined ? {} : { scope: parseScopeValue(options.scope) }),
|
|
2939
|
-
cwd: path.resolve(options.cwd),
|
|
2940
|
-
},
|
|
2941
|
-
targets: projectedTargets,
|
|
2942
|
-
...(publicConfigIssues.length > 0 ? { configIssues: publicConfigIssues } : {}),
|
|
2943
|
-
errors,
|
|
2944
|
-
};
|
|
2945
|
-
const hasErrors = payload.catalog.sources.some((source) => source.error !== undefined)
|
|
2946
|
-
|| payload.errors.length > 0
|
|
2947
|
-
|| payload.targets.some((target) => target.reasons.some((reason) => reason.severity === 'blocking'));
|
|
2948
|
-
return {
|
|
2949
|
-
payload,
|
|
2950
|
-
output: options.json ? JSON.stringify(payload) : renderStatusV8(payload, options.verbose === true),
|
|
2951
|
-
hasErrors,
|
|
2952
|
-
targetRevisions,
|
|
2953
|
-
nativeObservations,
|
|
2954
|
-
nativeExtraObserved: ownerInventory.references.flatMap((reference) => {
|
|
2955
|
-
if (!reference.sourceId || !reference.pluginName || reference.scope !== scope
|
|
2956
|
-
|| !['namespacedOwner', 'namespacedConfig', 'namespacedMarketplace'].includes(reference.kind))
|
|
2957
|
-
return [];
|
|
2958
|
-
return [{ pluginId: `${reference.sourceId}/${reference.pluginName}`,
|
|
2959
|
-
...(reference.platform === 'codex' || reference.platform === 'claude'
|
|
2960
|
-
? { platform: reference.platform } : {}), scope, reference }];
|
|
2961
|
-
}),
|
|
2962
|
-
...(projectRoot ? { projectRoot } : {}),
|
|
2963
|
-
projectIntentObservation,
|
|
2964
|
-
pluginSummaries: available.map((entry) => {
|
|
2965
|
-
const sourceEntries = available.filter((candidate) => candidate.source.id === entry.source.id);
|
|
2966
|
-
const byName = new Map(sourceEntries.map((candidate) => [candidate.name, candidate]));
|
|
2967
|
-
const transitive = new Set();
|
|
2968
|
-
const visit = (name) => {
|
|
2969
|
-
const candidate = byName.get(name);
|
|
2970
|
-
for (const dependency of candidate?.dependencies ?? []) {
|
|
2971
|
-
if (transitive.has(dependency))
|
|
2972
|
-
continue;
|
|
2973
|
-
transitive.add(dependency);
|
|
2974
|
-
visit(dependency);
|
|
2975
|
-
}
|
|
2976
|
-
};
|
|
2977
|
-
visit(entry.name);
|
|
2978
|
-
const dependencyIssueCount = targets.filter((target) => target.pluginId === formatPluginId({
|
|
2979
|
-
sourceId: entry.source.id,
|
|
2980
|
-
pluginName: entry.name,
|
|
2981
|
-
})).reduce((count, target) => count + target.errors.filter((error) => error.code.startsWith('dependency')
|
|
2982
|
-
|| error.code === 'awCapabilityUnsupported'
|
|
2983
|
-
|| error.code === 'sourceChanged').length, 0);
|
|
2984
|
-
return {
|
|
2985
|
-
pluginName: entry.name,
|
|
2986
|
-
pluginId: formatPluginId({ sourceId: entry.source.id, pluginName: entry.name }),
|
|
2987
|
-
displayName: entry.displayName,
|
|
2988
|
-
description: entry.shortDescription,
|
|
2989
|
-
version: entry.version,
|
|
2990
|
-
supportedTargets: {
|
|
2991
|
-
codex: ['user', 'project'].filter((scope) => entry.targets.codex[scope]),
|
|
2992
|
-
claude: ['user', 'project'].filter((scope) => entry.targets.claude[scope]),
|
|
2993
|
-
},
|
|
2994
|
-
...(entry.platforms ? { platforms: entry.platforms } : {}),
|
|
2995
|
-
configFieldCount: Object.keys(entry.configSchema ?? {}).length,
|
|
2996
|
-
...(entry.configSchema ? { configSchema: entry.configSchema } : {}),
|
|
2997
|
-
...(entry.configIssues ? { configIssues: entry.configIssues } : {}),
|
|
2998
|
-
...(entry.configDiagnostic ? { configDiagnostic: entry.configDiagnostic } : {}),
|
|
2999
|
-
dependencyDirectCount: entry.dependencies.length,
|
|
3000
|
-
dependencyTotalCount: transitive.size,
|
|
3001
|
-
dependencyIssueCount,
|
|
3002
|
-
...(entry.missingCapabilities
|
|
3003
|
-
? { missingCapabilities: entry.missingCapabilities }
|
|
3004
|
-
: {}),
|
|
3005
|
-
};
|
|
3006
|
-
}),
|
|
3007
|
-
};
|
|
3008
|
-
}
|
|
3009
|
-
export async function statusCommandV8(options) {
|
|
3010
|
-
options.signal?.throwIfAborted();
|
|
3011
|
-
options = { ...options, nativeCliRunner: bindNativeCliRunnerSignal(options.nativeCliRunner ?? getDefaultNativeCliRunner(), options.signal) };
|
|
3012
|
-
if (options.codexObservationSession) {
|
|
3013
|
-
return statusCommandV8InSession({
|
|
3014
|
-
...options,
|
|
3015
|
-
codexObservationSession: options.codexObservationSession,
|
|
3016
|
-
});
|
|
3017
|
-
}
|
|
3018
|
-
const env = options.env ?? process.env;
|
|
3019
|
-
const session = await createCodexNativeObservationSession({
|
|
3020
|
-
exactCwd: options.cwd,
|
|
3021
|
-
env,
|
|
3022
|
-
runner: options.nativeCliRunner ?? getDefaultNativeCliRunner(),
|
|
3023
|
-
});
|
|
3024
|
-
try {
|
|
3025
|
-
options.signal?.throwIfAborted();
|
|
3026
|
-
const result = await statusCommandV8InSession({ ...options, codexObservationSession: session });
|
|
3027
|
-
options.signal?.throwIfAborted();
|
|
3028
|
-
return result;
|
|
3029
|
-
}
|
|
3030
|
-
finally {
|
|
3031
|
-
await session.dispose();
|
|
3032
|
-
}
|
|
3033
|
-
}
|
|
3034
148
|
//# sourceMappingURL=status-v6.js.map
|