@lesliechan721/aw 0.1.0-beta.38 → 0.1.0-beta.39

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 (55) hide show
  1. package/dist/authoring/assets/aw-runtime-config.d.mts +13 -0
  2. package/dist/authoring/assets/aw-runtime-config.mjs +199 -0
  3. package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -0
  4. package/dist/authoring/scripts/lib/plugin-version-check.mjs +1 -1
  5. package/dist/authoring/scripts/validate-plugin.mjs +44 -3
  6. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  7. package/dist/scripts/test-plugin-scripts.js +3 -0
  8. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  9. package/dist/src/commands/aw-capabilities.d.ts +1 -1
  10. package/dist/src/commands/aw-capabilities.js +4 -0
  11. package/dist/src/commands/aw-capabilities.js.map +1 -1
  12. package/dist/src/commands/plugin-capabilities.js +4 -0
  13. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  14. package/dist/src/commands/rebuild-integration.js +16 -11
  15. package/dist/src/commands/rebuild-integration.js.map +1 -1
  16. package/dist/src/commands/skill-eval.d.ts +1 -0
  17. package/dist/src/commands/skill-eval.js +14 -2
  18. package/dist/src/commands/skill-eval.js.map +1 -1
  19. package/dist/src/generators/local-plugin.js +3 -0
  20. package/dist/src/generators/local-plugin.js.map +1 -1
  21. package/dist/src/index.js +2 -0
  22. package/dist/src/index.js.map +1 -1
  23. package/dist/src/review/review-profile.js +55 -15
  24. package/dist/src/review/review-profile.js.map +1 -1
  25. package/dist/src/review/source-binding.d.ts +3 -2
  26. package/dist/src/review/source-binding.js +32 -6
  27. package/dist/src/review/source-binding.js.map +1 -1
  28. package/dist/src/tui/config-leaf-editor.d.ts +16 -0
  29. package/dist/src/tui/config-leaf-editor.js +206 -0
  30. package/dist/src/tui/config-leaf-editor.js.map +1 -0
  31. package/dist/src/tui/config-value-presentation.js +23 -12
  32. package/dist/src/tui/config-value-presentation.js.map +1 -1
  33. package/dist/src/tui/console-app-v4.js +137 -25
  34. package/dist/src/tui/console-app-v4.js.map +1 -1
  35. package/dist/src/tui/model.js +12 -12
  36. package/dist/src/tui/model.js.map +1 -1
  37. package/dist/src/utils/artifact-renderer.d.ts +4 -0
  38. package/dist/src/utils/artifact-renderer.js +24 -3
  39. package/dist/src/utils/artifact-renderer.js.map +1 -1
  40. package/dist/src/utils/artifact-request.js +1 -5
  41. package/dist/src/utils/artifact-request.js.map +1 -1
  42. package/dist/src/utils/bundle-layout.js +8 -0
  43. package/dist/src/utils/bundle-layout.js.map +1 -1
  44. package/dist/src/utils/plugin-config-write.js +11 -1
  45. package/dist/src/utils/plugin-config-write.js.map +1 -1
  46. package/dist/src/utils/plugin-config.d.ts +13 -0
  47. package/dist/src/utils/plugin-config.js +113 -3
  48. package/dist/src/utils/plugin-config.js.map +1 -1
  49. package/dist/src/utils/plugin-scripts.d.ts +3 -0
  50. package/dist/src/utils/plugin-scripts.js +18 -3
  51. package/dist/src/utils/plugin-scripts.js.map +1 -1
  52. package/dist/src/utils/runtime-config.d.ts +20 -0
  53. package/dist/src/utils/runtime-config.js +75 -0
  54. package/dist/src/utils/runtime-config.js.map +1 -0
  55. package/package.json +3 -3
