@aiwg/cli 2026.10.16 → 2026.10.18

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 (128) hide show
  1. package/dist/src/artifacts/corpus-tools/resolve.js +21 -4
  2. package/dist/src/artifacts/query-engine-corpus.js +217 -0
  3. package/dist/src/artifacts/query-engine-discover-output.js +229 -0
  4. package/dist/src/artifacts/query-engine-discover.js +285 -0
  5. package/dist/src/artifacts/query-engine-entries.js +188 -0
  6. package/dist/src/artifacts/query-engine-index.js +249 -0
  7. package/dist/src/artifacts/query-engine-matching.js +143 -0
  8. package/dist/src/artifacts/query-engine-options.js +2 -0
  9. package/dist/src/artifacts/query-engine-rules.js +202 -0
  10. package/dist/src/artifacts/query-engine-scoring.js +436 -0
  11. package/dist/src/artifacts/query-engine-show-card.js +194 -0
  12. package/dist/src/artifacts/query-engine-show-load.js +211 -0
  13. package/dist/src/artifacts/query-engine-show.js +300 -0
  14. package/dist/src/artifacts/query-engine.js +7 -2576
  15. package/dist/src/cli/handlers/mc-agents.js +111 -0
  16. package/dist/src/cli/handlers/mc-args.js +54 -0
  17. package/dist/src/cli/handlers/mc-control.js +227 -0
  18. package/dist/src/cli/handlers/mc-dispatch.js +203 -0
  19. package/dist/src/cli/handlers/mc-help.js +171 -0
  20. package/dist/src/cli/handlers/mc-run.js +343 -0
  21. package/dist/src/cli/handlers/mc-session.js +138 -0
  22. package/dist/src/cli/handlers/mc-status.js +258 -0
  23. package/dist/src/cli/handlers/mc-summary.js +43 -0
  24. package/dist/src/cli/handlers/mc-types.js +3 -0
  25. package/dist/src/cli/handlers/mc-worker.js +205 -0
  26. package/dist/src/cli/handlers/mc.js +12 -1665
  27. package/dist/src/cli/handlers/models-refusal.js +13 -0
  28. package/dist/src/cli/handlers/models.js +2 -1
  29. package/dist/src/cli/handlers/remove-bundled.js +133 -0
  30. package/dist/src/cli/handlers/remove-options.js +31 -0
  31. package/dist/src/cli/handlers/remove-user.js +174 -0
  32. package/dist/src/cli/handlers/remove.js +201 -0
  33. package/dist/src/cli/handlers/subcommands-bundles.js +257 -0
  34. package/dist/src/cli/handlers/subcommands-discovery.js +165 -0
  35. package/dist/src/cli/handlers/subcommands-list-format.js +129 -0
  36. package/dist/src/cli/handlers/subcommands-list.js +250 -0
  37. package/dist/src/cli/handlers/subcommands-plugins.js +213 -0
  38. package/dist/src/cli/handlers/subcommands-quickref.js +58 -0
  39. package/dist/src/cli/handlers/subcommands-rlm.js +113 -0
  40. package/dist/src/cli/handlers/subcommands-services.js +66 -0
  41. package/dist/src/cli/handlers/subcommands-storage.js +259 -0
  42. package/dist/src/cli/handlers/subcommands.js +18 -1984
  43. package/dist/src/cli/scope-resolver.js +1 -142
  44. package/dist/src/cli/user-scope-mirror.js +173 -0
  45. package/dist/src/config/dispatch-host-thresholds.js +2 -0
  46. package/dist/src/config/dispatch-thresholds-runtime.mjs +4 -0
  47. package/dist/src/config/host-resource-report.d.mts +5 -0
  48. package/dist/src/config/host-resource-report.mjs +36 -6
  49. package/dist/src/config/host-resource-runtime.d.mts +3 -0
  50. package/dist/src/config/host-resource-runtime.mjs +9 -6
  51. package/dist/src/decision/ensemble-study/artifacts.js +7 -0
  52. package/dist/src/decision/ensemble-study/gate-policy.js +58 -0
  53. package/dist/src/decision/ensemble-study/gates.js +78 -0
  54. package/dist/src/decision/ensemble-study/protocol.js +18 -21
  55. package/dist/src/decision/ensemble-study/score.js +3 -2
  56. package/dist/src/decision/ensemble-study/statistics.js +7 -26
  57. package/dist/src/decision/sensitivity/comparative-gates.js +135 -0
  58. package/dist/src/decision/sensitivity/comparative.js +18 -41
  59. package/dist/src/extensions/claude-hooks-installer.js +18 -0
  60. package/dist/src/gates/evaluate.js +2 -358
  61. package/dist/src/gates/observations.js +363 -0
  62. package/dist/src/gates/pack-composition.js +270 -0
  63. package/dist/src/gates/pack-tightening.js +197 -0
  64. package/dist/src/gates/pack-validation.js +262 -0
  65. package/dist/src/gates/registry-error.js +5 -0
  66. package/dist/src/gates/registry.js +13 -685
  67. package/dist/src/mcp/json-document.mjs +29 -0
  68. package/dist/src/mcp/muse-native-config.mjs +1 -28
  69. package/dist/src/mission-protocol/worker-review-gate.js +7 -0
  70. package/dist/src/models/worker-plan.js +5 -5
  71. package/dist/src/plugin/command-ownership.js +34 -0
  72. package/dist/src/plugin/skill-command-frontmatter.js +197 -0
  73. package/dist/src/plugin/skill-command-translator.js +6 -232
  74. package/dist/src/providers/context-output-ownership.js +26 -0
  75. package/dist/src/providers/deployment-ownership.d.mts +19 -0
  76. package/dist/src/providers/deployment-ownership.mjs +226 -0
  77. package/dist/src/providers/deployment-removal.js +200 -0
  78. package/dist/src/providers/removal-transaction.js +86 -0
  79. package/dist/src/providers/settings-document.d.mts +3 -0
  80. package/dist/src/providers/settings-document.mjs +47 -0
  81. package/dist/src/providers/settings-removal.js +190 -0
  82. package/dist/src/providers/skill-ownership.d.mts +19 -2
  83. package/dist/src/providers/skill-ownership.mjs +12 -4
  84. package/dist/src/providers/transformation-receipt-integration.js +15 -271
  85. package/dist/src/providers/transformation-receipt-outputs.js +99 -0
  86. package/dist/src/providers/transformation-receipt-source.js +194 -0
  87. package/dist/src/research/identity.js +8 -2
  88. package/dist/src/research/reference-match.js +42 -7
  89. package/dist/src/rules/activation.mjs +15 -6
  90. package/dist/src/rules/core-startup.mjs +2 -2
  91. package/dist/src/serve/mission-conductor.js +4 -0
  92. package/dist/src/serve/mission-summary.js +56 -0
  93. package/dist/src/smiths/context-pipeline/aiwg-md.js +23 -0
  94. package/dist/src/smiths/context-pipeline/context-file-safety.js +3 -0
  95. package/dist/src/smiths/context-pipeline/generator.js +1 -1
  96. package/dist/src/smiths/hook-bridge/index.js +9 -0
  97. package/package.json +4 -1
  98. package/schemas/decision/D17StudyProtocol.v1.schema.json +39 -67
  99. package/tools/agents/deploy-agents.mjs +16 -677
  100. package/tools/agents/deploy-command-mirrors.mjs +229 -0
  101. package/tools/agents/deploy-options.mjs +258 -0
  102. package/tools/agents/deploy-support.mjs +165 -0
  103. package/tools/agents/providers/base-addon-discovery.mjs +139 -0
  104. package/tools/agents/providers/base-behaviors.mjs +168 -0
  105. package/tools/agents/providers/base-context.mjs +205 -0
  106. package/tools/agents/providers/base-contract.mjs +116 -0
  107. package/tools/agents/providers/base-files.mjs +252 -0
  108. package/tools/agents/providers/base-flat-artifacts.mjs +233 -0
  109. package/tools/agents/providers/base-framework-discovery.mjs +309 -0
  110. package/tools/agents/providers/base-frontmatter.mjs +196 -0
  111. package/tools/agents/providers/base-inventory.mjs +269 -0
  112. package/tools/agents/providers/base-kernel-skills.mjs +354 -0
  113. package/tools/agents/providers/base-migrations.mjs +258 -0
  114. package/tools/agents/providers/base-models-platforms.mjs +273 -0
  115. package/tools/agents/providers/base-rule-index.mjs +450 -0
  116. package/tools/agents/providers/base-runtime.mjs +60 -0
  117. package/tools/agents/providers/base-skill-copy.mjs +273 -0
  118. package/tools/agents/providers/base.mjs +16 -3364
  119. package/tools/agents/providers/claude-post-deploy.mjs +10 -2
  120. package/tools/agents/providers/hermes-startup.mjs +0 -5
  121. package/tools/agents/providers/muse.mjs +7 -2
  122. package/tools/agents/providers/rule-delivery-surface.mjs +31 -4
  123. package/tools/agents/providers/rule-deployment-commit.mjs +19 -15
  124. package/tools/agents/providers/rule-deployment-prepare.mjs +11 -2
  125. package/tools/agents/providers/rule-projection.mjs +3 -0
  126. package/tools/ralph-external/lib/worker-invocation-processes.mjs +4 -2
  127. package/tools/ralph-external/lib/worker-termination.mjs +15 -8
  128. package/vscode-extension/schemas/aiwg.config.v1.json +2 -4
