@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,273 @@
1
+ // Shared provider skill copy utilities.
2
+ import { canDeploySkill, extractFrameworkSlug, fs, path, pruneRecordedSkillFiles, releaseSkillOwnership } from './base-runtime.mjs';
3
+ import { contentHash, ensureDir, readSidecarManifest, resolveFrameworkWorkspaceRoot, writeSidecarManifest } from './base-files.mjs';
4
+ import { PROVIDER_TO_PLATFORM, injectPlatformInContent, skillMatchesProvider } from './base-models-platforms.mjs';
5
+ import { injectBoundRules } from './base-contract.mjs';
6
+ import { getFrameworksForMode } from './base-framework-discovery.mjs';
7
+
8
+
9
+ /** Source-scoped cleanup also works when a removed standard skill is absent from this deploy's input. */
10
+ export function pruneMissingStandardSkills(destDir, opts) {
11
+ if (!destDir || !opts?.srcRoot || opts.dryRun || !fs.existsSync(destDir)) return 0;
12
+ const sourceRoot = path.resolve(opts.srcRoot);
13
+ let pruned = 0;
14
+ for (const entry of fs.readdirSync(destDir, { withFileTypes: true })) {
15
+ if (!entry.isDirectory()) continue;
16
+ const skillDir = path.join(destDir, entry.name);
17
+ const receipt = readSidecarManifest(skillDir);
18
+ if (!receipt?.skillSource || !receipt.managed?.['SKILL.md']) continue;
19
+ const relative = path.relative(sourceRoot, receipt.skillSource);
20
+ if (!relative || relative.startsWith('..') || path.isAbsolute(relative)) continue;
21
+ try {
22
+ fs.statSync(path.join(receipt.skillSource, 'SKILL.md'));
23
+ continue;
24
+ } catch (error) {
25
+ if (error.code !== 'ENOENT' && error.code !== 'ENOTDIR') continue;
26
+ }
27
+ if (releaseSkillOwnership(skillDir, {
28
+ frameworkSlug: receipt.managed['SKILL.md'].frameworkSlug,
29
+ skillSource: receipt.skillSource,
30
+ }, opts)) pruned++;
31
+ }
32
+ return pruned;
33
+ }
34
+
35
+
36
+ /**
37
+ * Deploy a skill directory (copy recursively).
38
+ *
39
+ * Platform handling (controlled by opts.provider):
40
+ * - If the skill's SKILL.md has platforms: [all] → deploy to all, inject [provider] in deployed copy
41
+ * - If no platforms: field → deploy to all, inject [provider] in deployed copy
42
+ * - If explicit restriction list → only deploy if opts.provider is in the list; keep list in deployed copy
43
+ */
44
+ export function deploySkillDir(skillDir, destDir, opts) {
45
+ const { force = false, dryRun = false, provider, transformSkillMd } = opts;
46
+ const verbose = opts.verbose === true;
47
+ const skillName = opts.skillName || path.basename(skillDir);
48
+
49
+ // Check SKILL.md for explicit platform restriction before deploying anything
50
+ const skillMdPath = path.join(skillDir, 'SKILL.md');
51
+ if (provider && fs.existsSync(skillMdPath)) {
52
+ const skillContent = fs.readFileSync(skillMdPath, 'utf8');
53
+ if (!skillMatchesProvider(skillContent, provider)) {
54
+ if (verbose) console.log(`skip (platform restricted): ${skillName}`);
55
+ return;
56
+ }
57
+ }
58
+
59
+ const destSkillDir = path.join(destDir, skillName);
60
+ const previous = readSidecarManifest(destSkillDir);
61
+ const frameworkSlug = extractFrameworkSlug(opts.logicalInputPath?.(skillMdPath) || skillMdPath);
62
+ if (!canDeploySkill(previous, skillDir, opts)) return false;
63
+ const managed = {};
64
+ if (!dryRun) ensureDir(destSkillDir);
65
+
66
+ function copyRecursive(src, dest) {
67
+ const entries = fs.readdirSync(src, { withFileTypes: true });
68
+ for (const entry of entries) {
69
+ const srcPath = path.join(src, entry.name);
70
+ const destPath = path.join(dest, entry.name);
71
+
72
+ if (entry.isDirectory()) {
73
+ if (!dryRun) ensureDir(destPath);
74
+ copyRecursive(srcPath, destPath);
75
+ } else {
76
+ let srcContent = fs.readFileSync(srcPath, 'utf8');
77
+
78
+ // Inject target platform into SKILL.md — replaces [all] token with [provider-name]
79
+ if (entry.name === 'SKILL.md' && provider) {
80
+ const platformName = PROVIDER_TO_PLATFORM[provider] || provider;
81
+ srcContent = injectPlatformInContent(srcContent, platformName);
82
+
83
+ // Provider-specific frontmatter transform (e.g. Factory remaps
84
+ // commandHint.allowedTools / commandHint.model). Optional callback —
85
+ // most providers leave SKILL.md alone after platform injection.
86
+ if (typeof transformSkillMd === 'function') {
87
+ srcContent = transformSkillMd(srcContent, opts) || srcContent;
88
+ }
89
+ }
90
+
91
+ if (entry.name === 'SKILL.md') srcContent = injectBoundRules(srcContent, srcPath, opts);
92
+
93
+ const relative = path.relative(destSkillDir, destPath);
94
+ managed[relative] = {
95
+ hash: `sha256:${contentHash(srcContent)}`,
96
+ source: opts.deploySource || 'bundled',
97
+ version: opts.deployVersion || 'unknown',
98
+ ...(frameworkSlug ? { frameworkSlug } : {}),
99
+ };
100
+ if (fs.existsSync(destPath)) {
101
+ const destContent = fs.readFileSync(destPath, 'utf8');
102
+ if (destContent === srcContent && !force) {
103
+ if (verbose) console.log(`skip (unchanged): ${path.relative(destDir, destPath)}`);
104
+ continue;
105
+ }
106
+ }
107
+
108
+ if (dryRun) {
109
+ console.log(`[dry-run] deploy ${srcPath} -> ${destPath}`);
110
+ } else {
111
+ fs.writeFileSync(destPath, srcContent, 'utf8');
112
+ if (verbose) console.log(`deployed ${entry.name} -> ${path.relative(process.cwd(), destPath)}`);
113
+ }
114
+ }
115
+ }
116
+ }
117
+
118
+ copyRecursive(skillDir, destSkillDir);
119
+ pruneRecordedSkillFiles(destSkillDir, previous?.managed, new Set(Object.keys(managed)), opts);
120
+ writeSidecarManifest(destSkillDir, { managed, skillSource: path.resolve(skillDir) }, dryRun);
121
+
122
+ // Drop a `.aiwg-managed` marker so future cleanup runs can identify
123
+ // AIWG-deployed skills regardless of frontmatter shape (some providers
124
+ // strip `namespace:` during transform). Cleanup keys off this presence
125
+ // to safely prune renamed/removed source skills.
126
+ if (!dryRun) {
127
+ try {
128
+ fs.writeFileSync(path.join(destSkillDir, '.aiwg-managed'), 'aiwg\n', 'utf8');
129
+ } catch { /* non-fatal */ }
130
+ }
131
+
132
+ if (verbose) console.log(`deployed skill: ${skillName}`);
133
+ }
134
+
135
+
136
+ // ============================================================================
137
+ // Workspace Initialization
138
+ // ============================================================================
139
+
140
+ /**
141
+ * Initialize framework-scoped workspace structure
142
+ * Creates .aiwg/frameworks/{framework-id}/ directories
143
+ */
144
+ export function initializeFrameworkWorkspace(target, mode, dryRun, srcRoot = null) {
145
+ const aiwgBase = resolveFrameworkWorkspaceRoot(target);
146
+ const frameworksDir = path.join(aiwgBase, 'frameworks');
147
+ const sharedDir = path.join(aiwgBase, 'shared');
148
+
149
+ const frameworkDirs = srcRoot
150
+ ? getFrameworksForMode(srcRoot, mode).map(fw => ({
151
+ id: fw.id,
152
+ path: fw.path,
153
+ subdirs: fw.workspaceSubdirs,
154
+ memoryCreates: Array.isArray(fw.manifest?.memory?.creates) ? fw.manifest.memory.creates : []
155
+ }))
156
+ : [];
157
+
158
+ // Backward-compatible fallback when source root isn't provided.
159
+ if (frameworkDirs.length === 0) {
160
+ if (mode === 'sdlc' || mode === 'both' || mode === 'all') {
161
+ frameworkDirs.push({
162
+ id: 'sdlc-complete',
163
+ subdirs: ['repo', 'projects', 'working', 'archive']
164
+ });
165
+ }
166
+
167
+ if (mode === 'marketing' || mode === 'all') {
168
+ frameworkDirs.push({
169
+ id: 'media-marketing-kit',
170
+ subdirs: ['repo', 'campaigns', 'working', 'archive']
171
+ });
172
+ }
173
+
174
+ if (mode === 'media-curator' || mode === 'all') {
175
+ frameworkDirs.push({
176
+ id: 'media-curator',
177
+ subdirs: ['repo', 'library', 'working', 'archive']
178
+ });
179
+ }
180
+
181
+ if (mode === 'research' || mode === 'all') {
182
+ frameworkDirs.push({
183
+ id: 'research-complete',
184
+ subdirs: ['repo', 'corpus', 'working', 'archive']
185
+ });
186
+ }
187
+ }
188
+
189
+ if (frameworkDirs.length === 0) return;
190
+
191
+ if (dryRun) {
192
+ console.log('\n[dry-run] Would create framework-scoped workspace structure:');
193
+ console.log(`[dry-run] ${aiwgBase}/`);
194
+ console.log(`[dry-run] ${frameworksDir}/`);
195
+ console.log(`[dry-run] ${sharedDir}/`);
196
+ for (const fw of frameworkDirs) {
197
+ for (const subdir of fw.subdirs) {
198
+ console.log(`[dry-run] ${path.join(frameworksDir, fw.id, subdir)}/`);
199
+ }
200
+ for (const entry of fw.memoryCreates || []) {
201
+ if (entry && typeof entry.path === 'string') {
202
+ console.log(`[dry-run] ${path.join(aiwgBase, entry.path.slice('.aiwg/'.length))}${entry.path.endsWith('/') ? '/' : ''}`);
203
+ }
204
+ }
205
+ }
206
+ return;
207
+ }
208
+
209
+ ensureDir(aiwgBase);
210
+ ensureDir(frameworksDir);
211
+ ensureDir(sharedDir);
212
+
213
+ for (const fw of frameworkDirs) {
214
+ const fwBase = path.join(frameworksDir, fw.id);
215
+ ensureDir(fwBase);
216
+ for (const subdir of fw.subdirs) {
217
+ ensureDir(path.join(fwBase, subdir));
218
+ }
219
+ initializeMemoryCreates(aiwgBase, fw.path, fw.memoryCreates);
220
+ }
221
+
222
+ // Initialize registry.json if it doesn't exist
223
+ const registryPath = path.join(frameworksDir, 'registry.json');
224
+ if (!fs.existsSync(registryPath)) {
225
+ const registry = {
226
+ version: '1.0.0',
227
+ created: new Date().toISOString(),
228
+ frameworks: frameworkDirs.map(fw => ({
229
+ id: fw.id,
230
+ installed: new Date().toISOString(),
231
+ version: '1.0.0'
232
+ }))
233
+ };
234
+ fs.writeFileSync(registryPath, JSON.stringify(registry, null, 2), 'utf8');
235
+ console.log('Created framework registry at .aiwg/frameworks/registry.json');
236
+ }
237
+ }
238
+
239
+
240
+
241
+ export function initializeMemoryCreates(aiwgBase, frameworkPath, creates) {
242
+ for (const entry of creates || []) {
243
+ if (!entry || typeof entry.path !== 'string') continue;
244
+ if (!entry.path.startsWith('.aiwg/')) continue;
245
+
246
+ const targetPath = path.join(aiwgBase, entry.path.slice('.aiwg/'.length));
247
+ const isDirectory = entry.path.endsWith('/') || path.extname(entry.path) === '';
248
+ if (isDirectory) {
249
+ ensureDir(targetPath);
250
+ continue;
251
+ }
252
+
253
+ ensureDir(path.dirname(targetPath));
254
+ if (fs.existsSync(targetPath)) continue;
255
+
256
+ let content = null;
257
+ if (typeof entry.template === 'string' && frameworkPath) {
258
+ const templatePath = path.join(frameworkPath, entry.template);
259
+ if (fs.existsSync(templatePath)) {
260
+ content = fs.readFileSync(templatePath, 'utf8');
261
+ }
262
+ }
263
+
264
+ if (content === null) {
265
+ const title = path.basename(entry.path, path.extname(entry.path))
266
+ .replace(/[-_]+/g, ' ')
267
+ .replace(/\b\w/g, c => c.toUpperCase());
268
+ content = '# ' + title + '\n\n';
269
+ }
270
+
271
+ fs.writeFileSync(targetPath, content.endsWith('\n') ? content : content + '\n', 'utf8');
272
+ }
273
+ }