@lesliechan721/aw 0.1.0-beta.10 → 0.1.0-beta.12
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-config.d.mts +1 -50
- package/dist/authoring/assets/aw-config.mjs +58 -928
- package/dist/authoring/assets/aw-config.mjs.map +1 -1
- package/dist/authoring/scripts/init-plugin.mjs +28 -33
- package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-version-check.d.mts +1 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs +229 -8
- package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
- package/dist/authoring/scripts/validate-plugin.mjs +159 -48
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
- package/dist/scripts/bundle-plugins.js +18 -4
- package/dist/scripts/bundle-plugins.js.map +1 -1
- package/dist/scripts/test-plugin-scripts.d.ts +2 -0
- package/dist/scripts/test-plugin-scripts.js +21 -5
- 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 +1 -1
- package/dist/src/commands/aw-capabilities.js.map +1 -1
- package/dist/src/commands/catalog-dev-source.d.ts +6 -3
- package/dist/src/commands/catalog-dev-source.js +96 -35
- package/dist/src/commands/catalog-dev-source.js.map +1 -1
- package/dist/src/commands/catalog-publication-inspection.d.ts +1 -1
- package/dist/src/commands/catalog-publication-inspection.js +54 -8
- package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
- package/dist/src/commands/catalog-publication-journal.js +1 -1
- package/dist/src/commands/catalog-publication-journal.js.map +1 -1
- package/dist/src/commands/catalog-source.d.ts +19 -4
- package/dist/src/commands/catalog-source.js +121 -12
- package/dist/src/commands/catalog-source.js.map +1 -1
- package/dist/src/commands/catalog-store.d.ts +26 -7
- package/dist/src/commands/catalog-store.js +361 -42
- package/dist/src/commands/catalog-store.js.map +1 -1
- package/dist/src/commands/console.js +28 -17
- package/dist/src/commands/console.js.map +1 -1
- package/dist/src/commands/operation-plan.d.ts +2 -1
- package/dist/src/commands/operation-plan.js +24 -0
- package/dist/src/commands/operation-plan.js.map +1 -1
- package/dist/src/commands/operation-planner.d.ts +2 -2
- package/dist/src/commands/operation-planner.js +22 -20
- package/dist/src/commands/operation-planner.js.map +1 -1
- package/dist/src/commands/options.d.ts +2 -2
- package/dist/src/commands/options.js +18 -4
- package/dist/src/commands/options.js.map +1 -1
- package/dist/src/commands/plugin-capabilities.js +2 -2
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/rebuild-command.d.ts +19 -0
- package/dist/src/commands/rebuild-command.js +828 -283
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +25 -47
- package/dist/src/commands/rebuild-integration.js +1176 -1016
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +50 -12
- package/dist/src/commands/rebuild-operations.js +207 -101
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/status-v6.d.ts +21 -2
- package/dist/src/commands/status-v6.js +163 -31
- package/dist/src/commands/status-v6.js.map +1 -1
- package/dist/src/commands/sync-command.d.ts +17 -0
- package/dist/src/commands/sync-command.js +45 -37
- package/dist/src/commands/sync-command.js.map +1 -1
- package/dist/src/commands/write-commands.d.ts +5 -0
- package/dist/src/commands/write-commands.js +50 -3
- package/dist/src/commands/write-commands.js.map +1 -1
- package/dist/src/generators/local-plugin.js +14 -4
- package/dist/src/generators/local-plugin.js.map +1 -1
- package/dist/src/index.js +260 -91
- package/dist/src/index.js.map +1 -1
- package/dist/src/output/command-receipt.js +1 -3
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/output/rebuild-progress.js +1 -3
- package/dist/src/output/rebuild-progress.js.map +1 -1
- package/dist/src/portable/materializer.js +10 -8
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/tui/catalog-generation.js +41 -1
- package/dist/src/tui/catalog-generation.js.map +1 -1
- package/dist/src/tui/catalog-sources/session.d.ts +1 -0
- package/dist/src/tui/catalog-sources/session.js +16 -3
- package/dist/src/tui/catalog-sources/session.js.map +1 -1
- package/dist/src/tui/catalog-sources/types.d.ts +3 -2
- package/dist/src/tui/components.d.ts +4 -0
- package/dist/src/tui/components.js +36 -24
- package/dist/src/tui/components.js.map +1 -1
- package/dist/src/tui/console-app-v4.d.ts +13 -4
- package/dist/src/tui/console-app-v4.js +2065 -857
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/controller-runtime.js +731 -62
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +156 -10
- package/dist/src/tui/controller.js +1187 -163
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/diagnostic-projection.d.ts +22 -0
- package/dist/src/tui/diagnostic-projection.js +437 -0
- package/dist/src/tui/diagnostic-projection.js.map +1 -0
- package/dist/src/tui/diagnostics.d.ts +1 -1
- package/dist/src/tui/diagnostics.js +7 -2
- package/dist/src/tui/diagnostics.js.map +1 -1
- package/dist/src/tui/glossary.d.ts +23 -0
- package/dist/src/tui/glossary.js +42 -0
- package/dist/src/tui/glossary.js.map +1 -0
- package/dist/src/tui/index.d.ts +4 -1
- package/dist/src/tui/index.js +4 -1
- package/dist/src/tui/index.js.map +1 -1
- package/dist/src/tui/keys.d.ts +44 -0
- package/dist/src/tui/keys.js +43 -15
- package/dist/src/tui/keys.js.map +1 -1
- package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
- package/dist/src/tui/lifecycle-action-view.js +34 -0
- package/dist/src/tui/lifecycle-action-view.js.map +1 -0
- package/dist/src/tui/model.d.ts +12 -2
- package/dist/src/tui/model.js +128 -52
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/tui/operation-diagnostic-screens.d.ts +21 -0
- package/dist/src/tui/operation-diagnostic-screens.js +101 -0
- package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
- package/dist/src/tui/operation-history.d.ts +80 -0
- package/dist/src/tui/operation-history.js +130 -0
- package/dist/src/tui/operation-history.js.map +1 -0
- package/dist/src/tui/operation-review-planner.js +366 -99
- package/dist/src/tui/operation-review-planner.js.map +1 -1
- package/dist/src/tui/router.d.ts +82 -17
- package/dist/src/tui/router.js +186 -38
- package/dist/src/tui/router.js.map +1 -1
- package/dist/src/tui/screen-registry.d.ts +546 -0
- package/dist/src/tui/screen-registry.js +179 -0
- package/dist/src/tui/screen-registry.js.map +1 -0
- package/dist/src/tui/session-console-app.d.ts +6 -0
- package/dist/src/tui/session-console-app.js +13 -0
- package/dist/src/tui/session-console-app.js.map +1 -0
- package/dist/src/tui/session-host.d.ts +44 -0
- package/dist/src/tui/session-host.js +197 -0
- package/dist/src/tui/session-host.js.map +1 -0
- package/dist/src/types.d.ts +64 -3
- package/dist/src/types.js +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/agent-version.js +1 -1
- package/dist/src/utils/agent-version.js.map +1 -1
- package/dist/src/utils/artifact-plan.d.ts +2 -2
- package/dist/src/utils/artifact-plan.js +8 -6
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +2 -1
- package/dist/src/utils/artifact-renderer.js +139 -120
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/artifact-request.d.ts +5 -0
- package/dist/src/utils/artifact-request.js +40 -0
- package/dist/src/utils/artifact-request.js.map +1 -1
- package/dist/src/utils/bundle-layout.js +4 -4
- package/dist/src/utils/bundle-layout.js.map +1 -1
- package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
- package/dist/src/utils/catalog-capability-projection.js +14 -0
- package/dist/src/utils/catalog-capability-projection.js.map +1 -0
- package/dist/src/utils/catalog-generation-resolver.d.ts +14 -2
- package/dist/src/utils/catalog-generation-resolver.js +49 -27
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
- package/dist/src/utils/catalog-generation-service.d.ts +8 -1
- package/dist/src/utils/catalog-generation-service.js +81 -47
- package/dist/src/utils/catalog-generation-service.js.map +1 -1
- package/dist/src/utils/catalog-generation-store.d.ts +1 -0
- package/dist/src/utils/catalog-generation-store.js +60 -5
- package/dist/src/utils/catalog-generation-store.js.map +1 -1
- package/dist/src/utils/catalog-operation-context.js +1 -0
- package/dist/src/utils/catalog-operation-context.js.map +1 -1
- package/dist/src/utils/catalog-public-error.js +4 -0
- package/dist/src/utils/catalog-public-error.js.map +1 -1
- package/dist/src/utils/catalog-source-impact.d.ts +3 -2
- package/dist/src/utils/catalog-source-impact.js +142 -20
- package/dist/src/utils/catalog-source-impact.js.map +1 -1
- package/dist/src/utils/catalog-source-references.js +95 -9
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/catalog-sources.d.ts +1 -1
- package/dist/src/utils/catalog-sources.js +19 -3
- package/dist/src/utils/catalog-sources.js.map +1 -1
- package/dist/src/utils/codex-manager.js +8 -0
- package/dist/src/utils/codex-manager.js.map +1 -1
- package/dist/src/utils/codex-native-observation.d.ts +34 -1
- package/dist/src/utils/codex-native-observation.js +132 -0
- package/dist/src/utils/codex-native-observation.js.map +1 -1
- package/dist/src/utils/codex-reconciler.d.ts +0 -2
- package/dist/src/utils/codex-reconciler.js.map +1 -1
- package/dist/src/utils/codex-shared-native.d.ts +2 -26
- package/dist/src/utils/codex-shared-native.js +8 -82
- package/dist/src/utils/codex-shared-native.js.map +1 -1
- package/dist/src/utils/git-catalog-provider.d.ts +3 -0
- package/dist/src/utils/git-catalog-provider.js +40 -1
- package/dist/src/utils/git-catalog-provider.js.map +1 -1
- package/dist/src/utils/local-marketplace.d.ts +1 -0
- package/dist/src/utils/local-marketplace.js +69 -73
- package/dist/src/utils/local-marketplace.js.map +1 -1
- package/dist/src/utils/multi-source-catalog.js +1 -0
- package/dist/src/utils/multi-source-catalog.js.map +1 -1
- package/dist/src/utils/native-cli.d.ts +9 -4
- package/dist/src/utils/native-cli.js +280 -34
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/path-catalog-provider.js +2 -0
- package/dist/src/utils/path-catalog-provider.js.map +1 -1
- package/dist/src/utils/plugin-config-impact.d.ts +33 -0
- package/dist/src/utils/plugin-config-impact.js +298 -0
- package/dist/src/utils/plugin-config-impact.js.map +1 -0
- package/dist/src/utils/plugin-config-write.d.ts +36 -14
- package/dist/src/utils/plugin-config-write.js +709 -225
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +58 -4
- package/dist/src/utils/plugin-config.js +328 -60
- package/dist/src/utils/plugin-config.js.map +1 -1
- package/dist/src/utils/plugin-scripts.d.ts +20 -12
- package/dist/src/utils/plugin-scripts.js +389 -114
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/dist/src/utils/process-tree.d.ts +2 -2
- package/dist/src/utils/process-tree.js +1 -1
- package/dist/src/utils/process-tree.js.map +1 -1
- package/dist/src/utils/project-boundary.d.ts +11 -1
- package/dist/src/utils/project-boundary.js +33 -11
- package/dist/src/utils/project-boundary.js.map +1 -1
- package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
- package/dist/src/utils/safe-operation-diagnostic.js +33 -0
- package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
- package/dist/src/utils/sensitive-content.d.ts +4 -0
- package/dist/src/utils/sensitive-content.js +36 -0
- package/dist/src/utils/sensitive-content.js.map +1 -0
- package/dist/src/utils/windows-claude-shim.d.ts +9 -0
- package/dist/src/utils/windows-claude-shim.js +141 -0
- package/dist/src/utils/windows-claude-shim.js.map +1 -0
- package/dist/vitest.config.js +91 -10
- package/dist/vitest.config.js.map +1 -1
- package/package.json +9 -9
- package/dist/authoring/templates/aw-config-runtime.d.mts +0 -2
- package/dist/authoring/templates/aw-config-runtime.mjs +0 -407
- package/dist/authoring/templates/aw-config-runtime.mjs.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { GeneratedArtifact, CatalogResolution, PlatformName, PluginMeta, RebuildActionEvent, RebuildActionName, RebuildCommand, Scope } from '../types.js';
|
|
2
|
+
import { type SafeOperationErrorMetadata } from '../utils/safe-operation-diagnostic.js';
|
|
2
3
|
import type { OperationAction } from './operation-plan.js';
|
|
3
|
-
import { type NativeOwnershipProbe, type NativeOwnershipRemove, type OwnedComponent, type OwnedComponentExecutor } from '../utils/ownership.js';
|
|
4
|
+
import { type NativeOwnershipProbe, type NativeOwnershipRemove, type OwnedComponent, type OwnedComponentExecutor, type OwnershipInspection } from '../utils/ownership.js';
|
|
4
5
|
export type { RebuildActionName, RebuildCommand } from '../types.js';
|
|
5
6
|
export interface RebuildTargetIdentity {
|
|
6
7
|
sourceId?: string;
|
|
@@ -22,11 +23,13 @@ export interface DesiredTarget {
|
|
|
22
23
|
optionalOwnedComponents?: readonly OwnedComponent[];
|
|
23
24
|
requiresNative: boolean;
|
|
24
25
|
writeNativeRequired?: boolean;
|
|
26
|
+
nativeOverlayDesired?: boolean;
|
|
25
27
|
codexNativeObservationExpectation?: 'observed' | 'installed';
|
|
28
|
+
codexNativeSensitivePreflightRequired?: boolean;
|
|
26
29
|
artifacts: readonly GeneratedArtifact[];
|
|
27
30
|
operationActions?: readonly OperationAction[];
|
|
28
31
|
catalog?: CatalogResolution;
|
|
29
|
-
|
|
32
|
+
preApplySource: PluginMeta;
|
|
30
33
|
forceExclusiveCleanup?: boolean;
|
|
31
34
|
}
|
|
32
35
|
export interface RebuildAction {
|
|
@@ -37,6 +40,7 @@ export interface RebuildFailure {
|
|
|
37
40
|
phase: RebuildActionName | 'preflight';
|
|
38
41
|
message: string;
|
|
39
42
|
label?: string;
|
|
43
|
+
operationDiagnostic?: SafeOperationErrorMetadata;
|
|
40
44
|
}
|
|
41
45
|
interface RebuildResultBase {
|
|
42
46
|
command: RebuildCommand;
|
|
@@ -57,40 +61,74 @@ export interface RebuildFailedResult extends RebuildResultBase {
|
|
|
57
61
|
error: {
|
|
58
62
|
phase: RebuildFailure['phase'];
|
|
59
63
|
message: string;
|
|
64
|
+
operationDiagnostic?: SafeOperationErrorMetadata;
|
|
60
65
|
};
|
|
61
66
|
}
|
|
62
67
|
export type RebuildResult = RebuildSucceededResult | RebuildFailedResult;
|
|
63
|
-
export interface
|
|
68
|
+
export interface RebuildPreApplyInvocation {
|
|
64
69
|
target: DesiredTarget;
|
|
65
70
|
plugin: PluginMeta;
|
|
66
|
-
artifacts: readonly GeneratedArtifact[];
|
|
67
|
-
components: Array<{
|
|
68
|
-
kind: string;
|
|
69
|
-
key: string;
|
|
70
|
-
outcome: 'created' | 'updated' | 'removed' | 'unchanged';
|
|
71
|
-
}>;
|
|
72
71
|
}
|
|
73
72
|
export interface RebuildTargetDriver {
|
|
74
73
|
ownership: OwnedComponentExecutor;
|
|
75
74
|
preflightMutation?(target: DesiredTarget): Promise<void>;
|
|
76
75
|
preflightMaterialize?(target: DesiredTarget): Promise<void>;
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
selectRecoveryCleanupComponents?(target: DesiredTarget, components: readonly OwnedComponent[]): readonly OwnedComponent[];
|
|
77
|
+
deferPostcheck?(target: DesiredTarget, postcheck: () => Promise<void>): boolean;
|
|
78
|
+
completePostchecks?(): Promise<readonly DeferredRebuildPostcheckFailure[]>;
|
|
79
79
|
finalizeCleanup?(target: DesiredTarget): Promise<void>;
|
|
80
80
|
writeNative(target: DesiredTarget): Promise<void>;
|
|
81
81
|
writeArtifacts(target: DesiredTarget): Promise<void | readonly GeneratedArtifact[]>;
|
|
82
82
|
probeNative?: NativeOwnershipProbe;
|
|
83
83
|
probeNativeHealth?: NativeOwnershipProbe;
|
|
84
84
|
removeNative?: NativeOwnershipRemove;
|
|
85
|
-
|
|
85
|
+
runPreApply(invocation: RebuildPreApplyInvocation): Promise<void>;
|
|
86
|
+
}
|
|
87
|
+
export interface DeferredRebuildPostcheckFailure {
|
|
88
|
+
target: DesiredTarget;
|
|
89
|
+
error: unknown;
|
|
86
90
|
}
|
|
91
|
+
export interface PreparedRebuildOperation {
|
|
92
|
+
command: RebuildCommand;
|
|
93
|
+
target: DesiredTarget;
|
|
94
|
+
inspection: OwnershipInspection;
|
|
95
|
+
actions: RebuildAction[];
|
|
96
|
+
}
|
|
97
|
+
export type PrepareRebuildOperationResult = {
|
|
98
|
+
status: 'ready';
|
|
99
|
+
preparation: PreparedRebuildOperation;
|
|
100
|
+
} | {
|
|
101
|
+
status: 'failed';
|
|
102
|
+
result: RebuildResult;
|
|
103
|
+
};
|
|
104
|
+
export declare function executeRebuildComponentCleanup(options: {
|
|
105
|
+
command: RebuildCommand;
|
|
106
|
+
target: DesiredTarget;
|
|
107
|
+
driver: RebuildTargetDriver;
|
|
108
|
+
components: readonly OwnedComponent[];
|
|
109
|
+
actions?: readonly RebuildAction[];
|
|
110
|
+
onActionEvent?: (event: RebuildActionEvent) => void | Promise<void>;
|
|
111
|
+
now?: () => number;
|
|
112
|
+
beforeMutation?: (component: OwnedComponent) => Promise<void>;
|
|
113
|
+
afterQuarantine?: (component: OwnedComponent, quarantinePath: string) => Promise<void>;
|
|
114
|
+
}): Promise<RebuildResult>;
|
|
87
115
|
export declare function executeRebuildOperation(options: {
|
|
88
116
|
command: RebuildCommand;
|
|
89
117
|
target: DesiredTarget;
|
|
90
118
|
driver: RebuildTargetDriver;
|
|
119
|
+
preparation?: PreparedRebuildOperation;
|
|
91
120
|
onActionEvent?: (event: RebuildActionEvent) => void | Promise<void>;
|
|
92
121
|
now?: () => number;
|
|
93
122
|
}): Promise<RebuildResult>;
|
|
123
|
+
export declare function prepareRebuildOperation(options: {
|
|
124
|
+
command: 'install' | 'sync' | 'reinstall';
|
|
125
|
+
target: DesiredTarget;
|
|
126
|
+
driver: RebuildTargetDriver;
|
|
127
|
+
deferNativeInspection?: boolean;
|
|
128
|
+
skipPreApply?: boolean;
|
|
129
|
+
onActionEvent?: (event: RebuildActionEvent) => void | Promise<void>;
|
|
130
|
+
now?: () => number;
|
|
131
|
+
}): Promise<PrepareRebuildOperationResult>;
|
|
94
132
|
export declare function executeRebuildTargets(options: {
|
|
95
133
|
command: RebuildCommand;
|
|
96
134
|
targets: readonly DesiredTarget[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
+
import { readSafeOperationError } from '../utils/safe-operation-diagnostic.js';
|
|
2
3
|
import { cleanupOwnedComponents, inspectOwnedComponents, validateOwnerIdentity, } from '../utils/ownership.js';
|
|
3
4
|
function artifactIdentity(artifact) {
|
|
4
5
|
return [
|
|
@@ -40,10 +41,8 @@ const REBUILD_ACTION_FAILURE_MESSAGES = {
|
|
|
40
41
|
'stale.cleanup': '清理过期组件失败。',
|
|
41
42
|
'native.write': '写入平台插件失败。',
|
|
42
43
|
'artifacts.write': '写入插件文件失败。',
|
|
43
|
-
|
|
44
|
+
preApply: '运行 preApply 失败。',
|
|
44
45
|
'postcheck.inspect': '检查写入结果失败。',
|
|
45
|
-
'marketplace.commit': '提交 marketplace generation 失败。',
|
|
46
|
-
'marketplace.rollback': '回滚 marketplace generation 失败。',
|
|
47
46
|
'recovery.cleanup': '清理失败写入失败。',
|
|
48
47
|
'cleanup.owned': '清理 AW 组件失败。',
|
|
49
48
|
};
|
|
@@ -78,16 +77,16 @@ function mergeCleanup(accumulator, cleanup, phase) {
|
|
|
78
77
|
function succeeded(command, target, accumulator) {
|
|
79
78
|
return { status: 'succeeded', command, target: target.identity, ...accumulator };
|
|
80
79
|
}
|
|
81
|
-
function failed(command, target, accumulator, phase, message) {
|
|
80
|
+
function failed(command, target, accumulator, phase, message, operationDiagnostic) {
|
|
82
81
|
if (!accumulator.failures.some((failure) => failure.phase === phase && failure.message === message)) {
|
|
83
|
-
accumulator.failures.unshift({ phase, message });
|
|
82
|
+
accumulator.failures.unshift({ phase, message, ...(operationDiagnostic ? { operationDiagnostic } : {}) });
|
|
84
83
|
}
|
|
85
84
|
return {
|
|
86
85
|
status: 'failed',
|
|
87
86
|
command,
|
|
88
87
|
target: target.identity,
|
|
89
88
|
...accumulator,
|
|
90
|
-
error: { phase, message },
|
|
89
|
+
error: { phase, message, ...(operationDiagnostic ? { operationDiagnostic } : {}) },
|
|
91
90
|
};
|
|
92
91
|
}
|
|
93
92
|
async function action(accumulator, name, operation, events, failureMessage) {
|
|
@@ -158,10 +157,10 @@ function validateDesiredTarget(target) {
|
|
|
158
157
|
throw new Error('Desired target has an invalid namespaced source identity.');
|
|
159
158
|
}
|
|
160
159
|
if (target.plugin.manifest.name !== pluginName
|
|
161
|
-
|| target.
|
|
160
|
+
|| target.preApplySource.manifest.name !== pluginName
|
|
162
161
|
|| target.plugin.manifest.version !== pluginVersion
|
|
163
|
-
|| target.
|
|
164
|
-
throw new Error('Desired target plugin name/version does not match its
|
|
162
|
+
|| target.preApplySource.manifest.version !== pluginVersion) {
|
|
163
|
+
throw new Error('Desired target plugin name/version does not match its preApply source and identity.');
|
|
165
164
|
}
|
|
166
165
|
if (platform !== 'codex' && platform !== 'claude') {
|
|
167
166
|
throw new Error(`Desired target platform is invalid: ${String(platform)}`);
|
|
@@ -295,19 +294,20 @@ function postcheckMessage(accumulator, inspection) {
|
|
|
295
294
|
return diagnostics.join('; ');
|
|
296
295
|
return `Post-install ownership inspection failed for ${invalid.length} component(s).`;
|
|
297
296
|
}
|
|
298
|
-
async function cleanupOwned(target, driver, components = target.ownedComponents) {
|
|
297
|
+
async function cleanupOwned(target, driver, components = target.ownedComponents, hooks = {}) {
|
|
299
298
|
return cleanupOwnedComponents({
|
|
300
299
|
components,
|
|
301
300
|
executor: driver.ownership,
|
|
302
301
|
nativeProbe: driver.probeNative,
|
|
303
302
|
nativeRemove: driver.removeNative,
|
|
304
303
|
forceExclusive: target.forceExclusiveCleanup,
|
|
304
|
+
...hooks,
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
|
-
async function cleanupTarget(target, driver, accumulator, ownedAction, events, components = target.ownedComponents) {
|
|
307
|
+
async function cleanupTarget(target, driver, accumulator, ownedAction, events, components = target.ownedComponents, hooks = {}) {
|
|
308
308
|
accumulator.cleanupAttempted = true;
|
|
309
309
|
try {
|
|
310
|
-
const cleanup = await action(accumulator, ownedAction, () => cleanupOwned(target, driver, components), events, (value) => value.failures[0]?.message
|
|
310
|
+
const cleanup = await action(accumulator, ownedAction, () => cleanupOwned(target, driver, components, hooks), events, (value) => value.failures[0]?.message
|
|
311
311
|
?? (value.residual.length > 0
|
|
312
312
|
? `Ownership cleanup left residual components: ${value.residual.join(', ')}`
|
|
313
313
|
: value.quarantined.length > 0
|
|
@@ -333,32 +333,62 @@ async function cleanupTarget(target, driver, accumulator, ownedAction, events, c
|
|
|
333
333
|
}
|
|
334
334
|
return null;
|
|
335
335
|
}
|
|
336
|
+
export async function executeRebuildComponentCleanup(options) {
|
|
337
|
+
const accumulator = createAccumulator();
|
|
338
|
+
accumulator.actions.push(...(options.actions ?? []));
|
|
339
|
+
const cleanupError = await cleanupTarget(options.target, options.driver, accumulator, 'cleanup.owned', {
|
|
340
|
+
command: options.command,
|
|
341
|
+
target: options.target.identity,
|
|
342
|
+
emit: options.onActionEvent,
|
|
343
|
+
now: options.now ?? Date.now,
|
|
344
|
+
}, options.components, {
|
|
345
|
+
...(options.beforeMutation ? { beforeMutation: options.beforeMutation } : {}),
|
|
346
|
+
...(options.afterQuarantine ? { afterQuarantine: options.afterQuarantine } : {}),
|
|
347
|
+
});
|
|
348
|
+
return cleanupError
|
|
349
|
+
? failed(options.command, options.target, accumulator, cleanupError.phase, cleanupError.message)
|
|
350
|
+
: succeeded(options.command, options.target, accumulator);
|
|
351
|
+
}
|
|
336
352
|
async function materializeTarget(options) {
|
|
337
353
|
const { command, target, driver, accumulator, events } = options;
|
|
338
|
-
let inspection;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
await
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
354
|
+
let inspection = options.inspection;
|
|
355
|
+
if (!inspection) {
|
|
356
|
+
try {
|
|
357
|
+
inspection = await action(accumulator, 'preflight.inspect', async () => {
|
|
358
|
+
await driver.preflightMaterialize?.(target);
|
|
359
|
+
return inspectOwnedComponents({
|
|
360
|
+
components: target.ownedComponents,
|
|
361
|
+
executor: driver.ownership,
|
|
362
|
+
nativeProbe: driver.probeNative,
|
|
363
|
+
});
|
|
364
|
+
}, events, collisionMessage);
|
|
365
|
+
}
|
|
366
|
+
catch (error) {
|
|
367
|
+
return failed(command, target, accumulator, 'preflight.inspect', errorMessage(error), readSafeOperationError(error));
|
|
368
|
+
}
|
|
351
369
|
}
|
|
352
370
|
const collision = collisionMessage(inspection);
|
|
353
371
|
if (collision) {
|
|
354
372
|
recordInspectionResiduals(accumulator, inspection);
|
|
355
373
|
return failed(command, target, accumulator, 'preflight.inspect', collision);
|
|
356
374
|
}
|
|
375
|
+
if (!options.preApplyCompleted && target.preApplySource.manifest.scripts?.preApply) {
|
|
376
|
+
try {
|
|
377
|
+
await action(accumulator, 'preApply', () => driver.runPreApply({
|
|
378
|
+
target,
|
|
379
|
+
plugin: target.preApplySource,
|
|
380
|
+
}), events);
|
|
381
|
+
}
|
|
382
|
+
catch (error) {
|
|
383
|
+
return failed(command, target, accumulator, 'preApply', errorMessage(error), readSafeOperationError(error));
|
|
384
|
+
}
|
|
385
|
+
}
|
|
357
386
|
const desiredComponents = new Set(target.desiredOwnedComponents ?? target.ownedComponents);
|
|
358
387
|
const optionalComponents = new Set(target.optionalOwnedComponents ?? []);
|
|
359
388
|
const staleComponents = target.ownedComponents.filter((component) => !desiredComponents.has(component) && !optionalComponents.has(component));
|
|
360
389
|
const staleInspection = inspection.components.filter((entry) => staleComponents.includes(entry.component));
|
|
361
|
-
if (
|
|
390
|
+
if (!options.skipStaleCleanup
|
|
391
|
+
&& staleInspection.some((component) => component.state === 'present')) {
|
|
362
392
|
accumulator.cleanupAttempted = true;
|
|
363
393
|
let stale;
|
|
364
394
|
try {
|
|
@@ -368,7 +398,7 @@ async function materializeTarget(options) {
|
|
|
368
398
|
: undefined));
|
|
369
399
|
}
|
|
370
400
|
catch (error) {
|
|
371
|
-
return failed(command, target, accumulator, 'stale.cleanup', errorMessage(error));
|
|
401
|
+
return failed(command, target, accumulator, 'stale.cleanup', errorMessage(error), readSafeOperationError(error));
|
|
372
402
|
}
|
|
373
403
|
mergeCleanup(accumulator, stale, 'stale.cleanup');
|
|
374
404
|
if (stale.failures.length > 0 || stale.residual.length > 0) {
|
|
@@ -388,8 +418,7 @@ async function materializeTarget(options) {
|
|
|
388
418
|
const writtenArtifacts = await driver.writeArtifacts(target);
|
|
389
419
|
bindWrittenArtifacts(target, writtenArtifacts);
|
|
390
420
|
}, events);
|
|
391
|
-
|
|
392
|
-
await action(accumulator, failurePhase, async () => {
|
|
421
|
+
const postcheck = () => action(accumulator, 'postcheck.inspect', async () => {
|
|
393
422
|
const optional = new Set(target.optionalOwnedComponents ?? []);
|
|
394
423
|
const postcheck = await inspectOwnedComponents({
|
|
395
424
|
components: (target.desiredOwnedComponents ?? target.ownedComponents)
|
|
@@ -402,70 +431,26 @@ async function materializeTarget(options) {
|
|
|
402
431
|
if (postcheckFailure)
|
|
403
432
|
throw new Error(postcheckFailure);
|
|
404
433
|
}, events);
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
await
|
|
408
|
-
}
|
|
409
|
-
try {
|
|
410
|
-
const postApplyComponents = inspection.components.map((entry) => ({
|
|
411
|
-
kind: entry.component.kind,
|
|
412
|
-
key: entry.component.identity.artifactKey,
|
|
413
|
-
outcome: (optionalComponents.has(entry.component)
|
|
414
|
-
? 'unchanged'
|
|
415
|
-
: !desiredComponents.has(entry.component)
|
|
416
|
-
? (entry.state === 'present' ? 'removed' : 'unchanged')
|
|
417
|
-
: entry.state === 'absent'
|
|
418
|
-
? 'created'
|
|
419
|
-
: entry.state === 'present'
|
|
420
|
-
? 'unchanged'
|
|
421
|
-
: 'updated'),
|
|
422
|
-
}));
|
|
423
|
-
await action(accumulator, 'postApply', () => driver.runPostApply({
|
|
424
|
-
target,
|
|
425
|
-
plugin: target.postApplySource,
|
|
426
|
-
artifacts: target.artifacts,
|
|
427
|
-
components: postApplyComponents,
|
|
428
|
-
}), events);
|
|
429
|
-
}
|
|
430
|
-
catch (error) {
|
|
431
|
-
void error;
|
|
434
|
+
failurePhase = 'postcheck.inspect';
|
|
435
|
+
if (driver.deferPostcheck?.(target, postcheck) !== true) {
|
|
436
|
+
await postcheck();
|
|
432
437
|
}
|
|
433
438
|
return succeeded(command, target, accumulator);
|
|
434
439
|
}
|
|
435
440
|
catch (error) {
|
|
436
441
|
const primary = errorMessage(error);
|
|
437
|
-
if (error.
|
|
438
|
-
return failed(command, target, accumulator, failurePhase, primary);
|
|
442
|
+
if (error.nativeMarketplaceGroupFailure === true) {
|
|
443
|
+
return failed(command, target, accumulator, failurePhase, primary, readSafeOperationError(error));
|
|
439
444
|
}
|
|
440
445
|
if (target.identity.platform === 'codex') {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
await action(accumulator, 'marketplace.rollback', () => driver.rollbackMaterialize(target), events);
|
|
445
|
-
}
|
|
446
|
-
catch (rollbackError) {
|
|
447
|
-
accumulator.failures.push({
|
|
448
|
-
phase: 'marketplace.rollback',
|
|
449
|
-
message: errorMessage(rollbackError),
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
}
|
|
446
|
+
const recoveryComponents = target.ownedComponents.filter((component) => component.kind === 'skill-directory' || component.kind === 'owned-text-file');
|
|
447
|
+
await cleanupTarget(target, driver, accumulator, 'recovery.cleanup', events, driver.selectRecoveryCleanupComponents?.(target, recoveryComponents)
|
|
448
|
+
?? recoveryComponents);
|
|
453
449
|
}
|
|
454
450
|
else {
|
|
455
451
|
await cleanupTarget(target, driver, accumulator, 'recovery.cleanup', events);
|
|
456
|
-
if (driver.rollbackMaterialize) {
|
|
457
|
-
try {
|
|
458
|
-
await action(accumulator, 'marketplace.rollback', () => driver.rollbackMaterialize(target), events);
|
|
459
|
-
}
|
|
460
|
-
catch (rollbackError) {
|
|
461
|
-
accumulator.failures.push({
|
|
462
|
-
phase: 'marketplace.rollback',
|
|
463
|
-
message: errorMessage(rollbackError),
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
452
|
}
|
|
468
|
-
return failed(command, target, accumulator, failurePhase, primary);
|
|
453
|
+
return failed(command, target, accumulator, failurePhase, primary, readSafeOperationError(error));
|
|
469
454
|
}
|
|
470
455
|
}
|
|
471
456
|
async function executeCleanup(options) {
|
|
@@ -527,6 +512,25 @@ export async function executeRebuildOperation(options) {
|
|
|
527
512
|
emit: options.onActionEvent,
|
|
528
513
|
now: options.now ?? Date.now,
|
|
529
514
|
};
|
|
515
|
+
if (options.preparation) {
|
|
516
|
+
if (options.preparation.command !== options.command
|
|
517
|
+
|| options.preparation.target !== options.target) {
|
|
518
|
+
return failed(options.command, options.target, accumulator, 'preflight', 'Prepared rebuild operation does not match the requested target.');
|
|
519
|
+
}
|
|
520
|
+
accumulator.actions.push(...options.preparation.actions);
|
|
521
|
+
try {
|
|
522
|
+
await options.driver.preflightMutation?.(options.target);
|
|
523
|
+
}
|
|
524
|
+
catch (error) {
|
|
525
|
+
return failed(options.command, options.target, accumulator, 'preflight', errorMessage(error));
|
|
526
|
+
}
|
|
527
|
+
try {
|
|
528
|
+
return await executeRebuildOperationCore(options, accumulator, events, options.preparation);
|
|
529
|
+
}
|
|
530
|
+
catch (error) {
|
|
531
|
+
return failed(options.command, options.target, accumulator, 'preflight', errorMessage(error));
|
|
532
|
+
}
|
|
533
|
+
}
|
|
530
534
|
try {
|
|
531
535
|
validateDesiredTarget(options.target);
|
|
532
536
|
}
|
|
@@ -546,7 +550,7 @@ export async function executeRebuildOperation(options) {
|
|
|
546
550
|
return failed(options.command, options.target, accumulator, 'preflight', errorMessage(error));
|
|
547
551
|
}
|
|
548
552
|
}
|
|
549
|
-
async function executeRebuildOperationCore(options, accumulator, events) {
|
|
553
|
+
async function executeRebuildOperationCore(options, accumulator, events, preparation) {
|
|
550
554
|
if (options.command === 'install') {
|
|
551
555
|
return materializeTarget({
|
|
552
556
|
command: options.command,
|
|
@@ -554,6 +558,10 @@ async function executeRebuildOperationCore(options, accumulator, events) {
|
|
|
554
558
|
driver: options.driver,
|
|
555
559
|
accumulator,
|
|
556
560
|
events,
|
|
561
|
+
...(preparation ? {
|
|
562
|
+
inspection: preparation.inspection,
|
|
563
|
+
preApplyCompleted: true,
|
|
564
|
+
} : {}),
|
|
557
565
|
});
|
|
558
566
|
}
|
|
559
567
|
if (options.command === 'cleanup') {
|
|
@@ -573,24 +581,37 @@ async function executeRebuildOperationCore(options, accumulator, events) {
|
|
|
573
581
|
events,
|
|
574
582
|
});
|
|
575
583
|
}
|
|
576
|
-
let inspection;
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
await
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
584
|
+
let inspection = preparation?.inspection;
|
|
585
|
+
if (!inspection) {
|
|
586
|
+
try {
|
|
587
|
+
inspection = await action(accumulator, 'preflight.inspect', async () => {
|
|
588
|
+
await options.driver.preflightMaterialize?.(options.target);
|
|
589
|
+
return inspectOwnedComponents({
|
|
590
|
+
components: options.target.ownedComponents,
|
|
591
|
+
executor: options.driver.ownership,
|
|
592
|
+
nativeProbe: options.driver.probeNative,
|
|
593
|
+
});
|
|
594
|
+
}, events, collisionMessage);
|
|
595
|
+
}
|
|
596
|
+
catch (error) {
|
|
597
|
+
return failed('reinstall', options.target, accumulator, 'preflight.inspect', errorMessage(error));
|
|
598
|
+
}
|
|
599
|
+
const collision = collisionMessage(inspection);
|
|
600
|
+
if (collision) {
|
|
601
|
+
recordInspectionResiduals(accumulator, inspection);
|
|
602
|
+
return failed('reinstall', options.target, accumulator, 'preflight.inspect', collision);
|
|
603
|
+
}
|
|
604
|
+
if (options.target.preApplySource.manifest.scripts?.preApply) {
|
|
605
|
+
try {
|
|
606
|
+
await action(accumulator, 'preApply', () => options.driver.runPreApply({
|
|
607
|
+
target: options.target,
|
|
608
|
+
plugin: options.target.preApplySource,
|
|
609
|
+
}), events);
|
|
610
|
+
}
|
|
611
|
+
catch (error) {
|
|
612
|
+
return failed('reinstall', options.target, accumulator, 'preApply', errorMessage(error), readSafeOperationError(error));
|
|
613
|
+
}
|
|
614
|
+
}
|
|
594
615
|
}
|
|
595
616
|
const cleanupResult = await executeCleanup({
|
|
596
617
|
command: 'reinstall',
|
|
@@ -607,8 +628,79 @@ async function executeRebuildOperationCore(options, accumulator, events) {
|
|
|
607
628
|
driver: options.driver,
|
|
608
629
|
accumulator,
|
|
609
630
|
events,
|
|
631
|
+
inspection,
|
|
632
|
+
preApplyCompleted: true,
|
|
633
|
+
skipStaleCleanup: true,
|
|
610
634
|
});
|
|
611
635
|
}
|
|
636
|
+
export async function prepareRebuildOperation(options) {
|
|
637
|
+
const accumulator = createAccumulator();
|
|
638
|
+
const events = {
|
|
639
|
+
command: options.command,
|
|
640
|
+
target: options.target.identity,
|
|
641
|
+
emit: options.onActionEvent,
|
|
642
|
+
now: options.now ?? Date.now,
|
|
643
|
+
};
|
|
644
|
+
try {
|
|
645
|
+
validateDesiredTarget(options.target);
|
|
646
|
+
}
|
|
647
|
+
catch (error) {
|
|
648
|
+
return {
|
|
649
|
+
status: 'failed',
|
|
650
|
+
result: failed(options.command, options.target, accumulator, 'preflight', errorMessage(error)),
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
let inspection;
|
|
654
|
+
try {
|
|
655
|
+
inspection = await action(accumulator, 'preflight.inspect', async () => {
|
|
656
|
+
await options.driver.preflightMaterialize?.(options.target);
|
|
657
|
+
return inspectOwnedComponents({
|
|
658
|
+
components: options.deferNativeInspection
|
|
659
|
+
? options.target.ownedComponents.filter((component) => component.kind !== 'native-plugin')
|
|
660
|
+
: options.target.ownedComponents,
|
|
661
|
+
executor: options.driver.ownership,
|
|
662
|
+
nativeProbe: options.driver.probeNative,
|
|
663
|
+
});
|
|
664
|
+
}, events, collisionMessage);
|
|
665
|
+
}
|
|
666
|
+
catch (error) {
|
|
667
|
+
return {
|
|
668
|
+
status: 'failed',
|
|
669
|
+
result: failed(options.command, options.target, accumulator, 'preflight.inspect', errorMessage(error)),
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
const collision = collisionMessage(inspection);
|
|
673
|
+
if (collision) {
|
|
674
|
+
recordInspectionResiduals(accumulator, inspection);
|
|
675
|
+
return {
|
|
676
|
+
status: 'failed',
|
|
677
|
+
result: failed(options.command, options.target, accumulator, 'preflight.inspect', collision),
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
if (!options.skipPreApply && options.target.preApplySource.manifest.scripts?.preApply) {
|
|
681
|
+
try {
|
|
682
|
+
await action(accumulator, 'preApply', () => options.driver.runPreApply({
|
|
683
|
+
target: options.target,
|
|
684
|
+
plugin: options.target.preApplySource,
|
|
685
|
+
}), events);
|
|
686
|
+
}
|
|
687
|
+
catch (error) {
|
|
688
|
+
return {
|
|
689
|
+
status: 'failed',
|
|
690
|
+
result: failed(options.command, options.target, accumulator, 'preApply', errorMessage(error), readSafeOperationError(error)),
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return {
|
|
695
|
+
status: 'ready',
|
|
696
|
+
preparation: {
|
|
697
|
+
command: options.command,
|
|
698
|
+
target: options.target,
|
|
699
|
+
inspection,
|
|
700
|
+
actions: accumulator.actions,
|
|
701
|
+
},
|
|
702
|
+
};
|
|
703
|
+
}
|
|
612
704
|
export async function executeRebuildTargets(options) {
|
|
613
705
|
const results = [];
|
|
614
706
|
for (const target of options.targets) {
|
|
@@ -620,6 +712,20 @@ export async function executeRebuildTargets(options) {
|
|
|
620
712
|
...(options.now ? { now: options.now } : {}),
|
|
621
713
|
}));
|
|
622
714
|
}
|
|
715
|
+
const postcheckFailures = await options.driver.completePostchecks?.() ?? [];
|
|
716
|
+
for (const failure of postcheckFailures) {
|
|
717
|
+
const index = results.findIndex((result) => result.target === failure.target.identity);
|
|
718
|
+
if (index === -1 || results[index].status === 'failed')
|
|
719
|
+
continue;
|
|
720
|
+
const result = results[index];
|
|
721
|
+
const message = errorMessage(failure.error);
|
|
722
|
+
result.failures.unshift({ phase: 'postcheck.inspect', message });
|
|
723
|
+
results[index] = {
|
|
724
|
+
...result,
|
|
725
|
+
status: 'failed',
|
|
726
|
+
error: { phase: 'postcheck.inspect', message },
|
|
727
|
+
};
|
|
728
|
+
}
|
|
623
729
|
return results;
|
|
624
730
|
}
|
|
625
731
|
//# sourceMappingURL=rebuild-operations.js.map
|