@aiwg/cli 2026.10.16 → 2026.10.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/src/artifacts/corpus-tools/resolve.js +21 -4
  2. package/dist/src/artifacts/query-engine-corpus.js +217 -0
  3. package/dist/src/artifacts/query-engine-discover-output.js +229 -0
  4. package/dist/src/artifacts/query-engine-discover.js +285 -0
  5. package/dist/src/artifacts/query-engine-entries.js +188 -0
  6. package/dist/src/artifacts/query-engine-index.js +249 -0
  7. package/dist/src/artifacts/query-engine-matching.js +143 -0
  8. package/dist/src/artifacts/query-engine-options.js +2 -0
  9. package/dist/src/artifacts/query-engine-rules.js +202 -0
  10. package/dist/src/artifacts/query-engine-scoring.js +436 -0
  11. package/dist/src/artifacts/query-engine-show-card.js +194 -0
  12. package/dist/src/artifacts/query-engine-show-load.js +211 -0
  13. package/dist/src/artifacts/query-engine-show.js +300 -0
  14. package/dist/src/artifacts/query-engine.js +7 -2576
  15. package/dist/src/cli/handlers/mc-agents.js +111 -0
  16. package/dist/src/cli/handlers/mc-args.js +54 -0
  17. package/dist/src/cli/handlers/mc-control.js +227 -0
  18. package/dist/src/cli/handlers/mc-dispatch.js +203 -0
  19. package/dist/src/cli/handlers/mc-help.js +171 -0
  20. package/dist/src/cli/handlers/mc-run.js +343 -0
  21. package/dist/src/cli/handlers/mc-session.js +138 -0
  22. package/dist/src/cli/handlers/mc-status.js +258 -0
  23. package/dist/src/cli/handlers/mc-summary.js +43 -0
  24. package/dist/src/cli/handlers/mc-types.js +3 -0
  25. package/dist/src/cli/handlers/mc-worker.js +205 -0
  26. package/dist/src/cli/handlers/mc.js +12 -1665
  27. package/dist/src/cli/handlers/models-refusal.js +13 -0
  28. package/dist/src/cli/handlers/models.js +2 -1
  29. package/dist/src/cli/handlers/remove-bundled.js +133 -0
  30. package/dist/src/cli/handlers/remove-options.js +31 -0
  31. package/dist/src/cli/handlers/remove-user.js +174 -0
  32. package/dist/src/cli/handlers/remove.js +201 -0
  33. package/dist/src/cli/handlers/subcommands-bundles.js +257 -0
  34. package/dist/src/cli/handlers/subcommands-discovery.js +165 -0
  35. package/dist/src/cli/handlers/subcommands-list-format.js +129 -0
  36. package/dist/src/cli/handlers/subcommands-list.js +250 -0
  37. package/dist/src/cli/handlers/subcommands-plugins.js +213 -0
  38. package/dist/src/cli/handlers/subcommands-quickref.js +58 -0
  39. package/dist/src/cli/handlers/subcommands-rlm.js +113 -0
  40. package/dist/src/cli/handlers/subcommands-services.js +66 -0
  41. package/dist/src/cli/handlers/subcommands-storage.js +259 -0
  42. package/dist/src/cli/handlers/subcommands.js +18 -1984
  43. package/dist/src/cli/scope-resolver.js +1 -142
  44. package/dist/src/cli/user-scope-mirror.js +173 -0
  45. package/dist/src/config/dispatch-host-thresholds.js +2 -0
  46. package/dist/src/config/dispatch-thresholds-runtime.mjs +4 -0
  47. package/dist/src/config/host-resource-report.d.mts +5 -0
  48. package/dist/src/config/host-resource-report.mjs +36 -6
  49. package/dist/src/config/host-resource-runtime.d.mts +3 -0
  50. package/dist/src/config/host-resource-runtime.mjs +9 -6
  51. package/dist/src/decision/ensemble-study/artifacts.js +7 -0
  52. package/dist/src/decision/ensemble-study/gate-policy.js +58 -0
  53. package/dist/src/decision/ensemble-study/gates.js +78 -0
  54. package/dist/src/decision/ensemble-study/protocol.js +18 -21
  55. package/dist/src/decision/ensemble-study/score.js +3 -2
  56. package/dist/src/decision/ensemble-study/statistics.js +7 -26
  57. package/dist/src/decision/sensitivity/comparative-gates.js +135 -0
  58. package/dist/src/decision/sensitivity/comparative.js +18 -41
  59. package/dist/src/extensions/claude-hooks-installer.js +18 -0
  60. package/dist/src/gates/evaluate.js +2 -358
  61. package/dist/src/gates/observations.js +363 -0
  62. package/dist/src/gates/pack-composition.js +270 -0
  63. package/dist/src/gates/pack-tightening.js +197 -0
  64. package/dist/src/gates/pack-validation.js +262 -0
  65. package/dist/src/gates/registry-error.js +5 -0
  66. package/dist/src/gates/registry.js +13 -685
  67. package/dist/src/mcp/json-document.mjs +29 -0
  68. package/dist/src/mcp/muse-native-config.mjs +1 -28
  69. package/dist/src/mission-protocol/worker-review-gate.js +7 -0
  70. package/dist/src/models/worker-plan.js +5 -5
  71. package/dist/src/plugin/command-ownership.js +34 -0
  72. package/dist/src/plugin/skill-command-frontmatter.js +197 -0
  73. package/dist/src/plugin/skill-command-translator.js +6 -232
  74. package/dist/src/providers/context-output-ownership.js +26 -0
  75. package/dist/src/providers/deployment-ownership.d.mts +19 -0
  76. package/dist/src/providers/deployment-ownership.mjs +226 -0
  77. package/dist/src/providers/deployment-removal.js +200 -0
  78. package/dist/src/providers/removal-transaction.js +86 -0
  79. package/dist/src/providers/settings-document.d.mts +3 -0
  80. package/dist/src/providers/settings-document.mjs +47 -0
  81. package/dist/src/providers/settings-removal.js +190 -0
  82. package/dist/src/providers/skill-ownership.d.mts +19 -2
  83. package/dist/src/providers/skill-ownership.mjs +12 -4
  84. package/dist/src/providers/transformation-receipt-integration.js +15 -271
  85. package/dist/src/providers/transformation-receipt-outputs.js +99 -0
  86. package/dist/src/providers/transformation-receipt-source.js +194 -0
  87. package/dist/src/research/identity.js +8 -2
  88. package/dist/src/research/reference-match.js +42 -7
  89. package/dist/src/rules/activation.mjs +15 -6
  90. package/dist/src/rules/core-startup.mjs +2 -2
  91. package/dist/src/serve/mission-conductor.js +4 -0
  92. package/dist/src/serve/mission-summary.js +56 -0
  93. package/dist/src/smiths/context-pipeline/aiwg-md.js +23 -0
  94. package/dist/src/smiths/context-pipeline/context-file-safety.js +3 -0
  95. package/dist/src/smiths/context-pipeline/generator.js +1 -1
  96. package/dist/src/smiths/hook-bridge/index.js +9 -0
  97. package/package.json +4 -1
  98. package/schemas/decision/D17StudyProtocol.v1.schema.json +39 -67
  99. package/tools/agents/deploy-agents.mjs +16 -677
  100. package/tools/agents/deploy-command-mirrors.mjs +229 -0
  101. package/tools/agents/deploy-options.mjs +258 -0
  102. package/tools/agents/deploy-support.mjs +165 -0
  103. package/tools/agents/providers/base-addon-discovery.mjs +139 -0
  104. package/tools/agents/providers/base-behaviors.mjs +168 -0
  105. package/tools/agents/providers/base-context.mjs +205 -0
  106. package/tools/agents/providers/base-contract.mjs +116 -0
  107. package/tools/agents/providers/base-files.mjs +252 -0
  108. package/tools/agents/providers/base-flat-artifacts.mjs +233 -0
  109. package/tools/agents/providers/base-framework-discovery.mjs +309 -0
  110. package/tools/agents/providers/base-frontmatter.mjs +196 -0
  111. package/tools/agents/providers/base-inventory.mjs +269 -0
  112. package/tools/agents/providers/base-kernel-skills.mjs +354 -0
  113. package/tools/agents/providers/base-migrations.mjs +258 -0
  114. package/tools/agents/providers/base-models-platforms.mjs +273 -0
  115. package/tools/agents/providers/base-rule-index.mjs +450 -0
  116. package/tools/agents/providers/base-runtime.mjs +60 -0
  117. package/tools/agents/providers/base-skill-copy.mjs +273 -0
  118. package/tools/agents/providers/base.mjs +16 -3364
  119. package/tools/agents/providers/claude-post-deploy.mjs +10 -2
  120. package/tools/agents/providers/hermes-startup.mjs +0 -5
  121. package/tools/agents/providers/muse.mjs +7 -2
  122. package/tools/agents/providers/rule-delivery-surface.mjs +31 -4
  123. package/tools/agents/providers/rule-deployment-commit.mjs +19 -15
  124. package/tools/agents/providers/rule-deployment-prepare.mjs +11 -2
  125. package/tools/agents/providers/rule-projection.mjs +3 -0
  126. package/tools/ralph-external/lib/worker-invocation-processes.mjs +4 -2
  127. package/tools/ralph-external/lib/worker-termination.mjs +15 -8
  128. package/vscode-extension/schemas/aiwg.config.v1.json +2 -4
