@aiwg/cli 2026.10.16 → 2026.10.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/agentic/code/providers/capability-matrix.yaml +51 -0
  2. package/agentic/code/providers/flue/README.md +62 -0
  3. package/agentic/code/providers/flue/templates/aiwg/tools.ts +120 -0
  4. package/agentic/code/providers/model-capabilities.v1.json +23 -0
  5. package/agentic/code/providers/model-catalog.v1.json +9 -0
  6. package/dist/src/artifacts/corpus-tools/resolve.js +28 -6
  7. package/dist/src/artifacts/query-engine-corpus.js +217 -0
  8. package/dist/src/artifacts/query-engine-discover-output.js +229 -0
  9. package/dist/src/artifacts/query-engine-discover.js +285 -0
  10. package/dist/src/artifacts/query-engine-entries.js +188 -0
  11. package/dist/src/artifacts/query-engine-index.js +249 -0
  12. package/dist/src/artifacts/query-engine-matching.js +143 -0
  13. package/dist/src/artifacts/query-engine-options.js +2 -0
  14. package/dist/src/artifacts/query-engine-rules.js +202 -0
  15. package/dist/src/artifacts/query-engine-scoring.js +436 -0
  16. package/dist/src/artifacts/query-engine-show-card.js +194 -0
  17. package/dist/src/artifacts/query-engine-show-load.js +211 -0
  18. package/dist/src/artifacts/query-engine-show.js +300 -0
  19. package/dist/src/artifacts/query-engine.js +7 -2576
  20. package/dist/src/cli/handlers/help.js +1 -1
  21. package/dist/src/cli/handlers/init.js +1 -0
  22. package/dist/src/cli/handlers/mc-agents.js +111 -0
  23. package/dist/src/cli/handlers/mc-args.js +54 -0
  24. package/dist/src/cli/handlers/mc-control.js +227 -0
  25. package/dist/src/cli/handlers/mc-dispatch.js +203 -0
  26. package/dist/src/cli/handlers/mc-help.js +171 -0
  27. package/dist/src/cli/handlers/mc-run.js +343 -0
  28. package/dist/src/cli/handlers/mc-session.js +138 -0
  29. package/dist/src/cli/handlers/mc-status.js +258 -0
  30. package/dist/src/cli/handlers/mc-summary.js +43 -0
  31. package/dist/src/cli/handlers/mc-types.js +3 -0
  32. package/dist/src/cli/handlers/mc-worker.js +205 -0
  33. package/dist/src/cli/handlers/mc.js +12 -1665
  34. package/dist/src/cli/handlers/models-refusal.js +13 -0
  35. package/dist/src/cli/handlers/models.js +2 -1
  36. package/dist/src/cli/handlers/remove-bundled.js +133 -0
  37. package/dist/src/cli/handlers/remove-options.js +31 -0
  38. package/dist/src/cli/handlers/remove-user.js +174 -0
  39. package/dist/src/cli/handlers/remove.js +201 -0
  40. package/dist/src/cli/handlers/subcommands-bundles.js +257 -0
  41. package/dist/src/cli/handlers/subcommands-discovery.js +165 -0
  42. package/dist/src/cli/handlers/subcommands-list-format.js +129 -0
  43. package/dist/src/cli/handlers/subcommands-list.js +250 -0
  44. package/dist/src/cli/handlers/subcommands-plugins.js +213 -0
  45. package/dist/src/cli/handlers/subcommands-quickref.js +58 -0
  46. package/dist/src/cli/handlers/subcommands-rlm.js +113 -0
  47. package/dist/src/cli/handlers/subcommands-services.js +66 -0
  48. package/dist/src/cli/handlers/subcommands-storage.js +259 -0
  49. package/dist/src/cli/handlers/subcommands.js +18 -1984
  50. package/dist/src/cli/handlers/use.js +11 -5
  51. package/dist/src/cli/scope-resolver.js +1 -142
  52. package/dist/src/cli/services/deployment-verification.js +3 -0
  53. package/dist/src/cli/user-scope-mirror.js +173 -0
  54. package/dist/src/config/dispatch-host-thresholds.js +2 -0
  55. package/dist/src/config/dispatch-thresholds-runtime.mjs +4 -0
  56. package/dist/src/config/host-resource-report.d.mts +5 -0
  57. package/dist/src/config/host-resource-report.mjs +36 -6
  58. package/dist/src/config/host-resource-runtime.d.mts +3 -0
  59. package/dist/src/config/host-resource-runtime.mjs +9 -6
  60. package/dist/src/decision/ensemble-study/artifacts.js +7 -0
  61. package/dist/src/decision/ensemble-study/gate-policy.js +58 -0
  62. package/dist/src/decision/ensemble-study/gates.js +78 -0
  63. package/dist/src/decision/ensemble-study/protocol.js +18 -21
  64. package/dist/src/decision/ensemble-study/score.js +3 -2
  65. package/dist/src/decision/ensemble-study/statistics.js +7 -26
  66. package/dist/src/decision/sensitivity/comparative-gates.js +135 -0
  67. package/dist/src/decision/sensitivity/comparative.js +18 -41
  68. package/dist/src/extensions/claude-hooks-installer.js +18 -0
  69. package/dist/src/gates/evaluate.js +2 -358
  70. package/dist/src/gates/observations.js +363 -0
  71. package/dist/src/gates/pack-composition.js +270 -0
  72. package/dist/src/gates/pack-tightening.js +197 -0
  73. package/dist/src/gates/pack-validation.js +262 -0
  74. package/dist/src/gates/registry-error.js +5 -0
  75. package/dist/src/gates/registry.js +13 -685
  76. package/dist/src/mcp/json-document.mjs +29 -0
  77. package/dist/src/mcp/muse-native-config.mjs +1 -28
  78. package/dist/src/memory/provider-memory-adapter.js +1 -0
  79. package/dist/src/mission-protocol/worker-review-gate.js +7 -0
  80. package/dist/src/models/model-capabilities.v1.json +23 -0
  81. package/dist/src/models/model-catalog.v1.json +9 -0
  82. package/dist/src/models/policy-resources.js +1 -1
  83. package/dist/src/models/worker-plan.js +5 -5
  84. package/dist/src/plugin/command-ownership.js +34 -0
  85. package/dist/src/plugin/skill-command-frontmatter.js +197 -0
  86. package/dist/src/plugin/skill-command-translator.js +6 -232
  87. package/dist/src/providers/capability-matrix.yaml +51 -0
  88. package/dist/src/providers/context-output-ownership.js +26 -0
  89. package/dist/src/providers/deployment-ownership.d.mts +20 -0
  90. package/dist/src/providers/deployment-ownership.mjs +236 -0
  91. package/dist/src/providers/deployment-removal.js +222 -0
  92. package/dist/src/providers/provider-context-contracts.js +8 -0
  93. package/dist/src/providers/provider-definition-schema.js +1 -0
  94. package/dist/src/providers/provider-definitions.js +1 -0
  95. package/dist/src/providers/provider-seeds-3.js +18 -0
  96. package/dist/src/providers/removal-transaction.js +86 -0
  97. package/dist/src/providers/settings-document.d.mts +3 -0
  98. package/dist/src/providers/settings-document.mjs +47 -0
  99. package/dist/src/providers/settings-removal.js +190 -0
  100. package/dist/src/providers/skill-ownership.d.mts +20 -2
  101. package/dist/src/providers/skill-ownership.mjs +12 -4
  102. package/dist/src/providers/transformation-receipt-integration.js +15 -271
  103. package/dist/src/providers/transformation-receipt-outputs.js +99 -0
  104. package/dist/src/providers/transformation-receipt-source.js +194 -0
  105. package/dist/src/research/identity.js +8 -2
  106. package/dist/src/research/reference-match.js +66 -8
  107. package/dist/src/rules/activation.mjs +15 -6
  108. package/dist/src/rules/core-startup.mjs +2 -2
  109. package/dist/src/serve/mission-conductor.js +4 -0
  110. package/dist/src/serve/mission-summary.js +56 -0
  111. package/dist/src/skills/deployment-ownership.js +2 -2
  112. package/dist/src/skills/deployment-policy.js +9 -0
  113. package/dist/src/smiths/context-pipeline/aiwg-md.js +23 -0
  114. package/dist/src/smiths/context-pipeline/context-file-safety.js +3 -0
  115. package/dist/src/smiths/context-pipeline/flue-context.js +25 -0
  116. package/dist/src/smiths/context-pipeline/generator.js +7 -2
  117. package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +9 -7
  118. package/dist/src/smiths/hook-bridge/index.js +9 -0
  119. package/package.json +5 -1
  120. package/schemas/decision/D17StudyProtocol.v1.schema.json +39 -67
  121. package/tools/agents/deploy-agents.mjs +21 -680
  122. package/tools/agents/deploy-command-mirrors.mjs +229 -0
  123. package/tools/agents/deploy-options.mjs +267 -0
  124. package/tools/agents/deploy-support.mjs +165 -0
  125. package/tools/agents/providers/base-addon-discovery.mjs +139 -0
  126. package/tools/agents/providers/base-behaviors.mjs +168 -0
  127. package/tools/agents/providers/base-context.mjs +205 -0
  128. package/tools/agents/providers/base-contract.mjs +116 -0
  129. package/tools/agents/providers/base-files.mjs +252 -0
  130. package/tools/agents/providers/base-flat-artifacts.mjs +233 -0
  131. package/tools/agents/providers/base-framework-discovery.mjs +309 -0
  132. package/tools/agents/providers/base-frontmatter.mjs +196 -0
  133. package/tools/agents/providers/base-inventory.mjs +269 -0
  134. package/tools/agents/providers/base-kernel-skills.mjs +354 -0
  135. package/tools/agents/providers/base-migrations.mjs +258 -0
  136. package/tools/agents/providers/base-models-platforms.mjs +273 -0
  137. package/tools/agents/providers/base-rule-index.mjs +450 -0
  138. package/tools/agents/providers/base-runtime.mjs +60 -0
  139. package/tools/agents/providers/base-skill-copy.mjs +273 -0
  140. package/tools/agents/providers/base.mjs +16 -3364
  141. package/tools/agents/providers/claude-post-deploy.mjs +10 -2
  142. package/tools/agents/providers/flue-project.mjs +79 -0
  143. package/tools/agents/providers/flue-specialists.mjs +64 -0
  144. package/tools/agents/providers/flue.mjs +50 -0
  145. package/tools/agents/providers/hermes-startup.mjs +0 -5
  146. package/tools/agents/providers/muse.mjs +7 -2
  147. package/tools/agents/providers/rule-delivery-surface.mjs +33 -5
  148. package/tools/agents/providers/rule-deployment-commit.mjs +19 -15
  149. package/tools/agents/providers/rule-deployment-prepare.mjs +13 -3
  150. package/tools/agents/providers/rule-projection.mjs +3 -0
  151. package/tools/agents/providers/rule-startup.mjs +3 -3
  152. package/tools/agents/use-rule-selection.mjs +17 -0
  153. package/tools/ralph-external/lib/worker-invocation-processes.mjs +4 -2
  154. package/tools/ralph-external/lib/worker-termination.mjs +15 -8
  155. package/vscode-extension/schemas/aiwg.config.v1.json +2 -4
