@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.
Files changed (155) hide show
  1. package/agentic/code/providers/capability-matrix.yaml +51 -0
  2. package/agentic/code/providers/flue/README.md +62 -0
  3. package/agentic/code/providers/flue/templates/aiwg/tools.ts +120 -0
  4. package/agentic/code/providers/model-capabilities.v1.json +23 -0
  5. package/agentic/code/providers/model-catalog.v1.json +9 -0
  6. package/dist/src/artifacts/corpus-tools/resolve.js +28 -6
  7. package/dist/src/artifacts/query-engine-corpus.js +217 -0
  8. package/dist/src/artifacts/query-engine-discover-output.js +229 -0
  9. package/dist/src/artifacts/query-engine-discover.js +285 -0
  10. package/dist/src/artifacts/query-engine-entries.js +188 -0
  11. package/dist/src/artifacts/query-engine-index.js +249 -0
  12. package/dist/src/artifacts/query-engine-matching.js +143 -0
  13. package/dist/src/artifacts/query-engine-options.js +2 -0
  14. package/dist/src/artifacts/query-engine-rules.js +202 -0
  15. package/dist/src/artifacts/query-engine-scoring.js +436 -0
  16. package/dist/src/artifacts/query-engine-show-card.js +194 -0
  17. package/dist/src/artifacts/query-engine-show-load.js +211 -0
  18. package/dist/src/artifacts/query-engine-show.js +300 -0
  19. package/dist/src/artifacts/query-engine.js +7 -2576
  20. package/dist/src/cli/handlers/help.js +1 -1
  21. package/dist/src/cli/handlers/init.js +1 -0
  22. package/dist/src/cli/handlers/mc-agents.js +111 -0
  23. package/dist/src/cli/handlers/mc-args.js +54 -0
  24. package/dist/src/cli/handlers/mc-control.js +227 -0
  25. package/dist/src/cli/handlers/mc-dispatch.js +203 -0
  26. package/dist/src/cli/handlers/mc-help.js +171 -0
  27. package/dist/src/cli/handlers/mc-run.js +343 -0
  28. package/dist/src/cli/handlers/mc-session.js +138 -0
  29. package/dist/src/cli/handlers/mc-status.js +258 -0
  30. package/dist/src/cli/handlers/mc-summary.js +43 -0
  31. package/dist/src/cli/handlers/mc-types.js +3 -0
  32. package/dist/src/cli/handlers/mc-worker.js +205 -0
  33. package/dist/src/cli/handlers/mc.js +12 -1665
  34. package/dist/src/cli/handlers/models-refusal.js +13 -0
  35. package/dist/src/cli/handlers/models.js +2 -1
  36. package/dist/src/cli/handlers/remove-bundled.js +133 -0
  37. package/dist/src/cli/handlers/remove-options.js +31 -0
  38. package/dist/src/cli/handlers/remove-user.js +174 -0
  39. package/dist/src/cli/handlers/remove.js +201 -0
  40. package/dist/src/cli/handlers/subcommands-bundles.js +257 -0
  41. package/dist/src/cli/handlers/subcommands-discovery.js +165 -0
  42. package/dist/src/cli/handlers/subcommands-list-format.js +129 -0
  43. package/dist/src/cli/handlers/subcommands-list.js +250 -0
  44. package/dist/src/cli/handlers/subcommands-plugins.js +213 -0
  45. package/dist/src/cli/handlers/subcommands-quickref.js +58 -0
  46. package/dist/src/cli/handlers/subcommands-rlm.js +113 -0
  47. package/dist/src/cli/handlers/subcommands-services.js +66 -0
  48. package/dist/src/cli/handlers/subcommands-storage.js +259 -0
  49. package/dist/src/cli/handlers/subcommands.js +18 -1984
  50. package/dist/src/cli/handlers/use.js +11 -5
  51. package/dist/src/cli/scope-resolver.js +1 -142
  52. package/dist/src/cli/services/deployment-verification.js +3 -0
  53. package/dist/src/cli/user-scope-mirror.js +173 -0
  54. package/dist/src/config/dispatch-host-thresholds.js +2 -0
  55. package/dist/src/config/dispatch-thresholds-runtime.mjs +4 -0
  56. package/dist/src/config/host-resource-report.d.mts +5 -0
  57. package/dist/src/config/host-resource-report.mjs +36 -6
  58. package/dist/src/config/host-resource-runtime.d.mts +3 -0
  59. package/dist/src/config/host-resource-runtime.mjs +9 -6
  60. package/dist/src/decision/ensemble-study/artifacts.js +7 -0
  61. package/dist/src/decision/ensemble-study/gate-policy.js +58 -0
  62. package/dist/src/decision/ensemble-study/gates.js +78 -0
  63. package/dist/src/decision/ensemble-study/protocol.js +18 -21
  64. package/dist/src/decision/ensemble-study/score.js +3 -2
  65. package/dist/src/decision/ensemble-study/statistics.js +7 -26
  66. package/dist/src/decision/sensitivity/comparative-gates.js +135 -0
  67. package/dist/src/decision/sensitivity/comparative.js +18 -41
  68. package/dist/src/extensions/claude-hooks-installer.js +18 -0
  69. package/dist/src/gates/evaluate.js +2 -358
  70. package/dist/src/gates/observations.js +363 -0
  71. package/dist/src/gates/pack-composition.js +270 -0
  72. package/dist/src/gates/pack-tightening.js +197 -0
  73. package/dist/src/gates/pack-validation.js +262 -0
  74. package/dist/src/gates/registry-error.js +5 -0
  75. package/dist/src/gates/registry.js +13 -685
  76. package/dist/src/mcp/json-document.mjs +29 -0
  77. package/dist/src/mcp/muse-native-config.mjs +1 -28
  78. package/dist/src/memory/provider-memory-adapter.js +1 -0
  79. package/dist/src/mission-protocol/worker-review-gate.js +7 -0
  80. package/dist/src/models/model-capabilities.v1.json +23 -0
  81. package/dist/src/models/model-catalog.v1.json +9 -0
  82. package/dist/src/models/policy-resources.js +1 -1
  83. package/dist/src/models/worker-plan.js +5 -5
  84. package/dist/src/plugin/command-ownership.js +34 -0
  85. package/dist/src/plugin/skill-command-frontmatter.js +197 -0
  86. package/dist/src/plugin/skill-command-translator.js +6 -232
  87. package/dist/src/providers/capability-matrix.yaml +51 -0
  88. package/dist/src/providers/context-output-ownership.js +26 -0
  89. package/dist/src/providers/deployment-ownership.d.mts +20 -0
  90. package/dist/src/providers/deployment-ownership.mjs +236 -0
  91. package/dist/src/providers/deployment-removal.js +222 -0
  92. package/dist/src/providers/provider-context-contracts.js +8 -0
  93. package/dist/src/providers/provider-definition-schema.js +1 -0
  94. package/dist/src/providers/provider-definitions.js +1 -0
  95. package/dist/src/providers/provider-seeds-3.js +18 -0
  96. package/dist/src/providers/removal-transaction.js +86 -0
  97. package/dist/src/providers/settings-document.d.mts +3 -0
  98. package/dist/src/providers/settings-document.mjs +47 -0
  99. package/dist/src/providers/settings-removal.js +190 -0
  100. package/dist/src/providers/skill-ownership.d.mts +20 -2
  101. package/dist/src/providers/skill-ownership.mjs +12 -4
  102. package/dist/src/providers/transformation-receipt-integration.js +15 -271
  103. package/dist/src/providers/transformation-receipt-outputs.js +99 -0
  104. package/dist/src/providers/transformation-receipt-source.js +194 -0
  105. package/dist/src/research/identity.js +8 -2
  106. package/dist/src/research/reference-match.js +66 -8
  107. package/dist/src/rules/activation.mjs +15 -6
  108. package/dist/src/rules/core-startup.mjs +2 -2
  109. package/dist/src/serve/mission-conductor.js +4 -0
  110. package/dist/src/serve/mission-summary.js +56 -0
  111. package/dist/src/skills/deployment-ownership.js +2 -2
  112. package/dist/src/skills/deployment-policy.js +9 -0
  113. package/dist/src/smiths/context-pipeline/aiwg-md.js +23 -0
  114. package/dist/src/smiths/context-pipeline/context-file-safety.js +3 -0
  115. package/dist/src/smiths/context-pipeline/flue-context.js +25 -0
  116. package/dist/src/smiths/context-pipeline/generator.js +7 -2
  117. package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +9 -7
  118. package/dist/src/smiths/hook-bridge/index.js +9 -0
  119. package/package.json +5 -1
  120. package/schemas/decision/D17StudyProtocol.v1.schema.json +39 -67
  121. package/tools/agents/deploy-agents.mjs +21 -680
  122. package/tools/agents/deploy-command-mirrors.mjs +229 -0
  123. package/tools/agents/deploy-options.mjs +267 -0
  124. package/tools/agents/deploy-support.mjs +165 -0
  125. package/tools/agents/providers/base-addon-discovery.mjs +139 -0
  126. package/tools/agents/providers/base-behaviors.mjs +168 -0
  127. package/tools/agents/providers/base-context.mjs +205 -0
  128. package/tools/agents/providers/base-contract.mjs +116 -0
  129. package/tools/agents/providers/base-files.mjs +252 -0
  130. package/tools/agents/providers/base-flat-artifacts.mjs +233 -0
  131. package/tools/agents/providers/base-framework-discovery.mjs +309 -0
  132. package/tools/agents/providers/base-frontmatter.mjs +196 -0
  133. package/tools/agents/providers/base-inventory.mjs +269 -0
  134. package/tools/agents/providers/base-kernel-skills.mjs +354 -0
  135. package/tools/agents/providers/base-migrations.mjs +258 -0
  136. package/tools/agents/providers/base-models-platforms.mjs +273 -0
  137. package/tools/agents/providers/base-rule-index.mjs +450 -0
  138. package/tools/agents/providers/base-runtime.mjs +60 -0
  139. package/tools/agents/providers/base-skill-copy.mjs +273 -0
  140. package/tools/agents/providers/base.mjs +16 -3364
  141. package/tools/agents/providers/claude-post-deploy.mjs +10 -2
  142. package/tools/agents/providers/flue-project.mjs +79 -0
  143. package/tools/agents/providers/flue-specialists.mjs +64 -0
  144. package/tools/agents/providers/flue.mjs +50 -0
  145. package/tools/agents/providers/hermes-startup.mjs +0 -5
  146. package/tools/agents/providers/muse.mjs +7 -2
  147. package/tools/agents/providers/rule-delivery-surface.mjs +33 -5
  148. package/tools/agents/providers/rule-deployment-commit.mjs +19 -15
  149. package/tools/agents/providers/rule-deployment-prepare.mjs +13 -3
  150. package/tools/agents/providers/rule-projection.mjs +3 -0
  151. package/tools/agents/providers/rule-startup.mjs +3 -3
  152. package/tools/agents/use-rule-selection.mjs +17 -0
  153. package/tools/ralph-external/lib/worker-invocation-processes.mjs +4 -2
  154. package/tools/ralph-external/lib/worker-termination.mjs +15 -8
  155. package/vscode-extension/schemas/aiwg.config.v1.json +2 -4
