@aiwg/cli 2026.11.5 → 2026.11.6

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 (150) hide show
  1. package/agentic/code/providers/model-capabilities.v1.json +9 -9
  2. package/bin/aiwg.mjs +6 -4
  3. package/dist/src/activity-log/cli.js +1 -1
  4. package/dist/src/agents/agent-deployer.js +1 -1
  5. package/dist/src/artifacts/audit/types.js +1 -1
  6. package/dist/src/artifacts/discover-facets.js +1 -1
  7. package/dist/src/artifacts/enrichment/prompt.js +1 -1
  8. package/dist/src/artifacts/enrichment/types.js +1 -1
  9. package/dist/src/artifacts/views/definition.js +1 -1
  10. package/dist/src/artifacts/views/types.js +1 -1
  11. package/dist/src/catalog/cli.js +1 -1
  12. package/dist/src/catalog/cli.mjs +1 -1
  13. package/dist/src/catalog/loader.js +1 -1
  14. package/dist/src/catalog/loader.mjs +1 -1
  15. package/dist/src/catalog/types.js +1 -1
  16. package/dist/src/cli/cli-extension-loader.js +19 -5
  17. package/dist/src/cli/cli-extension-paths.js +65 -0
  18. package/dist/src/cli/handlers/best-practices-audit.js +1 -1
  19. package/dist/src/cli/handlers/help.js +3 -4
  20. package/dist/src/cli/handlers/index.js +1 -1
  21. package/dist/src/cli/handlers/marketplace-plugin-search.js +37 -0
  22. package/dist/src/cli/handlers/marketplace.js +3 -1
  23. package/dist/src/cli/handlers/models.js +1 -1
  24. package/dist/src/cli/handlers/ralph-launcher.js +8 -2
  25. package/dist/src/cli/handlers/ralph.js +1 -1
  26. package/dist/src/cli/handlers/runtime-info.js +1 -1
  27. package/dist/src/cli/handlers/scaffolding.js +2 -2
  28. package/dist/src/cli/handlers/script-runner.js +1 -1
  29. package/dist/src/cli/handlers/sdlc-accelerate.js +1 -1
  30. package/dist/src/cli/handlers/subcommands-bundles.js +1 -1
  31. package/dist/src/cli/handlers/subcommands-list-format.js +19 -1
  32. package/dist/src/cli/handlers/types.js +1 -1
  33. package/dist/src/cli/handlers/use.js +2 -2
  34. package/dist/src/cli/handlers/utilities.js +1 -1
  35. package/dist/src/cli/handlers/version.js +1 -1
  36. package/dist/src/cli/handlers/workspace.js +1 -1
  37. package/dist/src/cli/help-generator.js +9 -11
  38. package/dist/src/cli/hooks/builtin/activity-log-hook.js +1 -1
  39. package/dist/src/cli/router.js +1 -1
  40. package/dist/src/cli/workflow-orchestrator.js +1 -1
  41. package/dist/src/config/worker-context.js +37 -7
  42. package/dist/src/config/worker-parallelism.js +11 -0
  43. package/dist/src/contributors/detect.js +1 -1
  44. package/dist/src/contributors/discover.js +1 -1
  45. package/dist/src/contributors/heuristic.js +1 -1
  46. package/dist/src/contributors/index.js +1 -1
  47. package/dist/src/contributors/types.js +1 -1
  48. package/dist/src/contributors/validation.js +1 -1
  49. package/dist/src/effects/worker-delivery.js +83 -0
  50. package/dist/src/extensions/capability-index.js +1 -1
  51. package/dist/src/extensions/commands/definitions.js +2 -2
  52. package/dist/src/extensions/deployment-registration.js +1 -1
  53. package/dist/src/extensions/index.js +1 -1
  54. package/dist/src/extensions/loader.js +1 -1
  55. package/dist/src/extensions/manifest.js +4 -2
  56. package/dist/src/extensions/project-local-activity.js +1 -1
  57. package/dist/src/extensions/project-local-discovery.js +2 -2
  58. package/dist/src/extensions/project-local-doctor.js +7 -3
  59. package/dist/src/extensions/project-local-promote.js +3 -3
  60. package/dist/src/extensions/project-local-remove.js +3 -3
  61. package/dist/src/extensions/project-local-scaffold.js +1 -1
  62. package/dist/src/extensions/registry.js +1 -1
  63. package/dist/src/extensions/shadow-resolver.js +1 -1
  64. package/dist/src/extensions/types.js +1 -1
  65. package/dist/src/extensions/upstream-registry.js +1 -1
  66. package/dist/src/extensions/validation.js +1 -1
  67. package/dist/src/intake/git-history-analyzer.js +1 -1
  68. package/dist/src/kb/cli.js +1 -1
  69. package/dist/src/marketplace/plugin-directory.js +36 -0
  70. package/dist/src/marketplace/plugin-search.js +180 -0
  71. package/dist/src/mcp/cli.mjs +2 -2
  72. package/dist/src/mcp/helpers.mjs +1 -1
  73. package/dist/src/mcp/http-tools.mjs +8 -6
  74. package/dist/src/mcp/http-transport.mjs +3 -1
  75. package/dist/src/mcp/server.mjs +1 -1
  76. package/dist/src/mcp/tools/command-run.mjs +1 -1
  77. package/dist/src/mcp/tools/discovery.mjs +1 -1
  78. package/dist/src/mcp/tools/subsystems.mjs +1 -1
  79. package/dist/src/mcp/tools/worker-invoke.mjs +68 -22
  80. package/dist/src/mcp/tools/worker-local-only-preflight.mjs +79 -0
  81. package/dist/src/mcp/tools/worker-recorded-launch.mjs +26 -0
  82. package/dist/src/mcp/tools/worker-stdin-runtime.mjs +33 -6
  83. package/dist/src/mcp/tools/worker-verify-deliver-schema.mjs +33 -0
  84. package/dist/src/mcp/tools/worker-verify-deliver.mjs +27 -0
  85. package/dist/src/models/catalog-policy.js +2 -2
  86. package/dist/src/models/conductor-data-policy.mjs +83 -14
  87. package/dist/src/models/config-loader.js +2 -2
  88. package/dist/src/models/index.js +2 -2
  89. package/dist/src/models/local-endpoint-models.js +155 -0
  90. package/dist/src/models/model-capabilities.v1.json +9 -9
  91. package/dist/src/models/model-discovery.js +9 -5
  92. package/dist/src/models/opencode-worker-model.mjs +16 -0
  93. package/dist/src/models/resolver.js +2 -2
  94. package/dist/src/models/worker-installation.mjs +5 -3
  95. package/dist/src/models/worker-plan.js +1 -1
  96. package/dist/src/plugin/plugin-installer.js +2 -2
  97. package/dist/src/plugin/registry-validator.js +2 -2
  98. package/dist/src/plugin/skill-command-translator.js +1 -1
  99. package/dist/src/rlm/cache/hash.js +1 -1
  100. package/dist/src/rlm/cache/store.js +1 -1
  101. package/dist/src/rlm/cache/types.js +1 -1
  102. package/dist/src/serve/worker-invocation-preparation.js +13 -0
  103. package/dist/src/serve/worker-invocation.js +21 -6
  104. package/dist/src/skills/run.js +0 -11
  105. package/dist/src/smiths/agentsmith/generator.js +1 -1
  106. package/dist/src/smiths/context-pipeline/index.js +1 -1
  107. package/dist/src/smiths/context-pipeline/provider-policy.js +1 -1
  108. package/dist/src/smiths/context-pipeline/types.js +1 -1
  109. package/dist/src/smiths/mcpsmith/analyzers/cli-analyzer.js +2 -2
  110. package/dist/src/smiths/mcpsmith/generator.js +2 -2
  111. package/dist/src/smiths/mcpsmith/index.js +2 -2
  112. package/dist/src/smiths/mcpsmith/types.js +2 -2
  113. package/dist/src/smiths/skillsmith/collision-detector.js +1 -1
  114. package/dist/src/smiths/skillsmith/namespace-adapter.js +1 -1
  115. package/dist/src/smiths/toolsmith/runtime-discovery.mjs +2 -2
  116. package/dist/src/smiths/toolsmith/types.js +2 -2
  117. package/dist/src/storage/backends/fortemi.js +1 -1
  118. package/dist/src/storage/backends/fs.js +1 -1
  119. package/dist/src/storage/backends/logseq.js +1 -1
  120. package/dist/src/storage/backends/obsidian.js +1 -1
  121. package/dist/src/storage/cli.js +2 -2
  122. package/dist/src/storage/config.js +1 -1
  123. package/dist/src/storage/index.js +1 -1
  124. package/dist/src/storage/subsystem-cli.js +1 -1
  125. package/dist/src/storage/types.js +1 -1
  126. package/dist/src/testing/generators/test-case-generator.js +1 -1
  127. package/dist/src/writing/validation-engine.js +1 -1
  128. package/package.json +11 -1
  129. package/schemas/models/model-catalog.v1.schema.json +6 -3
  130. package/tools/agents/providers/conductor-data-guard.mjs +1 -1
  131. package/tools/ralph-external/lib/mcp-worker-launch.mjs +67 -0
  132. package/tools/ralph-external/lib/opencode-adapter.mjs +9 -7
  133. package/tools/ralph-external/lib/trusted-verification.mjs +1021 -0
  134. package/tools/ralph-external/lib/typed-stop-delivery.mjs +46 -0
  135. package/tools/ralph-external/lib/verification-isolation.mjs +509 -0
  136. package/tools/ralph-external/lib/worker-context.mjs +3 -3
  137. package/tools/ralph-external/lib/worker-delivery-guards.mjs +95 -0
  138. package/tools/ralph-external/lib/worker-delivery-record.mjs +15 -0
  139. package/tools/ralph-external/lib/worker-final.mjs +4 -1
  140. package/tools/ralph-external/lib/worker-isolation-status.mjs +3 -0
  141. package/tools/ralph-external/lib/worker-launch-cli.mjs +8 -0
  142. package/tools/ralph-external/lib/worker-local-only-paths.mjs +45 -0
  143. package/tools/ralph-external/lib/worker-prompt.mjs +4 -1
  144. package/tools/ralph-external/lib/worker-retry-evidence.mjs +2 -1
  145. package/tools/ralph-external/lib/worker-run-directory.mjs +45 -0
  146. package/tools/ralph-external/lib/worker-unit-cleanup.mjs +10 -2
  147. package/tools/ralph-external/lib/worker-verification-cli.mjs +164 -0
  148. package/tools/ralph-external/lib/worktree-preparation.mjs +417 -0
  149. package/tools/ralph-external/session-launcher.mjs +8 -15
  150. package/vscode-extension/schemas/aiwg.config.v1.json +27 -0
