@aiwg/cli 2026.9.15 → 2026.9.17

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 (41) hide show
  1. package/agentic/code/providers/capability-matrix.yaml +80 -0
  2. package/agentic/code/providers/model-capabilities.v1.json +119 -34
  3. package/agentic/code/providers/model-catalog.v1.json +259 -56
  4. package/dist/src/cli/handlers/sessions.js +159 -45
  5. package/dist/src/cli/handlers/use.js +20 -1
  6. package/dist/src/cli/scope-resolver.js +26 -0
  7. package/dist/src/cli/services/deployment-verification.js +90 -2
  8. package/dist/src/config/aiwg-config.js +41 -0
  9. package/dist/src/config/user-registry.js +9 -0
  10. package/dist/src/dataset/conformance-types.d.ts +2 -1
  11. package/dist/src/dataset/conformance.js +10 -1
  12. package/dist/src/dataset/fortemi-live-qualification.d.ts +10 -0
  13. package/dist/src/dataset/fortemi-live-qualification.js +134 -0
  14. package/dist/src/extensions/manifest.js +1 -0
  15. package/dist/src/models/model-capabilities.v1.json +119 -34
  16. package/dist/src/models/model-catalog.v1.json +259 -56
  17. package/dist/src/models/model-discovery.js +7 -0
  18. package/dist/src/models/provider-policy.js +1 -1
  19. package/dist/src/plugin/skill-command-translator.js +1 -0
  20. package/dist/src/providers/capability-matrix.yaml +80 -0
  21. package/dist/src/providers/grok-build-inspect.js +245 -0
  22. package/dist/src/providers/grok-build-paths.js +92 -0
  23. package/dist/src/providers/grokbot-paths.js +103 -0
  24. package/dist/src/providers/provider-definitions.js +172 -2
  25. package/dist/src/providers/provider-inventory.js +2 -0
  26. package/dist/src/sessions/adapters/grokbot.js +49 -0
  27. package/dist/src/sessions/adapters/hermes.js +17 -9
  28. package/dist/src/sessions/adapters/opencode.js +12 -1
  29. package/dist/src/sessions/contracts.js +1 -1
  30. package/dist/src/sessions/export-plan.js +130 -4
  31. package/dist/src/sessions/fortemi-export-mapping.js +10 -6
  32. package/dist/src/sessions/fortemi-shard-blobs.js +78 -0
  33. package/dist/src/sessions/index.js +2 -0
  34. package/dist/src/sessions/workspace-discovery.js +1 -1
  35. package/dist/src/skills/deployer.js +17 -0
  36. package/dist/src/smiths/skillsmith/collision-detector.js +1 -0
  37. package/package.json +1 -1
  38. package/schemas/dataset/conformance-receipt.v1.schema.json +1 -1
  39. package/tools/agents/deploy-agents.mjs +4 -2
  40. package/tools/agents/providers/grok-build.mjs +153 -0
  41. package/tools/agents/providers/grokbot.mjs +285 -0
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Grok Build provider (experimental).
3
+ * Project skills under `.grok/skills`; user home via $GROK_HOME (default ~/.grok).
4
+ * Distinct from grokbot. No bare `grok` alias.
5
+ *
6
+ * Wave 1: native kernel skills + AGENTS.md bridge. Agents and rules are
7
+ * indexed/deferred until #2577 (Grok discovers `.grok/agents` and
8
+ * `.grok/rules`, but AIWG does not yet emit qualified writers for them).
9
+ *
10
+ * @issue #2575
11
+ */
12
+
13
+ import path from 'node:path';
14
+ import os from 'node:os';
15
+ import {
16
+ createAgentsMdFromTemplate,
17
+ deploySkillsWithKernelRouting,
18
+ collectFrameworkArtifacts,
19
+ getAddonSkillDirs,
20
+ normalizeDeploymentMode,
21
+ resolveAiwgRoot,
22
+ } from './base.mjs';
23
+
24
+ export const name = 'grok-build';
25
+ export const aliases = [];
26
+ export const paths = {
27
+ // Agents/rules dirs exist in Grok Build, but Wave 1 does not write them.
28
+ agents: '',
29
+ skills: '.grok/skills',
30
+ rules: '',
31
+ hooks: '.grok/hooks',
32
+ config: '.grok/config.toml',
33
+ };
34
+ export const kernelSkillsPath = '.grok/skills';
35
+ /** Standard-tier opt-in mirror (`--copy-all`) lives under the project .aiwg tree. */
36
+ export const standardSkillsPath = '.grok/.aiwg/skills';
37
+
38
+ export const support = {
39
+ agents: 'indexed', // deferred native writer until #2577
40
+ commands: 'indexed', // discoverable through the AIWG index; no native command writer
41
+ skills: 'native',
42
+ rules: 'indexed', // deferred native writer until #2577; host still loads AGENTS.md + .grok/rules hierarchically
43
+ };
44
+
45
+ export const capabilities = {
46
+ skills: true,
47
+ rules: false, // indexed/deferred — do not claim native rule transforms yet
48
+ yamlFormat: false,
49
+ aggregatedOutput: false,
50
+ homeDirectoryDeploy: true,
51
+ parallelCommandAndSkillSurfaces: false,
52
+ };
53
+
54
+ const GROK_HOME_ENV = 'GROK_HOME';
55
+
56
+ export function resolveGrokHome(env = process.env, userHome = os.homedir()) {
57
+ const raw = (env[GROK_HOME_ENV] || '').trim();
58
+ const candidate = raw || path.join(userHome, '.grok');
59
+ if (candidate === '~') return null;
60
+ let expanded = candidate;
61
+ if (candidate.startsWith('~/')) expanded = path.join(userHome, candidate.slice(2));
62
+ if (!path.isAbsolute(expanded)) return null;
63
+ const resolved = path.resolve(expanded);
64
+ if (!resolved || path.parse(resolved).root === resolved) return null;
65
+ return resolved;
66
+ }
67
+
68
+ export function createAgentsMd(target, srcRoot, dryRun) {
69
+ createAgentsMdFromTemplate(
70
+ target,
71
+ resolveAiwgRoot(srcRoot) || srcRoot,
72
+ 'grok-build/AGENTS.md.aiwg-template',
73
+ dryRun,
74
+ );
75
+ }
76
+
77
+ /**
78
+ * Kernel skills → `.grok/skills` (always).
79
+ * Standard skills → index-driven by default; `.grok/.aiwg/skills` with `--copy-all`.
80
+ */
81
+ export function deploySkills(skillDirs, targetDir, opts = {}) {
82
+ const kernelDest = path.join(targetDir, kernelSkillsPath);
83
+ const standardDest = path.join(targetDir, standardSkillsPath);
84
+ return deploySkillsWithKernelRouting(skillDirs, standardDest, kernelDest, {
85
+ ...opts,
86
+ copyStandardSkills: opts.copyStandardSkills === true,
87
+ });
88
+ }
89
+
90
+ export function deployAgents() {
91
+ return 0;
92
+ }
93
+
94
+ export function deployRules() {
95
+ return 0;
96
+ }
97
+
98
+ export async function postDeploy(target, opts = {}) {
99
+ if (opts.createAgentsMd || (!opts.commandsOnly && !opts.skillsOnly && !opts.rulesOnly)) {
100
+ createAgentsMd(target, opts.srcRoot, opts.dryRun);
101
+ }
102
+ if (!opts.quiet) {
103
+ const home = resolveGrokHome(opts.env || process.env);
104
+ console.log(
105
+ `Grok Build (experimental): kernel skills → ${kernelSkillsPath}; ` +
106
+ `standard skills index-driven (opt-in mirror → ${standardSkillsPath} with --copy-all); ` +
107
+ `agents/rules indexed until #2577; user home → ${home || '(unresolved GROK_HOME)'}. ` +
108
+ 'Distinct from grokbot.',
109
+ );
110
+ }
111
+ }
112
+
113
+ export function getFileExtension() {
114
+ return '.md';
115
+ }
116
+
117
+ export async function deploy(opts) {
118
+ const mode = normalizeDeploymentMode(opts.mode);
119
+ const skillDirs = [...getAddonSkillDirs(opts.srcRoot)];
120
+ skillDirs.push(
121
+ ...collectFrameworkArtifacts(opts.srcRoot, mode, {
122
+ includeAgents: false,
123
+ includeCommands: false,
124
+ includeSkills: true,
125
+ includeRules: false,
126
+ }).skills,
127
+ );
128
+ let count = 0;
129
+ if (!opts.commandsOnly && !opts.rulesOnly) {
130
+ const result = deploySkills(skillDirs, opts.target, opts);
131
+ count += (result?.kernel ?? 0) + (result?.standardCopied ?? 0);
132
+ }
133
+ await postDeploy(opts.target, opts);
134
+ return count;
135
+ }
136
+
137
+ export default {
138
+ name,
139
+ aliases,
140
+ paths,
141
+ kernelSkillsPath,
142
+ standardSkillsPath,
143
+ support,
144
+ capabilities,
145
+ resolveGrokHome,
146
+ createAgentsMd,
147
+ deploySkills,
148
+ deployAgents,
149
+ deployRules,
150
+ postDeploy,
151
+ getFileExtension,
152
+ deploy,
153
+ };
@@ -0,0 +1,285 @@
1
+ /**
2
+ * Grok Bot provider (experimental).
3
+ *
4
+ * Discover-first project bridge + fail-closed user skill root.
5
+ * Never targets `.cursor/**` or invents `~/.grokbot`.
6
+ *
7
+ * User-scope skill writes require AIWG_GROKBOT_SKILLS_DIR (absolute path).
8
+ * See `docs/architecture/adr-grokbot-provider-target.md` and #203–#208.
9
+ */
10
+
11
+ import path from 'path';
12
+ import os from 'os';
13
+ import {
14
+ collectFrameworkArtifacts,
15
+ createAgentsMdFromTemplate,
16
+ deploySkillsWithKernelRouting,
17
+ getAddonSkillDirs,
18
+ normalizeDeploymentMode,
19
+ resolveAiwgRoot,
20
+ } from './base.mjs';
21
+
22
+ export const name = 'grokbot';
23
+ export const aliases = [];
24
+
25
+ const SKILLS_DIR_ENV = 'AIWG_GROKBOT_SKILLS_DIR';
26
+
27
+ /**
28
+ * Resolve configured Grok Bot skills directory (fail-closed).
29
+ * Mirrors src/providers/grokbot-paths.ts for the JS deploy path.
30
+ */
31
+ export function resolveGrokbotSkillsDir(env = process.env, userHome = os.homedir()) {
32
+ const raw = (env[SKILLS_DIR_ENV] || '').trim();
33
+ if (!raw) return null;
34
+ let expanded = raw;
35
+ if (raw === '~') return null;
36
+ if (raw.startsWith('~/')) expanded = path.join(userHome, raw.slice(2));
37
+ if (!path.isAbsolute(expanded)) return null;
38
+ const resolved = path.resolve(expanded);
39
+ if (!resolved || resolved === path.sep) return null;
40
+ return resolved;
41
+ }
42
+
43
+ export function getGrokbotMissingRootMessage(env = process.env) {
44
+ const raw = (env[SKILLS_DIR_ENV] || '').trim();
45
+ if (!raw) {
46
+ return (
47
+ `Grok Bot user-scope skill root is not configured. Set ${SKILLS_DIR_ENV} ` +
48
+ 'to the absolute path of the Grok Bot skills/workflows directory before ' +
49
+ 'using --scope user or --global. AIWG does not invent ~/.grokbot.'
50
+ );
51
+ }
52
+ if (raw === '~' || (!raw.startsWith('~/') && !path.isAbsolute(raw))) {
53
+ return (
54
+ `${SKILLS_DIR_ENV} must be an absolute path (got '${raw}'). ` +
55
+ 'Relative values and bare ~ are rejected.'
56
+ );
57
+ }
58
+ if (raw.startsWith('~/')) {
59
+ const expanded = path.join(os.homedir(), raw.slice(2));
60
+ if (!path.isAbsolute(path.resolve(expanded))) {
61
+ return `${SKILLS_DIR_ENV} must resolve to an absolute path (got '${raw}').`;
62
+ }
63
+ }
64
+ return (
65
+ `Grok Bot skill root '${raw}' is not usable. Set ${SKILLS_DIR_ENV} to a ` +
66
+ 'valid absolute directory.'
67
+ );
68
+ }
69
+
70
+ // Project-relative paths stay empty: agents/commands/rules are indexed.
71
+ // Skills path is absolute only when the operator configured the env override;
72
+ // otherwise '' so project deploy skips native skill copies.
73
+ function configuredSkillsPath() {
74
+ return resolveGrokbotSkillsDir() || '';
75
+ }
76
+
77
+ export const paths = {
78
+ agents: '',
79
+ commands: '',
80
+ get skills() {
81
+ return configuredSkillsPath();
82
+ },
83
+ rules: '',
84
+ };
85
+
86
+ // Empty when unset — deploySkills resolves AIWG_GROKBOT_SKILLS_DIR dynamically.
87
+ // Never default to ~/.grokbot.
88
+ export const kernelSkillsPath = '';
89
+
90
+ export const support = {
91
+ agents: 'indexed',
92
+ commands: 'indexed',
93
+ skills: 'native-when-configured',
94
+ rules: 'indexed',
95
+ };
96
+
97
+ export const capabilities = {
98
+ skills: true,
99
+ rules: false,
100
+ aggregatedOutput: false,
101
+ yamlFormat: false,
102
+ homeDirectoryDeploy: true,
103
+ };
104
+
105
+ export function mapModel(originalModel) {
106
+ return originalModel;
107
+ }
108
+
109
+ export function transformAgent(_srcPath, content) {
110
+ return content;
111
+ }
112
+
113
+ export function transformCommand(_srcPath, content) {
114
+ return content;
115
+ }
116
+
117
+ export function deployAgents() {
118
+ return 0;
119
+ }
120
+
121
+ export function deployCommands() {
122
+ return 0;
123
+ }
124
+
125
+ export function deployRules() {
126
+ return 0;
127
+ }
128
+
129
+ /**
130
+ * Deploy skills only when AIWG_GROKBOT_SKILLS_DIR is configured.
131
+ * Kernel → configured root; standard → index/discovery unless --copy-all
132
+ * (then `<root>/.aiwg/skills`).
133
+ */
134
+ export function deploySkills(skillDirs, targetDir, opts = {}) {
135
+ const root = resolveGrokbotSkillsDir(opts.env || process.env);
136
+ if (!root) {
137
+ if (!opts.quiet) {
138
+ console.log(
139
+ `\n Grok Bot: skipping native skill copy (${SKILLS_DIR_ENV} unset). ` +
140
+ 'Skills remain available via aiwg discover / aiwg show.',
141
+ );
142
+ }
143
+ return 0;
144
+ }
145
+
146
+ if (root.includes(`${path.sep}.cursor${path.sep}`) || root.endsWith(`${path.sep}.cursor`) || root.includes('/.cursor/') || root.endsWith('/.cursor')) {
147
+ throw new Error(
148
+ `Refusing to deploy Grok Bot skills into a .cursor path (${root}). ` +
149
+ `Set ${SKILLS_DIR_ENV} to the Grok Bot skills root, not Cursor.`,
150
+ );
151
+ }
152
+
153
+ const kernelDest = root;
154
+ const standardDest = path.join(root, '.aiwg', 'skills');
155
+ if (!opts.quiet) {
156
+ console.log(
157
+ `\n Grok Bot skills root: ${root} (from ${SKILLS_DIR_ENV})` +
158
+ (opts.dryRun ? ' [dry-run]' : ''),
159
+ );
160
+ }
161
+ return deploySkillsWithKernelRouting(skillDirs, standardDest, kernelDest, {
162
+ ...opts,
163
+ copyStandardSkills: opts.copyStandardSkills === true,
164
+ });
165
+ }
166
+
167
+ export function createAgentsMd(target, srcRoot, dryRun) {
168
+ const aiwgRoot = resolveAiwgRoot(srcRoot) || srcRoot;
169
+ createAgentsMdFromTemplate(target, aiwgRoot, 'grokbot/AGENTS.md.aiwg-template', dryRun);
170
+ }
171
+
172
+ export async function postDeploy(targetDir, opts = {}) {
173
+ if (
174
+ opts.createAgentsMd ||
175
+ (!opts.commandsOnly && !opts.skillsOnly && !opts.rulesOnly)
176
+ ) {
177
+ createAgentsMd(targetDir, opts.srcRoot, opts.dryRun);
178
+ }
179
+ if (!opts.quiet) {
180
+ const root = resolveGrokbotSkillsDir(opts.env || process.env);
181
+ if (root) {
182
+ console.log(
183
+ 'Grok Bot: after deploy, start a new agent chat or re-read skills. ' +
184
+ 'Live refresh is not claimed until product behavior is verified.',
185
+ );
186
+ } else {
187
+ console.log(
188
+ `Grok Bot: project bridge only. Set ${SKILLS_DIR_ENV} for user-scope skill deploy.`,
189
+ );
190
+ }
191
+ }
192
+ }
193
+
194
+ export function getFileExtension() {
195
+ return '.md';
196
+ }
197
+
198
+ /**
199
+ * Assert user-scope is allowed. Called when the orchestrator is mirroring
200
+ * to user scope or when opts.scope === 'user'.
201
+ */
202
+ export function assertUserScopeConfigured(opts = {}) {
203
+ const root = resolveGrokbotSkillsDir(opts.env || process.env);
204
+ if (!root) {
205
+ const err = new Error(getGrokbotMissingRootMessage(opts.env || process.env));
206
+ err.code = 'GROKBOT_SKILLS_DIR_UNSET';
207
+ throw err;
208
+ }
209
+ return root;
210
+ }
211
+
212
+ export async function deploy(opts = {}) {
213
+ const {
214
+ srcRoot,
215
+ target,
216
+ mode,
217
+ deploySkills: shouldDeploySkills,
218
+ skillsOnly,
219
+ commandsOnly,
220
+ rulesOnly,
221
+ scope,
222
+ } = opts;
223
+
224
+ if (!opts.quiet) {
225
+ console.log(`\n=== Grok Bot Provider (experimental) ===`);
226
+ console.log(`Target: ${target}`);
227
+ console.log(`Mode: ${mode}`);
228
+ const root = resolveGrokbotSkillsDir(opts.env || process.env);
229
+ console.log(
230
+ `Skills root: ${root || `(unset — set ${SKILLS_DIR_ENV} for user-scope writes)`}`,
231
+ );
232
+ if (opts.dryRun) console.log('Dry-run: no filesystem mutations');
233
+ }
234
+
235
+ // Fail closed when caller explicitly requested user scope without a root.
236
+ if (scope === 'user' || opts.userScope === true) {
237
+ assertUserScopeConfigured(opts);
238
+ }
239
+
240
+ const skillDirs = [];
241
+ const normalizedMode = normalizeDeploymentMode(mode);
242
+
243
+ if (['general', 'sdlc', 'both', 'all'].includes(normalizedMode)) {
244
+ if (shouldDeploySkills || skillsOnly) skillDirs.push(...getAddonSkillDirs(srcRoot));
245
+ }
246
+
247
+ const fw = collectFrameworkArtifacts(srcRoot, normalizedMode, {
248
+ includeAgents: false,
249
+ includeCommands: false,
250
+ includeSkills: shouldDeploySkills || skillsOnly,
251
+ includeRules: false,
252
+ });
253
+ skillDirs.push(...fw.skills);
254
+
255
+ let count = 0;
256
+ if ((shouldDeploySkills || skillsOnly) && !commandsOnly && !rulesOnly) {
257
+ count += deploySkills(skillDirs, target, opts);
258
+ }
259
+
260
+ await postDeploy(target, opts);
261
+ return count;
262
+ }
263
+
264
+ export default {
265
+ name,
266
+ aliases,
267
+ paths,
268
+ kernelSkillsPath,
269
+ support,
270
+ capabilities,
271
+ mapModel,
272
+ transformAgent,
273
+ transformCommand,
274
+ deployAgents,
275
+ deployCommands,
276
+ deploySkills,
277
+ deployRules,
278
+ createAgentsMd,
279
+ postDeploy,
280
+ getFileExtension,
281
+ deploy,
282
+ resolveGrokbotSkillsDir,
283
+ getGrokbotMissingRootMessage,
284
+ assertUserScopeConfigured,
285
+ };