@lesliechan721/aw 0.1.0-beta.23 → 0.1.0-beta.24

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.
Files changed (45) hide show
  1. package/dist/scripts/aw-skill-eval-materializer.js +12 -63
  2. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
  3. package/dist/src/commands/aw-capabilities.d.ts +1 -1
  4. package/dist/src/commands/aw-capabilities.js +2 -1
  5. package/dist/src/commands/aw-capabilities.js.map +1 -1
  6. package/dist/src/commands/rebuild-integration.d.ts +25 -0
  7. package/dist/src/commands/rebuild-integration.js +154 -6
  8. package/dist/src/commands/rebuild-integration.js.map +1 -1
  9. package/dist/src/commands/review-inspection.d.ts +71 -12
  10. package/dist/src/commands/review-inspection.js +485 -61
  11. package/dist/src/commands/review-inspection.js.map +1 -1
  12. package/dist/src/commands/review-preparation.d.ts +49 -0
  13. package/dist/src/commands/review-preparation.js +427 -0
  14. package/dist/src/commands/review-preparation.js.map +1 -0
  15. package/dist/src/generators/local-plugin.d.ts +2 -1
  16. package/dist/src/generators/local-plugin.js +40 -34
  17. package/dist/src/generators/local-plugin.js.map +1 -1
  18. package/dist/src/index.js +146 -20
  19. package/dist/src/index.js.map +1 -1
  20. package/dist/src/portable/materializer.d.ts +1 -0
  21. package/dist/src/portable/materializer.js +51 -11
  22. package/dist/src/portable/materializer.js.map +1 -1
  23. package/dist/src/review/review-profile.d.ts +17 -0
  24. package/dist/src/review/review-profile.js +177 -0
  25. package/dist/src/review/review-profile.js.map +1 -0
  26. package/dist/src/review/review-selection.d.ts +30 -0
  27. package/dist/src/review/review-selection.js +527 -0
  28. package/dist/src/review/review-selection.js.map +1 -0
  29. package/dist/src/review/review-types.d.ts +68 -0
  30. package/dist/src/review/review-types.js +16 -0
  31. package/dist/src/review/review-types.js.map +1 -0
  32. package/dist/src/review/skill-materialization.d.ts +13 -0
  33. package/dist/src/review/skill-materialization.js +72 -0
  34. package/dist/src/review/skill-materialization.js.map +1 -0
  35. package/dist/src/review/source-binding.d.ts +21 -9
  36. package/dist/src/review/source-binding.js +58 -18
  37. package/dist/src/review/source-binding.js.map +1 -1
  38. package/dist/src/tui/console-app-v4.js +2 -1
  39. package/dist/src/tui/console-app-v4.js.map +1 -1
  40. package/dist/src/tui/controller-runtime.js +5 -2
  41. package/dist/src/tui/controller-runtime.js.map +1 -1
  42. package/dist/src/tui/model.d.ts +1 -0
  43. package/dist/src/tui/model.js +32 -3
  44. package/dist/src/tui/model.js.map +1 -1
  45. package/package.json +3 -3