@@ -0,0 +1,13 @@
1
+ /** Read this Skill's installed effective values from its actual calling resource. */
2
+ export function readRuntimeConfig(options?: {}): Promise<{
3
+ installedIdentity: any;
4
+ effectiveValues: {
5
+ [k: string]: any;
6
+ };
7
+ resourceRoot: string;
8
+ } | undefined>;
9
+ export class RuntimeConfigError extends Error {
10
+ constructor(code: any, detail?: string);
11
+ code: any;
12
+ recoveryActions: string[];
13
+ }
@@ -0,0 +1,199 @@
1
+ import fs from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ const BINDING = '.aw-runtime-config.json';
5
+ const READER = 'scripts/aw-runtime-config.mjs';
6
+ const isRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
7
+ export class RuntimeConfigError extends Error {
8
+ constructor(code, detail = 'Installed runtime config is unavailable.') {
9
+ super(`${code}: ${detail} Fix the configuration, then run aw sync or aw reinstall.`);
10
+ this.name = 'RuntimeConfigError';
11
+ this.code = code;
12
+ this.recoveryActions = ['sync', 'reinstall'];
13
+ }
14
+ }
15
+ function fail(code, detail) { throw new RuntimeConfigError(code, detail); }
16
+ function relativeFile(value) {
17
+ return typeof value === 'string' && value.length > 0 && !value.includes('\\')
18
+ && !value.includes('\0') && !path.posix.isAbsolute(value)
19
+ && !path.win32.isAbsolute(value) && value.split('/').every((part) => part !== '' && part !== '.' && part !== '..');
20
+ }
21
+ async function regularFile(root, relative) {
22
+ if (!relativeFile(relative))
23
+ fail('runtimeConfigPathUnsafe');
24
+ let current = root;
25
+ const parts = relative.split('/');
26
+ for (let index = 0; index < parts.length; index += 1) {
27
+ current = path.join(current, parts[index]);
28
+ const stat = await fs.lstat(current).catch(() => fail('runtimeConfigResourceMissing'));
29
+ if (stat.isSymbolicLink() || (index === parts.length - 1 ? !stat.isFile() : !stat.isDirectory())) {
30
+ fail('runtimeConfigPathUnsafe');
31
+ }
32
+ }
33
+ return current;
34
+ }
35
+ async function assertPathSafe(file) {
36
+ const absolute = path.resolve(file);
37
+ const parsed = path.parse(absolute);
38
+ let current = parsed.root;
39
+ for (const part of absolute.slice(parsed.root.length).split(path.sep)) {
40
+ current = path.join(current, part);
41
+ const stat = await fs.lstat(current).catch(() => fail('runtimeConfigResourceMissing'));
42
+ if (stat.isSymbolicLink())
43
+ fail('runtimeConfigPathUnsafe');
44
+ }
45
+ return absolute;
46
+ }
47
+ function validateBinding(binding) {
48
+ if (!isRecord(binding) || binding.schemaVersion !== 2 || binding.kind !== 'aw-runtime-config') {
49
+ fail('runtimeConfigVersionUnsupported', 'Expected installed runtime config schemaVersion 2. Rebuild old runtime resources before installing them.');
50
+ }
51
+ if (['definition', 'sources', 'resourceVersion', 'revision', 'digest', 'resources', 'consistencyGroup', 'peerLocators']
52
+ .some((key) => Object.hasOwn(binding, key))) {
53
+ fail('runtimeConfigMigrationRequired', 'Remove v1 runtime metadata and regenerate the schemaVersion 2 binding.');
54
+ }
55
+ const identity = binding.installedIdentity;
56
+ if (!isRecord(identity) || !isRecord(binding.effectiveValues)
57
+ || Object.keys(binding).some((key) => !['schemaVersion', 'kind', 'installedIdentity', 'allowedKeys', 'effectiveValues', 'nativeReceiptPath'].includes(key))
58
+ || !Array.isArray(binding.allowedKeys) || binding.allowedKeys.length === 0
59
+ || binding.allowedKeys.some((key) => typeof key !== 'string' || !key)
60
+ || new Set(binding.allowedKeys).size !== binding.allowedKeys.length
61
+ || Object.values(binding.effectiveValues).some((value) => value === null))
62
+ fail('runtimeConfigBindingInvalid');
63
+ for (const key of ['sourceId', 'sourceIdentity', 'pluginId', 'pluginName', 'pluginVersion', 'artifactId', 'skillKey']) {
64
+ if (typeof identity[key] !== 'string' || !identity[key])
65
+ fail('runtimeConfigIdentityMismatch');
66
+ }
67
+ if (!['codex', 'claude'].includes(identity.platform) || !['user', 'project'].includes(identity.scope)
68
+ || !['user', 'project'].includes(identity.configScope)
69
+ || identity.pluginId !== `${identity.sourceId}/${identity.pluginName}`
70
+ || !/^[A-Za-z][A-Za-z0-9_-]*$/u.test(identity.skillKey)
71
+ || (identity.logicalIdentity !== undefined && (typeof identity.logicalIdentity !== 'string' || !identity.logicalIdentity))) {
72
+ fail('runtimeConfigIdentityMismatch');
73
+ }
74
+ // Core validates field definitions and dependency values when it creates this resource.
75
+ // The reader enforces only this resource's format and permitted projection.
76
+ if (Object.keys(binding.effectiveValues).some((key) => !binding.allowedKeys.includes(key)))
77
+ fail('runtimeConfigKeyDenied');
78
+ return binding;
79
+ }
80
+ async function checkOwner(root, identity) {
81
+ const ownerPath = path.join(root, '.agent-workflows-owner.json');
82
+ const stat = await fs.lstat(ownerPath).catch(() => null);
83
+ if (!stat)
84
+ return;
85
+ if (!stat.isFile() || stat.isSymbolicLink())
86
+ fail('runtimeConfigIdentityMismatch');
87
+ let owner;
88
+ try {
89
+ owner = JSON.parse(await fs.readFile(ownerPath, 'utf8'));
90
+ }
91
+ catch {
92
+ fail('runtimeConfigIdentityMismatch');
93
+ }
94
+ if (!isRecord(owner) || owner.schemaVersion !== 3 || owner.owner !== 'agent-workflows'
95
+ || owner.sourceId !== identity.sourceId || owner.pluginId !== identity.pluginId
96
+ || owner.plugin !== identity.pluginName || owner.artifactKey !== identity.skillKey
97
+ || owner.platform !== identity.platform || owner.scope !== identity.scope)
98
+ fail('runtimeConfigIdentityMismatch');
99
+ }
100
+ async function checkNativeReceipt(root, binding) {
101
+ if (binding.nativeReceiptPath === undefined)
102
+ return;
103
+ if (typeof binding.nativeReceiptPath !== 'string'
104
+ || (binding.nativeReceiptPath !== '.aw-runtime-native-receipt.json'
105
+ && !/^(?:\.\.\/)+\.agents-plugin\/aw-codex-native-render\.json$/u.test(binding.nativeReceiptPath))) {
106
+ fail('runtimeConfigPathUnsafe');
107
+ }
108
+ const receiptFile = await assertPathSafe(path.resolve(root, binding.nativeReceiptPath));
109
+ const stat = await fs.lstat(receiptFile);
110
+ if (!stat.isFile())
111
+ fail('runtimeConfigPathUnsafe');
112
+ let receipt;
113
+ try {
114
+ receipt = JSON.parse(await fs.readFile(receiptFile, 'utf8'));
115
+ }
116
+ catch {
117
+ fail('runtimeConfigBindingInvalid');
118
+ }
119
+ const identity = binding.installedIdentity;
120
+ if (!isRecord(receipt) || receipt.schemaVersion !== 1 || receipt.kind !== 'aw-codex-native-render') {
121
+ fail('runtimeConfigVersionUnsupported');
122
+ }
123
+ if (identity.platform !== 'codex' || identity.scope !== 'user' || identity.configScope !== 'user'
124
+ || receipt.logicalPluginId !== identity.pluginId || receipt.sourceIdentity !== identity.sourceIdentity
125
+ || receipt.pluginVersion !== identity.pluginVersion || receipt.strategy !== 'shared-user'
126
+ || !Array.isArray(receipt.targets) || !receipt.targets.some((target) => isRecord(target)
127
+ && target.id === identity.artifactId && target.skillKey === identity.skillKey)) {
128
+ fail('runtimeConfigIdentityMismatch');
129
+ }
130
+ }
131
+ /** Read this Skill's installed effective values from its actual calling resource. */
132
+ export async function readRuntimeConfig(options = {}) {
133
+ try {
134
+ if (Object.hasOwn(options, 'expectedRevision')) {
135
+ fail('runtimeConfigMigrationRequired', 'expectedRevision is no longer supported. Call readRuntimeConfig with from and keys only.');
136
+ }
137
+ const { from, keys } = options;
138
+ if (!Array.isArray(keys) || keys.some((key) => typeof key !== 'string' || !key) || new Set(keys).size !== keys.length) {
139
+ fail('runtimeConfigKeyDenied');
140
+ }
141
+ let caller;
142
+ try {
143
+ caller = from instanceof URL || (typeof from === 'string' && from.startsWith('file:'))
144
+ ? fileURLToPath(from) : from;
145
+ }
146
+ catch {
147
+ fail('runtimeConfigPathUnsafe');
148
+ }
149
+ if (typeof caller !== 'string' || !path.isAbsolute(caller))
150
+ fail('runtimeConfigPathUnsafe');
151
+ caller = await assertPathSafe(caller);
152
+ const callerStat = await fs.lstat(caller);
153
+ if (!callerStat.isFile())
154
+ fail('runtimeConfigPathUnsafe');
155
+ let root = path.dirname(caller);
156
+ let binding;
157
+ while (true) {
158
+ const stat = await fs.lstat(path.join(root, BINDING)).catch(() => null);
159
+ if (stat) {
160
+ if (!stat.isFile() || stat.isSymbolicLink())
161
+ fail('runtimeConfigPathUnsafe');
162
+ let value;
163
+ try {
164
+ value = JSON.parse(await fs.readFile(path.join(root, BINDING), 'utf8'));
165
+ }
166
+ catch {
167
+ fail('runtimeConfigBindingInvalid');
168
+ }
169
+ binding = validateBinding(value);
170
+ break;
171
+ }
172
+ const parent = path.dirname(root);
173
+ if (parent === root)
174
+ fail('runtimeConfigBindingMissing');
175
+ root = parent;
176
+ }
177
+ if (path.basename(root) !== binding.installedIdentity.skillKey)
178
+ fail('runtimeConfigIdentityMismatch');
179
+ await regularFile(root, path.relative(root, caller).split(path.sep).join('/'));
180
+ await regularFile(root, READER);
181
+ await regularFile(root, 'SKILL.md');
182
+ if (keys.some((key) => !binding.allowedKeys.includes(key)))
183
+ fail('runtimeConfigKeyDenied');
184
+ await checkOwner(root, binding.installedIdentity);
185
+ await checkNativeReceipt(root, binding);
186
+ return {
187
+ installedIdentity: structuredClone(binding.installedIdentity),
188
+ effectiveValues: Object.fromEntries(keys.filter((key) => Object.hasOwn(binding.effectiveValues, key))
189
+ .map((key) => [key, structuredClone(binding.effectiveValues[key])])),
190
+ resourceRoot: root,
191
+ };
192
+ }
193
+ catch (error) {
194
+ if (error instanceof RuntimeConfigError)
195
+ throw error;
196
+ fail('runtimeConfigReadFailed');
197
+ }
198
+ }
199
+ //# sourceMappingURL=aw-runtime-config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aw-runtime-config.mjs","sourceRoot":"","sources":["../../../authoring/assets/aw-runtime-config.mjs"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,OAAO,GAAG,yBAAyB,CAAC;AAC1C,MAAM,MAAM,GAAG,+BAA+B,CAAC;AAC/C,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEjG,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,IAAI,EAAE,MAAM,GAAG,0CAA0C;QACnE,KAAK,CAAC,GAAG,IAAI,KAAK,MAAM,2DAA2D,CAAC,CAAC;QACrF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,eAAe,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC/C,CAAC;CACF;AAED,SAAS,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,MAAM,IAA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ver.mjs';
11
11
  import { assertAuthoringPluginPathFence, resolveAuthoringPluginRoot, } from './plugin-root.mjs';