@@ -0,0 +1,257 @@
1
+ import { getFrameworkRoot } from "../../channel/manager.mjs";
2
+ /**
3
+ * Promote handler — graduate a project-local bundle to upstream or to a
4
+ * private corpus path. Implements the design at
5
+ * @.aiwg/architecture/design-doctor-log-promote.md (#1049).
6
+ *
7
+ * Usage:
8
+ * aiwg promote <name> # default: --to upstream
9
+ * aiwg promote <name> --to upstream
10
+ * aiwg promote <name> --to corpus <path>
11
+ * aiwg promote <name> --dry-run
12
+ * aiwg promote <name> --cleanup
13
+ * aiwg promote <name> --force
14
+ *
15
+ * @implements #1037
16
+ */
17
+ export const promoteHandler = {
18
+ id: 'promote',
19
+ name: 'Promote',
20
+ description: 'Graduate a project-local bundle to upstream or a corpus path',
21
+ category: 'framework',
22
+ aliases: ['-promote', '--promote', 'graduate'],
23
+ async execute(ctx) {
24
+ const args = ctx.args;
25
+ const positional = args.find(a => !a.startsWith('-'));
26
+ if (!positional) {
27
+ return { exitCode: 1, message: 'Error: bundle name required\n\nUsage: aiwg promote <name> [--to upstream|corpus <path>] [--dry-run] [--cleanup] [--force]' };
28
+ }
29
+ const toIdx = args.findIndex(a => a === '--to');
30
+ const toValue = toIdx >= 0 ? args[toIdx + 1] : 'upstream';
31
+ let corpusPath;
32
+ if (toValue === 'corpus') {
33
+ // The argument *after* "corpus" is the path
34
+ corpusPath = args[toIdx + 2];
35
+ if (!corpusPath || corpusPath.startsWith('-')) {
36
+ return { exitCode: 1, message: 'Error: --to corpus requires a path argument' };
37
+ }
38
+ }
39
+ else if (toValue !== 'upstream') {
40
+ return { exitCode: 1, message: `Error: --to must be 'upstream' or 'corpus' (got '${toValue}')` };
41
+ }
42
+ const dryRun = args.includes('--dry-run');
43
+ const cleanup = args.includes('--cleanup');
44
+ const force = args.includes('--force');
45
+ try {
46
+ const { readAiwgConfig, writeAiwgConfig, getProjectDir } = await import('../../config/aiwg-config.js');
47
+ const { promoteProjectLocalBundle } = await import('../../extensions/project-local-promote.js');
48
+ const projectDir = getProjectDir({ cwd: ctx.cwd }, args);
49
+ const config = await readAiwgConfig(projectDir);
50
+ if (!config) {
51
+ return { exitCode: 1, message: 'Error: no .aiwg/aiwg.config found — run `aiwg init` first' };
52
+ }
53
+ const fr = await getFrameworkRoot();
54
+ const result = await promoteProjectLocalBundle(config, projectDir, positional, {
55
+ to: toValue,
56
+ corpusPath,
57
+ dryRun,
58
+ cleanup,
59
+ force,
60
+ frameworkRoot: fr,
61
+ });
62
+ if (!result.ok) {
63
+ return { exitCode: 1, message: `Error: ${result.message ?? result.failureReason}` };
64
+ }
65
+ if (dryRun && result.plan) {
66
+ console.log('[dry-run] Would copy:');
67
+ console.log(` ${result.plan.source} → ${result.plan.destination}`);
68
+ console.log(` Files: ${result.plan.files.length}, ${result.plan.totalBytes} bytes`);
69
+ console.log(' Pre-flight: ✓ manifest valid ✓ destination clean');
70
+ console.log(' Hash verification: skipped (dry-run)');
71
+ console.log(` Registry update: source: project-local → ${toValue === 'upstream' ? 'bundled' : 'corpus'}`);
72
+ console.log(` Cleanup: ${cleanup ? 'will remove .aiwg source after copy' : 'skipped (--cleanup not set)'}`);
73
+ return { exitCode: 0 };
74
+ }
75
+ await writeAiwgConfig(projectDir, config);
76
+ console.log(`✓ Promoted '${positional}' → ${result.plan?.destination}`);
77
+ if (cleanup) {
78
+ console.log(' Source removed from .aiwg/');
79
+ try {
80
+ const { deployProjectQuickref, generateProjectQuickref, hasProjectQuickref } = await import('../../extensions/project-quickref.js');
81
+ if (await hasProjectQuickref(projectDir)) {
82
+ if (config.providers.length > 0) {
83
+ for (const provider of config.providers)
84
+ await deployProjectQuickref(projectDir, provider);
85
+ console.log(` Managed project quickref refreshed for: ${config.providers.join(', ')}.`);
86
+ }
87
+ else {
88
+ await generateProjectQuickref(projectDir);
89
+ console.log(' Managed project quickref generated; no providers are configured for deployment.');
90
+ }
91
+ }
92
+ else {
93
+ console.log(' Managed project quickref is now empty; run `aiwg doctor --project-local` to inspect deployed stale copies.');
94
+ }
95
+ }
96
+ catch (error) {
97
+ console.log(` Managed project quickref refresh failed: ${error.message}`);
98
+ }
99
+ }
100
+ return { exitCode: 0 };
101
+ }
102
+ catch (err) {
103
+ const msg = err instanceof Error ? err.message : String(err);
104
+ return { exitCode: 1, message: `promote failed: ${msg}` };
105
+ }
106
+ },
107
+ };
108
+ /**
109
+ * New bundle handler — scaffolds a project-local bundle under the configured
110
+ * AIWG artifact root with a valid manifest, starter artifact, and a
111
+ * README that includes the identical-form portability reminder.
112
+ *
113
+ * Usage:
114
+ * aiwg new-bundle <name> # default: --type extension --starter skill
115
+ * aiwg new-bundle <name> --type addon
116
+ * aiwg new-bundle <name> --type framework --starter minimal
117
+ * aiwg new-bundle <name> --starter rule --description "Custom rule"
118
+ *
119
+ * @implements #1050
120
+ */
121
+ export const newBundleHandler = {
122
+ id: 'new-bundle',
123
+ name: 'New Bundle',
124
+ description: 'Scaffold a project-local bundle under the configured AIWG artifact root',
125
+ category: 'scaffolding',
126
+ aliases: ['new-extension', 'new-addon', 'new-framework', 'new-plugin', 'new-provider'],
127
+ async execute(ctx) {
128
+ const args = ctx.args;
129
+ const positional = args.find(a => !a.startsWith('-'));
130
+ if (!positional) {
131
+ return {
132
+ exitCode: 1,
133
+ message: 'Error: bundle name required\n\nUsage: aiwg new-bundle <name> [--type extension|addon|framework|plugin|provider] [--starter skill|rule|agent|minimal] [--description "..."]',
134
+ };
135
+ }
136
+ // Type can be inferred from the alias used to invoke (new-extension etc.)
137
+ const aliasMap = {
138
+ 'new-extension': 'extension',
139
+ 'new-addon': 'addon',
140
+ 'new-framework': 'framework',
141
+ 'new-plugin': 'plugin',
142
+ 'new-provider': 'provider',
143
+ };
144
+ const invoked = ctx.rawArgs[0] ?? '';
145
+ const aliasType = aliasMap[invoked];
146
+ const typeIdx = args.findIndex(a => a === '--type');
147
+ const typeFlag = typeIdx >= 0 ? args[typeIdx + 1] : undefined;
148
+ const type = (typeFlag ?? aliasType ?? 'extension');
149
+ if (!['extension', 'addon', 'framework', 'plugin', 'provider'].includes(type)) {
150
+ return { exitCode: 1, message: `Error: --type must be one of extension|addon|framework|plugin|provider (got '${type}')` };
151
+ }
152
+ const starterIdx = args.findIndex(a => a === '--starter');
153
+ const starter = starterIdx >= 0 ? args[starterIdx + 1] : undefined;
154
+ if (starter && !['skill', 'rule', 'agent', 'minimal'].includes(starter)) {
155
+ return { exitCode: 1, message: `Error: --starter must be one of skill|rule|agent|minimal (got '${starter}')` };
156
+ }
157
+ const descIdx = args.findIndex(a => a === '--description');
158
+ const description = descIdx >= 0 ? args[descIdx + 1] : undefined;
159
+ const dryRun = args.includes('--dry-run');
160
+ const { scaffoldProjectLocalBundle } = await import('../../extensions/project-local-scaffold.js');
161
+ try {
162
+ const result = await scaffoldProjectLocalBundle({
163
+ type,
164
+ name: positional,
165
+ description,
166
+ starter,
167
+ projectDir: ctx.cwd,
168
+ dryRun,
169
+ });
170
+ if (result.alreadyExists) {
171
+ return {
172
+ exitCode: 1,
173
+ message: `Refused: bundle already exists at ${result.bundlePath}. Remove it first or pick a different name.`,
174
+ };
175
+ }
176
+ if (dryRun) {
177
+ console.log(`[DRY RUN] Would scaffold project-local ${type} '${positional}' at ${result.bundlePath}`);
178
+ console.log(' Files that would be created:');
179
+ for (const f of result.filesCreated)
180
+ console.log(` + ${f}`);
181
+ console.log('');
182
+ console.log('No files written. Re-run without --dry-run to create.');
183
+ return { exitCode: 0 };
184
+ }
185
+ console.log(`✓ Scaffolded project-local ${type} '${positional}' at ${result.bundlePath}`);
186
+ console.log(' Files created:');
187
+ for (const f of result.filesCreated)
188
+ console.log(` + ${f}`);
189
+ // #1085 — when the project blanket-ignores .aiwg/, the new bundle's
190
+ // source would be silently dropped from version control. Detect and
191
+ // self-heal idempotently.
192
+ try {
193
+ const { appendAiwgSourceTrackBlock } = await import('../../extensions/project-local-gitignore.js');
194
+ const ig = await appendAiwgSourceTrackBlock(ctx.cwd);
195
+ if (ig.added) {
196
+ console.log('');
197
+ console.log(` → ${ig.reason}`);
198
+ console.log(' .aiwg/{addons,extensions,frameworks,plugins,providers}/ now tracked by git.');
199
+ console.log(' Generated state under .aiwg/ (working/, ralph/, research/, ...) stays ignored.');
200
+ }
201
+ }
202
+ catch {
203
+ // .gitignore management is best-effort; don't fail the scaffold
204
+ }
205
+ try {
206
+ const { generateProjectQuickref } = await import('../../extensions/project-quickref.js');
207
+ await generateProjectQuickref(ctx.cwd);
208
+ console.log(' → Managed project quickref refreshed from discovered capabilities.');
209
+ }
210
+ catch (error) {
211
+ console.log(` → Managed project quickref refresh deferred: ${error.message}`);
212
+ }
213
+ // #1235 / #1758 — auto-rebuild the project graph and refresh the
214
+ // Fortemi Core static cache so the new bundle is immediately
215
+ // discoverable via top-level `aiwg discover` / `aiwg show`.
216
+ // Best-effort: don't fail the scaffold if indexing hiccups.
217
+ let indexedOk = false;
218
+ let fortemiSyncedOk = false;
219
+ try {
220
+ const { buildIndex } = await import('../../artifacts/index-builder.js');
221
+ await buildIndex(ctx.cwd, { graph: 'project', force: false, explicit: true });
222
+ indexedOk = true;
223
+ const { syncFortemiCoreIndex } = await import('../../artifacts/fortemi-core-sync.js');
224
+ syncFortemiCoreIndex(ctx.cwd, { graph: 'project' });
225
+ fortemiSyncedOk = true;
226
+ }
227
+ catch {
228
+ // ignore — surface via next-steps hint instead
229
+ }
230
+ console.log('');
231
+ console.log('Next steps:');
232
+ console.log(` 1. Edit manifest.json (description, version, keywords)`);
233
+ console.log(` 2. Customize the starter artifact under ${result.bundlePath}/`);
234
+ if (indexedOk && fortemiSyncedOk) {
235
+ console.log(` 3. Discoverable now via: aiwg discover "${positional}"`);
236
+ }
237
+ else if (indexedOk) {
238
+ console.log(` 3. Sync project search cache: aiwg index sync --graph project`);
239
+ console.log(` then: aiwg discover "${positional}"`);
240
+ }
241
+ else {
242
+ console.log(` 3. Rebuild project index: aiwg index build --graph project`);
243
+ console.log(` then sync search cache: aiwg index sync --graph project`);
244
+ console.log(` then: aiwg discover "${positional}"`);
245
+ }
246
+ console.log(` 4. Deploy: aiwg use ${positional}`);
247
+ console.log(` 5. Inspect: aiwg doctor --project-local`);
248
+ console.log(` 6. When mature, promote: aiwg promote ${positional}`);
249
+ return { exitCode: 0 };
250
+ }
251
+ catch (err) {
252
+ const msg = err instanceof Error ? err.message : String(err);
253
+ return { exitCode: 1, message: `Error: ${msg}` };
254
+ }
255
+ },
256
+ };
257
+ //# sourceMappingURL=subcommands-bundles.js.map
@@ -0,0 +1,165 @@
1
+ import { handlerResultFromError } from "../errors.js";
2
+ export const indexHandler = {
3
+ id: "index",
4
+ name: "Artifact Index",
5
+ description: "Artifact index commands (build, query, deps, stats)",
6
+ category: "index",
7
+ aliases: [],
8
+ async help() {
9
+ const { printIndexUsage } = await import("../../artifacts/cli.js");
10
+ printIndexUsage();
11
+ return { exitCode: 0 };
12
+ },
13
+ async execute(ctx) {
14
+ try {
15
+ const { main } = await import("../../artifacts/cli.js");
16
+ await main(ctx.args);
17
+ return {
18
+ exitCode: Number(process.exitCode ?? 0),
19
+ };
20
+ }
21
+ catch (error) {
22
+ const result = handlerResultFromError(error);
23
+ return { ...result, message: `Index command failed: ${result.message}` };
24
+ }
25
+ },
26
+ };
27
+ /**
28
+ * `aiwg corpus` — research-corpus tools (radar/freshness subsystem, #1498).
29
+ * Delegates to the corpus-tools router, mirroring indexHandler.
30
+ */
31
+ export const corpusHandler = {
32
+ id: "corpus",
33
+ name: "Research Corpus Tools",
34
+ description: "Research-corpus tools (radar-init, radar-status, radar-report)",
35
+ category: "index",
36
+ aliases: [],
37
+ async help() {
38
+ const { corpusMain } = await import("../../artifacts/corpus-tools/cli.js");
39
+ await corpusMain(["--help"]);
40
+ return { exitCode: 0 };
41
+ },
42
+ async execute(ctx) {
43
+ try {
44
+ const { corpusMain } = await import("../../artifacts/corpus-tools/cli.js");
45
+ await corpusMain(ctx.args, ctx.cwd);
46
+ return { exitCode: 0 };
47
+ }
48
+ catch (error) {
49
+ const result = handlerResultFromError(error);
50
+ return { ...result, message: `Corpus command failed: ${result.message}` };
51
+ }
52
+ },
53
+ };
54
+ /**
55
+ * Discovery command handler — first-class top-level verb (#1212).
56
+ *
57
+ * Forwards to the same implementation as `aiwg index discover` but
58
+ * exposes discovery as its own command so agents don't conflate it
59
+ * with the project's general-purpose artifact graph indices.
60
+ *
61
+ * aiwg discover "<phrase>" [--limit N] [--type skill,agent,...] [--json]
62
+ * [--resource-source local|web|auto] [--aiwg-version <version|range|digest|channel>] [--offline]
63
+ */
64
+ export const discoverHandler = {
65
+ id: "discover",
66
+ name: "Discover",
67
+ description: "Find AIWG operational assets by capability — index-driven on-demand discovery",
68
+ category: "index",
69
+ aliases: [],
70
+ async execute(ctx) {
71
+ try {
72
+ // Delegate to the same handler `aiwg index discover` uses, by
73
+ // prepending the `discover` subcommand and reusing the artifacts
74
+ // CLI router. This keeps a single implementation path.
75
+ const { main } = await import("../../artifacts/cli.js");
76
+ await main(["discover", ...ctx.args]);
77
+ return { exitCode: 0 };
78
+ }
79
+ catch (error) {
80
+ const result = handlerResultFromError(error);
81
+ return { ...result, message: `Discover command failed: ${result.message}` };
82
+ }
83
+ },
84
+ };
85
+ /**
86
+ * Features command handler — manage AIWG's optional runtime features (#1219).
87
+ *
88
+ * Subcommands: status / info / install / remove. Native feature installs use
89
+ * a user-owned package root with explicit package-level script approval.
90
+ */
91
+ export const featuresHandler = {
92
+ id: "features",
93
+ name: "Features",
94
+ description: "List, inspect, and install AIWG's optional runtime features",
95
+ category: "maintenance",
96
+ aliases: [],
97
+ async execute(ctx) {
98
+ try {
99
+ const { main } = await import("../../features/cli.js");
100
+ await main(ctx.args);
101
+ return { exitCode: 0 };
102
+ }
103
+ catch (error) {
104
+ const result = handlerResultFromError(error);
105
+ return { ...result, message: `Features command failed: ${result.message}` };
106
+ }
107
+ },
108
+ };
109
+ /**
110
+ * Show command handler — fetch the full text of a specific artifact (#1218).
111
+ *
112
+ * Forwards to the same implementation as `aiwg index show`. Companion to
113
+ * `aiwg discover`: where discover ranks candidates, show fetches the body
114
+ * so consumers don't need to navigate AIWG's storage paths themselves.
115
+ *
116
+ * aiwg show <name> [--type skill,agent,...] [--json] [--first]
117
+ * [--resource-source local|web|auto] [--aiwg-version <version|range|digest|channel>] [--offline]
118
+ */
119
+ export const showHandler = {
120
+ id: "show",
121
+ name: "Show",
122
+ description: "Show an AIWG metadata card; --section or --body fetches content",
123
+ category: "index",
124
+ aliases: [],
125
+ async execute(ctx) {
126
+ try {
127
+ const { main } = await import("../../artifacts/cli.js");
128
+ await main(["show", ...ctx.args]);
129
+ return { exitCode: 0 };
130
+ }
131
+ catch (error) {
132
+ const result = handlerResultFromError(error);
133
+ return { ...result, message: `Show command failed: ${result.message}` };
134
+ }
135
+ },
136
+ };
137
+ /**
138
+ * Skills command handler
139
+ *
140
+ * Dynamically imports and delegates to src/skills/cli.ts.
141
+ * Handles subcommands: search, info, list, install, publish
142
+ *
143
+ * @implements #539
144
+ */
145
+ export const skillsHandler = {
146
+ id: "skills",
147
+ name: "Skills Registry",
148
+ description: "Skill commands (search, info, list, install, publish)",
149
+ category: "catalog",
150
+ aliases: [],
151
+ async execute(ctx) {
152
+ try {
153
+ const { main } = await import("../../skills/cli.js");
154
+ await main(ctx.args);
155
+ return {
156
+ exitCode: 0,
157
+ };
158
+ }
159
+ catch (error) {
160
+ const result = handlerResultFromError(error);
161
+ return { ...result, message: `Skills command failed: ${result.message}` };
162
+ }
163
+ },
164
+ };
165
+ //# sourceMappingURL=subcommands-discovery.js.map
@@ -0,0 +1,129 @@
1
+ import { buildUpstreamRegistry } from "../../extensions/upstream-registry.js";
2
+ import { resolveShadows } from "../../extensions/shadow-resolver.js";
3
+ /**
4
+ * Format `aiwg list --project-local` output: only project-local bundles, with
5
+ * per-type breakdown and any validation errors surfaced. (#1034)
6
+ */
7
+ export function formatProjectLocalOnly(result) {
8
+ let output = '';
9
+ const total = result.counts.extension +
10
+ result.counts.addon +
11
+ result.counts.framework +
12
+ result.counts.plugin;
13
+ if (total === 0 && result.errors.length === 0) {
14
+ output += '\nNo project-local bundles found.\n';
15
+ 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';
16
+ return { exitCode: 0, message: output };
17
+ }
18
+ output += `\nProject-local bundles (${total}):\n`;
19
+ output += '─'.repeat(60) + '\n';
20
+ for (const b of result.bundles) {
21
+ output += ` ${b.id} [project] [${b.type}] v${b.manifest.version}\n`;
22
+ output += ` Path: ${b.localPath}\n`;
23
+ output += ` Description: ${b.manifest.description.slice(0, 80)}${b.manifest.description.length > 80 ? '...' : ''}\n\n`;
24
+ }
25
+ if (result.errors.length > 0) {
26
+ output += '\nValidation errors:\n';
27
+ output += '─'.repeat(60) + '\n';
28
+ for (const e of result.errors.slice(0, 10)) {
29
+ output += ` [${e.severity}] ${e.path}\n`;
30
+ output += ` ${e.field}: expected ${e.expected}, got ${e.actual}\n`;
31
+ if (e.hint)
32
+ output += ` hint: ${e.hint}\n`;
33
+ }
34
+ if (result.errors.length > 10) {
35
+ output += ` ... and ${result.errors.length - 10} more\n`;
36
+ }
37
+ }
38
+ output += '\n' + '═'.repeat(60) + '\n';
39
+ output += `Counts by type: extension=${result.counts.extension} addon=${result.counts.addon} framework=${result.counts.framework} plugin=${result.counts.plugin}\n`;
40
+ return { exitCode: 0, message: output };
41
+ }
42
+ /**
43
+ * Format `aiwg list --shadows` output: only artifacts that currently shadow
44
+ * an upstream artifact, with safety-critical and override status. (#1036)
45
+ */
46
+ export async function formatShadowsOnly(projectLocal) {
47
+ let output = '';
48
+ if (projectLocal.bundles.length === 0) {
49
+ output += '\nNo project-local bundles — no shadows possible.\n';
50
+ return { exitCode: 0, message: output };
51
+ }
52
+ const { getFrameworkRoot: gfr } = await import('../../channel/manager.mjs');
53
+ const frameworkRoot = await gfr();
54
+ const upstream = await buildUpstreamRegistry({ frameworkRoot });
55
+ const result = await resolveShadows(projectLocal.bundles, upstream);
56
+ if (result.shadows.length === 0) {
57
+ output += '\nNo active shadows.\n';
58
+ output += '\nProject-local bundles deploy alongside upstream without collision.\n';
59
+ return { exitCode: 0, message: output };
60
+ }
61
+ output += `\nActive shadows (${result.shadows.length}):\n`;
62
+ output += '─'.repeat(60) + '\n';
63
+ for (const r of result.shadows) {
64
+ const sc = r.upstream?.safetyCritical ? ' [SAFETY-CRITICAL]' : '';
65
+ output += ` ${r.artifactType}/${r.artifactId}${sc}\n`;
66
+ output += ` Bundle: ${r.bundleId} (${r.bundleLocalPath})\n`;
67
+ output += ` Project-local: ${r.artifactSourcePath}\n`;
68
+ if (r.upstream) {
69
+ output += ` Shadows ${r.upstream.source}: ${r.upstream.sourcePath}\n`;
70
+ }
71
+ output += ` Verdict: ${r.verdict}\n\n`;
72
+ }
73
+ if (result.blockedBundleIds.size > 0) {
74
+ output += `\n⚠ ${result.blockedBundleIds.size} bundle(s) blocked from deployment due to unsafe shadows.\n`;
75
+ }
76
+ return { exitCode: 0, message: output };
77
+ }
78
+ /**
79
+ * #1156 Phase 1 — `--scope user` detection. Mirrors `detectScope()` from
80
+ * scope-resolver but tolerates the absence of the flag (no throw on absent).
81
+ * Returns true when args contain `--scope user`.
82
+ */
83
+ export function isScopeUser(args) {
84
+ const idx = args.findIndex((a) => a === '--scope');
85
+ if (idx === -1)
86
+ return false;
87
+ return args[idx + 1] === 'user';
88
+ }
89
+ /**
90
+ * #1156 Phase 1 — Format the per-user registry (~/.aiwg/installed.json) as a
91
+ * human-readable inventory. Used by `aiwg list --scope user` / `aiwg list
92
+ * --user`. Independent of any project — works from any cwd.
93
+ */
94
+ export async function formatUserScopeRegistry() {
95
+ const { readUserRegistry, userRegistryPath } = await import('../../config/user-registry.js');
96
+ const registry = await readUserRegistry();
97
+ const frameworks = Object.entries(registry.installed);
98
+ let output = '';
99
+ if (frameworks.length === 0) {
100
+ output += '\nNo frameworks deployed at user scope.\n';
101
+ output += `\nRegistry path: ${userRegistryPath()}\n`;
102
+ output += '\nTip: run `aiwg use <framework> --provider <p> --scope user` to install at user scope.\n';
103
+ return { exitCode: 0, message: output };
104
+ }
105
+ output += `\nUser-scope deployments (${frameworks.length}):\n`;
106
+ output += '─'.repeat(60) + '\n';
107
+ for (const [name, entry] of frameworks) {
108
+ output += ` ${name} v${entry.version} [${entry.source}]\n`;
109
+ output += ` Installed: ${entry.installedAt}\n`;
110
+ const providers = Object.entries(entry.deployedTo);
111
+ for (const [provider, counts] of providers) {
112
+ const parts = [];
113
+ if (counts.agents > 0)
114
+ parts.push(`${counts.agents} agents`);
115
+ if (counts.commands > 0)
116
+ parts.push(`${counts.commands} commands`);
117
+ if (counts.skills > 0)
118
+ parts.push(`${counts.skills} skills`);
119
+ if (counts.rules > 0)
120
+ parts.push(`${counts.rules} rules`);
121
+ output += ` ${provider}: ${parts.length > 0 ? parts.join(', ') : '(empty)'}\n`;
122
+ }
123
+ output += '\n';
124
+ }
125
+ output += '═'.repeat(60) + '\n';
126
+ output += `Registry path: ${userRegistryPath()}\n`;
127
+ return { exitCode: 0, message: output };
128
+ }
129
+ //# sourceMappingURL=subcommands-list-format.js.map