@@ -0,0 +1,427 @@
1
+ import path from 'node:path';
2
+ import { calculateCatalogWorkspaceSourceIdentity } from '@lesliechan721/aw-plugin-core';
3
+ import fs from 'fs-extra';
4
+ import { materializeReviewNativeSkills } from './rebuild-integration.js';
5
+ import { resolveReviewSelection } from '../review/review-selection.js';
6
+ import { ReviewSelectionError, } from '../review/review-types.js';
7
+ import { createIsolatedSkillEnv, prepareSkillPluginBundle, } from '../review/skill-materialization.js';
8
+ import { AW_SOURCE_BINDING_FILENAME, writeAwSourceBinding, } from '../review/source-binding.js';
9
+ import { materializePortableSkills } from '../portable/materializer.js';
10
+ import { writePluginConfigStore } from '../utils/plugin-config.js';
11
+ import { canonicalizePathThroughExistingAncestor, getCodexHome, resolveAwHome, resolveClaudePaths, resolveCodexPaths, resolveRepoRoot, } from '../utils/paths.js';
12
+ class ReviewPreparationError extends Error {
13
+ code;
14
+ exitCode;
15
+ issuePath;
16
+ constructor(code, message, exitCode, issuePath = null) {
17
+ super(message);
18
+ this.name = 'ReviewPreparationError';
19
+ this.code = code;
20
+ this.exitCode = exitCode;
21
+ this.issuePath = issuePath;
22
+ }
23
+ }
24
+ function isPathInsideOrEqual(root, candidate) {
25
+ const relative = path.relative(root, candidate);
26
+ return relative === '' || (!relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative));
27
+ }
28
+ function pathsOverlap(left, right) {
29
+ return isPathInsideOrEqual(left, right) || isPathInsideOrEqual(right, left);
30
+ }
31
+ async function resolvePhysicalPath(target) {
32
+ let current = path.resolve(target);
33
+ const suffix = [];
34
+ while (true) {
35
+ const info = await fs.lstat(current).catch((error) => {
36
+ if (error.code === 'ENOENT')
37
+ return null;
38
+ throw error;
39
+ });
40
+ if (info) {
41
+ if (info.isSymbolicLink()) {
42
+ throw new ReviewPreparationError('unsafeOutput', `Output path contains a symbolic link: ${current}.`, 2, current);
43
+ }
44
+ if (!info.isDirectory()) {
45
+ throw new ReviewPreparationError('unsafeOutput', `Output parent is not a regular directory: ${current}.`, 2, current);
46
+ }
47
+ return path.join(await fs.realpath(current), ...suffix);
48
+ }
49
+ const parent = path.dirname(current);
50
+ if (parent === current) {
51
+ throw new ReviewPreparationError('unsafeOutput', 'Output path has no existing directory ancestor.', 2, path.resolve(target));
52
+ }
53
+ suffix.unshift(path.basename(current));
54
+ current = parent;
55
+ }
56
+ }
57
+ async function installationRoots(options) {
58
+ const repoRoot = await resolveRepoRoot(options.cwd);
59
+ const roots = [
60
+ resolveAwHome(options.env),
61
+ getCodexHome(options.env),
62
+ path.join(repoRoot, '.agents'),
63
+ resolveCodexPaths(options.cwd, 'project', options.env).configDir,
64
+ resolveCodexPaths(options.cwd, 'user', options.env).configDir,
65
+ resolveClaudePaths(options.cwd, 'project', options.env).configDir,
66
+ resolveClaudePaths(options.cwd, 'user', options.env).configDir,
67
+ ];
68
+ return [...new Set(await Promise.all(roots.map(canonicalizePathThroughExistingAncestor)))];
69
+ }
70
+ async function assertSafeOutput(options) {
71
+ const target = await resolvePhysicalPath(options.target);
72
+ const existing = await fs.lstat(target).catch((error) => {
73
+ if (error.code === 'ENOENT')
74
+ return null;
75
+ throw error;
76
+ });
77
+ if (existing) {
78
+ throw new ReviewPreparationError('unsafeOutput', `Review output already exists: ${target}.`, 2, target);
79
+ }
80
+ const sourceRoots = await Promise.all(options.selection.workspace.plugins.map((plugin) => fs.realpath(plugin.rootDir)));
81
+ const blockedRoots = [
82
+ ...sourceRoots,
83
+ ...await installationRoots(options),
84
+ ];
85
+ if (target === path.parse(target).root
86
+ || blockedRoots.some((root) => pathsOverlap(root, target))) {
87
+ throw new ReviewPreparationError('unsafeOutput', 'Review output is too broad or overlaps source or installation content.', 2, target);
88
+ }
89
+ await fs.ensureDir(path.dirname(target));
90
+ const rechecked = await resolvePhysicalPath(target);
91
+ if (rechecked !== target) {
92
+ throw new ReviewPreparationError('unsafeOutput', 'Review output path changed during validation.', 2, target);
93
+ }
94
+ return target;
95
+ }
96
+ function preparedPluginIdentity(options) {
97
+ const sourceId = options.plugin.sourceId ?? 'review-source';
98
+ return {
99
+ ...options.plugin,
100
+ sourceId,
101
+ sourceIdentity: options.plugin.sourceIdentity ?? options.sourceIdentity,
102
+ catalogLogicalIdentity: options.plugin.catalogLogicalIdentity ?? options.workspaceIdentity,
103
+ pluginId: options.plugin.pluginId ?? `${sourceId}/${options.plugin.manifest.name}`,
104
+ };
105
+ }
106
+ function selectedProfile(selection) {
107
+ if (selection.profiles.length !== 1) {
108
+ throw new ReviewPreparationError('unsupportedProfile', 'Review preparation requires exactly one resolved platform and scope profile.', 2, selection.target.path);
109
+ }
110
+ return selection.profiles[0];
111
+ }
112
+ function targetReceipt(selection) {
113
+ return selection.target.kind === 'catalog'
114
+ ? null
115
+ : { kind: selection.target.kind, path: selection.target.path };
116
+ }
117
+ function failedReceipt(options) {
118
+ return {
119
+ schemaVersion: 1,
120
+ command: 'review:prepare',
121
+ ok: false,
122
+ target: options.target,
123
+ sourceBindingPath: null,
124
+ skills: [],
125
+ issues: options.issues,
126
+ };
127
+ }
128
+ function sameResolvedInput(before, beforeProfile, after) {
129
+ if (after.sourceIdentity !== before.sourceIdentity
130
+ || after.target.kind !== before.target.kind
131
+ || after.target.path !== before.target.path
132
+ || after.profiles.length !== 1)
133
+ return false;
134
+ const afterProfile = after.profiles[0];
135
+ const skillIdentity = (profile) => JSON.stringify(profile.skills.map((skill) => [
136
+ skill.pluginName,
137
+ skill.name,
138
+ skill.targetId,
139
+ skill.delivery,
140
+ skill.configScope,
141
+ ]).sort());
142
+ return JSON.stringify(afterProfile.profile) === JSON.stringify(beforeProfile.profile)
143
+ && skillIdentity(afterProfile) === skillIdentity(beforeProfile);
144
+ }
145
+ async function resolveSelection(options) {
146
+ return resolveReviewSelection({
147
+ cwd: options.cwd,
148
+ target: options.target,
149
+ ...(options.workspaceRoot ? { workspaceRoot: options.workspaceRoot } : {}),
150
+ ...(options.skills ? { skills: options.skills } : {}),
151
+ platform: options.platform,
152
+ scope: options.scope,
153
+ ...(options.configFile ? { configFile: options.configFile } : {}),
154
+ env: options.env,
155
+ });
156
+ }
157
+ async function writeIsolatedConfig(options) {
158
+ for (const config of options.profile.pluginConfigs) {
159
+ const plugin = options.plugins.get(config.pluginName);
160
+ if (!plugin) {
161
+ throw new Error(`Review config references unresolved plugin "${config.pluginName}".`);
162
+ }
163
+ await writePluginConfigStore({
164
+ sourceId: plugin.sourceId,
165
+ sourceIdentity: plugin.sourceIdentity,
166
+ logicalIdentity: plugin.catalogLogicalIdentity,
167
+ pluginName: config.pluginName,
168
+ scope: config.scope,
169
+ cwd: options.cwd,
170
+ values: config.overrides,
171
+ env: options.env,
172
+ });
173
+ }
174
+ }
175
+ async function prepareSelectedSkills(options) {
176
+ const pluginNames = new Set(options.profile.skills.map((skill) => skill.pluginName));
177
+ if (pluginNames.size !== 1) {
178
+ throw new Error('One review preparation output must contain Skills from exactly one plugin.');
179
+ }
180
+ const pluginName = [...pluginNames][0];
181
+ const sourcePlugin = options.selection.workspace.plugins.find((plugin) => plugin.manifest.name === pluginName);
182
+ if (!sourcePlugin)
183
+ throw new Error(`Selected plugin "${pluginName}" is unresolved.`);
184
+ let prepared;
185
+ let portable;
186
+ try {
187
+ prepared = await prepareSkillPluginBundle({
188
+ plugin: sourcePlugin,
189
+ plugins: options.selection.workspace.plugins,
190
+ workRoot: path.join(options.workRoot, 'bundle'),
191
+ env: options.env,
192
+ });
193
+ const bundlePlugin = preparedPluginIdentity({
194
+ plugin: prepared.bundlePlugin,
195
+ sourceIdentity: options.selection.sourceIdentity,
196
+ workspaceIdentity: options.selection.workspace.workspaceIdentity,
197
+ });
198
+ const plugins = new Map(options.selection.workspace.plugins.map((plugin) => [
199
+ plugin.manifest.name,
200
+ preparedPluginIdentity({
201
+ plugin,
202
+ sourceIdentity: options.selection.sourceIdentity,
203
+ workspaceIdentity: options.selection.workspace.workspaceIdentity,
204
+ }),
205
+ ]));
206
+ plugins.set(pluginName, bundlePlugin);
207
+ await writeIsolatedConfig({
208
+ profile: options.profile,
209
+ plugins,
210
+ cwd: options.cwd,
211
+ env: options.env,
212
+ });
213
+ if (options.profile.platform === 'agent-skills') {
214
+ const portableRoot = path.join(options.workRoot, 'portable');
215
+ portable = await materializePortableSkills({
216
+ plugins: [...plugins.values()],
217
+ pluginId: bundlePlugin.pluginId,
218
+ scope: options.profile.scope,
219
+ cwd: options.cwd,
220
+ env: options.env,
221
+ outputRoot: portableRoot,
222
+ inputMode: 'bundle',
223
+ selectedSkills: options.profile.skills.map((skill) => skill.name),
224
+ });
225
+ await fs.copy(path.join(portable.rootDir, 'skills'), path.join(options.outputRoot, 'skills'), {
226
+ overwrite: false,
227
+ errorOnExist: true,
228
+ dereference: false,
229
+ });
230
+ return;
231
+ }
232
+ await materializeReviewNativeSkills({
233
+ plugin: bundlePlugin,
234
+ platform: options.profile.platform,
235
+ scope: options.profile.scope,
236
+ cwd: options.cwd,
237
+ env: options.env,
238
+ outputRoot: options.outputRoot,
239
+ skills: options.profile.skills.map((skill) => ({
240
+ skill: skill.name,
241
+ targetId: skill.targetId,
242
+ })),
243
+ scriptTimeoutMs: options.scriptTimeoutMs,
244
+ });
245
+ }
246
+ finally {
247
+ await portable?.cleanup();
248
+ await prepared?.cleanup();
249
+ }
250
+ }
251
+ function normalizeError(error) {
252
+ if (error instanceof ReviewPreparationError)
253
+ return error;
254
+ if (error instanceof ReviewSelectionError) {
255
+ return new ReviewPreparationError(error.code, error.message, error.exitCode);
256
+ }
257
+ return new ReviewPreparationError('materializationFailed', error instanceof Error ? error.message : String(error), 1);
258
+ }
259
+ export async function prepareReviewTarget(options) {
260
+ let selection;
261
+ let profile;
262
+ let stagingRoot;
263
+ let finalOutput;
264
+ let committed = false;
265
+ try {
266
+ selection = await resolveSelection(options);
267
+ if (selection.target.kind === 'catalog') {
268
+ throw new ReviewPreparationError('invalidArguments', 'Review preparation accepts a plugin or source Skill target.', 2, selection.target.path);
269
+ }
270
+ profile = selectedProfile(selection);
271
+ if (profile.skills.length === 0) {
272
+ throw new ReviewPreparationError('unsupportedProfile', 'The selected profile does not contain a Skill to prepare.', 2, selection.target.path);
273
+ }
274
+ const baseEnv = options.env ?? process.env;
275
+ finalOutput = await assertSafeOutput({
276
+ target: path.resolve(options.cwd, options.out),
277
+ selection,
278
+ cwd: options.cwd,
279
+ env: baseEnv,
280
+ });
281
+ stagingRoot = await fs.mkdtemp(path.join(path.dirname(finalOutput), `.aw-review-${path.basename(finalOutput)}-`));
282
+ const stagedOutput = path.join(stagingRoot, 'output');
283
+ const workRoot = path.join(stagingRoot, 'work');
284
+ const materializationCwd = path.join(stagingRoot, 'project');
285
+ const env = await createIsolatedSkillEnv(baseEnv, path.join(stagingRoot, 'environment'));
286
+ await fs.ensureDir(path.join(materializationCwd, '.git'));
287
+ await fs.ensureDir(stagedOutput);
288
+ await prepareSelectedSkills({
289
+ selection,
290
+ profile,
291
+ outputRoot: stagedOutput,
292
+ workRoot,
293
+ env,
294
+ cwd: materializationCwd,
295
+ scriptTimeoutMs: options.scriptTimeoutMs,
296
+ });
297
+ const artifacts = profile.skills.map((skill) => ({
298
+ kind: 'review-skill',
299
+ plugin: skill.pluginName,
300
+ skill: skill.name,
301
+ path: `skills/${skill.name}`,
302
+ }));
303
+ const writtenBinding = await writeAwSourceBinding({
304
+ rootDir: stagedOutput,
305
+ source: {
306
+ kind: 'workspace',
307
+ workspaceIdentity: selection.workspace.workspaceIdentity,
308
+ sourceIdentity: selection.sourceIdentity,
309
+ },
310
+ subject: {
311
+ plugin: profile.skills[0].pluginName,
312
+ ...(selection.target.kind === 'skill'
313
+ ? { skill: selection.target.skill ?? profile.skills[0].name }
314
+ : {}),
315
+ },
316
+ profile: profile.profile,
317
+ artifacts,
318
+ });
319
+ const rechecked = await resolveSelection(options).catch(() => {
320
+ throw new ReviewPreparationError('sourceChanged', 'Review source or config changed while output was staged.', 3, selection.target.path);
321
+ });
322
+ if (!sameResolvedInput(selection, profile, rechecked)) {
323
+ throw new ReviewPreparationError('sourceChanged', 'Review source or config changed while output was staged.', 3, selection.target.path);
324
+ }
325
+ const recheckedOutput = await assertSafeOutput({
326
+ target: finalOutput,
327
+ selection: rechecked,
328
+ cwd: options.cwd,
329
+ env: baseEnv,
330
+ });
331
+ if (recheckedOutput !== finalOutput) {
332
+ throw new ReviewPreparationError('unsafeOutput', 'Review output path changed while output was staged.', 2, finalOutput);
333
+ }
334
+ await fs.remove(workRoot);
335
+ await fs.remove(path.join(stagingRoot, 'environment'));
336
+ await fs.remove(materializationCwd);
337
+ await fs.rename(stagedOutput, finalOutput);
338
+ committed = true;
339
+ const successIssues = [];
340
+ await fs.remove(stagingRoot).catch((cleanupError) => {
341
+ successIssues.push({
342
+ code: 'cleanupResidue',
343
+ path: stagingRoot,
344
+ message: cleanupError instanceof Error ? cleanupError.message : String(cleanupError),
345
+ });
346
+ });
347
+ stagingRoot = undefined;
348
+ const sourceBindingPath = path.join(finalOutput, AW_SOURCE_BINDING_FILENAME);
349
+ const digests = new Map(writtenBinding.binding.artifacts
350
+ .filter((artifact) => artifact.kind === 'review-skill')
351
+ .map((artifact) => [`${artifact.plugin}\0${artifact.skill}`, artifact.digest]));
352
+ return {
353
+ exitCode: 0,
354
+ receipt: {
355
+ schemaVersion: 1,
356
+ command: 'review:prepare',
357
+ ok: true,
358
+ target: targetReceipt(selection),
359
+ sourceBindingPath,
360
+ skills: profile.skills.map((skill) => ({
361
+ skill: skill.name,
362
+ sourcePath: skill.sourcePath,
363
+ profile: {
364
+ platform: profile.platform,
365
+ scope: profile.scope,
366
+ inputDigest: profile.profile.inputDigest,
367
+ },
368
+ finalPath: path.join(finalOutput, 'skills', skill.name),
369
+ digest: digests.get(`${skill.pluginName}\0${skill.name}`) ?? null,
370
+ state: 'ready',
371
+ evidencePath: sourceBindingPath,
372
+ })),
373
+ issues: successIssues,
374
+ },
375
+ };
376
+ }
377
+ catch (caught) {
378
+ let error = normalizeError(caught);
379
+ if (selection && profile && stagingRoot && error.code !== 'sourceChanged') {
380
+ try {
381
+ const current = await resolveSelection(options);
382
+ if (!sameResolvedInput(selection, profile, current)) {
383
+ error = new ReviewPreparationError('sourceChanged', 'Review source or config changed while output was staged.', 3, selection.target.path);
384
+ }
385
+ }
386
+ catch {
387
+ const currentIdentity = await calculateCatalogWorkspaceSourceIdentity(selection.workspace)
388
+ .catch(() => selection.sourceIdentity);
389
+ if (currentIdentity !== selection.sourceIdentity) {
390
+ error = new ReviewPreparationError('sourceChanged', 'Review source changed while output was staged.', 3, selection.target.path);
391
+ }
392
+ }
393
+ }
394
+ const issues = [{
395
+ code: error.code,
396
+ path: error.issuePath,
397
+ message: error.message,
398
+ }];
399
+ if (!committed && finalOutput && await fs.pathExists(finalOutput)) {
400
+ issues.push({
401
+ code: 'unsafeOutput',
402
+ path: finalOutput,
403
+ message: 'Review output appeared while preparation was running; it was not modified.',
404
+ });
405
+ }
406
+ if (stagingRoot) {
407
+ try {
408
+ await fs.remove(stagingRoot);
409
+ }
410
+ catch (cleanupError) {
411
+ issues.push({
412
+ code: 'cleanupResidue',
413
+ path: stagingRoot,
414
+ message: cleanupError instanceof Error ? cleanupError.message : String(cleanupError),
415
+ });
416
+ }
417
+ }
418
+ return {
419
+ exitCode: error.exitCode,
420
+ receipt: failedReceipt({
421
+ target: selection ? targetReceipt(selection) : null,
422
+ issues,
423
+ }),
424
+ };
425
+ }
426
+ }
427
+ //# sourceMappingURL=review-preparation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-preparation.js","sourceRoot":"","s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;gBACxC,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,IAAI,EAAE,KAAK,CAAC,SAAS;gBACrB,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB,CAAC,CAAA;QACF,IAAI,CAAC,SAAS,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YAClE,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,cAAc;gBACpB,IAAI,EAAE,WAAW;gBACjB,OAAO,EAAE,4EAA4E;aACtF,CAAC,CAAA;QACJ,CAAC;QACD,IAAI,WAAW,EAAE,CAAC;YAChB,IAAI,CAAC;gBACH,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;YAC9B,CAAC;YAAC,OAAO,YAAY,EAAE,CAAC;gBACtB,MAAM,CAAC,IAAI,CAAC;oBACV,IAAI,EAAE,gBAAgB;oBACtB,IAAI,EAAE,WAAW;oBACjB,OAAO,EAAE,YAAY,YAAY,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;iBACrF,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,OAAO,EAAE,aAAa,CAAC;gBACrB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI;gBACnD,MAAM;aACP,CAAC;SACH,CAAA;IACH,CAAC;AACH,CAAC"}
@@ -33,13 +33,14 @@ export interface PreparedPluginRuntimeContext {
33
33
  export interface BundleLocalPluginOptions {
34
34
  buildMode?: PluginBundleBuildMode;
35
35
  stagingRunner?: PluginStagingRunner;
36
+ commandEnv?: NodeJS.ProcessEnv;
36
37
  runtimeResolver?: CatalogRuntimeImportResolver;
37
38
  preparedRuntimeContext?: PreparedPluginRuntimeContext;
38
39
  runtimeSkillClosureValidation?: 'current' | 'historical';
39
40
  strictRequirements?: boolean;
40
41
  }
41
42
  export declare function validateStagingPackageManager(packageRoot: string): Promise<string>;
42
- export declare function prepareLocalPluginBundleSource(plugin: PluginMeta, options?: Pick<BundleLocalPluginOptions, 'buildMode' | 'stagingRunner' | 'runtimeResolver'>): Promise<{
43
+ export declare function prepareLocalPluginBundleSource(plugin: PluginMeta, options?: Pick<BundleLocalPluginOptions, 'buildMode' | 'stagingRunner' | 'commandEnv' | 'runtimeResolver'>): Promise<{
43
44
  plugin: PluginMeta;
44
45
  runtimeContext: PreparedPluginRuntimeContext;
45
46
  cleanup(): Promise<void>;
@@ -99,34 +99,36 @@ async function resolveRuntimePnpmEntry(supportedPackageManager) {
99
99
  const stats = await fs.stat(entryPath).catch(() => undefined);
100
100
  return stats?.isFile() ? entryPath : undefined;
101
101
  }
102
- const defaultStagingRunner = {
103
- async installPackageRoot(packageRoot) {
104
- const supportedPackageManager = await validateStagingPackageManager(packageRoot);
105
- const fixedPnpmEntry = await resolveFixedPnpmEntry(supportedPackageManager, process.env)
106
- ?? await resolveRuntimePnpmEntry(supportedPackageManager);
107
- if (!fixedPnpmEntry) {
108
- throw new Error(`Cannot stage scripts.node.packageRoot: missing bundled ${supportedPackageManager} runtime dependency.`);
109
- }
110
- const args = [
111
- fixedPnpmEntry,
112
- 'install',
113
- '--frozen-lockfile',
114
- '--ignore-scripts',
115
- ];
116
- await execFileAsync(process.execPath, args, {
117
- cwd: packageRoot,
118
- env: process.env,
119
- maxBuffer: 10 * 1024 * 1024,
120
- });
121
- },
122
- async runNodeBuild({ pluginRoot, scriptPath, args, env }) {
123
- await execFileAsync(process.execPath, [path.join(pluginRoot, stripDotSlash(scriptPath)), ...args], {
124
- cwd: pluginRoot,
125
- env,
126
- maxBuffer: 10 * 1024 * 1024,
127
- });
128
- },
129
- };
102
+ function createDefaultStagingRunner(commandEnv) {
103
+ return {
104
+ async installPackageRoot(packageRoot) {
105
+ const supportedPackageManager = await validateStagingPackageManager(packageRoot);
106
+ const fixedPnpmEntry = await resolveFixedPnpmEntry(supportedPackageManager, commandEnv)
107
+ ?? await resolveRuntimePnpmEntry(supportedPackageManager);
108
+ if (!fixedPnpmEntry) {
109
+ throw new Error(`Cannot stage scripts.node.packageRoot: missing bundled ${supportedPackageManager} runtime dependency.`);
110
+ }
111
+ const args = [
112
+ fixedPnpmEntry,
113
+ 'install',
114
+ '--frozen-lockfile',
115
+ '--ignore-scripts',
116
+ ];
117
+ await execFileAsync(process.execPath, args, {
118
+ cwd: packageRoot,
119
+ env: commandEnv,
120
+ maxBuffer: 10 * 1024 * 1024,
121
+ });
122
+ },
123
+ async runNodeBuild({ pluginRoot, scriptPath, args, env }) {
124
+ await execFileAsync(process.execPath, [path.join(pluginRoot, stripDotSlash(scriptPath)), ...args], {
125
+ cwd: pluginRoot,
126
+ env,
127
+ maxBuffer: 10 * 1024 * 1024,
128
+ });
129
+ },
130
+ };
131
+ }
130
132
  function stripDotSlash(value) {
131
133
  return value.startsWith('./') ? value.slice(2) : value;
132
134
  }
@@ -982,7 +984,7 @@ async function validateBuildImportProjectionSources(projections) {
982
984
  }
983
985
  }
984
986
  }
985
- async function createStagedPlugin(plugin, runner, resolver) {
987
+ async function createStagedPlugin(plugin, runner, resolver, commandEnv = process.env) {
986
988
  const stagingRoot = await fs.mkdtemp(assertLocalPluginStagingPathForTests(path.join(os.tmpdir(), 'aw-plugin-staging-'), 'local plugin bundle staging root'));
987
989
  const stagingPluginRoot = assertLocalPluginStagingPathForTests(path.join(stagingRoot, 'plugin'), 'local plugin staged plugin root');
988
990
  try {
@@ -997,14 +999,14 @@ async function createStagedPlugin(plugin, runner, resolver) {
997
999
  if (declaredBuildImports.length > 0 && !sourceBuild) {
998
1000
  throw new Error(`Invalid plugin "${plugin.manifest.name}": buildConfig.buildImports requires scripts.node.build.`);
999
1001
  }
1000
- const buildEnv = { ...process.env };
1002
+ const buildEnv = { ...commandEnv };
1001
1003
  const buildImportProvenance = [];
1002
1004
  const buildImportProjections = [];
1003
1005
  for (const buildImport of declaredBuildImports) {
1004
1006
  if (!resolver) {
1005
1007
  throw new Error(`Cannot resolve buildConfig.buildImports for plugin "${plugin.manifest.name}": catalog runtime import resolver is required.`);
1006
1008
  }
1007
- if (Object.hasOwn(process.env, buildImport.env)) {
1009
+ if (Object.hasOwn(commandEnv, buildImport.env)) {
1008
1010
  throw new Error(`Invalid buildConfig.buildImports env "${buildImport.env}": refusing to overwrite an existing environment variable.`);
1009
1011
  }
1010
1012
  const resolution = await resolver.resolve({
@@ -1096,13 +1098,15 @@ async function resolveBuildPlugin(plugin, options) {
1096
1098
  cleanup: async () => { },
1097
1099
  };
1098
1100
  }
1099
- return createStagedPlugin(plugin, options.stagingRunner, options.runtimeResolver);
1101
+ return createStagedPlugin(plugin, options.stagingRunner, options.runtimeResolver, options.commandEnv);
1100
1102
  }
1101
1103
  export async function prepareLocalPluginBundleSource(plugin, options = {}) {
1102
1104
  await assertPluginInputTree(plugin.rootDir);
1103
1105
  const buildOptions = {
1104
1106
  buildMode: options.buildMode ?? 'staging',
1105
- stagingRunner: options.stagingRunner ?? defaultStagingRunner,
1107
+ stagingRunner: options.stagingRunner
1108
+ ?? createDefaultStagingRunner(options.commandEnv ?? process.env),
1109
+ commandEnv: options.commandEnv,
1106
1110
  runtimeResolver: options.runtimeResolver,
1107
1111
  preparedRuntimeContext: undefined,
1108
1112
  };
@@ -1137,7 +1141,9 @@ export async function bundleLocalPlugin(plugin, outputRoot, options = {}) {
1137
1141
  const historicalComparison = options.runtimeSkillClosureValidation === 'historical';
1138
1142
  const buildOptions = {
1139
1143
  buildMode: options.buildMode ?? 'build-free',
1140
- stagingRunner: options.stagingRunner ?? defaultStagingRunner,
1144
+ stagingRunner: options.stagingRunner
1145
+ ?? createDefaultStagingRunner(options.commandEnv ?? process.env),
1146
+ commandEnv: options.commandEnv,
1141
1147
  runtimeResolver: options.runtimeResolver,
1142
1148
  preparedRuntimeContext: options.preparedRuntimeContext,
1143
1149
  };