12
12
  const execFileAsync = promisify(execFile);
13
- const EXPECTED_MANIFEST_CONTRACT_VERSION = 13;
13
+ const EXPECTED_MANIFEST_CONTRACT_VERSION = 16;
14
14
  const PLUGIN_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
15
15
  const GIT_OBJECT_ID_PATTERN = /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u;
16
16
  const MAX_GIT_BLOB_BYTES = 50 * 1024 * 1024;
@@ -6,7 +6,7 @@ import { createRequire } from 'node:module';
6
6
  import * as os from 'node:os';
7
7
  import * as path from 'node:path';
8
8
  import { fileURLToPath, pathToFileURL } from 'node:url';
9
- import { getPluginAuthoringAcceptedValues as getCorePluginAuthoringAcceptedValues, getSkillFrontmatterCapabilityRegistry, normalizePluginConfigDefinition, } from '@lesliechan721/aw-plugin-core/manifest';
9
+ import { AW_RUNTIME_CONFIG_READER_PATH, createRuntimeConfigSnapshot, getPluginAuthoringAcceptedValues as getCorePluginAuthoringAcceptedValues, getSkillFrontmatterCapabilityRegistry, normalizePluginConfigDefinition, } from '@lesliechan721/aw-plugin-core/manifest';
10
10
  import { checkPluginVersions } from './lib/plugin-version-check.mjs';