@@ -0,0 +1,250 @@
1
+ import { createScriptRunner } from "./script-runner.js";
2
+ import { getFrameworkRoot } from "../../channel/manager.mjs";
3
+ import * as path from "node:path";
4
+ import * as fsSync from "node:fs";
5
+ import { getRegistry } from "../../extensions/registry.js";
6
+ import { registerDeployedExtensions } from "../../extensions/deployment-registration.js";
7
+ import { discoverProjectLocalBundles } from "../../extensions/project-local-discovery.js";
8
+ import { getProjectDir } from "../../config/aiwg-config.js";
9
+ import { formatDeployedWorkspaceSignalPlan, readWorkspaceSignalPlan } from "../workspace-signals.js";
10
+ import { isScopeUser, formatUserScopeRegistry, formatProjectLocalOnly, formatShadowsOnly } from "./subcommands-list-format.js";
11
+ const LIST_PROVIDER_TARGETS = [
12
+ { name: 'claude', root: '.claude', agentsPath: '.claude/agents', skillsPath: '.claude/skills', commandsPath: '.claude/commands' },
13
+ { name: 'codex', root: '.codex', agentsPath: '.codex/agents', skillsPath: '.codex/skills', commandsPath: '.codex/commands' },
14
+ { name: 'copilot', root: '.github', agentsPath: '.github/agents', skillsPath: '.github/skills', commandsPath: '.github/prompts' },
15
+ { name: 'cursor', root: '.cursor', agentsPath: '.cursor/agents', skillsPath: '.cursor/skills', commandsPath: '.cursor/commands' },
16
+ { name: 'opencode', root: '.opencode', agentsPath: '.opencode/agent', skillsPath: '.opencode/skill', commandsPath: '.opencode/command' },
17
+ { name: 'warp', root: '.warp', agentsPath: '.warp/agents', skillsPath: '.warp/skills', commandsPath: '.warp/commands' },
18
+ { name: 'factory', root: '.factory', agentsPath: '.factory/droids', skillsPath: '.factory/skills', commandsPath: '.factory/commands' },
19
+ { name: 'windsurf', root: '.windsurf', agentsPath: '.windsurf/agents', skillsPath: '.windsurf/skills', commandsPath: '.windsurf/workflows' },
20
+ { name: 'universal', root: '.agents', agentsPath: '.agents/agents', skillsPath: '.agents/skills', commandsPath: '.agents/commands' },
21
+ ];
22
+ function hasAnyPopulated(cwd, p) {
23
+ const candidates = [p.agentsPath, p.skillsPath, p.commandsPath];
24
+ for (const rel of candidates) {
25
+ const abs = path.join(cwd, rel);
26
+ try {
27
+ if (fsSync.statSync(abs).isDirectory() && fsSync.readdirSync(abs).length > 0)
28
+ return true;
29
+ }
30
+ catch {
31
+ // dir doesn't exist or unreadable — skip
32
+ }
33
+ }
34
+ return false;
35
+ }
36
+ function detectDeployedProviders(cwd) {
37
+ return LIST_PROVIDER_TARGETS.filter(p => hasAnyPopulated(cwd, p));
38
+ }
39
+ export const listHandler = {
40
+ id: "list",
41
+ name: "List Frameworks",
42
+ description: "List installed frameworks and plugins",
43
+ category: "framework",
44
+ aliases: ["ls"],
45
+ async execute(ctx) {
46
+ // Filter args: positional type filter, plus --project-local flag (#1034)
47
+ const projectLocalOnly = ctx.args.includes('--project-local');
48
+ const shadowsOnly = ctx.args.includes('--shadows');
49
+ const deployedOnly = ctx.args.includes('--deployed');
50
+ const filterType = ctx.args.find((a) => !a.startsWith('--')); // 'agents'|'skills'|'commands'|'all'|undefined
51
+ // #1156 Phase 1 — --scope user / --user surfaces the per-user registry
52
+ // (~/.aiwg/installed.json) instead of the project-scope deployed-extensions
53
+ // registry. Works from any cwd; does not require a project to be present.
54
+ const userScopeRequested = ctx.args.includes('--user') || isScopeUser(ctx.args);
55
+ if (userScopeRequested) {
56
+ return await formatUserScopeRegistry();
57
+ }
58
+ // Project-local bundle discovery (#1034) — read-only scan, no deploy
59
+ const projectLocal = await discoverProjectLocalBundles(ctx.cwd);
60
+ if (shadowsOnly) {
61
+ // #1036 — surface only artifacts that shadow upstream
62
+ return await formatShadowsOnly(projectLocal);
63
+ }
64
+ if (projectLocalOnly) {
65
+ // --project-local: only show project-local bundles; skip the deployed-
66
+ // extension registry read entirely
67
+ return formatProjectLocalOnly(projectLocal);
68
+ }
69
+ // Ensure registry is populated with deployed extensions
70
+ const registry = getRegistry();
71
+ // If registry is empty, try to populate it from EVERY deployed provider
72
+ // in the workspace (not just claude). Fixes #1530: in a Codex-only
73
+ // workspace the legacy hard-coded `.claude/...` lookup reported zero
74
+ // extensions even though `.codex/` was populated. Detection mirrors
75
+ // `tools/cli/workspace-status.mjs` so `aiwg list` and `aiwg status`
76
+ // agree on what counts as deployed.
77
+ //
78
+ // `--provider <name>` narrows registration to one provider; otherwise
79
+ // we register the union of everything detected so a multi-provider
80
+ // workspace shows everything in a single inventory.
81
+ if (registry.size === 0) {
82
+ try {
83
+ const provIdx = ctx.args.findIndex((a) => a === '--provider' || a === '--platform');
84
+ const requestedProvider = provIdx >= 0 ? ctx.args[provIdx + 1] : undefined;
85
+ let targets = detectDeployedProviders(ctx.cwd);
86
+ if (requestedProvider) {
87
+ targets = targets.filter((p) => p.name === requestedProvider);
88
+ if (targets.length === 0) {
89
+ return {
90
+ exitCode: 1,
91
+ message: `Error: provider '${requestedProvider}' is not deployed in this workspace.\n\nRun 'aiwg status' to see deployed providers.`,
92
+ };
93
+ }
94
+ }
95
+ if (targets.length === 0) {
96
+ // No deployed providers detected → return a clean empty-inventory
97
+ // message rather than dispatching to the legacy script (which
98
+ // requires a path argument it doesn't get here). Matches the
99
+ // legacy script's helpful guidance from #1530.
100
+ return {
101
+ exitCode: 0,
102
+ message: 'No agents, skills, or commands deployed in this workspace.\n\n' +
103
+ 'Tip: Deploy a framework with "aiwg use sdlc" (or another framework) to get started.\n' +
104
+ 'Run "aiwg status" for workspace health detail.\n',
105
+ };
106
+ }
107
+ for (const target of targets) {
108
+ await registerDeployedExtensions(registry, {
109
+ agentsPath: target.agentsPath,
110
+ skillsPath: target.skillsPath,
111
+ commandsPath: target.commandsPath,
112
+ provider: target.name,
113
+ cwd: ctx.cwd,
114
+ });
115
+ }
116
+ }
117
+ catch (error) {
118
+ // If registry population fails, fall back to legacy script
119
+ const frameworkRoot = await getFrameworkRoot();
120
+ const runner = createScriptRunner(frameworkRoot);
121
+ return runner.run("tools/plugin/plugin-status-cli.mjs", ctx.args, {
122
+ cwd: ctx.cwd,
123
+ });
124
+ }
125
+ }
126
+ // Determine what to show
127
+ const showAgents = !filterType || filterType === 'agents' || filterType === 'all';
128
+ const showSkills = !filterType || filterType === 'skills' || filterType === 'all';
129
+ const showCommands = !filterType || filterType === 'commands' || filterType === 'all';
130
+ let output = '';
131
+ if (showAgents) {
132
+ const agents = registry.getByType('agent');
133
+ output += `\nAgents (${agents.length}):\n`;
134
+ output += '─'.repeat(60) + '\n';
135
+ if (agents.length === 0) {
136
+ output += ' No agents deployed\n';
137
+ }
138
+ else {
139
+ for (const agent of agents.slice(0, 20)) { // Limit to 20 for readability
140
+ output += ` ${agent.name}\n`;
141
+ output += ` ID: ${agent.id}\n`;
142
+ output += ` Description: ${agent.description.slice(0, 80)}${agent.description.length > 80 ? '...' : ''}\n`;
143
+ if (agent.installation) {
144
+ output += ` Path: ${agent.installation.installedPath}\n`;
145
+ }
146
+ output += '\n';
147
+ }
148
+ if (agents.length > 20) {
149
+ output += ` ... and ${agents.length - 20} more\n`;
150
+ }
151
+ }
152
+ }
153
+ if (showSkills) {
154
+ const skills = registry.getByType('skill');
155
+ output += `\nSkills (${skills.length}):\n`;
156
+ output += '─'.repeat(60) + '\n';
157
+ if (skills.length === 0) {
158
+ output += ' No skills deployed\n';
159
+ }
160
+ else {
161
+ for (const skill of skills.slice(0, 20)) {
162
+ output += ` ${skill.name}\n`;
163
+ output += ` ID: ${skill.id}\n`;
164
+ output += ` Description: ${skill.description.slice(0, 80)}${skill.description.length > 80 ? '...' : ''}\n`;
165
+ if (skill.installation) {
166
+ output += ` Path: ${skill.installation.installedPath}\n`;
167
+ }
168
+ output += '\n';
169
+ }
170
+ if (skills.length > 20) {
171
+ output += ` ... and ${skills.length - 20} more\n`;
172
+ }
173
+ }
174
+ }
175
+ if (showCommands) {
176
+ const commands = registry.getByType('command');
177
+ output += `\nCommands (${commands.length}):\n`;
178
+ output += '─'.repeat(60) + '\n';
179
+ if (commands.length === 0) {
180
+ output += ' No commands registered\n';
181
+ }
182
+ else {
183
+ for (const command of commands.slice(0, 20)) {
184
+ output += ` ${command.name}\n`;
185
+ output += ` ID: ${command.id}\n`;
186
+ output += ` Description: ${command.description.slice(0, 80)}${command.description.length > 80 ? '...' : ''}\n`;
187
+ output += '\n';
188
+ }
189
+ if (commands.length > 20) {
190
+ output += ` ... and ${commands.length - 20} more\n`;
191
+ }
192
+ }
193
+ }
194
+ // Project-local bundles (#1034) — surfaced as a separate section with
195
+ // [project] source label
196
+ const totalProjectLocal = projectLocal.counts.extension +
197
+ projectLocal.counts.addon +
198
+ projectLocal.counts.framework +
199
+ projectLocal.counts.plugin;
200
+ if (totalProjectLocal > 0 || projectLocal.errors.length > 0) {
201
+ output += `\nProject-local bundles (${totalProjectLocal}):\n`;
202
+ output += '─'.repeat(60) + '\n';
203
+ for (const b of projectLocal.bundles) {
204
+ output += ` ${b.id} [project] [${b.type}]\n`;
205
+ output += ` Path: ${b.localPath}\n`;
206
+ output += ` Description: ${b.manifest.description.slice(0, 80)}${b.manifest.description.length > 80 ? '...' : ''}\n\n`;
207
+ }
208
+ if (projectLocal.errors.length > 0) {
209
+ output += ` ⚠ ${projectLocal.errors.length} validation error(s) — see "aiwg doctor" for details\n`;
210
+ }
211
+ }
212
+ // Summary
213
+ const totalAgents = registry.getByType('agent').length;
214
+ const totalSkills = registry.getByType('skill').length;
215
+ const totalCommands = registry.getByType('command').length;
216
+ const total = totalAgents + totalSkills + totalCommands;
217
+ output += '\n' + '═'.repeat(60) + '\n';
218
+ output += `Total: ${total} extensions (${totalAgents} agents, ${totalSkills} skills, ${totalCommands} commands)`;
219
+ if (totalProjectLocal > 0) {
220
+ output += ` + ${totalProjectLocal} project-local`;
221
+ }
222
+ output += '\n';
223
+ if (total === 0 && totalProjectLocal === 0) {
224
+ output += '\nTip: Deploy a framework with "aiwg use sdlc" to get started\n';
225
+ }
226
+ else if (totalCommands === 0 && totalAgents > 0) {
227
+ // Skill-only model (Claude Code default): commands aren't deployed as
228
+ // slash commands; capabilities reach the agent via natural language or
229
+ // `aiwg discover` (#1228). Surface this so 0 commands doesn't look like
230
+ // a deploy failure.
231
+ output += '\nNote: 0 commands is expected on Claude Code — capabilities are reached via natural language or `aiwg discover "<phrase>"`.\n';
232
+ }
233
+ if (deployedOnly) {
234
+ const projectDir = getProjectDir(ctx, ctx.args);
235
+ const plan = await readWorkspaceSignalPlan(projectDir);
236
+ if (plan) {
237
+ output += formatDeployedWorkspaceSignalPlan(plan);
238
+ }
239
+ else {
240
+ output += '\nWorkspace skill filter: no recorded plan found.\n';
241
+ output += 'Run `aiwg use --profile <name>` to record workspace-aware include/exclude reasons.\n';
242
+ }
243
+ }
244
+ return {
245
+ exitCode: 0,
246
+ message: output,
247
+ };
248
+ },
249
+ };
250
+ //# sourceMappingURL=subcommands-list.js.map
@@ -0,0 +1,213 @@
1
+ import * as path from "node:path";
2
+ import { createScriptRunner } from "./script-runner.js";
3
+ import { getFrameworkRoot } from "../../channel/manager.mjs";
4
+ /**
5
+ * New project handler
6
+ *
7
+ * Delegates to tools/install/new-project.mjs
8
+ */
9
+ export const newProjectHandler = {
10
+ id: "new",
11
+ name: "New Project",
12
+ description: "Scaffold a new project with AIWG",
13
+ category: "project",
14
+ aliases: ["-new", "--new"],
15
+ async execute(ctx) {
16
+ const frameworkRoot = await getFrameworkRoot();
17
+ const runner = createScriptRunner(frameworkRoot);
18
+ const result = await runner.run("tools/install/new-project.mjs", ctx.args, {
19
+ cwd: ctx.cwd,
20
+ });
21
+ if (result.exitCode === 0) {
22
+ // The real scaffolder always runs in an existing target directory. Keep
23
+ // mocked/script-runner-only calls side-effect free when their synthetic
24
+ // cwd does not exist.
25
+ const { access } = await import('node:fs/promises');
26
+ const { constants } = await import('node:fs');
27
+ try {
28
+ await access(ctx.cwd, constants.W_OK);
29
+ const { ensureWorkspaceContext } = await import('../../smiths/context-pipeline/workspace-context.js');
30
+ await ensureWorkspaceContext(ctx.cwd);
31
+ }
32
+ catch (error) {
33
+ if (!['ENOENT', 'EACCES'].includes(error.code ?? ''))
34
+ throw error;
35
+ }
36
+ const { formatStarNudge } = await import("../../community/links.js");
37
+ const { markNudgeShown, shouldShowNudge } = await import("../../community/nudge-policy.js");
38
+ if (shouldShowNudge('intake')) {
39
+ const nudge = formatStarNudge();
40
+ if (nudge) {
41
+ console.log('');
42
+ console.log(nudge);
43
+ markNudgeShown('intake');
44
+ }
45
+ }
46
+ }
47
+ return result;
48
+ },
49
+ };
50
+ /**
51
+ * Install plugin handler
52
+ *
53
+ * Delegates to tools/plugin/plugin-installer-cli.mjs
54
+ */
55
+ export const installPluginHandler = {
56
+ id: "install-plugin",
57
+ name: "Install Plugin",
58
+ description: "Install a plugin from the registry",
59
+ category: "plugin",
60
+ aliases: ["-install-plugin", "--install-plugin"],
61
+ async execute(ctx) {
62
+ const frameworkRoot = await getFrameworkRoot();
63
+ const runner = createScriptRunner(frameworkRoot);
64
+ return runner.run("tools/plugin/plugin-installer-cli.mjs", ctx.args, {
65
+ cwd: ctx.cwd,
66
+ env: { AIWG_ROOT: frameworkRoot },
67
+ });
68
+ },
69
+ };
70
+ /**
71
+ * Uninstall plugin handler
72
+ *
73
+ * Delegates to tools/plugin/plugin-uninstaller-cli.mjs
74
+ */
75
+ export const uninstallPluginHandler = {
76
+ id: "uninstall-plugin",
77
+ name: "Uninstall Plugin",
78
+ description: "Uninstall a plugin",
79
+ category: "plugin",
80
+ aliases: ["-uninstall-plugin", "--uninstall-plugin"],
81
+ async execute(ctx) {
82
+ const frameworkRoot = await getFrameworkRoot();
83
+ const runner = createScriptRunner(frameworkRoot);
84
+ return runner.run("tools/plugin/plugin-uninstaller-cli.mjs", ctx.args, {
85
+ cwd: ctx.cwd,
86
+ });
87
+ },
88
+ };
89
+ /**
90
+ * Plugin status handler
91
+ *
92
+ * Delegates to tools/plugin/plugin-status-cli.mjs
93
+ */
94
+ export const pluginStatusHandler = {
95
+ id: "plugin-status",
96
+ name: "Plugin Status",
97
+ description: "Show plugin status and installation details",
98
+ category: "plugin",
99
+ aliases: ["-plugin-status", "--plugin-status"],
100
+ async execute(ctx) {
101
+ const frameworkRoot = await getFrameworkRoot();
102
+ const runner = createScriptRunner(frameworkRoot);
103
+ return runner.run("tools/plugin/plugin-status-cli.mjs", ctx.args, {
104
+ cwd: ctx.cwd,
105
+ });
106
+ },
107
+ };
108
+ /**
109
+ * Package plugin handler
110
+ *
111
+ * Delegates to tools/plugin/package-plugins.mjs
112
+ */
113
+ function packagePluginHelp() {
114
+ return {
115
+ exitCode: 0,
116
+ message: [
117
+ "aiwg package-plugin — package a project-local or built-in marketplace wrapper",
118
+ "",
119
+ "Usage:",
120
+ " aiwg package-plugin <name> [--source <path>] [--output <path>] [--provider <name>] [--clean] [--dry-run]",
121
+ " aiwg package-plugin --plugin <name> [options] # compatibility form",
122
+ "",
123
+ "Options:",
124
+ " --source <path> explicit project-local wrapper source (must stay inside the project)",
125
+ " --output <path> standalone archive output (default: dist/plugins)",
126
+ " --provider <name> claude, codex, or all for standalone wrappers; built-ins retain all formats",
127
+ " --clean clean generated plugin output before packaging",
128
+ " --dry-run, -n preview without writing",
129
+ " --help, -h show this help",
130
+ "",
131
+ "Project-local wrappers are discovered under .aiwg/plugins and packaged as deterministic archives.",
132
+ ].join("\n"),
133
+ };
134
+ }
135
+ export const packagePluginHandler = {
136
+ id: "package-plugin",
137
+ name: "Package Plugin",
138
+ description: "Package a plugin for distribution",
139
+ category: "plugin",
140
+ aliases: ["-package-plugin", "--package-plugin"],
141
+ async help() {
142
+ return packagePluginHelp();
143
+ },
144
+ async execute(ctx) {
145
+ if (ctx.args.includes("--help") || ctx.args.includes("-h")) {
146
+ return packagePluginHelp();
147
+ }
148
+ const hasExplicitPlugin = ctx.args.includes("--plugin") || ctx.args.includes("-p");
149
+ const positional = ctx.args[0] && !ctx.args[0].startsWith("-")
150
+ ? ctx.args[0]
151
+ : undefined;
152
+ if (!hasExplicitPlugin && !positional) {
153
+ return {
154
+ exitCode: 1,
155
+ message: "Error: plugin name is required.\n\nRun `aiwg package-plugin --help` for usage.",
156
+ };
157
+ }
158
+ const positionalSource = positional && (positional.includes('/') || positional.includes('\\'))
159
+ ? positional
160
+ : undefined;
161
+ const normalizedArgs = hasExplicitPlugin
162
+ ? ctx.args
163
+ : positionalSource
164
+ ? [
165
+ "--plugin", path.basename(path.resolve(ctx.cwd, positionalSource)),
166
+ "--source", positionalSource,
167
+ ...ctx.args.slice(1),
168
+ ]
169
+ : ["--plugin", positional, ...ctx.args.slice(1)];
170
+ const frameworkRoot = await getFrameworkRoot();
171
+ const runner = createScriptRunner(frameworkRoot);
172
+ return runner.run("tools/plugin/package-plugins.mjs", normalizedArgs, {
173
+ cwd: ctx.cwd,
174
+ });
175
+ },
176
+ };
177
+ /**
178
+ * Package all plugins handler
179
+ *
180
+ * Delegates to tools/plugin/package-plugins.mjs with --all flag
181
+ */
182
+ export const packageAllPluginsHandler = {
183
+ id: "package-all-plugins",
184
+ name: "Package All Plugins",
185
+ description: "Package all plugins for distribution",
186
+ category: "plugin",
187
+ aliases: ["-package-all-plugins", "--package-all-plugins"],
188
+ async execute(ctx) {
189
+ if (ctx.args.includes("--help") || ctx.args.includes("-h")) {
190
+ return {
191
+ exitCode: 0,
192
+ message: [
193
+ "aiwg package-all-plugins — package every built-in marketplace wrapper",
194
+ "",
195
+ "Usage:",
196
+ " aiwg package-all-plugins [--provider <name>] [--clean] [--dry-run]",
197
+ "",
198
+ "Options:",
199
+ " --provider <name> claude, codex, cursor, factory, openclaw, or all",
200
+ " --clean clean generated plugin output before packaging",
201
+ " --dry-run, -n preview without writing",
202
+ " --help, -h show this help",
203
+ ].join("\n"),
204
+ };
205
+ }
206
+ const frameworkRoot = await getFrameworkRoot();
207
+ const runner = createScriptRunner(frameworkRoot);
208
+ return runner.run("tools/plugin/package-plugins.mjs", ["--all", ...ctx.args], {
209
+ cwd: ctx.cwd,
210
+ });
211
+ },
212
+ };
213
+ //# sourceMappingURL=subcommands-plugins.js.map
@@ -0,0 +1,58 @@
1
+ /** Generate or deploy the canonical project quickref. */
2
+ export const quickrefHandler = {
3
+ id: 'quickref',
4
+ name: 'Project Quickref',
5
+ description: 'Generate and deploy an always-visible project quickref',
6
+ category: 'project',
7
+ aliases: [],
8
+ async help() {
9
+ return { exitCode: 0, message: 'Usage: aiwg quickref generate|deploy --project [--provider <id>] [--dry-run]', rawOutput: true };
10
+ },
11
+ async execute(ctx) {
12
+ const action = ctx.args.find(arg => !arg.startsWith('-')) ?? 'generate';
13
+ if (!ctx.args.includes('--project')) {
14
+ return { exitCode: 1, message: 'Error: project quickrefs require --project\n\nUsage: aiwg quickref generate|deploy --project [--provider <id>] [--dry-run]' };
15
+ }
16
+ if (!['generate', 'deploy'].includes(action)) {
17
+ return { exitCode: 1, message: `Error: unknown quickref action '${action}' (expected generate or deploy)` };
18
+ }
19
+ const { generateProjectQuickref, deployProjectQuickref, } = await import('../../extensions/project-quickref.js');
20
+ try {
21
+ if (action === 'generate') {
22
+ const result = await generateProjectQuickref(ctx.cwd, { dryRun: ctx.dryRun });
23
+ const verb = ctx.dryRun ? 'Would generate' : result.changed ? 'Generated' : 'Unchanged';
24
+ console.log(`${verb} ${result.skillName}`);
25
+ console.log(` Source: ${result.sourcePath}`);
26
+ console.log(` Output: ${result.outputPath}`);
27
+ for (const warning of result.warnings)
28
+ console.log(` Warning: ${warning}`);
29
+ if (ctx.dryRun) {
30
+ console.log('\n--- preview ---\n');
31
+ console.log(result.content);
32
+ }
33
+ return { exitCode: 0 };
34
+ }
35
+ const providerIndex = ctx.args.indexOf('--provider');
36
+ const explicitProvider = providerIndex >= 0 ? ctx.args[providerIndex + 1] : undefined;
37
+ const { readAiwgConfig } = await import('../../config/aiwg-config.js');
38
+ const config = await readAiwgConfig(ctx.cwd);
39
+ const providers = explicitProvider ? [explicitProvider] : (config?.providers ?? []);
40
+ if (providers.length === 0) {
41
+ return { exitCode: 1, message: 'No providers configured. Pass --provider <id> or add providers to .aiwg/aiwg.config.' };
42
+ }
43
+ for (const provider of providers) {
44
+ const result = await deployProjectQuickref(ctx.cwd, provider, { dryRun: ctx.dryRun });
45
+ const verb = ctx.dryRun ? 'Would deploy' : result.changed ? 'Deployed' : 'Unchanged';
46
+ console.log(`${verb} ${result.skillName} -> ${result.provider}: ${result.targetPath}${result.emulated ? ' (emulated skill surface)' : ''}`);
47
+ for (const stale of result.pruned) {
48
+ console.log(` ${ctx.dryRun ? 'Would prune' : 'Pruned'} stale managed quickref: ${stale}`);
49
+ }
50
+ }
51
+ return { exitCode: 0 };
52
+ }
53
+ catch (error) {
54
+ return { exitCode: 1, message: `Project quickref failed: ${error.message}` };
55
+ }
56
+ },
57
+ };
58
+ //# sourceMappingURL=subcommands-quickref.js.map
@@ -0,0 +1,113 @@
1
+ import { handlerResultFromError } from "../errors.js";
2
+ export const storageHandler = {
3
+ id: 'storage',
4
+ name: 'Storage',
5
+ description: 'Storage adapter commands (show, list-backends, test)',
6
+ category: 'utility',
7
+ aliases: [],
8
+ async execute(ctx) {
9
+ try {
10
+ const { main } = await import('../../storage/cli.js');
11
+ await main(ctx.args);
12
+ return { exitCode: 0 };
13
+ }
14
+ catch (error) {
15
+ const result = handlerResultFromError(error);
16
+ return { ...result, message: `Storage command failed: ${result.message}` };
17
+ }
18
+ },
19
+ };
20
+ /**
21
+ * RLM agentic tools handler
22
+ *
23
+ * Routes `aiwg chunk`, `aiwg fanout`, `aiwg rlm-prep`, `aiwg rlm-search`,
24
+ * and `aiwg rlm-status` to src/rlm/cli.ts.
25
+ *
26
+ * These are support tools for agentic sessions — callable by users but
27
+ * primarily used by RLM agents during recursive and fanout operations.
28
+ *
29
+ * @implements #559
30
+ */
31
+ export const rlmToolsHandler = {
32
+ id: 'rlm-tools',
33
+ name: 'RLM Tools',
34
+ description: 'Agentic support tools for RLM operations (chunk, fanout, rlm-prep, rlm-search, rlm-status)',
35
+ category: 'agentic-tools',
36
+ aliases: [],
37
+ async execute(ctx) {
38
+ try {
39
+ const { main } = await import('../../rlm/cli.js');
40
+ await main(ctx.args);
41
+ return {
42
+ exitCode: 0,
43
+ };
44
+ }
45
+ catch (error) {
46
+ const result = handlerResultFromError(error);
47
+ return { ...result, message: `RLM tools command failed: ${result.message}` };
48
+ }
49
+ },
50
+ };
51
+ // Individual handlers that delegate to rlmToolsHandler with their command prepended
52
+ export const chunkHandler = {
53
+ id: 'chunk',
54
+ name: 'Chunk',
55
+ description: 'Split a file into overlapping chunks for parallel fanout processing',
56
+ category: 'agentic-tools',
57
+ aliases: [],
58
+ async execute(ctx) {
59
+ return rlmToolsHandler.execute({ ...ctx, args: ['chunk', ...ctx.args] });
60
+ },
61
+ };
62
+ export const fanoutHandler = {
63
+ id: 'fanout',
64
+ name: 'Fanout',
65
+ description: 'Dispatch parallel subagent queries across a chunk manifest',
66
+ category: 'agentic-tools',
67
+ aliases: [],
68
+ async execute(ctx) {
69
+ return rlmToolsHandler.execute({ ...ctx, args: ['fanout', ...ctx.args] });
70
+ },
71
+ };
72
+ export const rlmPrepHandler = {
73
+ id: 'rlm-prep',
74
+ name: 'RLM Prep',
75
+ description: 'Prepare source content for RLM processing (chunk + index + manifest)',
76
+ category: 'agentic-tools',
77
+ aliases: [],
78
+ async execute(ctx) {
79
+ return rlmToolsHandler.execute({ ...ctx, args: ['rlm-prep', ...ctx.args] });
80
+ },
81
+ };
82
+ export const rlmSearchHandler = {
83
+ id: 'rlm-search',
84
+ name: 'RLM Search',
85
+ description: 'Full recursive search pipeline: decompose source, fanout query, synthesize results',
86
+ category: 'agentic-tools',
87
+ aliases: [],
88
+ async execute(ctx) {
89
+ return rlmToolsHandler.execute({ ...ctx, args: ['rlm-search', ...ctx.args] });
90
+ },
91
+ };
92
+ export const rlmStatusCliHandler = {
93
+ id: 'rlm-status',
94
+ name: 'RLM Status',
95
+ description: 'Show active RLM task tree, progress, and cost breakdown',
96
+ category: 'agentic-tools',
97
+ aliases: [],
98
+ async execute(ctx) {
99
+ return rlmToolsHandler.execute({ ...ctx, args: ['rlm-status', ...ctx.args] });
100
+ },
101
+ };
102
+ /** RLM result cache (#1203). */
103
+ export const rlmCacheHandler = {
104
+ id: 'rlm-cache',
105
+ name: 'RLM Cache',
106
+ description: 'Manage cached RLM results (list, stats, evict, clear) — keyed by index content-hash',
107
+ category: 'agentic-tools',
108
+ aliases: [],
109
+ async execute(ctx) {
110
+ return rlmToolsHandler.execute({ ...ctx, args: ['rlm-cache', ...ctx.args] });
111
+ },
112
+ };
113
+ //# sourceMappingURL=subcommands-rlm.js.map