@aiwg/cli 2026.11.0 → 2026.11.1
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/agentic/code/providers/flue/README.md +2 -1
- package/dist/src/artifacts/cli.js +3 -2
- package/dist/src/artifacts/discover-facets.js +2 -0
- package/dist/src/artifacts/discover-session-facets.js +14 -0
- package/dist/src/artifacts/fortemi-core-query-adapter.js +4 -4
- package/dist/src/artifacts/framework-capabilities.js +7 -3
- package/dist/src/artifacts/index-builder.js +2 -3
- package/dist/src/artifacts/query-engine-discover-output.js +3 -3
- package/dist/src/artifacts/query-engine-discover.js +61 -14
- package/dist/src/artifacts/query-engine-entries.js +52 -9
- package/dist/src/artifacts/query-engine-installation.js +27 -0
- package/dist/src/artifacts/query-engine-rules.js +1 -2
- package/dist/src/artifacts/query-engine-scoring.js +33 -31
- package/dist/src/artifacts/query-engine-show-card.js +6 -2
- package/dist/src/artifacts/query-engine-show.js +2 -2
- package/dist/src/artifacts/relations.js +17 -10
- package/dist/src/cli/handlers/checkpoint.js +143 -0
- package/dist/src/cli/handlers/help.js +1 -0
- package/dist/src/cli/handlers/index.js +4 -2
- package/dist/src/cli/handlers/models-resource-sample.js +7 -3
- package/dist/src/cli/handlers/ralph-launcher.js +1 -1
- package/dist/src/cli/handlers/script-runner.js +2 -1
- package/dist/src/cli/handlers/steward-signing.js +44 -0
- package/dist/src/cli/handlers/steward.js +5 -0
- package/dist/src/cli/handlers/use-provider-results.js +17 -0
- package/dist/src/cli/handlers/use.js +9 -15
- package/dist/src/cli/router.js +12 -2
- package/dist/src/cli/user-scope-mirror.js +3 -1
- package/dist/src/config/aiwg-config.js +5 -1
- package/dist/src/config/cli.js +1 -0
- package/dist/src/config/delivery-validation.js +21 -0
- package/dist/src/config/host-resource-report.d.mts +1 -1
- package/dist/src/config/host-resource-report.mjs +23 -4
- package/dist/src/config/host-resource-runtime.d.mts +8 -0
- package/dist/src/config/host-resource-runtime.mjs +67 -24
- package/dist/src/config/index-graph-overrides.js +4 -0
- package/dist/src/config/worker-attribution.d.mts +7 -0
- package/dist/src/config/worker-attribution.mjs +44 -0
- package/dist/src/delivery/git.js +62 -0
- package/dist/src/delivery/pr.js +149 -0
- package/dist/src/delivery/tracker.js +33 -0
- package/dist/src/discovery/interview.js +1 -1
- package/dist/src/extensions/claude-hooks-installer.js +1 -0
- package/dist/src/extensions/loader.js +2 -1
- package/dist/src/issues/cli.js +12 -3
- package/dist/src/issues/external-cli.js +76 -0
- package/dist/src/issues/live.js +18 -1
- package/dist/src/issues/tracker-policy.js +17 -0
- package/dist/src/mcp/tools/worker-invoke.mjs +2 -1
- package/dist/src/mcp/tools/worker-stdin-runtime.mjs +12 -0
- package/dist/src/models/conductor-data-policy.d.mts +3 -2
- package/dist/src/models/conductor-data-policy.mjs +94 -5
- package/dist/src/models/worker-plan.js +3 -3
- package/dist/src/models/worker-selection-policy.js +2 -1
- package/dist/src/providers/deployment-lock.js +77 -0
- package/dist/src/providers/deployment-ownership.d.mts +12 -2
- package/dist/src/providers/deployment-ownership.mjs +115 -21
- package/dist/src/providers/deployment-preservation.d.mts +2 -1
- package/dist/src/providers/deployment-preservation.mjs +3 -0
- package/dist/src/providers/provider-definitions.js +4 -0
- package/dist/src/serve/worker-invocation-preparation.js +3 -1
- package/dist/src/serve/worker-invocation.js +2 -0
- package/dist/src/skills/run.js +5 -0
- package/dist/src/smiths/hook-bridge/codex-translator.js +3 -1
- package/dist/src/smiths/hook-bridge/hermes-translator.js +3 -1
- package/dist/src/smiths/hook-bridge/prompt-discovery-gaps.js +6 -0
- package/package.json +4 -2
- package/schemas/models/model-config-compatibility.v1.schema.json +4 -0
- package/tools/agents/deploy-agents.mjs +15 -0
- package/tools/agents/providers/base-contract.mjs +7 -1
- package/tools/agents/providers/base-inventory.mjs +35 -13
- package/tools/agents/providers/base.mjs +1 -1
- package/tools/agents/providers/conductor-data-guard.mjs +35 -11
- package/tools/agents/providers/muse-hooks.mjs +4 -0
- package/tools/agents/providers/muse-prompt-discovery.mjs +22 -0
- package/tools/agents/providers/provider-prepare-coordinator.mjs +15 -10
- package/tools/agents/providers/rule-delivery-surface.mjs +6 -3
- package/tools/agents/providers/rule-deployment-commit.mjs +10 -0
- package/tools/agents/providers/stale-artifact-prune.mjs +9 -8
- package/tools/ralph-external/lib/worker-capture.mjs +157 -0
- package/tools/ralph-external/lib/worker-health.mjs +3 -0
- package/tools/ralph-external/lib/worker-invocation-processes.mjs +9 -6
- package/tools/ralph-external/lib/worker-launch-cli.mjs +10 -1
- package/tools/ralph-external/lib/worker-process-identity.mjs +30 -0
- package/tools/ralph-external/lib/worker-retry-evidence.mjs +87 -6
- package/tools/ralph-external/lib/worker-termination.mjs +56 -6
- package/tools/ralph-external/process-monitor.mjs +12 -18
- package/tools/ralph-external/session-launcher.mjs +43 -29
- package/vscode-extension/schemas/aiwg.config.v1.json +15 -0
|
@@ -31,16 +31,110 @@ export function deploymentOutputRoots(provider, target) {
|
|
|
31
31
|
'.windsurfrules', 'models.json', '.aiwg/frameworks', '.aiwg/.aiwg-manifest.json'].map(name => path.join(target, name))])];
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
// Settings files and Flue outputs keep preimage bytes in their receipts.
|
|
35
|
+
const SETTINGS_FILE = /^(?:settings(?:\.local)?|hooks|opencode|config|aiwg\.cordis\.patch)\.(?:json|toml|ya?ml)$/;
|
|
36
|
+
const FLUE_OUTPUT = /[/\\](?:db\.ts|aiwg[/\\](?:(?:tools|specialists|skills)\.ts|remote-specialist\.(?:js|d\.ts)))$/;
|
|
37
|
+
// Timestamps are coarse: a same-size write right after a stat can keep its
|
|
38
|
+
// ctime. Files changed this recently are hashed instead of trusted by stat.
|
|
39
|
+
const RECENT_NS = 2_000_000_000n;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A snapshot entry for a file whose bytes the recorder never needs: provider
|
|
43
|
+
* homes such as ~/.hermes or ~/.codex hold gigabytes of runtime data (#3846).
|
|
44
|
+
* `hash` is set when the bytes were read; otherwise only the stat is known.
|
|
45
|
+
*/
|
|
46
|
+
export class DeploymentOutputState {
|
|
47
|
+
constructor(signature, digest) { this.signature = signature; this.hash = digest; }
|
|
48
|
+
}
|
|
49
|
+
const signatures = new WeakMap();
|
|
50
|
+
const digests = new WeakMap();
|
|
51
|
+
const digestOf = entry => {
|
|
52
|
+
if (entry == null) return undefined;
|
|
53
|
+
if (entry instanceof DeploymentOutputState) return entry.hash;
|
|
54
|
+
if (!digests.has(entry)) digests.set(entry, hash(entry));
|
|
55
|
+
return digests.get(entry);
|
|
56
|
+
};
|
|
57
|
+
/** sha256 digest of a snapshot entry, or undefined when only its stat is known. */
|
|
58
|
+
export const outputDigest = entry => digestOf(entry);
|
|
59
|
+
/** Content equality; a stat-only entry never equals a different entry. */
|
|
60
|
+
export const sameOutput = (a, b) => a != null && b != null && (a === b || (digestOf(a) !== undefined && digestOf(a) === digestOf(b)));
|
|
61
|
+
const bytesOf = (file, entry) => {
|
|
62
|
+
if (entry == null || Buffer.isBuffer(entry)) return entry;
|
|
63
|
+
throw new Error(`Deployment snapshot did not retain bytes for ${file}`);
|
|
64
|
+
};
|
|
65
|
+
const signature = stat => `${stat.dev}:${stat.ino}:${stat.size}:${stat.mtimeNs}:${stat.ctimeNs}`;
|
|
66
|
+
const receiptBase = (file, receipt) => receipt.scope === 'project' && path.basename(path.dirname(file)) === '.aiwg'
|
|
67
|
+
? path.dirname(path.dirname(file)) : path.dirname(file);
|
|
68
|
+
const claimsOf = (file, bytes, claims) => {
|
|
69
|
+
const receipt = parse(bytes), base = receiptBase(file, receipt);
|
|
70
|
+
for (const name of Object.keys(receipt.managed || {})) {
|
|
71
|
+
const target = path.resolve(base, name);
|
|
72
|
+
if (target.startsWith(`${base}${path.sep}`)) claims.add(target);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Capture regular output files before this invocation; never follow symlinks.
|
|
78
|
+
* Bytes are kept for receipts, settings, Flue outputs, receipt-claimed files,
|
|
79
|
+
* files beside a receipt and project-root files. Other files are recorded by
|
|
80
|
+
* stat (or digest, when recently changed), so memory does not scale with the
|
|
81
|
+
* size of a provider home. Pass the earlier snapshot as `previous` to reuse
|
|
82
|
+
* entries for files whose stat did not change.
|
|
83
|
+
*/
|
|
84
|
+
export function captureDeploymentOutputs(roots, { previous } = {}) {
|
|
36
85
|
const files = new Map();
|
|
37
|
-
const
|
|
86
|
+
const stats = new Map();
|
|
87
|
+
signatures.set(files, stats);
|
|
88
|
+
const prior = previous && signatures.get(previous);
|
|
89
|
+
const recentFrom = BigInt(Date.now()) * 1_000_000n - RECENT_NS;
|
|
90
|
+
const claims = new Set();
|
|
91
|
+
// A file this process cannot read is not one it wrote; keep its stat only.
|
|
92
|
+
// Live provider homes also delete files mid-walk; those are simply absent.
|
|
93
|
+
const gone = Symbol('gone');
|
|
94
|
+
const readable = file => {
|
|
95
|
+
try { return fs.readFileSync(file); } catch (error) {
|
|
96
|
+
if (error.code === 'EACCES' || error.code === 'EPERM') return null;
|
|
97
|
+
if (error.code === 'ENOENT') return gone;
|
|
98
|
+
throw error;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const capture = (file, stat, retain, output) => {
|
|
102
|
+
const sig = signature(stat), recent = stat.ctimeNs >= recentFrom, old = previous?.get(file);
|
|
103
|
+
stats.set(file, sig);
|
|
104
|
+
if (old && !recent && prior?.get(file) === sig && (Buffer.isBuffer(old) || !retain)) { files.set(file, old); return; }
|
|
105
|
+
// The post-deploy pass hashes every file it cannot reuse. The first pass
|
|
106
|
+
// hashes AIWG output kinds (so an identical rewrite is not a change) and
|
|
107
|
+
// recently changed files; provider runtime data keeps only its stat.
|
|
108
|
+
const bytes = retain || previous || recent || output ? readable(file) : null;
|
|
109
|
+
if (bytes === gone) { stats.delete(file); return; }
|
|
110
|
+
files.set(file, retain && bytes ? bytes : new DeploymentOutputState(sig, bytes ? hash(bytes) : undefined));
|
|
111
|
+
};
|
|
112
|
+
// `parent` is 'project' for a project root's direct children and 'managed'
|
|
113
|
+
// for files beside a receipt.
|
|
114
|
+
const visit = (root, file, depth, parent) => {
|
|
38
115
|
let stat;
|
|
39
|
-
try { stat = fs.lstatSync(file); } catch (error) { if (error.code === 'ENOENT') return; throw error; }
|
|
40
|
-
if (stat.isDirectory())
|
|
41
|
-
|
|
116
|
+
try { stat = fs.lstatSync(file, { bigint: true }); } catch (error) { if (error.code === 'ENOENT') return; throw error; }
|
|
117
|
+
if (stat.isDirectory()) {
|
|
118
|
+
let names;
|
|
119
|
+
try { names = fs.readdirSync(file); } catch (error) { if (error.code === 'ENOENT' || error.code === 'ENOTDIR') return; throw error; }
|
|
120
|
+
const managed = names.includes(SIDECAR);
|
|
121
|
+
// Read a directory's receipt before its files so its claims are known.
|
|
122
|
+
if (managed) visit(root, path.join(file, SIDECAR), depth + 1, 'managed');
|
|
123
|
+
const childParent = depth === 0 && names.includes('.aiwg') ? 'project' : managed ? 'managed' : null;
|
|
124
|
+
for (const name of names) if (name !== SIDECAR) visit(root, path.join(file, name), depth + 1, childParent);
|
|
125
|
+
} else if (stat.isFile()) {
|
|
126
|
+
const key = path.resolve(file), base = path.basename(key);
|
|
127
|
+
capture(key, stat, base === SIDECAR || SETTINGS_FILE.test(base) || FLUE_OUTPUT.test(key)
|
|
128
|
+
|| depth === 0 || parent !== null || claims.has(key), artifactKind(path.relative(root, key)) !== 'generated');
|
|
129
|
+
if (base === SIDECAR) claimsOf(key, files.get(key), claims);
|
|
130
|
+
}
|
|
42
131
|
};
|
|
43
|
-
|
|
132
|
+
// Project-scoped receipts claim files outside their own directory.
|
|
133
|
+
for (const root of roots) {
|
|
134
|
+
const receipt = path.basename(String(root)) === SIDECAR ? String(root) : path.join(String(root), '.aiwg', SIDECAR);
|
|
135
|
+
try { claimsOf(path.resolve(receipt), fs.readFileSync(receipt), claims); } catch { /* absent */ }
|
|
136
|
+
}
|
|
137
|
+
for (const root of roots) visit(path.resolve(String(root)), String(root), 0, null);
|
|
44
138
|
// A root-level file's sidecar is itself outside that file's snapshot root.
|
|
45
139
|
for (const file of [...files.keys()]) {
|
|
46
140
|
const receipt = path.join(path.dirname(file), SIDECAR);
|
|
@@ -126,7 +220,7 @@ function artifactKind(file) {
|
|
|
126
220
|
/** Record only writes evidenced by this invocation or newly emitted file receipts. */
|
|
127
221
|
export function recordDeploymentOutputs(before, roots, opts = {}) {
|
|
128
222
|
if (opts.dryRun) return;
|
|
129
|
-
const after = captureDeploymentOutputs(roots);
|
|
223
|
+
const after = captureDeploymentOutputs(roots, { previous: before });
|
|
130
224
|
const owner = deploymentOwner(opts);
|
|
131
225
|
const manifests = new Map();
|
|
132
226
|
const manifest = dir => {
|
|
@@ -148,7 +242,7 @@ export function recordDeploymentOutputs(before, roots, opts = {}) {
|
|
|
148
242
|
const base = receiptRoot(file, receipt);
|
|
149
243
|
const target = path.resolve(base, name);
|
|
150
244
|
if (!target.startsWith(`${base}${path.sep}`) || receipt.managed?.[name]) continue;
|
|
151
|
-
if (!
|
|
245
|
+
if (!sameOutput(after.get(target), before.get(target))) continue;
|
|
152
246
|
receipt.managed ||= {};
|
|
153
247
|
receipt.managed[name] = entry;
|
|
154
248
|
manifests.set(file, receipt);
|
|
@@ -161,8 +255,8 @@ export function recordDeploymentOutputs(before, roots, opts = {}) {
|
|
|
161
255
|
// A receipt rewrite is not evidence of a payload write. Preservation can
|
|
162
256
|
// also restore bytes after a writer/binder marked the file as written.
|
|
163
257
|
// Never bless those edited bytes, even with an explicit write hint.
|
|
164
|
-
if (before.get(target)
|
|
165
|
-
(prior ? prior.hash !==
|
|
258
|
+
if (sameOutput(before.get(target), after.get(target)) &&
|
|
259
|
+
(prior ? prior.hash !== digestOf(before.get(target)) : entry.hash === digestOf(before.get(target)) && !opts.writtenFiles?.includes(target))) {
|
|
166
260
|
if (prior) receipt.managed[name] = prior;
|
|
167
261
|
else delete receipt.managed[name];
|
|
168
262
|
preserved.add(target);
|
|
@@ -176,12 +270,12 @@ export function recordDeploymentOutputs(before, roots, opts = {}) {
|
|
|
176
270
|
if (path.basename(file) === SIDECAR || /(?:^|[/\\])aiwg\.config$/.test(file)
|
|
177
271
|
|| /(?:\.bak\.|\.aiwg-backup-)/.test(path.basename(file))) continue;
|
|
178
272
|
if (preserved.has(file)) continue;
|
|
179
|
-
const changed = !before.get(file)
|
|
273
|
+
const changed = !sameOutput(before.get(file), bytes);
|
|
180
274
|
const declaration = declared.get(file);
|
|
181
275
|
if (opts.onlyDeclared && !declaration) continue;
|
|
182
276
|
if (!changed && !declaration && !opts.writtenFiles?.includes(file)) continue;
|
|
183
277
|
// Existing integrity receipts that disagree with bytes never bless operator edits.
|
|
184
|
-
if (declaration?.entry.hash && declaration.entry.hash !==
|
|
278
|
+
if (declaration?.entry.hash && declaration.entry.hash !== digestOf(bytes)) continue;
|
|
185
279
|
let skillRoot = path.dirname(file);
|
|
186
280
|
while (skillRoot !== path.dirname(skillRoot)) {
|
|
187
281
|
const parentReceipt = parse(after.get(path.join(skillRoot, SIDECAR)));
|
|
@@ -189,7 +283,7 @@ export function recordDeploymentOutputs(before, roots, opts = {}) {
|
|
|
189
283
|
skillRoot = path.dirname(skillRoot);
|
|
190
284
|
}
|
|
191
285
|
const skillReceipt = parse(after.get(path.join(skillRoot, SIDECAR)));
|
|
192
|
-
const projectScoped = projectRoot && (path.dirname(file) === projectRoot || opts.provider === 'flue' &&
|
|
286
|
+
const projectScoped = projectRoot && (path.dirname(file) === projectRoot || opts.provider === 'flue' && FLUE_OUTPUT.test(file));
|
|
193
287
|
const dir = projectScoped ? path.join(projectRoot, '.aiwg') : declaration ? path.dirname(declaration.file) : skillReceipt.managed?.['SKILL.md'] ? skillRoot : path.dirname(file);
|
|
194
288
|
const name = declaration?.name || portable(path.relative(projectScoped ? projectRoot : dir, file));
|
|
195
289
|
const existing = manifests.get(path.join(dir, SIDECAR)) || parse(after.get(path.join(dir, SIDECAR)));
|
|
@@ -197,10 +291,10 @@ export function recordDeploymentOutputs(before, roots, opts = {}) {
|
|
|
197
291
|
const current = existing.managed?.[name] || {};
|
|
198
292
|
// A redeploy may preserve operator additions around generated context.
|
|
199
293
|
// Keep the old digest so removal cannot restore a stale preimage over them.
|
|
200
|
-
if (previous?.filePreimage && before.has(file) && previous.hash !==
|
|
294
|
+
if (previous?.filePreimage && before.has(file) && previous.hash !== digestOf(before.get(file))) continue;
|
|
201
295
|
const identity = current.sourcePath || `${declaration?.receipt.skillSource}/SKILL.md`;
|
|
202
296
|
const logicalSource = opts.logicalInputPath?.(identity) || identity;
|
|
203
|
-
const sourceOwner = (declaration || current.hash ===
|
|
297
|
+
const sourceOwner = (declaration || current.hash === digestOf(bytes)) && (current.frameworkSlug || bundleOwner(logicalSource))
|
|
204
298
|
|| skillReceipt.managed?.['SKILL.md']?.frameworkSlug;
|
|
205
299
|
const generatedIndex = /^RULES-(?:INDEX|ONDEMAND)\.(?:md|mdc)$/.test(path.basename(file));
|
|
206
300
|
const kind = generatedIndex ? 'rule-index' : current.kind || artifactKind(file);
|
|
@@ -211,12 +305,12 @@ export function recordDeploymentOutputs(before, roots, opts = {}) {
|
|
|
211
305
|
}
|
|
212
306
|
const receipt = manifest(dir);
|
|
213
307
|
if (projectScoped) receipt.scope = 'project';
|
|
214
|
-
const record = mergeArtifactOwnership(previous, { ...current, hash:
|
|
308
|
+
const record = mergeArtifactOwnership(previous, { ...current, hash: digestOf(bytes), owners: opts.provider === 'flue' ? [] : current.hash === digestOf(bytes) ? current.owners : [], kind }, selectedOwner);
|
|
215
309
|
// Flue's composed context and generated database/ignore outputs support
|
|
216
310
|
// exact restoration. Never infer a preimage for another provider's files.
|
|
217
311
|
if (opts.provider === 'flue' && (projectScoped || /[/\\]db\.ts$/.test(file))) {
|
|
218
312
|
record.filePreimage = previous?.filePreimage || { present: before.has(file),
|
|
219
|
-
...(before.has(file) ? { bytes: before.get(file).toString('base64'), hash:
|
|
313
|
+
...(before.has(file) ? { bytes: bytesOf(file, before.get(file)).toString('base64'), hash: digestOf(before.get(file)) } : {}) };
|
|
220
314
|
}
|
|
221
315
|
// Structural rule indexes are generated outputs; their assembly scratch
|
|
222
316
|
// directory is not a durable source identity.
|
|
@@ -225,14 +319,14 @@ export function recordDeploymentOutputs(before, roots, opts = {}) {
|
|
|
225
319
|
record.kind = 'rule-index';
|
|
226
320
|
}
|
|
227
321
|
// Settings have key/value receipts in the same entry, never a separate store.
|
|
228
|
-
if (
|
|
322
|
+
if (SETTINGS_FILE.test(path.basename(file))) {
|
|
229
323
|
record.kind = 'settings';
|
|
230
324
|
record.settingsPreimage = previous?.settingsPreimage || (!previous?.settings ? {
|
|
231
|
-
present: before.has(file), ...(before.has(file) ? { bytes: before.get(file).toString('base64'), hash:
|
|
325
|
+
present: before.has(file), ...(before.has(file) ? { bytes: bytesOf(file, before.get(file)).toString('base64'), hash: digestOf(before.get(file)) } : {})
|
|
232
326
|
} : undefined);
|
|
233
327
|
const claimUnchanged = opts.claimUnchangedSettings !== false
|
|
234
328
|
&& !/(?:agentic\/code|\.aiwg)\/(?:addons|extensions)\//.test((opts.logicalInputPath?.(opts.srcRoot) || opts.srcRoot)?.replaceAll('\\', '/') || '');
|
|
235
|
-
record.settings = settingsRecords(settingsDocument(file, before.get(file)), settingsDocument(file, bytes), previous?.settings, selectedOwner, claimUnchanged);
|
|
329
|
+
record.settings = settingsRecords(settingsDocument(file, bytesOf(file, before.get(file))), settingsDocument(file, bytesOf(file, bytes)), previous?.settings, selectedOwner, claimUnchanged);
|
|
236
330
|
const settingsOwners = Object.values(record.settings).flatMap(entry => entry.owners);
|
|
237
331
|
record.owners = [...new Set(settingsOwners.length ? settingsOwners
|
|
238
332
|
: [...(previous?.owners || []), ...(changed ? [selectedOwner] : [])])].sort();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AiwgConfig } from '../config/aiwg-config.js';
|
|
2
|
+
import type { DeploymentOutputSnapshot } from './deployment-ownership.mjs';
|
|
2
3
|
export function providerCopyMode(project: string, provider: string, owner?: string, config?: AiwgConfig, indexOwner?: string): boolean;
|
|
3
4
|
export function automaticRemovalAllowed(project: string, provider: string, file: string, config?: AiwgConfig): boolean;
|
|
4
|
-
export function preserveDeploymentOutputs(before:
|
|
5
|
+
export function preserveDeploymentOutputs(before: DeploymentOutputSnapshot, roots: string[], opts?: Record<string, unknown>): void;
|
|
5
6
|
export function deploymentEditWarnings(project: string, provider: string): string[];
|
|
@@ -54,6 +54,9 @@ export function preserveDeploymentOutputs(before, roots, opts = {}) {
|
|
|
54
54
|
const restored = [];
|
|
55
55
|
for (const [file, bytes] of before) {
|
|
56
56
|
if (path.basename(file) === sidecar) continue;
|
|
57
|
+
// Snapshots keep bytes for receipt-claimed and receipt-adjacent files only;
|
|
58
|
+
// provider runtime data recorded by stat or digest is never restored (#3846).
|
|
59
|
+
if (!Buffer.isBuffer(bytes)) continue;
|
|
57
60
|
const exists = fs.existsSync(file);
|
|
58
61
|
if (!exists && opts.replacedSkillCopies?.has(file)) continue;
|
|
59
62
|
const claim = claims.get(file);
|
|
@@ -71,6 +71,10 @@ function assertNoDuplicateAliases(definitions) {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
+
/** Deployment paths do not require loading the optional capability corpus. */
|
|
75
|
+
export function listProviderDeploymentLayouts() {
|
|
76
|
+
return BUILT_IN_SEEDS.map(({ paths, smithPaths }) => ({ paths, smithPaths }));
|
|
77
|
+
}
|
|
74
78
|
export function listProviderDefinitions() {
|
|
75
79
|
if (!cachedRegistry) {
|
|
76
80
|
const definitions = BUILT_IN_SEEDS.map(buildDefinition);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** Validate and render a prepared invocation against trusted installation controls. */
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { directWorkerEnvironment } from '../config/worker-attribution.mjs';
|
|
3
4
|
import { createHash } from 'node:crypto';
|
|
4
5
|
import { fileURLToPath } from 'node:url';
|
|
5
6
|
import { validateWorkerArtifacts } from './worker-artifacts.mjs';
|
|
@@ -106,7 +107,8 @@ export async function prepareWorkerInvocation(invocation, qualification) {
|
|
|
106
107
|
// (worker-stdin-frame.mjs), so brief text never enters any argv.
|
|
107
108
|
const deadline = qualification.ceilings?.wallSeconds === undefined ? ''
|
|
108
109
|
: `timeout --signal=KILL ${quote(`${Math.min(result.health?.hardTimeoutSeconds ?? Infinity, result.limits.wallSeconds)}s`)} `;
|
|
109
|
-
const
|
|
110
|
+
const markers = Object.entries(directWorkerEnvironment(result)).map(([name, value]) => `${name}=${quote(value)}`).join(' ');
|
|
111
|
+
const worker = `${deadline}env -i${environment ? ` ${environment}` : ''} ${markers} ${result.argv.map(quote).join(' ')}`;
|
|
110
112
|
const outputs = `> ${quote(result.stdoutPath)} 2> ${quote(result.stderrPath)}`;
|
|
111
113
|
if (result.stdin === 'brief-json') {
|
|
112
114
|
const framer = fileURLToPath(new URL('./worker-stdin-frame.mjs', import.meta.url));
|
|
@@ -402,6 +402,8 @@ export function workerInvocationDiagnostic(error, pointer, fallback = 'OG_CONFIG
|
|
|
402
402
|
OG_MODEL_UNAPPROVED: 'The selected model lacks current approved observation evidence.',
|
|
403
403
|
OG_EFFORT_DENIED: 'The selected effort is denied by the resolved worker policy.',
|
|
404
404
|
OG_DATA_POLICY: 'The selected model does not satisfy the resolved data policy.',
|
|
405
|
+
OG_HOST_ATTRIBUTION: 'Host capacity includes unattributed workers. Inspect aiwg doctor --resources --json before retrying.',
|
|
406
|
+
OG_HOST_CAPACITY: 'Worker capacity is exhausted. Inspect aiwg doctor --resources --json before retrying.',
|
|
405
407
|
OG_ADAPTER_UNQUALIFIED: 'The installation or invocation could not be revalidated. Run aiwg doctor --probe-workers --qualify to qualify this workspace.',
|
|
406
408
|
OG_POLICY_RELAXATION: 'The request would relax the resolved worker policy.',
|
|
407
409
|
OG_BUDGET_UNMEASURABLE: 'The requested worker budget cannot be enforced.',
|
package/dist/src/skills/run.js
CHANGED
|
@@ -165,6 +165,11 @@ export async function runSkill(opts) {
|
|
|
165
165
|
const audit = await import('../issues/audit-cli.js');
|
|
166
166
|
return audit.main(opts.args, runCwd, { env });
|
|
167
167
|
}
|
|
168
|
+
if (/agentic\/code\/(addons\/aiwg-utils|plugins\/utils)\/skills\/aiwg-pr\/SKILL\.md$/.test(entry.path.replaceAll('\\', '/'))
|
|
169
|
+
&& entry.script.entrypoint === 'scripts/deliver.mjs') {
|
|
170
|
+
const delivery = await import('../delivery/pr.js');
|
|
171
|
+
return delivery.main(opts.args, runCwd);
|
|
172
|
+
}
|
|
168
173
|
const fullArgs = [...invocation.prefixArgs, entrypointPath, ...opts.args];
|
|
169
174
|
return new Promise((resolve) => {
|
|
170
175
|
const child = spawn(invocation.command, fullArgs, {
|
|
@@ -13,6 +13,7 @@ import { promises as fs } from 'node:fs';
|
|
|
13
13
|
import * as path from 'node:path';
|
|
14
14
|
import { homedir } from 'node:os';
|
|
15
15
|
import { substituteEnvVars } from './shim.js';
|
|
16
|
+
import { PROMPT_DISCOVERY_GAPS } from './prompt-discovery-gaps.js';
|
|
16
17
|
import { tomlString } from '../../mcp/toml-string.mjs';
|
|
17
18
|
/** Codex-native event names (subset; extend when verified against codex-rs). */
|
|
18
19
|
const CODEX_EVENT_MAP = {
|
|
@@ -93,7 +94,8 @@ export async function translateForCodex(source, options) {
|
|
|
93
94
|
};
|
|
94
95
|
if (source.degradeOn?.includes('codex')) {
|
|
95
96
|
result.skipped = true;
|
|
96
|
-
result.skipReason =
|
|
97
|
+
result.skipReason = source.id === 'aiwg-prompt-discovery'
|
|
98
|
+
? PROMPT_DISCOVERY_GAPS['codex'] : 'degrade-on declared codex';
|
|
97
99
|
return result;
|
|
98
100
|
}
|
|
99
101
|
const configPath = path.join(process.env.CODEX_HOME || path.join(homedir(), '.codex'), 'config.toml');
|
|
@@ -11,6 +11,7 @@ import { promises as fs } from 'node:fs';
|
|
|
11
11
|
import * as path from 'node:path';
|
|
12
12
|
import { homedir } from 'node:os';
|
|
13
13
|
import { substituteEnvVars } from './shim.js';
|
|
14
|
+
import { PROMPT_DISCOVERY_GAPS } from './prompt-discovery-gaps.js';
|
|
14
15
|
const HERMES_EVENT_MAP = {
|
|
15
16
|
PreToolUse: 'pre_tool',
|
|
16
17
|
PostToolUse: 'post_tool',
|
|
@@ -63,7 +64,8 @@ export async function translateForHermes(source, options) {
|
|
|
63
64
|
};
|
|
64
65
|
if (source.degradeOn?.includes('hermes')) {
|
|
65
66
|
result.skipped = true;
|
|
66
|
-
result.skipReason =
|
|
67
|
+
result.skipReason = source.id === 'aiwg-prompt-discovery'
|
|
68
|
+
? PROMPT_DISCOVERY_GAPS['hermes'] : 'degrade-on declared hermes';
|
|
67
69
|
return result;
|
|
68
70
|
}
|
|
69
71
|
const events = source.events
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Explain prompt discovery gaps where an event mapping has no context contract.
|
|
2
|
+
export const PROMPT_DISCOVERY_GAPS = {
|
|
3
|
+
codex: 'Prompt discovery unavailable: the Codex bridge maps before_prompt but has no verified additionalContext injection contract.',
|
|
4
|
+
hermes: 'Prompt discovery unavailable: the Hermes bridge returns an exit code without forwarding prompt JSON or injecting additionalContext.',
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=prompt-discovery-gaps.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiwg/cli",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.1",
|
|
4
4
|
"description": "Lightweight AIWG CLI for signed, versioned web-backed resources.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"tools/ralph-external/lib/session-environment.mjs",
|
|
62
62
|
"tools/ralph-external/lib/worker-inputs.mjs",
|
|
63
63
|
"tools/ralph-external/lib/worker-final.mjs",
|
|
64
|
+
"tools/ralph-external/lib/worker-capture.mjs",
|
|
64
65
|
"tools/ralph-external/lib/worker-launch-cli.mjs",
|
|
65
66
|
"tools/ralph-external/lib/worker-isolation.mjs",
|
|
66
67
|
"tools/ralph-external/lib/worker-isolation-args.mjs",
|
|
@@ -69,6 +70,7 @@
|
|
|
69
70
|
"tools/ralph-external/lib/worker-isolation-status.mjs",
|
|
70
71
|
"tools/ralph-external/lib/worker-retry-evidence.mjs",
|
|
71
72
|
"tools/ralph-external/lib/worker-termination.mjs",
|
|
73
|
+
"tools/ralph-external/lib/worker-process-identity.mjs",
|
|
72
74
|
"tools/ralph-external/lib/worker-invocation-processes.mjs",
|
|
73
75
|
"tools/ralph-external/lib/worker-invocation-ancestry.mjs",
|
|
74
76
|
"tools/ralph-external/lib/worker-context.mjs",
|
|
@@ -141,7 +143,7 @@
|
|
|
141
143
|
"chalk": "^4.1.2",
|
|
142
144
|
"chokidar": "^4.0.3",
|
|
143
145
|
"commander": "^12.1.0",
|
|
144
|
-
"glob": "^
|
|
146
|
+
"glob": "^14.0.2",
|
|
145
147
|
"graceful-fs": "^4.2.11",
|
|
146
148
|
"js-yaml": "^4.3.0",
|
|
147
149
|
"listr2": "^8.2.5",
|
|
@@ -166,6 +166,21 @@ const { preserveDeploymentOutputs } = await importImpl(import.meta.url, 'provide
|
|
|
166
166
|
const { captureDeploymentOutputs, recordDeploymentOutputs, deploymentOutputRoots } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
|
|
167
167
|
|
|
168
168
|
export async function main(args = process.argv.slice(2), internal = {}) {
|
|
169
|
+
const cfg = parseArgs(args);
|
|
170
|
+
if (!cfg.help && !cfg.dryRun && !internal.preflightOnly && !internal.finalizeOnly
|
|
171
|
+
&& !globalThis[Symbol.for('aiwg.provider-preparation-hook.v1')]) {
|
|
172
|
+
const provider = await loadProvider(cfg.provider);
|
|
173
|
+
const shared = [...Object.values(provider.paths), provider.kernelSkillsPath].some(dir => dir && path.isAbsolute(dir))
|
|
174
|
+
|| provider.name === 'codex' || cfg.userScope || cfg.saveUser;
|
|
175
|
+
if (shared) {
|
|
176
|
+
const { withProviderDeploymentLock } = await importImpl(import.meta.url, 'providers/deployment-lock.js');
|
|
177
|
+
return withProviderDeploymentLock(() => mainUnlocked(args, internal));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return mainUnlocked(args, internal);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async function mainUnlocked(args, internal) {
|
|
169
184
|
const cfg = parseArgs(args);
|
|
170
185
|
if (cfg.help) { printHelp(); return 0; }
|
|
171
186
|
const modelCatalog = loadRuntimeModelCatalog(staticModelCatalog);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Shared provider contract utilities.
|
|
2
2
|
import { path } from './base-runtime.mjs';
|
|
3
|
+
import { importImpl } from '../../_resolve-impl.mjs';
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
// ============================================================================
|
|
@@ -110,7 +111,12 @@ export function injectBoundRules(content, source, opts = {}) {
|
|
|
110
111
|
* kernel passes leave rule delivery to the final source in the invocation. */
|
|
111
112
|
export async function withRuleDeployment(opts, provider, deploy) {
|
|
112
113
|
if (opts.kernelOnly && opts.deferRuleProjection && provider.name !== 'warp'
|
|
113
|
-
&& !globalThis[Symbol.for('aiwg.provider-preparation-hook.v1')])
|
|
114
|
+
&& !globalThis[Symbol.for('aiwg.provider-preparation-hook.v1')]) {
|
|
115
|
+
const shared = [...Object.values(provider.paths), provider.kernelSkillsPath].some(dir => dir && path.isAbsolute(dir));
|
|
116
|
+
if (!shared || opts.dryRun) return deploy(opts);
|
|
117
|
+
const { withProviderDeploymentLock } = await importImpl(import.meta.url, 'providers/deployment-lock.js');
|
|
118
|
+
return withProviderDeploymentLock(() => deploy(opts));
|
|
119
|
+
}
|
|
114
120
|
const { deployWithRuleDelivery } = await import('./rule-delivery.mjs');
|
|
115
121
|
return deployWithRuleDelivery(opts, provider, deploy);
|
|
116
122
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Shared provider inventory utilities.
|
|
2
|
-
import { fs, path } from './base-runtime.mjs';
|
|
2
|
+
import { extractFrameworkSlug, fs, path } from './base-runtime.mjs';
|
|
3
3
|
import { collectFrameworkArtifacts } from './base-framework-discovery.mjs';
|
|
4
4
|
import { getAddonAgentFiles, getAddonCommandFiles } from './base-addon-discovery.mjs';
|
|
5
5
|
import { getAddonRuleFiles } from './base-rule-index.mjs';
|
|
@@ -40,8 +40,9 @@ export function artifactStem(name) {
|
|
|
40
40
|
* deliberate and mirrors `computeAllKernelNames` for skills: `aiwg use sdlc`
|
|
41
41
|
* must not prune a marketing agent that a prior `aiwg use all` deployed and
|
|
42
42
|
* that is still a valid AIWG artifact. Only artifacts whose source no longer
|
|
43
|
-
* exists ANYWHERE in the tree (renamed/removed) fall out of this set
|
|
44
|
-
*
|
|
43
|
+
* exists ANYWHERE in the tree (renamed/removed) fall out of this set.
|
|
44
|
+
* Receipts with bundle identity use the owner inventory instead, so an
|
|
45
|
+
* unrelated bundle's same-named artifact cannot hide a retired artifact.
|
|
45
46
|
*
|
|
46
47
|
* Anchors to the AIWG root (resolved by walking up from `srcRoot` for the
|
|
47
48
|
* `agentic/code/frameworks` + `agentic/code/addons` pair, or `AIWG_ROOT`),
|
|
@@ -57,12 +58,25 @@ export function artifactStem(name) {
|
|
|
57
58
|
* if the AIWG framework/addon tree can't be located
|
|
58
59
|
*/
|
|
59
60
|
export function computeAllArtifactBasenames(srcRoot, type) {
|
|
61
|
+
return computeArtifactInventory(srcRoot, type)?.stems ?? null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Global and per-bundle stems from the same mode-independent discovery pass. */
|
|
65
|
+
export function computeArtifactInventory(srcRoot, type) {
|
|
60
66
|
const aiwgRoot = resolveAiwgRoot(srcRoot);
|
|
61
67
|
if (!aiwgRoot) return null;
|
|
62
68
|
|
|
63
69
|
const stems = new Set();
|
|
70
|
+
const ownerStems = new Map();
|
|
64
71
|
const add = (files) => {
|
|
65
|
-
for (const f of files)
|
|
72
|
+
for (const f of files) {
|
|
73
|
+
const stem = artifactStem(path.basename(f));
|
|
74
|
+
stems.add(stem);
|
|
75
|
+
const owner = extractFrameworkSlug(f);
|
|
76
|
+
if (!owner) continue;
|
|
77
|
+
if (!ownerStems.has(owner)) ownerStems.set(owner, new Set());
|
|
78
|
+
ownerStems.get(owner).add(stem);
|
|
79
|
+
}
|
|
66
80
|
};
|
|
67
81
|
|
|
68
82
|
const frameworkArtifacts = collectFrameworkArtifacts(aiwgRoot, 'all', {
|
|
@@ -87,7 +101,7 @@ export function computeAllArtifactBasenames(srcRoot, type) {
|
|
|
87
101
|
add(getAddonRuleFiles(aiwgRoot, [], { includeExplicit: true }));
|
|
88
102
|
}
|
|
89
103
|
|
|
90
|
-
return stems;
|
|
104
|
+
return { stems, ownerStems };
|
|
91
105
|
}
|
|
92
106
|
|
|
93
107
|
|
|
@@ -170,21 +184,23 @@ export function computeAllSkillNames(srcRoot) {
|
|
|
170
184
|
* 1. It has an allowed deployed-artifact extension (`.md` / `.mdc` by
|
|
171
185
|
* default; callers may include `.toml`), is not `RULES-INDEX.md`,
|
|
172
186
|
* and not the sidecar manifest.
|
|
173
|
-
* 2.
|
|
187
|
+
* 2. No recorded owner still ships its stem. Receipts without bundle
|
|
188
|
+
* identity fall back to the global `desiredStems` check.
|
|
174
189
|
* 3. It carries an AIWG ownership signal — either a `.aiwg-manifest.json`
|
|
175
190
|
* sidecar entry, or an in-file `aiwg:managed` marker.
|
|
191
|
+
* 4. Its bytes match the sidecar's hash. Markers alone never permit deletion.
|
|
176
192
|
*
|
|
177
|
-
* User-authored files (no ownership signal) and
|
|
178
|
-
*
|
|
193
|
+
* User-authored files (no ownership signal) and artifacts still shipped by a
|
|
194
|
+
* recorded owner are never touched. Pruned files also have their sidecar
|
|
179
195
|
* entry dropped so the manifest stays accurate.
|
|
180
196
|
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
197
|
+
* Shared-path rule: retain the file if ANY recorded owner still ships the
|
|
198
|
+
* stem, including when another recorded owner has retired it. Inventory is
|
|
199
|
+
* mode-independent so sibling-framework files remain protected.
|
|
184
200
|
*
|
|
185
201
|
* @param {string} destDir absolute path to the provider artifact dir
|
|
186
202
|
* @param {Set<string>|string[]} desiredStems stems that should remain
|
|
187
|
-
* @param {object} opts `{ dryRun, verbose }`
|
|
203
|
+
* @param {object} opts `{ dryRun, verbose, ownerStems?: Map<string, Set<string>> }`
|
|
188
204
|
* @returns {string[]} removed (or would-be-removed) file paths
|
|
189
205
|
*/
|
|
190
206
|
export function pruneStaleAiwgFiles(destDir, desiredStems, opts = {}) {
|
|
@@ -224,7 +240,13 @@ export function pruneStaleAiwgFiles(destDir, desiredStems, opts = {}) {
|
|
|
224
240
|
const lower = name.toLowerCase();
|
|
225
241
|
if (!artifactExtensions.some(extension => lower.endsWith(extension))) continue;
|
|
226
242
|
|
|
227
|
-
|
|
243
|
+
const stem = artifactStem(name);
|
|
244
|
+
const record = managed[name];
|
|
245
|
+
const owners = [record?.frameworkSlug, ...(Array.isArray(record?.owners) ? record.owners : [])]
|
|
246
|
+
.filter(owner => typeof owner === 'string' && owner.length > 0);
|
|
247
|
+
// Wrappers belong to the skill inventory below, not the command inventory.
|
|
248
|
+
const ownerAware = opts.ownerStems instanceof Map && owners.length > 0 && record?.kind !== 'skill-command';
|
|
249
|
+
if (ownerAware ? owners.some(owner => opts.ownerStems.get(owner)?.has(stem)) : desired.has(stem)) continue;
|
|
228
250
|
|
|
229
251
|
// Skill-command wrappers are named after skills, not command sources, so
|
|
230
252
|
// they are absent from the command desired set by construction — pruning
|
|
@@ -5,7 +5,7 @@ export { loadModelConfig, loadRuntimeModelCatalog, parseSkillPlatforms, skillMat
|
|
|
5
5
|
export { parseFrontmatter, stringifyFrontmatter, toKebabCase, stripJsonComments, inferAgentCategory, parseTools, filterCommandsAgainstSkills } from './base-frontmatter.mjs';
|
|
6
6
|
export { deployFiles, deploySoulCompanions } from './base-flat-artifacts.mjs';
|
|
7
7
|
export { isKernelSkill, deploySkillsWithKernelRouting, computeAllKernelNames, pruneStaleAiwgSkills } from './base-kernel-skills.mjs';
|
|
8
|
-
export { artifactStem, computeAllArtifactBasenames, resolveAiwgRoot, computeAllSkillNames, pruneStaleAiwgFiles } from './base-inventory.mjs';
|
|
8
|
+
export { artifactStem, computeAllArtifactBasenames, computeArtifactInventory, resolveAiwgRoot, computeAllSkillNames, pruneStaleAiwgFiles } from './base-inventory.mjs';
|
|
9
9
|
export { deploySkillDir, initializeFrameworkWorkspace } from './base-skill-copy.mjs';
|
|
10
10
|
export { buildRemotesTopologyBlock, interpolateContextTokens, createManagedMdFromTemplate, createAgentsMdFromTemplate } from './base-context.mjs';
|
|
11
11
|
export { shouldDeployAgent, matchesGlob, filterAgentFiles, normalizeDeploymentMode, discoverFrameworks, getFrameworksForMode, collectFrameworkArtifacts } from './base-framework-discovery.mjs';
|
|
@@ -6,26 +6,50 @@ import { importImpl, resolveImpl } from '../../_resolve-impl.mjs';
|
|
|
6
6
|
|
|
7
7
|
const quote = value => `'${value.replace(/'/g, `'"'"'`)}'`;
|
|
8
8
|
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
// on the framework default config (absent from the slim CLI package).
|
|
13
|
-
function declaresLocalOnlyPaths(targetDir) {
|
|
9
|
+
// Avoid the full model-config load for ordinary deploys, including slim CLI installs
|
|
10
|
+
// without framework defaults. Declared guards use the same validated loader as paths.
|
|
11
|
+
function declaresGuardPolicy(targetDir, provider) {
|
|
14
12
|
const userDir = process.env.AIWG_CONFIG || path.join(os.homedir(), '.config/aiwg');
|
|
15
13
|
return [path.join(targetDir, 'models.json'), path.join(userDir, 'models.json'), path.join(targetDir, '.aiwg/aiwg.config')]
|
|
16
|
-
.some(file => { try {
|
|
14
|
+
.some(file => { try {
|
|
15
|
+
const source = fs.readFileSync(file, 'utf8');
|
|
16
|
+
if (source.includes('localOnlyPaths')) return true;
|
|
17
|
+
if (provider !== 'claude' || !source.includes('denyConductorWorkerExecution')) return false;
|
|
18
|
+
const value = JSON.parse(source)?.defaults?.workerSelection?.guards?.denyConductorWorkerExecution;
|
|
19
|
+
return value !== undefined && value !== false;
|
|
20
|
+
} catch (error) { return error instanceof SyntaxError; } });
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Turn off a previously deployed opt-in check without removing retained read rules.
|
|
24
|
+
function disableExecutionCheck(targetDir, provider, opts) {
|
|
25
|
+
if (provider !== 'claude' || opts.dryRun) return;
|
|
26
|
+
const root = path.resolve(targetDir), hookPath = path.join(root, '.claude/hooks/aiwg-local-only.mjs');
|
|
27
|
+
if (!fs.existsSync(hookPath)) return;
|
|
28
|
+
const source = fs.readFileSync(hookPath, 'utf8');
|
|
29
|
+
const start = source.lastIndexOf(`\nrunConductorDataHook(${JSON.stringify(root)}, `);
|
|
30
|
+
if (start >= 0 && source.endsWith(', true);\n')) {
|
|
31
|
+
fs.writeFileSync(hookPath, source.slice(0, -', true);\n'.length) + ', false);\n');
|
|
32
|
+
}
|
|
17
33
|
}
|
|
18
34
|
|
|
19
35
|
export async function deployConductorDataGuard(targetDir, provider, opts = {}) {
|
|
20
|
-
if (!
|
|
36
|
+
if (!declaresGuardPolicy(targetDir, provider)) {
|
|
37
|
+
disableExecutionCheck(targetDir, provider, opts);
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
21
40
|
// Always resolve policy through the existing loader, including inherited restrictions.
|
|
22
|
-
const { ConfigLoader } = await importImpl(import.meta.url, 'models/config-loader.js');
|
|
23
41
|
const { readAiwgConfig } = await importImpl(import.meta.url, 'config/aiwg-config.js');
|
|
42
|
+
const { ConfigLoader } = await importImpl(import.meta.url, 'models/config-loader.js');
|
|
24
43
|
const guard = await importImpl(import.meta.url, 'models/conductor-data-policy.mjs');
|
|
25
44
|
const config = await readAiwgConfig(targetDir);
|
|
26
45
|
const models = await new ConfigLoader(targetDir).load(config?.parallelism);
|
|
46
|
+
const executionGuard = provider === 'claude' && models.defaults.workerSelection?.guards?.denyConductorWorkerExecution === true;
|
|
27
47
|
const paths = guard.collectLocalOnlyPaths(models.defaults.workerSelection, config?.parallelism);
|
|
28
|
-
if (!paths.length
|
|
48
|
+
if (!paths.length && !executionGuard) {
|
|
49
|
+
disableExecutionCheck(targetDir, provider, opts);
|
|
50
|
+
return paths;
|
|
51
|
+
}
|
|
52
|
+
if (opts.dryRun) return paths;
|
|
29
53
|
const root = path.resolve(targetDir);
|
|
30
54
|
if (provider === 'claude') {
|
|
31
55
|
const settingsPath = path.join(root, '.claude/settings.json');
|
|
@@ -33,7 +57,7 @@ export async function deployConductorDataGuard(targetDir, provider, opts = {}) {
|
|
|
33
57
|
const hookPath = path.join(root, '.claude/hooks/aiwg-local-only.mjs');
|
|
34
58
|
const hookSource = fs.readFileSync(resolveImpl(import.meta.url, 'models/conductor-data-policy.mjs'), 'utf8');
|
|
35
59
|
fs.mkdirSync(path.dirname(hookPath), { recursive: true });
|
|
36
|
-
fs.writeFileSync(hookPath, `${hookSource}\nrunConductorDataHook(${JSON.stringify(root)}, ${JSON.stringify(paths)});\n`);
|
|
60
|
+
fs.writeFileSync(hookPath, `${hookSource}\nrunConductorDataHook(${JSON.stringify(root)}, ${JSON.stringify(paths)}, ${JSON.stringify(executionGuard)});\n`);
|
|
37
61
|
settings.permissions ??= {};
|
|
38
62
|
settings.permissions.deny = [...new Set([...(settings.permissions.deny ?? []), ...paths.flatMap(file => [
|
|
39
63
|
`Read(//${path.join(root, file).slice(1)})`, `Read(//${path.join(root, file).slice(1)}/**)`,
|
|
@@ -56,6 +80,6 @@ export async function deployConductorDataGuard(targetDir, provider, opts = {}) {
|
|
|
56
80
|
fs.mkdirSync(path.dirname(rulesPath), { recursive: true });
|
|
57
81
|
fs.writeFileSync(rulesPath, lines.join('\n') + '\n');
|
|
58
82
|
}
|
|
59
|
-
console.log(`
|
|
83
|
+
console.log(`Conductor guard (${provider}): ${paths.join(', ')}${executionGuard ? '; worker execution checks enabled' : ''}; shell coverage is limited.`);
|
|
60
84
|
return paths;
|
|
61
85
|
}
|