11
11
  import { scanJavaScriptImportSpecifiers } from './lib/javascript-import-scanner.mjs';
12
12
  import { assertAuthoringPluginPathFence, assertCanonicalAuthoringPluginRoot, } from './lib/plugin-root.mjs';
@@ -18,7 +18,7 @@ const CLI_PACKAGE_ROOT = path.basename(authoringRuntimeRoot) === 'dist'
18
18
  : authoringRuntimeRoot;
19
19
  const errors = [];
20
20
  const warnings = [];
21
- const SOURCE_PLUGIN_MANIFEST_CONTRACT_VERSION = 13;
21
+ const SOURCE_PLUGIN_MANIFEST_CONTRACT_VERSION = 16;
22
22
  let capabilityDiagnostic = null;
23
23
  const MAX_SKILL_NAME_LEN = 64;
24
24
  const MAX_SKILL_DESCRIPTION_LEN = 1024;
@@ -1631,6 +1631,10 @@ function scanNodeImportContract(pluginDir, entryPaths, options) {
1631
1631
  continue;
1632
1632
  }
1633
1633
  if (!resolved.path) {
1634
+ const requested = path.posix.normalize(path.posix.join(path.posix.dirname(relativePath), specifier));
1635
+ if ((options.runtimeConfigSkillRoots ?? []).some((root) => (relativePath.startsWith(`${root}/`)
1636
+ && requested === path.posix.join(root, AW_RUNTIME_CONFIG_READER_PATH))))
1637
+ continue;
1634
1638
  error(`${options.label}: unable to resolve relative import "${specifier}" from "${relativePath}"`);
1635
1639
  continue;
1636
1640
  }