@@ -5,7 +5,7 @@
5
5
  * error messages. Ensures extension manifests conform to the unified schema.
6
6
  *
7
7
  * @implements @.aiwg/requirements/use-cases/UC-003-extension-validation.md
8
- * @architecture @.aiwg/architecture/unified-extension-schema.md
8
+ * @architecture @docs/architecture/cli/extending-cli.md
9
9
  * @tests @test/unit/extensions/validation.test.ts
10
10
  * @version 1.0.0
11
11
  */
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @module src/intake/git-history-analyzer
8
8
  * @implements @.aiwg/requirements/use-cases/UC-003-generate-intake-from-codebase.md
9
- * @architecture @.aiwg/architecture/software-architecture-doc.md - Section 5.2 Intake Coordinator
9
+ * @architecture @docs/architecture/cli/index.md
10
10
  * @tests @test/unit/intake/git-history-analyzer.test.ts
11
11
  * @command @.claude/commands/intake-from-codebase.md
12
12
  * @agent @agentic/code/frameworks/sdlc-complete/agents/intake-coordinator.md
@@ -13,7 +13,7 @@
13
13
  * put <path> Write stdin contents to an entry (creates parents)
14
14
  * delete <path> Delete an entry (no-op if missing)
15
15
  *
16
- * @design @.aiwg/architecture/storage-design.md (§4, §5)
16
+ * @design @docs/storage/overview.md
17
17
  * @issue #934
18
18
  * @issue #965
19
19
  */
