@aiwg/cli 2026.10.19 → 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/README.md +1 -0
- 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/bundle-declaration.js +55 -0
- package/dist/src/cli/handlers/bundle-deployment-mode.js +71 -0
- package/dist/src/cli/handlers/bundle-hash-prune.js +37 -0
- package/dist/src/cli/handlers/bundle-reconciliation.js +140 -0
- 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/refresh-bundles.js +35 -0
- package/dist/src/cli/handlers/refresh-rule-inventory.js +10 -0
- package/dist/src/cli/handlers/refresh.js +15 -52
- package/dist/src/cli/handlers/remove-bundled.js +7 -4
- package/dist/src/cli/handlers/remove-flue-modules.js +19 -0
- package/dist/src/cli/handlers/remove-historical-bundle.js +18 -0
- package/dist/src/cli/handlers/remove.js +8 -0
- package/dist/src/cli/handlers/script-runner.js +12 -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/subcommands-list-format.js +4 -4
- package/dist/src/cli/handlers/update.js +18 -8
- package/dist/src/cli/handlers/use-additive-bundles.js +87 -0
- package/dist/src/cli/handlers/use-bundle-counts.js +5 -1
- package/dist/src/cli/handlers/use-owned-counts.js +75 -0
- package/dist/src/cli/handlers/use-provider-results.js +17 -0
- package/dist/src/cli/handlers/use.js +53 -114
- package/dist/src/cli/router.js +12 -2
- package/dist/src/cli/services/deployment-verification.js +2 -1
- package/dist/src/cli/user-scope-mirror.js +3 -1
- package/dist/src/config/aiwg-config.js +15 -6
- package/dist/src/config/cli.js +1 -0
- package/dist/src/config/delivery-validation.js +21 -0
- package/dist/src/config/framework-aliases.js +14 -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/installed-selection.js +9 -1
- package/dist/src/config/installed-validation.js +35 -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/extensions/project-local-doctor.js +1 -1
- package/dist/src/extensions/project-local-remove.js +3 -3
- 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/cli.mjs +12 -7
- package/dist/src/mcp/helpers.mjs +5 -1
- package/dist/src/mcp/http-options.mjs +101 -0
- package/dist/src/mcp/http-tools.mjs +51 -0
- package/dist/src/mcp/http-transport.mjs +201 -0
- package/dist/src/mcp/server.mjs +9 -7
- package/dist/src/mcp/tool-context.mjs +25 -0
- package/dist/src/mcp/tools/orchestration.mjs +2 -1
- 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 +127 -19
- package/dist/src/providers/deployment-preservation.d.mts +6 -0
- package/dist/src/providers/deployment-preservation.mjs +113 -0
- package/dist/src/providers/deployment-removal.js +4 -2
- package/dist/src/providers/flue-package-mode.js +19 -0
- package/dist/src/providers/provider-definitions.js +4 -0
- package/dist/src/providers/skill-ownership.mjs +1 -0
- package/dist/src/research/reference-match.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 +5 -2
- package/schemas/models/model-config-compatibility.v1.schema.json +4 -0
- package/tools/agents/deploy-agents.mjs +21 -1
- package/tools/agents/deploy-options.mjs +2 -0
- package/tools/agents/providers/base-contract.mjs +7 -1
- package/tools/agents/providers/base-inventory.mjs +41 -14
- package/tools/agents/providers/base-kernel-skills.mjs +9 -5
- package/tools/agents/providers/base-migrations.mjs +1 -0
- package/tools/agents/providers/base-skill-copy.mjs +9 -1
- package/tools/agents/providers/base.mjs +1 -1
- package/tools/agents/providers/claude.mjs +2 -1
- package/tools/agents/providers/codex.mjs +5 -1
- package/tools/agents/providers/conductor-data-guard.mjs +35 -11
- package/tools/agents/providers/flue-bundles.mjs +42 -0
- package/tools/agents/providers/flue-cloudflare.mjs +20 -0
- package/tools/agents/providers/flue-project.mjs +45 -6
- package/tools/agents/providers/flue-skill-copy.mjs +25 -0
- package/tools/agents/providers/flue-skills.mjs +45 -0
- package/tools/agents/providers/flue-specialists.mjs +36 -18
- package/tools/agents/providers/flue-validation.mjs +14 -0
- package/tools/agents/providers/flue.mjs +12 -8
- package/tools/agents/providers/hermes-skill-lifecycle.mjs +1 -0
- 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 +18 -1
- package/tools/agents/providers/rule-deployment-commit.mjs +24 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +4 -0
- package/tools/agents/providers/skill-copy-prune.mjs +49 -0
- package/tools/agents/providers/stale-artifact-prune.mjs +10 -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/tools/skills/codex-skill-metadata.mjs +22 -0
- package/tools/skills/deploy-skills-codex.mjs +8 -7
- package/vscode-extension/schemas/aiwg.config.v1.json +59 -19
|
@@ -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 => {
|
|
@@ -138,6 +232,7 @@ export function recordDeploymentOutputs(before, roots, opts = {}) {
|
|
|
138
232
|
const receiptRoot = (file, receipt) => projectRoot && file === path.join(projectRoot, '.aiwg', SIDECAR) && receipt.scope === 'project'
|
|
139
233
|
? projectRoot : path.dirname(file);
|
|
140
234
|
const declared = new Map();
|
|
235
|
+
const preserved = new Set();
|
|
141
236
|
for (const [file, bytes] of after) {
|
|
142
237
|
if (path.basename(file) !== SIDECAR) continue;
|
|
143
238
|
const receipt = parse(bytes), previous = parse(before.get(file));
|
|
@@ -147,7 +242,7 @@ export function recordDeploymentOutputs(before, roots, opts = {}) {
|
|
|
147
242
|
const base = receiptRoot(file, receipt);
|
|
148
243
|
const target = path.resolve(base, name);
|
|
149
244
|
if (!target.startsWith(`${base}${path.sep}`) || receipt.managed?.[name]) continue;
|
|
150
|
-
if (!
|
|
245
|
+
if (!sameOutput(after.get(target), before.get(target))) continue;
|
|
151
246
|
receipt.managed ||= {};
|
|
152
247
|
receipt.managed[name] = entry;
|
|
153
248
|
manifests.set(file, receipt);
|
|
@@ -156,18 +251,31 @@ export function recordDeploymentOutputs(before, roots, opts = {}) {
|
|
|
156
251
|
const base = receiptRoot(file, receipt);
|
|
157
252
|
const target = path.resolve(base, name);
|
|
158
253
|
if (!target.startsWith(`${base}${path.sep}`) || !after.has(target)) continue;
|
|
254
|
+
const prior = previous.managed?.[name];
|
|
255
|
+
// A receipt rewrite is not evidence of a payload write. Preservation can
|
|
256
|
+
// also restore bytes after a writer/binder marked the file as written.
|
|
257
|
+
// Never bless those edited bytes, even with an explicit write hint.
|
|
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))) {
|
|
260
|
+
if (prior) receipt.managed[name] = prior;
|
|
261
|
+
else delete receipt.managed[name];
|
|
262
|
+
preserved.add(target);
|
|
263
|
+
manifests.set(file, receipt);
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
159
266
|
if (stable(previous.managed?.[name]) !== stable(entry)) declared.set(target, { file, name, entry, receipt });
|
|
160
267
|
}
|
|
161
268
|
}
|
|
162
269
|
for (const [file, bytes] of after) {
|
|
163
270
|
if (path.basename(file) === SIDECAR || /(?:^|[/\\])aiwg\.config$/.test(file)
|
|
164
271
|
|| /(?:\.bak\.|\.aiwg-backup-)/.test(path.basename(file))) continue;
|
|
165
|
-
|
|
272
|
+
if (preserved.has(file)) continue;
|
|
273
|
+
const changed = !sameOutput(before.get(file), bytes);
|
|
166
274
|
const declaration = declared.get(file);
|
|
167
275
|
if (opts.onlyDeclared && !declaration) continue;
|
|
168
276
|
if (!changed && !declaration && !opts.writtenFiles?.includes(file)) continue;
|
|
169
277
|
// Existing integrity receipts that disagree with bytes never bless operator edits.
|
|
170
|
-
if (declaration?.entry.hash && declaration.entry.hash !==
|
|
278
|
+
if (declaration?.entry.hash && declaration.entry.hash !== digestOf(bytes)) continue;
|
|
171
279
|
let skillRoot = path.dirname(file);
|
|
172
280
|
while (skillRoot !== path.dirname(skillRoot)) {
|
|
173
281
|
const parentReceipt = parse(after.get(path.join(skillRoot, SIDECAR)));
|
|
@@ -175,7 +283,7 @@ export function recordDeploymentOutputs(before, roots, opts = {}) {
|
|
|
175
283
|
skillRoot = path.dirname(skillRoot);
|
|
176
284
|
}
|
|
177
285
|
const skillReceipt = parse(after.get(path.join(skillRoot, SIDECAR)));
|
|
178
|
-
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));
|
|
179
287
|
const dir = projectScoped ? path.join(projectRoot, '.aiwg') : declaration ? path.dirname(declaration.file) : skillReceipt.managed?.['SKILL.md'] ? skillRoot : path.dirname(file);
|
|
180
288
|
const name = declaration?.name || portable(path.relative(projectScoped ? projectRoot : dir, file));
|
|
181
289
|
const existing = manifests.get(path.join(dir, SIDECAR)) || parse(after.get(path.join(dir, SIDECAR)));
|
|
@@ -183,10 +291,10 @@ export function recordDeploymentOutputs(before, roots, opts = {}) {
|
|
|
183
291
|
const current = existing.managed?.[name] || {};
|
|
184
292
|
// A redeploy may preserve operator additions around generated context.
|
|
185
293
|
// Keep the old digest so removal cannot restore a stale preimage over them.
|
|
186
|
-
if (previous?.filePreimage && before.has(file) && previous.hash !==
|
|
294
|
+
if (previous?.filePreimage && before.has(file) && previous.hash !== digestOf(before.get(file))) continue;
|
|
187
295
|
const identity = current.sourcePath || `${declaration?.receipt.skillSource}/SKILL.md`;
|
|
188
296
|
const logicalSource = opts.logicalInputPath?.(identity) || identity;
|
|
189
|
-
const sourceOwner = (declaration || current.hash ===
|
|
297
|
+
const sourceOwner = (declaration || current.hash === digestOf(bytes)) && (current.frameworkSlug || bundleOwner(logicalSource))
|
|
190
298
|
|| skillReceipt.managed?.['SKILL.md']?.frameworkSlug;
|
|
191
299
|
const generatedIndex = /^RULES-(?:INDEX|ONDEMAND)\.(?:md|mdc)$/.test(path.basename(file));
|
|
192
300
|
const kind = generatedIndex ? 'rule-index' : current.kind || artifactKind(file);
|
|
@@ -197,12 +305,12 @@ export function recordDeploymentOutputs(before, roots, opts = {}) {
|
|
|
197
305
|
}
|
|
198
306
|
const receipt = manifest(dir);
|
|
199
307
|
if (projectScoped) receipt.scope = 'project';
|
|
200
|
-
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);
|
|
201
309
|
// Flue's composed context and generated database/ignore outputs support
|
|
202
310
|
// exact restoration. Never infer a preimage for another provider's files.
|
|
203
311
|
if (opts.provider === 'flue' && (projectScoped || /[/\\]db\.ts$/.test(file))) {
|
|
204
312
|
record.filePreimage = previous?.filePreimage || { present: before.has(file),
|
|
205
|
-
...(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)) } : {}) };
|
|
206
314
|
}
|
|
207
315
|
// Structural rule indexes are generated outputs; their assembly scratch
|
|
208
316
|
// directory is not a durable source identity.
|
|
@@ -211,14 +319,14 @@ export function recordDeploymentOutputs(before, roots, opts = {}) {
|
|
|
211
319
|
record.kind = 'rule-index';
|
|
212
320
|
}
|
|
213
321
|
// Settings have key/value receipts in the same entry, never a separate store.
|
|
214
|
-
if (
|
|
322
|
+
if (SETTINGS_FILE.test(path.basename(file))) {
|
|
215
323
|
record.kind = 'settings';
|
|
216
324
|
record.settingsPreimage = previous?.settingsPreimage || (!previous?.settings ? {
|
|
217
|
-
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)) } : {})
|
|
218
326
|
} : undefined);
|
|
219
327
|
const claimUnchanged = opts.claimUnchangedSettings !== false
|
|
220
328
|
&& !/(?:agentic\/code|\.aiwg)\/(?:addons|extensions)\//.test((opts.logicalInputPath?.(opts.srcRoot) || opts.srcRoot)?.replaceAll('\\', '/') || '');
|
|
221
|
-
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);
|
|
222
330
|
const settingsOwners = Object.values(record.settings).flatMap(entry => entry.owners);
|
|
223
331
|
record.owners = [...new Set(settingsOwners.length ? settingsOwners
|
|
224
332
|
: [...(previous?.owners || []), ...(changed ? [selectedOwner] : [])])].sort();
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AiwgConfig } from '../config/aiwg-config.js';
|
|
2
|
+
import type { DeploymentOutputSnapshot } from './deployment-ownership.mjs';
|
|
3
|
+
export function providerCopyMode(project: string, provider: string, owner?: string, config?: AiwgConfig, indexOwner?: string): boolean;
|
|
4
|
+
export function automaticRemovalAllowed(project: string, provider: string, file: string, config?: AiwgConfig): boolean;
|
|
5
|
+
export function preserveDeploymentOutputs(before: DeploymentOutputSnapshot, roots: string[], opts?: Record<string, unknown>): void;
|
|
6
|
+
export function deploymentEditWarnings(project: string, provider: string): string[];
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Preserve copy-mode deletions and edited receipt-owned payloads across provider passes.
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
5
|
+
import { frameworkRegistryId } from '../config/framework-aliases.js';
|
|
6
|
+
const hash = bytes => `sha256:${createHash('sha256').update(bytes).digest('hex')}`;
|
|
7
|
+
const parse = bytes => { try { return JSON.parse(bytes?.toString() || '{}'); } catch { return {}; } };
|
|
8
|
+
const sidecar = '.aiwg-manifest.json';
|
|
9
|
+
const context = new Set(['AGENTS.md', 'AIWG.md', 'WORKSPACE.md', 'CLAUDE.md', 'WARP.md', '.hermes.md', 'copilot-instructions.md']);
|
|
10
|
+
export function providerCopyMode(project, provider, owner, config, indexOwner) {
|
|
11
|
+
const history = parse(fs.existsSync(path.join(project, '.aiwg', sidecar)) ? fs.readFileSync(path.join(project, '.aiwg', sidecar)) : null).bundleDeployments?.[provider] || {};
|
|
12
|
+
if (!config) {
|
|
13
|
+
try { config = JSON.parse(fs.readFileSync(path.join(project, '.aiwg/aiwg.config'), 'utf8')); } catch { config = {}; }
|
|
14
|
+
}
|
|
15
|
+
const modes = new Map(Object.entries(history).map(([id, mode]) => [frameworkRegistryId(id), mode.copy === true || mode.package === true]));
|
|
16
|
+
for (const [id, entry] of Object.entries(config.installed || {})) {
|
|
17
|
+
if (entry.deployedTo?.[provider]) modes.set(frameworkRegistryId(id), entry.deployedTo[provider].copy === true || entry.deployedTo[provider].package === true);
|
|
18
|
+
}
|
|
19
|
+
if (indexOwner) modes.set(frameworkRegistryId(indexOwner), false);
|
|
20
|
+
const inherited = new Set();
|
|
21
|
+
for (const [id, mode] of Object.entries(history)) if (modes.get(frameworkRegistryId(id))) {
|
|
22
|
+
for (const produced of mode.produces || []) inherited.add(frameworkRegistryId(produced));
|
|
23
|
+
}
|
|
24
|
+
return owner ? modes.get(frameworkRegistryId(owner)) === true || inherited.has(frameworkRegistryId(owner)) || inherited.has('*')
|
|
25
|
+
: [...modes.values()].some(Boolean) || inherited.size > 0;
|
|
26
|
+
}
|
|
27
|
+
export function automaticRemovalAllowed(project, provider, file, config) {
|
|
28
|
+
const receipt = parse(fs.existsSync(path.join(path.dirname(file), sidecar)) ? fs.readFileSync(path.join(path.dirname(file), sidecar)) : null);
|
|
29
|
+
const record = receipt.managed?.[path.basename(file)];
|
|
30
|
+
const owners = record?.owners || (record?.frameworkSlug ? [record.frameworkSlug] : []);
|
|
31
|
+
const copy = owners.length ? owners.some(owner => providerCopyMode(project, provider, owner, config)) : providerCopyMode(project, provider, undefined, config);
|
|
32
|
+
const modified = !record?.hash || record.hash !== hash(fs.readFileSync(file));
|
|
33
|
+
if (!copy && !modified) return true;
|
|
34
|
+
console.warn(`${file}: kept (${copy ? 'copy mode' : record?.hash ? 'operator-edited' : 'unverifiable ownership'});${copy ? ' use aiwg remove <bundle> to delete' : ' managed hash differs'}`);
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Called against a staging snapshot before ownership is refreshed or output is promoted. */
|
|
39
|
+
export function preserveDeploymentOutputs(before, roots, opts = {}) {
|
|
40
|
+
const writeReceipt = (file, bytes) => file === path.join(opts.target, '.aiwg', sidecar) && opts.writeReceipt
|
|
41
|
+
? opts.writeReceipt(file, bytes) : fs.writeFileSync(file, bytes);
|
|
42
|
+
const claims = new Map();
|
|
43
|
+
const receipts = new Map();
|
|
44
|
+
for (const [file, bytes] of before) {
|
|
45
|
+
if (path.basename(file) !== sidecar) continue;
|
|
46
|
+
const receipt = parse(bytes);
|
|
47
|
+
receipts.set(file, receipt);
|
|
48
|
+
const base = receipt.scope === 'project' && file === path.join(opts.target, '.aiwg', sidecar) ? opts.target : path.dirname(file);
|
|
49
|
+
for (const [name, record] of Object.entries(receipt.managed || {})) {
|
|
50
|
+
const target = path.resolve(base, name);
|
|
51
|
+
if (target.startsWith(`${base}${path.sep}`)) claims.set(target, { record, file, name });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const restored = [];
|
|
55
|
+
for (const [file, bytes] of before) {
|
|
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;
|
|
60
|
+
const exists = fs.existsSync(file);
|
|
61
|
+
if (!exists && opts.replacedSkillCopies?.has(file)) continue;
|
|
62
|
+
const claim = claims.get(file);
|
|
63
|
+
const edited = claim?.record.hash && claim.record.hash !== hash(bytes) && !context.has(path.basename(file)) && claim.record.kind !== 'settings';
|
|
64
|
+
const owners = claim?.record.owners || (claim?.record.frameworkSlug ? [claim.record.frameworkSlug] : []);
|
|
65
|
+
const currentOwner = (opts.srcRoot || '').replaceAll('\\', '/').match(/(?:agentic\/code|\.aiwg)\/(?:frameworks|addons|extensions)\/([^/]+)/)?.[1] || frameworkRegistryId(opts.mode || '');
|
|
66
|
+
const copy = (opts.copyMode ?? opts.copyStandardSkills) || owners.some(owner => providerCopyMode(opts.target, opts.provider, owner, opts.config, currentOwner));
|
|
67
|
+
if (!(edited || !exists && copy) || exists && fs.readFileSync(file).equals(bytes)) continue;
|
|
68
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
69
|
+
fs.writeFileSync(file, bytes);
|
|
70
|
+
if (edited) console.warn(`${opts.logicalOutputPath?.(file) || file}: kept (operator-edited)`);
|
|
71
|
+
restored.push(claim);
|
|
72
|
+
}
|
|
73
|
+
// Keep the old digest for protected payloads: a later run must still detect edits.
|
|
74
|
+
for (const claim of restored.filter(Boolean)) {
|
|
75
|
+
const { managed: _managed, ...metadata } = receipts.get(claim.file) || {};
|
|
76
|
+
const receipt = { ...metadata, ...parse(fs.existsSync(claim.file) ? fs.readFileSync(claim.file) : null) };
|
|
77
|
+
receipt.managed ??= {};
|
|
78
|
+
receipt.managed[claim.name] = claim.record;
|
|
79
|
+
writeReceipt(claim.file, `${JSON.stringify(receipt, null, 2)}\n`);
|
|
80
|
+
}
|
|
81
|
+
// Provider writers must not discard declaration history when rewriting a receipt.
|
|
82
|
+
for (const [file, previous] of receipts) {
|
|
83
|
+
if (!previous.bundleDeployments) continue;
|
|
84
|
+
const current = parse(fs.existsSync(file) ? fs.readFileSync(file) : null);
|
|
85
|
+
current.bundleDeployments = previous.bundleDeployments;
|
|
86
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
87
|
+
if (JSON.stringify(current.bundleDeployments) !== JSON.stringify(parse(fs.existsSync(file) ? fs.readFileSync(file) : null).bundleDeployments)) writeReceipt(file, `${JSON.stringify(current, null, 2)}\n`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Successful captured passes still report edits whose old receipt digests were retained. */
|
|
92
|
+
export function deploymentEditWarnings(project, provider) {
|
|
93
|
+
const warnings = new Set();
|
|
94
|
+
const visit = dir => {
|
|
95
|
+
const stat = fs.lstatSync(dir, { throwIfNoEntry: false });
|
|
96
|
+
if (!stat?.isDirectory() || stat.isSymbolicLink()) return;
|
|
97
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
98
|
+
const file = path.join(dir, entry.name);
|
|
99
|
+
if (entry.isDirectory()) { visit(file); continue; }
|
|
100
|
+
if (entry.name !== sidecar || !entry.isFile()) continue;
|
|
101
|
+
const receipt = parse(fs.readFileSync(file));
|
|
102
|
+
for (const [name, record] of Object.entries(receipt.managed || {})) {
|
|
103
|
+
const target = path.resolve(dir, name);
|
|
104
|
+
if (!target.startsWith(`${dir}${path.sep}`) || context.has(path.basename(target)) || record.kind === 'settings') continue;
|
|
105
|
+
const state = fs.lstatSync(target, { throwIfNoEntry: false });
|
|
106
|
+
if (state?.isFile() && record.hash && record.hash !== hash(fs.readFileSync(target))) warnings.add(`${target}: kept (operator-edited)`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
visit(path.join(project, `.${provider}`));
|
|
111
|
+
visit(path.join(project, '.agents'));
|
|
112
|
+
return [...warnings];
|
|
113
|
+
}
|
|
@@ -27,13 +27,15 @@ function symlinkBetween(root, file) {
|
|
|
27
27
|
}
|
|
28
28
|
return false;
|
|
29
29
|
}
|
|
30
|
-
export function planDeploymentRemoval(project, provider, owner, includeProject = true) {
|
|
30
|
+
export function planDeploymentRemoval(project, provider, owner, includeProject = true, preserveRoots = []) {
|
|
31
31
|
const paths = Object.values(getProviderArtifactPathStrings(provider) || {}).filter(Boolean);
|
|
32
32
|
const roots = [...new Set([...paths.map(dir => path.isAbsolute(dir) ? dir : path.join(project, dir.split(/[\\/]/)[0])),
|
|
33
33
|
...deployedSkillRoots(project, provider), path.join(project, `.${provider}`), ...(includeProject ? [path.join(project, '.aiwg/frameworks')] : [])])].map(root => path.resolve(root));
|
|
34
34
|
const files = new Set();
|
|
35
35
|
const decisions = [], writes = [], remaining = [], recorded = [];
|
|
36
36
|
const visit = (file) => {
|
|
37
|
+
if (preserveRoots.some(root => file === root || inside(root, file)))
|
|
38
|
+
return;
|
|
37
39
|
let stat;
|
|
38
40
|
try {
|
|
39
41
|
stat = fs.lstatSync(file);
|
|
@@ -192,7 +194,7 @@ export function planDeploymentRemoval(project, provider, owner, includeProject =
|
|
|
192
194
|
delete receipt.managed[name];
|
|
193
195
|
}
|
|
194
196
|
if (changed) {
|
|
195
|
-
const empty = Object.keys(receipt.managed).length === 0;
|
|
197
|
+
const empty = Object.keys(receipt.managed).length === 0 && !receipt.bundleDeployments;
|
|
196
198
|
writes.push({ path: file, before, after: empty ? null : Buffer.from(`${JSON.stringify(receipt, null, 2)}\n`) });
|
|
197
199
|
if (empty)
|
|
198
200
|
decisions.push({ path: file, action: 'remove', reason: 'ownership metadata released' });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Recognize a package-mode deployment without requiring copied skill directories.
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { readAiwgConfig } from '../config/aiwg-config.js';
|
|
5
|
+
export async function hasFluePackageDeployment(project) {
|
|
6
|
+
const config = await readAiwgConfig(project);
|
|
7
|
+
if (!Object.values(config?.installed ?? {}).some(entry => entry.deployedTo.flue?.package))
|
|
8
|
+
return false;
|
|
9
|
+
try {
|
|
10
|
+
const source = await readFile(path.join(project, 'src/aiwg/skills.ts'), 'utf8');
|
|
11
|
+
return /from ['"]@aiwg\/flue\/skills\/[^'"\n]+\/SKILL\.md['"]/.test(source);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (error.code === 'ENOENT')
|
|
15
|
+
return false;
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=flue-package-mode.js.map
|
|
@@ -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);
|
|
@@ -42,6 +42,7 @@ export function canDeploySkill(receipt, skillSource, { force = false, logicalInp
|
|
|
42
42
|
|
|
43
43
|
/** Remove unchanged recorded files, allowing symlinks above (but never inside) the skill root. */
|
|
44
44
|
export function pruneRecordedSkillFiles(skillDir, managed, desired, opts = {}) {
|
|
45
|
+
if (opts.copyMode ?? opts.copyStandardSkills) return;
|
|
45
46
|
const root = path.resolve(skillDir);
|
|
46
47
|
for (const [relative, record] of Object.entries(managed || {})) {
|
|
47
48
|
const target = path.resolve(skillDir, relative);
|
|
@@ -54,6 +54,10 @@ export function needsTitleDisambiguation(reference, candidates, incomplete) {
|
|
|
54
54
|
// A 0.25 window preserves caution for short titles sharing three of four tokens
|
|
55
55
|
// (~0.24 behind with author corroboration), excluding weaker hits like 1.000 vs 0.711.
|
|
56
56
|
const competing = candidates.slice(1).some(candidate => classifyCandidates([candidate]) !== 'unresolved' &&
|
|
57
|
+
// An exact winner year excludes only known gaps beyond one-year preprint/venue lag
|
|
58
|
+
// (e.g. reprints); adjacent or missing runner-up years still compete, failing safe.
|
|
59
|
+
!(reference.year !== undefined && candidates[0].score_parts.year === 1 && candidate.score_parts.year === 0 &&
|
|
60
|
+
candidate.paper.year > 0 && Math.abs(candidate.paper.year - reference.year) > 1) &&
|
|
57
61
|
candidates[0].score - candidate.score <= 0.25 + 1e-12);
|
|
58
62
|
if (!competing && !unqualified)
|
|
59
63
|
return false;
|
|
@@ -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.
|
|
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",
|
|
@@ -107,6 +109,7 @@
|
|
|
107
109
|
"tools/plugin/plugin-links.mjs",
|
|
108
110
|
"tools/skills/deploy-skills-codex.mjs",
|
|
109
111
|
"tools/skills/codex-skill-transform.mjs",
|
|
112
|
+
"tools/skills/codex-skill-metadata.mjs",
|
|
110
113
|
"README.md"
|
|
111
114
|
],
|
|
112
115
|
"repository": {
|
|
@@ -140,7 +143,7 @@
|
|
|
140
143
|
"chalk": "^4.1.2",
|
|
141
144
|
"chokidar": "^4.0.3",
|
|
142
145
|
"commander": "^12.1.0",
|
|
143
|
-
"glob": "^
|
|
146
|
+
"glob": "^14.0.2",
|
|
144
147
|
"graceful-fs": "^4.2.11",
|
|
145
148
|
"js-yaml": "^4.3.0",
|
|
146
149
|
"listr2": "^8.2.5",
|
|
@@ -162,9 +162,25 @@ import { parseArgs, printHelp } from './deploy-options.mjs';
|
|
|
162
162
|
import { useRuleSelectionConfig } from './use-rule-selection.mjs';
|
|
163
163
|
import { mirrorSkillsAsCommands } from './deploy-command-mirrors.mjs';
|
|
164
164
|
import { resolveShorthand, saveModelConfig, promptCommandsMigration } from './deploy-support.mjs';
|
|
165
|
+
const { preserveDeploymentOutputs } = await importImpl(import.meta.url, 'providers/deployment-preservation.mjs');
|
|
165
166
|
const { captureDeploymentOutputs, recordDeploymentOutputs, deploymentOutputRoots } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
|
|
166
167
|
|
|
167
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) {
|
|
168
184
|
const cfg = parseArgs(args);
|
|
169
185
|
if (cfg.help) { printHelp(); return 0; }
|
|
170
186
|
const modelCatalog = loadRuntimeModelCatalog(staticModelCatalog);
|
|
@@ -248,6 +264,7 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
248
264
|
// Build options for provider
|
|
249
265
|
const { writeContextFileSync } = await import('./providers/context-write.mjs');
|
|
250
266
|
const opts = {
|
|
267
|
+
replacedSkillCopies: new Set(),
|
|
251
268
|
writeReceipt: writeContextFileSync,
|
|
252
269
|
config: useRuleSelectionConfig(cfg, srcRoot),
|
|
253
270
|
srcRoot,
|
|
@@ -297,7 +314,9 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
297
314
|
// for the standard tier. Default is no-copy + index-driven discovery.
|
|
298
315
|
// Replaces the legacy AIWG_COPY_STANDARD_SKILLS env var (removed rc.30).
|
|
299
316
|
// Default (#1217) is no-copy + index-driven discovery.
|
|
317
|
+
fluePackage: cfg.fluePackage === true,
|
|
300
318
|
copyStandardSkills: cfg.copyStandardSkills === true,
|
|
319
|
+
copyMode: cfg.copyStandardSkills === true && cfg.indexMode !== true,
|
|
301
320
|
// #228: Muse provider hooks/MCP profile surface.
|
|
302
321
|
mcp: cfg.mcp === true,
|
|
303
322
|
hooks: cfg.hooks !== false,
|
|
@@ -318,7 +337,7 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
318
337
|
// Commands → Skills migration: prompt then delete the commands directory
|
|
319
338
|
// so stale command files don't create duplicates in the provider TUI.
|
|
320
339
|
if (!preparationActive && !internal.finalizeOnly) {
|
|
321
|
-
if (!cfg.dryRun && !cfg.skipCommandsMigration) {
|
|
340
|
+
if (!cfg.dryRun && !opts.copyMode && !cfg.skipCommandsMigration) {
|
|
322
341
|
const doMigrate = await promptCommandsMigration(cfg, provider, cfg.target, internal.capture ? false : process.stdout.isTTY);
|
|
323
342
|
if (doMigrate) {
|
|
324
343
|
const commandsRelPath = provider.paths?.commands;
|
|
@@ -386,6 +405,7 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
386
405
|
await saveModelConfig(cfg, provider.name);
|
|
387
406
|
}
|
|
388
407
|
|
|
408
|
+
if (ownershipBefore) preserveDeploymentOutputs(ownershipBefore, ownershipRoots, opts);
|
|
389
409
|
if (ownershipBefore) recordDeploymentOutputs(ownershipBefore, ownershipRoots, opts);
|
|
390
410
|
if (!cfg.quiet) console.log(`\n=== Deployment complete ===\n`);
|
|
391
411
|
} catch (err) {
|