@@ -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]?';
@@ -45,16 +45,29 @@ export function titleSimilarity(left, right) {
45
45
  const repetition = Math.min(uniqueA.size / a.length, uniqueB.size / b.length);
46
46
  return coverage * row[b.length] / Math.min(a.length, b.length) * repetition;
47
47
  }
48
- /** Incomplete short/generic titles require an ID; unqualified very short titles need metadata. */
48
+ /** Caution needs competing candidates or an unqualified generic topic, never length alone with metadata. */
49
49
  export function needsTitleDisambiguation(reference, candidates, incomplete) {
50
- if (!reference.title || candidates[0]?.score_parts.identifier === 1)
50
+ if (!reference.title || !candidates.length || candidates[0]?.score_parts.identifier === 1)
51
+ return false;
52
+ const unqualified = reference.year === undefined && !reference.firstAuthor;
53
+ const competing = candidates.slice(1).some(candidate => classifyCandidates([candidate]) !== 'unresolved');
54
+ // A supplied year that the only candidate contradicts is not corroboration.
55
+ if (reference.year !== undefined && candidates[0]?.score_parts.year === 0)
56
+ return true;
57
+ if (!competing && !unqualified)
51
58
  return false;
52
59
  const title = normalizeTitle(reference.title);
53
60
  const tokens = title.split(' ');
54
61
  const informative = tokens.filter(token => !/^(?:a|an|the|of|for|in|on|and|with|to|is|all|you)$/.test(token));
55
62
  const exact = candidates.filter(candidate => normalizeTitle(candidate.paper.title) === title).length;
63
+ // Overview headings and common topic phrases remain generic even after a complete search.
64
+ // Single names/acronyms and distinctive technical phrases keep their complete-search behavior.
65
+ const overview = /^(?:(?:a|an|the) )?(?:tutorial|theory)\b/.test(title);
66
+ const commonTopic = informative.every(token => /^(?:deep|learning|scaling|laws|logical|physical|clocks)$/.test(token));
67
+ const generic = tokens.length > 1 && (tokens.length <= 2 ||
68
+ (informative.length <= 4 && (overview || commonTopic)));
56
69
  return (incomplete && (tokens.length <= 4 || informative.length <= 4 || exact > 1)) ||
57
- (tokens.length <= 2 && reference.year === undefined && !reference.firstAuthor);
70
+ (generic && (unqualified || competing));
58
71
  }
