@aiwg/cli 2026.11.4 → 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.
- package/agentic/code/providers/capability-matrix.yaml +75 -5
- package/agentic/code/providers/model-capabilities.v1.json +44 -36
- package/bin/aiwg.mjs +6 -4
- package/dist/src/activity-log/cli.js +1 -1
- package/dist/src/agents/agent-deployer.js +1 -1
- package/dist/src/artifacts/audit/types.js +1 -1
- package/dist/src/artifacts/discover-facets.js +1 -1
- package/dist/src/artifacts/enrichment/prompt.js +1 -1
- package/dist/src/artifacts/enrichment/types.js +1 -1
- package/dist/src/artifacts/index-builder.js +4 -2
- package/dist/src/artifacts/query-engine-rules.js +2 -2
- package/dist/src/artifacts/types.js +1 -1
- package/dist/src/artifacts/views/definition.js +1 -1
- package/dist/src/artifacts/views/types.js +1 -1
- package/dist/src/catalog/cli.js +1 -1
- package/dist/src/catalog/cli.mjs +1 -1
- package/dist/src/catalog/loader.js +1 -1
- package/dist/src/catalog/loader.mjs +1 -1
- package/dist/src/catalog/types.js +1 -1
- package/dist/src/cli/cli-extension-loader.js +19 -5
- package/dist/src/cli/cli-extension-paths.js +65 -0
- package/dist/src/cli/handlers/best-practices-audit.js +1 -1
- package/dist/src/cli/handlers/help.js +3 -4
- package/dist/src/cli/handlers/index.js +1 -1
- package/dist/src/cli/handlers/marketplace-plugin-search.js +37 -0
- package/dist/src/cli/handlers/marketplace.js +3 -1
- package/dist/src/cli/handlers/models.js +1 -1
- package/dist/src/cli/handlers/ralph-launcher.js +8 -2
- package/dist/src/cli/handlers/ralph.js +1 -1
- package/dist/src/cli/handlers/runtime-info.js +1 -1
- package/dist/src/cli/handlers/scaffolding.js +2 -2
- package/dist/src/cli/handlers/script-runner.js +8 -5
- package/dist/src/cli/handlers/sdlc-accelerate.js +1 -1
- package/dist/src/cli/handlers/steward-format.js +12 -0
- package/dist/src/cli/handlers/subcommands-bundles.js +1 -1
- package/dist/src/cli/handlers/subcommands-list-format.js +19 -1
- package/dist/src/cli/handlers/types.js +1 -1
- package/dist/src/cli/handlers/use.js +15 -6
- package/dist/src/cli/handlers/utilities.js +1 -1
- package/dist/src/cli/handlers/utility-doctor.js +4 -0
- package/dist/src/cli/handlers/version.js +1 -1
- package/dist/src/cli/handlers/workspace.js +1 -1
- package/dist/src/cli/help-generator.js +9 -11
- package/dist/src/cli/hooks/builtin/activity-log-hook.js +1 -1
- package/dist/src/cli/router.js +1 -1
- package/dist/src/cli/workflow-orchestrator.js +1 -1
- package/dist/src/config/worker-context.js +37 -7
- package/dist/src/config/worker-parallelism.js +11 -0
- package/dist/src/contributors/detect.js +1 -1
- package/dist/src/contributors/discover.js +1 -1
- package/dist/src/contributors/heuristic.js +1 -1
- package/dist/src/contributors/index.js +1 -1
- package/dist/src/contributors/types.js +1 -1
- package/dist/src/contributors/validation.js +1 -1
- package/dist/src/effects/worker-delivery.js +83 -0
- package/dist/src/extensions/capability-index.js +1 -1
- package/dist/src/extensions/commands/definitions.js +2 -2
- package/dist/src/extensions/deployment-registration.js +1 -1
- package/dist/src/extensions/index.js +1 -1
- package/dist/src/extensions/loader.js +1 -1
- package/dist/src/extensions/manifest.js +10 -2
- package/dist/src/extensions/project-local-activity.js +1 -1
- package/dist/src/extensions/project-local-discovery.js +23 -3
- package/dist/src/extensions/project-local-doctor.js +7 -3
- package/dist/src/extensions/project-local-promote.js +3 -3
- package/dist/src/extensions/project-local-remove.js +3 -3
- package/dist/src/extensions/project-local-scaffold.js +20 -8
- package/dist/src/extensions/registry.js +1 -1
- package/dist/src/extensions/shadow-resolver.js +1 -1
- package/dist/src/extensions/types.js +1 -1
- package/dist/src/extensions/upstream-registry.js +1 -1
- package/dist/src/extensions/validation.js +1 -1
- package/dist/src/intake/git-history-analyzer.js +1 -1
- package/dist/src/kb/cli.js +1 -1
- package/dist/src/marketplace/plugin-directory.js +36 -0
- package/dist/src/marketplace/plugin-search.js +180 -0
- package/dist/src/mcp/cli.mjs +2 -2
- package/dist/src/mcp/helpers.mjs +1 -1
- package/dist/src/mcp/http-tools.mjs +8 -6
- package/dist/src/mcp/http-transport.mjs +3 -1
- package/dist/src/mcp/server.mjs +1 -1
- package/dist/src/mcp/tools/command-run.mjs +1 -1
- package/dist/src/mcp/tools/discovery.mjs +1 -1
- package/dist/src/mcp/tools/subsystems.mjs +1 -1
- package/dist/src/mcp/tools/worker-invoke.mjs +68 -22
- package/dist/src/mcp/tools/worker-local-only-preflight.mjs +79 -0
- package/dist/src/mcp/tools/worker-recorded-launch.mjs +26 -0
- package/dist/src/mcp/tools/worker-stdin-runtime.mjs +33 -6
- package/dist/src/mcp/tools/worker-verify-deliver-schema.mjs +33 -0
- package/dist/src/mcp/tools/worker-verify-deliver.mjs +27 -0
- package/dist/src/models/catalog-policy.js +2 -2
- package/dist/src/models/conductor-data-policy.mjs +83 -14
- package/dist/src/models/config-loader.js +2 -2
- package/dist/src/models/factory-models.js +144 -0
- package/dist/src/models/index.js +2 -2
- package/dist/src/models/local-endpoint-models.js +155 -0
- package/dist/src/models/model-capabilities.v1.json +44 -36
- package/dist/src/models/model-discovery.js +16 -8
- package/dist/src/models/opencode-worker-model.mjs +16 -0
- package/dist/src/models/resolver.js +2 -2
- package/dist/src/models/worker-installation.d.mts +2 -0
- package/dist/src/models/worker-installation.mjs +16 -5
- package/dist/src/models/worker-invocation-policy.js +25 -1
- package/dist/src/models/worker-plan.js +1 -1
- package/dist/src/models/wrapper-enforcement.js +1 -1
- package/dist/src/plugin/plugin-installer.js +2 -2
- package/dist/src/plugin/registry-validator.js +2 -2
- package/dist/src/plugin/skill-command-translator.js +1 -1
- package/dist/src/policy/repo-access.js +3 -1
- package/dist/src/providers/capability-matrix.yaml +75 -5
- package/dist/src/providers/deployment-ownership.mjs +8 -1
- package/dist/src/providers/deployment-preservation.mjs +44 -3
- package/dist/src/providers/grok-build-acp.js +13 -5
- package/dist/src/providers/grok-build-dispatch.js +35 -2
- package/dist/src/providers/grok-build-headless.js +2 -1
- package/dist/src/rlm/cache/hash.js +1 -1
- package/dist/src/rlm/cache/store.js +1 -1
- package/dist/src/rlm/cache/types.js +1 -1
- package/dist/src/serve/worker-invocation-preparation.js +13 -0
- package/dist/src/serve/worker-invocation.js +21 -6
- package/dist/src/serve/worker-stdin-frame.mjs +1 -1
- package/dist/src/sessions/adapters/grok-build-native-records.js +77 -7
- package/dist/src/sessions/adapters/grok-build-native.js +148 -1
- package/dist/src/sessions/adapters/grok-build.js +36 -14
- package/dist/src/sessions/normalization.js +1 -1
- package/dist/src/skills/run.js +0 -11
- package/dist/src/smiths/agentsmith/generator.js +1 -1
- package/dist/src/smiths/context-pipeline/index.js +1 -1
- package/dist/src/smiths/context-pipeline/provider-policy.js +1 -1
- package/dist/src/smiths/context-pipeline/types.js +1 -1
- package/dist/src/smiths/context-pipeline/workspace-doctor.js +4 -0
- package/dist/src/smiths/hook-bridge/factory-trust.js +2 -2
- package/dist/src/smiths/hook-bridge/hermes-prompt-discovery.js +10 -7
- package/dist/src/smiths/hook-bridge/hermes-trust.js +65 -0
- package/dist/src/smiths/mcpsmith/analyzers/cli-analyzer.js +2 -2
- package/dist/src/smiths/mcpsmith/generator.js +2 -2
- package/dist/src/smiths/mcpsmith/index.js +2 -2
- package/dist/src/smiths/mcpsmith/types.js +2 -2
- package/dist/src/smiths/skillsmith/collision-detector.js +1 -1
- package/dist/src/smiths/skillsmith/namespace-adapter.js +1 -1
- package/dist/src/smiths/toolsmith/runtime-discovery.mjs +2 -2
- package/dist/src/smiths/toolsmith/types.js +2 -2
- package/dist/src/storage/backends/fortemi.js +1 -1
- package/dist/src/storage/backends/fs.js +1 -1
- package/dist/src/storage/backends/logseq.js +1 -1
- package/dist/src/storage/backends/obsidian.js +1 -1
- package/dist/src/storage/cli.js +2 -2
- package/dist/src/storage/config.js +1 -1
- package/dist/src/storage/index.js +1 -1
- package/dist/src/storage/subsystem-cli.js +1 -1
- package/dist/src/storage/types.js +1 -1
- package/dist/src/testing/generators/test-case-generator.js +1 -1
- package/dist/src/writing/validation-engine.js +1 -1
- package/package.json +11 -1
- package/schemas/models/model-catalog.v1.schema.json +6 -3
- package/tools/agents/deploy-agents.mjs +4 -2
- package/tools/agents/deploy-options.mjs +2 -0
- package/tools/agents/providers/base-inventory.mjs +3 -1
- package/tools/agents/providers/base-kernel-skills.mjs +11 -5
- package/tools/agents/providers/conductor-data-guard.mjs +1 -1
- package/tools/agents/providers/grok-build.mjs +31 -40
- package/tools/agents/providers/model-wrapper.mjs +2 -5
- package/tools/agents/providers/rule-deployment-commit.mjs +3 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +2 -2
- package/tools/agents/providers/rule-projection.mjs +39 -4
- package/tools/agents/providers/skill-copy-prune.mjs +12 -0
- package/tools/agents/providers/stale-artifact-prune.mjs +24 -10
- package/tools/ralph-external/lib/claude-adapter.mjs +2 -0
- package/tools/ralph-external/lib/factory-adapter.mjs +6 -2
- package/tools/ralph-external/lib/mcp-worker-launch.mjs +67 -0
- package/tools/ralph-external/lib/opencode-adapter.mjs +9 -7
- package/tools/ralph-external/lib/trusted-verification.mjs +1021 -0
- package/tools/ralph-external/lib/typed-stop-delivery.mjs +46 -0
- package/tools/ralph-external/lib/verification-isolation.mjs +509 -0
- package/tools/ralph-external/lib/worker-context.mjs +3 -3
- package/tools/ralph-external/lib/worker-delivery-guards.mjs +95 -0
- package/tools/ralph-external/lib/worker-delivery-record.mjs +15 -0
- package/tools/ralph-external/lib/worker-final.mjs +4 -1
- package/tools/ralph-external/lib/worker-inputs.mjs +20 -1
- package/tools/ralph-external/lib/worker-isolation-status.mjs +3 -0
- package/tools/ralph-external/lib/worker-isolation.mjs +1 -0
- package/tools/ralph-external/lib/worker-launch-cli.mjs +8 -0
- package/tools/ralph-external/lib/worker-local-only-paths.mjs +45 -0
- package/tools/ralph-external/lib/worker-prompt.mjs +4 -1
- package/tools/ralph-external/lib/worker-retry-evidence.mjs +2 -1
- package/tools/ralph-external/lib/worker-run-directory.mjs +45 -0
- package/tools/ralph-external/lib/worker-termination.mjs +21 -12
- package/tools/ralph-external/lib/worker-unit-cleanup.mjs +10 -2
- package/tools/ralph-external/lib/worker-verification-cli.mjs +164 -0
- package/tools/ralph-external/lib/worktree-preparation.mjs +417 -0
- package/tools/ralph-external/session-launcher.mjs +30 -32
- package/vscode-extension/schemas/aiwg.config.v1.json +27 -0
|
@@ -10,9 +10,17 @@ import { writeContextFileSync } from './context-write.mjs';
|
|
|
10
10
|
export { inlineStartup } from './rule-startup.mjs';
|
|
11
11
|
const { parseRuleFrontmatter } = await importImpl(import.meta.url, 'rules/activation.mjs');
|
|
12
12
|
const { renderCoreStartup } = await importImpl(import.meta.url, 'rules/core-startup.mjs');
|
|
13
|
+
const { deploymentOwner } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
|
|
13
14
|
const read = file => fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : '';
|
|
14
15
|
const walk = dir => fs.existsSync(dir) ? fs.readdirSync(dir, { withFileTypes: true }).flatMap(entry =>
|
|
15
16
|
entry.isDirectory() ? walk(path.join(dir, entry.name)) : [path.join(dir, entry.name)]) : [];
|
|
17
|
+
const deployedRule = file => parseRuleFrontmatter(read(file).replace(/^<!-- aiwg:managed[^\n]*-->\r?\n/, ''));
|
|
18
|
+
export function ruleRemovalReason(file) {
|
|
19
|
+
if (!/[/\\](?:rules|rule|instructions)[/\\].*\.(?:md|mdc)$/.test(file)) return '';
|
|
20
|
+
const parsed = deployedRule(file);
|
|
21
|
+
const level = parsed.data?.enforcement === 'critical' ? 'critical rule' : 'rule';
|
|
22
|
+
return ` (${level} retired because the selected deployment no longer projects its source at this path)`;
|
|
23
|
+
}
|
|
16
24
|
const put = (file, content) => { fs.mkdirSync(path.dirname(file), { recursive: true }); fs.writeFileSync(file, content); };
|
|
17
25
|
export const nativeRuleLoader = name => ['claude', 'cursor', 'grok-build', 'windsurf', 'opencode'].includes(name);
|
|
18
26
|
export const nativePathLoader = name => ['claude', 'cursor', 'windsurf'].includes(name);
|
|
@@ -57,18 +65,44 @@ export function projectRules(opts, provider) {
|
|
|
57
65
|
const extension = provider.name === 'cursor' ? '.mdc' : '.md';
|
|
58
66
|
const managed = content => addManagedMarker(content, opts.deployVersion, opts.deploySource || 'bundled');
|
|
59
67
|
const deployedSources = new Map();
|
|
68
|
+
const owner = deploymentOwner(opts);
|
|
69
|
+
const selectedSource = rule => !opts.bundleOnly || rule.file.startsWith(`${opts.srcRoot}${path.sep}`);
|
|
70
|
+
const manifestPath = path.join(rulesDir, '.aiwg-manifest.json');
|
|
71
|
+
const manifest = fs.existsSync(manifestPath) ? JSON.parse(read(manifestPath)) : { managed: {} };
|
|
72
|
+
const previousManaged = opts.ownershipBefore
|
|
73
|
+
? JSON.parse(opts.ownershipBefore.get(manifestPath)?.toString() || '{}').managed || {} : { ...manifest.managed };
|
|
74
|
+
const owned = file => {
|
|
75
|
+
const name = path.relative(rulesDir, file);
|
|
76
|
+
const record = previousManaged[name];
|
|
77
|
+
const owners = record?.owners || (record?.frameworkSlug ? [record.frameworkSlug] : []);
|
|
78
|
+
const newSource = opts.ownershipBefore?.has(file) ? undefined : manifest.managed?.[name]?.sourcePath;
|
|
79
|
+
return owners.length === 1 && owners[0] === owner || Boolean(newSource?.startsWith(`${opts.srcRoot}${path.sep}`));
|
|
80
|
+
};
|
|
81
|
+
// Retained native contracts also stay reachable through non-native loaders.
|
|
82
|
+
// Older deployments can carry kernel rules whose original source has moved.
|
|
83
|
+
if (opts.bundleOnly) for (const file of walk(rulesDir)) {
|
|
84
|
+
if (!/\.(md|mdc)$/.test(file) || owned(file)) continue;
|
|
85
|
+
const parsed = deployedRule(file);
|
|
86
|
+
if (!parsed.valid || !parsed.rule?.tagged) continue;
|
|
87
|
+
const name = parsed.data.name || path.basename(file, path.extname(file));
|
|
88
|
+
if (['kernel', 'paths'].includes(parsed.rule.activation)
|
|
89
|
+
&& !rules.some(rule => rule.name === name)) rules.push({ ...parsed.rule, name, file, content: read(file), body: parsed.body });
|
|
90
|
+
}
|
|
60
91
|
const writeRule = (rule, content) => {
|
|
92
|
+
if (!selectedSource(rule)) return;
|
|
61
93
|
const name = `${ruleName(rule, provider)}${extension}`;
|
|
94
|
+
if (opts.bundleOnly && opts.ownershipBefore?.has(path.join(rulesDir, name)) && !owned(path.join(rulesDir, name)) && !opts.force) return;
|
|
62
95
|
put(path.join(rulesDir, name), managed(content));
|
|
63
96
|
// Keep the source before reference rewriting, pinning, and native transforms.
|
|
64
97
|
deployedSources.set(name, opts.ruleDelivery.rules.find(original => original.file === rule.file));
|
|
65
98
|
};
|
|
66
99
|
for (const file of walk(rulesDir)) {
|
|
67
|
-
if (/\.(md|mdc)$/.test(file) && /aiwg:managed/.test(read(file))) fs.rmSync(file);
|
|
100
|
+
if (/\.(md|mdc)$/.test(file) && /aiwg:managed/.test(read(file)) && (!opts.bundleOnly || owned(file))) fs.rmSync(file);
|
|
68
101
|
}
|
|
69
102
|
const cores = [...new Map(tagged.filter(rule => rule.activation === 'core').map(rule => [rule.name, rule])).values()];
|
|
70
103
|
if (['claude', 'cursor'].includes(provider.name)) {
|
|
71
104
|
for (const rule of cores) {
|
|
105
|
+
if (!selectedSource(rule)) continue;
|
|
72
106
|
const dest = path.join(rulesDir, `core-${path.basename(rule.file, '.md')}${extension}`);
|
|
73
107
|
if (fs.existsSync(dest) && !/aiwg:managed/.test(read(dest)) && !opts.force) {
|
|
74
108
|
console.warn(`Unmanaged core rule left in place: ${dest}. Re-run with --force to replace it.`);
|
|
@@ -110,9 +144,7 @@ export function projectRules(opts, provider) {
|
|
|
110
144
|
const startups = projectStartup(opts, provider, coreSection, indexFile);
|
|
111
145
|
registerOpenCode(opts, provider, rulesDir);
|
|
112
146
|
fs.rmSync(path.join(rulesDir, '.aiwg-rules-budget.json'), { force: true });
|
|
113
|
-
|
|
114
|
-
const manifest = fs.existsSync(manifestPath) ? JSON.parse(read(manifestPath)) : { managed: {} };
|
|
115
|
-
manifest.ruleSources = rules.map(rule => rule.file);
|
|
147
|
+
manifest.ruleSources = opts.ruleDelivery.rules.map(rule => rule.file);
|
|
116
148
|
const logical = opts.logicalOutputPath || (file => file);
|
|
117
149
|
const relative = file => path.relative(logical(opts.target), logical(file)).replaceAll('\\', '/');
|
|
118
150
|
manifest.delivery = { projectFromRules: path.relative(logical(rulesDir), logical(opts.target)),
|
|
@@ -122,9 +154,12 @@ export function projectRules(opts, provider) {
|
|
|
122
154
|
for (const file of walk(rulesDir).filter(file => /\.(md|mdc)$/.test(file) && /aiwg:managed/.test(read(file)))) {
|
|
123
155
|
const name = path.relative(rulesDir, file);
|
|
124
156
|
const source = deployedSources.get(name);
|
|
157
|
+
if (opts.bundleOnly && !source && !/^(?:RULES-INDEX|RULES-ONDEMAND)\./.test(name)) continue;
|
|
125
158
|
manifest.managed[name] = { ...manifest.managed[name], hash: `sha256:${contentHash(read(file))}`,
|
|
126
159
|
...(source ? { sourceHash: `sha256:${contentHash(source.content)}` } : {}) };
|
|
127
160
|
}
|
|
128
161
|
for (const name of Object.keys(manifest.managed)) if (!fs.existsSync(path.join(rulesDir, name))) delete manifest.managed[name];
|
|
162
|
+
if (opts.bundleOnly) opts.retiredRuleFiles = new Set([...(opts.ownershipBefore?.keys() || [])].filter(file =>
|
|
163
|
+
file.startsWith(`${rulesDir}${path.sep}`) && owned(file) && !fs.existsSync(file)));
|
|
129
164
|
put(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
130
165
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
|
+
import { importImpl } from '../../_resolve-impl.mjs';
|
|
6
|
+
const { deploymentOwner } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
|
|
5
7
|
export function removeSkillCopy(dir, opts = {}) {
|
|
6
8
|
const copyMode = opts.copyMode ?? opts.copyStandardSkills;
|
|
7
9
|
if (copyMode && !opts.tierMove) return false;
|
|
@@ -17,6 +19,7 @@ export function removeSkillCopy(dir, opts = {}) {
|
|
|
17
19
|
let receipt;
|
|
18
20
|
try { receipt = JSON.parse(fs.readFileSync(path.join(dir, '.aiwg-manifest.json'), 'utf8')); }
|
|
19
21
|
catch (error) {
|
|
22
|
+
if (opts.bundleOnly) return false;
|
|
20
23
|
// Only a missing receipt may use legacy ownership. An invalid receipt must
|
|
21
24
|
// not turn an edited copy into a marker-only deletion candidate.
|
|
22
25
|
if (error.code !== 'ENOENT') return keep('unverifiable ownership');
|
|
@@ -24,6 +27,15 @@ export function removeSkillCopy(dir, opts = {}) {
|
|
|
24
27
|
if (!opts.dryRun) fs.rmSync(dir, { recursive: true, force: true });
|
|
25
28
|
return true;
|
|
26
29
|
}
|
|
30
|
+
if (opts.bundleOnly) {
|
|
31
|
+
const record = receipt?.managed?.['SKILL.md'];
|
|
32
|
+
const owners = record?.owners || (record?.frameworkSlug ? [record.frameworkSlug] : []);
|
|
33
|
+
const logical = opts.logicalInputPath || (file => file);
|
|
34
|
+
const selectedRoot = path.resolve(logical(opts.srcRoot));
|
|
35
|
+
const source = receipt?.skillSource && path.resolve(logical(receipt.skillSource));
|
|
36
|
+
const ownSource = source && source.startsWith(`${selectedRoot}${path.sep}`);
|
|
37
|
+
if (owners.length ? owners.some(owner => owner !== deploymentOwner(opts)) : !ownSource) return false;
|
|
38
|
+
}
|
|
27
39
|
if (!receipt?.managed?.['SKILL.md']?.hash) return keep('unverifiable ownership');
|
|
28
40
|
const walk = root => fs.readdirSync(root, { withFileTypes: true }).flatMap(entry => {
|
|
29
41
|
const file = path.join(root, entry.name);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/** Preserve projector-owned rules while pruning stale legacy flat artifacts. */
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
import { computeArtifactInventory, computeAllSkillNames, pruneStaleAiwgFiles, resolveAiwgRoot } from './base.mjs';
|
|
4
|
+
import { artifactStem, computeArtifactInventory, computeAllSkillNames, listMdFiles, listSkillDirs, pruneStaleAiwgFiles, resolveAiwgRoot } from './base.mjs';
|
|
5
|
+
import { importImpl } from '../../_resolve-impl.mjs';
|
|
6
|
+
const { deploymentOwner } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* After a deploy, prune AIWG-managed flat artifacts (agents/commands/rules)
|
|
@@ -9,9 +11,9 @@ import { computeArtifactInventory, computeAllSkillNames, pruneStaleAiwgFiles, re
|
|
|
9
11
|
*
|
|
10
12
|
* Safety boundaries:
|
|
11
13
|
* - Runs ONLY for AIWG framework/addon deploys (default source = AIWG root,
|
|
12
|
-
* or `--source` under `<aiwgRoot>/agentic/code`).
|
|
13
|
-
*
|
|
14
|
-
*
|
|
14
|
+
* or `--source` under `<aiwgRoot>/agentic/code`). A named bundle pass
|
|
15
|
+
* instead compares only its own recorded outputs with its source tree,
|
|
16
|
+
* including project-local sources.
|
|
15
17
|
* - `pruneStaleAiwgFiles` itself only removes files whose AIWG
|
|
16
18
|
* receipt hash matches their bytes AND whose recorded owners no longer
|
|
17
19
|
* ship the stem. Without bundle identity, it uses the global source set.
|
|
@@ -49,22 +51,24 @@ export function bulkInstallOwnsFlatArtifacts(target) {
|
|
|
49
51
|
|
|
50
52
|
export function pruneStaleAiwgArtifacts(provider, target, srcRoot, opts, explicitSource) {
|
|
51
53
|
if (opts.copyMode ?? opts.copyStandardSkills) return;
|
|
52
|
-
if (opts.skillsOnly && !opts.kernelOnly) return; // skills run their own prune in the provider
|
|
54
|
+
if (opts.skillsOnly && (!opts.kernelOnly || provider.name === 'grok-build')) return; // skills run their own prune in the provider
|
|
53
55
|
|
|
54
56
|
const aiwgRoot = resolveAiwgRoot(srcRoot);
|
|
55
|
-
if (!aiwgRoot) return; //
|
|
57
|
+
if (!aiwgRoot && !opts.bundleOnly) return; // standalone deploy without an ownership scope
|
|
56
58
|
|
|
57
59
|
// Gate: only framework/addon deploys are eligible. A default deploy (no
|
|
58
60
|
// --source) sources from the AIWG root. An explicit --source is eligible
|
|
59
61
|
// only when it lives under <aiwgRoot>/agentic/code (bundled fw/addon).
|
|
60
|
-
if (explicitSource) {
|
|
62
|
+
if (explicitSource && !opts.bundleOnly) {
|
|
61
63
|
const codeRoot = path.join(aiwgRoot, 'agentic', 'code');
|
|
62
64
|
const rel = path.relative(codeRoot, path.resolve(explicitSource));
|
|
63
65
|
const underCode = !!rel && !rel.startsWith('..') && !path.isAbsolute(rel);
|
|
64
66
|
if (!underCode) return; // project-local bundle / external source → skip
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
// Grok bulk mode writes native agents; reconcile against the corpus below,
|
|
70
|
+
// rather than treating its newly deployed agents as obsolete bulk output.
|
|
71
|
+
if (opts.kernelOnly && provider.name !== 'grok-build') {
|
|
68
72
|
// Kernel-only delivers skills and rules. The empty desired set below
|
|
69
73
|
// applies only to bulk agents/commands left by
|
|
70
74
|
// the pre-#152 bulk default, when the bulk install is the only thing this
|
|
@@ -103,7 +107,10 @@ export function pruneStaleAiwgArtifacts(provider, target, srcRoot, opts, explici
|
|
|
103
107
|
if (!relPath) continue; // type not file-deployed by provider
|
|
104
108
|
if (relPath.endsWith('.md')) continue; // aggregate file (e.g. AGENTS.md)
|
|
105
109
|
|
|
106
|
-
const
|
|
110
|
+
const onlyOwner = opts.bundleOnly ? deploymentOwner(opts) : undefined;
|
|
111
|
+
const selectedStems = onlyOwner && new Set(listMdFiles(path.join(srcRoot, type)).map(file => artifactStem(path.basename(file))));
|
|
112
|
+
const inventory = onlyOwner ? { stems: selectedStems, ownerStems: new Map([[onlyOwner, selectedStems]]) }
|
|
113
|
+
: computeArtifactInventory(srcRoot, type);
|
|
107
114
|
if (!inventory) continue; // no global desired set → skip
|
|
108
115
|
|
|
109
116
|
const destDir = path.isAbsolute(relPath) ? relPath : path.join(target, relPath);
|
|
@@ -113,14 +120,21 @@ export function pruneStaleAiwgArtifacts(provider, target, srcRoot, opts, explici
|
|
|
113
120
|
const receipt = path.join(destDir, '.aiwg-manifest.json');
|
|
114
121
|
if (fs.existsSync(receipt) && JSON.parse(fs.readFileSync(receipt, 'utf8')).delivery) continue;
|
|
115
122
|
}
|
|
123
|
+
let skillCommandStems = null;
|
|
124
|
+
if (type === 'commands') {
|
|
125
|
+
skillCommandStems = onlyOwner
|
|
126
|
+
? new Set(listSkillDirs(path.join(srcRoot, 'skills')).map(file => path.basename(file)))
|
|
127
|
+
: computeAllSkillNames(srcRoot);
|
|
128
|
+
}
|
|
116
129
|
const removed = pruneStaleAiwgFiles(destDir, inventory.stems, {
|
|
117
130
|
ownerStems: inventory.ownerStems,
|
|
131
|
+
onlyOwner,
|
|
118
132
|
dryRun: opts.dryRun,
|
|
119
133
|
verbose: opts.verbose,
|
|
120
134
|
// Retire wrappers whose source skill no longer ships (#2511). Only the
|
|
121
135
|
// command directory holds them; the kernel-only branch returns earlier,
|
|
122
136
|
// so a bulk install still cannot touch wrappers it did not write.
|
|
123
|
-
skillCommandStems
|
|
137
|
+
skillCommandStems,
|
|
124
138
|
});
|
|
125
139
|
if (removed.length > 0 && !opts.quiet) {
|
|
126
140
|
console.log(` Pruned: ${removed.length} stale AIWG ${type} file${removed.length === 1 ? '' : 's'}`);
|
|
@@ -341,6 +341,8 @@ export class ClaudeAdapter extends ProviderAdapter {
|
|
|
341
341
|
* inherited from ProviderAdapter.
|
|
342
342
|
*/
|
|
343
343
|
export class ClaudeDirectAdapter extends ClaudeAdapter {
|
|
344
|
+
getName() { return 'claude-direct'; }
|
|
345
|
+
|
|
344
346
|
async parseWorkerFinal(output, options = {}) {
|
|
345
347
|
// MCP envelopes retain the shared strict parser. Every other input must be
|
|
346
348
|
// Claude's own stream-json transcript with a validated terminal result: the
|
|
@@ -202,8 +202,12 @@ export class FactoryAdapter extends ProviderAdapter {
|
|
|
202
202
|
if (FACTORY_RESERVED_MODEL_VALUES.includes(model.toLowerCase())) {
|
|
203
203
|
throw new Error(`Factory worker requires an explicit observed model, not the CLI's own auto-selection '${model}'`);
|
|
204
204
|
}
|
|
205
|
+
if (model.startsWith('custom:') && (model.trim() !== model || !/^custom:[^\s\x00-\x1f\x7f]+-\d+$/.test(model))) {
|
|
206
|
+
throw new Error('Factory custom model selector requires a safe normalized name and numeric suffix');
|
|
207
|
+
}
|
|
205
208
|
const effort = invocation?.selected?.effort?.value ?? null;
|
|
206
|
-
|
|
209
|
+
const customNoEffort = model.startsWith('custom:') && invocation?.selected?.effort?.support === 'not-applicable' && effort === null;
|
|
210
|
+
if (!customNoEffort && (effort === null || !FACTORY_DIRECT_EFFORT_VALUES.includes(effort))) {
|
|
207
211
|
throw new Error('Factory worker requires an explicit qualified reasoning effort (never a CLI default)');
|
|
208
212
|
}
|
|
209
213
|
const sandbox = permissions?.sandbox ?? 'workspace-write';
|
|
@@ -225,7 +229,7 @@ export class FactoryAdapter extends ProviderAdapter {
|
|
|
225
229
|
const auto = FACTORY_SANDBOX_TO_AUTO[sandbox];
|
|
226
230
|
const args = ['exec'];
|
|
227
231
|
if (auto) args.push('--auto', auto);
|
|
228
|
-
args.push('-m', model, '-r', effort, '--cwd', cwd, '--output-format', 'stream-json');
|
|
232
|
+
args.push('-m', model, ...(customNoEffort ? [] : ['-r', effort]), '--cwd', cwd, '--output-format', 'stream-json');
|
|
229
233
|
return args;
|
|
230
234
|
}
|
|
231
235
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Adapt MCP shell dispatch to the same one-shot launch and capture owner as --launch-worker.
|
|
2
|
+
import { mkdtemp, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { SessionLauncher, planDirectWorkerLaunch } from '../session-launcher.mjs';
|
|
5
|
+
import { checkWorkerDispatch, launchIsolatedWorker } from './worker-isolation.mjs';
|
|
6
|
+
|
|
7
|
+
// The capture owner's attached launch connects stdio itself, so the planner must not default capture
|
|
8
|
+
// paths from the invocation; systemd-run refuses attached mode with redirects (#4157).
|
|
9
|
+
function attachedInvocation(invocation) {
|
|
10
|
+
return { ...invocation, stdoutPath: undefined, stderrPath: undefined, briefPath: undefined };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function launchMcpShellWorker(invocation, { plan, invocationId, releaseOutput, runDir, servedRoot,
|
|
14
|
+
loadInputs, now, onRunDir, memoryMaxGb = 2, allowDegraded, admission, dispatchGuard,
|
|
15
|
+
live, readers, thresholdOverlay, isolation, spawn, spawnAsync }) {
|
|
16
|
+
if (!Number.isFinite(memoryMaxGb) || memoryMaxGb <= 0) throw new Error('Worker isolation requires a positive memoryMaxGb ceiling');
|
|
17
|
+
const parent = await mkdtemp(join(servedRoot, '.worker-run-'));
|
|
18
|
+
runDir ??= join(parent, 'run');
|
|
19
|
+
const invocationPath = join(parent, 'plan.json');
|
|
20
|
+
await writeFile(invocationPath, JSON.stringify(plan), { flag: 'wx', mode: 0o600 });
|
|
21
|
+
onRunDir(runDir);
|
|
22
|
+
await releaseOutput(); // The launcher exclusively reserves every output before spawning.
|
|
23
|
+
const owner = new SessionLauncher();
|
|
24
|
+
let launch;
|
|
25
|
+
let attempt;
|
|
26
|
+
let resolveStarted;
|
|
27
|
+
const started = new Promise(resolve => { resolveStarted = resolve; });
|
|
28
|
+
owner.once('launched', () => resolveStarted(launch));
|
|
29
|
+
const completion = owner.launchWorker({ invocationPath, invocationId, runDir, loadInputs, now: () => now().toISOString(),
|
|
30
|
+
projectRoot: servedRoot, memoryMaxGb, allowDegraded, scopedBreaker: null, isolation,
|
|
31
|
+
checkDispatch: options => checkWorkerDispatch({ ...options, live, readers, thresholdOverlay }),
|
|
32
|
+
launchIsolated: async options => {
|
|
33
|
+
const onSpawnAttempt = value => { attempt = value; };
|
|
34
|
+
// The MCP bridge retains its single recovery admission and leaf dispatch guard.
|
|
35
|
+
launch = await (admission === undefined
|
|
36
|
+
? launchIsolatedWorker({ ...options, spawn, spawnAsync, onSpawnAttempt })
|
|
37
|
+
: planDirectWorkerLaunch({ ...options, invocation: options.attached ? attachedInvocation(invocation) : invocation, invocationId, admission, dispatchGuard,
|
|
38
|
+
live, readers, thresholdOverlay, spawn, spawnAsync, onSpawnAttempt }));
|
|
39
|
+
launch.child?.once('close', (exitCode, signalCode) => {
|
|
40
|
+
launch.spawnObservation = { closed: true, exitCode, signalCode };
|
|
41
|
+
});
|
|
42
|
+
return launch;
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
// Observe rejection immediately; preparation failures must never strand MCP admission.
|
|
46
|
+
const settled = completion.then(() => launch, error => {
|
|
47
|
+
error.launchAttempted = !!(launch?.child?.pid || launch?.unit || attempt?.child?.pid || attempt?.unit);
|
|
48
|
+
throw error;
|
|
49
|
+
});
|
|
50
|
+
const result = await Promise.race([started, settled]);
|
|
51
|
+
// A transport's close cannot override the capture owner's descendant proof.
|
|
52
|
+
const stop = () => { if (!owner.workerStop) return false; owner.workerStop(); return true; };
|
|
53
|
+
const outcome = async () => { const value = await completion; return { ...value, stopped: !!value.cancelled }; };
|
|
54
|
+
const control = {
|
|
55
|
+
stop: async () => stop(),
|
|
56
|
+
stopAndConfirm: async () => { stop(); return outcome(); },
|
|
57
|
+
wait: async (deadlineMs, { deadlineAtMs, nowMs = () => performance.now() } = {}) => {
|
|
58
|
+
const remaining = Math.max(0, Math.min(deadlineMs, (deadlineAtMs ?? Infinity) - nowMs()));
|
|
59
|
+
const timer = setTimeout(() => owner.workerStop?.('HARD_DEADLINE'), remaining);
|
|
60
|
+
try { return await outcome(); } finally { clearTimeout(timer); }
|
|
61
|
+
},
|
|
62
|
+
dispose() {},
|
|
63
|
+
};
|
|
64
|
+
return { ...result, runDir, launchAttempted: !!(result?.child?.pid || result?.unit),
|
|
65
|
+
ownedGroup: result?.ownedGroup ?? (['native-sandbox', 'degraded'].includes(result?.mode) && !!result?.pid),
|
|
66
|
+
control, cleanup: () => settled };
|
|
67
|
+
}
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Version-bound direct-worker surface (roctinam/aiwg#2904, B-OG-39).
|
|
31
|
+
* npm 1.x uses separate --variant (1.19.0 help, titan, 2026-11-15);
|
|
32
|
+
* installer 2.x uses #variant. Other flags and qualification stay unchanged.
|
|
31
33
|
*
|
|
32
34
|
* Qualified against OpenCode CLI 2.0.26 `opencode --help` / `opencode run
|
|
33
35
|
* --help` (help/version syntax captured on host 'noodle' 2026-10-10; see
|
|
@@ -91,7 +93,9 @@
|
|
|
91
93
|
import { ProviderAdapter, registerProvider } from './provider-adapter.mjs';
|
|
92
94
|
import { classifyWorkerHealthFailure, healthEventMatchesBinding } from './worker-health.mjs';
|
|
93
95
|
|
|
94
|
-
|
|
96
|
+
import { importImpl } from '../../_resolve-impl.mjs';
|
|
97
|
+
const { opencodeWorkerModelArgs, OPENCODE_SUPPORTED_VERSIONS } = await importImpl(import.meta.url, 'models/opencode-worker-model.mjs');
|
|
98
|
+
export { OPENCODE_SUPPORTED_VERSIONS };
|
|
95
99
|
/** Stdin is confirmed unsupported by the compiled v2.0.26 `run` chunk (see
|
|
96
100
|
* module doc); the brief travels via `-f`/`--file` instead. */
|
|
97
101
|
export const OPENCODE_DIRECT_STDIN = 'closed';
|
|
@@ -186,7 +190,7 @@ export class OpenCodeAdapter extends ProviderAdapter {
|
|
|
186
190
|
/**
|
|
187
191
|
* Driver-owned argv after the binary for the version-bound direct-shell
|
|
188
192
|
* profile. Every control is explicit: exact observed model via `-m`
|
|
189
|
-
* (with
|
|
193
|
+
* (with effort as `--variant` on 1.x or `#<variant>` on 2.x),
|
|
190
194
|
* `--format json` for the evidenced JSONL stream, and the brief as an
|
|
191
195
|
* attached file via `-f` (no stdin transport is evidenced; see the
|
|
192
196
|
* module doc comment) — the positional argument is always the fixed,
|
|
@@ -194,7 +198,7 @@ export class OpenCodeAdapter extends ProviderAdapter {
|
|
|
194
198
|
* externally-enforced is refused rather than guessed, since it has no
|
|
195
199
|
* evidenced CLI mapping.
|
|
196
200
|
*
|
|
197
|
-
* @param {{ selected?: { model?: unknown, effort?: { value?: unknown } }, cwd?: unknown, briefPath?: unknown }} invocation
|
|
201
|
+
* @param {{ cliVersion?: string, selected?: { model?: unknown, effort?: { value?: unknown } }, cwd?: unknown, briefPath?: unknown }} invocation
|
|
198
202
|
* @param {unknown} _profile
|
|
199
203
|
* @param {{ sandbox?: unknown }} [permissions]
|
|
200
204
|
* @returns {string[]}
|
|
@@ -207,18 +211,16 @@ export class OpenCodeAdapter extends ProviderAdapter {
|
|
|
207
211
|
if (OPENCODE_GENERIC_ALIASES.includes(model.toLowerCase())) {
|
|
208
212
|
throw new Error(`OpenCode worker requires an exact observed model, not the generic alias '${model}'`);
|
|
209
213
|
}
|
|
210
|
-
// #variant
|
|
214
|
+
// #variant (2.x) / --variant (1.x) selects reasoning effort (see module
|
|
211
215
|
// doc), but the valid id set is model-specific and not enumerated here,
|
|
212
216
|
// so a syntactically valid id is appended. Whether the real CLI refuses
|
|
213
217
|
// an undeclared id or silently falls back is unverified (effort stays
|
|
214
218
|
// unqualified).
|
|
215
219
|
const effort = invocation?.selected?.effort?.value ?? null;
|
|
216
|
-
let modelToken = model;
|
|
217
220
|
if (effort !== null) {
|
|
218
221
|
if (typeof effort !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(effort)) {
|
|
219
222
|
throw new Error('OpenCode worker effort must be a plain variant id (no "#", "/", whitespace or control characters)');
|
|
220
223
|
}
|
|
221
|
-
modelToken = `${model}#${effort}`;
|
|
222
224
|
}
|
|
223
225
|
const sandbox = permissions?.sandbox ?? 'external';
|
|
224
226
|
if (!OPENCODE_DIRECT_SANDBOX_MODES.includes(sandbox)) {
|
|
@@ -234,7 +236,7 @@ export class OpenCodeAdapter extends ProviderAdapter {
|
|
|
234
236
|
if (typeof briefPath !== 'string' || !briefPath.startsWith('/') || briefPath.includes('\0')) {
|
|
235
237
|
throw new Error('OpenCode worker requires an absolute brief-file path');
|
|
236
238
|
}
|
|
237
|
-
return ['run', '--format', 'json',
|
|
239
|
+
return ['run', '--format', 'json', ...opencodeWorkerModelArgs(model, effort, invocation.cliVersion), '-f', briefPath, OPENCODE_FIXED_MESSAGE];
|
|
238
240
|
}
|
|
239
241
|
|
|
240
242
|
/** No evidenced stdin abort channel for `opencode run`. */
|