@@ -1816,6 +1820,7 @@ function validateArtifactTargetEntry(entry, index, manifest, pluginDir) {
1816
1820
  'skillKey',
1817
1821
  'sourceDirs',
1818
1822
  'runtimeImports',
1823
+ 'runtimeConfig',
1819
1824
  ]);
1820
1825
  const id = validateArtifactId(target.id, `${fieldName}.id`);
1821
1826
  const artifactTarget = validateManifestString(target.target, `${fieldName}.target`);
@@ -2013,6 +2018,7 @@ function validateArtifactTargetEntry(entry, index, manifest, pluginDir) {
2013
2018
  roleKey,
2014
2019
  skillKey,
2015
2020
  sourceDirs,
2021
+ runtimeConfig: target.runtimeConfig,
2016
2022
  runtimeImports: Array.isArray(target.runtimeImports) ? target.runtimeImports : [],
2017
2023
  };
2018
2024
  }
@@ -2650,6 +2656,32 @@ function runArtifactRendererFixture(pluginDir, manifest, renderEntry, declaratio
2650
2656
  ? []
2651
2657
  : [[key, manifest.config.fields[key]]]));
2652
2658
  const scopedValues = Object.fromEntries(refreshKeys.flatMap((key) => Object.prototype.hasOwnProperty.call(values, key) ? [[key, values[key]]] : []));