59
72
  function surname(name) {
60
73
  return normalizeTitle(name.includes(',') ? name.split(',')[0] : name.trim().split(/\s+/).at(-1) ?? '');
@@ -87,18 +100,35 @@ export function classifyCandidates(candidates) {
87
100
  const margin = best - (candidates[1]?.score ?? 0);
88
101
  return best + 1e-12 >= 0.92 && margin + 1e-12 >= 0.05 ? 'resolved' : 'ambiguous';
89
102
  }
90
- /** Shared IDs require title similarity >= 0.5; title agreement never establishes identity. */
103
+ /** Shared IDs or corroborated preprint/publication metadata establish a work, never title alone. */
91
104
  export function mergePapers(papers) {
92
105
  const ids = ['arxivId', 'doi', 's2PaperId', 'openReviewId', 'aclId'];
93
- const published = (paper) => Boolean(paper.doi && !parseArxivId(paper.doi));
106
+ const preprintDoi = (doi) => Boolean(parseArxivId(doi) || /^10\.2139\/ssrn\./i.test(doi));
107
+ const published = (paper) => Boolean(paper.doi && !preprintDoi(paper.doi));
108
+ const preprint = (paper) => !published(paper) && Boolean(paper.arxivId || (paper.doi && preprintDoi(paper.doi)));
109
+ const sameWorkMetadata = (left, right) => {
110
+ if (!((preprint(left) && published(right)) || (preprint(right) && published(left))))
111
+ return false;
112
+ if (!Number.isInteger(left.year) || !Number.isInteger(right.year) || Math.abs(left.year - right.year) > 2)
113
+ return false;
114
+ if (!normalizeTitle(left.title) || normalizeTitle(left.title) !== normalizeTitle(right.title))
115
+ return false;
116
+ const names = new Set(left.authors.map(author => normalizeTitle(author.name)).filter(Boolean));
117
+ return right.authors.some(author => names.has(normalizeTitle(author.name)));
118
+ };
94
119
  const linked = (left, right) => {
95
120
  const a = normalizeIdentity(left), b = normalizeIdentity(right);
96
121
  if (titleSimilarity(a.title ?? '', b.title ?? '') < 0.5)
97
122
  return false;
123
+ if (published(left) && published(right) && a.doi !== b.doi)
124
+ return false;
125
+ const metadataMatch = sameWorkMetadata(left, right);
126
+ const sharedDoi = [a.doi, ...(a.alternateDois ?? [])].some(doi => doi && [b.doi, ...(b.alternateDois ?? [])].includes(doi));
98
127
  if (ids.some(key => a[key] && b[key] && a[key] !== b[key] &&
99
- !(key === 'doi' && a.arxivId && a.arxivId === b.arxivId && (parseArxivId(a.doi) || parseArxivId(b.doi)))))
128
+ !(key === 'doi' && (metadataMatch || sharedDoi ||
129
+ (a.arxivId && a.arxivId === b.arxivId && (parseArxivId(a.doi) || parseArxivId(b.doi)))))))
100
130
  return false;
101
- return ids.some(key => a[key] && a[key] === b[key]);
131
+ return metadataMatch || sharedDoi || ids.some(key => a[key] && a[key] === b[key]);
102
132
  };
