@lesliechan721/aw 0.1.0-beta.64 → 0.1.0-beta.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring/assets/aw-runtime-config.mjs +3 -3
- package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -1
- package/dist/authoring/scripts/add-skill.mjs +3 -17
- package/dist/authoring/scripts/add-skill.mjs.map +1 -1
- package/dist/authoring/scripts/init-plugin.mjs +1 -0
- package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-version-check.mjs +1 -1
- package/dist/authoring/scripts/lib/skill-scaffold.d.mts +2 -0
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +2 -0
- package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
- package/dist/authoring/scripts/validate-plugin.mjs +95 -698
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
- package/dist/scripts/aw-skill-eval-materializer.d.ts +2 -0
- package/dist/scripts/aw-skill-eval-materializer.js +74 -44
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
- package/dist/scripts/bundle-plugins.js +10 -2
- package/dist/scripts/bundle-plugins.js.map +1 -1
- package/dist/scripts/plugin-staging.d.ts +1 -1
- package/dist/scripts/plugin-staging.js +1 -1
- package/dist/scripts/plugin-staging.js.map +1 -1
- package/dist/scripts/test-plugin-scripts.js +31 -31
- package/dist/scripts/test-plugin-scripts.js.map +1 -1
- package/dist/src/commands/aw-capabilities.d.ts +1 -1
- package/dist/src/commands/aw-capabilities.js +2 -0
- package/dist/src/commands/aw-capabilities.js.map +1 -1
- package/dist/src/commands/console.js +4 -3
- package/dist/src/commands/console.js.map +1 -1
- package/dist/src/commands/intent-command.d.ts +30 -0
- package/dist/src/commands/intent-command.js +164 -0
- package/dist/src/commands/intent-command.js.map +1 -0
- package/dist/src/commands/operation-plan.d.ts +2 -0
- package/dist/src/commands/operation-plan.js +2 -1
- package/dist/src/commands/operation-plan.js.map +1 -1
- package/dist/src/commands/options.d.ts +3 -11
- package/dist/src/commands/options.js +11 -17
- package/dist/src/commands/options.js.map +1 -1
- package/dist/src/commands/plugin-capabilities.js +27 -33
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/rebuild-command.d.ts +108 -6
- package/dist/src/commands/rebuild-command.js +617 -1549
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +19 -3
- package/dist/src/commands/rebuild-integration.js +500 -459
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.js +1 -2
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/review-inspection.d.ts +2 -2
- package/dist/src/commands/review-inspection.js +30 -86
- package/dist/src/commands/review-inspection.js.map +1 -1
- package/dist/src/commands/review-preparation.js +16 -7
- package/dist/src/commands/review-preparation.js.map +1 -1
- package/dist/src/commands/skill-eval.d.ts +2 -0
- package/dist/src/commands/skill-eval.js +15 -9
- package/dist/src/commands/skill-eval.js.map +1 -1
- package/dist/src/commands/status-v6.d.ts +38 -5
- package/dist/src/commands/status-v6.js +269 -102
- package/dist/src/commands/status-v6.js.map +1 -1
- package/dist/src/commands/targets-command.d.ts +27 -0
- package/dist/src/commands/targets-command.js +77 -0
- package/dist/src/commands/targets-command.js.map +1 -0
- package/dist/src/commands/write-commands.js +5 -5
- package/dist/src/commands/write-commands.js.map +1 -1
- package/dist/src/eval/manifest-v1.d.ts +2 -0
- package/dist/src/eval/manifest-v1.js +7 -2
- package/dist/src/eval/manifest-v1.js.map +1 -1
- package/dist/src/generators/local-plugin.d.ts +2 -1
- package/dist/src/generators/local-plugin.js +111 -108
- package/dist/src/generators/local-plugin.js.map +1 -1
- package/dist/src/index.d.ts +10 -17
- package/dist/src/index.js +585 -1349
- package/dist/src/index.js.map +1 -1
- package/dist/src/intent/deployment-preferences.d.ts +63 -0
- package/dist/src/intent/deployment-preferences.js +170 -0
- package/dist/src/intent/deployment-preferences.js.map +1 -0
- package/dist/src/intent/diagnostics.d.ts +11 -0
- package/dist/src/intent/diagnostics.js +14 -0
- package/dist/src/intent/diagnostics.js.map +1 -0
- package/dist/src/intent/intent-codec.d.ts +19 -0
- package/dist/src/intent/intent-codec.js +117 -0
- package/dist/src/intent/intent-codec.js.map +1 -0
- package/dist/src/intent/intent-store.d.ts +43 -0
- package/dist/src/intent/intent-store.js +118 -0
- package/dist/src/intent/intent-store.js.map +1 -0
- package/dist/src/intent/scope-context.d.ts +33 -0
- package/dist/src/intent/scope-context.js +145 -0
- package/dist/src/intent/scope-context.js.map +1 -0
- package/dist/src/intent/work-context.d.ts +13 -0
- package/dist/src/intent/work-context.js +22 -0
- package/dist/src/intent/work-context.js.map +1 -0
- package/dist/src/output/command-receipt.js +16 -9
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/portable/commands.d.ts +18 -8
- package/dist/src/portable/commands.js +46 -562
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/historical-materialization.d.ts +22 -0
- package/dist/src/portable/historical-materialization.js +124 -0
- package/dist/src/portable/historical-materialization.js.map +1 -0
- package/dist/src/portable/materializer.d.ts +8 -0
- package/dist/src/portable/materializer.js +75 -44
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery-layout.d.ts +17 -0
- package/dist/src/portable/recovery-layout.js +55 -0
- package/dist/src/portable/recovery-layout.js.map +1 -0
- package/dist/src/portable/recovery.d.ts +143 -0
- package/dist/src/portable/recovery.js +339 -0
- package/dist/src/portable/recovery.js.map +1 -0
- package/dist/src/portable/writer.d.ts +64 -0
- package/dist/src/portable/writer.js +316 -0
- package/dist/src/portable/writer.js.map +1 -0
- package/dist/src/recovery/coordinator.d.ts +137 -0
- package/dist/src/recovery/coordinator.js +1198 -0
- package/dist/src/recovery/coordinator.js.map +1 -0
- package/dist/src/recovery/demand.d.ts +44 -0
- package/dist/src/recovery/demand.js +178 -0
- package/dist/src/recovery/demand.js.map +1 -0
- package/dist/src/recovery/joint-coordinator.d.ts +24 -0
- package/dist/src/recovery/joint-coordinator.js +770 -0
- package/dist/src/recovery/joint-coordinator.js.map +1 -0
- package/dist/src/recovery/joint-demand.d.ts +68 -0
- package/dist/src/recovery/joint-demand.js +166 -0
- package/dist/src/recovery/joint-demand.js.map +1 -0
- package/dist/src/recovery/receipt.d.ts +81 -0
- package/dist/src/recovery/receipt.js +2 -0
- package/dist/src/recovery/receipt.js.map +1 -0
- package/dist/src/recovery/retirement.d.ts +45 -0
- package/dist/src/recovery/retirement.js +366 -0
- package/dist/src/recovery/retirement.js.map +1 -0
- package/dist/src/recovery/status.d.ts +108 -0
- package/dist/src/recovery/status.js +417 -0
- package/dist/src/recovery/status.js.map +1 -0
- package/dist/src/recovery/types.d.ts +86 -0
- package/dist/src/recovery/types.js +2 -0
- package/dist/src/recovery/types.js.map +1 -0
- package/dist/src/review/review-profile.d.ts +2 -1
- package/dist/src/review/review-profile.js +15 -15
- package/dist/src/review/review-profile.js.map +1 -1
- package/dist/src/review/review-selection.d.ts +1 -2
- package/dist/src/review/review-selection.js +40 -114
- package/dist/src/review/review-selection.js.map +1 -1
- package/dist/src/review/review-types.d.ts +4 -4
- package/dist/src/review/review-types.js.map +1 -1
- package/dist/src/review/skill-materialization.js +15 -6
- package/dist/src/review/skill-materialization.js.map +1 -1
- package/dist/src/review/source-binding.d.ts +14 -4
- package/dist/src/review/source-binding.js +62 -117
- package/dist/src/review/source-binding.js.map +1 -1
- package/dist/src/tui/agent-management.d.ts +23 -0
- package/dist/src/tui/agent-management.js +217 -0
- package/dist/src/tui/agent-management.js.map +1 -0
- package/dist/src/tui/agent-settings.d.ts +44 -0
- package/dist/src/tui/agent-settings.js +98 -0
- package/dist/src/tui/agent-settings.js.map +1 -0
- package/dist/src/tui/components.d.ts +3 -0
- package/dist/src/tui/components.js +10 -1
- package/dist/src/tui/components.js.map +1 -1
- package/dist/src/tui/config-references.d.ts +6 -3
- package/dist/src/tui/config-references.js +17 -12
- package/dist/src/tui/config-references.js.map +1 -1
- package/dist/src/tui/console-app-v4.d.ts +1 -2
- package/dist/src/tui/console-app-v4.js +1533 -1047
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/controller-runtime.d.ts +2 -1
- package/dist/src/tui/controller-runtime.js +405 -1626
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +131 -81
- package/dist/src/tui/controller.js +307 -227
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/entity-cards.d.ts +2 -2
- package/dist/src/tui/entity-cards.js +98 -20
- package/dist/src/tui/entity-cards.js.map +1 -1
- package/dist/src/tui/glossary.d.ts +2 -0
- package/dist/src/tui/glossary.js +20 -0
- package/dist/src/tui/glossary.js.map +1 -1
- package/dist/src/tui/model.d.ts +28 -10
- package/dist/src/tui/model.js +41 -41
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/tui/operation-review-planner.d.ts +2 -0
- package/dist/src/tui/operation-review-planner.js +58 -122
- package/dist/src/tui/operation-review-planner.js.map +1 -1
- package/dist/src/tui/plugin-content.js +7 -4
- package/dist/src/tui/plugin-content.js.map +1 -1
- package/dist/src/tui/plugin-detail.d.ts +22 -3
- package/dist/src/tui/plugin-detail.js +113 -26
- package/dist/src/tui/plugin-detail.js.map +1 -1
- package/dist/src/tui/reader.d.ts +1 -0
- package/dist/src/tui/reader.js +3 -1
- package/dist/src/tui/reader.js.map +1 -1
- package/dist/src/tui/router.d.ts +23 -33
- package/dist/src/tui/router.js.map +1 -1
- package/dist/src/tui/scoped-flow.d.ts +45 -0
- package/dist/src/tui/scoped-flow.js +96 -0
- package/dist/src/tui/scoped-flow.js.map +1 -0
- package/dist/src/tui/scoped-inventory.d.ts +122 -0
- package/dist/src/tui/scoped-inventory.js +225 -0
- package/dist/src/tui/scoped-inventory.js.map +1 -0
- package/dist/src/tui/screen-registry.d.ts +25 -25
- package/dist/src/tui/screen-registry.js +3 -7
- package/dist/src/tui/screen-registry.js.map +1 -1
- package/dist/src/tui/session-console-app.js +1 -1
- package/dist/src/tui/session-console-app.js.map +1 -1
- package/dist/src/tui/session-host.js +12 -2
- package/dist/src/tui/session-host.js.map +1 -1
- package/dist/src/types.d.ts +15 -12
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/agent-version.js +2 -0
- package/dist/src/utils/agent-version.js.map +1 -1
- package/dist/src/utils/artifact-plan.js +13 -6
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +6 -3
- package/dist/src/utils/artifact-renderer.js +27 -32
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/artifact-request.d.ts +1 -0
- package/dist/src/utils/artifact-request.js +22 -12
- package/dist/src/utils/artifact-request.js.map +1 -1
- package/dist/src/utils/artifact-sources.d.ts +2 -2
- package/dist/src/utils/bundle-layout.js +18 -16
- package/dist/src/utils/bundle-layout.js.map +1 -1
- package/dist/src/utils/catalog-digests.js +2 -0
- package/dist/src/utils/catalog-digests.js.map +1 -1
- package/dist/src/utils/catalog-runtime-projection.d.ts +4 -3
- package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
- package/dist/src/utils/catalog-source-references.d.ts +5 -0
- package/dist/src/utils/catalog-source-references.js +42 -57
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/claude-native-render-receipt.d.ts +14 -0
- package/dist/src/utils/claude-native-render-receipt.js +26 -0
- package/dist/src/utils/claude-native-render-receipt.js.map +1 -0
- package/dist/src/utils/claude-skills-root.js +14 -3
- package/dist/src/utils/claude-skills-root.js.map +1 -1
- package/dist/src/utils/codex-manager.js +6 -12
- package/dist/src/utils/codex-manager.js.map +1 -1
- package/dist/src/utils/codex-native-observation.js +29 -13
- package/dist/src/utils/codex-native-observation.js.map +1 -1
- package/dist/src/utils/codex-reconciler.d.ts +2 -5
- package/dist/src/utils/codex-reconciler.js +25 -1
- package/dist/src/utils/codex-reconciler.js.map +1 -1
- package/dist/src/utils/codex-surface-analysis.js +5 -3
- package/dist/src/utils/codex-surface-analysis.js.map +1 -1
- package/dist/src/utils/local-marketplace.d.ts +14 -2
- package/dist/src/utils/local-marketplace.js +209 -42
- package/dist/src/utils/local-marketplace.js.map +1 -1
- package/dist/src/utils/managed-command-evidence.js +1 -1
- package/dist/src/utils/managed-command-evidence.js.map +1 -1
- package/dist/src/utils/managed-command-materialization.d.ts +4 -0
- package/dist/src/utils/managed-command-materialization.js +15 -6
- package/dist/src/utils/managed-command-materialization.js.map +1 -1
- package/dist/src/utils/managed-command-store.d.ts +15 -0
- package/dist/src/utils/managed-command-store.js +73 -8
- package/dist/src/utils/managed-command-store.js.map +1 -1
- package/dist/src/utils/native-cli.d.ts +2 -0
- package/dist/src/utils/native-cli.js +22 -0
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/native-demand.d.ts +10 -0
- package/dist/src/utils/native-demand.js +4 -0
- package/dist/src/utils/native-demand.js.map +1 -0
- package/dist/src/utils/ownership.js +2 -0
- package/dist/src/utils/ownership.js.map +1 -1
- package/dist/src/utils/paths.js +1 -1
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/platform-support.d.ts +1 -1
- package/dist/src/utils/platform-support.js +1 -1
- package/dist/src/utils/platform-support.js.map +1 -1
- package/dist/src/utils/plugin-config-impact.d.ts +3 -0
- package/dist/src/utils/plugin-config-impact.js +115 -273
- package/dist/src/utils/plugin-config-impact.js.map +1 -1
- package/dist/src/utils/plugin-config-references.d.ts +9 -2
- package/dist/src/utils/plugin-config-references.js +75 -85
- package/dist/src/utils/plugin-config-references.js.map +1 -1
- package/dist/src/utils/plugin-config-write.d.ts +58 -1
- package/dist/src/utils/plugin-config-write.js +756 -809
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +47 -46
- package/dist/src/utils/plugin-config.js +292 -833
- package/dist/src/utils/plugin-config.js.map +1 -1
- package/dist/src/utils/plugin-scripts.d.ts +11 -6
- package/dist/src/utils/plugin-scripts.js +52 -35
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/dist/src/utils/runtime-config.js +5 -4
- package/dist/src/utils/runtime-config.js.map +1 -1
- package/dist/src/utils/runtime-skill-closure.d.ts +2 -2
- package/dist/src/utils/runtime-skill-closure.js.map +1 -1
- package/dist/src/utils/state-paths.d.ts +8 -3
- package/dist/src/utils/state-paths.js +53 -16
- package/dist/src/utils/state-paths.js.map +1 -1
- package/dist/src/utils/windows-npm-shim.d.ts +2 -0
- package/dist/src/utils/windows-npm-shim.js +5 -7
- package/dist/src/utils/windows-npm-shim.js.map +1 -1
- package/dist/vitest.config.js +1 -0
- package/dist/vitest.config.js.map +1 -1
- package/package.json +3 -3
- package/dist/src/commands/sync-command.d.ts +0 -40
- package/dist/src/commands/sync-command.js +0 -254
- package/dist/src/commands/sync-command.js.map +0 -1
- package/dist/src/portable/skills-cli.d.ts +0 -51
- package/dist/src/portable/skills-cli.js +0 -202
- package/dist/src/portable/skills-cli.js.map +0 -1
- package/dist/src/tui/project-inventory.d.ts +0 -68
- package/dist/src/tui/project-inventory.js +0 -203
- package/dist/src/tui/project-inventory.js.map +0 -1
- package/dist/src/utils/plugin-intent-state.d.ts +0 -49
- package/dist/src/utils/plugin-intent-state.js +0 -320
- package/dist/src/utils/plugin-intent-state.js.map +0 -1
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { PlatformName, Scope } from '../types.js';
|
|
2
|
-
import { type StatusScopedTarget, type StatusTargetRevision, type StatusV8Payload } from '../commands/status-v6.js';
|
|
3
|
-
import { type PluginDependencyOverviewViewModel, type PluginListItemViewModel } from './model.js';
|
|
4
|
-
export type ProjectInventoryState = 'blocked' | 'pending' | 'unknown' | 'ready';
|
|
5
|
-
export interface ProjectInventoryTarget {
|
|
6
|
-
platform: PlatformName;
|
|
7
|
-
scope: Scope;
|
|
8
|
-
location: 'project' | 'sharedUser';
|
|
9
|
-
state: ProjectInventoryState;
|
|
10
|
-
expectedVersion?: string;
|
|
11
|
-
installedVersion?: string;
|
|
12
|
-
reasonCodes: string[];
|
|
13
|
-
}
|
|
14
|
-
export interface ProjectInventoryDependency {
|
|
15
|
-
pluginId: string;
|
|
16
|
-
displayName: string;
|
|
17
|
-
targets: ProjectInventoryTarget[];
|
|
18
|
-
}
|
|
19
|
-
export interface ProjectInventoryRoot {
|
|
20
|
-
pluginId: string;
|
|
21
|
-
sourceId: string;
|
|
22
|
-
displayName: string;
|
|
23
|
-
section: 'declared' | 'extraInstalled';
|
|
24
|
-
state: ProjectInventoryState;
|
|
25
|
-
targets: ProjectInventoryTarget[];
|
|
26
|
-
dependencies: ProjectInventoryDependency[];
|
|
27
|
-
}
|
|
28
|
-
export interface ProjectInventoryViewModel {
|
|
29
|
-
projectRoot?: string;
|
|
30
|
-
projectName?: string;
|
|
31
|
-
declarationState: 'ready' | 'absent' | 'invalid' | 'unavailable' | 'notProject';
|
|
32
|
-
declaredRoots: ProjectInventoryRoot[];
|
|
33
|
-
extraInstalledRoots: ProjectInventoryRoot[];
|
|
34
|
-
syncTargets: Array<{
|
|
35
|
-
pluginId: string;
|
|
36
|
-
platform: PlatformName;
|
|
37
|
-
scope: 'project';
|
|
38
|
-
}>;
|
|
39
|
-
counts: Record<ProjectInventoryState, number>;
|
|
40
|
-
}
|
|
41
|
-
type ProjectIntent = {
|
|
42
|
-
state: 'ready';
|
|
43
|
-
roots: Array<{
|
|
44
|
-
pluginId: string;
|
|
45
|
-
platforms: PlatformName[];
|
|
46
|
-
}>;
|
|
47
|
-
} | {
|
|
48
|
-
state: 'absent';
|
|
49
|
-
} | {
|
|
50
|
-
state: 'invalid' | 'unavailable';
|
|
51
|
-
code: string;
|
|
52
|
-
message: string;
|
|
53
|
-
};
|
|
54
|
-
export declare function hasStatusInstallationEvidence(target: StatusScopedTarget): boolean;
|
|
55
|
-
export declare function buildProjectInventory(options: {
|
|
56
|
-
projectRoot?: string;
|
|
57
|
-
projectIntent?: ProjectIntent;
|
|
58
|
-
status: StatusV8Payload;
|
|
59
|
-
pluginSummaries: readonly PluginListItemViewModel[];
|
|
60
|
-
targetRevisions?: readonly StatusTargetRevision[];
|
|
61
|
-
dependencyOverviews?: readonly PluginDependencyOverviewViewModel[];
|
|
62
|
-
actionableTargets?: readonly {
|
|
63
|
-
pluginId: string;
|
|
64
|
-
platform: PlatformName;
|
|
65
|
-
scope: Scope;
|
|
66
|
-
}[];
|
|
67
|
-
}): ProjectInventoryViewModel;
|
|
68
|
-
export {};
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import { flattenStatusTargets, statusTargetActivation, statusTargetIntent, statusTargetOwnershipState, statusTargetSharedNative, } from '../commands/status-v6.js';
|
|
3
|
-
import { hasActualScopeEvidence, } from './model.js';
|
|
4
|
-
const stateOrder = {
|
|
5
|
-
blocked: 0,
|
|
6
|
-
pending: 1,
|
|
7
|
-
unknown: 2,
|
|
8
|
-
ready: 3,
|
|
9
|
-
};
|
|
10
|
-
function reasonCodes(target) {
|
|
11
|
-
return [...new Set([...target.reasons, ...(target.sharedReasons ?? [])]
|
|
12
|
-
.flatMap((reason) => [reason.code, ...(reason.rootIssueCode ? [reason.rootIssueCode] : [])]))]
|
|
13
|
-
.sort((left, right) => left.localeCompare(right, 'en'));
|
|
14
|
-
}
|
|
15
|
-
export function hasStatusInstallationEvidence(target) {
|
|
16
|
-
return hasActualScopeEvidence(target)
|
|
17
|
-
|| target.reasons.some((reason) => reason.code === 'sourceMissing'
|
|
18
|
-
|| reason.code === 'catalogSourceUnavailable'
|
|
19
|
-
|| reason.code === 'bundleUnavailable');
|
|
20
|
-
}
|
|
21
|
-
function targetState(target) {
|
|
22
|
-
const reasons = [...target.reasons, ...(target.sharedReasons ?? [])];
|
|
23
|
-
if (target.state === 'blocked' || reasons.some((reason) => reason.severity === 'blocking')) {
|
|
24
|
-
return 'blocked';
|
|
25
|
-
}
|
|
26
|
-
if (target.state === 'ready')
|
|
27
|
-
return 'ready';
|
|
28
|
-
if (statusTargetSharedNative(target)?.state === 'unobserved'
|
|
29
|
-
|| statusTargetActivation(target)?.evidence === 'unobserved'
|
|
30
|
-
|| statusTargetOwnershipState(target) === 'error'
|
|
31
|
-
|| reasons.some((reason) => reason.code.includes('Unobserved')
|
|
32
|
-
|| reason.code.includes('ObservationFailed')
|
|
33
|
-
|| reason.code === 'nativeStateUnreadable'))
|
|
34
|
-
return 'unknown';
|
|
35
|
-
if (target.state === 'needsSync' && (hasActualScopeEvidence(target)
|
|
36
|
-
|| statusTargetOwnershipState(target) === 'absent'
|
|
37
|
-
|| statusTargetOwnershipState(target) === 'partial'))
|
|
38
|
-
return 'pending';
|
|
39
|
-
return 'unknown';
|
|
40
|
-
}
|
|
41
|
-
function combinedState(targets) {
|
|
42
|
-
return ['blocked', 'pending', 'unknown', 'ready']
|
|
43
|
-
.find((state) => targets.some((target) => target.state === state)) ?? 'unknown';
|
|
44
|
-
}
|
|
45
|
-
function sortedRoots(roots) {
|
|
46
|
-
return roots.sort((left, right) => stateOrder[left.state] - stateOrder[right.state]
|
|
47
|
-
|| left.displayName.localeCompare(right.displayName, 'en')
|
|
48
|
-
|| left.pluginId.localeCompare(right.pluginId, 'en'));
|
|
49
|
-
}
|
|
50
|
-
export function buildProjectInventory(options) {
|
|
51
|
-
const targets = flattenStatusTargets(options.status.targets);
|
|
52
|
-
const targetsById = new Map();
|
|
53
|
-
for (const target of targets) {
|
|
54
|
-
targetsById.set(target.pluginId, [...(targetsById.get(target.pluginId) ?? []), target]);
|
|
55
|
-
}
|
|
56
|
-
const plugins = new Map(options.pluginSummaries.map((plugin) => [plugin.pluginId, plugin]));
|
|
57
|
-
const sources = new Map(options.status.catalog.sources.map((source) => [source.id, source]));
|
|
58
|
-
const dependencies = new Map((options.dependencyOverviews ?? [])
|
|
59
|
-
.map((overview) => [overview.pluginId, overview]));
|
|
60
|
-
const revisions = new Map((options.targetRevisions ?? []).map((revision) => [
|
|
61
|
-
`${revision.pluginId}\0${revision.platform}\0${revision.scope}`, revision.revision,
|
|
62
|
-
]));
|
|
63
|
-
const targetView = (target, location) => {
|
|
64
|
-
const revision = revisions.get(`${target.pluginId}\0${target.platform}\0${target.scope}`);
|
|
65
|
-
return {
|
|
66
|
-
platform: target.platform,
|
|
67
|
-
scope: target.scope,
|
|
68
|
-
location,
|
|
69
|
-
state: targetState(target),
|
|
70
|
-
...(revision?.availableVersion ?? target.version
|
|
71
|
-
? { expectedVersion: revision?.availableVersion ?? target.version }
|
|
72
|
-
: {}),
|
|
73
|
-
...(revision?.installedVersion ? { installedVersion: revision.installedVersion } : {}),
|
|
74
|
-
reasonCodes: reasonCodes(target),
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
const nameFor = (pluginId) => plugins.get(pluginId)?.displayName
|
|
78
|
-
?? targetsById.get(pluginId)?.[0]?.pluginName
|
|
79
|
-
?? pluginId.split('/').at(-1) ?? pluginId;
|
|
80
|
-
const declared = options.projectIntent?.state === 'ready'
|
|
81
|
-
? options.projectIntent.roots : [];
|
|
82
|
-
const declaredIds = new Set(declared.map((root) => root.pluginId));
|
|
83
|
-
const dependencyIds = new Set();
|
|
84
|
-
const declaredRoots = declared.map((root) => {
|
|
85
|
-
const rootTargets = [];
|
|
86
|
-
const sharedDependencyKeys = new Set();
|
|
87
|
-
const rootStatusTargets = targetsById.get(root.pluginId) ?? [];
|
|
88
|
-
const sourceId = root.pluginId.split('/')[0] ?? root.pluginId;
|
|
89
|
-
const source = sources.get(sourceId);
|
|
90
|
-
const missingReason = !source ? 'sourceMissing'
|
|
91
|
-
: source.error ? 'catalogSourceUnavailable'
|
|
92
|
-
: !plugins.has(root.pluginId) ? 'bundleUnavailable' : 'projectTargetUnavailable';
|
|
93
|
-
for (const platform of root.platforms) {
|
|
94
|
-
const projectTarget = rootStatusTargets.find((target) => target.platform === platform && target.scope === 'project');
|
|
95
|
-
if (projectTarget)
|
|
96
|
-
rootTargets.push(targetView(projectTarget, 'project'));
|
|
97
|
-
else
|
|
98
|
-
rootTargets.push({
|
|
99
|
-
platform,
|
|
100
|
-
scope: 'project',
|
|
101
|
-
location: 'project',
|
|
102
|
-
state: missingReason === 'projectTargetUnavailable' ? 'unknown' : 'blocked',
|
|
103
|
-
...(plugins.get(root.pluginId)?.version
|
|
104
|
-
? { expectedVersion: plugins.get(root.pluginId).version }
|
|
105
|
-
: {}),
|
|
106
|
-
reasonCodes: [missingReason],
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
const overview = dependencies.get(root.pluginId);
|
|
110
|
-
const allDependencies = overview?.dependencies ?? [];
|
|
111
|
-
for (const dependency of allDependencies)
|
|
112
|
-
dependencyIds.add(dependency.pluginId);
|
|
113
|
-
const rootDependencyIds = new Set(allDependencies.map((dependency) => dependency.pluginId));
|
|
114
|
-
const consumers = rootStatusTargets.filter((target) => root.platforms.includes(target.platform) && target.scope === 'project');
|
|
115
|
-
const seenConsumers = new Set(consumers.map((target) => `${target.pluginId}\0${target.platform}\0${target.scope}`));
|
|
116
|
-
for (let index = 0; index < consumers.length; index += 1) {
|
|
117
|
-
for (const component of consumers[index].components) {
|
|
118
|
-
if (component.kind !== 'dependency' || component.state !== 'ready'
|
|
119
|
-
|| !rootDependencyIds.has(component.key))
|
|
120
|
-
continue;
|
|
121
|
-
const candidate = (targetsById.get(component.key) ?? []).find((target) => target.platform === consumers[index].platform
|
|
122
|
-
&& target.scope === component.metadata?.scope
|
|
123
|
-
&& hasActualScopeEvidence(target));
|
|
124
|
-
if (!candidate)
|
|
125
|
-
continue;
|
|
126
|
-
if (candidate.scope === 'user') {
|
|
127
|
-
sharedDependencyKeys.add(`${candidate.pluginId}\0${candidate.platform}`);
|
|
128
|
-
}
|
|
129
|
-
const key = `${candidate.pluginId}\0${candidate.platform}\0${candidate.scope}`;
|
|
130
|
-
if (!seenConsumers.has(key)) {
|
|
131
|
-
seenConsumers.add(key);
|
|
132
|
-
consumers.push(candidate);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
const nested = allDependencies.map((dependency) => ({
|
|
137
|
-
pluginId: dependency.pluginId,
|
|
138
|
-
displayName: dependency.displayName,
|
|
139
|
-
targets: (targetsById.get(dependency.pluginId) ?? [])
|
|
140
|
-
.filter((target) => root.platforms.includes(target.platform)
|
|
141
|
-
&& (target.scope === 'project'
|
|
142
|
-
&& (statusTargetIntent(target).scopes.includes('project') || hasActualScopeEvidence(target))
|
|
143
|
-
|| target.scope === 'user'
|
|
144
|
-
&& sharedDependencyKeys.has(`${dependency.pluginId}\0${target.platform}`)))
|
|
145
|
-
.map((target) => targetView(target, target.scope === 'user' ? 'sharedUser' : 'project')),
|
|
146
|
-
}));
|
|
147
|
-
return {
|
|
148
|
-
pluginId: root.pluginId,
|
|
149
|
-
sourceId,
|
|
150
|
-
displayName: nameFor(root.pluginId),
|
|
151
|
-
section: 'declared',
|
|
152
|
-
state: combinedState(rootTargets.filter((target) => target.location === 'project')),
|
|
153
|
-
targets: rootTargets,
|
|
154
|
-
dependencies: nested,
|
|
155
|
-
};
|
|
156
|
-
});
|
|
157
|
-
const extraById = new Map();
|
|
158
|
-
if (options.projectRoot) {
|
|
159
|
-
for (const target of targets) {
|
|
160
|
-
if (target.scope !== 'project' || !hasStatusInstallationEvidence(target)
|
|
161
|
-
|| declaredIds.has(target.pluginId) || dependencyIds.has(target.pluginId)
|
|
162
|
-
|| statusTargetIntent(target).relation === 'dependency')
|
|
163
|
-
continue;
|
|
164
|
-
extraById.set(target.pluginId, [
|
|
165
|
-
...(extraById.get(target.pluginId) ?? []), targetView(target, 'project'),
|
|
166
|
-
]);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
const extraInstalledRoots = [...extraById].map(([pluginId, extraTargets]) => ({
|
|
170
|
-
pluginId,
|
|
171
|
-
sourceId: pluginId.split('/')[0] ?? pluginId,
|
|
172
|
-
displayName: nameFor(pluginId),
|
|
173
|
-
section: 'extraInstalled',
|
|
174
|
-
state: combinedState(extraTargets),
|
|
175
|
-
targets: extraTargets,
|
|
176
|
-
dependencies: [],
|
|
177
|
-
}));
|
|
178
|
-
const counts = { blocked: 0, pending: 0, unknown: 0, ready: 0 };
|
|
179
|
-
for (const root of declaredRoots)
|
|
180
|
-
counts[root.state] += 1;
|
|
181
|
-
const declaredPlatforms = new Set(declared.flatMap((root) => root.platforms.map((platform) => `${root.pluginId}\0${platform}`)));
|
|
182
|
-
const syncTargets = [...new Map((options.actionableTargets ?? [])
|
|
183
|
-
.filter((target) => target.scope === 'project'
|
|
184
|
-
&& declaredPlatforms.has(`${target.pluginId}\0${target.platform}`))
|
|
185
|
-
.map((target) => [`${target.pluginId}\0${target.platform}`, {
|
|
186
|
-
pluginId: target.pluginId,
|
|
187
|
-
platform: target.platform,
|
|
188
|
-
scope: 'project',
|
|
189
|
-
}])).values()];
|
|
190
|
-
return {
|
|
191
|
-
...(options.projectRoot ? {
|
|
192
|
-
projectRoot: options.projectRoot,
|
|
193
|
-
projectName: path.basename(options.projectRoot),
|
|
194
|
-
} : {}),
|
|
195
|
-
declarationState: options.projectRoot
|
|
196
|
-
? options.projectIntent?.state ?? 'absent' : 'notProject',
|
|
197
|
-
declaredRoots: sortedRoots(declaredRoots),
|
|
198
|
-
extraInstalledRoots: sortedRoots(extraInstalledRoots),
|
|
199
|
-
syncTargets,
|
|
200
|
-
counts,
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
//# sourceMappingURL=project-inventory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-inventory.js","sourceRoot":"","sources":["../../../src/tui/project-inventory.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,0BAA0B,EAC1B,wBAAwB,GAIzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,sBAAsB,GAGvB,MAAM,YAAY,CAAC;AA6CpB,MAAM,UAAU,GAA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AAE,WAAW,CAAC,mBAAmB,CAAC;QACrD,WAAW;QACX,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import type { DependencyScopeOverride, PlatformName, Scope } from '../types.js';
|
|
2
|
-
export declare const PLUGIN_INTENT_SCHEMA_VERSION = 2;
|
|
3
|
-
export declare const PLUGIN_INTENT_KIND = "aw-plugin-intents";
|
|
4
|
-
export interface PluginIntentRoot {
|
|
5
|
-
pluginId: string;
|
|
6
|
-
platforms: PlatformName[];
|
|
7
|
-
}
|
|
8
|
-
export type PluginIntentDependencyScopeOverride = DependencyScopeOverride;
|
|
9
|
-
export interface PluginIntentState {
|
|
10
|
-
schemaVersion: 2;
|
|
11
|
-
kind: 'aw-plugin-intents';
|
|
12
|
-
roots: PluginIntentRoot[];
|
|
13
|
-
dependencyScopeOverrides: PluginIntentDependencyScopeOverride[];
|
|
14
|
-
}
|
|
15
|
-
export interface PluginIntentStateLocation {
|
|
16
|
-
scope: Scope;
|
|
17
|
-
cwd: string;
|
|
18
|
-
env?: NodeJS.ProcessEnv;
|
|
19
|
-
}
|
|
20
|
-
export type PluginIntentStateObservation = {
|
|
21
|
-
state: 'ready';
|
|
22
|
-
value: PluginIntentState;
|
|
23
|
-
} | {
|
|
24
|
-
state: 'absent';
|
|
25
|
-
} | {
|
|
26
|
-
state: 'invalid';
|
|
27
|
-
code: 'pluginIntentStateInvalid';
|
|
28
|
-
message: string;
|
|
29
|
-
} | {
|
|
30
|
-
state: 'unavailable';
|
|
31
|
-
code: 'pluginIntentStateUnavailable';
|
|
32
|
-
message: string;
|
|
33
|
-
};
|
|
34
|
-
type PluginIntentPathAccess = 'read' | 'write';
|
|
35
|
-
export declare function createEmptyPluginIntentState(): PluginIntentState;
|
|
36
|
-
export declare function canonicalizePluginIntentState(state: PluginIntentState): PluginIntentState;
|
|
37
|
-
export declare function parsePluginIntentState(value: unknown): PluginIntentState;
|
|
38
|
-
export declare function serializePluginIntentState(state: PluginIntentState): string;
|
|
39
|
-
export declare function calculatePluginIntentDigest(state: PluginIntentState): string;
|
|
40
|
-
export declare function upsertPluginIntentRoot(state: PluginIntentState, root: PluginIntentRoot): PluginIntentState;
|
|
41
|
-
export declare function mergePluginIntentRootPlatforms(state: PluginIntentState, root: PluginIntentRoot): PluginIntentState;
|
|
42
|
-
export declare function addPluginIntentRoot(state: PluginIntentState, root: PluginIntentRoot): PluginIntentState;
|
|
43
|
-
export declare function removePluginIntentRoot(state: PluginIntentState, pluginId: string): PluginIntentState;
|
|
44
|
-
export declare function removePluginIntentRootPlatforms(state: PluginIntentState, root: PluginIntentRoot): PluginIntentState;
|
|
45
|
-
export declare function resolvePluginIntentStatePath(location: PluginIntentStateLocation, access?: PluginIntentPathAccess): string;
|
|
46
|
-
export declare function observePluginIntentState(location: PluginIntentStateLocation): Promise<PluginIntentStateObservation>;
|
|
47
|
-
export declare function readPluginIntentState(location: PluginIntentStateLocation): Promise<PluginIntentState>;
|
|
48
|
-
export declare function writePluginIntentState(location: PluginIntentStateLocation, state: PluginIntentState): Promise<PluginIntentState>;
|
|
49
|
-
export {};
|
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import crypto from 'node:crypto';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import fs from 'fs-extra';
|
|
4
|
-
import { parsePluginId } from './multi-source-catalog.js';
|
|
5
|
-
import { atomicReplaceConfigFile, resolveAwProjectRoot, } from './plugin-config.js';
|
|
6
|
-
import { assertCanonicalProjectManagedRoots, assertProjectSharedConfigPathVisible, } from './project-boundary.js';
|
|
7
|
-
import { resolveAwHome } from './state-paths.js';
|
|
8
|
-
import { assertTestReadablePath, assertTestWritablePath, } from './test-path-fence.js';
|
|
9
|
-
export const PLUGIN_INTENT_SCHEMA_VERSION = 2;
|
|
10
|
-
export const PLUGIN_INTENT_KIND = 'aw-plugin-intents';
|
|
11
|
-
function compareText(left, right) {
|
|
12
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
13
|
-
}
|
|
14
|
-
function isRecord(value) {
|
|
15
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
16
|
-
}
|
|
17
|
-
function assertExactKeys(value, expected, fieldName) {
|
|
18
|
-
const allowed = new Set(expected);
|
|
19
|
-
const unknown = Object.keys(value).filter((key) => !allowed.has(key));
|
|
20
|
-
const missing = expected.filter((key) => !(key in value));
|
|
21
|
-
if (unknown.length > 0 || missing.length > 0) {
|
|
22
|
-
throw new Error(`Invalid ${fieldName}: expected exactly ${expected.join(', ')}.`
|
|
23
|
-
+ `${unknown.length > 0 ? ` Unknown: ${unknown.sort(compareText).join(', ')}.` : ''}`
|
|
24
|
-
+ `${missing.length > 0 ? ` Missing: ${missing.join(', ')}.` : ''}`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function parseCanonicalPluginId(value, fieldName) {
|
|
28
|
-
if (typeof value !== 'string') {
|
|
29
|
-
throw new Error(`Invalid ${fieldName}: expected a source-qualified plugin ID.`);
|
|
30
|
-
}
|
|
31
|
-
const parsed = parsePluginId(value);
|
|
32
|
-
if (!parsed.sourceId) {
|
|
33
|
-
throw new Error(`Invalid ${fieldName}: expected a source-qualified plugin ID.`);
|
|
34
|
-
}
|
|
35
|
-
return `${parsed.sourceId}/${parsed.pluginName}`;
|
|
36
|
-
}
|
|
37
|
-
function parsePlatform(value, fieldName) {
|
|
38
|
-
if (value !== 'codex' && value !== 'claude') {
|
|
39
|
-
throw new Error(`Invalid ${fieldName}: expected codex or claude.`);
|
|
40
|
-
}
|
|
41
|
-
return value;
|
|
42
|
-
}
|
|
43
|
-
function parseScope(value, fieldName) {
|
|
44
|
-
if (value !== 'project' && value !== 'user') {
|
|
45
|
-
throw new Error(`Invalid ${fieldName}: expected project or user.`);
|
|
46
|
-
}
|
|
47
|
-
return value;
|
|
48
|
-
}
|
|
49
|
-
function canonicalPlatforms(platforms) {
|
|
50
|
-
return [...new Set(platforms)].sort(compareText);
|
|
51
|
-
}
|
|
52
|
-
export function createEmptyPluginIntentState() {
|
|
53
|
-
return {
|
|
54
|
-
schemaVersion: PLUGIN_INTENT_SCHEMA_VERSION,
|
|
55
|
-
kind: PLUGIN_INTENT_KIND,
|
|
56
|
-
roots: [],
|
|
57
|
-
dependencyScopeOverrides: [],
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
export function canonicalizePluginIntentState(state) {
|
|
61
|
-
const roots = state.roots.map((root) => ({
|
|
62
|
-
pluginId: parseCanonicalPluginId(root.pluginId, 'roots[].pluginId'),
|
|
63
|
-
platforms: canonicalPlatforms(root.platforms.map((platform) => parsePlatform(platform, 'roots[].platforms[]'))),
|
|
64
|
-
}));
|
|
65
|
-
if (roots.some((root) => root.platforms.length === 0)) {
|
|
66
|
-
throw new Error('Invalid roots[].platforms: expected at least one platform.');
|
|
67
|
-
}
|
|
68
|
-
if (new Set(roots.map((root) => root.pluginId)).size !== roots.length) {
|
|
69
|
-
throw new Error('Invalid roots: duplicate pluginId.');
|
|
70
|
-
}
|
|
71
|
-
const dependencyScopeOverrides = state.dependencyScopeOverrides.map((override) => ({
|
|
72
|
-
pluginId: parseCanonicalPluginId(override.pluginId, 'dependencyScopeOverrides[].pluginId'),
|
|
73
|
-
platform: parsePlatform(override.platform, 'dependencyScopeOverrides[].platform'),
|
|
74
|
-
scope: parseScope(override.scope, 'dependencyScopeOverrides[].scope'),
|
|
75
|
-
}));
|
|
76
|
-
const overrideKeys = dependencyScopeOverrides.map((override) => `${override.pluginId}\0${override.platform}`);
|
|
77
|
-
if (new Set(overrideKeys).size !== overrideKeys.length) {
|
|
78
|
-
throw new Error('Invalid dependencyScopeOverrides: duplicate pluginId/platform target.');
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
schemaVersion: PLUGIN_INTENT_SCHEMA_VERSION,
|
|
82
|
-
kind: PLUGIN_INTENT_KIND,
|
|
83
|
-
roots: roots.sort((left, right) => compareText(left.pluginId, right.pluginId)),
|
|
84
|
-
dependencyScopeOverrides: dependencyScopeOverrides.sort((left, right) => compareText(`${left.pluginId}\0${left.platform}`, `${right.pluginId}\0${right.platform}`)),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
export function parsePluginIntentState(value) {
|
|
88
|
-
if (!isRecord(value))
|
|
89
|
-
throw new Error('Invalid plugin intent state: expected an object.');
|
|
90
|
-
assertExactKeys(value, ['schemaVersion', 'kind', 'roots', 'dependencyScopeOverrides'], 'plugin intent state');
|
|
91
|
-
if (value.schemaVersion !== PLUGIN_INTENT_SCHEMA_VERSION) {
|
|
92
|
-
throw new Error('Invalid plugin intent state schemaVersion: expected 2.');
|
|
93
|
-
}
|
|
94
|
-
if (value.kind !== PLUGIN_INTENT_KIND) {
|
|
95
|
-
throw new Error(`Invalid plugin intent state kind: expected ${PLUGIN_INTENT_KIND}.`);
|
|
96
|
-
}
|
|
97
|
-
if (!Array.isArray(value.roots))
|
|
98
|
-
throw new Error('Invalid roots: expected an array.');
|
|
99
|
-
if (!Array.isArray(value.dependencyScopeOverrides)) {
|
|
100
|
-
throw new Error('Invalid dependencyScopeOverrides: expected an array.');
|
|
101
|
-
}
|
|
102
|
-
const roots = value.roots.map((entry, index) => {
|
|
103
|
-
if (!isRecord(entry))
|
|
104
|
-
throw new Error(`Invalid roots[${index}]: expected an object.`);
|
|
105
|
-
assertExactKeys(entry, ['pluginId', 'platforms'], `roots[${index}]`);
|
|
106
|
-
if (!Array.isArray(entry.platforms)) {
|
|
107
|
-
throw new Error(`Invalid roots[${index}].platforms: expected an array.`);
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
pluginId: parseCanonicalPluginId(entry.pluginId, `roots[${index}].pluginId`),
|
|
111
|
-
platforms: entry.platforms.map((platform, platformIndex) => parsePlatform(platform, `roots[${index}].platforms[${platformIndex}]`)),
|
|
112
|
-
};
|
|
113
|
-
});
|
|
114
|
-
const dependencyScopeOverrides = value.dependencyScopeOverrides.map((entry, index) => {
|
|
115
|
-
if (!isRecord(entry)) {
|
|
116
|
-
throw new Error(`Invalid dependencyScopeOverrides[${index}]: expected an object.`);
|
|
117
|
-
}
|
|
118
|
-
assertExactKeys(entry, ['pluginId', 'platform', 'scope'], `dependencyScopeOverrides[${index}]`);
|
|
119
|
-
return {
|
|
120
|
-
pluginId: parseCanonicalPluginId(entry.pluginId, `dependencyScopeOverrides[${index}].pluginId`),
|
|
121
|
-
platform: parsePlatform(entry.platform, `dependencyScopeOverrides[${index}].platform`),
|
|
122
|
-
scope: parseScope(entry.scope, `dependencyScopeOverrides[${index}].scope`),
|
|
123
|
-
};
|
|
124
|
-
});
|
|
125
|
-
return canonicalizePluginIntentState({
|
|
126
|
-
schemaVersion: PLUGIN_INTENT_SCHEMA_VERSION,
|
|
127
|
-
kind: PLUGIN_INTENT_KIND,
|
|
128
|
-
roots,
|
|
129
|
-
dependencyScopeOverrides,
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
export function serializePluginIntentState(state) {
|
|
133
|
-
return `${JSON.stringify(canonicalizePluginIntentState(state), null, 2)}\n`;
|
|
134
|
-
}
|
|
135
|
-
export function calculatePluginIntentDigest(state) {
|
|
136
|
-
const canonical = canonicalizePluginIntentState(state);
|
|
137
|
-
const digest = crypto.createHash('sha256').update(JSON.stringify(canonical)).digest('hex');
|
|
138
|
-
return `sha256:${digest}`;
|
|
139
|
-
}
|
|
140
|
-
export function upsertPluginIntentRoot(state, root) {
|
|
141
|
-
const pluginId = parseCanonicalPluginId(root.pluginId, 'root.pluginId');
|
|
142
|
-
return canonicalizePluginIntentState({
|
|
143
|
-
...state,
|
|
144
|
-
roots: [
|
|
145
|
-
...state.roots.filter((entry) => entry.pluginId !== pluginId),
|
|
146
|
-
{ pluginId, platforms: [...root.platforms] },
|
|
147
|
-
],
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
export function mergePluginIntentRootPlatforms(state, root) {
|
|
151
|
-
const pluginId = parseCanonicalPluginId(root.pluginId, 'root.pluginId');
|
|
152
|
-
const current = state.roots.find((entry) => entry.pluginId === pluginId);
|
|
153
|
-
return upsertPluginIntentRoot(state, {
|
|
154
|
-
pluginId,
|
|
155
|
-
platforms: [...(current?.platforms ?? []), ...root.platforms],
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
export function addPluginIntentRoot(state, root) {
|
|
159
|
-
const pluginId = parseCanonicalPluginId(root.pluginId, 'root.pluginId');
|
|
160
|
-
if (state.roots.some((entry) => entry.pluginId === pluginId)) {
|
|
161
|
-
throw new Error(`Plugin intent root already exists: ${pluginId}`);
|
|
162
|
-
}
|
|
163
|
-
return upsertPluginIntentRoot(state, { ...root, pluginId });
|
|
164
|
-
}
|
|
165
|
-
export function removePluginIntentRoot(state, pluginId) {
|
|
166
|
-
const canonicalPluginId = parseCanonicalPluginId(pluginId, 'pluginId');
|
|
167
|
-
return canonicalizePluginIntentState({
|
|
168
|
-
...state,
|
|
169
|
-
roots: state.roots.filter((entry) => entry.pluginId !== canonicalPluginId),
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
export function removePluginIntentRootPlatforms(state, root) {
|
|
173
|
-
const pluginId = parseCanonicalPluginId(root.pluginId, 'root.pluginId');
|
|
174
|
-
const removed = new Set(root.platforms.map((platform) => parsePlatform(platform, 'root.platforms[]')));
|
|
175
|
-
const current = state.roots.find((entry) => entry.pluginId === pluginId);
|
|
176
|
-
if (!current)
|
|
177
|
-
return state;
|
|
178
|
-
const platforms = current.platforms.filter((platform) => !removed.has(platform));
|
|
179
|
-
return platforms.length === 0
|
|
180
|
-
? removePluginIntentRoot(state, pluginId)
|
|
181
|
-
: upsertPluginIntentRoot(state, { pluginId, platforms });
|
|
182
|
-
}
|
|
183
|
-
export function resolvePluginIntentStatePath(location, access) {
|
|
184
|
-
const filePath = location.scope === 'user'
|
|
185
|
-
? path.join(resolveAwHome(location.env), 'plugin-intents.json')
|
|
186
|
-
: path.join(resolveAwProjectRoot(location.cwd), '.agent-workflows', 'plugin-intents.json');
|
|
187
|
-
if (access === 'read') {
|
|
188
|
-
return assertTestReadablePath(filePath, `${location.scope} plugin intent state`, '用测试隔离环境登记可读 project 或 AW_HOME 根。');
|
|
189
|
-
}
|
|
190
|
-
if (access === 'write') {
|
|
191
|
-
return assertTestWritablePath(filePath, `${location.scope} plugin intent state`, '用 createIsolatedTestEnv() 或 withSafeTestCwd() 登记可写根。');
|
|
192
|
-
}
|
|
193
|
-
return filePath;
|
|
194
|
-
}
|
|
195
|
-
function assertPathInsideRoot(allowedRoot, filePath) {
|
|
196
|
-
const relative = path.relative(path.resolve(allowedRoot), path.resolve(filePath));
|
|
197
|
-
if (relative === ''
|
|
198
|
-
|| relative === '..'
|
|
199
|
-
|| relative.startsWith(`..${path.sep}`)
|
|
200
|
-
|| path.isAbsolute(relative)) {
|
|
201
|
-
throw new Error('Plugin intent path escapes its allowed root.');
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
async function assertReadableIntentPath(allowedRoot, filePath) {
|
|
205
|
-
assertPathInsideRoot(allowedRoot, filePath);
|
|
206
|
-
const root = path.resolve(allowedRoot);
|
|
207
|
-
const rootStats = await fs.lstat(root).catch((error) => {
|
|
208
|
-
if (error.code === 'ENOENT')
|
|
209
|
-
return null;
|
|
210
|
-
throw error;
|
|
211
|
-
});
|
|
212
|
-
if (!rootStats)
|
|
213
|
-
return false;
|
|
214
|
-
if (rootStats.isSymbolicLink() || !rootStats.isDirectory()) {
|
|
215
|
-
throw new Error(`Plugin intent root must be a regular directory: ${root}`);
|
|
216
|
-
}
|
|
217
|
-
let current = root;
|
|
218
|
-
for (const segment of path.relative(root, path.resolve(filePath)).split(path.sep).filter(Boolean)) {
|
|
219
|
-
current = path.join(current, segment);
|
|
220
|
-
const stats = await fs.lstat(current).catch((error) => {
|
|
221
|
-
if (error.code === 'ENOENT')
|
|
222
|
-
return null;
|
|
223
|
-
throw error;
|
|
224
|
-
});
|
|
225
|
-
if (!stats)
|
|
226
|
-
return false;
|
|
227
|
-
if (stats.isSymbolicLink()) {
|
|
228
|
-
throw new Error(`Plugin intent path cannot contain a symbolic link: ${current}`);
|
|
229
|
-
}
|
|
230
|
-
if (current === path.resolve(filePath) && !stats.isFile()) {
|
|
231
|
-
throw new Error(`Plugin intent target must be a regular file: ${filePath}`);
|
|
232
|
-
}
|
|
233
|
-
if (current !== path.resolve(filePath) && !stats.isDirectory()) {
|
|
234
|
-
throw new Error(`Plugin intent path parent must be a directory: ${current}`);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return true;
|
|
238
|
-
}
|
|
239
|
-
async function resolveIntentLocation(location) {
|
|
240
|
-
if (location.scope === 'user') {
|
|
241
|
-
const allowedRoot = resolveAwHome(location.env);
|
|
242
|
-
return {
|
|
243
|
-
allowedRoot,
|
|
244
|
-
filePath: resolvePluginIntentStatePath(location),
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
const allowedRoot = await assertCanonicalProjectManagedRoots({
|
|
248
|
-
cwd: location.cwd,
|
|
249
|
-
rootNames: [],
|
|
250
|
-
managedPaths: ['.agent-workflows'],
|
|
251
|
-
});
|
|
252
|
-
return {
|
|
253
|
-
allowedRoot,
|
|
254
|
-
filePath: path.join(allowedRoot, '.agent-workflows', 'plugin-intents.json'),
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
async function readPluginIntentStateObservationUnsafe(location) {
|
|
258
|
-
resolvePluginIntentStatePath(location, 'read');
|
|
259
|
-
const { allowedRoot, filePath } = await resolveIntentLocation(location);
|
|
260
|
-
if (!await assertReadableIntentPath(allowedRoot, filePath)) {
|
|
261
|
-
return { state: 'absent' };
|
|
262
|
-
}
|
|
263
|
-
let value;
|
|
264
|
-
try {
|
|
265
|
-
value = JSON.parse(await fs.readFile(filePath, 'utf8'));
|
|
266
|
-
}
|
|
267
|
-
catch (error) {
|
|
268
|
-
if (error instanceof SyntaxError) {
|
|
269
|
-
throw new Error('Invalid plugin intent state JSON.');
|
|
270
|
-
}
|
|
271
|
-
throw error;
|
|
272
|
-
}
|
|
273
|
-
return { state: 'ready', value: parsePluginIntentState(value) };
|
|
274
|
-
}
|
|
275
|
-
function invalidIntentPathError(error) {
|
|
276
|
-
if (!(error instanceof Error))
|
|
277
|
-
return false;
|
|
278
|
-
return /(?:symbolic link|regular (?:directory|file)|escapes its allowed root|符号链接|realpath 越界|必须位于 repo 内)/iu
|
|
279
|
-
.test(error.message);
|
|
280
|
-
}
|
|
281
|
-
export async function observePluginIntentState(location) {
|
|
282
|
-
try {
|
|
283
|
-
return await readPluginIntentStateObservationUnsafe(location);
|
|
284
|
-
}
|
|
285
|
-
catch (error) {
|
|
286
|
-
if (error instanceof Error && error.name === 'AbortError')
|
|
287
|
-
throw error;
|
|
288
|
-
const invalid = invalidIntentPathError(error)
|
|
289
|
-
|| error instanceof SyntaxError
|
|
290
|
-
|| error instanceof Error && /^Invalid (?:plugin intent|roots|dependencyScopeOverrides)/u.test(error.message);
|
|
291
|
-
return invalid ? {
|
|
292
|
-
state: 'invalid',
|
|
293
|
-
code: 'pluginIntentStateInvalid',
|
|
294
|
-
message: '插件声明格式无效或路径不安全。',
|
|
295
|
-
} : {
|
|
296
|
-
state: 'unavailable',
|
|
297
|
-
code: 'pluginIntentStateUnavailable',
|
|
298
|
-
message: '无法读取插件声明。',
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
export async function readPluginIntentState(location) {
|
|
303
|
-
const observation = await readPluginIntentStateObservationUnsafe(location);
|
|
304
|
-
return observation.state === 'ready' ? observation.value : createEmptyPluginIntentState();
|
|
305
|
-
}
|
|
306
|
-
export async function writePluginIntentState(location, state) {
|
|
307
|
-
const requestedPath = resolvePluginIntentStatePath(location, 'write');
|
|
308
|
-
if (location.scope === 'project') {
|
|
309
|
-
await assertProjectSharedConfigPathVisible({ cwd: location.cwd, targetPath: requestedPath });
|
|
310
|
-
}
|
|
311
|
-
const { allowedRoot, filePath } = await resolveIntentLocation(location);
|
|
312
|
-
const canonical = canonicalizePluginIntentState(state);
|
|
313
|
-
await atomicReplaceConfigFile({
|
|
314
|
-
filePath,
|
|
315
|
-
allowedRoot,
|
|
316
|
-
content: serializePluginIntentState(canonical),
|
|
317
|
-
});
|
|
318
|
-
return canonical;
|
|
319
|
-
}
|
|
320
|
-
//# sourceMappingURL=plugin-intent-state.js.map
|