@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.
- package/dist/src/artifacts/corpus-tools/resolve.js +21 -4
- package/dist/src/artifacts/query-engine-corpus.js +217 -0
- package/dist/src/artifacts/query-engine-discover-output.js +229 -0
- package/dist/src/artifacts/query-engine-discover.js +285 -0
- package/dist/src/artifacts/query-engine-entries.js +188 -0
- package/dist/src/artifacts/query-engine-index.js +249 -0
- package/dist/src/artifacts/query-engine-matching.js +143 -0
- package/dist/src/artifacts/query-engine-options.js +2 -0
- package/dist/src/artifacts/query-engine-rules.js +202 -0
- package/dist/src/artifacts/query-engine-scoring.js +436 -0
- package/dist/src/artifacts/query-engine-show-card.js +194 -0
- package/dist/src/artifacts/query-engine-show-load.js +211 -0
- package/dist/src/artifacts/query-engine-show.js +300 -0
- package/dist/src/artifacts/query-engine.js +7 -2576
- package/dist/src/cli/handlers/mc-agents.js +111 -0
- package/dist/src/cli/handlers/mc-args.js +54 -0
- package/dist/src/cli/handlers/mc-control.js +227 -0
- package/dist/src/cli/handlers/mc-dispatch.js +203 -0
- package/dist/src/cli/handlers/mc-help.js +171 -0
- package/dist/src/cli/handlers/mc-run.js +343 -0
- package/dist/src/cli/handlers/mc-session.js +138 -0
- package/dist/src/cli/handlers/mc-status.js +258 -0
- package/dist/src/cli/handlers/mc-summary.js +43 -0
- package/dist/src/cli/handlers/mc-types.js +3 -0
- package/dist/src/cli/handlers/mc-worker.js +205 -0
- package/dist/src/cli/handlers/mc.js +12 -1665
- package/dist/src/cli/handlers/models-refusal.js +13 -0
- package/dist/src/cli/handlers/models.js +2 -1
- package/dist/src/cli/handlers/remove-bundled.js +133 -0
- package/dist/src/cli/handlers/remove-options.js +31 -0
- package/dist/src/cli/handlers/remove-user.js +174 -0
- package/dist/src/cli/handlers/remove.js +201 -0
- package/dist/src/cli/handlers/subcommands-bundles.js +257 -0
- package/dist/src/cli/handlers/subcommands-discovery.js +165 -0
- package/dist/src/cli/handlers/subcommands-list-format.js +129 -0
- package/dist/src/cli/handlers/subcommands-list.js +250 -0
- package/dist/src/cli/handlers/subcommands-plugins.js +213 -0
- package/dist/src/cli/handlers/subcommands-quickref.js +58 -0
- package/dist/src/cli/handlers/subcommands-rlm.js +113 -0
- package/dist/src/cli/handlers/subcommands-services.js +66 -0
- package/dist/src/cli/handlers/subcommands-storage.js +259 -0
- package/dist/src/cli/handlers/subcommands.js +18 -1984
- package/dist/src/cli/scope-resolver.js +1 -142
- package/dist/src/cli/user-scope-mirror.js +173 -0
- package/dist/src/config/dispatch-host-thresholds.js +2 -0
- package/dist/src/config/dispatch-thresholds-runtime.mjs +4 -0
- package/dist/src/config/host-resource-report.d.mts +5 -0
- package/dist/src/config/host-resource-report.mjs +36 -6
- package/dist/src/config/host-resource-runtime.d.mts +3 -0
- package/dist/src/config/host-resource-runtime.mjs +9 -6
- package/dist/src/decision/ensemble-study/artifacts.js +7 -0
- package/dist/src/decision/ensemble-study/gate-policy.js +58 -0
- package/dist/src/decision/ensemble-study/gates.js +78 -0
- package/dist/src/decision/ensemble-study/protocol.js +18 -21
- package/dist/src/decision/ensemble-study/score.js +3 -2
- package/dist/src/decision/ensemble-study/statistics.js +7 -26
- package/dist/src/decision/sensitivity/comparative-gates.js +135 -0
- package/dist/src/decision/sensitivity/comparative.js +18 -41
- package/dist/src/extensions/claude-hooks-installer.js +18 -0
- package/dist/src/gates/evaluate.js +2 -358
- package/dist/src/gates/observations.js +363 -0
- package/dist/src/gates/pack-composition.js +270 -0
- package/dist/src/gates/pack-tightening.js +197 -0
- package/dist/src/gates/pack-validation.js +262 -0
- package/dist/src/gates/registry-error.js +5 -0
- package/dist/src/gates/registry.js +13 -685
- package/dist/src/mcp/json-document.mjs +29 -0
- package/dist/src/mcp/muse-native-config.mjs +1 -28
- package/dist/src/mission-protocol/worker-review-gate.js +7 -0
- package/dist/src/models/worker-plan.js +5 -5
- package/dist/src/plugin/command-ownership.js +34 -0
- package/dist/src/plugin/skill-command-frontmatter.js +197 -0
- package/dist/src/plugin/skill-command-translator.js +6 -232
- package/dist/src/providers/context-output-ownership.js +26 -0
- package/dist/src/providers/deployment-ownership.d.mts +19 -0
- package/dist/src/providers/deployment-ownership.mjs +226 -0
- package/dist/src/providers/deployment-removal.js +200 -0
- package/dist/src/providers/removal-transaction.js +86 -0
- package/dist/src/providers/settings-document.d.mts +3 -0
- package/dist/src/providers/settings-document.mjs +47 -0
- package/dist/src/providers/settings-removal.js +190 -0
- package/dist/src/providers/skill-ownership.d.mts +19 -2
- package/dist/src/providers/skill-ownership.mjs +12 -4
- package/dist/src/providers/transformation-receipt-integration.js +15 -271
- package/dist/src/providers/transformation-receipt-outputs.js +99 -0
- package/dist/src/providers/transformation-receipt-source.js +194 -0
- package/dist/src/research/identity.js +8 -2
- package/dist/src/research/reference-match.js +42 -7
- package/dist/src/rules/activation.mjs +15 -6
- package/dist/src/rules/core-startup.mjs +2 -2
- package/dist/src/serve/mission-conductor.js +4 -0
- package/dist/src/serve/mission-summary.js +56 -0
- package/dist/src/smiths/context-pipeline/aiwg-md.js +23 -0
- package/dist/src/smiths/context-pipeline/context-file-safety.js +3 -0
- package/dist/src/smiths/context-pipeline/generator.js +1 -1
- package/dist/src/smiths/hook-bridge/index.js +9 -0
- package/package.json +4 -1
- package/schemas/decision/D17StudyProtocol.v1.schema.json +39 -67
- package/tools/agents/deploy-agents.mjs +16 -677
- package/tools/agents/deploy-command-mirrors.mjs +229 -0
- package/tools/agents/deploy-options.mjs +258 -0
- package/tools/agents/deploy-support.mjs +165 -0
- package/tools/agents/providers/base-addon-discovery.mjs +139 -0
- package/tools/agents/providers/base-behaviors.mjs +168 -0
- package/tools/agents/providers/base-context.mjs +205 -0
- package/tools/agents/providers/base-contract.mjs +116 -0
- package/tools/agents/providers/base-files.mjs +252 -0
- package/tools/agents/providers/base-flat-artifacts.mjs +233 -0
- package/tools/agents/providers/base-framework-discovery.mjs +309 -0
- package/tools/agents/providers/base-frontmatter.mjs +196 -0
- package/tools/agents/providers/base-inventory.mjs +269 -0
- package/tools/agents/providers/base-kernel-skills.mjs +354 -0
- package/tools/agents/providers/base-migrations.mjs +258 -0
- package/tools/agents/providers/base-models-platforms.mjs +273 -0
- package/tools/agents/providers/base-rule-index.mjs +450 -0
- package/tools/agents/providers/base-runtime.mjs +60 -0
- package/tools/agents/providers/base-skill-copy.mjs +273 -0
- package/tools/agents/providers/base.mjs +16 -3364
- package/tools/agents/providers/claude-post-deploy.mjs +10 -2
- package/tools/agents/providers/hermes-startup.mjs +0 -5
- package/tools/agents/providers/muse.mjs +7 -2
- package/tools/agents/providers/rule-delivery-surface.mjs +31 -4
- package/tools/agents/providers/rule-deployment-commit.mjs +19 -15
- package/tools/agents/providers/rule-deployment-prepare.mjs +11 -2
- package/tools/agents/providers/rule-projection.mjs +3 -0
- package/tools/ralph-external/lib/worker-invocation-processes.mjs +4 -2
- package/tools/ralph-external/lib/worker-termination.mjs +15 -8
- package/vscode-extension/schemas/aiwg.config.v1.json +2 -4
|
@@ -79,28 +79,16 @@ import path from 'path';
|
|
|
79
79
|
import { importImpl } from '../_resolve-impl.mjs';
|
|
80
80
|
const { resolveDeployVersion } = await importImpl(import.meta.url, 'providers/deploy-version.mjs');
|
|
81
81
|
import os from 'os';
|
|
82
|
-
import readline from 'readline';
|
|
83
82
|
import { fileURLToPath } from 'url';
|
|
84
83
|
import {
|
|
85
|
-
addManagedMarker,
|
|
86
84
|
collectBehaviorDirs,
|
|
87
|
-
collectFrameworkArtifacts,
|
|
88
|
-
contentHash,
|
|
89
85
|
deployEmulatedBehaviors,
|
|
90
|
-
getAddonSkillDirs,
|
|
91
|
-
listSkillDirs,
|
|
92
86
|
loadModelConfig,
|
|
93
87
|
loadRuntimeModelCatalog,
|
|
94
88
|
migrateCommandsDirectory,
|
|
95
|
-
parseFrontmatter,
|
|
96
89
|
resolveAiwgRoot,
|
|
97
|
-
updateSidecarManifest,
|
|
98
90
|
} from './providers/base.mjs';
|
|
99
91
|
|
|
100
|
-
// ============================================================================
|
|
101
|
-
// Provider Registry
|
|
102
|
-
// ============================================================================
|
|
103
|
-
|
|
104
92
|
const PROVIDER_ALIASES = {
|
|
105
93
|
agy: 'antigravity',
|
|
106
94
|
'openai': 'codex',
|
|
@@ -122,490 +110,6 @@ const UNSUPPORTED_PROVIDER_HINTS = {
|
|
|
122
110
|
],
|
|
123
111
|
};
|
|
124
112
|
|
|
125
|
-
const MIRRORED_STANDARD_COMMAND_SKILLS = new Set([
|
|
126
|
-
'aiwg-setup-project',
|
|
127
|
-
'aiwg-update-claude',
|
|
128
|
-
'aiwg-update-agents-md',
|
|
129
|
-
'sdlc-accelerate',
|
|
130
|
-
'project-status',
|
|
131
|
-
'intake-wizard',
|
|
132
|
-
'intake-from-codebase',
|
|
133
|
-
'intake-start',
|
|
134
|
-
// Issue-workflow entry commands — invoked directly by users; mirror as
|
|
135
|
-
// commands so they reach .opencode/command/, .claude/commands/, etc. (#1549).
|
|
136
|
-
'address-issues',
|
|
137
|
-
'issue-audit',
|
|
138
|
-
]);
|
|
139
|
-
|
|
140
|
-
const MIRRORED_KERNEL_COMMAND_SKILLS = new Set([
|
|
141
|
-
'aiwg-refresh',
|
|
142
|
-
'aiwg-doctor',
|
|
143
|
-
'aiwg-status',
|
|
144
|
-
'aiwg-help',
|
|
145
|
-
'aiwg-regenerate',
|
|
146
|
-
'aiwg-regenerate-claude',
|
|
147
|
-
'aiwg-regenerate-codex',
|
|
148
|
-
'aiwg-regenerate-opencode',
|
|
149
|
-
'aiwg-regenerate-agents',
|
|
150
|
-
'aiwg-issue',
|
|
151
|
-
'aiwg-pr',
|
|
152
|
-
'aiwg-mission',
|
|
153
|
-
'use',
|
|
154
|
-
'steward',
|
|
155
|
-
]);
|
|
156
|
-
|
|
157
|
-
function providerUsesSkillsNatively(providerName) {
|
|
158
|
-
return ['antigravity', 'claude', 'cursor', 'deepseek-harness', 'hermes', 'openhuman', 'pi', 'omp'].includes(providerName);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function shouldMirrorStandardCommandSkill(skillName) {
|
|
162
|
-
return (
|
|
163
|
-
skillName.startsWith('flow-') ||
|
|
164
|
-
MIRRORED_STANDARD_COMMAND_SKILLS.has(skillName)
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function shouldMirrorCommandSkill(providerName, skillName) {
|
|
169
|
-
if (MIRRORED_KERNEL_COMMAND_SKILLS.has(skillName)) {
|
|
170
|
-
return !providerUsesSkillsNatively(providerName);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
return shouldMirrorStandardCommandSkill(skillName);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function uniquePaths(paths) {
|
|
177
|
-
return [...new Set(paths.filter(Boolean))];
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export function collectMirrorSkillDirs(srcRoot, mode, providerName) {
|
|
181
|
-
const dirs = [];
|
|
182
|
-
|
|
183
|
-
const directSkillsDir = path.join(srcRoot, 'skills');
|
|
184
|
-
dirs.push(...listSkillDirs(directSkillsDir));
|
|
185
|
-
|
|
186
|
-
// If --source itself is a skills directory, support that shape too.
|
|
187
|
-
dirs.push(...listSkillDirs(srcRoot));
|
|
188
|
-
|
|
189
|
-
const repoFrameworksRoot = path.join(srcRoot, 'agentic', 'code', 'frameworks');
|
|
190
|
-
if (fs.existsSync(repoFrameworksRoot)) {
|
|
191
|
-
const artifacts = collectFrameworkArtifacts(srcRoot, mode, {
|
|
192
|
-
includeAgents: false,
|
|
193
|
-
includeCommands: false,
|
|
194
|
-
includeSkills: true,
|
|
195
|
-
includeRules: false,
|
|
196
|
-
});
|
|
197
|
-
dirs.push(...artifacts.skills);
|
|
198
|
-
|
|
199
|
-
// Pi's provider collector already deploys all eligible addon skills for
|
|
200
|
-
// every root framework mode. Mirror the command-shaped addon skills in
|
|
201
|
-
// that same root pass so `aiwg use` does not need to repeat the entire
|
|
202
|
-
// deployment once per addon merely to produce these wrappers. Keep addon
|
|
203
|
-
// skills after framework skills: this preserves the existing per-addon
|
|
204
|
-
// winner when a framework and addon expose the same command name.
|
|
205
|
-
if (mode === 'all'
|
|
206
|
-
|| (providerName === 'pi' && ['general', 'sdlc', 'both'].includes(mode))) {
|
|
207
|
-
dirs.push(...getAddonSkillDirs(srcRoot));
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
return uniquePaths(dirs);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
function resolveCommandMirrorDir(provider, target) {
|
|
215
|
-
const commandsPath = provider.paths?.commands;
|
|
216
|
-
if (commandsPath) {
|
|
217
|
-
return path.isAbsolute(commandsPath) ? commandsPath : path.join(target, commandsPath);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// Closest conventional location for providers whose primary command
|
|
221
|
-
// surface is MCP/aggregation rather than a documented command directory.
|
|
222
|
-
if (provider.name === 'hermes') {
|
|
223
|
-
// #2119: HERMES_HOME is the single source of truth the running Hermes
|
|
224
|
-
// runtime uses to locate its files — resolve the home the same way the
|
|
225
|
-
// provider does instead of hardcoding $HOME/.hermes.
|
|
226
|
-
const hermesHome = typeof provider.getHermesHome === 'function'
|
|
227
|
-
? provider.getHermesHome()
|
|
228
|
-
: path.join(os.homedir(), '.hermes');
|
|
229
|
-
return path.resolve(hermesHome, 'commands');
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return null;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function commandFileExtensionForProvider(provider) {
|
|
236
|
-
if (provider.name === 'copilot') return '.prompt.md';
|
|
237
|
-
return '.md';
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function resolveSkillCommandPolicy(commandHint = {}) {
|
|
241
|
-
const legacy = String(commandHint.model || '').trim().toLowerCase();
|
|
242
|
-
const legacyRole = legacy === 'opus' ? 'reasoning'
|
|
243
|
-
: legacy === 'haiku' ? 'efficiency'
|
|
244
|
-
: legacy ? 'coding' : null;
|
|
245
|
-
const modelRole = commandHint.modelRole || legacyRole;
|
|
246
|
-
if (!modelRole) return null;
|
|
247
|
-
const modelTier = commandHint.modelTier
|
|
248
|
-
|| (modelRole === 'reasoning' ? 'premium'
|
|
249
|
-
: modelRole === 'efficiency' ? 'economy' : 'standard');
|
|
250
|
-
return {
|
|
251
|
-
modelRole,
|
|
252
|
-
modelTier,
|
|
253
|
-
modelEffort: commandHint.modelEffort,
|
|
254
|
-
modelRationale: commandHint.modelRationale,
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function parseSkillCommandHint(raw) {
|
|
259
|
-
const { frontmatter } = parseFrontmatter(raw);
|
|
260
|
-
const block = frontmatter?.match(/^commandHint:\s*\n((?:[ \t]+[^\n]*\n?)*)/m)?.[1] || '';
|
|
261
|
-
const hint = {};
|
|
262
|
-
for (const line of block.split('\n')) {
|
|
263
|
-
const match = line.trim().match(/^(model|modelRole|modelTier|modelEffort|modelRationale):\s*(.+)$/);
|
|
264
|
-
if (match) hint[match[1]] = match[2].trim().replace(/^['"]|['"]$/g, '');
|
|
265
|
-
}
|
|
266
|
-
return hint;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function skillToCommandContent(skillDir) {
|
|
270
|
-
const skillName = path.basename(skillDir);
|
|
271
|
-
const skillPath = path.join(skillDir, 'SKILL.md');
|
|
272
|
-
const raw = fs.readFileSync(skillPath, 'utf8');
|
|
273
|
-
const { metadata, body } = parseFrontmatter(raw);
|
|
274
|
-
const description = metadata.description || `Run AIWG skill ${skillName}`;
|
|
275
|
-
const policy = resolveSkillCommandPolicy(parseSkillCommandHint(raw));
|
|
276
|
-
const policyLines = policy ? [
|
|
277
|
-
`aiwg-model-role: ${policy.modelRole}`,
|
|
278
|
-
`aiwg-model-tier: ${policy.modelTier}`,
|
|
279
|
-
...(policy.modelEffort ? [`aiwg-model-effort: ${policy.modelEffort}`] : []),
|
|
280
|
-
...(policy.modelRationale ? [`aiwg-model-rationale: ${policy.modelRationale}`] : []),
|
|
281
|
-
] : [];
|
|
282
|
-
|
|
283
|
-
return `---\nname: ${skillName}\ndescription: ${description}\n${policyLines.join('\n')}${policyLines.length ? '\n' : ''}---\n\n${body.trim()}\n`;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function mirrorSkillsAsCommands(provider, target, srcRoot, opts) {
|
|
287
|
-
if (!opts.deployCommands && !opts.commandsOnly) return 0;
|
|
288
|
-
|
|
289
|
-
const targetDir = resolveCommandMirrorDir(provider, target);
|
|
290
|
-
if (!targetDir) return 0;
|
|
291
|
-
|
|
292
|
-
const skillDirs = collectMirrorSkillDirs(srcRoot, opts.mode, provider.name)
|
|
293
|
-
.filter((dir) => shouldMirrorCommandSkill(provider.name, path.basename(dir)));
|
|
294
|
-
|
|
295
|
-
if (skillDirs.length === 0) return 0;
|
|
296
|
-
if (!opts.dryRun) fs.mkdirSync(targetDir, { recursive: true });
|
|
297
|
-
|
|
298
|
-
const ext = commandFileExtensionForProvider(provider);
|
|
299
|
-
const deployedEntries = [];
|
|
300
|
-
let count = 0;
|
|
301
|
-
|
|
302
|
-
for (const skillDir of skillDirs) {
|
|
303
|
-
const skillName = path.basename(skillDir);
|
|
304
|
-
let content = skillToCommandContent(skillDir);
|
|
305
|
-
if (typeof provider.transformCommand === 'function') {
|
|
306
|
-
content = provider.transformCommand(path.join(skillDir, `${skillName}.md`), content, opts);
|
|
307
|
-
}
|
|
308
|
-
// #2507: mirrored wrappers used to be written with no ownership signal, so
|
|
309
|
-
// AIWG could neither count them as deployed nor prune them when the source
|
|
310
|
-
// skill went away — a later run reported its own 46 wrappers as unmanaged
|
|
311
|
-
// artifacts the operator should delete. They carry the same managed marker
|
|
312
|
-
// and sidecar entry as any other deployed command now.
|
|
313
|
-
content = addManagedMarker(content, opts.deployVersion || 'unknown', opts.deploySource || 'bundled');
|
|
314
|
-
|
|
315
|
-
const filename = `${skillName}${ext}`;
|
|
316
|
-
const dest = path.join(targetDir, filename);
|
|
317
|
-
if (opts.dryRun) {
|
|
318
|
-
if (opts.verbose) console.log(`[dry-run] mirror skill command ${skillName} -> ${dest}`);
|
|
319
|
-
const raw = fs.readFileSync(path.join(skillDir, 'SKILL.md'), 'utf8');
|
|
320
|
-
const policy = resolveSkillCommandPolicy(parseSkillCommandHint(raw));
|
|
321
|
-
if (policy && opts.verbose) {
|
|
322
|
-
const outcome = provider.name === 'claude' ? 'native'
|
|
323
|
-
: provider.name === 'factory' ? 'informational' : 'unsupported';
|
|
324
|
-
console.log(`[dry-run] skill model policy ${skillName}: ${outcome} (${policy.modelRole}/${policy.modelTier})`);
|
|
325
|
-
}
|
|
326
|
-
} else {
|
|
327
|
-
fs.writeFileSync(dest, content, 'utf8');
|
|
328
|
-
}
|
|
329
|
-
deployedEntries.push({ filename, hash: contentHash(content), kind: 'skill-command' });
|
|
330
|
-
count++;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
if (deployedEntries.length > 0) {
|
|
334
|
-
updateSidecarManifest(targetDir, deployedEntries, {
|
|
335
|
-
dryRun: opts.dryRun,
|
|
336
|
-
version: opts.deployVersion || 'unknown',
|
|
337
|
-
source: opts.deploySource || 'bundled',
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
return count;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
export { bulkInstallOwnsFlatArtifacts } from './providers/stale-artifact-prune.mjs';
|
|
346
|
-
import { pruneStaleAiwgArtifacts } from './providers/stale-artifact-prune.mjs';
|
|
347
|
-
|
|
348
|
-
// ============================================================================
|
|
349
|
-
// Argument Parsing
|
|
350
|
-
// ============================================================================
|
|
351
|
-
|
|
352
|
-
export function parseArgs(args = process.argv.slice(2)) {
|
|
353
|
-
const cfg = {
|
|
354
|
-
source: null,
|
|
355
|
-
userScope: false,
|
|
356
|
-
target: process.cwd(),
|
|
357
|
-
mode: 'all', // 'general', 'sdlc', 'marketing', 'media-curator', 'research', 'both' (legacy), or 'all'
|
|
358
|
-
dryRun: false,
|
|
359
|
-
force: false,
|
|
360
|
-
provider: 'claude',
|
|
361
|
-
model: null, // Blanket override for all tiers
|
|
362
|
-
modelTier: null, // Blanket canonical tier override
|
|
363
|
-
reasoningModel: null,
|
|
364
|
-
codingModel: null,
|
|
365
|
-
efficiencyModel: null,
|
|
366
|
-
asAgentsMd: false,
|
|
367
|
-
createAgentsMd: false,
|
|
368
|
-
contextFiles: true,
|
|
369
|
-
projectScope: false,
|
|
370
|
-
deployCommands: false,
|
|
371
|
-
deploySkills: false,
|
|
372
|
-
deployRules: false,
|
|
373
|
-
deployBehaviors: false, // Deploy behaviors (native on openclaw, emulated on others)
|
|
374
|
-
commandsOnly: false,
|
|
375
|
-
skillsOnly: false,
|
|
376
|
-
rulesOnly: false,
|
|
377
|
-
strict: false,
|
|
378
|
-
reportOnly: true,
|
|
379
|
-
kernelOnly: false,
|
|
380
|
-
deferRuleProjection: false,
|
|
381
|
-
additionalSources: [],
|
|
382
|
-
filter: null, // Glob pattern for agent names
|
|
383
|
-
filterRole: null, // Filter by role: reasoning|coding|efficiency
|
|
384
|
-
save: false, // Save model config to project models.json
|
|
385
|
-
saveUser: false, // Save model config to ~/.config/aiwg/models.json
|
|
386
|
-
verbose: false, // Show per-file deployment details
|
|
387
|
-
quiet: false, // Suppress all non-error output (for embedding in use.ts)
|
|
388
|
-
asPlugin: false, // Generate .factory-plugin/ bundle (Factory provider only)
|
|
389
|
-
deployBehaviors: false, // Deploy behaviors in addition to agents
|
|
390
|
-
skipCommandsMigration: false, // Skip commands → skills migration (warns about duplicates)
|
|
391
|
-
warnOnSkippedCommandsMigration: true, // Emit the duplicate warning when the migration is skipped
|
|
392
|
-
// Managed-marker provenance (#2502). Deployers that are not shipping the
|
|
393
|
-
// bundled framework corpus (project-local bundles, in particular) must
|
|
394
|
-
// override these so `aiwg refresh` does not mistake their artifacts for
|
|
395
|
-
// stale copies of packaged ones.
|
|
396
|
-
deploySource: null, // Managed-marker source; defaults to 'bundled'
|
|
397
|
-
listingBudget: false, // Honor the provider startup-listing cap despite --copy-all (#2561)
|
|
398
|
-
deployVersion: null, // Managed-marker version; defaults to srcRoot package.json
|
|
399
|
-
mcp: false, // #228: opt-in MCP settings profile (Muse provider)
|
|
400
|
-
hooks: true, // #228: managed project hooks (Muse provider); --no-hooks opts out
|
|
401
|
-
};
|
|
402
|
-
for (let i = 0; i < args.length; i++) {
|
|
403
|
-
const a = args[i];
|
|
404
|
-
if (a === '--source' && args[i + 1]) cfg.source = path.resolve(args[++i]);
|
|
405
|
-
else if (a === '--additional-source') {
|
|
406
|
-
const source = args[++i];
|
|
407
|
-
if (!source || source.startsWith('--')) throw new Error('--additional-source requires a source directory');
|
|
408
|
-
cfg.additionalSources.push(path.resolve(source));
|
|
409
|
-
}
|
|
410
|
-
else if (a === '--target' && args[i + 1]) cfg.target = path.resolve(args[++i]);
|
|
411
|
-
else if (a === '--mode' && args[i + 1]) cfg.mode = String(args[++i]).toLowerCase();
|
|
412
|
-
else if (a === '--scope') {
|
|
413
|
-
const scope = args[++i];
|
|
414
|
-
if (scope !== 'user' && scope !== 'project') {
|
|
415
|
-
throw new Error(`--scope expected 'user' or 'project', got '${scope ?? '(missing)'}'`);
|
|
416
|
-
}
|
|
417
|
-
cfg.userScope = scope === 'user';
|
|
418
|
-
cfg.projectScope = scope === 'project';
|
|
419
|
-
}
|
|
420
|
-
else if (a === '--user') cfg.userScope = true;
|
|
421
|
-
else if (a === '--dry-run') cfg.dryRun = true;
|
|
422
|
-
else if (a === '--force') cfg.force = true;
|
|
423
|
-
else if ((a === '--provider' || a === '--platform') && args[i + 1]) cfg.provider = String(args[++i]).toLowerCase();
|
|
424
|
-
else if (a === '--model' && args[i + 1]) cfg.model = args[++i];
|
|
425
|
-
else if (a === '--model-tier' && args[i + 1]) cfg.modelTier = String(args[++i]).toLowerCase();
|
|
426
|
-
else if ((a === '--reasoning-model' || a === '--reasoning') && args[i + 1]) cfg.reasoningModel = args[++i];
|
|
427
|
-
else if ((a === '--coding-model' || a === '--coding') && args[i + 1]) cfg.codingModel = args[++i];
|
|
428
|
-
else if ((a === '--efficiency-model' || a === '--efficiency') && args[i + 1]) cfg.efficiencyModel = args[++i];
|
|
429
|
-
else if (a === '--as-agents-md') cfg.asAgentsMd = true;
|
|
430
|
-
else if (a === '--create-agents-md') cfg.createAgentsMd = true;
|
|
431
|
-
else if (a === '--deploy-commands') cfg.deployCommands = true;
|
|
432
|
-
else if (a === '--deploy-skills') cfg.deploySkills = true;
|
|
433
|
-
else if (a === '--deploy-rules') cfg.deployRules = true;
|
|
434
|
-
else if (a === '--deploy-behaviors') cfg.deployBehaviors = true;
|
|
435
|
-
else if (a === '--commands-only') cfg.commandsOnly = true;
|
|
436
|
-
else if (a === '--skills-only') cfg.skillsOnly = true;
|
|
437
|
-
else if (a === '--rules-only') cfg.rulesOnly = true;
|
|
438
|
-
else if (a === '--strict') { cfg.strict = true; cfg.reportOnly = false; }
|
|
439
|
-
else if (a === '--allow-over-budget') cfg.allowOverBudget = true;
|
|
440
|
-
else if (a === '--report-only') cfg.reportOnly = true;
|
|
441
|
-
else if (a === '--kernel-only') cfg.kernelOnly = true;
|
|
442
|
-
// Internal use orchestration: the final source owns rule presentation.
|
|
443
|
-
else if (a === '--defer-rule-projection') cfg.deferRuleProjection = true;
|
|
444
|
-
else if (a === '--deploy-behaviors') cfg.deployBehaviors = true;
|
|
445
|
-
else if (a === '--filter' && args[i + 1]) cfg.filter = args[++i];
|
|
446
|
-
else if (a === '--filter-role' && args[i + 1]) cfg.filterRole = args[++i];
|
|
447
|
-
else if (a === '--save') cfg.save = true;
|
|
448
|
-
else if (a === '--save-user') cfg.saveUser = true;
|
|
449
|
-
else if (a === '--verbose' || a === '-v') cfg.verbose = true;
|
|
450
|
-
else if (a === '--quiet' || a === '-q') cfg.quiet = true;
|
|
451
|
-
else if (a === '--as-plugin') cfg.asPlugin = true;
|
|
452
|
-
else if (a === '--skip-commands-migration') cfg.skipCommandsMigration = true;
|
|
453
|
-
// Structural opt-out: skip the migration without claiming the operator declined it (#2541).
|
|
454
|
-
else if (a === '--no-commands-warning') cfg.warnOnSkippedCommandsMigration = false;
|
|
455
|
-
else if (a === '--copy-all' || a === '--copy-standard-skills') cfg.copyStandardSkills = true;
|
|
456
|
-
// #228: Muse provider — explicit opt-in MCP settings profile, and the
|
|
457
|
-
// managed-hooks opt-out (default on, mirroring the Claude autoInstall policy).
|
|
458
|
-
else if (a === '--mcp') cfg.mcp = true;
|
|
459
|
-
else if (a === '--no-hooks') cfg.hooks = false;
|
|
460
|
-
else if (a === '--no-attribution') cfg.attribution = false;
|
|
461
|
-
else if (a === '--no-context-files') cfg.contextFiles = false;
|
|
462
|
-
else if (a === '--deploy-source' && args[i + 1]) cfg.deploySource = String(args[++i]);
|
|
463
|
-
else if (a === '--listing-budget') cfg.listingBudget = true;
|
|
464
|
-
else if (a === '--deploy-version' && args[i + 1]) cfg.deployVersion = String(args[++i]);
|
|
465
|
-
else if (a === '--help' || a === '-h') {
|
|
466
|
-
cfg.help = true;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
return cfg;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
function printHelp() {
|
|
473
|
-
console.log(`
|
|
474
|
-
Deploy Agents and Commands
|
|
475
|
-
|
|
476
|
-
Usage:
|
|
477
|
-
node tools/agents/deploy-agents.mjs [options]
|
|
478
|
-
aiwg -deploy-agents [options]
|
|
479
|
-
|
|
480
|
-
Options:
|
|
481
|
-
--source <path> Source directory (defaults to repo root)
|
|
482
|
-
--target <path> Target directory (defaults to cwd)
|
|
483
|
-
--scope <user|project> Deployment scope (default: project)
|
|
484
|
-
--user Shorthand for --scope user
|
|
485
|
-
--mode <type> Deployment mode: general, sdlc, marketing (alias: mmk), media-curator, research, both, or all (default)
|
|
486
|
-
--deploy-commands Deploy commands in addition to agents
|
|
487
|
-
--deploy-skills Deploy skills in addition to agents
|
|
488
|
-
--deploy-rules Deploy rules in addition to agents
|
|
489
|
-
--commands-only Deploy only commands (skip agents)
|
|
490
|
-
--skills-only Deploy only skills (skip agents)
|
|
491
|
-
--rules-only Deploy only rules (skip agents)
|
|
492
|
-
--kernel-only Deploy kernel skills and rules; prune managed bulk agents/commands
|
|
493
|
-
--dry-run Show what would be deployed without writing
|
|
494
|
-
--force Overwrite existing files
|
|
495
|
-
--provider <name> Target provider (see below)
|
|
496
|
-
--model <name> Override model for all tiers (blanket)
|
|
497
|
-
--reasoning-model <name> Override model for reasoning tasks (alias: --reasoning)
|
|
498
|
-
--coding-model <name> Override model for coding tasks (alias: --coding)
|
|
499
|
-
--efficiency-model <name> Override model for efficiency tasks (alias: --efficiency)
|
|
500
|
-
--model-tier <tier> Override all artifacts with economy|standard|premium
|
|
501
|
-
--filter <pattern> Only deploy agents matching pattern (glob)
|
|
502
|
-
--filter-role <role> Only deploy agents of role: reasoning|coding|efficiency
|
|
503
|
-
--save Save model config to project models.json
|
|
504
|
-
--save-user Save model config to ~/.config/aiwg/models.json
|
|
505
|
-
--mcp Muse provider: opt in to the AIWG MCP settings profile
|
|
506
|
-
(merges the aiwg stdio server into user settings
|
|
507
|
-
mcp_servers; default off)
|
|
508
|
-
--no-hooks Muse provider: skip managed project hooks
|
|
509
|
-
(.muse/hooks.json; installed by default)
|
|
510
|
-
--no-attribution Claude provider: leave attribution settings untouched
|
|
511
|
-
--as-agents-md Aggregate to single AGENTS.md (Codex)
|
|
512
|
-
--create-agents-md Create/update AGENTS.md template
|
|
513
|
-
--no-context-files Preserve WORKSPACE.md, AIWG.md and AGENTS.md (including managed blocks)
|
|
514
|
-
--skip-commands-migration Skip deleting the commands directory before skills deployment
|
|
515
|
-
--listing-budget Honor the provider startup-listing cap even with --copy-all
|
|
516
|
-
--deploy-source <name> Managed-marker source stamped into deployed artifacts.
|
|
517
|
-
Defaults to 'bundled'. Deploys that do not ship the packaged
|
|
518
|
-
framework corpus (e.g. project-local bundles) MUST override
|
|
519
|
-
this so refresh's stale-artifact prune skips them (#2502).
|
|
520
|
-
--deploy-version <version> Managed-marker version stamped into deployed artifacts.
|
|
521
|
-
Defaults to the --source tree's package.json version.
|
|
522
|
-
--copy-all Copy ALL skills per-project (legacy mirror at <provider>/.aiwg/skills/).
|
|
523
|
-
For aiwg use all, this also restores the legacy full agent,
|
|
524
|
-
command, and expanded-rule copy. Default bulk deployment is
|
|
525
|
-
kernel-only + index-driven discovery for the rest (#1217).
|
|
526
|
-
Use this for sandboxed runtimes / air-gapped corpora where
|
|
527
|
-
$AIWG_ROOT isn't readable from the agent's working dir.
|
|
528
|
-
Alias: --copy-standard-skills — rc.29 era).
|
|
529
|
-
(warns about duplicate entries in the provider command palette)
|
|
530
|
-
|
|
531
|
-
Model Override Examples:
|
|
532
|
-
# Use sonnet for everything
|
|
533
|
-
aiwg use sdlc --model sonnet
|
|
534
|
-
|
|
535
|
-
# Override individual tiers
|
|
536
|
-
aiwg use sdlc --reasoning opus --coding sonnet --efficiency haiku
|
|
537
|
-
|
|
538
|
-
# Use a specific model ID for coding tier
|
|
539
|
-
aiwg use sdlc --provider factory --coding-model gpt-5.6-terra
|
|
540
|
-
|
|
541
|
-
# Blanket with per-tier override (reasoning uses opus, others use sonnet)
|
|
542
|
-
aiwg use sdlc --model sonnet --reasoning opus
|
|
543
|
-
|
|
544
|
-
# Save overrides to project models.json for future deployments
|
|
545
|
-
aiwg use sdlc --model sonnet --save
|
|
546
|
-
|
|
547
|
-
Model Precedence:
|
|
548
|
-
CLI flags > project models.json > user ~/.config/aiwg/models.json > AIWG defaults
|
|
549
|
-
|
|
550
|
-
Shorthand Values:
|
|
551
|
-
opus, sonnet, haiku, inherit — resolved per provider to full model IDs
|
|
552
|
-
|
|
553
|
-
Providers (all deploy agents, commands, skills, and rules):
|
|
554
|
-
claude - Claude Code (default)
|
|
555
|
-
Paths: .claude/agents/, .claude/commands/, .claude/skills/, .claude/rules/
|
|
556
|
-
factory - Factory AI
|
|
557
|
-
Paths: .factory/droids/, .factory/commands/, .factory/skills/, .factory/rules/
|
|
558
|
-
codex - OpenAI Codex (alias: openai)
|
|
559
|
-
Paths: .codex/agents/, .codex/commands/, .codex/skills/, .codex/rules/
|
|
560
|
-
opencode - OpenCode
|
|
561
|
-
Paths: .opencode/skill/, .opencode/rule/ (agents/commands not file-based in OpenCode)
|
|
562
|
-
copilot - GitHub Copilot
|
|
563
|
-
Paths: .github/agents/, .github/commands/, .github/skills/, .github/copilot-rules/
|
|
564
|
-
cursor - Cursor IDE
|
|
565
|
-
Paths: .cursor/agents/, .cursor/commands/, .cursor/skills/, .cursor/rules/
|
|
566
|
-
warp - Warp Terminal
|
|
567
|
-
Paths: .warp/agents/, .warp/commands/, .warp/skills/, .warp/rules/ + WARP.md
|
|
568
|
-
deepseek-harness - DeepSeek Harness (alias: dsh; experimental)
|
|
569
|
-
Paths: AGENTS.md, .agents/skills/, .dsh/aiwg.cordis.patch.yml
|
|
570
|
-
devin - Devin Desktop (preferred; aliases: devin-desktop, windsurf)
|
|
571
|
-
Paths: .windsurf/agents/, .windsurf/workflows/, .windsurf/skills/, .windsurf/rules/
|
|
572
|
-
grokbot - Grok Bot (AGENTS.md bridge; skills only with AIWG_GROKBOT_SKILLS_DIR)
|
|
573
|
-
grok-build - Grok Build (experimental; .grok paths + $GROK_HOME; no bare grok alias)
|
|
574
|
-
muse - Muse Code (stable; AGENTS.md bridge; .agents/skills + XDG user root; managed hooks, opt-in --mcp; no aliases)
|
|
575
|
-
hermes - Hermes Agent (MCP-based integration)
|
|
576
|
-
Skills: $HERMES_HOME/skills/ (user-global; defaults to ~/.hermes/skills/) | Agents: AGENTS.md
|
|
577
|
-
Commands/Rules: served via MCP, not file-deployed
|
|
578
|
-
|
|
579
|
-
Modes:
|
|
580
|
-
general - Writing-quality addon agents and commands (alias: writing)
|
|
581
|
-
sdlc - SDLC Complete framework agents and commands
|
|
582
|
-
marketing - Media/Marketing Kit framework agents and commands (alias: mmk)
|
|
583
|
-
media-curator - Media Curator framework agents and commands
|
|
584
|
-
research - Research Complete framework agents and commands
|
|
585
|
-
both - writing + SDLC (legacy compatibility)
|
|
586
|
-
all - All frameworks + addons (default)
|
|
587
|
-
|
|
588
|
-
Examples:
|
|
589
|
-
# Deploy SDLC framework to Claude Code
|
|
590
|
-
aiwg -deploy-agents --mode sdlc
|
|
591
|
-
|
|
592
|
-
# Deploy to Factory with commands and AGENTS.md
|
|
593
|
-
aiwg -deploy-agents --provider factory --mode sdlc --deploy-commands --create-agents-md
|
|
594
|
-
|
|
595
|
-
# Deploy to GitHub Copilot
|
|
596
|
-
aiwg -deploy-agents --provider copilot --mode sdlc
|
|
597
|
-
|
|
598
|
-
# Override model for all tiers
|
|
599
|
-
aiwg -deploy-agents --mode sdlc --model sonnet
|
|
600
|
-
|
|
601
|
-
# Override individual tiers
|
|
602
|
-
aiwg -deploy-agents --mode sdlc --reasoning opus --coding sonnet --efficiency haiku
|
|
603
|
-
|
|
604
|
-
# Dry run to preview deployment
|
|
605
|
-
aiwg -deploy-agents --provider cursor --mode sdlc --dry-run
|
|
606
|
-
`);
|
|
607
|
-
}
|
|
608
|
-
|
|
609
113
|
// ============================================================================
|
|
610
114
|
// Provider Loading
|
|
611
115
|
// ============================================================================
|
|
@@ -613,7 +117,7 @@ Examples:
|
|
|
613
117
|
/**
|
|
614
118
|
* Resolve provider name (handle aliases)
|
|
615
119
|
*/
|
|
616
|
-
function resolveProvider(name) {
|
|
120
|
+
export function resolveProvider(name) {
|
|
617
121
|
const candidate = String(name || '').trim().toLowerCase();
|
|
618
122
|
const resolved = PROVIDER_ALIASES[candidate] || candidate;
|
|
619
123
|
if (!AVAILABLE_PROVIDERS.includes(resolved)) {
|
|
@@ -632,7 +136,7 @@ function resolveProvider(name) {
|
|
|
632
136
|
/**
|
|
633
137
|
* Dynamically load provider module
|
|
634
138
|
*/
|
|
635
|
-
async function loadProvider(providerName) {
|
|
139
|
+
export async function loadProvider(providerName) {
|
|
636
140
|
const resolved = resolveProvider(providerName);
|
|
637
141
|
// Resolve against this module, not the caller's cwd: in-process callers
|
|
638
142
|
// (including module runners such as Vitest) cannot resolve a bare relative
|
|
@@ -648,187 +152,16 @@ async function loadProvider(providerName) {
|
|
|
648
152
|
}
|
|
649
153
|
}
|
|
650
154
|
|
|
651
|
-
// ============================================================================
|
|
652
|
-
// Model Shorthand Resolution
|
|
653
|
-
// ============================================================================
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* Resolve a shorthand model value to a full model ID
|
|
657
|
-
*
|
|
658
|
-
* If the value is a known shorthand (opus, sonnet, haiku, inherit), resolve it
|
|
659
|
-
* through the provider's shorthand map. Otherwise treat it as a literal model ID.
|
|
660
|
-
*
|
|
661
|
-
* @param {string|null} value - CLI flag value (e.g., "opus" or "claude-opus-5")
|
|
662
|
-
* @param {object} shorthandMap - Provider shorthand map (e.g., { opus: "claude-opus-5" })
|
|
663
|
-
* @param {object} modelsConfig - Full models config from loadModelConfig()
|
|
664
|
-
* @param {string} provider - Provider name
|
|
665
|
-
* @param {string} tier - Tier name: "reasoning", "coding", or "efficiency"
|
|
666
|
-
* @returns {string|null} Resolved model ID or null if input was null
|
|
667
|
-
*/
|
|
668
|
-
function resolveShorthand(value, shorthandMap, modelsConfig, provider, tier) {
|
|
669
|
-
if (!value) return null;
|
|
670
|
-
|
|
671
|
-
const clean = value.toLowerCase().replace(/['"]/g, '');
|
|
672
|
-
|
|
673
|
-
// Check shorthand map first
|
|
674
|
-
if (shorthandMap[clean]) return shorthandMap[clean];
|
|
675
|
-
|
|
676
|
-
// Check provider-specific tier config (e.g., modelsConfig.factory.reasoning.model)
|
|
677
|
-
const providerConfig = modelsConfig?.[provider];
|
|
678
|
-
if (providerConfig?.[tier]?.model && clean === tier) {
|
|
679
|
-
return providerConfig[tier].model;
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
// Not a shorthand — return as literal model ID
|
|
683
|
-
return value;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
// ============================================================================
|
|
687
|
-
// Model Configuration Persistence
|
|
688
|
-
// ============================================================================
|
|
689
|
-
|
|
690
|
-
/**
|
|
691
|
-
* Save model configuration to project or user config file
|
|
692
|
-
* @param {object} cfg - Configuration with model overrides
|
|
693
|
-
* @param {string} providerName - Provider name for provider-specific config
|
|
694
|
-
*/
|
|
695
|
-
async function saveModelConfig(cfg, providerName) {
|
|
696
|
-
// Build config object with only the provided overrides
|
|
697
|
-
const modelConfig = {};
|
|
698
|
-
if (cfg.modelTier) {
|
|
699
|
-
modelConfig.defaults = { tier: cfg.modelTier };
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
// Provider-specific tier configuration
|
|
703
|
-
if (cfg.reasoningModel || cfg.codingModel || cfg.efficiencyModel) {
|
|
704
|
-
modelConfig[providerName] = {};
|
|
705
|
-
if (cfg.reasoningModel) {
|
|
706
|
-
modelConfig[providerName].reasoning = { model: cfg.reasoningModel };
|
|
707
|
-
}
|
|
708
|
-
if (cfg.codingModel) {
|
|
709
|
-
modelConfig[providerName].coding = { model: cfg.codingModel };
|
|
710
|
-
}
|
|
711
|
-
if (cfg.efficiencyModel) {
|
|
712
|
-
modelConfig[providerName].efficiency = { model: cfg.efficiencyModel };
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
155
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
modelConfig.shorthand = {};
|
|
719
|
-
if (cfg.reasoningModel) modelConfig.shorthand.opus = cfg.reasoningModel;
|
|
720
|
-
if (cfg.codingModel) modelConfig.shorthand.sonnet = cfg.codingModel;
|
|
721
|
-
if (cfg.efficiencyModel) modelConfig.shorthand.haiku = cfg.efficiencyModel;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
// Determine target path
|
|
725
|
-
let targetPath;
|
|
726
|
-
if (cfg.saveUser) {
|
|
727
|
-
const configDir = path.join(os.homedir(), '.config', 'aiwg');
|
|
728
|
-
if (!fs.existsSync(configDir)) {
|
|
729
|
-
fs.mkdirSync(configDir, { recursive: true });
|
|
730
|
-
}
|
|
731
|
-
targetPath = path.join(configDir, 'models.json');
|
|
732
|
-
} else {
|
|
733
|
-
targetPath = path.join(cfg.target, 'models.json');
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
// Merge with existing config if it exists
|
|
737
|
-
let existingConfig = {};
|
|
738
|
-
if (fs.existsSync(targetPath)) {
|
|
739
|
-
try {
|
|
740
|
-
existingConfig = JSON.parse(fs.readFileSync(targetPath, 'utf8'));
|
|
741
|
-
} catch {
|
|
742
|
-
// Ignore parse errors, start fresh
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
// Deep merge: existing config + new overrides
|
|
747
|
-
const mergedConfig = deepMerge(existingConfig, modelConfig);
|
|
748
|
-
|
|
749
|
-
// Write the config
|
|
750
|
-
fs.writeFileSync(targetPath, JSON.stringify(mergedConfig, null, 2) + '\n', 'utf8');
|
|
751
|
-
console.log(`\nModel configuration saved to: ${targetPath}`);
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
/**
|
|
755
|
-
* Deep merge two objects
|
|
756
|
-
*/
|
|
757
|
-
function deepMerge(target, source) {
|
|
758
|
-
const result = { ...target };
|
|
759
|
-
for (const key of Object.keys(source)) {
|
|
760
|
-
if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
|
|
761
|
-
result[key] = deepMerge(result[key] || {}, source[key]);
|
|
762
|
-
} else {
|
|
763
|
-
result[key] = source[key];
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
return result;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
// ============================================================================
|
|
770
|
-
// Commands → Skills Migration
|
|
771
|
-
// ============================================================================
|
|
772
|
-
|
|
773
|
-
/**
|
|
774
|
-
* Ask the user whether to delete the provider's commands directory before
|
|
775
|
-
* deploying skills. Skipped automatically when not running in a TTY (CI/pipe)
|
|
776
|
-
* or when --quiet is set.
|
|
777
|
-
*
|
|
778
|
-
* @param {object} cfg - Parsed CLI config
|
|
779
|
-
* @param {object} provider - Loaded provider module
|
|
780
|
-
* @param {string} targetDir - Resolved target directory
|
|
781
|
-
* @returns {Promise<boolean>} true = proceed with migration, false = skip
|
|
782
|
-
*/
|
|
783
|
-
async function promptCommandsMigration(cfg, provider, targetDir, interactive = process.stdout.isTTY) {
|
|
784
|
-
// Home-directory providers share commands across projects — do not delete.
|
|
785
|
-
if (provider.capabilities?.homeDirectoryDeploy) return false;
|
|
786
|
-
// Some providers intentionally expose both surfaces with different runtime
|
|
787
|
-
// semantics. Pi prompt templates (/name) are not aliases for Agent Skills
|
|
788
|
-
// (/skill:name), so command-to-skill migration would destroy valid prompts.
|
|
789
|
-
if (provider.capabilities?.parallelCommandAndSkillSurfaces) return false;
|
|
790
|
-
|
|
791
|
-
const commandsRelPath = provider.paths?.commands;
|
|
792
|
-
if (!commandsRelPath) return false;
|
|
793
|
-
|
|
794
|
-
const commandsDir = path.join(targetDir, commandsRelPath);
|
|
795
|
-
if (!fs.existsSync(commandsDir)) return false;
|
|
796
|
-
|
|
797
|
-
const entries = fs.readdirSync(commandsDir).filter(e => e.endsWith('.md'));
|
|
798
|
-
if (entries.length === 0) return false;
|
|
799
|
-
|
|
800
|
-
// Non-interactive context: migrate silently.
|
|
801
|
-
if (cfg.quiet || !interactive) return true;
|
|
802
|
-
|
|
803
|
-
const rel = path.relative(process.cwd(), commandsDir);
|
|
804
|
-
console.log(`\n⚠ Commands → Skills Migration`);
|
|
805
|
-
console.log(` ${rel} contains ${entries.length} legacy command file(s).`);
|
|
806
|
-
console.log(` AIWG now serves these as skills (.claude/skills/).`);
|
|
807
|
-
console.log(` Keeping both causes duplicate entries in the Claude Code command palette.`);
|
|
808
|
-
console.log('');
|
|
809
|
-
|
|
810
|
-
const answer = await new Promise(resolve => {
|
|
811
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
812
|
-
rl.question(' Remove commands directory and migrate? [Y/n] ', ans => {
|
|
813
|
-
rl.close();
|
|
814
|
-
resolve(ans.trim().toLowerCase());
|
|
815
|
-
});
|
|
816
|
-
});
|
|
817
|
-
|
|
818
|
-
if (answer === 'n' || answer === 'no') {
|
|
819
|
-
console.log('');
|
|
820
|
-
console.log(' Skipping migration. Run `aiwg use` again without --skip-commands-migration');
|
|
821
|
-
console.log(` to clean up, or delete ${rel} manually.`);
|
|
822
|
-
console.log('');
|
|
823
|
-
return false;
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
return true;
|
|
827
|
-
}
|
|
156
|
+
export { bulkInstallOwnsFlatArtifacts } from './providers/stale-artifact-prune.mjs';
|
|
157
|
+
import { pruneStaleAiwgArtifacts } from './providers/stale-artifact-prune.mjs';
|
|
828
158
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
159
|
+
export { parseArgs } from './deploy-options.mjs';
|
|
160
|
+
export { collectMirrorSkillDirs } from './deploy-command-mirrors.mjs';
|
|
161
|
+
import { parseArgs, printHelp } from './deploy-options.mjs';
|
|
162
|
+
import { mirrorSkillsAsCommands } from './deploy-command-mirrors.mjs';
|
|
163
|
+
import { resolveShorthand, saveModelConfig, promptCommandsMigration } from './deploy-support.mjs';
|
|
164
|
+
const { captureDeploymentOutputs, recordDeploymentOutputs, deploymentOutputRoots } = await importImpl(import.meta.url, 'providers/deployment-ownership.mjs');
|
|
832
165
|
|
|
833
166
|
export async function main(args = process.argv.slice(2), internal = {}) {
|
|
834
167
|
const cfg = parseArgs(args);
|
|
@@ -912,7 +245,9 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
912
245
|
if (!cfg.quiet) console.log(`\nLoaded provider: ${provider.name}`);
|
|
913
246
|
|
|
914
247
|
// Build options for provider
|
|
248
|
+
const { writeContextFileSync } = await import('./providers/context-write.mjs');
|
|
915
249
|
const opts = {
|
|
250
|
+
writeReceipt: writeContextFileSync,
|
|
916
251
|
srcRoot,
|
|
917
252
|
target: cfg.target,
|
|
918
253
|
...(cfg.userScope ? { userScope: true } : {}),
|
|
@@ -1006,6 +341,9 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
1006
341
|
// must remain on the same side of the transaction boundary as serial deploy.
|
|
1007
342
|
if (internal.preflightOnly) return;
|
|
1008
343
|
|
|
344
|
+
const ownershipRoots = deploymentOutputRoots(provider, cfg.target);
|
|
345
|
+
const ownershipBefore = cfg.dryRun || preparationActive || internal.preflightOnly ? null : captureDeploymentOutputs(ownershipRoots);
|
|
346
|
+
|
|
1009
347
|
// Delegate to provider
|
|
1010
348
|
try {
|
|
1011
349
|
if (!internal.finalizeOnly) {
|
|
@@ -1046,6 +384,7 @@ export async function main(args = process.argv.slice(2), internal = {}) {
|
|
|
1046
384
|
await saveModelConfig(cfg, provider.name);
|
|
1047
385
|
}
|
|
1048
386
|
|
|
387
|
+
if (ownershipBefore) recordDeploymentOutputs(ownershipBefore, ownershipRoots, opts);
|
|
1049
388
|
if (!cfg.quiet) console.log(`\n=== Deployment complete ===\n`);
|
|
1050
389
|
} catch (err) {
|
|
1051
390
|
if (preparationActive || internal.finalizeOnly) throw err;
|