@@ -1,5 +1,5 @@
1
1
  import { createHash, randomUUID } from 'node:crypto';
2
- import { access, lstat, mkdir, readFile, readdir, rename, rm, writeFile } from 'node:fs/promises';
2
+ import { access, mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
3
3
  import { homedir } from 'node:os';
4
4
  import path from 'node:path';
5
5
  import { readAiwgConfig } from '../config/aiwg-config.js';
@@ -9,22 +9,9 @@ import { getProviderDefinition, getProviderKernelSkillPath, normalizeProviderDef
9
9
  import { createProviderTransformationReceipt, diagnoseProviderTransformationReceipt, providerTransformationReceiptPath, writeProviderTransformationReceipt, } from './transformation-receipt.js';
10
10
  const TRANSFORMER_ID = 'aiwg-provider-transformer';
11
11
  const TRANSFORMER_VERSION = '1';
12
- const MANAGED_SIDECAR = '.aiwg-manifest.json';
13
- const MANAGED_DIRECTORY_MARKER = '.aiwg-managed';
14
- const MANAGED_FILE_MARKER = /^(?:<!-- aiwg:managed |# aiwg:managed )/m;
15
- const FRAMEWORK_BUNDLE_DIRS = {
16
- all: 'sdlc-complete',
17
- sdlc: 'sdlc-complete',
18
- marketing: 'media-marketing-kit',
19
- 'media-curator': 'media-curator',
20
- research: 'research-complete',
21
- forensics: 'forensics-complete',
22
- dfir: 'forensics-complete',
23
- 'security-engineering': 'security-engineering',
24
- ops: 'ops-complete',
25
- validation: 'validation-complete',
26
- 'knowledge-base': 'knowledge-base',
27
- };
12
+ import { collectOwnedDirectory } from './transformation-receipt-outputs.js';
13
+ import { receiptBundles, sourceEvidence } from './transformation-receipt-source.js';
14
+ export { providerReceiptHasLocalSources, sourceVerificationsFromSignedWebRelease } from './transformation-receipt-source.js';
28
15
  const PROVIDER_TRANSFORMATION_EVIDENCE_STATE_SCHEMA = 'aiwg.provider-transformation-evidence-state.v1';
29
16
  export function providerTransformationEvidenceStatePath(projectRoot, provider, scope) {
30
17
  const receiptPath = providerTransformationReceiptPath(projectRoot, provider, scope);
@@ -102,93 +89,6 @@ function portablePath(root, absolute) {
102
89
  return null;
103
90
  return relative.split(path.sep).join('/');
104
91
  }
105
- async function regularFiles(root) {
106
- const files = [];
107
- let entries;
108
- try {
109
- entries = await readdir(root, { withFileTypes: true });
110
- }
111
- catch {
112
- return files;
113
- }
114
- for (const entry of entries) {
115
- const candidate = path.join(root, entry.name);
116
- if (entry.isDirectory())
117
- files.push(...await regularFiles(candidate));
118
- else if (entry.isFile())
119
- files.push(candidate);
120
- }
121
- return files;
122
- }
123
- async function addEntry(files, candidate) {
124
- try {
125
- const metadata = await lstat(candidate);
126
- if (metadata.isFile())
127
- files.add(candidate);
128
- else if (metadata.isDirectory()) {
129
- for (const file of await regularFiles(candidate))
130
- files.add(file);
131
- }
132
- }
133
- catch {
134
- // A registry or sidecar entry can describe a stale partial deployment.
135
- // Receipt finalization binds only successful on-disk outputs; an existing
136
- // receipt remains responsible for diagnosing later deletion.
137
- }
138
- }
139
- async function collectOwnedDirectory(directory, exactEntries, files) {
140
- for (const entry of exactEntries)
141
- await addEntry(files, path.join(directory, entry));
142
- const sidecarPath = path.join(directory, MANAGED_SIDECAR);
143
- try {
144
- const sidecar = JSON.parse(await readFile(sidecarPath, 'utf8'));
145
- const managed = sidecar.managed && typeof sidecar.managed === 'object'
146
- ? Object.keys(sidecar.managed)
147
- : [];
148
- if (managed.length > 0)
149
- files.add(sidecarPath);
150
- for (const name of managed) {
151
- if (name === path.basename(name) && name !== MANAGED_SIDECAR) {
152
- await addEntry(files, path.join(directory, name));
153
- }
154
- }
155
- }
156
- catch {
157
- // Missing or invalid sidecars are not ownership evidence.
158
- }
159
- let entries;
160
- try {
161
- entries = await readdir(directory, { withFileTypes: true });
162
- }
163
- catch {
164
- return;
165
- }
166
- for (const entry of entries) {
167
- const candidate = path.join(directory, entry.name);
168
- if (entry.isDirectory()) {
169
- try {
170
- const marker = await lstat(path.join(candidate, MANAGED_DIRECTORY_MARKER));
171
- if (!marker.isFile())
172
- continue;
173
- await addEntry(files, candidate);
174
- }
175
- catch {
176
- // Unmarked directories remain operator-owned.
177
- }
178
- continue;
179
- }
180
- if (!entry.isFile() || entry.name === MANAGED_SIDECAR)
181
- continue;
182
- try {
183
- const content = await readFile(candidate, 'utf8');
184
- if (MANAGED_FILE_MARKER.test(content))
185
- files.add(candidate);
186
- }
187
- catch {
188
- // Unreadable files cannot establish an ownership signal.
189
- }
190
- }
191
- }
192
92
  function artifactPaths(provider, scope) {
193
93
  const definition = getProviderDefinition(provider);
194
94
  if (!definition)
@@ -203,7 +103,7 @@ function artifactPaths(provider, scope) {
203
103
  behaviors: definition.paths.artifacts.behaviors ?? '',
204
104
  };
205
105
  }
206
- async function installedEntries(options) {
106
+ export async function installedEntries(options) {
207
107
  if (options.scope === 'user' && options.provider !== 'openhuman') {
208
108
  return (await readUserRegistry()).installed;
209
109
  }
@@ -220,172 +120,6 @@ function exactUserEntries(installed, bundles, provider, type) {
220
120
  }
221
121
  return [...entries].sort();
222
122
  }
223
- async function sourceBundleFiles(root) {
224
- const files = [];
225
- const walk = async (directory) => {
226
- const entries = await readdir(directory, { withFileTypes: true });
227
- for (const entry of entries) {
228
- const candidate = path.join(directory, entry.name);
229
- if (entry.isSymbolicLink())
230
- throw new Error(`canonical source bundle contains a symbolic link: ${candidate}`);
231
- if (entry.isDirectory())
232
- await walk(candidate);
233
- else if (entry.isFile())
234
- files.push(candidate);
235
- else
236
- throw new Error(`canonical source bundle contains a non-regular entry: ${candidate}`);
237
- }
238
- };
239
- await walk(root);
240
- const inventory = await Promise.all(files.map(async (absolutePath) => {
241
- const content = await readFile(absolutePath);
242
- return {
243
- path: path.relative(root, absolutePath).split(path.sep).join('/'),
244
- sha256: sha256(content),
245
- bytes: content.byteLength,
246
- absolutePath,
247
- };
248
- }));
249
- return inventory.sort((left, right) => left.path.localeCompare(right.path));
250
- }
251
- async function resolveSourceBundle(options, bundle, entry) {
252
- const candidates = [];
253
- if (entry?.source === 'project-local' && entry.localPath) {
254
- candidates.push(path.resolve(options.projectRoot, entry.localPath, 'manifest.json'));
255
- }
256
- const frameworkDir = FRAMEWORK_BUNDLE_DIRS[bundle] ?? bundle;
257
- candidates.push(path.join(options.frameworkRoot, 'agentic', 'code', 'frameworks', frameworkDir, 'manifest.json'), path.join(options.frameworkRoot, 'agentic', 'code', 'addons', bundle, 'manifest.json'), path.join(options.frameworkRoot, 'agentic', 'code', 'extensions', bundle, 'manifest.json'));
258
- for (const candidate of candidates) {
259
- try {
260
- await access(candidate);
261
- const root = path.dirname(candidate);
262
- const files = await sourceBundleFiles(root);
263
- if (files.length === 0)
264
- continue;
265
- return {
266
- digest: sha256(stable(files.map(({ path: file, sha256: digest, bytes }) => ({ path: file, sha256: digest, bytes })))),
267
- root,
268
- files,
269
- canonicalBytesAvailable: true,
270
- };
271
- }
272
- catch {
273
- // Continue through the canonical source locations.
274
- }
275
- }
276
- const recorded = entry?.manifestHash?.replace(/^sha256:/, '');
277
- return recorded && /^[a-f0-9]{64}$/.test(recorded)
278
- ? { digest: recorded, root: '', files: [], canonicalBytesAvailable: false }
279
- : null;
280
- }
281
- function receiptBundles(installed, options) {
282
- const deployed = Object.keys(installed)
283
- .filter(bundle => Boolean(installed[bundle]?.deployedTo[options.provider]))
284
- .sort();
285
- return deployed.length > 0 ? deployed : [...new Set(options.requestedBundles)].sort();
286
- }
287
- /**
288
- * Return whether the deployed provider surface includes project-local source
289
- * material that cannot be authenticated by an AIWG signed web release.
290
- */
291
- export async function providerReceiptHasLocalSources(rawOptions) {
292
- const provider = normalizeProviderDefinitionId(rawOptions.provider) ?? rawOptions.provider;
293
- const options = { ...rawOptions, provider };
294
- const installed = await installedEntries(options);
295
- return receiptBundles(installed, options)
296
- .some(bundle => installed[bundle]?.source === 'project-local');
297
- }
298
- /**
299
- * Convert an already signature-verified web release into the stable verifier
300
- * result contract for the complete canonical bundle consumed by deployment.
301
- * Every local file must match its signed descriptor; a registry's self-recorded
302
- * manifestHash is never an authentication boundary.
303
- */
304
- export async function sourceVerificationsFromSignedWebRelease(options, release) {
305
- const installed = await installedEntries(options);
306
- const results = {};
307
- for (const bundle of receiptBundles(installed, options)) {
308
- const entry = installed[bundle];
309
- if (entry?.source === 'project-local')
310
- continue;
311
- const source = await resolveSourceBundle(options, bundle, entry);
312
- if (!source?.canonicalBytesAvailable)
313
- continue;
314
- let matched = true;
315
- for (const file of source.files) {
316
- const relative = path.relative(options.frameworkRoot, file.absolutePath).split(path.sep).join('/');
317
- if (!relative || relative === '..' || relative.startsWith('../')) {
318
- matched = false;
319
- break;
320
- }
321
- const descriptor = release.descriptors.get(`raw/${relative}`);
322
- if (!descriptor || descriptor.sha256 !== file.sha256 || descriptor.size !== file.bytes) {
323
- matched = false;
324
- break;
325
- }
326
- }
327
- if (!matched)
328
- continue;
329
- const artifactName = `aiwg:bundle-inventory:${bundle}`;
330
- results[bundle] = {
331
- schemaVersion: 'aiwg.verify.result.v1',
332
- status: 'verified',
333
- exitCode: 0,
334
- artifact: { name: artifactName, sha256: source.digest },
335
- policy: 'aiwg-signed-web-release',
336
- identities: ['aiwg-release-publisher'],
337
- ...(release.channelSequence === undefined ? {} : {
338
- freshness: {
339
- namespace: 'aiwg',
340
- channel: release.selector,
341
- sequence: release.channelSequence,
342
- version: release.version,
343
- },
344
- }),
345
- diagnostics: [{
346
- code: 'SIGNED_RELEASE_DESCRIPTOR',
347
- message: `Exact canonical source bytes match signed release manifest ${release.manifestDigest}`,
348
- }],
349
- };
350
- }
351
- return results;
352
- }
353
- async function sourceEvidence(options, installed) {
354
- const bundles = [...new Set(options.requestedBundles)].sort();
355
- const materials = [];
356
- let authenticated = Boolean(options.sourceVerifications);
357
- for (const bundle of bundles) {
358
- const entry = installed[bundle];
359
- const source = await resolveSourceBundle(options, bundle, entry);
360
- if (!source) {
361
- return {
362
- subject: `aiwg:deployment:${sha256(bundles.join('\0')).slice(0, 24)}`,
363
- sha256: sha256(stable(materials)),
364
- verification: 'failed',
365
- };
366
- }
367
- const verification = options.sourceVerifications?.[bundle];
368
- if (!source.canonicalBytesAvailable
369
- || verification?.status !== 'verified'
370
- || verification.artifact.sha256 !== source.digest) {
371
- authenticated = false;
372
- }
373
- materials.push({
374
- bundle,
375
- digest: source.digest,
376
- source: entry?.source ?? 'unknown',
377
- version: entry?.version ?? 'unknown',
378
- });
379
- }
380
- const digest = sha256(stable(materials));
381
- return {
382
- subject: `aiwg:deployment:${digest.slice(0, 24)}`,
383
- sha256: digest,
384
- verification: options.sourceVerifications
385
- ? authenticated ? 'verified' : 'failed'
386
- : 'policy-exempt',
387
- };
388
- }
389
123
  function transformerEvidence(provider, scope) {
390
124
  const definition = getProviderDefinition(provider);
391
125
  const adapterContract = definition
@@ -415,12 +149,16 @@ export async function resolveProviderReceiptRuntimeEvidence(rawOptions) {
415
149
  const paths = artifactPaths(provider, options.scope);
416
150
  const outputRoot = path.resolve(options.outputRoot ?? (options.scope === 'user' ? homedir() : options.projectRoot));
417
151
  const ownedFiles = new Set();
152
+ const receiptDirectories = new Set([outputRoot, path.join(outputRoot, '.aiwg'), path.join(outputRoot, `.${provider}`)]);
418
153
  if (paths) {
419
154
  for (const type of ['agents', 'commands', 'skills', 'rules', 'behaviors']) {
420
155
  const configured = paths[type];
421
156
  if (!configured)
422
157
  continue;
423
158
  const directory = resolveProviderPathValue(configured, outputRoot);
159
+ receiptDirectories.add(path.dirname(directory));
160
+ if (path.basename(path.dirname(directory)) === '.aiwg')
161
+ receiptDirectories.add(path.dirname(path.dirname(directory)));
424
162
  const entries = options.scope === 'user'
425
163
  ? exactUserEntries(installed, evidenceOptions.requestedBundles, provider, type)
426
164
  : [];
@@ -432,6 +170,12 @@ export async function resolveProviderReceiptRuntimeEvidence(rawOptions) {
432
170
  await collectOwnedDirectory(kernel, [], ownedFiles);
433
171
  }
434
172
  }
173
+ // Settings, hooks and generated context now have explicit sidecars too.
174
+ for (const directory of receiptDirectories) {
175
+ await collectOwnedDirectory(directory, [], ownedFiles, outputRoot);
176
+ for (const child of ['hooks', 'plugins'])
177
+ await collectOwnedDirectory(path.join(directory, child), [], ownedFiles);
178
+ }
435
179
  const outputPaths = [...ownedFiles]
436
180
  .map(file => portablePath(outputRoot, file))
437
181
  .filter((file) => Boolean(file))
@@ -0,0 +1,99 @@
1
+ // Discover provider outputs from existing ownership evidence, including nested sidecars.
2
+ import { lstat, readFile, readdir } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ const MANAGED_SIDECAR = '.aiwg-manifest.json';
5
+ const MANAGED_DIRECTORY_MARKER = '.aiwg-managed';
6
+ const MANAGED_FILE_MARKER = /^(?:<!-- aiwg:managed |# aiwg:managed )/m;
7
+ function safeChild(root, name) {
8
+ const relative = path.relative(root, path.resolve(root, name));
9
+ return Boolean(relative) && relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
10
+ }
11
+ async function regularFiles(root) {
12
+ const files = [];
13
+ let entries;
14
+ try {
15
+ entries = await readdir(root, { withFileTypes: true });
16
+ }
17
+ catch {
18
+ return files;
19
+ }
20
+ for (const entry of entries) {
21
+ const candidate = path.join(root, entry.name);
22
+ if (entry.isDirectory())
23
+ files.push(...await regularFiles(candidate));
24
+ else if (entry.isFile())
25
+ files.push(candidate);
26
+ }
27
+ return files;
28
+ }
29
+ async function addEntry(files, candidate) {
30
+ try {
31
+ const metadata = await lstat(candidate);
32
+ if (metadata.isFile())
33
+ files.add(candidate);
34
+ else if (metadata.isDirectory()) {
35
+ for (const file of await regularFiles(candidate))
36
+ files.add(file);
37
+ }
38
+ }
39
+ catch {
40
+ // A registry or sidecar entry can describe a stale partial deployment.
41
+ // Receipt finalization binds only successful on-disk outputs; an existing
42
+ // receipt remains responsible for diagnosing later deletion.
43
+ }
44
+ }
45
+ export async function collectOwnedDirectory(directory, exactEntries, files, projectRoot) {
46
+ for (const entry of exactEntries)
47
+ await addEntry(files, path.join(directory, entry));
48
+ const sidecarPath = path.join(directory, MANAGED_SIDECAR);
49
+ try {
50
+ const sidecar = JSON.parse(await readFile(sidecarPath, 'utf8'));
51
+ const managed = sidecar.managed && typeof sidecar.managed === 'object'
52
+ ? Object.keys(sidecar.managed)
53
+ : [];
54
+ if (managed.length > 0)
55
+ files.add(sidecarPath);
56
+ const base = projectRoot && directory === path.join(projectRoot, '.aiwg') && sidecar.scope === 'project' ? projectRoot : directory;
57
+ for (const name of managed) {
58
+ if (name !== MANAGED_SIDECAR && safeChild(base, name)) {
59
+ await addEntry(files, path.join(base, name));
60
+ }
61
+ }
62
+ }
63
+ catch {
64
+ // Missing or invalid sidecars are not ownership evidence.
65
+ }
66
+ let entries;
67
+ try {
68
+ entries = await readdir(directory, { withFileTypes: true });
69
+ }
70
+ catch {
71
+ return;
72
+ }
73
+ for (const entry of entries) {
74
+ const candidate = path.join(directory, entry.name);
75
+ if (entry.isDirectory()) {
76
+ try {
77
+ const marker = await lstat(path.join(candidate, MANAGED_DIRECTORY_MARKER));
78
+ if (!marker.isFile())
79
+ continue;
80
+ await addEntry(files, candidate);
81
+ }
82
+ catch {
83
+ // Unmarked directories remain operator-owned.
84
+ }
85
+ continue;
86
+ }
87
+ if (!entry.isFile() || entry.name === MANAGED_SIDECAR)
88
+ continue;
89
+ try {
90
+ const content = await readFile(candidate, 'utf8');
91
+ if (MANAGED_FILE_MARKER.test(content))
92
+ files.add(candidate);
93
+ }
94
+ catch {
95
+ // Unreadable files cannot establish an ownership signal.
96
+ }
97
+ }
98
+ }
99
+ //# sourceMappingURL=transformation-receipt-outputs.js.map
@@ -0,0 +1,194 @@
1
+ // Authenticate canonical source inventories for provider transformation receipts.
2
+ import { createHash } from 'node:crypto';
3
+ import { access, readFile, readdir } from 'node:fs/promises';
4
+ import path from 'node:path';
5
+ import { normalizeProviderDefinitionId } from './provider-definitions.js';
6
+ import { installedEntries } from './transformation-receipt-integration.js';
7
+ const sha256 = (value) => createHash('sha256').update(value).digest('hex');
8
+ function stable(value) {
9
+ if (Array.isArray(value))
10
+ return `[${value.map(stable).join(',')}]`;
11
+ if (value && typeof value === 'object')
12
+ return `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${stable(value[key])}`).join(',')}}`;
13
+ return JSON.stringify(value) ?? 'null';
14
+ }
15
+ const FRAMEWORK_BUNDLE_DIRS = {
16
+ all: 'sdlc-complete',
17
+ sdlc: 'sdlc-complete',
18
+ marketing: 'media-marketing-kit',
19
+ 'media-curator': 'media-curator',
20
+ research: 'research-complete',
21
+ forensics: 'forensics-complete',
22
+ dfir: 'forensics-complete',
23
+ 'security-engineering': 'security-engineering',
24
+ ops: 'ops-complete',
25
+ validation: 'validation-complete',
26
+ 'knowledge-base': 'knowledge-base',
27
+ };
28
+ async function sourceBundleFiles(root) {
29
+ const files = [];
30
+ const walk = async (directory) => {
31
+ const entries = await readdir(directory, { withFileTypes: true });
32
+ for (const entry of entries) {
33
+ const candidate = path.join(directory, entry.name);
34
+ if (entry.isSymbolicLink())
35
+ throw new Error(`canonical source bundle contains a symbolic link: ${candidate}`);
36
+ if (entry.isDirectory())
37
+ await walk(candidate);
38
+ else if (entry.isFile())
39
+ files.push(candidate);
40
+ else
41
+ throw new Error(`canonical source bundle contains a non-regular entry: ${candidate}`);
42
+ }
43
+ };
44
+ await walk(root);
45
+ const inventory = await Promise.all(files.map(async (absolutePath) => {
46
+ const content = await readFile(absolutePath);
47
+ return {
48
+ path: path.relative(root, absolutePath).split(path.sep).join('/'),
49
+ sha256: sha256(content),
50
+ bytes: content.byteLength,
51
+ absolutePath,
52
+ };
53
+ }));
54
+ return inventory.sort((left, right) => left.path.localeCompare(right.path));
55
+ }
56
+ async function resolveSourceBundle(options, bundle, entry) {
57
+ const candidates = [];
58
+ if (entry?.source === 'project-local' && entry.localPath) {
59
+ candidates.push(path.resolve(options.projectRoot, entry.localPath, 'manifest.json'));
60
+ }
61
+ const frameworkDir = FRAMEWORK_BUNDLE_DIRS[bundle] ?? bundle;
62
+ candidates.push(path.join(options.frameworkRoot, 'agentic', 'code', 'frameworks', frameworkDir, 'manifest.json'), path.join(options.frameworkRoot, 'agentic', 'code', 'addons', bundle, 'manifest.json'), path.join(options.frameworkRoot, 'agentic', 'code', 'extensions', bundle, 'manifest.json'));
63
+ for (const candidate of candidates) {
64
+ try {
65
+ await access(candidate);
66
+ const root = path.dirname(candidate);
67
+ const files = await sourceBundleFiles(root);
68
+ if (files.length === 0)
69
+ continue;
70
+ return {
71
+ digest: sha256(stable(files.map(({ path: file, sha256: digest, bytes }) => ({ path: file, sha256: digest, bytes })))),
72
+ root,
73
+ files,
74
+ canonicalBytesAvailable: true,
75
+ };
76
+ }
77
+ catch {
78
+ // Continue through the canonical source locations.
79
+ }
80
+ }
81
+ const recorded = entry?.manifestHash?.replace(/^sha256:/, '');
82
+ return recorded && /^[a-f0-9]{64}$/.test(recorded)
83
+ ? { digest: recorded, root: '', files: [], canonicalBytesAvailable: false }
84
+ : null;
85
+ }
86
+ export function receiptBundles(installed, options) {
87
+ const deployed = Object.keys(installed)
88
+ .filter(bundle => Boolean(installed[bundle]?.deployedTo[options.provider]))
89
+ .sort();
90
+ return deployed.length > 0 ? deployed : [...new Set(options.requestedBundles)].sort();
91
+ }
92
+ /**
93
+ * Return whether the deployed provider surface includes project-local source
94
+ * material that cannot be authenticated by an AIWG signed web release.
95
+ */
96
+ export async function providerReceiptHasLocalSources(rawOptions) {
97
+ const provider = normalizeProviderDefinitionId(rawOptions.provider) ?? rawOptions.provider;
98
+ const options = { ...rawOptions, provider };
99
+ const installed = await installedEntries(options);
100
+ return receiptBundles(installed, options)
101
+ .some(bundle => installed[bundle]?.source === 'project-local');
102
+ }
103
+ /**
104
+ * Convert an already signature-verified web release into the stable verifier
105
+ * result contract for the complete canonical bundle consumed by deployment.
106
+ * Every local file must match its signed descriptor; a registry's self-recorded
107
+ * manifestHash is never an authentication boundary.
108
+ */
109
+ export async function sourceVerificationsFromSignedWebRelease(options, release) {
110
+ const installed = await installedEntries(options);
111
+ const results = {};
112
+ for (const bundle of receiptBundles(installed, options)) {
113
+ const entry = installed[bundle];
114
+ if (entry?.source === 'project-local')
115
+ continue;
116
+ const source = await resolveSourceBundle(options, bundle, entry);
117
+ if (!source?.canonicalBytesAvailable)
118
+ continue;
119
+ let matched = true;
120
+ for (const file of source.files) {
121
+ const relative = path.relative(options.frameworkRoot, file.absolutePath).split(path.sep).join('/');
122
+ if (!relative || relative === '..' || relative.startsWith('../')) {
123
+ matched = false;
124
+ break;
125
+ }
126
+ const descriptor = release.descriptors.get(`raw/${relative}`);
127
+ if (!descriptor || descriptor.sha256 !== file.sha256 || descriptor.size !== file.bytes) {
128
+ matched = false;
129
+ break;
130
+ }
131
+ }
132
+ if (!matched)
133
+ continue;
134
+ const artifactName = `aiwg:bundle-inventory:${bundle}`;
135
+ results[bundle] = {
136
+ schemaVersion: 'aiwg.verify.result.v1',
137
+ status: 'verified',
138
+ exitCode: 0,
139
+ artifact: { name: artifactName, sha256: source.digest },
140
+ policy: 'aiwg-signed-web-release',
141
+ identities: ['aiwg-release-publisher'],
142
+ ...(release.channelSequence === undefined ? {} : {
143
+ freshness: {
144
+ namespace: 'aiwg',
145
+ channel: release.selector,
146
+ sequence: release.channelSequence,
147
+ version: release.version,
148
+ },
149
+ }),
150
+ diagnostics: [{
151
+ code: 'SIGNED_RELEASE_DESCRIPTOR',
152
+ message: `Exact canonical source bytes match signed release manifest ${release.manifestDigest}`,
153
+ }],
154
+ };
155
+ }
156
+ return results;
157
+ }
158
+ export async function sourceEvidence(options, installed) {
159
+ const bundles = [...new Set(options.requestedBundles)].sort();
160
+ const materials = [];
161
+ let authenticated = Boolean(options.sourceVerifications);
162
+ for (const bundle of bundles) {
163
+ const entry = installed[bundle];
164
+ const source = await resolveSourceBundle(options, bundle, entry);
165
+ if (!source) {
166
+ return {
167
+ subject: `aiwg:deployment:${sha256(bundles.join('\0')).slice(0, 24)}`,
168
+ sha256: sha256(stable(materials)),
169
+ verification: 'failed',
170
+ };
171
+ }
172
+ const verification = options.sourceVerifications?.[bundle];
173
+ if (!source.canonicalBytesAvailable
174
+ || verification?.status !== 'verified'
175
+ || verification.artifact.sha256 !== source.digest) {
176
+ authenticated = false;
177
+ }
178
+ materials.push({
179
+ bundle,
180
+ digest: source.digest,
181
+ source: entry?.source ?? 'unknown',
182
+ version: entry?.version ?? 'unknown',
183
+ });
184
+ }
185
+ const digest = sha256(stable(materials));
186
+ return {
187
+ subject: `aiwg:deployment:${digest.slice(0, 24)}`,
188
+ sha256: digest,
189
+ verification: options.sourceVerifications
190
+ ? authenticated ? 'verified' : 'failed'
191
+ : 'policy-exempt',
192
+ };
193
+ }
194
+ //# sourceMappingURL=transformation-receipt-source.js.map
@@ -67,9 +67,12 @@ export function normalizeIdentity(value) {
67
67
  .map(v => typeof v === 'number' && Number.isFinite(v) ? String(v) : v)
68
68
  .find(v => typeof v === 'string' && v.trim());
69
69
  const arxiv = parseArxivId(str('arxivId', 'arxiv_id', 'arxiv') ?? '') ?? parseArxivId(str('doi') ?? '');
70
+ const alternateDois = Array.isArray(fields.alternateDois)
71
+ ? [...new Set(fields.alternateDois.flatMap(value => typeof value === 'string' ? normalizeDoi(value) ?? [] : []))] : [];
70
72
  return {
71
73
  ...(arxiv ? { arxivId: arxiv.id, arxivVersion: arxiv.version ?? (typeof fields.arxivVersion === 'number' ? fields.arxivVersion : undefined) } : {}),
72
74
  doi: normalizeDoi(str('doi', 'DOI') ?? ''),
75
+ ...(alternateDois.length ? { alternateDois } : {}),
73
76
  s2PaperId: str('s2PaperId', 's2_paper_id', 'paperId')?.toLowerCase(),
74
77
  openReviewId: str('openReviewId', 'openreview_id')?.toLowerCase(),
75
78
  aclId: str('aclId', 'acl_id')?.toLowerCase(),
@@ -79,8 +82,11 @@ export function normalizeIdentity(value) {
79
82
  /** Stable keys for matching any identifier or a normalized title across corpus sources. */
80
83
  export function identityKeys(value) {
81
84
  const identity = normalizeIdentity(value);
82
- return ['arxivId', 'doi', 's2PaperId', 'openReviewId', 'aclId', 'title']
83
- .flatMap(key => identity[key] ? [`${key}:${identity[key]}`] : []);
85
+ return [...new Set([
86
+ ...['arxivId', 'doi', 's2PaperId', 'openReviewId', 'aclId', 'title']
87
+ .flatMap(key => identity[key] ? [`${key}:${identity[key]}`] : []),
88
+ ...(identity.alternateDois ?? []).map(doi => `doi:${doi}`),
89
+ ])];
84
90
  }
85
91
  /** REF spelling is case-sensitive, including the optional legacy suffix letter. */
86
92
  export const REF_ID_SOURCE = 'REF-\\d+[a-zA-Z]?';