103
133
  const combine = (left, right) => {
104
134
  // A published CrossRef record owns proceedings metadata; other sources fill gaps.
@@ -112,6 +142,11 @@ export function mergePapers(papers) {
112
142
  result[key] = value;
113
143
  }
114
144
  }
145
+ const alternateDois = [...new Set([primary.doi, alternate.doi,
146
+ ...(primary.alternateDois ?? []), ...(alternate.alternateDois ?? [])])]
147
+ .filter((doi) => Boolean(doi && doi !== result.doi));
148
+ if (alternateDois.length)
149
+ result.alternateDois = alternateDois;
115
150
  return result;
116
151
  };
117
152
  const merged = [];
@@ -12,8 +12,8 @@ export const RULE_ACTIVATIONS = Object.freeze(['core', 'kernel', 'summary', 'bou
12
12
  // `aiwg show rule <name>`, never an @ import.
13
13
  export const CORE_BODY_MAX_BYTES = 1024;
14
14
  export const CORE_TOTAL_MAX_BYTES = 6144;
15
- export const CORE_RULES_START = '<!-- AIWG:core-rules:start -->';
16
- export const CORE_RULES_END = '<!-- AIWG:core-rules:end -->';
15
+ export const CORE_RULES_START = '<!-- AIWG:rule-core:start -->';
16
+ export const CORE_RULES_END = '<!-- AIWG:rule-core:end -->';
17
17
  const AT_IMPORT = /(?:^|[\s(`"'])@[\w$.\/-]*[\/.][\w$.\/-]*/m;
18
18
 
19
19
  export const RULE_BINDING_TYPES = Object.freeze({ skills: 'skill', agents: 'agent', flows: 'flow' });
@@ -147,12 +147,21 @@ export function measureDeployedCoreRules(target, provider, rulesDir) {
147
147
  const file = path.join(target, name);
148
148
  if (!existsSync(file)) continue;
149
149
  const content = readFileSync(file, 'utf8');
150
- const start = content.indexOf(CORE_RULES_START);
151
- const end = content.indexOf(CORE_RULES_END);
152
- if (start >= 0 && end > start) {
153
- bodies.push({ name, bytes: Buffer.byteLength(content.slice(start + CORE_RULES_START.length, end).trim(), 'utf8') });
150
+ for (const [startMarker, endMarker] of [[CORE_RULES_START, CORE_RULES_END],
151
+ ['<!-- AIWG:core-rules:start -->', '<!-- AIWG:core-rules:end -->']]) {
152
+ const start = content.indexOf(startMarker);
153
+ const end = content.indexOf(endMarker);
154
+ if (start < 0 || end <= start) continue;
155
+ const section = content.slice(start + startMarker.length, end).trim();
156
+ const parts = section.replace(/^## Core rules\s*/, '').split(/(?=^# Core: )/m).filter(text => text.trim());
157
+ const named = parts.every(text => /^# Core: /m.test(text));
158
+ for (const text of named ? parts : [section]) {
159
+ const ruleName = text.match(/aiwg show rule ([\w-]+)/)?.[1];
160
+ bodies.push({ name: ruleName || name, bytes: Buffer.byteLength(text.trim(), 'utf8') });
161
+ }
154
162
  break;
155
163
  }
164
+ if (bodies.length) break;
156
165
  }
157
166
  }
158
167
  return { bodies, bytes: bodies.reduce((sum, item) => sum + item.bytes, 0), limit: CORE_TOTAL_MAX_BYTES };
@@ -3,13 +3,13 @@ import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import { findPackageRoot } from '../cli/find-package-root.js';
6
- import { parseRuleFrontmatter, readCoreBody, validateCoreSet } from './activation.mjs';
6
+ import { parseRuleFrontmatter, readCoreBody, validateCoreSet, CORE_RULES_START, CORE_RULES_END } from './activation.mjs';
7
7
 
8
8
  export function renderCoreStartup(rules) {
9
9
  const cores = [...new Map(rules.filter(rule => rule.coreBody !== undefined).map(rule => [rule.name, rule])).values()];
10
10
  const errors = validateCoreSet(cores.map(rule => ({ name: rule.name, text: rule.coreBody })));
11
11
  if (errors.length) throw new Error(errors.join('; '));
12
- return cores.length ? `<!-- AIWG:rule-core:start -->\n## Core rules\n\n${cores.map(rule => rule.coreBody).join('\n\n')}\n<!-- AIWG:rule-core:end -->\n` : '';
12
+ return cores.length ? `${CORE_RULES_START}\n## Core rules\n\n${cores.map(rule => rule.coreBody).join('\n\n')}\n${CORE_RULES_END}\n` : '';
13
13
  }
14
14
 
15
15
  export function ensureCoreStartup(content) {
@@ -28,6 +28,7 @@ import { assertMissionWorkerHandoff } from '../mission-protocol/codecs.js';
28
28
  import { lookupEffect, reconcileEffect, recordIntent } from '../effects/ledger.js';
29
29
  import { createVerifierRegistry } from '../effects/verifiers/registry.js';
30
30
  import { fileDigestVerifier } from '../effects/verifiers/file.js';
31
+ export { summarizeMissionLedger } from './mission-summary.js';
31
32
  /**
32
33
  * The cross-stack Mission conductor. Decomposes a Mission into worker cycles,
33
34
  * dispatches each to an executor of the chosen runtime via `routeMission`, and
@@ -157,6 +158,7 @@ export class MissionConductor {
157
158
  continue;
158
159
  }
159
160
  let output;
161
+ let workerResult;
160
162
  let cost = 0;
161
163
  let reason = routing.selected.matchReason;
162
164
  try {
@@ -194,6 +196,7 @@ export class MissionConductor {
194
196
  if (!recovered) {
195
197
  const ran = await this.runWorker(cycle, executor, invocation);
196
198
  output = ran.output;
199
+ workerResult = ran.workerResult === undefined ? undefined : structuredClone(ran.workerResult);
197
200
  cost = ran.cost ?? 0;
198
201
  if (intent) {
199
202
  const checked = await reconcile(intent.effectId);
@@ -226,6 +229,7 @@ export class MissionConductor {
226
229
  routed: true,
227
230
  reason,
228
231
  output,
232
+ ...(workerResult ? { workerResult } : {}),
229
233
  cost,
230
234
  ...(graph ? { graph } : {}),
231
235
  };
@@ -0,0 +1,56 @@
1
+ // Read-only classification of conductor checkpoints and existing verifier results.
2
+ import { validateWorkerPayload } from '../mission-protocol/codecs.js';
3
+ import { hasIndependentWorkerAcceptance } from '../mission-protocol/worker-review-gate.js';
4
+ function classify(ledger, cycle) {
5
+ const entry = (status, reason, evidence = []) => ({ cycleId: cycle.cycleId, status, reason, evidence: structuredClone(evidence) });
6
+ if (ledger.checkpoint.failed.includes(cycle.cycleId))
7
+ return entry('failed', 'Conductor recorded failure');
8
+ if (ledger.executionMode !== undefined && !['plan-only', 'executed'].includes(ledger.executionMode)) {
9
+ return entry('unknown', `Unrecognized execution mode: ${String(ledger.executionMode)}`);
10
+ }
11
+ if (ledger.executionMode === 'plan-only' || !cycle.routed
12
+ || !ledger.checkpoint.completed.includes(cycle.cycleId)
13
+ || ledger.checkpoint.pending.includes(cycle.cycleId)) {
14
+ return entry('unknown', 'No completed execution measurement');
15
+ }
16
+ const result = cycle.workerResult;
17
+ if (result !== undefined) {
18
+ const definition = result && typeof result === 'object' && 'mode' in result && result.mode === 'direct'
19
+ ? 'workerDirectResult' : 'workerResult';
20
+ if (!validateWorkerPayload(definition, result).valid || result.taskId !== cycle.cycleId) {
21
+ return entry('unknown', 'Invalid or unbound worker measurement');
22
+ }
23
+ if (result.execution.status === 'failed')
24
+ return entry('failed', 'Adapter recorded worker failure');
25
+ if (result.execution.status !== 'completed')
26
+ return entry('unknown', 'Worker execution is not complete');
27
+ // The result codec already requires confirmed, successful terminal execution
28
+ // and completed worker claims for an accepted verifier verdict.
29
+ if (Date.parse(result.execution.endedAt) >= Date.parse(result.execution.startedAt)
30
+ && hasIndependentWorkerAcceptance(result.verification)) {
31
+ return entry('accepted', 'Independent review accepted with evidence', result.verification.evidence);
32
+ }
33
+ }
34
+ else if (ledger.executionMode !== 'executed') {
35
+ return entry('unknown', 'Legacy checkpoint lacks an execution measurement');
36
+ }
37
+ return entry('completed', 'Worker finished; independent acceptance with evidence is unavailable');
38
+ }
39
+ /** Project existing observations only; no scoring, file reads, sync or writes. */
40
+ export function summarizeMissionLedger(ledger) {
41
+ const counts = { accepted: 0, completed: 0, failed: 0, unknown: 0 };
42
+ const cycles = ledger.cycles.map(cycle => classify(ledger, cycle));
43
+ const measured = new Set(cycles.map(cycle => cycle.cycleId));
44
+ const checkpointIds = new Set([
45
+ ...ledger.checkpoint.completed, ...ledger.checkpoint.failed, ...ledger.checkpoint.pending,
46
+ ]);
47
+ for (const cycleId of checkpointIds) {
48
+ if (!measured.has(cycleId))
49
+ cycles.push({ cycleId, status: 'unknown',
50
+ reason: 'Checkpoint has no retained cycle measurement', evidence: [] });
51
+ }
52
+ for (const cycle of cycles)
53
+ counts[cycle.status]++;
54
+ return { missionId: ledger.missionId, counts, cycles };
55
+ }
56
+ //# sourceMappingURL=mission-summary.js.map
@@ -106,4 +106,27 @@ export async function buildAiwgMdContent(projectPath, stagedClaudeMdContent) {
106
106
  export async function generateAiwgMd(projectPath, stagedClaudeMdContent) {
107
107
  return buildAiwgMdContent(projectPath, stagedClaudeMdContent);
108
108
  }
109
+ /** Keep pipeline-owned startup boilerplate out of the shared context on redeploy. */
110
+ export async function generateAiwgMdForPipeline(projectPath) {
111
+ let claudeMdContent;
112
+ try {
113
+ claudeMdContent = await fs.readFile(path.join(projectPath, 'CLAUDE.md'), 'utf8');
114
+ }
115
+ catch (error) {
116
+ if (error.code !== 'ENOENT')
117
+ throw error;
118
+ claudeMdContent = null;
119
+ }
120
+ // A generated startup hook is not project prose. Mirroring it would change
121
+ // the initial shared-context stub on redeploy and duplicate provider policy.
122
+ if (claudeMdContent?.includes(CLAUDE_HOOK_START)) {
123
+ const prose = claudeMdContent
124
+ .replace(/<!-- AIWG:claude-md-hook:start -->[\s\S]*?<!-- AIWG:claude-md-hook:end -->/g, '')
125
+ .replace(/<!-- AIWG:(rule-core|rule-startup|rule-hook-[\w-]+):start -->[\s\S]*?<!-- AIWG:\1:end -->/g, '')
126
+ .replace(/^\s*<!-- aiwg-managed -->\s*$/gm, '');
127
+ if (!prose.trim())
128
+ claudeMdContent = null;
129
+ }
130
+ return buildAiwgMdContent(projectPath, claudeMdContent);
131
+ }
109
132
  //# sourceMappingURL=aiwg-md.js.map
@@ -2,6 +2,7 @@ import * as fs from 'node:fs';
2
2
  import * as path from 'node:path';
3
3
  import { tmpdir } from 'node:os';
4
4
  import { createHash } from 'node:crypto';
5
+ import { refreshRecordedContextOutput } from '../../providers/context-output-ownership.js';
5
6
  import { trackTemporaryDirectory } from '../../utils/temporary-directory.js';
6
7
  const JOURNAL_ENV = 'AIWG_CONTEXT_WRITE_JOURNAL';
7
8
  export const CONTEXT_STAGE_ENV = 'AIWG_CONTEXT_STAGE_LOG';
@@ -201,6 +202,8 @@ export function writeContextFileSync(file, content, _encoding) {
201
202
  verifyTarget(anchored, result);
202
203
  if (!matches(state(fd), result))
203
204
  throw new Error(`Context changed during write: ${absolute}`);
205
+ if (!stageLog)
206
+ refreshRecordedContextOutput(absolute, prior?.hash, result.hash, writeContextFileSync);
204
207
  }
205
208
  }
206
209
  finally {
@@ -6,7 +6,7 @@ import * as path from 'node:path';
6
6
  import { readdirSync, readFileSync } from 'node:fs';
7
7
  import { sanitizeDescription, sanitizeTags } from './sanitizer.js';
8
8
  import { checkPathAllowed } from './allowlist.js';
9
- import { generateAiwgMd } from './aiwg-md.js';
9
+ import { generateAiwgMdForPipeline as generateAiwgMd } from './aiwg-md.js';
10
10
  import { injectSpilloverBlock } from './overflow.js';
11
11
  import { migrateAiwgOperatorNotes } from './finalization.js';
12
12
  import { shouldEmitAgentsMd, shouldEmitClaudeMdHook } from './provider-policy.js';
@@ -9,6 +9,9 @@
9
9
  *
10
10
  * @module smiths/hook-bridge
11
11
  */
12
+ import path from 'node:path';
13
+ import { homedir } from 'node:os';
14
+ import { captureDeploymentOutputs, recordDeploymentOutputs } from '../../providers/deployment-ownership.mjs';
12
15
  import { translateForCodex } from './codex-translator.js';
13
16
  import { translateForCopilot } from './copilot-translator.js';
14
17
  import { translateForFactory } from './factory-translator.js';
@@ -63,7 +66,13 @@ export async function bridgeAll(sources, providers, options) {
63
66
  continue;
64
67
  }
65
68
  try {
69
+ const roots = [path.join(options.projectPath, '.factory/hooks'), path.join(options.projectPath, '.github/hooks'),
70
+ path.join(options.projectPath, '.grok/hooks'), path.join(process.env.CODEX_HOME || path.join(homedir(), '.codex'), 'config.toml'),
71
+ path.join(homedir(), '.hermes/plugins')];
72
+ const before = options.dryRun ? undefined : captureDeploymentOutputs(roots);
66
73
  const r = await translator(source, options);
74
+ if (before)
75
+ recordDeploymentOutputs(before, roots, { frameworkSlug: 'aiwg-hooks', writtenFiles: r.emittedPaths });
67
76
  results.push(r);
68
77
  }
69
78
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiwg/cli",
3
- "version": "2026.10.16",
3
+ "version": "2026.10.18",
4
4
  "description": "Lightweight AIWG CLI for signed, versioned web-backed resources.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -96,6 +96,9 @@
96
96
  "tools/providers/omp-transport.mjs",
97
97
  "tools/providers/deepseek-harness-transport.mjs",
98
98
  "tools/agents/deploy-agents.mjs",
99
+ "tools/agents/deploy-command-mirrors.mjs",
100
+ "tools/agents/deploy-options.mjs",
101
+ "tools/agents/deploy-support.mjs",
99
102
  "tools/agents/providers/",
100
103
  "tools/providers/antigravity-transport.mjs",
101
104
  "tools/commands/deploy-prompts-codex.mjs",