@@ -0,0 +1,36 @@
1
+ const record = (value) => value !== null && typeof value === 'object' ? value : {};
2
+ export function repositoryKey(value) {
3
+ if (typeof value !== 'string')
4
+ return null;
5
+ try {
6
+ const url = new URL(value);
7
+ return `${url.hostname.toLowerCase()}${url.pathname.replace(/\.git\/?$/, '').replace(/\/$/, '')}`.toLowerCase();
8
+ }
9
+ catch {
10
+ return /^[\w.-]+\/[\w.-]+$/.test(value) ? `github.com/${value.toLowerCase().replace(/\.git$/, '')}` : null;
11
+ }
12
+ }
13
+ export function pluginRepository(plugin, marketplaceSource) {
14
+ const source = record(record(plugin).source);
15
+ const market = record(marketplaceSource);
16
+ return repositoryKey(source.url ?? source.repo) ?? repositoryKey(market.repo ?? market.url);
17
+ }
18
+ export function normalizeDirectoryListing(raw, entryNames, targets) {
19
+ const entry = record(raw);
20
+ if (typeof entry.id !== 'string')
21
+ return null;
22
+ const repository = record(record(entry.source).repository);
23
+ const key = repositoryKey(repository.url);
24
+ const slug = record(entryNames)[entry.id];
25
+ const name = typeof slug === 'string' && slug ? slug : typeof entry.name === 'string' ? entry.name : null;
26
+ if (!name)
27
+ return null;
28
+ const matches = targets.filter(target => key !== null && target.repository === key && target.name === name);
29
+ const matching = matches.length === 1 ? matches[0] : undefined;
30
+ return {
31
+ plugin: { ...entry, name, description: entry.summary, repository: repository.url },
32
+ marketplace: matching?.marketplace ?? undefined,
33
+ directoryId: matching ? undefined : entry.id,
34
+ };
35
+ }
36
+ //# sourceMappingURL=plugin-directory.js.map
@@ -0,0 +1,180 @@
1
+ // Read provider-owned plugin manifests and caches without fetching or changing state.
2
+ import { normalizeDirectoryListing, pluginRepository, repositoryKey } from './plugin-directory.js';
3
+ import fs from 'node:fs';
4
+ import os from 'node:os';
5
+ import path from 'node:path';
6
+ const object = (value) => value !== null && typeof value === 'object' && !Array.isArray(value)
7
+ ? value : {};
8
+ const string = (value) => typeof value === 'string' && value.trim() ? value : undefined;
9
+ function date(value) {
10
+ if (typeof value !== 'string' && typeof value !== 'number')
11
+ return null;
12
+ const milliseconds = typeof value === 'number' && value < 1e12 ? value * 1000 : value;
13
+ const parsed = new Date(milliseconds);
14
+ return Number.isFinite(parsed.getTime()) ? parsed.toISOString() : null;
15
+ }
16
+ function asOf(value) {
17
+ return date(value.lastUpdated ?? value.updatedAt ?? value.fetchedAt ?? value.timestamp);
18
+ }
19
+ function entries(value) {
20
+ return Array.isArray(value) ? value.map((entry, index) => [String(index), entry]) : Object.entries(object(value));
21
+ }
22
+ export function searchProviderPlugins(query, options = {}) {
23
+ const maxAgeDays = options.maxAgeDays ?? 30;
24
+ if (!Number.isFinite(maxAgeDays) || maxAgeDays < 0)
25
+ throw new Error('--max-age-days must be a non-negative number');
26
+ const report = {
27
+ query, marketplaces: [], results: [], warnings: [],
28
+ ranking: 'Matched terms, review tier (anthropic > partner > none/unknown), installs, cache date; descending. Signals are observations, not ratings or capability measurements.',
29
+ };
30
+ const provider = options.provider ?? 'all';
31
+ if (!['all', 'claude', 'codex'].includes(provider))
32
+ throw new Error('Plugin search supports --provider all, claude or codex');
33
+ if (provider !== 'claude')
34
+ report.warnings.push('Codex marketplace.json search deferred pending a stable local manifest/configuration contract (#783). Other provider formats are not yet supported.');
35
+ if (provider === 'codex')
36
+ return report;
37
+ const base = path.join(options.claudeConfigDir ?? process.env.CLAUDE_CONFIG_DIR
38
+ ?? path.join(options.home ?? os.homedir(), '.claude'), 'plugins');
39
+ const now = options.now ?? Date.now();
40
+ function read(file, required = false) {
41
+ try {
42
+ const parsed = JSON.parse(fs.readFileSync(file, 'utf8'));
43
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
44
+ throw new Error('Expected a JSON object');
45
+ return object(parsed);
46
+ }
47
+ catch (error) {
48
+ if (required || error.code !== 'ENOENT') {
49
+ report.warnings.push(`Unable to read marketplace data: ${file}`);
50
+ }
51
+ return null;
52
+ }
53
+ }
54
+ function checkAge(file, timestamp) {
55
+ if (!timestamp)
56
+ report.warnings.push(`Cache date unknown: ${file}`);
57
+ else if (Date.parse(timestamp) > now)
58
+ report.warnings.push(`Cache date is in the future: ${file} (as of ${timestamp})`);
59
+ else if (now - Date.parse(timestamp) > maxAgeDays * 86_400_000) {
60
+ report.warnings.push(`Stale cache: ${file} (as of ${timestamp}; maximum age ${maxAgeDays} days)`);
61
+ }
62
+ }
63
+ const results = new Map();
64
+ function add(raw, marketplace, source, timestamp, key, directoryId, repository) {
65
+ const entry = object(raw);
66
+ const plugin = Object.keys(object(entry.plugin)).length ? object(entry.plugin) : entry;
67
+ const coordinate = string(entry.id) ?? (key?.includes('@') ? key : undefined);
68
+ const split = coordinate?.lastIndexOf('@') ?? -1;
69
+ const name = string(plugin.name) ?? (split > 0 ? coordinate?.slice(0, split) : undefined);
70
+ const market = marketplace ?? string(entry.marketplace) ?? string(object(entry.marketplace).name)
71
+ ?? string(entry.marketplaceName) ?? (split > 0 ? coordinate?.slice(split + 1) : undefined);
72
+ if (!name || (!market && !directoryId))
73
+ return;
74
+ const id = directoryId ? `directory:${directoryId}` : `${name}@${market}`;
75
+ const previous = results.get(id);
76
+ const keywords = Array.isArray(plugin.keywords) ? plugin.keywords.filter((item) => typeof item === 'string') : [];
77
+ const reviewType = object(object(object(entry.checks).review).by).type;
78
+ const review = ['anthropic', 'partner', 'none'].includes(String(reviewType))
79
+ ? reviewType : null;
80
+ const observedAt = asOf(entry) ?? timestamp;
81
+ results.set(id, {
82
+ id, name, marketplace: market ?? null, provider: 'claude',
83
+ repository: repository ?? repositoryKey(plugin.repository) ?? previous?.repository ?? null,
84
+ description: string(plugin.description) ?? previous?.description ?? '',
85
+ category: string(plugin.category) ?? previous?.category ?? null,
86
+ keywords: [...new Set([...(previous?.keywords ?? []), ...keywords])],
87
+ sources: [...new Set([...(previous?.sources ?? []), source])],
88
+ cacheAsOf: observedAt ?? previous?.cacheAsOf ?? null,
89
+ installs: previous?.installs ?? { value: null, asOf: null },
90
+ review: review ? { value: review, asOf: observedAt } : previous?.review ?? { value: null, asOf: null },
91
+ matchedTerms: [], installSkill: 'install-plugin',
92
+ installHelp: 'aiwg show skill install-plugin',
93
+ });
94
+ }
95
+ const registryFile = path.join(base, 'known_marketplaces.json');
96
+ const registry = read(registryFile);
97
+ for (const [name, value] of Object.entries(registry ?? {}).sort(([a], [b]) => a.localeCompare(b))) {
98
+ const config = object(value);
99
+ const location = string(config.installLocation);
100
+ // Registry names must never escape the provider's marketplaces directory.
101
+ if (!location && (name === '.' || name === '..' || /[\\/]/.test(name))) {
102
+ report.warnings.push(`Invalid marketplace name: ${name}`);
103
+ continue;
104
+ }
105
+ const manifest = path.join(location ? path.resolve(base, location) : path.join(base, 'marketplaces', name), '.claude-plugin/marketplace.json');
106
+ const data = read(manifest, true);
107
+ const timestamp = asOf(data ?? {}) ?? asOf(config);
108
+ report.marketplaces.push({ name, provider: 'claude', manifest, asOf: timestamp });
109
+ if (!data)
110
+ continue;
111
+ checkAge(manifest, timestamp);
112
+ for (const [key, plugin] of entries(data.plugins))
113
+ add(plugin, name, manifest, timestamp, key, undefined, pluginRepository(plugin, config.source));
114
+ }
115
+ const directoryFile = path.join(base, 'plugin-directory-cache-v2.json');
116
+ const directory = read(directoryFile);
117
+ if (directory) {
118
+ const timestamp = asOf(directory);
119
+ checkAge(directoryFile, timestamp);
120
+ if (!directory.plugins && !directory.listings)
121
+ report.warnings.push(`Unrecognized directory cache format: ${directoryFile}`);
122
+ const manifestTargets = [...results.values()];
123
+ for (const [key, plugin] of entries(directory.plugins))
124
+ add(plugin, undefined, directoryFile, timestamp, key);
125
+ // V2 directory IDs do not encode marketplace membership. Join only on
126
+ // both repository identity and the provider's recorded entry name.
127
+ for (const [, listing] of entries(directory.listings)) {
128
+ const normalized = normalizeDirectoryListing(listing, directory.entryNames, manifestTargets);
129
+ if (normalized)
130
+ add(normalized.plugin, normalized.marketplace, directoryFile, timestamp, undefined, normalized.directoryId);
131
+ }
132
+ }
133
+ const countsFile = path.join(base, 'install-counts-cache.json');
134
+ const counts = read(countsFile);
135
+ if (counts) {
136
+ const timestamp = asOf(counts);
137
+ checkAge(countsFile, timestamp);
138
+ if (!counts.counts)
139
+ report.warnings.push(`Unrecognized install-count cache format: ${countsFile}`);
140
+ for (const [key, value] of entries(counts.counts)) {
141
+ const entry = object(value);
142
+ const id = string(entry.plugin) ?? string(entry.id) ?? key;
143
+ const result = results.get(id);
144
+ const installs = entry.unique_installs;
145
+ if (result && typeof installs === 'number' && Number.isSafeInteger(installs) && installs >= 0) {
146
+ result.installs = { value: installs, asOf: asOf(entry) ?? timestamp };
147
+ }
148
+ }
149
+ }
150
+ const terms = [...new Set(query.toLowerCase().match(/[\p{L}\p{N}]+/gu) ?? [])];
151
+ const tier = (result) => ({ anthropic: 2, partner: 1, none: 0 })[result.review.value ?? 'none'];
152
+ report.results = [...results.values()].filter(result => {
153
+ const text = [result.name, result.description, result.category, ...result.keywords].join(' ').toLowerCase();
154
+ result.matchedTerms = terms.filter(term => text.includes(term));
155
+ return terms.length > 0 && result.matchedTerms.length > 0;
156
+ }).sort((a, b) => b.matchedTerms.length - a.matchedTerms.length || tier(b) - tier(a)
157
+ || (b.installs.value ?? -1) - (a.installs.value ?? -1)
158
+ || Date.parse(b.cacheAsOf ?? '1970-01-01') - Date.parse(a.cacheAsOf ?? '1970-01-01')
159
+ || a.id.localeCompare(b.id));
160
+ if (!registry && !directory)
161
+ report.warnings.push('No local Claude marketplace manifests or directory cache found; nothing was fetched.');
162
+ return report;
163
+ }
164
+ export function formatPluginSearch(report) {
165
+ const clean = (value) => value.replace(/[\u0000-\u001f\u007f-\u009f]/g, ' ');
166
+ const lines = [`Plugin marketplace search: ${clean(report.query)}`,
167
+ `Configured marketplaces: ${report.marketplaces.map(market => clean(market.name)).join(', ') || 'none'}`,
168
+ 'Plugin / ID | Marketplace | Installs (as of) | Review (as of) | Cache as of | Description'];
169
+ for (const result of report.results)
170
+ lines.push([
171
+ clean(result.marketplace ? result.id : `${result.name} / ${result.id}`), clean(result.marketplace ?? 'unknown'),
172
+ `${result.installs.value ?? 'unknown'} (${result.installs.asOf ?? 'unknown'})`,
173
+ `${result.review.value ?? 'unknown'} (${result.review.asOf ?? 'unknown'})`, result.cacheAsOf ?? 'unknown', clean(result.description),
174
+ ].join(' | '));
175
+ if (!report.results.length)
176
+ lines.push('No results found.');
177
+ lines.push(report.ranking, 'Installation guidance for a selected ID: aiwg show skill install-plugin');
178
+ return lines.join('\n');
179
+ }
180
+ //# sourceMappingURL=plugin-search.js.map
@@ -628,7 +628,7 @@ CORE TOOLS (19, always registered):
628
628
  aiwg_authorization_grant_lookup Read-only list/search/explain of signed grants