2659
+ try {
2660
+ for (const target of scopedDeclarations.filter((declaration) => declaration.runtimeConfig)) {
2661
+ const definition = normalizePluginConfigDefinition(manifest.config);
2662
+ createRuntimeConfigSnapshot({
2663
+ installedIdentity: {
2664
+ sourceId: 'authoring',
2665
+ sourceIdentity: 'authoring',
2666
+ pluginId: `authoring/${manifest.name}`,
2667
+ pluginName: manifest.name,
2668
+ pluginVersion: manifest.version,
2669
+ platform: target.platform,
2670
+ scope: target.delivery?.mode === 'codex-native' ? 'user' : scope,
2671
+ configScope,
2672
+ artifactId: target.id,
2673
+ skillKey: target.skillKey,
2674
+ },
2675
+ declaration: target.runtimeConfig,
2676
+ definition,
2677
+ values,
2678
+ });
2679
+ }
2680
+ }
2681
+ catch (runtimeConfigError) {
2682
+ error(`scripts.artifacts.render fixture (${surface}/${scope}) runtime config failed: ${runtimeConfigError.message}`);
2683
+ continue;
2684
+ }
2653
2685
  fs.writeFileSync(contextPath, JSON.stringify({
2654
2686
  event,
2655
2687
  surface: distribution
@@ -2674,7 +2706,9 @@ function runArtifactRendererFixture(pluginDir, manifest, renderEntry, declaratio
2674
2706
  changedConfigKeys: [],
2675
2707
  requestedArtifactIds: scopedDeclarations.map((target) => target.id),
2676
2708
  previousArtifacts: [],
2677
- artifactSources: scopedDeclarations.map((target) => ({
2709
+ artifactSources: declarations.filter((target) => (target.target === 'codex.skill' || target.target === 'claude.skill' || target.target === 'agent-skills.skill')
2710
+ && (distribution ? target.distribution === distribution : target.platform === platform)
2711
+ && target.scopes.includes(scope)).map((target) => ({
2678
2712
  id: target.id,
2679
2713
  target: target.target,
2680
2714
  sourceDirs: target.sourceDirs.map((sourceDir) => path.join(pluginDir, normalizeRelativePath(sourceDir))),
@@ -2789,6 +2823,10 @@ function validateScriptsLightweight(pluginDir, manifest) {
2789
2823
  const runtimeNodeEntries = [];
2790
2824
  let artifactRenderEntry = null;
2791
2825
  let packageMeta = null;
2826
+ const runtimeConfigSkillRoots = (manifest.artifacts?.targets ?? [])
2827
+ .filter((target) => target.runtimeConfig !== undefined)
2828
+ .flatMap((target) => target.sourceDirs ?? [])
2829
+ .map(normalizeRelativePath);
2792
2830
  if (scripts.helpers !== undefined) {
2793
2831
  const helpers = expectRecord(scripts.helpers, 'scripts.helpers');
2794
2832
  if (helpers) {
@@ -2836,6 +2874,7 @@ function validateScriptsLightweight(pluginDir, manifest) {
2836
2874
  label: 'scripts.node.build import contract',
2837
2875
  packageMeta,
2838
2876
  allowDevDependencies: true,
2877
+ runtimeConfigSkillRoots,
2839
2878
  });
2840
2879
  }
2841
2880
  }
@@ -2885,6 +2924,7 @@ function validateScriptsLightweight(pluginDir, manifest) {
2885
2924
  label: 'scripts.tests.node import contract',
2886
2925
  packageMeta,
2887
2926
  allowDevDependencies: true,
2927
+ runtimeConfigSkillRoots,
2888
2928
  });
2889
2929
  }
2890
2930
  }
@@ -2894,6 +2934,7 @@ function validateScriptsLightweight(pluginDir, manifest) {
2894
2934
  label: 'runtime Node import contract',
2895
2935
  packageMeta,
2896
2936
  allowDevDependencies: false,
2937
+ runtimeConfigSkillRoots,
2897
2938
  });
2898
2939
  return artifactRenderEntry;
2899
2940
  }