@aiwg/cli 2026.10.16 → 2026.10.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agentic/code/providers/capability-matrix.yaml +51 -0
- package/agentic/code/providers/flue/README.md +62 -0
- package/agentic/code/providers/flue/templates/aiwg/tools.ts +120 -0
- package/agentic/code/providers/model-capabilities.v1.json +23 -0
- package/agentic/code/providers/model-catalog.v1.json +9 -0
- package/dist/src/artifacts/corpus-tools/resolve.js +28 -6
- 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/help.js +1 -1
- package/dist/src/cli/handlers/init.js +1 -0
- 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/handlers/use.js +11 -5
- package/dist/src/cli/scope-resolver.js +1 -142
- package/dist/src/cli/services/deployment-verification.js +3 -0
- 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/memory/provider-memory-adapter.js +1 -0
- package/dist/src/mission-protocol/worker-review-gate.js +7 -0
- package/dist/src/models/model-capabilities.v1.json +23 -0
- package/dist/src/models/model-catalog.v1.json +9 -0
- package/dist/src/models/policy-resources.js +1 -1
- 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/capability-matrix.yaml +51 -0
- package/dist/src/providers/context-output-ownership.js +26 -0
- package/dist/src/providers/deployment-ownership.d.mts +20 -0
- package/dist/src/providers/deployment-ownership.mjs +236 -0
- package/dist/src/providers/deployment-removal.js +222 -0
- package/dist/src/providers/provider-context-contracts.js +8 -0
- package/dist/src/providers/provider-definition-schema.js +1 -0
- package/dist/src/providers/provider-definitions.js +1 -0
- package/dist/src/providers/provider-seeds-3.js +18 -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 +20 -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 +66 -8
- 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/skills/deployment-ownership.js +2 -2
- package/dist/src/skills/deployment-policy.js +9 -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/flue-context.js +25 -0
- package/dist/src/smiths/context-pipeline/generator.js +7 -2
- package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +9 -7
- package/dist/src/smiths/hook-bridge/index.js +9 -0
- package/package.json +5 -1
- package/schemas/decision/D17StudyProtocol.v1.schema.json +39 -67
- package/tools/agents/deploy-agents.mjs +21 -680
- package/tools/agents/deploy-command-mirrors.mjs +229 -0
- package/tools/agents/deploy-options.mjs +267 -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/flue-project.mjs +79 -0
- package/tools/agents/providers/flue-specialists.mjs +64 -0
- package/tools/agents/providers/flue.mjs +50 -0
- 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 +33 -5
- package/tools/agents/providers/rule-deployment-commit.mjs +19 -15
- package/tools/agents/providers/rule-deployment-prepare.mjs +13 -3
- package/tools/agents/providers/rule-projection.mjs +3 -0
- package/tools/agents/providers/rule-startup.mjs +3 -3
- package/tools/agents/use-rule-selection.mjs +17 -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
|
@@ -1,1989 +1,23 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Subcommand Handlers
|
|
3
|
-
*
|
|
4
|
-
* Handlers for MCP, catalog, plugin, and other subcommands.
|
|
5
|
-
* Handles CLI subcommand routing.
|
|
6
|
-
*
|
|
7
|
-
* @implements @.aiwg/architecture/decisions/ADR-001-unified-extension-system.md
|
|
8
|
-
* @implements #56, #57
|
|
9
|
-
* @source @src/cli/router.ts
|
|
10
|
-
* @tests @test/unit/cli/handlers/subcommands.test.ts
|
|
11
|
-
* @issue #33
|
|
12
|
-
*/
|
|
13
|
-
import { createScriptRunner } from "./script-runner.js";
|
|
14
|
-
import { getFrameworkRoot } from "../../channel/manager.mjs";
|
|
15
|
-
import { getRegistry } from "../../extensions/registry.js";
|
|
16
|
-
import { registerDeployedExtensions } from "../../extensions/deployment-registration.js";
|
|
17
|
-
import { discoverProjectLocalBundles } from "../../extensions/project-local-discovery.js";
|
|
18
|
-
import { buildUpstreamRegistry } from "../../extensions/upstream-registry.js";
|
|
19
|
-
import { resolveShadows } from "../../extensions/shadow-resolver.js";
|
|
20
1
|
import { sessionHandler } from "./session.js";
|
|
21
2
|
import { feedbackHandler } from "./feedback.js";
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
import {
|
|
27
|
-
|
|
28
|
-
import
|
|
29
|
-
|
|
30
|
-
import
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return { exitCode: 0, message: 'Usage: aiwg quickref generate|deploy --project [--provider <id>] [--dry-run]', rawOutput: true };
|
|
41
|
-
},
|
|
42
|
-
async execute(ctx) {
|
|
43
|
-
const action = ctx.args.find(arg => !arg.startsWith('-')) ?? 'generate';
|
|
44
|
-
if (!ctx.args.includes('--project')) {
|
|
45
|
-
return { exitCode: 1, message: 'Error: project quickrefs require --project\n\nUsage: aiwg quickref generate|deploy --project [--provider <id>] [--dry-run]' };
|
|
46
|
-
}
|
|
47
|
-
if (!['generate', 'deploy'].includes(action)) {
|
|
48
|
-
return { exitCode: 1, message: `Error: unknown quickref action '${action}' (expected generate or deploy)` };
|
|
49
|
-
}
|
|
50
|
-
const { generateProjectQuickref, deployProjectQuickref, } = await import('../../extensions/project-quickref.js');
|
|
51
|
-
try {
|
|
52
|
-
if (action === 'generate') {
|
|
53
|
-
const result = await generateProjectQuickref(ctx.cwd, { dryRun: ctx.dryRun });
|
|
54
|
-
const verb = ctx.dryRun ? 'Would generate' : result.changed ? 'Generated' : 'Unchanged';
|
|
55
|
-
console.log(`${verb} ${result.skillName}`);
|
|
56
|
-
console.log(` Source: ${result.sourcePath}`);
|
|
57
|
-
console.log(` Output: ${result.outputPath}`);
|
|
58
|
-
for (const warning of result.warnings)
|
|
59
|
-
console.log(` Warning: ${warning}`);
|
|
60
|
-
if (ctx.dryRun) {
|
|
61
|
-
console.log('\n--- preview ---\n');
|
|
62
|
-
console.log(result.content);
|
|
63
|
-
}
|
|
64
|
-
return { exitCode: 0 };
|
|
65
|
-
}
|
|
66
|
-
const providerIndex = ctx.args.indexOf('--provider');
|
|
67
|
-
const explicitProvider = providerIndex >= 0 ? ctx.args[providerIndex + 1] : undefined;
|
|
68
|
-
const { readAiwgConfig } = await import('../../config/aiwg-config.js');
|
|
69
|
-
const config = await readAiwgConfig(ctx.cwd);
|
|
70
|
-
const providers = explicitProvider ? [explicitProvider] : (config?.providers ?? []);
|
|
71
|
-
if (providers.length === 0) {
|
|
72
|
-
return { exitCode: 1, message: 'No providers configured. Pass --provider <id> or add providers to .aiwg/aiwg.config.' };
|
|
73
|
-
}
|
|
74
|
-
for (const provider of providers) {
|
|
75
|
-
const result = await deployProjectQuickref(ctx.cwd, provider, { dryRun: ctx.dryRun });
|
|
76
|
-
const verb = ctx.dryRun ? 'Would deploy' : result.changed ? 'Deployed' : 'Unchanged';
|
|
77
|
-
console.log(`${verb} ${result.skillName} -> ${result.provider}: ${result.targetPath}${result.emulated ? ' (emulated skill surface)' : ''}`);
|
|
78
|
-
for (const stale of result.pruned) {
|
|
79
|
-
console.log(` ${ctx.dryRun ? 'Would prune' : 'Pruned'} stale managed quickref: ${stale}`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return { exitCode: 0 };
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
return { exitCode: 1, message: `Project quickref failed: ${error.message}` };
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
};
|
|
89
|
-
const LIST_PROVIDER_TARGETS = [
|
|
90
|
-
{ name: 'claude', root: '.claude', agentsPath: '.claude/agents', skillsPath: '.claude/skills', commandsPath: '.claude/commands' },
|
|
91
|
-
{ name: 'codex', root: '.codex', agentsPath: '.codex/agents', skillsPath: '.codex/skills', commandsPath: '.codex/commands' },
|
|
92
|
-
{ name: 'copilot', root: '.github', agentsPath: '.github/agents', skillsPath: '.github/skills', commandsPath: '.github/prompts' },
|
|
93
|
-
{ name: 'cursor', root: '.cursor', agentsPath: '.cursor/agents', skillsPath: '.cursor/skills', commandsPath: '.cursor/commands' },
|
|
94
|
-
{ name: 'opencode', root: '.opencode', agentsPath: '.opencode/agent', skillsPath: '.opencode/skill', commandsPath: '.opencode/command' },
|
|
95
|
-
{ name: 'warp', root: '.warp', agentsPath: '.warp/agents', skillsPath: '.warp/skills', commandsPath: '.warp/commands' },
|
|
96
|
-
{ name: 'factory', root: '.factory', agentsPath: '.factory/droids', skillsPath: '.factory/skills', commandsPath: '.factory/commands' },
|
|
97
|
-
{ name: 'windsurf', root: '.windsurf', agentsPath: '.windsurf/agents', skillsPath: '.windsurf/skills', commandsPath: '.windsurf/workflows' },
|
|
98
|
-
{ name: 'universal', root: '.agents', agentsPath: '.agents/agents', skillsPath: '.agents/skills', commandsPath: '.agents/commands' },
|
|
99
|
-
];
|
|
100
|
-
function hasAnyPopulated(cwd, p) {
|
|
101
|
-
const candidates = [p.agentsPath, p.skillsPath, p.commandsPath];
|
|
102
|
-
for (const rel of candidates) {
|
|
103
|
-
const abs = path.join(cwd, rel);
|
|
104
|
-
try {
|
|
105
|
-
if (fsSync.statSync(abs).isDirectory() && fsSync.readdirSync(abs).length > 0)
|
|
106
|
-
return true;
|
|
107
|
-
}
|
|
108
|
-
catch {
|
|
109
|
-
// dir doesn't exist or unreadable — skip
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return false;
|
|
113
|
-
}
|
|
114
|
-
function detectDeployedProviders(cwd) {
|
|
115
|
-
return LIST_PROVIDER_TARGETS.filter(p => hasAnyPopulated(cwd, p));
|
|
116
|
-
}
|
|
117
|
-
const REMOVE_FLAGS_WITH_VALUES = new Set([
|
|
118
|
-
'--provider',
|
|
119
|
-
'--platform',
|
|
120
|
-
'--scope',
|
|
121
|
-
'--target',
|
|
122
|
-
]);
|
|
123
|
-
function firstRemovePositional(args) {
|
|
124
|
-
for (let i = 0; i < args.length; i += 1) {
|
|
125
|
-
const arg = args[i];
|
|
126
|
-
if (REMOVE_FLAGS_WITH_VALUES.has(arg)) {
|
|
127
|
-
i += 1;
|
|
128
|
-
continue;
|
|
129
|
-
}
|
|
130
|
-
if (!arg.startsWith('-'))
|
|
131
|
-
return arg;
|
|
132
|
-
}
|
|
133
|
-
return undefined;
|
|
134
|
-
}
|
|
135
|
-
function parseRemoveProvider(args) {
|
|
136
|
-
const idx = args.findIndex(a => a === '--provider' || a === '--platform');
|
|
137
|
-
if (idx < 0)
|
|
138
|
-
return {};
|
|
139
|
-
const provider = args[idx + 1];
|
|
140
|
-
if (!provider || provider.startsWith('-')) {
|
|
141
|
-
return { error: 'Error: --provider requires a provider name' };
|
|
142
|
-
}
|
|
143
|
-
return { provider };
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* MCP server command handler
|
|
147
|
-
*
|
|
148
|
-
* Dynamically imports and delegates to src/mcp/cli.mjs.
|
|
149
|
-
* Handles subcommands: serve, install, info
|
|
150
|
-
*/
|
|
151
|
-
export const mcpHandler = {
|
|
152
|
-
id: "aiwg-mcp-server",
|
|
153
|
-
name: "AIWG MCP Server",
|
|
154
|
-
description: "AIWG MCP server commands (serve, install, add, remove, update, list, inject, info)",
|
|
155
|
-
category: "mcp",
|
|
156
|
-
aliases: ["mcp", "aiwg-mcp"],
|
|
157
|
-
async help() {
|
|
158
|
-
const { main } = await import("../../mcp/cli.mjs");
|
|
159
|
-
await main(["--help"]);
|
|
160
|
-
return { exitCode: 0 };
|
|
161
|
-
},
|
|
162
|
-
async execute(ctx) {
|
|
163
|
-
try {
|
|
164
|
-
// Dynamic import to avoid loading MCP dependencies unless needed
|
|
165
|
-
const { main } = await import("../../mcp/cli.mjs");
|
|
166
|
-
await main(ctx.args);
|
|
167
|
-
return {
|
|
168
|
-
exitCode: 0,
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
const result = handlerResultFromError(error);
|
|
173
|
-
return { ...result, message: `MCP command failed: ${result.message}` };
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
/**
|
|
178
|
-
* Model catalog command handler
|
|
179
|
-
*
|
|
180
|
-
* Dynamically imports and delegates to src/catalog/cli.mjs.
|
|
181
|
-
* Handles subcommands: list, info, search
|
|
182
|
-
*/
|
|
183
|
-
export const catalogHandler = {
|
|
184
|
-
id: "catalog",
|
|
185
|
-
name: "Model Catalog",
|
|
186
|
-
description: "Model catalog commands (list, info, search)",
|
|
187
|
-
category: "catalog",
|
|
188
|
-
aliases: [],
|
|
189
|
-
async help() {
|
|
190
|
-
const { printCatalogHelp } = await import("../../catalog/cli.mjs");
|
|
191
|
-
printCatalogHelp();
|
|
192
|
-
return { exitCode: 0 };
|
|
193
|
-
},
|
|
194
|
-
async execute(ctx) {
|
|
195
|
-
try {
|
|
196
|
-
// Dynamic import to avoid loading catalog dependencies unless needed
|
|
197
|
-
const { main } = await import("../../catalog/cli.mjs");
|
|
198
|
-
await main(ctx.args);
|
|
199
|
-
return {
|
|
200
|
-
exitCode: 0,
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
catch (error) {
|
|
204
|
-
const result = handlerResultFromError(error);
|
|
205
|
-
return { ...result, message: `Catalog command failed: ${result.message}` };
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
/**
|
|
210
|
-
* List frameworks handler
|
|
211
|
-
*
|
|
212
|
-
* Lists deployed extensions from the registry.
|
|
213
|
-
* Falls back to legacy plugin-status script if needed.
|
|
214
|
-
*/
|
|
215
|
-
export const listHandler = {
|
|
216
|
-
id: "list",
|
|
217
|
-
name: "List Frameworks",
|
|
218
|
-
description: "List installed frameworks and plugins",
|
|
219
|
-
category: "framework",
|
|
220
|
-
aliases: ["ls"],
|
|
221
|
-
async execute(ctx) {
|
|
222
|
-
// Filter args: positional type filter, plus --project-local flag (#1034)
|
|
223
|
-
const projectLocalOnly = ctx.args.includes('--project-local');
|
|
224
|
-
const shadowsOnly = ctx.args.includes('--shadows');
|
|
225
|
-
const deployedOnly = ctx.args.includes('--deployed');
|
|
226
|
-
const filterType = ctx.args.find((a) => !a.startsWith('--')); // 'agents'|'skills'|'commands'|'all'|undefined
|
|
227
|
-
// #1156 Phase 1 — --scope user / --user surfaces the per-user registry
|
|
228
|
-
// (~/.aiwg/installed.json) instead of the project-scope deployed-extensions
|
|
229
|
-
// registry. Works from any cwd; does not require a project to be present.
|
|
230
|
-
const userScopeRequested = ctx.args.includes('--user') || isScopeUser(ctx.args);
|
|
231
|
-
if (userScopeRequested) {
|
|
232
|
-
return await formatUserScopeRegistry();
|
|
233
|
-
}
|
|
234
|
-
// Project-local bundle discovery (#1034) — read-only scan, no deploy
|
|
235
|
-
const projectLocal = await discoverProjectLocalBundles(ctx.cwd);
|
|
236
|
-
if (shadowsOnly) {
|
|
237
|
-
// #1036 — surface only artifacts that shadow upstream
|
|
238
|
-
return await formatShadowsOnly(projectLocal);
|
|
239
|
-
}
|
|
240
|
-
if (projectLocalOnly) {
|
|
241
|
-
// --project-local: only show project-local bundles; skip the deployed-
|
|
242
|
-
// extension registry read entirely
|
|
243
|
-
return formatProjectLocalOnly(projectLocal);
|
|
244
|
-
}
|
|
245
|
-
// Ensure registry is populated with deployed extensions
|
|
246
|
-
const registry = getRegistry();
|
|
247
|
-
// If registry is empty, try to populate it from EVERY deployed provider
|
|
248
|
-
// in the workspace (not just claude). Fixes #1530: in a Codex-only
|
|
249
|
-
// workspace the legacy hard-coded `.claude/...` lookup reported zero
|
|
250
|
-
// extensions even though `.codex/` was populated. Detection mirrors
|
|
251
|
-
// `tools/cli/workspace-status.mjs` so `aiwg list` and `aiwg status`
|
|
252
|
-
// agree on what counts as deployed.
|
|
253
|
-
//
|
|
254
|
-
// `--provider <name>` narrows registration to one provider; otherwise
|
|
255
|
-
// we register the union of everything detected so a multi-provider
|
|
256
|
-
// workspace shows everything in a single inventory.
|
|
257
|
-
if (registry.size === 0) {
|
|
258
|
-
try {
|
|
259
|
-
const provIdx = ctx.args.findIndex((a) => a === '--provider' || a === '--platform');
|
|
260
|
-
const requestedProvider = provIdx >= 0 ? ctx.args[provIdx + 1] : undefined;
|
|
261
|
-
let targets = detectDeployedProviders(ctx.cwd);
|
|
262
|
-
if (requestedProvider) {
|
|
263
|
-
targets = targets.filter((p) => p.name === requestedProvider);
|
|
264
|
-
if (targets.length === 0) {
|
|
265
|
-
return {
|
|
266
|
-
exitCode: 1,
|
|
267
|
-
message: `Error: provider '${requestedProvider}' is not deployed in this workspace.\n\nRun 'aiwg status' to see deployed providers.`,
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
if (targets.length === 0) {
|
|
272
|
-
// No deployed providers detected → return a clean empty-inventory
|
|
273
|
-
// message rather than dispatching to the legacy script (which
|
|
274
|
-
// requires a path argument it doesn't get here). Matches the
|
|
275
|
-
// legacy script's helpful guidance from #1530.
|
|
276
|
-
return {
|
|
277
|
-
exitCode: 0,
|
|
278
|
-
message: 'No agents, skills, or commands deployed in this workspace.\n\n' +
|
|
279
|
-
'Tip: Deploy a framework with "aiwg use sdlc" (or another framework) to get started.\n' +
|
|
280
|
-
'Run "aiwg status" for workspace health detail.\n',
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
for (const target of targets) {
|
|
284
|
-
await registerDeployedExtensions(registry, {
|
|
285
|
-
agentsPath: target.agentsPath,
|
|
286
|
-
skillsPath: target.skillsPath,
|
|
287
|
-
commandsPath: target.commandsPath,
|
|
288
|
-
provider: target.name,
|
|
289
|
-
cwd: ctx.cwd,
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
catch (error) {
|
|
294
|
-
// If registry population fails, fall back to legacy script
|
|
295
|
-
const frameworkRoot = await getFrameworkRoot();
|
|
296
|
-
const runner = createScriptRunner(frameworkRoot);
|
|
297
|
-
return runner.run("tools/plugin/plugin-status-cli.mjs", ctx.args, {
|
|
298
|
-
cwd: ctx.cwd,
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
// Determine what to show
|
|
303
|
-
const showAgents = !filterType || filterType === 'agents' || filterType === 'all';
|
|
304
|
-
const showSkills = !filterType || filterType === 'skills' || filterType === 'all';
|
|
305
|
-
const showCommands = !filterType || filterType === 'commands' || filterType === 'all';
|
|
306
|
-
let output = '';
|
|
307
|
-
if (showAgents) {
|
|
308
|
-
const agents = registry.getByType('agent');
|
|
309
|
-
output += `\nAgents (${agents.length}):\n`;
|
|
310
|
-
output += '─'.repeat(60) + '\n';
|
|
311
|
-
if (agents.length === 0) {
|
|
312
|
-
output += ' No agents deployed\n';
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
for (const agent of agents.slice(0, 20)) { // Limit to 20 for readability
|
|
316
|
-
output += ` ${agent.name}\n`;
|
|
317
|
-
output += ` ID: ${agent.id}\n`;
|
|
318
|
-
output += ` Description: ${agent.description.slice(0, 80)}${agent.description.length > 80 ? '...' : ''}\n`;
|
|
319
|
-
if (agent.installation) {
|
|
320
|
-
output += ` Path: ${agent.installation.installedPath}\n`;
|
|
321
|
-
}
|
|
322
|
-
output += '\n';
|
|
323
|
-
}
|
|
324
|
-
if (agents.length > 20) {
|
|
325
|
-
output += ` ... and ${agents.length - 20} more\n`;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
if (showSkills) {
|
|
330
|
-
const skills = registry.getByType('skill');
|
|
331
|
-
output += `\nSkills (${skills.length}):\n`;
|
|
332
|
-
output += '─'.repeat(60) + '\n';
|
|
333
|
-
if (skills.length === 0) {
|
|
334
|
-
output += ' No skills deployed\n';
|
|
335
|
-
}
|
|
336
|
-
else {
|
|
337
|
-
for (const skill of skills.slice(0, 20)) {
|
|
338
|
-
output += ` ${skill.name}\n`;
|
|
339
|
-
output += ` ID: ${skill.id}\n`;
|
|
340
|
-
output += ` Description: ${skill.description.slice(0, 80)}${skill.description.length > 80 ? '...' : ''}\n`;
|
|
341
|
-
if (skill.installation) {
|
|
342
|
-
output += ` Path: ${skill.installation.installedPath}\n`;
|
|
343
|
-
}
|
|
344
|
-
output += '\n';
|
|
345
|
-
}
|
|
346
|
-
if (skills.length > 20) {
|
|
347
|
-
output += ` ... and ${skills.length - 20} more\n`;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
if (showCommands) {
|
|
352
|
-
const commands = registry.getByType('command');
|
|
353
|
-
output += `\nCommands (${commands.length}):\n`;
|
|
354
|
-
output += '─'.repeat(60) + '\n';
|
|
355
|
-
if (commands.length === 0) {
|
|
356
|
-
output += ' No commands registered\n';
|
|
357
|
-
}
|
|
358
|
-
else {
|
|
359
|
-
for (const command of commands.slice(0, 20)) {
|
|
360
|
-
output += ` ${command.name}\n`;
|
|
361
|
-
output += ` ID: ${command.id}\n`;
|
|
362
|
-
output += ` Description: ${command.description.slice(0, 80)}${command.description.length > 80 ? '...' : ''}\n`;
|
|
363
|
-
output += '\n';
|
|
364
|
-
}
|
|
365
|
-
if (commands.length > 20) {
|
|
366
|
-
output += ` ... and ${commands.length - 20} more\n`;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
// Project-local bundles (#1034) — surfaced as a separate section with
|
|
371
|
-
// [project] source label
|
|
372
|
-
const totalProjectLocal = projectLocal.counts.extension +
|
|
373
|
-
projectLocal.counts.addon +
|
|
374
|
-
projectLocal.counts.framework +
|
|
375
|
-
projectLocal.counts.plugin;
|
|
376
|
-
if (totalProjectLocal > 0 || projectLocal.errors.length > 0) {
|
|
377
|
-
output += `\nProject-local bundles (${totalProjectLocal}):\n`;
|
|
378
|
-
output += '─'.repeat(60) + '\n';
|
|
379
|
-
for (const b of projectLocal.bundles) {
|
|
380
|
-
output += ` ${b.id} [project] [${b.type}]\n`;
|
|
381
|
-
output += ` Path: ${b.localPath}\n`;
|
|
382
|
-
output += ` Description: ${b.manifest.description.slice(0, 80)}${b.manifest.description.length > 80 ? '...' : ''}\n\n`;
|
|
383
|
-
}
|
|
384
|
-
if (projectLocal.errors.length > 0) {
|
|
385
|
-
output += ` ⚠ ${projectLocal.errors.length} validation error(s) — see "aiwg doctor" for details\n`;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
// Summary
|
|
389
|
-
const totalAgents = registry.getByType('agent').length;
|
|
390
|
-
const totalSkills = registry.getByType('skill').length;
|
|
391
|
-
const totalCommands = registry.getByType('command').length;
|
|
392
|
-
const total = totalAgents + totalSkills + totalCommands;
|
|
393
|
-
output += '\n' + '═'.repeat(60) + '\n';
|
|
394
|
-
output += `Total: ${total} extensions (${totalAgents} agents, ${totalSkills} skills, ${totalCommands} commands)`;
|
|
395
|
-
if (totalProjectLocal > 0) {
|
|
396
|
-
output += ` + ${totalProjectLocal} project-local`;
|
|
397
|
-
}
|
|
398
|
-
output += '\n';
|
|
399
|
-
if (total === 0 && totalProjectLocal === 0) {
|
|
400
|
-
output += '\nTip: Deploy a framework with "aiwg use sdlc" to get started\n';
|
|
401
|
-
}
|
|
402
|
-
else if (totalCommands === 0 && totalAgents > 0) {
|
|
403
|
-
// Skill-only model (Claude Code default): commands aren't deployed as
|
|
404
|
-
// slash commands; capabilities reach the agent via natural language or
|
|
405
|
-
// `aiwg discover` (#1228). Surface this so 0 commands doesn't look like
|
|
406
|
-
// a deploy failure.
|
|
407
|
-
output += '\nNote: 0 commands is expected on Claude Code — capabilities are reached via natural language or `aiwg discover "<phrase>"`.\n';
|
|
408
|
-
}
|
|
409
|
-
if (deployedOnly) {
|
|
410
|
-
const projectDir = getProjectDir(ctx, ctx.args);
|
|
411
|
-
const plan = await readWorkspaceSignalPlan(projectDir);
|
|
412
|
-
if (plan) {
|
|
413
|
-
output += formatDeployedWorkspaceSignalPlan(plan);
|
|
414
|
-
}
|
|
415
|
-
else {
|
|
416
|
-
output += '\nWorkspace skill filter: no recorded plan found.\n';
|
|
417
|
-
output += 'Run `aiwg use --profile <name>` to record workspace-aware include/exclude reasons.\n';
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
return {
|
|
421
|
-
exitCode: 0,
|
|
422
|
-
message: output,
|
|
423
|
-
};
|
|
424
|
-
},
|
|
425
|
-
};
|
|
426
|
-
/**
|
|
427
|
-
* Format `aiwg list --project-local` output: only project-local bundles, with
|
|
428
|
-
* per-type breakdown and any validation errors surfaced. (#1034)
|
|
429
|
-
*/
|
|
430
|
-
function formatProjectLocalOnly(result) {
|
|
431
|
-
let output = '';
|
|
432
|
-
const total = result.counts.extension +
|
|
433
|
-
result.counts.addon +
|
|
434
|
-
result.counts.framework +
|
|
435
|
-
result.counts.plugin;
|
|
436
|
-
if (total === 0 && result.errors.length === 0) {
|
|
437
|
-
output += '\nNo project-local bundles found.\n';
|
|
438
|
-
output += '\nTip: place a manifest.json under the configured AIWG artifact root at {extensions,addons,frameworks,plugins,providers}/<name>/ to author a project-local artifact.\n';
|
|
439
|
-
return { exitCode: 0, message: output };
|
|
440
|
-
}
|
|
441
|
-
output += `\nProject-local bundles (${total}):\n`;
|
|
442
|
-
output += '─'.repeat(60) + '\n';
|
|
443
|
-
for (const b of result.bundles) {
|
|
444
|
-
output += ` ${b.id} [project] [${b.type}] v${b.manifest.version}\n`;
|
|
445
|
-
output += ` Path: ${b.localPath}\n`;
|
|
446
|
-
output += ` Description: ${b.manifest.description.slice(0, 80)}${b.manifest.description.length > 80 ? '...' : ''}\n\n`;
|
|
447
|
-
}
|
|
448
|
-
if (result.errors.length > 0) {
|
|
449
|
-
output += '\nValidation errors:\n';
|
|
450
|
-
output += '─'.repeat(60) + '\n';
|
|
451
|
-
for (const e of result.errors.slice(0, 10)) {
|
|
452
|
-
output += ` [${e.severity}] ${e.path}\n`;
|
|
453
|
-
output += ` ${e.field}: expected ${e.expected}, got ${e.actual}\n`;
|
|
454
|
-
if (e.hint)
|
|
455
|
-
output += ` hint: ${e.hint}\n`;
|
|
456
|
-
}
|
|
457
|
-
if (result.errors.length > 10) {
|
|
458
|
-
output += ` ... and ${result.errors.length - 10} more\n`;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
output += '\n' + '═'.repeat(60) + '\n';
|
|
462
|
-
output += `Counts by type: extension=${result.counts.extension} addon=${result.counts.addon} framework=${result.counts.framework} plugin=${result.counts.plugin}\n`;
|
|
463
|
-
return { exitCode: 0, message: output };
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Format `aiwg list --shadows` output: only artifacts that currently shadow
|
|
467
|
-
* an upstream artifact, with safety-critical and override status. (#1036)
|
|
468
|
-
*/
|
|
469
|
-
async function formatShadowsOnly(projectLocal) {
|
|
470
|
-
let output = '';
|
|
471
|
-
if (projectLocal.bundles.length === 0) {
|
|
472
|
-
output += '\nNo project-local bundles — no shadows possible.\n';
|
|
473
|
-
return { exitCode: 0, message: output };
|
|
474
|
-
}
|
|
475
|
-
const { getFrameworkRoot: gfr } = await import('../../channel/manager.mjs');
|
|
476
|
-
const frameworkRoot = await gfr();
|
|
477
|
-
const upstream = await buildUpstreamRegistry({ frameworkRoot });
|
|
478
|
-
const result = await resolveShadows(projectLocal.bundles, upstream);
|
|
479
|
-
if (result.shadows.length === 0) {
|
|
480
|
-
output += '\nNo active shadows.\n';
|
|
481
|
-
output += '\nProject-local bundles deploy alongside upstream without collision.\n';
|
|
482
|
-
return { exitCode: 0, message: output };
|
|
483
|
-
}
|
|
484
|
-
output += `\nActive shadows (${result.shadows.length}):\n`;
|
|
485
|
-
output += '─'.repeat(60) + '\n';
|
|
486
|
-
for (const r of result.shadows) {
|
|
487
|
-
const sc = r.upstream?.safetyCritical ? ' [SAFETY-CRITICAL]' : '';
|
|
488
|
-
output += ` ${r.artifactType}/${r.artifactId}${sc}\n`;
|
|
489
|
-
output += ` Bundle: ${r.bundleId} (${r.bundleLocalPath})\n`;
|
|
490
|
-
output += ` Project-local: ${r.artifactSourcePath}\n`;
|
|
491
|
-
if (r.upstream) {
|
|
492
|
-
output += ` Shadows ${r.upstream.source}: ${r.upstream.sourcePath}\n`;
|
|
493
|
-
}
|
|
494
|
-
output += ` Verdict: ${r.verdict}\n\n`;
|
|
495
|
-
}
|
|
496
|
-
if (result.blockedBundleIds.size > 0) {
|
|
497
|
-
output += `\n⚠ ${result.blockedBundleIds.size} bundle(s) blocked from deployment due to unsafe shadows.\n`;
|
|
498
|
-
}
|
|
499
|
-
return { exitCode: 0, message: output };
|
|
500
|
-
}
|
|
501
|
-
/**
|
|
502
|
-
* #1156 Phase 1 — `--scope user` detection. Mirrors `detectScope()` from
|
|
503
|
-
* scope-resolver but tolerates the absence of the flag (no throw on absent).
|
|
504
|
-
* Returns true when args contain `--scope user`.
|
|
505
|
-
*/
|
|
506
|
-
function isScopeUser(args) {
|
|
507
|
-
const idx = args.findIndex((a) => a === '--scope');
|
|
508
|
-
if (idx === -1)
|
|
509
|
-
return false;
|
|
510
|
-
return args[idx + 1] === 'user';
|
|
511
|
-
}
|
|
512
|
-
/**
|
|
513
|
-
* #1156 Phase 1 — Format the per-user registry (~/.aiwg/installed.json) as a
|
|
514
|
-
* human-readable inventory. Used by `aiwg list --scope user` / `aiwg list
|
|
515
|
-
* --user`. Independent of any project — works from any cwd.
|
|
516
|
-
*/
|
|
517
|
-
async function formatUserScopeRegistry() {
|
|
518
|
-
const { readUserRegistry, userRegistryPath } = await import('../../config/user-registry.js');
|
|
519
|
-
const registry = await readUserRegistry();
|
|
520
|
-
const frameworks = Object.entries(registry.installed);
|
|
521
|
-
let output = '';
|
|
522
|
-
if (frameworks.length === 0) {
|
|
523
|
-
output += '\nNo frameworks deployed at user scope.\n';
|
|
524
|
-
output += `\nRegistry path: ${userRegistryPath()}\n`;
|
|
525
|
-
output += '\nTip: run `aiwg use <framework> --provider <p> --scope user` to install at user scope.\n';
|
|
526
|
-
return { exitCode: 0, message: output };
|
|
527
|
-
}
|
|
528
|
-
output += `\nUser-scope deployments (${frameworks.length}):\n`;
|
|
529
|
-
output += '─'.repeat(60) + '\n';
|
|
530
|
-
for (const [name, entry] of frameworks) {
|
|
531
|
-
output += ` ${name} v${entry.version} [${entry.source}]\n`;
|
|
532
|
-
output += ` Installed: ${entry.installedAt}\n`;
|
|
533
|
-
const providers = Object.entries(entry.deployedTo);
|
|
534
|
-
for (const [provider, counts] of providers) {
|
|
535
|
-
const parts = [];
|
|
536
|
-
if (counts.agents > 0)
|
|
537
|
-
parts.push(`${counts.agents} agents`);
|
|
538
|
-
if (counts.commands > 0)
|
|
539
|
-
parts.push(`${counts.commands} commands`);
|
|
540
|
-
if (counts.skills > 0)
|
|
541
|
-
parts.push(`${counts.skills} skills`);
|
|
542
|
-
if (counts.rules > 0)
|
|
543
|
-
parts.push(`${counts.rules} rules`);
|
|
544
|
-
output += ` ${provider}: ${parts.length > 0 ? parts.join(', ') : '(empty)'}\n`;
|
|
545
|
-
}
|
|
546
|
-
output += '\n';
|
|
547
|
-
}
|
|
548
|
-
output += '═'.repeat(60) + '\n';
|
|
549
|
-
output += `Registry path: ${userRegistryPath()}\n`;
|
|
550
|
-
return { exitCode: 0, message: output };
|
|
551
|
-
}
|
|
552
|
-
/**
|
|
553
|
-
* #1156 Phase 1 — Revert a user-scope mirror.
|
|
554
|
-
*
|
|
555
|
-
* Reads `~/.aiwg/installed.json`, looks up the framework + provider entry,
|
|
556
|
-
* and deletes the specific artifact entries this deploy created (recorded
|
|
557
|
-
* by the mirror in Cycle 3). With `--dry-run`, lists what would be removed
|
|
558
|
-
* without touching the filesystem.
|
|
559
|
-
*
|
|
560
|
-
* Back-compat: registry entries written before Cycle 3 lack the `entries`
|
|
561
|
-
* snapshot. For those, the handler falls back to the conservative
|
|
562
|
-
* registry-only revert and tells the operator to clean up manually.
|
|
563
|
-
*
|
|
564
|
-
* Multi-provider: if `--provider` is omitted, all of the framework's
|
|
565
|
-
* provider deployments are reverted in one pass.
|
|
566
|
-
*/
|
|
567
|
-
async function removeUserScopeDeploy(args) {
|
|
568
|
-
const positional = firstRemovePositional(args);
|
|
569
|
-
if (!positional) {
|
|
570
|
-
return {
|
|
571
|
-
exitCode: 1,
|
|
572
|
-
message: 'Error: framework name required\n\nUsage: aiwg remove <framework> --scope user [--provider <p>] [--dry-run]',
|
|
573
|
-
};
|
|
574
|
-
}
|
|
575
|
-
const dryRun = args.includes('--dry-run');
|
|
576
|
-
const providerParse = parseRemoveProvider(args);
|
|
577
|
-
if (providerParse.error) {
|
|
578
|
-
return {
|
|
579
|
-
exitCode: 1,
|
|
580
|
-
message: `${providerParse.error}\n\nUsage: aiwg remove <framework> --scope user [--provider <p>] [--dry-run]`,
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
const provider = providerParse.provider;
|
|
584
|
-
const { readUserRegistry, removeUserDeploy } = await import('../../config/user-registry.js');
|
|
585
|
-
const { USER_SCOPE_PATHS } = await import('../scope-resolver.js');
|
|
586
|
-
const registry = await readUserRegistry();
|
|
587
|
-
const entry = registry.installed[positional];
|
|
588
|
-
if (!entry) {
|
|
589
|
-
return {
|
|
590
|
-
exitCode: 1,
|
|
591
|
-
message: `Error: framework '${positional}' is not deployed at user scope.\n\nRun 'aiwg list --scope user' to see installed frameworks.`,
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
const providersToRevert = provider ? [provider] : Object.keys(entry.deployedTo);
|
|
595
|
-
if (provider && !entry.deployedTo[provider]) {
|
|
596
|
-
return {
|
|
597
|
-
exitCode: 1,
|
|
598
|
-
message: `Error: framework '${positional}' is not deployed at user scope for provider '${provider}'.\n\nDeployed providers: ${Object.keys(entry.deployedTo).join(', ') || '(none)'}`,
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
const fs = await import('node:fs/promises');
|
|
602
|
-
const path = await import('node:path');
|
|
603
|
-
const linesOut = [];
|
|
604
|
-
if (dryRun)
|
|
605
|
-
linesOut.push(`[dry-run] Plan for user-scope remove of '${positional}':`);
|
|
606
|
-
else
|
|
607
|
-
linesOut.push(`Removing user-scope mirror of '${positional}':`);
|
|
608
|
-
let totalDeleted = 0;
|
|
609
|
-
let conservativeFallbackUsed = false;
|
|
610
|
-
for (const p of providersToRevert) {
|
|
611
|
-
const userPaths = USER_SCOPE_PATHS[p];
|
|
612
|
-
if (!userPaths) {
|
|
613
|
-
linesOut.push(` ⚠ ${p}: no user-scope paths registered — skipping (manual cleanup may be needed)`);
|
|
614
|
-
continue;
|
|
615
|
-
}
|
|
616
|
-
// Cast through unknown to access the optional `entries` snapshot recorded
|
|
617
|
-
// by the Cycle 3 mirror. Older registry entries won't have it.
|
|
618
|
-
const providerEntry = entry.deployedTo[p];
|
|
619
|
-
const recorded = providerEntry?.entries;
|
|
620
|
-
if (!recorded) {
|
|
621
|
-
// Pre-Cycle-3 entry: surface the deploy paths and let the operator
|
|
622
|
-
// clean them up manually. We can't safely auto-delete because the dirs
|
|
623
|
-
// are shared with other frameworks.
|
|
624
|
-
conservativeFallbackUsed = true;
|
|
625
|
-
const existingDirs = [
|
|
626
|
-
{ type: 'agents', path: userPaths.agents },
|
|
627
|
-
{ type: 'commands', path: userPaths.commands },
|
|
628
|
-
{ type: 'skills', path: userPaths.skills },
|
|
629
|
-
{ type: 'rules', path: userPaths.rules },
|
|
630
|
-
{ type: 'behaviors', path: userPaths.behaviors },
|
|
631
|
-
].filter(t => t.path);
|
|
632
|
-
linesOut.push(` ⚠ ${p}: registry entry has no per-artifact manifest (deployed before Cycle 3). Manual cleanup of these dirs may be needed:`);
|
|
633
|
-
for (const t of existingDirs) {
|
|
634
|
-
const stat = await fs.stat(t.path).catch(() => null);
|
|
635
|
-
if (stat && stat.isDirectory()) {
|
|
636
|
-
linesOut.push(` - ${t.path}`);
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
continue;
|
|
640
|
-
}
|
|
641
|
-
// Precise revert — walk the recorded entry names and delete each one
|
|
642
|
-
// from its corresponding user-scope dir.
|
|
643
|
-
const sets = [
|
|
644
|
-
['agents', userPaths.agents, recorded.agents],
|
|
645
|
-
['commands', userPaths.commands, recorded.commands],
|
|
646
|
-
['skills', userPaths.skills, recorded.skills],
|
|
647
|
-
['rules', userPaths.rules, recorded.rules],
|
|
648
|
-
['behaviors', userPaths.behaviors, recorded.behaviors],
|
|
649
|
-
];
|
|
650
|
-
for (const [type, dir, names] of sets) {
|
|
651
|
-
if (!dir || !names || names.length === 0)
|
|
652
|
-
continue;
|
|
653
|
-
let deletedHere = 0;
|
|
654
|
-
for (const name of names) {
|
|
655
|
-
const target = path.join(dir, name);
|
|
656
|
-
if (dryRun) {
|
|
657
|
-
linesOut.push(` · ${p} ${type}: ${target}`);
|
|
658
|
-
deletedHere++;
|
|
659
|
-
continue;
|
|
660
|
-
}
|
|
661
|
-
try {
|
|
662
|
-
if (type === 'skills') {
|
|
663
|
-
const { resolveFrameworkDir } = await import('./use.js');
|
|
664
|
-
const released = releaseSkillOwnership(target, { frameworkSlug: resolveFrameworkDir(positional) ?? positional });
|
|
665
|
-
if (released === null)
|
|
666
|
-
continue;
|
|
667
|
-
}
|
|
668
|
-
else {
|
|
669
|
-
await fs.rm(target, { recursive: true, force: true });
|
|
670
|
-
}
|
|
671
|
-
deletedHere++;
|
|
672
|
-
totalDeleted++;
|
|
673
|
-
}
|
|
674
|
-
catch (err) {
|
|
675
|
-
linesOut.push(` ⚠ ${p} ${type}: failed to remove ${target}: ${err instanceof Error ? err.message : String(err)}`);
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
if (!dryRun && deletedHere > 0) {
|
|
679
|
-
linesOut.push(` ✓ ${p} ${type}: removed ${deletedHere} entry/entries from ${dir}`);
|
|
680
|
-
}
|
|
681
|
-
else if (dryRun) {
|
|
682
|
-
linesOut.push(` (${deletedHere} ${type} would be removed from ${dir})`);
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
if (!dryRun) {
|
|
687
|
-
if (provider) {
|
|
688
|
-
await removeUserDeploy({ framework: positional, provider });
|
|
689
|
-
}
|
|
690
|
-
else {
|
|
691
|
-
await removeUserDeploy({ framework: positional });
|
|
692
|
-
}
|
|
693
|
-
if (providersToRevert.includes('claude') && !Object.values((await readUserRegistry()).installed).some(item => item.deployedTo.claude))
|
|
694
|
-
await removeClaudeAttribution(os.homedir());
|
|
695
|
-
linesOut.push('');
|
|
696
|
-
if (conservativeFallbackUsed) {
|
|
697
|
-
linesOut.push('Registry updated. Some providers had no per-artifact manifest (pre-Cycle-3 deploys); inspect the dirs listed above and clean up manually if needed.');
|
|
698
|
-
}
|
|
699
|
-
else {
|
|
700
|
-
linesOut.push(`Registry updated. ${totalDeleted} artifact entry/entries removed.`);
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
return {
|
|
704
|
-
exitCode: 0,
|
|
705
|
-
message: linesOut.join('\n') + '\n',
|
|
706
|
-
};
|
|
707
|
-
}
|
|
708
|
-
/** List only unrecorded paths; recorded decisions come from the ownership plan. */
|
|
709
|
-
function previewUnrecordedSkillFiles(skillDir, owned, plan, skillRoots) {
|
|
710
|
-
// Some adapters (Hermes) put the bulk root directly inside the kernel root.
|
|
711
|
-
if (skillRoots.includes(skillDir))
|
|
712
|
-
return;
|
|
713
|
-
const recorded = new Set(plan.map(entry => entry.path));
|
|
714
|
-
const visit = (target) => {
|
|
715
|
-
if (recorded.has(path.resolve(target)))
|
|
716
|
-
return;
|
|
717
|
-
let reason = owned ? 'unrecorded operator file' : 'foreign or unverifiable ownership receipt';
|
|
718
|
-
try {
|
|
719
|
-
const stat = fsSync.lstatSync(target);
|
|
720
|
-
if (stat.isDirectory()) {
|
|
721
|
-
for (const name of fsSync.readdirSync(target).sort())
|
|
722
|
-
visit(path.join(target, name));
|
|
723
|
-
return;
|
|
724
|
-
}
|
|
725
|
-
if (owned && stat.isSymbolicLink())
|
|
726
|
-
reason = 'symlink preserved';
|
|
727
|
-
}
|
|
728
|
-
catch {
|
|
729
|
-
reason = 'missing or unreadable path; cannot verify';
|
|
730
|
-
}
|
|
731
|
-
plan.push({ path: path.resolve(target), action: 'preserve', reason });
|
|
732
|
-
};
|
|
733
|
-
visit(skillDir);
|
|
734
|
-
}
|
|
735
|
-
/**
|
|
736
|
-
* Remove framework handler
|
|
737
|
-
*
|
|
738
|
-
* Delegates to tools/plugin/plugin-uninstaller-cli.mjs
|
|
739
|
-
*/
|
|
740
|
-
export const removeHandler = {
|
|
741
|
-
id: "remove",
|
|
742
|
-
name: "Remove Framework",
|
|
743
|
-
description: "Remove installed framework, plugin, or project-local bundle",
|
|
744
|
-
category: "framework",
|
|
745
|
-
aliases: [],
|
|
746
|
-
async help() {
|
|
747
|
-
return { exitCode: 0, rawOutput: true, message: [
|
|
748
|
-
'Usage: aiwg remove <id> [options]',
|
|
749
|
-
'',
|
|
750
|
-
'Remove an installed framework, plugin, or project-local bundle by id (for example all or sdlc).',
|
|
751
|
-
'Project scope is the default; without --provider, process all recorded provider deployments.',
|
|
752
|
-
'"all" is an installed bundle id, not a wildcard for every installed entry.',
|
|
753
|
-
'Bundled deployments release skill ownership receipts and delete only unchanged recorded files.',
|
|
754
|
-
'Project-local removal reverts deployed artifacts using recorded hashes; bundle source is preserved.',
|
|
755
|
-
'',
|
|
756
|
-
'Options:',
|
|
757
|
-
' --dry-run List planned removals and preserved paths with reasons; write nothing.',
|
|
758
|
-
' --provider <p> Select one recorded provider deployment.',
|
|
759
|
-
' --keep-registry Keep project installed/deployedTo records after removal. By default,',
|
|
760
|
-
' remove selected deployment records and drop the id when none remain.',
|
|
761
|
-
' Project-local partial reverts retain their registry records.',
|
|
762
|
-
' --force Override project-local mutation refusal or legacy plugin dependency checks;',
|
|
763
|
-
' does not override bundled skill hash/ownership preservation.',
|
|
764
|
-
' --scope user Remove the user-scope mirror using ~/.aiwg/installed.json instead.',
|
|
765
|
-
' --user Alias for --scope user; user mirror removal updates its own registry.',
|
|
766
|
-
' --target <d> Target a project directory (alias: --prefix; default: cwd).',
|
|
767
|
-
' --help, -h Show this help.',
|
|
768
|
-
'',
|
|
769
|
-
'Bundled skill removal preserves modified files, unrecorded operator files, foreign skills,',
|
|
770
|
-
'and symlinks inside skill directories. Project-local bundle source is never deleted.',
|
|
771
|
-
'User-scope legacy records without artifact manifests require manual file cleanup.',
|
|
772
|
-
'Unregistered ids fall back to the legacy plugin uninstaller (also supports --keep-data).',
|
|
773
|
-
'',
|
|
774
|
-
'Examples:',
|
|
775
|
-
' aiwg remove all --dry-run',
|
|
776
|
-
' aiwg remove sdlc --provider claude --dry-run',
|
|
777
|
-
' aiwg remove my-bundle --keep-registry',
|
|
778
|
-
' aiwg remove sdlc --scope user --provider codex --dry-run',
|
|
779
|
-
].join('\n') };
|
|
780
|
-
},
|
|
781
|
-
async execute(ctx) {
|
|
782
|
-
// Explicit provider removal is separate from framework removal. The native
|
|
783
|
-
// adapter validates receipt hashes and preserves operator modifications.
|
|
784
|
-
const nativeRemovalProvider = parseRemoveProvider(ctx.args);
|
|
785
|
-
if (firstRemovePositional(ctx.args) === 'omp' && nativeRemovalProvider.provider === 'omp') {
|
|
786
|
-
// Loaded from the package root, not by a path relative to this file: the
|
|
787
|
-
// compiled handler sits one directory deeper than its source.
|
|
788
|
-
const { uninstall } = (await import(pathToFileURL(path.join(await getFrameworkRoot(), 'tools/agents/providers/omp.mjs')).href));
|
|
789
|
-
const { getProjectDir } = await import('../../config/aiwg-config.js');
|
|
790
|
-
const dryRun = ctx.args.includes('--dry-run');
|
|
791
|
-
const scope = ctx.args.includes('--user') || isScopeUser(ctx.args) ? 'user' : 'project';
|
|
792
|
-
const count = uninstall(getProjectDir({ cwd: ctx.cwd }, ctx.args), { dryRun, scope });
|
|
793
|
-
return { exitCode: 0, message: `${dryRun ? 'Would remove' : 'Removed'} ${count} unchanged OMP-owned files; operator files preserved.` };
|
|
794
|
-
}
|
|
795
|
-
// #1156 Phase 1 — `--scope user` / `--user`: revert the user-scope mirror
|
|
796
|
-
// for the given framework. Independent of any project; reads the per-user
|
|
797
|
-
// registry at ~/.aiwg/installed.json to find what was deployed, deletes
|
|
798
|
-
// the mirrored artifacts under the provider's USER_SCOPE_PATHS, and
|
|
799
|
-
// updates the registry.
|
|
800
|
-
if (ctx.args.includes('--user') || isScopeUser(ctx.args)) {
|
|
801
|
-
return await removeUserScopeDeploy(ctx.args);
|
|
802
|
-
}
|
|
803
|
-
if (firstRemovePositional(ctx.args) === 'grok-build') {
|
|
804
|
-
const providerParse = parseRemoveProvider(ctx.args);
|
|
805
|
-
if (providerParse.provider !== 'grok-build' || providerParse.error) {
|
|
806
|
-
return { exitCode: 1, message: 'Use aiwg remove grok-build --provider grok-build [--dry-run] for reviewed project-scope removal.' };
|
|
807
|
-
}
|
|
808
|
-
const frameworkRoot = await getFrameworkRoot();
|
|
809
|
-
const { uninstall } = (await import(pathToFileURL(path.join(frameworkRoot, 'tools/agents/providers/grok-build.mjs')).href));
|
|
810
|
-
const { readAiwgConfig, writeAiwgConfig } = await import('../../config/aiwg-config.js');
|
|
811
|
-
const target = getProjectDir({ cwd: ctx.cwd }, ctx.args);
|
|
812
|
-
const dryRun = ctx.args.includes('--dry-run');
|
|
813
|
-
const report = uninstall(target, { dryRun, srcRoot: frameworkRoot });
|
|
814
|
-
if (!dryRun && report.skipped.length === 0) {
|
|
815
|
-
const config = await readAiwgConfig(target);
|
|
816
|
-
if (config) {
|
|
817
|
-
for (const [name, entry] of Object.entries(config.installed ?? {})) {
|
|
818
|
-
delete entry.deployedTo?.['grok-build'];
|
|
819
|
-
if (Object.keys(entry.deployedTo ?? {}).length === 0)
|
|
820
|
-
delete config.installed[name];
|
|
821
|
-
}
|
|
822
|
-
await writeAiwgConfig(target, config);
|
|
823
|
-
}
|
|
824
|
-
}
|
|
825
|
-
const lines = [
|
|
826
|
-
`${dryRun ? 'Would remove' : 'Removed'} ${dryRun ? report.planned.length : report.removed.length} unchanged AIWG-owned Grok Build artifact(s).`,
|
|
827
|
-
...report.planned.map(relative => ` ${relative}`),
|
|
828
|
-
...report.skipped.map(relative => ` Preserved modified or unverifiable: ${relative}`),
|
|
829
|
-
'Operator-owned Grok content and shared context files are preserved.',
|
|
830
|
-
];
|
|
831
|
-
return { exitCode: report.skipped.length ? 1 : 0, message: lines.join('\n') };
|
|
832
|
-
}
|
|
833
|
-
// #1037 — Project-local-aware remove. If the first positional arg matches
|
|
834
|
-
// a project-local entry in `installed`, route to the new handler.
|
|
835
|
-
// Otherwise fall through to the existing plugin-uninstaller flow.
|
|
836
|
-
const positionalArg = firstRemovePositional(ctx.args);
|
|
837
|
-
const providerParse = parseRemoveProvider(ctx.args);
|
|
838
|
-
if (providerParse.error) {
|
|
839
|
-
return {
|
|
840
|
-
exitCode: 1,
|
|
841
|
-
message: `${providerParse.error}\n\nUsage: aiwg remove <id> [--force] [--dry-run] [--provider <p>] [--keep-registry]`,
|
|
842
|
-
};
|
|
843
|
-
}
|
|
844
|
-
if (!positionalArg) {
|
|
845
|
-
return {
|
|
846
|
-
exitCode: 1,
|
|
847
|
-
message: 'Error: framework or bundle id required\n\nUsage: aiwg remove <id> [--force] [--dry-run] [--provider <p>] [--keep-registry]',
|
|
848
|
-
};
|
|
849
|
-
}
|
|
850
|
-
if (positionalArg) {
|
|
851
|
-
try {
|
|
852
|
-
const { readAiwgConfig, writeAiwgConfig, getProjectDir } = await import('../../config/aiwg-config.js');
|
|
853
|
-
const { removeProjectLocalBundle } = await import('../../extensions/project-local-remove.js');
|
|
854
|
-
const projectDir = getProjectDir({ cwd: ctx.cwd }, ctx.args);
|
|
855
|
-
const config = await readAiwgConfig(projectDir);
|
|
856
|
-
const entry = config?.installed?.[positionalArg];
|
|
857
|
-
if (config && entry && entry.source !== 'project-local') {
|
|
858
|
-
const fs = await import('node:fs/promises');
|
|
859
|
-
const { resolveFrameworkDir } = await import('./use.js');
|
|
860
|
-
const frameworkSlug = resolveFrameworkDir(positionalArg) ?? positionalArg;
|
|
861
|
-
const dryRun = ctx.args.includes('--dry-run');
|
|
862
|
-
const providers = Object.keys(entry.deployedTo).filter(p => !providerParse.provider || p === providerParse.provider);
|
|
863
|
-
if (providerParse.provider && providers.length === 0) {
|
|
864
|
-
return { exitCode: 1, message: `Error: '${positionalArg}' is not deployed for provider '${providerParse.provider}'.` };
|
|
865
|
-
}
|
|
866
|
-
let released = 0;
|
|
867
|
-
const lines = [];
|
|
868
|
-
for (const provider of providers) {
|
|
869
|
-
if (dryRun)
|
|
870
|
-
lines.push(` Provider ${provider}:`);
|
|
871
|
-
const providerStart = lines.length;
|
|
872
|
-
const skillRoots = deployedSkillRoots(projectDir, provider);
|
|
873
|
-
for (const root of skillRoots) {
|
|
874
|
-
for (const name of (await fs.readdir(root).catch(() => [])).sort()) {
|
|
875
|
-
const skillDir = path.join(root, name);
|
|
876
|
-
const plan = [];
|
|
877
|
-
const owned = releaseSkillOwnership(skillDir, { frameworkSlug }, { dryRun, plan }) !== null;
|
|
878
|
-
if (owned)
|
|
879
|
-
released++;
|
|
880
|
-
if (dryRun) {
|
|
881
|
-
previewUnrecordedSkillFiles(skillDir, owned, plan, skillRoots);
|
|
882
|
-
for (const entry of plan) {
|
|
883
|
-
lines.push(` Would ${entry.action} ${path.relative(projectDir, entry.path)} — ${entry.reason}`);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
if (dryRun && lines.length === providerStart)
|
|
889
|
-
lines.push(' No deployed skill files found.');
|
|
890
|
-
if (!dryRun && !ctx.args.includes('--keep-registry'))
|
|
891
|
-
delete entry.deployedTo[provider];
|
|
892
|
-
}
|
|
893
|
-
if (!dryRun && !ctx.args.includes('--keep-registry')) {
|
|
894
|
-
if (Object.keys(entry.deployedTo).length === 0)
|
|
895
|
-
delete config.installed[positionalArg];
|
|
896
|
-
await writeAiwgConfig(projectDir, config);
|
|
897
|
-
if (providers.includes('claude') && !Object.values(config.installed).some(item => item.deployedTo.claude))
|
|
898
|
-
await removeClaudeAttribution(projectDir);
|
|
899
|
-
}
|
|
900
|
-
if (dryRun) {
|
|
901
|
-
lines.push(ctx.args.includes('--keep-registry')
|
|
902
|
-
? ' Registry preserved (--keep-registry).'
|
|
903
|
-
: ` Would update .aiwg/aiwg.config: release ${providers.join(', ')} deployment record(s) for '${positionalArg}'; drop the id if none remain.`);
|
|
904
|
-
}
|
|
905
|
-
lines.push(`${dryRun ? 'Would release' : 'Released'} ${released} skill ownership receipt(s); operator files preserved.`);
|
|
906
|
-
return { exitCode: 0, message: lines.join('\n') };
|
|
907
|
-
}
|
|
908
|
-
if (config && entry?.source === 'project-local') {
|
|
909
|
-
const force = ctx.args.includes('--force');
|
|
910
|
-
const dryRun = ctx.args.includes('--dry-run');
|
|
911
|
-
const keepRegistry = ctx.args.includes('--keep-registry');
|
|
912
|
-
const provider = providerParse.provider;
|
|
913
|
-
const result = await removeProjectLocalBundle(config, projectDir, positionalArg, { force, dryRun, keepRegistry, provider });
|
|
914
|
-
// Print outcome summary
|
|
915
|
-
const lines = [];
|
|
916
|
-
if (dryRun)
|
|
917
|
-
lines.push(`[dry-run] Plan for project-local '${positionalArg}':`);
|
|
918
|
-
for (const o of result.outcomes) {
|
|
919
|
-
const marker = o.reverted ? '✓' : '⚠';
|
|
920
|
-
lines.push(` ${marker} ${o.provider} :: ${o.artifactPath} [${o.case}] ${o.message}`);
|
|
921
|
-
}
|
|
922
|
-
if (result.revertedProviders.length > 0) {
|
|
923
|
-
lines.push(`Fully reverted: ${result.revertedProviders.join(', ')}`);
|
|
924
|
-
}
|
|
925
|
-
if (result.partialProviders.length > 0) {
|
|
926
|
-
lines.push(`Partial (registry preserved): ${result.partialProviders.join(', ')}`);
|
|
927
|
-
}
|
|
928
|
-
if (lines.length > 0)
|
|
929
|
-
console.log(lines.join('\n'));
|
|
930
|
-
if (!dryRun) {
|
|
931
|
-
await writeAiwgConfig(projectDir, config);
|
|
932
|
-
if (result.revertedProviders.includes('claude') && !Object.values(config.installed).some(item => item.deployedTo.claude))
|
|
933
|
-
await removeClaudeAttribution(projectDir);
|
|
934
|
-
}
|
|
935
|
-
// Note: source under .aiwg/<type>/<name>/ is intentionally NOT
|
|
936
|
-
// deleted (load-bearing invariant from #1048 design).
|
|
937
|
-
return {
|
|
938
|
-
exitCode: result.partialProviders.length > 0 ? 1 : 0,
|
|
939
|
-
message: result.partialProviders.length > 0
|
|
940
|
-
? `Some artifacts skipped (see above). Use --force to override mutation refusal.`
|
|
941
|
-
: '',
|
|
942
|
-
};
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
catch (err) {
|
|
946
|
-
// Fall through to upstream remove on any error in the project-local path
|
|
947
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
948
|
-
process.stderr.write(`project-local remove pre-check failed (falling through): ${msg}\n`);
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
if (providerParse.provider) {
|
|
952
|
-
return {
|
|
953
|
-
exitCode: 1,
|
|
954
|
-
message: `Error: --provider is only supported for project-local or user-scope remove. '${positionalArg}' is not a project-local bundle.\n\nUse 'aiwg remove ${positionalArg}' without --provider, or 'aiwg remove ${positionalArg} --scope user --provider ${providerParse.provider}' for a user-scope mirror. Refs #1610.`,
|
|
955
|
-
};
|
|
956
|
-
}
|
|
957
|
-
const frameworkRoot = await getFrameworkRoot();
|
|
958
|
-
const runner = createScriptRunner(frameworkRoot);
|
|
959
|
-
return runner.run("tools/plugin/plugin-uninstaller-cli.mjs", ctx.args, {
|
|
960
|
-
cwd: ctx.cwd,
|
|
961
|
-
});
|
|
962
|
-
},
|
|
963
|
-
};
|
|
964
|
-
/**
|
|
965
|
-
* Promote handler — graduate a project-local bundle to upstream or to a
|
|
966
|
-
* private corpus path. Implements the design at
|
|
967
|
-
* @.aiwg/architecture/design-doctor-log-promote.md (#1049).
|
|
968
|
-
*
|
|
969
|
-
* Usage:
|
|
970
|
-
* aiwg promote <name> # default: --to upstream
|
|
971
|
-
* aiwg promote <name> --to upstream
|
|
972
|
-
* aiwg promote <name> --to corpus <path>
|
|
973
|
-
* aiwg promote <name> --dry-run
|
|
974
|
-
* aiwg promote <name> --cleanup
|
|
975
|
-
* aiwg promote <name> --force
|
|
976
|
-
*
|
|
977
|
-
* @implements #1037
|
|
978
|
-
*/
|
|
979
|
-
export const promoteHandler = {
|
|
980
|
-
id: 'promote',
|
|
981
|
-
name: 'Promote',
|
|
982
|
-
description: 'Graduate a project-local bundle to upstream or a corpus path',
|
|
983
|
-
category: 'framework',
|
|
984
|
-
aliases: ['-promote', '--promote', 'graduate'],
|
|
985
|
-
async execute(ctx) {
|
|
986
|
-
const args = ctx.args;
|
|
987
|
-
const positional = args.find(a => !a.startsWith('-'));
|
|
988
|
-
if (!positional) {
|
|
989
|
-
return { exitCode: 1, message: 'Error: bundle name required\n\nUsage: aiwg promote <name> [--to upstream|corpus <path>] [--dry-run] [--cleanup] [--force]' };
|
|
990
|
-
}
|
|
991
|
-
const toIdx = args.findIndex(a => a === '--to');
|
|
992
|
-
const toValue = toIdx >= 0 ? args[toIdx + 1] : 'upstream';
|
|
993
|
-
let corpusPath;
|
|
994
|
-
if (toValue === 'corpus') {
|
|
995
|
-
// The argument *after* "corpus" is the path
|
|
996
|
-
corpusPath = args[toIdx + 2];
|
|
997
|
-
if (!corpusPath || corpusPath.startsWith('-')) {
|
|
998
|
-
return { exitCode: 1, message: 'Error: --to corpus requires a path argument' };
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
else if (toValue !== 'upstream') {
|
|
1002
|
-
return { exitCode: 1, message: `Error: --to must be 'upstream' or 'corpus' (got '${toValue}')` };
|
|
1003
|
-
}
|
|
1004
|
-
const dryRun = args.includes('--dry-run');
|
|
1005
|
-
const cleanup = args.includes('--cleanup');
|
|
1006
|
-
const force = args.includes('--force');
|
|
1007
|
-
try {
|
|
1008
|
-
const { readAiwgConfig, writeAiwgConfig, getProjectDir } = await import('../../config/aiwg-config.js');
|
|
1009
|
-
const { promoteProjectLocalBundle } = await import('../../extensions/project-local-promote.js');
|
|
1010
|
-
const projectDir = getProjectDir({ cwd: ctx.cwd }, args);
|
|
1011
|
-
const config = await readAiwgConfig(projectDir);
|
|
1012
|
-
if (!config) {
|
|
1013
|
-
return { exitCode: 1, message: 'Error: no .aiwg/aiwg.config found — run `aiwg init` first' };
|
|
1014
|
-
}
|
|
1015
|
-
const fr = await getFrameworkRoot();
|
|
1016
|
-
const result = await promoteProjectLocalBundle(config, projectDir, positional, {
|
|
1017
|
-
to: toValue,
|
|
1018
|
-
corpusPath,
|
|
1019
|
-
dryRun,
|
|
1020
|
-
cleanup,
|
|
1021
|
-
force,
|
|
1022
|
-
frameworkRoot: fr,
|
|
1023
|
-
});
|
|
1024
|
-
if (!result.ok) {
|
|
1025
|
-
return { exitCode: 1, message: `Error: ${result.message ?? result.failureReason}` };
|
|
1026
|
-
}
|
|
1027
|
-
if (dryRun && result.plan) {
|
|
1028
|
-
console.log('[dry-run] Would copy:');
|
|
1029
|
-
console.log(` ${result.plan.source} → ${result.plan.destination}`);
|
|
1030
|
-
console.log(` Files: ${result.plan.files.length}, ${result.plan.totalBytes} bytes`);
|
|
1031
|
-
console.log(' Pre-flight: ✓ manifest valid ✓ destination clean');
|
|
1032
|
-
console.log(' Hash verification: skipped (dry-run)');
|
|
1033
|
-
console.log(` Registry update: source: project-local → ${toValue === 'upstream' ? 'bundled' : 'corpus'}`);
|
|
1034
|
-
console.log(` Cleanup: ${cleanup ? 'will remove .aiwg source after copy' : 'skipped (--cleanup not set)'}`);
|
|
1035
|
-
return { exitCode: 0 };
|
|
1036
|
-
}
|
|
1037
|
-
await writeAiwgConfig(projectDir, config);
|
|
1038
|
-
console.log(`✓ Promoted '${positional}' → ${result.plan?.destination}`);
|
|
1039
|
-
if (cleanup) {
|
|
1040
|
-
console.log(' Source removed from .aiwg/');
|
|
1041
|
-
try {
|
|
1042
|
-
const { deployProjectQuickref, generateProjectQuickref, hasProjectQuickref } = await import('../../extensions/project-quickref.js');
|
|
1043
|
-
if (await hasProjectQuickref(projectDir)) {
|
|
1044
|
-
if (config.providers.length > 0) {
|
|
1045
|
-
for (const provider of config.providers)
|
|
1046
|
-
await deployProjectQuickref(projectDir, provider);
|
|
1047
|
-
console.log(` Managed project quickref refreshed for: ${config.providers.join(', ')}.`);
|
|
1048
|
-
}
|
|
1049
|
-
else {
|
|
1050
|
-
await generateProjectQuickref(projectDir);
|
|
1051
|
-
console.log(' Managed project quickref generated; no providers are configured for deployment.');
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
else {
|
|
1055
|
-
console.log(' Managed project quickref is now empty; run `aiwg doctor --project-local` to inspect deployed stale copies.');
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
catch (error) {
|
|
1059
|
-
console.log(` Managed project quickref refresh failed: ${error.message}`);
|
|
1060
|
-
}
|
|
1061
|
-
}
|
|
1062
|
-
return { exitCode: 0 };
|
|
1063
|
-
}
|
|
1064
|
-
catch (err) {
|
|
1065
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1066
|
-
return { exitCode: 1, message: `promote failed: ${msg}` };
|
|
1067
|
-
}
|
|
1068
|
-
},
|
|
1069
|
-
};
|
|
1070
|
-
/**
|
|
1071
|
-
* New bundle handler — scaffolds a project-local bundle under the configured
|
|
1072
|
-
* AIWG artifact root with a valid manifest, starter artifact, and a
|
|
1073
|
-
* README that includes the identical-form portability reminder.
|
|
1074
|
-
*
|
|
1075
|
-
* Usage:
|
|
1076
|
-
* aiwg new-bundle <name> # default: --type extension --starter skill
|
|
1077
|
-
* aiwg new-bundle <name> --type addon
|
|
1078
|
-
* aiwg new-bundle <name> --type framework --starter minimal
|
|
1079
|
-
* aiwg new-bundle <name> --starter rule --description "Custom rule"
|
|
1080
|
-
*
|
|
1081
|
-
* @implements #1050
|
|
1082
|
-
*/
|
|
1083
|
-
export const newBundleHandler = {
|
|
1084
|
-
id: 'new-bundle',
|
|
1085
|
-
name: 'New Bundle',
|
|
1086
|
-
description: 'Scaffold a project-local bundle under the configured AIWG artifact root',
|
|
1087
|
-
category: 'scaffolding',
|
|
1088
|
-
aliases: ['new-extension', 'new-addon', 'new-framework', 'new-plugin', 'new-provider'],
|
|
1089
|
-
async execute(ctx) {
|
|
1090
|
-
const args = ctx.args;
|
|
1091
|
-
const positional = args.find(a => !a.startsWith('-'));
|
|
1092
|
-
if (!positional) {
|
|
1093
|
-
return {
|
|
1094
|
-
exitCode: 1,
|
|
1095
|
-
message: 'Error: bundle name required\n\nUsage: aiwg new-bundle <name> [--type extension|addon|framework|plugin|provider] [--starter skill|rule|agent|minimal] [--description "..."]',
|
|
1096
|
-
};
|
|
1097
|
-
}
|
|
1098
|
-
// Type can be inferred from the alias used to invoke (new-extension etc.)
|
|
1099
|
-
const aliasMap = {
|
|
1100
|
-
'new-extension': 'extension',
|
|
1101
|
-
'new-addon': 'addon',
|
|
1102
|
-
'new-framework': 'framework',
|
|
1103
|
-
'new-plugin': 'plugin',
|
|
1104
|
-
'new-provider': 'provider',
|
|
1105
|
-
};
|
|
1106
|
-
const invoked = ctx.rawArgs[0] ?? '';
|
|
1107
|
-
const aliasType = aliasMap[invoked];
|
|
1108
|
-
const typeIdx = args.findIndex(a => a === '--type');
|
|
1109
|
-
const typeFlag = typeIdx >= 0 ? args[typeIdx + 1] : undefined;
|
|
1110
|
-
const type = (typeFlag ?? aliasType ?? 'extension');
|
|
1111
|
-
if (!['extension', 'addon', 'framework', 'plugin', 'provider'].includes(type)) {
|
|
1112
|
-
return { exitCode: 1, message: `Error: --type must be one of extension|addon|framework|plugin|provider (got '${type}')` };
|
|
1113
|
-
}
|
|
1114
|
-
const starterIdx = args.findIndex(a => a === '--starter');
|
|
1115
|
-
const starter = starterIdx >= 0 ? args[starterIdx + 1] : undefined;
|
|
1116
|
-
if (starter && !['skill', 'rule', 'agent', 'minimal'].includes(starter)) {
|
|
1117
|
-
return { exitCode: 1, message: `Error: --starter must be one of skill|rule|agent|minimal (got '${starter}')` };
|
|
1118
|
-
}
|
|
1119
|
-
const descIdx = args.findIndex(a => a === '--description');
|
|
1120
|
-
const description = descIdx >= 0 ? args[descIdx + 1] : undefined;
|
|
1121
|
-
const dryRun = args.includes('--dry-run');
|
|
1122
|
-
const { scaffoldProjectLocalBundle } = await import('../../extensions/project-local-scaffold.js');
|
|
1123
|
-
try {
|
|
1124
|
-
const result = await scaffoldProjectLocalBundle({
|
|
1125
|
-
type,
|
|
1126
|
-
name: positional,
|
|
1127
|
-
description,
|
|
1128
|
-
starter,
|
|
1129
|
-
projectDir: ctx.cwd,
|
|
1130
|
-
dryRun,
|
|
1131
|
-
});
|
|
1132
|
-
if (result.alreadyExists) {
|
|
1133
|
-
return {
|
|
1134
|
-
exitCode: 1,
|
|
1135
|
-
message: `Refused: bundle already exists at ${result.bundlePath}. Remove it first or pick a different name.`,
|
|
1136
|
-
};
|
|
1137
|
-
}
|
|
1138
|
-
if (dryRun) {
|
|
1139
|
-
console.log(`[DRY RUN] Would scaffold project-local ${type} '${positional}' at ${result.bundlePath}`);
|
|
1140
|
-
console.log(' Files that would be created:');
|
|
1141
|
-
for (const f of result.filesCreated)
|
|
1142
|
-
console.log(` + ${f}`);
|
|
1143
|
-
console.log('');
|
|
1144
|
-
console.log('No files written. Re-run without --dry-run to create.');
|
|
1145
|
-
return { exitCode: 0 };
|
|
1146
|
-
}
|
|
1147
|
-
console.log(`✓ Scaffolded project-local ${type} '${positional}' at ${result.bundlePath}`);
|
|
1148
|
-
console.log(' Files created:');
|
|
1149
|
-
for (const f of result.filesCreated)
|
|
1150
|
-
console.log(` + ${f}`);
|
|
1151
|
-
// #1085 — when the project blanket-ignores .aiwg/, the new bundle's
|
|
1152
|
-
// source would be silently dropped from version control. Detect and
|
|
1153
|
-
// self-heal idempotently.
|
|
1154
|
-
try {
|
|
1155
|
-
const { appendAiwgSourceTrackBlock } = await import('../../extensions/project-local-gitignore.js');
|
|
1156
|
-
const ig = await appendAiwgSourceTrackBlock(ctx.cwd);
|
|
1157
|
-
if (ig.added) {
|
|
1158
|
-
console.log('');
|
|
1159
|
-
console.log(` → ${ig.reason}`);
|
|
1160
|
-
console.log(' .aiwg/{addons,extensions,frameworks,plugins,providers}/ now tracked by git.');
|
|
1161
|
-
console.log(' Generated state under .aiwg/ (working/, ralph/, research/, ...) stays ignored.');
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
catch {
|
|
1165
|
-
// .gitignore management is best-effort; don't fail the scaffold
|
|
1166
|
-
}
|
|
1167
|
-
try {
|
|
1168
|
-
const { generateProjectQuickref } = await import('../../extensions/project-quickref.js');
|
|
1169
|
-
await generateProjectQuickref(ctx.cwd);
|
|
1170
|
-
console.log(' → Managed project quickref refreshed from discovered capabilities.');
|
|
1171
|
-
}
|
|
1172
|
-
catch (error) {
|
|
1173
|
-
console.log(` → Managed project quickref refresh deferred: ${error.message}`);
|
|
1174
|
-
}
|
|
1175
|
-
// #1235 / #1758 — auto-rebuild the project graph and refresh the
|
|
1176
|
-
// Fortemi Core static cache so the new bundle is immediately
|
|
1177
|
-
// discoverable via top-level `aiwg discover` / `aiwg show`.
|
|
1178
|
-
// Best-effort: don't fail the scaffold if indexing hiccups.
|
|
1179
|
-
let indexedOk = false;
|
|
1180
|
-
let fortemiSyncedOk = false;
|
|
1181
|
-
try {
|
|
1182
|
-
const { buildIndex } = await import('../../artifacts/index-builder.js');
|
|
1183
|
-
await buildIndex(ctx.cwd, { graph: 'project', force: false, explicit: true });
|
|
1184
|
-
indexedOk = true;
|
|
1185
|
-
const { syncFortemiCoreIndex } = await import('../../artifacts/fortemi-core-sync.js');
|
|
1186
|
-
syncFortemiCoreIndex(ctx.cwd, { graph: 'project' });
|
|
1187
|
-
fortemiSyncedOk = true;
|
|
1188
|
-
}
|
|
1189
|
-
catch {
|
|
1190
|
-
// ignore — surface via next-steps hint instead
|
|
1191
|
-
}
|
|
1192
|
-
console.log('');
|
|
1193
|
-
console.log('Next steps:');
|
|
1194
|
-
console.log(` 1. Edit manifest.json (description, version, keywords)`);
|
|
1195
|
-
console.log(` 2. Customize the starter artifact under ${result.bundlePath}/`);
|
|
1196
|
-
if (indexedOk && fortemiSyncedOk) {
|
|
1197
|
-
console.log(` 3. Discoverable now via: aiwg discover "${positional}"`);
|
|
1198
|
-
}
|
|
1199
|
-
else if (indexedOk) {
|
|
1200
|
-
console.log(` 3. Sync project search cache: aiwg index sync --graph project`);
|
|
1201
|
-
console.log(` then: aiwg discover "${positional}"`);
|
|
1202
|
-
}
|
|
1203
|
-
else {
|
|
1204
|
-
console.log(` 3. Rebuild project index: aiwg index build --graph project`);
|
|
1205
|
-
console.log(` then sync search cache: aiwg index sync --graph project`);
|
|
1206
|
-
console.log(` then: aiwg discover "${positional}"`);
|
|
1207
|
-
}
|
|
1208
|
-
console.log(` 4. Deploy: aiwg use ${positional}`);
|
|
1209
|
-
console.log(` 5. Inspect: aiwg doctor --project-local`);
|
|
1210
|
-
console.log(` 6. When mature, promote: aiwg promote ${positional}`);
|
|
1211
|
-
return { exitCode: 0 };
|
|
1212
|
-
}
|
|
1213
|
-
catch (err) {
|
|
1214
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
1215
|
-
return { exitCode: 1, message: `Error: ${msg}` };
|
|
1216
|
-
}
|
|
1217
|
-
},
|
|
1218
|
-
};
|
|
1219
|
-
/**
|
|
1220
|
-
* New project handler
|
|
1221
|
-
*
|
|
1222
|
-
* Delegates to tools/install/new-project.mjs
|
|
1223
|
-
*/
|
|
1224
|
-
export const newProjectHandler = {
|
|
1225
|
-
id: "new",
|
|
1226
|
-
name: "New Project",
|
|
1227
|
-
description: "Scaffold a new project with AIWG",
|
|
1228
|
-
category: "project",
|
|
1229
|
-
aliases: ["-new", "--new"],
|
|
1230
|
-
async execute(ctx) {
|
|
1231
|
-
const frameworkRoot = await getFrameworkRoot();
|
|
1232
|
-
const runner = createScriptRunner(frameworkRoot);
|
|
1233
|
-
const result = await runner.run("tools/install/new-project.mjs", ctx.args, {
|
|
1234
|
-
cwd: ctx.cwd,
|
|
1235
|
-
});
|
|
1236
|
-
if (result.exitCode === 0) {
|
|
1237
|
-
// The real scaffolder always runs in an existing target directory. Keep
|
|
1238
|
-
// mocked/script-runner-only calls side-effect free when their synthetic
|
|
1239
|
-
// cwd does not exist.
|
|
1240
|
-
const { access } = await import('node:fs/promises');
|
|
1241
|
-
const { constants } = await import('node:fs');
|
|
1242
|
-
try {
|
|
1243
|
-
await access(ctx.cwd, constants.W_OK);
|
|
1244
|
-
const { ensureWorkspaceContext } = await import('../../smiths/context-pipeline/workspace-context.js');
|
|
1245
|
-
await ensureWorkspaceContext(ctx.cwd);
|
|
1246
|
-
}
|
|
1247
|
-
catch (error) {
|
|
1248
|
-
if (!['ENOENT', 'EACCES'].includes(error.code ?? ''))
|
|
1249
|
-
throw error;
|
|
1250
|
-
}
|
|
1251
|
-
const { formatStarNudge } = await import("../../community/links.js");
|
|
1252
|
-
const { markNudgeShown, shouldShowNudge } = await import("../../community/nudge-policy.js");
|
|
1253
|
-
if (shouldShowNudge('intake')) {
|
|
1254
|
-
const nudge = formatStarNudge();
|
|
1255
|
-
if (nudge) {
|
|
1256
|
-
console.log('');
|
|
1257
|
-
console.log(nudge);
|
|
1258
|
-
markNudgeShown('intake');
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
return result;
|
|
1263
|
-
},
|
|
1264
|
-
};
|
|
1265
|
-
/**
|
|
1266
|
-
* Install plugin handler
|
|
1267
|
-
*
|
|
1268
|
-
* Delegates to tools/plugin/plugin-installer-cli.mjs
|
|
1269
|
-
*/
|
|
1270
|
-
export const installPluginHandler = {
|
|
1271
|
-
id: "install-plugin",
|
|
1272
|
-
name: "Install Plugin",
|
|
1273
|
-
description: "Install a plugin from the registry",
|
|
1274
|
-
category: "plugin",
|
|
1275
|
-
aliases: ["-install-plugin", "--install-plugin"],
|
|
1276
|
-
async execute(ctx) {
|
|
1277
|
-
const frameworkRoot = await getFrameworkRoot();
|
|
1278
|
-
const runner = createScriptRunner(frameworkRoot);
|
|
1279
|
-
return runner.run("tools/plugin/plugin-installer-cli.mjs", ctx.args, {
|
|
1280
|
-
cwd: ctx.cwd,
|
|
1281
|
-
env: { AIWG_ROOT: frameworkRoot },
|
|
1282
|
-
});
|
|
1283
|
-
},
|
|
1284
|
-
};
|
|
1285
|
-
/**
|
|
1286
|
-
* Uninstall plugin handler
|
|
1287
|
-
*
|
|
1288
|
-
* Delegates to tools/plugin/plugin-uninstaller-cli.mjs
|
|
1289
|
-
*/
|
|
1290
|
-
export const uninstallPluginHandler = {
|
|
1291
|
-
id: "uninstall-plugin",
|
|
1292
|
-
name: "Uninstall Plugin",
|
|
1293
|
-
description: "Uninstall a plugin",
|
|
1294
|
-
category: "plugin",
|
|
1295
|
-
aliases: ["-uninstall-plugin", "--uninstall-plugin"],
|
|
1296
|
-
async execute(ctx) {
|
|
1297
|
-
const frameworkRoot = await getFrameworkRoot();
|
|
1298
|
-
const runner = createScriptRunner(frameworkRoot);
|
|
1299
|
-
return runner.run("tools/plugin/plugin-uninstaller-cli.mjs", ctx.args, {
|
|
1300
|
-
cwd: ctx.cwd,
|
|
1301
|
-
});
|
|
1302
|
-
},
|
|
1303
|
-
};
|
|
1304
|
-
/**
|
|
1305
|
-
* Plugin status handler
|
|
1306
|
-
*
|
|
1307
|
-
* Delegates to tools/plugin/plugin-status-cli.mjs
|
|
1308
|
-
*/
|
|
1309
|
-
export const pluginStatusHandler = {
|
|
1310
|
-
id: "plugin-status",
|
|
1311
|
-
name: "Plugin Status",
|
|
1312
|
-
description: "Show plugin status and installation details",
|
|
1313
|
-
category: "plugin",
|
|
1314
|
-
aliases: ["-plugin-status", "--plugin-status"],
|
|
1315
|
-
async execute(ctx) {
|
|
1316
|
-
const frameworkRoot = await getFrameworkRoot();
|
|
1317
|
-
const runner = createScriptRunner(frameworkRoot);
|
|
1318
|
-
return runner.run("tools/plugin/plugin-status-cli.mjs", ctx.args, {
|
|
1319
|
-
cwd: ctx.cwd,
|
|
1320
|
-
});
|
|
1321
|
-
},
|
|
1322
|
-
};
|
|
1323
|
-
/**
|
|
1324
|
-
* Package plugin handler
|
|
1325
|
-
*
|
|
1326
|
-
* Delegates to tools/plugin/package-plugins.mjs
|
|
1327
|
-
*/
|
|
1328
|
-
function packagePluginHelp() {
|
|
1329
|
-
return {
|
|
1330
|
-
exitCode: 0,
|
|
1331
|
-
message: [
|
|
1332
|
-
"aiwg package-plugin — package a project-local or built-in marketplace wrapper",
|
|
1333
|
-
"",
|
|
1334
|
-
"Usage:",
|
|
1335
|
-
" aiwg package-plugin <name> [--source <path>] [--output <path>] [--provider <name>] [--clean] [--dry-run]",
|
|
1336
|
-
" aiwg package-plugin --plugin <name> [options] # compatibility form",
|
|
1337
|
-
"",
|
|
1338
|
-
"Options:",
|
|
1339
|
-
" --source <path> explicit project-local wrapper source (must stay inside the project)",
|
|
1340
|
-
" --output <path> standalone archive output (default: dist/plugins)",
|
|
1341
|
-
" --provider <name> claude, codex, or all for standalone wrappers; built-ins retain all formats",
|
|
1342
|
-
" --clean clean generated plugin output before packaging",
|
|
1343
|
-
" --dry-run, -n preview without writing",
|
|
1344
|
-
" --help, -h show this help",
|
|
1345
|
-
"",
|
|
1346
|
-
"Project-local wrappers are discovered under .aiwg/plugins and packaged as deterministic archives.",
|
|
1347
|
-
].join("\n"),
|
|
1348
|
-
};
|
|
1349
|
-
}
|
|
1350
|
-
export const packagePluginHandler = {
|
|
1351
|
-
id: "package-plugin",
|
|
1352
|
-
name: "Package Plugin",
|
|
1353
|
-
description: "Package a plugin for distribution",
|
|
1354
|
-
category: "plugin",
|
|
1355
|
-
aliases: ["-package-plugin", "--package-plugin"],
|
|
1356
|
-
async help() {
|
|
1357
|
-
return packagePluginHelp();
|
|
1358
|
-
},
|
|
1359
|
-
async execute(ctx) {
|
|
1360
|
-
if (ctx.args.includes("--help") || ctx.args.includes("-h")) {
|
|
1361
|
-
return packagePluginHelp();
|
|
1362
|
-
}
|
|
1363
|
-
const hasExplicitPlugin = ctx.args.includes("--plugin") || ctx.args.includes("-p");
|
|
1364
|
-
const positional = ctx.args[0] && !ctx.args[0].startsWith("-")
|
|
1365
|
-
? ctx.args[0]
|
|
1366
|
-
: undefined;
|
|
1367
|
-
if (!hasExplicitPlugin && !positional) {
|
|
1368
|
-
return {
|
|
1369
|
-
exitCode: 1,
|
|
1370
|
-
message: "Error: plugin name is required.\n\nRun `aiwg package-plugin --help` for usage.",
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
|
-
const positionalSource = positional && (positional.includes('/') || positional.includes('\\'))
|
|
1374
|
-
? positional
|
|
1375
|
-
: undefined;
|
|
1376
|
-
const normalizedArgs = hasExplicitPlugin
|
|
1377
|
-
? ctx.args
|
|
1378
|
-
: positionalSource
|
|
1379
|
-
? [
|
|
1380
|
-
"--plugin", path.basename(path.resolve(ctx.cwd, positionalSource)),
|
|
1381
|
-
"--source", positionalSource,
|
|
1382
|
-
...ctx.args.slice(1),
|
|
1383
|
-
]
|
|
1384
|
-
: ["--plugin", positional, ...ctx.args.slice(1)];
|
|
1385
|
-
const frameworkRoot = await getFrameworkRoot();
|
|
1386
|
-
const runner = createScriptRunner(frameworkRoot);
|
|
1387
|
-
return runner.run("tools/plugin/package-plugins.mjs", normalizedArgs, {
|
|
1388
|
-
cwd: ctx.cwd,
|
|
1389
|
-
});
|
|
1390
|
-
},
|
|
1391
|
-
};
|
|
1392
|
-
/**
|
|
1393
|
-
* Package all plugins handler
|
|
1394
|
-
*
|
|
1395
|
-
* Delegates to tools/plugin/package-plugins.mjs with --all flag
|
|
1396
|
-
*/
|
|
1397
|
-
export const packageAllPluginsHandler = {
|
|
1398
|
-
id: "package-all-plugins",
|
|
1399
|
-
name: "Package All Plugins",
|
|
1400
|
-
description: "Package all plugins for distribution",
|
|
1401
|
-
category: "plugin",
|
|
1402
|
-
aliases: ["-package-all-plugins", "--package-all-plugins"],
|
|
1403
|
-
async execute(ctx) {
|
|
1404
|
-
if (ctx.args.includes("--help") || ctx.args.includes("-h")) {
|
|
1405
|
-
return {
|
|
1406
|
-
exitCode: 0,
|
|
1407
|
-
message: [
|
|
1408
|
-
"aiwg package-all-plugins — package every built-in marketplace wrapper",
|
|
1409
|
-
"",
|
|
1410
|
-
"Usage:",
|
|
1411
|
-
" aiwg package-all-plugins [--provider <name>] [--clean] [--dry-run]",
|
|
1412
|
-
"",
|
|
1413
|
-
"Options:",
|
|
1414
|
-
" --provider <name> claude, codex, cursor, factory, openclaw, or all",
|
|
1415
|
-
" --clean clean generated plugin output before packaging",
|
|
1416
|
-
" --dry-run, -n preview without writing",
|
|
1417
|
-
" --help, -h show this help",
|
|
1418
|
-
].join("\n"),
|
|
1419
|
-
};
|
|
1420
|
-
}
|
|
1421
|
-
const frameworkRoot = await getFrameworkRoot();
|
|
1422
|
-
const runner = createScriptRunner(frameworkRoot);
|
|
1423
|
-
return runner.run("tools/plugin/package-plugins.mjs", ["--all", ...ctx.args], {
|
|
1424
|
-
cwd: ctx.cwd,
|
|
1425
|
-
});
|
|
1426
|
-
},
|
|
1427
|
-
};
|
|
1428
|
-
/**
|
|
1429
|
-
* Artifact index command handler
|
|
1430
|
-
*
|
|
1431
|
-
* Dynamically imports and delegates to src/artifacts/cli.mjs.
|
|
1432
|
-
* Handles subcommands: build, query, deps, stats
|
|
1433
|
-
*
|
|
1434
|
-
* @implements #420
|
|
1435
|
-
*/
|
|
1436
|
-
export const indexHandler = {
|
|
1437
|
-
id: "index",
|
|
1438
|
-
name: "Artifact Index",
|
|
1439
|
-
description: "Artifact index commands (build, query, deps, stats)",
|
|
1440
|
-
category: "index",
|
|
1441
|
-
aliases: [],
|
|
1442
|
-
async help() {
|
|
1443
|
-
const { printIndexUsage } = await import("../../artifacts/cli.js");
|
|
1444
|
-
printIndexUsage();
|
|
1445
|
-
return { exitCode: 0 };
|
|
1446
|
-
},
|
|
1447
|
-
async execute(ctx) {
|
|
1448
|
-
try {
|
|
1449
|
-
const { main } = await import("../../artifacts/cli.js");
|
|
1450
|
-
await main(ctx.args);
|
|
1451
|
-
return {
|
|
1452
|
-
exitCode: Number(process.exitCode ?? 0),
|
|
1453
|
-
};
|
|
1454
|
-
}
|
|
1455
|
-
catch (error) {
|
|
1456
|
-
const result = handlerResultFromError(error);
|
|
1457
|
-
return { ...result, message: `Index command failed: ${result.message}` };
|
|
1458
|
-
}
|
|
1459
|
-
},
|
|
1460
|
-
};
|
|
1461
|
-
/**
|
|
1462
|
-
* `aiwg corpus` — research-corpus tools (radar/freshness subsystem, #1498).
|
|
1463
|
-
* Delegates to the corpus-tools router, mirroring indexHandler.
|
|
1464
|
-
*/
|
|
1465
|
-
export const corpusHandler = {
|
|
1466
|
-
id: "corpus",
|
|
1467
|
-
name: "Research Corpus Tools",
|
|
1468
|
-
description: "Research-corpus tools (radar-init, radar-status, radar-report)",
|
|
1469
|
-
category: "index",
|
|
1470
|
-
aliases: [],
|
|
1471
|
-
async help() {
|
|
1472
|
-
const { corpusMain } = await import("../../artifacts/corpus-tools/cli.js");
|
|
1473
|
-
await corpusMain(["--help"]);
|
|
1474
|
-
return { exitCode: 0 };
|
|
1475
|
-
},
|
|
1476
|
-
async execute(ctx) {
|
|
1477
|
-
try {
|
|
1478
|
-
const { corpusMain } = await import("../../artifacts/corpus-tools/cli.js");
|
|
1479
|
-
await corpusMain(ctx.args, ctx.cwd);
|
|
1480
|
-
return { exitCode: 0 };
|
|
1481
|
-
}
|
|
1482
|
-
catch (error) {
|
|
1483
|
-
const result = handlerResultFromError(error);
|
|
1484
|
-
return { ...result, message: `Corpus command failed: ${result.message}` };
|
|
1485
|
-
}
|
|
1486
|
-
},
|
|
1487
|
-
};
|
|
1488
|
-
/**
|
|
1489
|
-
* Discovery command handler — first-class top-level verb (#1212).
|
|
1490
|
-
*
|
|
1491
|
-
* Forwards to the same implementation as `aiwg index discover` but
|
|
1492
|
-
* exposes discovery as its own command so agents don't conflate it
|
|
1493
|
-
* with the project's general-purpose artifact graph indices.
|
|
1494
|
-
*
|
|
1495
|
-
* aiwg discover "<phrase>" [--limit N] [--type skill,agent,...] [--json]
|
|
1496
|
-
* [--resource-source local|web|auto] [--aiwg-version <version|range|digest|channel>] [--offline]
|
|
1497
|
-
*/
|
|
1498
|
-
export const discoverHandler = {
|
|
1499
|
-
id: "discover",
|
|
1500
|
-
name: "Discover",
|
|
1501
|
-
description: "Find AIWG operational assets by capability — index-driven on-demand discovery",
|
|
1502
|
-
category: "index",
|
|
1503
|
-
aliases: [],
|
|
1504
|
-
async execute(ctx) {
|
|
1505
|
-
try {
|
|
1506
|
-
// Delegate to the same handler `aiwg index discover` uses, by
|
|
1507
|
-
// prepending the `discover` subcommand and reusing the artifacts
|
|
1508
|
-
// CLI router. This keeps a single implementation path.
|
|
1509
|
-
const { main } = await import("../../artifacts/cli.js");
|
|
1510
|
-
await main(["discover", ...ctx.args]);
|
|
1511
|
-
return { exitCode: 0 };
|
|
1512
|
-
}
|
|
1513
|
-
catch (error) {
|
|
1514
|
-
const result = handlerResultFromError(error);
|
|
1515
|
-
return { ...result, message: `Discover command failed: ${result.message}` };
|
|
1516
|
-
}
|
|
1517
|
-
},
|
|
1518
|
-
};
|
|
1519
|
-
/**
|
|
1520
|
-
* Features command handler — manage AIWG's optional runtime features (#1219).
|
|
1521
|
-
*
|
|
1522
|
-
* Subcommands: status / info / install / remove. Native feature installs use
|
|
1523
|
-
* a user-owned package root with explicit package-level script approval.
|
|
1524
|
-
*/
|
|
1525
|
-
export const featuresHandler = {
|
|
1526
|
-
id: "features",
|
|
1527
|
-
name: "Features",
|
|
1528
|
-
description: "List, inspect, and install AIWG's optional runtime features",
|
|
1529
|
-
category: "maintenance",
|
|
1530
|
-
aliases: [],
|
|
1531
|
-
async execute(ctx) {
|
|
1532
|
-
try {
|
|
1533
|
-
const { main } = await import("../../features/cli.js");
|
|
1534
|
-
await main(ctx.args);
|
|
1535
|
-
return { exitCode: 0 };
|
|
1536
|
-
}
|
|
1537
|
-
catch (error) {
|
|
1538
|
-
const result = handlerResultFromError(error);
|
|
1539
|
-
return { ...result, message: `Features command failed: ${result.message}` };
|
|
1540
|
-
}
|
|
1541
|
-
},
|
|
1542
|
-
};
|
|
1543
|
-
/**
|
|
1544
|
-
* Show command handler — fetch the full text of a specific artifact (#1218).
|
|
1545
|
-
*
|
|
1546
|
-
* Forwards to the same implementation as `aiwg index show`. Companion to
|
|
1547
|
-
* `aiwg discover`: where discover ranks candidates, show fetches the body
|
|
1548
|
-
* so consumers don't need to navigate AIWG's storage paths themselves.
|
|
1549
|
-
*
|
|
1550
|
-
* aiwg show <name> [--type skill,agent,...] [--json] [--first]
|
|
1551
|
-
* [--resource-source local|web|auto] [--aiwg-version <version|range|digest|channel>] [--offline]
|
|
1552
|
-
*/
|
|
1553
|
-
export const showHandler = {
|
|
1554
|
-
id: "show",
|
|
1555
|
-
name: "Show",
|
|
1556
|
-
description: "Show an AIWG metadata card; --section or --body fetches content",
|
|
1557
|
-
category: "index",
|
|
1558
|
-
aliases: [],
|
|
1559
|
-
async execute(ctx) {
|
|
1560
|
-
try {
|
|
1561
|
-
const { main } = await import("../../artifacts/cli.js");
|
|
1562
|
-
await main(["show", ...ctx.args]);
|
|
1563
|
-
return { exitCode: 0 };
|
|
1564
|
-
}
|
|
1565
|
-
catch (error) {
|
|
1566
|
-
const result = handlerResultFromError(error);
|
|
1567
|
-
return { ...result, message: `Show command failed: ${result.message}` };
|
|
1568
|
-
}
|
|
1569
|
-
},
|
|
1570
|
-
};
|
|
1571
|
-
/**
|
|
1572
|
-
* Skills command handler
|
|
1573
|
-
*
|
|
1574
|
-
* Dynamically imports and delegates to src/skills/cli.ts.
|
|
1575
|
-
* Handles subcommands: search, info, list, install, publish
|
|
1576
|
-
*
|
|
1577
|
-
* @implements #539
|
|
1578
|
-
*/
|
|
1579
|
-
export const skillsHandler = {
|
|
1580
|
-
id: "skills",
|
|
1581
|
-
name: "Skills Registry",
|
|
1582
|
-
description: "Skill commands (search, info, list, install, publish)",
|
|
1583
|
-
category: "catalog",
|
|
1584
|
-
aliases: [],
|
|
1585
|
-
async execute(ctx) {
|
|
1586
|
-
try {
|
|
1587
|
-
const { main } = await import("../../skills/cli.js");
|
|
1588
|
-
await main(ctx.args);
|
|
1589
|
-
return {
|
|
1590
|
-
exitCode: 0,
|
|
1591
|
-
};
|
|
1592
|
-
}
|
|
1593
|
-
catch (error) {
|
|
1594
|
-
const result = handlerResultFromError(error);
|
|
1595
|
-
return { ...result, message: `Skills command failed: ${result.message}` };
|
|
1596
|
-
}
|
|
1597
|
-
},
|
|
1598
|
-
};
|
|
1599
|
-
/**
|
|
1600
|
-
* Config command handler
|
|
1601
|
-
*
|
|
1602
|
-
* Dynamically imports and delegates to src/config/cli.ts.
|
|
1603
|
-
* Handles subcommands: get, set, list, validate, reset, path, edit
|
|
1604
|
-
*
|
|
1605
|
-
* @implements #545
|
|
1606
|
-
*/
|
|
1607
|
-
export const configHandler = {
|
|
1608
|
-
id: "config",
|
|
1609
|
-
name: "Config",
|
|
1610
|
-
description: "User config commands (get, set, list, validate, reset, path, edit)",
|
|
1611
|
-
category: "config",
|
|
1612
|
-
aliases: [],
|
|
1613
|
-
async execute(ctx) {
|
|
1614
|
-
try {
|
|
1615
|
-
const { main } = await import("../../config/cli.js");
|
|
1616
|
-
await main(ctx.args);
|
|
1617
|
-
return {
|
|
1618
|
-
exitCode: 0,
|
|
1619
|
-
};
|
|
1620
|
-
}
|
|
1621
|
-
catch (error) {
|
|
1622
|
-
const result = handlerResultFromError(error);
|
|
1623
|
-
return { ...result, message: `Config command failed: ${result.message}` };
|
|
1624
|
-
}
|
|
1625
|
-
},
|
|
1626
|
-
};
|
|
1627
|
-
/**
|
|
1628
|
-
* Ops command handler
|
|
1629
|
-
*
|
|
1630
|
-
* Dynamically imports and delegates to src/ops/cli.ts.
|
|
1631
|
-
* Handles subcommands: init, status, use, list, push
|
|
1632
|
-
*
|
|
1633
|
-
* @implements #544
|
|
1634
|
-
*/
|
|
1635
|
-
export const opsHandler = {
|
|
1636
|
-
id: "ops",
|
|
1637
|
-
name: "Ops",
|
|
1638
|
-
description: "Ops ecosystem commands (init, status, use, list, push)",
|
|
1639
|
-
category: "ops",
|
|
1640
|
-
aliases: [],
|
|
1641
|
-
async execute(ctx) {
|
|
1642
|
-
try {
|
|
1643
|
-
const { main } = await import("../../ops/cli.js");
|
|
1644
|
-
await main(ctx.args);
|
|
1645
|
-
return {
|
|
1646
|
-
exitCode: 0,
|
|
1647
|
-
};
|
|
1648
|
-
}
|
|
1649
|
-
catch (error) {
|
|
1650
|
-
const result = handlerResultFromError(error);
|
|
1651
|
-
return { ...result, message: `Ops command failed: ${result.message}` };
|
|
1652
|
-
}
|
|
1653
|
-
},
|
|
1654
|
-
};
|
|
1655
|
-
/**
|
|
1656
|
-
* Activity-log command handler
|
|
1657
|
-
*
|
|
1658
|
-
* Dynamically imports and delegates to src/activity-log/cli.ts.
|
|
1659
|
-
* Handles subcommands: show, append, stats. Persistence routes through
|
|
1660
|
-
* resolveStorage('activity_log') so the log honors any storage.config
|
|
1661
|
-
* override (#934).
|
|
1662
|
-
*
|
|
1663
|
-
* @implements #934
|
|
1664
|
-
* @implements #964
|
|
1665
|
-
*/
|
|
1666
|
-
export const activityLogHandler = {
|
|
1667
|
-
id: 'activity-log',
|
|
1668
|
-
name: 'Activity Log',
|
|
1669
|
-
description: 'Query and manage .aiwg/activity.log (show, append, stats)',
|
|
1670
|
-
category: 'utility',
|
|
1671
|
-
aliases: [],
|
|
1672
|
-
async execute(ctx) {
|
|
1673
|
-
try {
|
|
1674
|
-
const { main } = await import('../../activity-log/cli.js');
|
|
1675
|
-
await main(ctx.args);
|
|
1676
|
-
return { exitCode: 0 };
|
|
1677
|
-
}
|
|
1678
|
-
catch (error) {
|
|
1679
|
-
const result = handlerResultFromError(error);
|
|
1680
|
-
return { ...result, message: `activity-log command failed: ${result.message}` };
|
|
1681
|
-
}
|
|
1682
|
-
},
|
|
1683
|
-
};
|
|
1684
|
-
/**
|
|
1685
|
-
* Provenance command handler — routes \`aiwg provenance\` through
|
|
1686
|
-
* resolveStorage('provenance') for provenance-* skills (#968).
|
|
1687
|
-
*
|
|
1688
|
-
* @implements #934
|
|
1689
|
-
* @implements #968
|
|
1690
|
-
*/
|
|
1691
|
-
export const provenanceHandler = {
|
|
1692
|
-
id: 'provenance',
|
|
1693
|
-
name: 'Provenance',
|
|
1694
|
-
description: 'Provenance subsystem storage operations (path, list, get, put, delete, append-log)',
|
|
1695
|
-
category: 'utility',
|
|
1696
|
-
aliases: [],
|
|
1697
|
-
async execute(ctx) {
|
|
1698
|
-
try {
|
|
1699
|
-
const { main } = await import('../../provenance/cli.js');
|
|
1700
|
-
await main(ctx.args);
|
|
1701
|
-
return { exitCode: 0 };
|
|
1702
|
-
}
|
|
1703
|
-
catch (error) {
|
|
1704
|
-
const result = handlerResultFromError(error);
|
|
1705
|
-
return { ...result, message: `provenance command failed: ${result.message}` };
|
|
1706
|
-
}
|
|
1707
|
-
},
|
|
1708
|
-
};
|
|
1709
|
-
/**
|
|
1710
|
-
* Research storage command handler — routes \`aiwg research-store\`
|
|
1711
|
-
* through resolveStorage('research') for research-acquire / corpus-*
|
|
1712
|
-
* skills (#968). Disambiguated from existing research-* workflow
|
|
1713
|
-
* commands by the \`-store\` suffix.
|
|
1714
|
-
*
|
|
1715
|
-
* @implements #934
|
|
1716
|
-
* @implements #968
|
|
1717
|
-
*/
|
|
1718
|
-
export const researchStoreHandler = {
|
|
1719
|
-
id: 'research-store',
|
|
1720
|
-
name: 'Research Store',
|
|
1721
|
-
description: 'Research subsystem storage operations (path, list, get, put, delete, append-log)',
|
|
1722
|
-
category: 'utility',
|
|
1723
|
-
aliases: [],
|
|
1724
|
-
async execute(ctx) {
|
|
1725
|
-
try {
|
|
1726
|
-
const { main } = await import('../../research/storage-cli.js');
|
|
1727
|
-
await main(ctx.args);
|
|
1728
|
-
return { exitCode: 0 };
|
|
1729
|
-
}
|
|
1730
|
-
catch (error) {
|
|
1731
|
-
const result = handlerResultFromError(error);
|
|
1732
|
-
return { ...result, message: `research-store command failed: ${result.message}` };
|
|
1733
|
-
}
|
|
1734
|
-
},
|
|
1735
|
-
};
|
|
1736
|
-
/** Executable source-selection companion to the research-query skill. */
|
|
1737
|
-
export const researchQueryHandler = {
|
|
1738
|
-
id: 'research-query',
|
|
1739
|
-
name: 'Research Query',
|
|
1740
|
-
description: 'Select research sources for a question with local or Fortemi Core retrieval',
|
|
1741
|
-
category: 'index',
|
|
1742
|
-
aliases: [],
|
|
1743
|
-
async execute(ctx) {
|
|
1744
|
-
try {
|
|
1745
|
-
const { main } = await import('../../research/query-cli.js');
|
|
1746
|
-
await main(ctx.args, ctx.cwd);
|
|
1747
|
-
return { exitCode: 0 };
|
|
1748
|
-
}
|
|
1749
|
-
catch (error) {
|
|
1750
|
-
const result = handlerResultFromError(error);
|
|
1751
|
-
return { ...result, message: `research-query command failed: ${result.message}` };
|
|
1752
|
-
}
|
|
1753
|
-
},
|
|
1754
|
-
};
|
|
1755
|
-
/**
|
|
1756
|
-
* Reflections command handler
|
|
1757
|
-
*
|
|
1758
|
-
* Routes \`aiwg reflections <subcommand>\` through resolveStorage('reflections')
|
|
1759
|
-
* for ralph-reflect / reflection-injection skills (#967).
|
|
1760
|
-
*
|
|
1761
|
-
* @implements #934
|
|
1762
|
-
* @implements #967
|
|
1763
|
-
*/
|
|
1764
|
-
export const reflectionsHandler = {
|
|
1765
|
-
id: 'reflections',
|
|
1766
|
-
name: 'Reflections',
|
|
1767
|
-
description: 'Reflections subsystem storage operations (path, list, get, put, delete, append-log)',
|
|
1768
|
-
category: 'utility',
|
|
1769
|
-
aliases: [],
|
|
1770
|
-
async execute(ctx) {
|
|
1771
|
-
try {
|
|
1772
|
-
const { main } = await import('../../reflections/cli.js');
|
|
1773
|
-
await main(ctx.args);
|
|
1774
|
-
return { exitCode: 0 };
|
|
1775
|
-
}
|
|
1776
|
-
catch (error) {
|
|
1777
|
-
const result = handlerResultFromError(error);
|
|
1778
|
-
return { ...result, message: `reflections command failed: ${result.message}` };
|
|
1779
|
-
}
|
|
1780
|
-
},
|
|
1781
|
-
};
|
|
1782
|
-
/**
|
|
1783
|
-
* Memory command handler
|
|
1784
|
-
*
|
|
1785
|
-
* Routes \`aiwg memory <subcommand>\` through resolveStorage('memory') so
|
|
1786
|
-
* the four memory skills (memory-ingest, memory-lint, memory-log-append,
|
|
1787
|
-
* memory-query-capture) honor any storage.config redirection.
|
|
1788
|
-
*
|
|
1789
|
-
* @implements #934
|
|
1790
|
-
* @implements #966
|
|
1791
|
-
*/
|
|
1792
|
-
export const memoryHandler = {
|
|
1793
|
-
id: 'memory',
|
|
1794
|
-
name: 'Memory',
|
|
1795
|
-
description: 'Memory storage, project registry, read-only audit/cost/recommendations, and reviewed lifecycle operations',
|
|
1796
|
-
category: 'utility',
|
|
1797
|
-
aliases: [],
|
|
1798
|
-
async help(ctx) {
|
|
1799
|
-
if (ctx.args[0] === 'cost') {
|
|
1800
|
-
const { MEMORY_COST_USAGE } = await import('../../memory/cli.js');
|
|
1801
|
-
return { exitCode: 0, message: MEMORY_COST_USAGE, rawOutput: true };
|
|
1802
|
-
}
|
|
1803
|
-
if (ctx.args[0] === 'recommend') {
|
|
1804
|
-
const { MEMORY_RECOMMEND_USAGE } = await import('../../memory/recommend-cli.js');
|
|
1805
|
-
return { exitCode: 0, message: MEMORY_RECOMMEND_USAGE, rawOutput: true };
|
|
1806
|
-
}
|
|
1807
|
-
if (['plan', 'apply', 'verify', 'restore'].includes(ctx.args[0])) {
|
|
1808
|
-
const { MEMORY_MAINTENANCE_USAGE } = await import('../../memory/maintenance-cli.js');
|
|
1809
|
-
return { exitCode: 0, message: MEMORY_MAINTENANCE_USAGE, rawOutput: true };
|
|
1810
|
-
}
|
|
1811
|
-
const { MEMORY_AUDIT_USAGE } = await import('../../memory/cli.js');
|
|
1812
|
-
return { exitCode: 0, message: MEMORY_AUDIT_USAGE, rawOutput: true };
|
|
1813
|
-
},
|
|
1814
|
-
async execute(ctx) {
|
|
1815
|
-
try {
|
|
1816
|
-
const { main } = await import('../../memory/cli.js');
|
|
1817
|
-
return { exitCode: (await main(ctx.args)) ?? 0 };
|
|
1818
|
-
}
|
|
1819
|
-
catch (error) {
|
|
1820
|
-
const result = handlerResultFromError(error);
|
|
1821
|
-
if (['audit', 'cost', 'recommend', 'plan', 'apply', 'verify', 'restore'].includes(ctx.args[0])) {
|
|
1822
|
-
const { isAiwgError } = await import('../errors.js');
|
|
1823
|
-
const exitCode = isAiwgError(error) ? error.exitCode : 3;
|
|
1824
|
-
const receipt = error && typeof error === 'object' && 'receipt' in error ? error.receipt : undefined;
|
|
1825
|
-
if (ctx.args.includes('--json')) {
|
|
1826
|
-
console.log(JSON.stringify({ error: result.message, exitCode,
|
|
1827
|
-
...(receipt !== undefined ? { receipt } : {}) }, null, 2));
|
|
1828
|
-
return { exitCode };
|
|
1829
|
-
}
|
|
1830
|
-
return { ...result, exitCode, message: `memory command failed: ${result.message}${receipt !== undefined ? `\n${JSON.stringify({ receipt }, null, 2)}` : ''}` };
|
|
1831
|
-
}
|
|
1832
|
-
return { ...result, message: `memory command failed: ${result.message}` };
|
|
1833
|
-
}
|
|
1834
|
-
},
|
|
1835
|
-
};
|
|
1836
|
-
/**
|
|
1837
|
-
* Knowledge-base command handler
|
|
1838
|
-
*
|
|
1839
|
-
* Routes \`aiwg kb <subcommand>\` through resolveStorage('kb') so the KB
|
|
1840
|
-
* honors any storage.config redirection without each kb skill
|
|
1841
|
-
* hardcoding `.aiwg/kb/`.
|
|
1842
|
-
*
|
|
1843
|
-
* @implements #934
|
|
1844
|
-
* @implements #965
|
|
1845
|
-
*/
|
|
1846
|
-
export const kbHandler = {
|
|
1847
|
-
id: 'kb',
|
|
1848
|
-
name: 'Knowledge Base',
|
|
1849
|
-
description: 'Knowledge base storage operations (path, list, get, put, delete)',
|
|
1850
|
-
category: 'utility',
|
|
1851
|
-
aliases: [],
|
|
1852
|
-
async execute(ctx) {
|
|
1853
|
-
try {
|
|
1854
|
-
const { main } = await import('../../kb/cli.js');
|
|
1855
|
-
await main(ctx.args);
|
|
1856
|
-
return { exitCode: 0 };
|
|
1857
|
-
}
|
|
1858
|
-
catch (error) {
|
|
1859
|
-
const result = handlerResultFromError(error);
|
|
1860
|
-
return { ...result, message: `kb command failed: ${result.message}` };
|
|
1861
|
-
}
|
|
1862
|
-
},
|
|
1863
|
-
};
|
|
1864
|
-
/**
|
|
1865
|
-
* Storage command handler
|
|
1866
|
-
*
|
|
1867
|
-
* Dynamically imports and delegates to src/storage/cli.ts.
|
|
1868
|
-
* Handles subcommands: show, list-backends, test
|
|
1869
|
-
*
|
|
1870
|
-
* @implements #934
|
|
1871
|
-
* @implements #954
|
|
1872
|
-
*/
|
|
1873
|
-
export const storageHandler = {
|
|
1874
|
-
id: 'storage',
|
|
1875
|
-
name: 'Storage',
|
|
1876
|
-
description: 'Storage adapter commands (show, list-backends, test)',
|
|
1877
|
-
category: 'utility',
|
|
1878
|
-
aliases: [],
|
|
1879
|
-
async execute(ctx) {
|
|
1880
|
-
try {
|
|
1881
|
-
const { main } = await import('../../storage/cli.js');
|
|
1882
|
-
await main(ctx.args);
|
|
1883
|
-
return { exitCode: 0 };
|
|
1884
|
-
}
|
|
1885
|
-
catch (error) {
|
|
1886
|
-
const result = handlerResultFromError(error);
|
|
1887
|
-
return { ...result, message: `Storage command failed: ${result.message}` };
|
|
1888
|
-
}
|
|
1889
|
-
},
|
|
1890
|
-
};
|
|
1891
|
-
/**
|
|
1892
|
-
* RLM agentic tools handler
|
|
1893
|
-
*
|
|
1894
|
-
* Routes `aiwg chunk`, `aiwg fanout`, `aiwg rlm-prep`, `aiwg rlm-search`,
|
|
1895
|
-
* and `aiwg rlm-status` to src/rlm/cli.ts.
|
|
1896
|
-
*
|
|
1897
|
-
* These are support tools for agentic sessions — callable by users but
|
|
1898
|
-
* primarily used by RLM agents during recursive and fanout operations.
|
|
1899
|
-
*
|
|
1900
|
-
* @implements #559
|
|
1901
|
-
*/
|
|
1902
|
-
export const rlmToolsHandler = {
|
|
1903
|
-
id: 'rlm-tools',
|
|
1904
|
-
name: 'RLM Tools',
|
|
1905
|
-
description: 'Agentic support tools for RLM operations (chunk, fanout, rlm-prep, rlm-search, rlm-status)',
|
|
1906
|
-
category: 'agentic-tools',
|
|
1907
|
-
aliases: [],
|
|
1908
|
-
async execute(ctx) {
|
|
1909
|
-
try {
|
|
1910
|
-
const { main } = await import('../../rlm/cli.js');
|
|
1911
|
-
await main(ctx.args);
|
|
1912
|
-
return {
|
|
1913
|
-
exitCode: 0,
|
|
1914
|
-
};
|
|
1915
|
-
}
|
|
1916
|
-
catch (error) {
|
|
1917
|
-
const result = handlerResultFromError(error);
|
|
1918
|
-
return { ...result, message: `RLM tools command failed: ${result.message}` };
|
|
1919
|
-
}
|
|
1920
|
-
},
|
|
1921
|
-
};
|
|
1922
|
-
// Individual handlers that delegate to rlmToolsHandler with their command prepended
|
|
1923
|
-
export const chunkHandler = {
|
|
1924
|
-
id: 'chunk',
|
|
1925
|
-
name: 'Chunk',
|
|
1926
|
-
description: 'Split a file into overlapping chunks for parallel fanout processing',
|
|
1927
|
-
category: 'agentic-tools',
|
|
1928
|
-
aliases: [],
|
|
1929
|
-
async execute(ctx) {
|
|
1930
|
-
return rlmToolsHandler.execute({ ...ctx, args: ['chunk', ...ctx.args] });
|
|
1931
|
-
},
|
|
1932
|
-
};
|
|
1933
|
-
export const fanoutHandler = {
|
|
1934
|
-
id: 'fanout',
|
|
1935
|
-
name: 'Fanout',
|
|
1936
|
-
description: 'Dispatch parallel subagent queries across a chunk manifest',
|
|
1937
|
-
category: 'agentic-tools',
|
|
1938
|
-
aliases: [],
|
|
1939
|
-
async execute(ctx) {
|
|
1940
|
-
return rlmToolsHandler.execute({ ...ctx, args: ['fanout', ...ctx.args] });
|
|
1941
|
-
},
|
|
1942
|
-
};
|
|
1943
|
-
export const rlmPrepHandler = {
|
|
1944
|
-
id: 'rlm-prep',
|
|
1945
|
-
name: 'RLM Prep',
|
|
1946
|
-
description: 'Prepare source content for RLM processing (chunk + index + manifest)',
|
|
1947
|
-
category: 'agentic-tools',
|
|
1948
|
-
aliases: [],
|
|
1949
|
-
async execute(ctx) {
|
|
1950
|
-
return rlmToolsHandler.execute({ ...ctx, args: ['rlm-prep', ...ctx.args] });
|
|
1951
|
-
},
|
|
1952
|
-
};
|
|
1953
|
-
export const rlmSearchHandler = {
|
|
1954
|
-
id: 'rlm-search',
|
|
1955
|
-
name: 'RLM Search',
|
|
1956
|
-
description: 'Full recursive search pipeline: decompose source, fanout query, synthesize results',
|
|
1957
|
-
category: 'agentic-tools',
|
|
1958
|
-
aliases: [],
|
|
1959
|
-
async execute(ctx) {
|
|
1960
|
-
return rlmToolsHandler.execute({ ...ctx, args: ['rlm-search', ...ctx.args] });
|
|
1961
|
-
},
|
|
1962
|
-
};
|
|
1963
|
-
export const rlmStatusCliHandler = {
|
|
1964
|
-
id: 'rlm-status',
|
|
1965
|
-
name: 'RLM Status',
|
|
1966
|
-
description: 'Show active RLM task tree, progress, and cost breakdown',
|
|
1967
|
-
category: 'agentic-tools',
|
|
1968
|
-
aliases: [],
|
|
1969
|
-
async execute(ctx) {
|
|
1970
|
-
return rlmToolsHandler.execute({ ...ctx, args: ['rlm-status', ...ctx.args] });
|
|
1971
|
-
},
|
|
1972
|
-
};
|
|
1973
|
-
/** RLM result cache (#1203). */
|
|
1974
|
-
export const rlmCacheHandler = {
|
|
1975
|
-
id: 'rlm-cache',
|
|
1976
|
-
name: 'RLM Cache',
|
|
1977
|
-
description: 'Manage cached RLM results (list, stats, evict, clear) — keyed by index content-hash',
|
|
1978
|
-
category: 'agentic-tools',
|
|
1979
|
-
aliases: [],
|
|
1980
|
-
async execute(ctx) {
|
|
1981
|
-
return rlmToolsHandler.execute({ ...ctx, args: ['rlm-cache', ...ctx.args] });
|
|
1982
|
-
},
|
|
1983
|
-
};
|
|
1984
|
-
/**
|
|
1985
|
-
* All subcommand handlers
|
|
1986
|
-
*/
|
|
3
|
+
import { quickrefHandler } from "./subcommands-quickref.js";
|
|
4
|
+
export { quickrefHandler };
|
|
5
|
+
import { listHandler } from "./subcommands-list.js";
|
|
6
|
+
export { listHandler };
|
|
7
|
+
import { removeHandler } from "./remove.js";
|
|
8
|
+
export { removeHandler };
|
|
9
|
+
import { promoteHandler, newBundleHandler } from "./subcommands-bundles.js";
|
|
10
|
+
export { promoteHandler, newBundleHandler };
|
|
11
|
+
import { newProjectHandler, installPluginHandler, uninstallPluginHandler, pluginStatusHandler, packagePluginHandler, packageAllPluginsHandler } from "./subcommands-plugins.js";
|
|
12
|
+
export { newProjectHandler, installPluginHandler, uninstallPluginHandler, pluginStatusHandler, packagePluginHandler, packageAllPluginsHandler };
|
|
13
|
+
import { indexHandler, corpusHandler, discoverHandler, featuresHandler, showHandler, skillsHandler } from "./subcommands-discovery.js";
|
|
14
|
+
export { indexHandler, corpusHandler, discoverHandler, featuresHandler, showHandler, skillsHandler };
|
|
15
|
+
import { configHandler, opsHandler, activityLogHandler, provenanceHandler, researchStoreHandler, researchQueryHandler, reflectionsHandler, memoryHandler, kbHandler } from "./subcommands-storage.js";
|
|
16
|
+
export { configHandler, opsHandler, activityLogHandler, provenanceHandler, researchStoreHandler, researchQueryHandler, reflectionsHandler, memoryHandler, kbHandler };
|
|
17
|
+
import { storageHandler, rlmToolsHandler, chunkHandler, fanoutHandler, rlmPrepHandler, rlmSearchHandler, rlmStatusCliHandler, rlmCacheHandler } from "./subcommands-rlm.js";
|
|
18
|
+
export { storageHandler, rlmToolsHandler, chunkHandler, fanoutHandler, rlmPrepHandler, rlmSearchHandler, rlmStatusCliHandler, rlmCacheHandler };
|
|
19
|
+
import { mcpHandler, catalogHandler } from "./subcommands-services.js";
|
|
20
|
+
export { mcpHandler, catalogHandler };
|
|
1987
21
|
export const subcommandHandlers = [
|
|
1988
22
|
mcpHandler,
|
|
1989
23
|
catalogHandler,
|