629
629
  aiwg_authorization_grant_request Save a bounded grant only after native form confirmation
630
630
 
631
- OPT-IN TOOLSETS (71 additional tools, including explicit workers):
631
+ OPT-IN TOOLSETS (72 additional tools, including explicit workers):
632
632
  flows flow-list / flow-show / flow-run
633
633
  missions mission-guide / mission-dispatch / mission-status / worker-resolve
634
634
  memory memory-* and reflections-* storage operations
@@ -641,7 +641,7 @@ OPT-IN TOOLSETS (71 additional tools, including explicit workers):
641
641
  ops status / list / use / push
642
642
  sandbox fleet inventory / mutation / reconciliation and governed activity
643
643
  decision validation / evaluation / rules / features / calibration
644
- workers worker-invoke (explicit opt-in; all excludes workers)
644
+ workers worker-invoke, worker-verify-deliver (explicit opt-in; all excludes workers)
645
645
 
646
646
  Enable opt-in tools:
647
647
  AIWG_MCP_TOOLSETS=flows,missions,memory,kb,ralph,sandbox aiwg mcp serve
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * AIWG MCP Server — Shared Helpers
3
3
  *
4
- * @architecture @.aiwg/architecture/sketch-hermes-mcp-parity.md
4
+ * @architecture @docs/cli/agent-usage.md
5
5
  * @issues #1311 (scope split), #1312 (command-run), #1313 (discover + pairs)
6
6
  */
7
7
 
@@ -14,25 +14,27 @@ function containsCliOption(value) {
14
14
  return false;
15
15
  }
16
16
 
17
- export function remoteToolPolicy(projectDir, tools) {
17
+ export function remoteToolPolicy(projectDir, tools, { verifiedDeliveryOnly = false } = {}) {
18
18
  const selected = tools === undefined ? undefined : new Set(tools);
19
19
  const exposed = new Set();
20
20
  const children = new Set();
21
21
  let active = 0;
22
22
  return {
23
23
  configureTool(name, config, handler) {
24
- const allowed = name === 'discover' || name.endsWith('-show') || name === 'artifact-write';
24
+ const allowed = name === 'discover' || name.endsWith('-show') || (name === 'artifact-write' && !verifiedDeliveryOnly) || name === 'worker-verify-deliver' || name === 'worker-invoke';
25
25
  if (!allowed || (selected && !selected.has(name))) return undefined;
26
26
  exposed.add(name);
27
27
  const shape = config.inputSchema?.shape ?? {};
28
- const inputSchema = z.strictObject(Object.fromEntries(
29
- Object.entries(shape).filter(([key]) => !scopeFields.has(key)),
28
+ // This tool's strict publication union already excludes every scope
29
+ // override; reconstructing its shape would discard union validation.
30
+ const inputSchema = name === 'worker-verify-deliver' ? config.inputSchema : z.strictObject(Object.fromEntries(
31
+ Object.entries(shape).filter(([key]) => !scopeFields.has(key) || (name === 'worker-invoke' && key === 'workdir')),
30
32
  ));
31
33
  return { config: { ...config, inputSchema }, handler: async (args, extra) => {
32
34
  extra.signal.throwIfAborted();
33
35
  // CLI-backed cards must not reinterpret data values as scope/source flags.
34
36
  // artifact-write uses openArtifact directly and spawns no CLI.
35
- if (name !== 'artifact-write' && containsCliOption(args)) {
37
+ if (name !== 'artifact-write' && name !== 'worker-verify-deliver' && name !== 'worker-invoke' && containsCliOption(args)) {
36
38
  throw new Error('Tool arguments must not contain CLI options');
37
39
  }
38
40
  active++;
@@ -44,7 +46,7 @@ export function remoteToolPolicy(projectDir, tools) {
44
46
  drain: () => Promise.allSettled([...children]),
45
47
  validate() {
46
48
  if (selected && [...selected].some(name => !exposed.has(name))) {
47
- throw new Error('--tools must name only available discover, *-show or artifact-write tools; enable required --toolsets explicitly');
49
+ throw new Error('--tools must name only available discover, *-show, artifact-write, worker-invoke or worker-verify-deliver tools; enable required --toolsets explicitly');
48
50
  }
49
51
  },
50
52
  };
@@ -38,6 +38,8 @@ async function readBody(request, response) {
38
38
  export async function startHttpServer(options) {
39
39
  const host = options.host === '[::1]' ? '::1' : options.host ?? '127.0.0.1';
40
40
  const loopback = host === '127.0.0.1' || host === '::1' || host === 'localhost';
41
+ const workersEnabled = String(options.toolsets ?? '').split(',').map(value => value.trim()).includes('workers');
42
+ if (!loopback && workersEnabled) throw new Error('The workers toolset requires a localhost HTTP bind');
41
43
  if (!loopback && !options.allowRemoteBind) {
42
44
  throw new Error('A non-loopback --host requires --allow-remote-bind');
43
45
  }
@@ -58,7 +60,7 @@ export async function startHttpServer(options) {
58
60
  let closing = false;
59
61
  let stopPromise;
60
62
  const buildServer = async () => {
61
- const policy = remoteToolPolicy(projectDir, options.tools);
63
+ const policy = remoteToolPolicy(projectDir, options.tools, { verifiedDeliveryOnly: workersEnabled });
62
64
  const mcp = await createServer({ projectDir, artifactStore, toolsets: options.toolsets ?? '', configureTool: policy.configureTool });
63
65
  try { policy.validate(); } catch (error) { await mcp.close(); throw error; }
64
66
  policies.set(mcp, policy);
@@ -5,7 +5,7 @@
5
5
  * Follows MCP 2025-11-25 specification.
6
6
  *
7
7
  * @see https://modelcontextprotocol.io/specification/2025-11-25
8
- * @architecture @.aiwg/architecture/software-architecture-doc.md - Section 2.1 CLI Layer
8
+ * @architecture @docs/architecture/cli/index.md
9
9
  * @reference @docs/references/REF-066-mcp-specification-2025.md
10
10
  * @cli @docs/cli/agent-usage.md - mcp serve command
11
11
  * @frameworks @agentic/code/frameworks/sdlc-complete/
@@ -11,7 +11,7 @@
11
11
  * - `shell: false` enforced in spawn
12
12
  * - Destructive commands require `confirmed: true`
13
13
  *
14
- * @architecture @.aiwg/architecture/sketch-hermes-mcp-parity.md DD-4
14
+ * @architecture @docs/cli/agent-usage.md
15
15
  * @issues #1312 (S1)
16
16
  * @rules @token-security, @anti-laziness
17
17
  */
@@ -17,7 +17,7 @@
17
17
  *
18
18
  * All are global-allowed (#1311) — work without a project root.
19
19
  *
20
- * @architecture @.aiwg/architecture/sketch-hermes-mcp-parity.md
20
+ * @architecture @docs/cli/agent-usage.md
21
21
  * @issues #1311 (scope split), #1313 (discover + pairs), #1320 (rule-list/show)
22
22
  */
23
23
 
@@ -9,7 +9,7 @@
9
9
  * Default toolset enabled: `core` (already registered by discovery.mjs +
10
10
  * command-run.mjs in server.mjs).
11
11
  *
12
- * @architecture @.aiwg/architecture/sketch-hermes-mcp-parity.md DD-3
12
+ * @architecture @docs/cli/agent-usage.md
13
13
  * @issues #1322 (memory) #1323 (kb) #1324 (provenance) #1325 (activity-log)
14
14
  * #1326 (index) #1327 (ralph) #1328 (ops) #1331 (mc) #1332 (dispatch)
15
15
  */
@@ -156,7 +156,9 @@
156
156
  * @issues #2892, #2896 (review reference, not reused as-is)
157
157
  */
158
158
 
159
+ import { registerWorkerVerifyDeliverTool } from './worker-verify-deliver.mjs';
159
160
  import { workerFailureDiagnostics } from './worker-failure-diagnostics.mjs';
161
+ import { workerLocalOnlyPreflight } from './worker-local-only-preflight.mjs';
160
162
  import { signalChild } from '../../process/signal-child.mjs';
161
163
  import { z } from 'zod';
162
164
 
@@ -177,6 +179,7 @@ import path from 'node:path';
177
179
  import { fileURLToPath, pathToFileURL } from 'node:url';
178
180
  import { mcpError, mcpJson } from '../helpers.mjs';
179
181
  import { buildShellStopControl, waitForUnitTermination } from './worker-shell-control.mjs';
182
+ import { recordedShellLauncher } from './worker-recorded-launch.mjs';
180
183
  import { launchPreparedShellWorker, sweepWorkerStdin, markWorkerServer } from './worker-stdin-runtime.mjs';
181
184
  // NOTE: no static import of ../../config/worker-context.js here. That
182
185
  // module is TypeScript: a literal relative import resolves under vitest
@@ -613,7 +616,39 @@ async function loadRalphExternal(relativeFromToolsRoot) {
613
616
  * in-process instead of shelling out to `aiwg models resolve`. */
614
617
  async function defaultLoadWorkerInputs(servedRoot) {
615
618
  const { loadWorkerInputs } = await loadModelsHandlerInternals();
616
- return loadWorkerInputs({ cwd: servedRoot, args: ['resolve'], rawArgs: ['models', 'resolve'], frameworkRoot: findOwnPackageRoot() });
619
+ return loadWorkerInputs(servedWorkerInputsContext(servedRoot));
620
+ }
621
+
622
+ /** Same context shape as the launcher's in-process loader. A bare `resolve`
623
+ * subcommand made the host-resource sampler parse a request with no flags
624
+ * and fail every real launch with `Missing role` (#4148). */
625
+ /** A shell worker's final file holds either plain workerClaims JSON (what
626
+ * real workers write, and what the launcher's own final collection reads) or
627
+ * a JSONL result stream. Parsing plain claims as JSONL rejected every real
628
+ * worker final with OG_CONTRACT_INVALID (#4151). The adapter still performs
629
+ * the strict decode and schema validation for either framing. */
630
+ export function shellFinalFormat(rawOutput) {
631
+ try {
632
+ const text = typeof rawOutput === 'string' ? rawOutput : Buffer.from(rawOutput).toString('utf8');
633
+ const value = JSON.parse(text);
634
+ return value && typeof value === 'object' && !Array.isArray(value) && !Object.hasOwn(value, 'type') ? 'json' : 'jsonl';
635
+ } catch {
636
+ return 'jsonl';
637
+ }
638
+ }
639
+
640
+ /** systemd collects a unit that exits successfully, so the legacy dispatch path cannot observe a
641
+ * clean exit (#4157). Name the owned-capture route instead of a misleading contract error. */
642
+ export function unobservedSystemdExit(invocation, outcome) {
643
+ if (invocation?.isolation !== 'systemd-unit' || outcome?.termination !== 'confirmed' || outcome.exitCode !== null
644
+ || outcome.timedOut || outcome.stopped || outcome.neverExecuted) return null;
645
+ return { code: 'OG_WORKER_EXIT_UNOBSERVED',
646
+ message: 'The systemd worker unit ended but its exit status could not be observed (systemd collects units that exit successfully); its result is unknown and the worker tree is retained.',
647
+ remedy: 'Pass run_dir to worker-invoke so the launcher owns capture and records the exit status and final output.' };
648
+ }
649
+
650
+ export function servedWorkerInputsContext(servedRoot) {
651
+ return { cwd: servedRoot, args: [], rawArgs: [], frameworkRoot: findOwnPackageRoot() };
617
652
  }
618
653
 
619
654
  /** #2892 D1: the registry's default `maxActive` respects the project's own
@@ -666,7 +701,7 @@ async function loadWorkerContextModule() {
666
701
  * provider's bootstrap is missing; an unmappable CLI refuses with the
667
702
  * typed diagnostic, since no deploy could target it. */
668
703
  async function ensureWorkerContextForInvocation({ invocation, config }) {
669
- const { ensureWorkerContextBootstrap, mapCliToProviderId, resolveWorkerContextProvidersFromConfig, WorkerContextBootstrapError } =
704
+ const { ensureWorkerContextBootstrap, mapCliToProviderId, WorkerContextBootstrapError } =
670
705
  await loadWorkerContextModule();
671
706
  const cli = invocation?.selected?.cli;
672
707
  const mapped = mapCliToProviderId(cli, config?.parallelism);
@@ -677,13 +712,7 @@ async function ensureWorkerContextForInvocation({ invocation, config }) {
677
712
  { workdir: invocation?.cwd },
678
713
  );
679
714
  }
680
- let providers = [mapped.provider];
681
- try {
682
- providers = [...new Set([...resolveWorkerContextProvidersFromConfig(config).providers, mapped.provider])];
683
- } catch {
684
- providers = [mapped.provider];
685
- }
686
- return ensureWorkerContextBootstrap({ workdir: invocation?.cwd, provider: mapped.provider, providers });
715
+ return ensureWorkerContextBootstrap({ workdir: invocation?.cwd, provider: mapped.provider, providers: [mapped.provider], projectLocal: true });
687
716
  }
688
717
 
689
718
  /** Refuse a failed bootstrap ensure as a typed blocked diagnostic that
@@ -733,7 +762,7 @@ async function defaultLaunchShellWorkerBaseline(invocation, { memoryMaxGb = DEFA
733
762
  return launchIsolatedWorker({
734
763
  command: invocation?.argv?.[0], args: invocation?.argv?.slice(1) ?? [], cwd,
735
764
  stdoutPath: invocation?.stdoutPath, stderrPath: invocation?.stderrPath, envNames: invocation?.envNames,
736
- ...launchOptions, gate,
765
+ ...launchOptions, workerGroup: invocation?.selected?.group, gate,
737
766
  });
738
767
  },
739
768
  };
@@ -1595,6 +1624,7 @@ async function defaultCallMcpWorker(mcpBinding, server, options = {}) {
1595
1624
  function publicStatus(entry, healthHook) {
1596
1625
  const base = {
1597
1626
  invocationId: entry.invocationId,
1627
+ run_dir: entry.run_dir ?? null,
1598
1628
  requestId: entry.requestId,
1599
1629
  status: entry.status ?? (entry.terminalAt === null ? 'running' : 'uncertain'),
1600
1630
  termination: entry.termination ?? 'running',
@@ -1625,6 +1655,7 @@ const inputSchema = z.strictObject({
1625
1655
  // authorized reconciliation operation on this SAME handler (never a
1626
1656
  // mailbox file, never a new breaker) — see `reconcileStopped` below.
1627
1657
  operation: z.enum(['run', 'status', 'cancel', 'reconcile_stopped', 'reset_recovery_scope']),
1658
+ run_dir: z.string().startsWith('/').max(4096).refine(value => !value.includes('\0')).optional(),
1628
1659
  invocation_id: invocationUuid().optional(),
1629
1660
  scope_id: z.string().min(1).max(512).optional(),
1630
1661
  request_id: z.string().min(1).max(128).regex(/^[a-zA-Z0-9_.:-]+$/).optional(),
@@ -1661,6 +1692,10 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
1661
1692
  return;
1662
1693
  }
1663
1694
  const servedRootReal = await resolveServedProjectRoot(options.projectRoot);
1695
+ registerWorkerVerifyDeliverTool(server, { projectRoot: servedRootReal,
1696
+ assertPath: candidate => assertServedPath(servedRootReal, candidate),
1697
+ verify: async input => (await loadRalphExternal('lib/worker-verification-cli.mjs')).verifyWorkerRun(input),
1698
+ });
1664
1699
  await sweepWorkerStdin(options.stdinRuntimeRoot);
1665
1700
  // Pinned once, here, at registration — never re-resolved per request, and
1666
1701
  // never re-derived from `process.cwd()` (#2892 B1).
@@ -1673,7 +1708,10 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
1673
1708
  const ttlMs = options.ttlMs ?? resolveServerTerminalTtlMs();
1674
1709
  const registry = options.registry ?? createInvocationRegistry({ now: options.now, maxActive, ttlMs });
1675
1710
  const loadWorkerInputsImpl = options.loadWorkerInputs ?? defaultLoadWorkerInputs;
1676
- const launchShellWorkerImpl = options.launchShellWorker ?? defaultLaunchShellWorker;
1711
+ const recordedShell = recordedShellLauncher({ loadRalphExternal, loadInputs: () => loadWorkerInputsImpl(servedRootReal),
1712
+ assertPath: candidate => assertServedPath(servedRootReal, candidate), registry, now: options.now ?? (() => new Date()) });
1713
+ const launchShellWorkerImpl = options.launchShellWorker ?? ((invocation, context) => recordedShell.requested(invocation)
1714
+ ? recordedShell.launch(invocation, context) : defaultLaunchShellWorker(invocation, context));
1677
1715
  const callMcpWorkerImpl = options.callMcpWorker ?? defaultCallMcpWorker;
1678
1716
  // Both continuations use the audited observer and hardened stop controls.
1679
1717
  const waitForUnitTerminationOverride = options.waitForUnitTermination;
@@ -1810,17 +1848,13 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
1810
1848
  const root = await servedRoot();
1811
1849
  const { snapshot, drivers } = await loadWorkerInputsImpl(root);
1812
1850
  const { resolveWorkerInvocation } = await loadServeWorkerInvocation();
1813
- const plan = await resolveWorkerInvocation(snapshot, request, drivers, now().toISOString());
1851
+ let plan = await resolveWorkerInvocation(snapshot, request, drivers, now().toISOString());
1852
+ plan = await recordedShell.bindPlan(plan, { resolve: resolveWorkerInvocation, snapshot, drivers, at: now().toISOString(), invocationId: entry.invocationId, input });
1814
1853
  if (plan.invocation?.readiness !== 'launchable') {
1815
1854
  return markTerminal({ status: 'blocked', termination: 'confirmed', diagnostics: plan.diagnostics ?? [] });
1816
1855
  }
1817
- if (plan.invocation.isolation === 'native-sandbox') {
1818
- return markTerminal({ status: 'blocked', termination: 'confirmed', diagnostics: [{
1819
- code: 'OG_POLICY_RELAXATION', pointer: '/worker/isolation',
1820
- message: 'MCP worker-invoke run does not support pinned native-sandbox isolation',
1821
- }] });
1822
- }
1823
1856
  prefix = { root, snapshot, drivers, invocation: plan.invocation };
1857
+ recordedShell.prepare(plan.invocation, { plan, input, invocationId: entry.invocationId, releaseOutput: cleanupReservation });
1824
1858
  } catch (error) {
1825
1859
  return markTerminal({ status: 'blocked', termination: 'confirmed', diagnostics: [error.message] });
1826
1860
  }
@@ -1844,6 +1878,11 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
1844
1878
  }
1845
1879
  }
1846
1880
 
1881
+ try {
1882
+ const diagnostic = await workerLocalOnlyPreflight({ root, snapshot, invocation, drivers });
1883
+ if (diagnostic) return markTerminal({ status: 'blocked', termination: 'confirmed', diagnostics: [diagnostic] });
1884
+ } catch (error) { return markTerminal({ status: 'blocked', termination: 'confirmed', diagnostics: [error.message] }); }
1885
+
1847
1886
  // =========================================================================
1848
1887
  // #2915 round 8 (D6): ONE decision, immediately after the prefix, from
1849
1888
  // the launcher's own pure eligibility predicate,
@@ -2020,7 +2059,7 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
2020
2059
  // M2: a live stop handle for the duration of this call, so an
2021
2060
  // explicit `cancel` can actually stop the isolated unit / kill the
2022
2061
  // child, not just record that cancellation was requested.
2023
- const control = buildShellStopControl(launch, {
2062
+ const control = launch.control ?? buildShellStopControl(launch, {
2024
2063
  waitForUnit: (waitForUnitTerminationOverride ?? waitForUnitTerminationBaseline),
2025
2064
  stopUnit: options.stopWorkerUnit,
2026
2065
  killUnit: options.killWorkerUnit,
@@ -2062,6 +2101,8 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
2062
2101
  status: registry.get(entry.invocationId)?.cancelRequested ? 'cancelled' : 'failed',
2063
2102
  diagnostics: [outcome.timedOut ? 'worker deadline exceeded; termination confirmed' : 'worker stopped; termination confirmed'] });
2064
2103
  }
2104
+ const unobserved1 = unobservedSystemdExit(invocation, outcome);
2105
+ if (unobserved1) return registry.markTerminal(entry.invocationId, { status: 'failed', termination: 'confirmed', diagnostics: [unobserved1] });
2065
2106
  try { rawOutput = await readBoundedFile(invocation.finalPath, invocation.maxOutputBytes, root); } catch {
2066
2107
  return registry.markTerminal(entry.invocationId, { status: 'failed', termination: 'confirmed', diagnostics: ['worker final output was not written'] });
2067
2108
  }
@@ -2114,7 +2155,7 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
2114
2155
  let claims;
2115
2156
  try {
2116
2157
  claims = await new (class extends ProviderAdapter {})().parseWorkerFinal(rawOutput, {
2117
- format: invocation.transport === 'shell' ? 'jsonl' : 'mcp', observation, maxOutputBytes: invocation.maxOutputBytes,
2158
+ format: invocation.transport === 'shell' ? shellFinalFormat(rawOutput) : 'mcp', observation, maxOutputBytes: invocation.maxOutputBytes,
2118
2159
  });
2119
2160
  } catch (error) {
2120
2161
  // M5: bounded, fixed-vocabulary diagnostic only — never the raw
@@ -2405,7 +2446,7 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
2405
2446
  // "remaining from right now" so time already spent launching is
2406
2447
  // never double-counted.
2407
2448
  let deadlineMs = Math.max(0, deadlineAtMs - deadlineClockNow());
2408
- const control = buildShellStopControl(launch, {
2449
+ const control = launch.control ?? buildShellStopControl(launch, {
2409
2450
  waitForUnit: (unit, budgetMs, observerOptions) => (waitForUnitTerminationOverride ?? waitForUnitTermination)(unit,
2410
2451
  budgetMs, { ...observerOptions, clock: deadlineClockNow }),
2411
2452
  nowMs: deadlineClockNow,
@@ -2501,6 +2542,11 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
2501
2542
  status: registry.get(entry.invocationId)?.cancelRequested ? 'cancelled' : 'failed',
2502
2543
  diagnostics: [outcome.timedOut ? 'worker deadline exceeded; termination confirmed' : 'worker stopped; termination confirmed'] });
2503
2544
  }
2545
+ const unobserved2 = unobservedSystemdExit(invocation, outcome);
2546
+ if (unobserved2) {
2547
+ settleRecovery({ kind: 'failed', confirmedStop });
2548
+ return registry.markTerminal(entry.invocationId, { status: 'failed', termination: 'confirmed', diagnostics: [unobserved2] });
2549
+ }
2504
2550
  try { rawOutput = await readBoundedFile(invocation.finalPath, invocation.maxOutputBytes, root); } catch {
2505
2551
  // #2915 review 5 (finding 1a): a confirmed clean exit that never
2506
2552
  // produced a readable final output is not a success -- settle
@@ -2671,7 +2717,7 @@ export async function registerWorkerInvokeToolset(server, options = {}) {
2671
2717
  let claims;
2672
2718
  try {
2673
2719
  claims = await new (class extends ProviderAdapter {})().parseWorkerFinal(rawOutput, {
2674
- format: invocation.transport === 'shell' ? 'jsonl' : 'mcp', observation, maxOutputBytes: invocation.maxOutputBytes,
2720
+ format: invocation.transport === 'shell' ? shellFinalFormat(rawOutput) : 'mcp', observation, maxOutputBytes: invocation.maxOutputBytes,
2675
2721
  });
2676
2722
  } catch (error) {
2677
2723
  // #2915 review 5 (finding 1a): the strict parse itself rejected the