@yunhozz/arc 0.4.1 → 0.4.3

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 (68) hide show
  1. package/MANIFEST.sha256 +66 -42
  2. package/README.md +6 -6
  3. package/claude/skill/references/coordination.md +1 -1
  4. package/codex/skill/references/coordination.md +1 -1
  5. package/gemini/skill/references/coordination.md +1 -1
  6. package/grok/AGENTS.md +8 -0
  7. package/grok/agents/arc-implementer.md +37 -0
  8. package/grok/agents/arc-planner.md +47 -0
  9. package/grok/agents/arc-qa.md +37 -0
  10. package/grok/agents/arc-reviewer.md +39 -0
  11. package/grok/agents/arc-scouter.md +38 -0
  12. package/grok/instructions.md +4 -0
  13. package/grok/skill/SKILL.md +78 -0
  14. package/grok/skill/models.toml +23 -0
  15. package/grok/skill/references/arc-visual-companion.md +28 -0
  16. package/grok/skill/references/commit.md +55 -0
  17. package/grok/skill/references/coordination.md +149 -0
  18. package/grok/skill/references/git-recovery.md +34 -0
  19. package/grok/skill/references/handoff-prep.md +110 -0
  20. package/grok/skill/references/handoff.md +227 -0
  21. package/grok/skill/references/limits.md +31 -0
  22. package/grok/skill/references/planning.md +168 -0
  23. package/grok/skill/references/verification.md +155 -0
  24. package/grok/skill/references/worktree-creation.md +8 -0
  25. package/lib/installer/grok-compat.mjs +107 -0
  26. package/lib/installer/plan.mjs +7 -3
  27. package/lib/installer/runtime-assets.mjs +1 -0
  28. package/lib/installer/uninstall.mjs +14 -1
  29. package/lib/installer/upgrade-state.mjs +4 -2
  30. package/lib/installer/upgrade.mjs +5 -0
  31. package/lib/management/operations.mjs +1 -1
  32. package/lib/management/status.mjs +4 -2
  33. package/lib/management/update.mjs +4 -4
  34. package/lib/models/codex-models.json +72 -0
  35. package/lib/models/grok-models.json +7 -0
  36. package/lib/platforms/formats/grok-markdown.mjs +49 -0
  37. package/lib/platforms/grok.mjs +14 -0
  38. package/lib/platforms/index.mjs +2 -1
  39. package/lib/policy/role-policy.json +34 -15
  40. package/lib/prompts/agent-fragments.json +70 -0
  41. package/lib/prompts/render.mjs +6 -1
  42. package/lib/runtime/bootstrap.mjs +1 -1
  43. package/lib/runtime/grok-stream.mjs +46 -0
  44. package/lib/runtime/platform-registry.mjs +21 -0
  45. package/lib/runtime/role-bridge-args.mjs +40 -0
  46. package/lib/runtime/role-bridge.mjs +1 -1
  47. package/lib/runtime/role-dispatch-policy.mjs +4 -2
  48. package/lib/runtime/role-routing.mjs +2 -1
  49. package/lib/runtime/role-supervisor.mjs +57 -13
  50. package/lib/tui/app.mjs +18 -11
  51. package/lib/tui/custom-preset.mjs +6 -4
  52. package/lib/tui/mode.mjs +26 -3
  53. package/lib/tui/render.mjs +19 -8
  54. package/lib/tui/setup.mjs +5 -5
  55. package/lib/tui/terminal.mjs +1 -1
  56. package/lib/watch/status-line.mjs +10 -2
  57. package/package.json +2 -1
  58. package/scripts/update-manifest.mjs +2 -2
  59. package/shared/skill/references/superpowers-provenance.json +1 -1
  60. package/shared/skill/runtime/bootstrap.mjs +1 -1
  61. package/shared/skill/runtime/grok-stream.mjs +46 -0
  62. package/shared/skill/runtime/platform-registry.mjs +21 -0
  63. package/shared/skill/runtime/role-bridge-args.mjs +40 -0
  64. package/shared/skill/runtime/role-bridge.mjs +1 -1
  65. package/shared/skill/runtime/role-dispatch-policy.mjs +4 -2
  66. package/shared/skill/runtime/role-policy.json +34 -15
  67. package/shared/skill/runtime/role-routing.mjs +2 -1
  68. package/shared/skill/runtime/role-supervisor.mjs +57 -13
@@ -7,6 +7,7 @@ import {verifyPayload} from './manifest.mjs';
7
7
  import {installTargets} from './install.mjs';
8
8
  import {installerRegistryOf} from '../platforms/index.mjs';
9
9
  import {createPlatformRegistry} from '../runtime/platform-registry.mjs';
10
+ import path from 'node:path';
10
11
  export function buildUpgradePlans({payload,state,safeFs,registry=state.registry}){
11
12
  const platforms=installerRegistryOf({platforms:registry}),runtimePlatforms=createPlatformRegistry(platforms.byAnchorOrder().map(descriptor=>descriptor.runtime));
12
13
  for(const entry of state.targets)assertPlanSnapshot(entry,{safeFs});
@@ -18,6 +19,10 @@ export function buildUpgradePlans({payload,state,safeFs,registry=state.registry}
18
19
  if(current.exists&&removeManagedBlock(current.bytes).changed){const rendered=renderManagedBlock(current.bytes,agentsBlockBody(target.home,target.userHome,language,target.platform));plan.managedPaths.push(target.instructionPath);if(!rendered.content.equals(current.bytes))plan.globalChanges.push({path:target.instructionPath,original:current.bytes,...rendered});}
19
20
  return plan;
20
21
  });
22
+ const writePaths=plans.map(plan=>new Set(plan.managedPaths));
23
+ for(const [index,plan]of plans.entries())for(const filename of state.targets[index].modeKeys??[]){
24
+ if(writePaths.some((paths,other)=>other!==index&&[...paths].some(written=>filename===written||filename.startsWith(written+path.sep)||written.startsWith(filename+path.sep))))plan.snapshot.delete(filename);
25
+ }
21
26
  attachShellCompletionCleanup(plans,{safeFs});
22
27
  validatePlanSet(plans);return plans;
23
28
  }
@@ -143,7 +143,7 @@ export async function executeCompositeOperation(context,prepared){
143
143
  if(!moving)await ready();
144
144
  const publication=await publishCompositeFiles({context,prepared:prepared.files,...(moving?{beforePublish:ready}:{})});
145
145
  const history=moving?[`Dispatch history stays in ${prepared.files.targets[prepared.files.previous.anchor].home}/arc-role-dispatch.`]:[];
146
- return {...operationResult(result),code:publication.cleanupError?1:0,activation:'published',publication,support:held,...(publication.cleanupError?{error:publication.cleanupError}:{}),messages:[`Mixed routing on: ${sortByDisplay(prepared.config.platforms,installerRegistryOf(context)).map(id=>platformLabel(id,installerRegistryOf(context))).join(' + ')}.`,'After upgrading ARC, run Install / Update again.',...history,...(publication.residualPaths??[]).map(value=>'Residual path: '+value)]};
146
+ return {...operationResult(result),code:publication.cleanupError?1:0,activation:'published',publication,support:held,...(publication.cleanupError?{error:publication.cleanupError}:{}),messages:[`Mixed routing on: ${sortByDisplay(prepared.config.platforms,installerRegistryOf(context)).map(id=>platformLabel(id,installerRegistryOf(context))).join(' + ')}.`,'After upgrading ARC, run Configure again.',...history,...(publication.residualPaths??[]).map(value=>'Residual path: '+value)]};
147
147
  }catch(error){if(installationHeld&&!error.lockReleaseFailed)return installationHeld;return {code:context.signal?.aborted?130:1,exitSession:false,interrupted:Boolean(context.signal?.aborted),results:result.results,activation:error.activation??'held',support:held,error,messages:[...(Array.isArray(error.activeDispatches)?[`${prepared.files.previous&&prepared.files.previous.anchor!==prepared.files.anchor?'Active dispatches':'Active bridge dispatches'}: ${error.activeDispatches.join(', ')}`]:[]),...(error.activation==='unknown'?['Configuration publication state is unknown; inspect the reported paths before retrying.']:[]),...(error.residualPaths??[]).map(value=>'Residual path: '+value)]};}
148
148
  }
149
149
  export function operationResult(result,successStatuses=['installed']){return{...result,code:result.interrupted?130:result.results.every(item=>successStatuses.includes(item.status)&&!item.error)?0:1,exitSession:false};}
@@ -18,9 +18,11 @@ export async function collectStatus(context,{codexCheck='refresh'}={}){const reg
18
18
  return{platform,target,state:'installed',settings,snapshot,residualPaths:profiles.filter(x=>x.exists&&!x.owned).map(x=>x.path),diagnostics:[]};
19
19
  }catch(error){return{platform,target,state:'incomplete',diagnostics:[error]};}
20
20
  });return Promise.all(statuses.map(async status=>{
21
+ const runtime=registry.getPlatform(status.platform).runtime;
22
+ if(runtime.capabilities.install.state!=='verified')return{...status,cliVersion:{version:null,reason:'capability_not_verified'},authentication:{authStatus:'unknown',reason:'capability_not_verified'}};
21
23
  const cli=resolveLocalCli(status.platform,context);
22
- const kind=registry.getPlatform(status.platform).runtime.auth.kind;
24
+ const kind=runtime.auth.kind;
23
25
  const authentication=kind==='none'?(cli.reason?{authStatus:'unknown',reason:'auth_unverified'}:await probePlatformAuth(cli,{signal:context.signal})):cli.reason?{platform:status.platform,authStatus:'unknown',reason:cli.reason}:kind==='codex-refresh'?await (codexCheck==='local'?probeCodexLoginStatus:probeCodexAuthStatus)(cli,{signal:context.signal}):kind==='cli-status-json'?await probePlatformAuth(cli,{signal:context.signal}):{platform:status.platform,authStatus:'unknown',reason:'auth_probe_unavailable'};
24
26
  const version=kind==='none'?{cliVersion:cli.reason?{version:null,reason:cli.reason}:await probeCliVersion(cli,{signal:context.signal})}:{};
25
- return {...status,authentication,...version,...(installation.legacyAnchor&&installation.platforms.includes(status.platform)?{diagnostics:[...status.diagnostics,new Error('Mixed routing will move to the Claude home on the next Install / Update.')]}:{})};
27
+ return {...status,authentication,...version,...(installation.legacyAnchor&&installation.platforms.includes(status.platform)?{diagnostics:[...status.diagnostics,new Error('Mixed routing will move to the Claude home the next time you apply Configure.')]}:{})};
26
28
  }));}
@@ -18,7 +18,7 @@ export function report(result,output,error){
18
18
  for(const filename of result.residualPaths??[])writeResidual(filename);
19
19
  if(result.interrupted)return 130;
20
20
  if(result.results.every(item=>item.status==='installed'&&!item.error)){output.write('ARC harness updated to '+result.version+'.\n');return 0;}
21
- error.write('Harness update did not complete. Run arc again and choose Install / Update to retry the harness update.\n');return 1;
21
+ error.write('Harness update did not complete. Run arc again and choose Configure to retry the harness update.\n');return 1;
22
22
  }
23
23
  export function failure(cause,error){error.write('Error: '+cause.message+'\n');return ['ARC_CANCELLED','ARC_NPM_CANCELLED'].includes(cause.code)?130:['ARC_CLI_INPUT','ARC_TARGET_CONFIGURATION','ARC_UNSUPPORTED_RUNTIME','ARC_NATIVE_UNAVAILABLE'].includes(cause.code)?2:1;}
24
24
  export async function runChild(request,io={},deps={}){
@@ -42,15 +42,15 @@ export async function prepareUpdate(context){
42
42
  if(!['global','npx'].includes(npmContext.kind))throw configurationError('Run arc from a verified global ARC installation or npx');
43
43
  let latestVersion=null,latestError;
44
44
  try{const latest=await api.resolveLatest({context:npmContext,env,cwd,signal:context.signal});if(!/^\d+\.\d+\.\d+$/.test(latest.version))throw Error('Invalid latest ARC version');latestVersion=latest.version;}catch(error){if(['ARC_CANCELLED','ARC_NPM_CANCELLED'].includes(error.code))throw error;latestError=error;}
45
- return{kind:'update',root,pkg,cwd,env,state,npmContext,currentVersion:pkg.version,latestVersion,canUpgrade:state.targets.length>0&&latestVersion!==null&&newer(latestVersion,pkg.version),latestError};
45
+ return{kind:'update',root,pkg,cwd,env,state,npmContext,currentVersion:pkg.version,latestVersion,canUpgrade:state.targets.length>0&&latestVersion!==null&&isNewerVersion(latestVersion,pkg.version),latestError};
46
46
  }
47
- function newer(left,right){const a=left.split('.').map(BigInt),b=right.split('.').map(BigInt);for(let i=0;i<3;i++){if(a[i]!==b[i])return a[i]>b[i];}return false;}
47
+ export function isNewerVersion(left,right){const a=left.split('.').map(BigInt),b=right.split('.').map(BigInt);for(let i=0;i<3;i++){if(a[i]!==b[i])return a[i]>b[i];}return false;}
48
48
 
49
49
  export async function executeUpdate(context,prepared){
50
50
  let packageStarted=false;const messages=[];try{
51
51
  const api=await runtime(context),{root,pkg,cwd,env,state}=prepared;
52
52
  if(!state?.targets?.length)throw configurationError('No installed ARC harness found');
53
- if(!prepared.canUpgrade||typeof prepared.latestVersion!=='string'||!/^\d+\.\d+\.\d+$/.test(prepared.latestVersion)||!newer(prepared.latestVersion,prepared.currentVersion))throw configurationError('No newer ARC version is available');
53
+ if(!prepared.canUpgrade||typeof prepared.latestVersion!=='string'||!/^\d+\.\d+\.\d+$/.test(prepared.latestVersion)||!isNewerVersion(prepared.latestVersion,prepared.currentVersion))throw configurationError('No newer ARC version is available');
54
54
  if(identity(root).version!==pkg.version||pkg.version!==prepared.currentVersion)throw configurationError('ARC package changed after checking its version');
55
55
  const{assertPlanSnapshot}=await import('../installer/transaction.mjs');for(const entry of state.targets)assertPlanSnapshot(entry,{safeFs:api.safeFs});
56
56
  const currentState=api.collectInstalledState({safeFs:api.safeFs,userHome:context.userHome??os.homedir(),env,cwd,platforms:api.platforms,runtimePlatforms:api.runtimePlatforms});if(currentState.stateToken!==state.stateToken)throw configurationError('Installed ARC settings changed; check the version again');
@@ -1,6 +1,54 @@
1
1
  {
2
2
  "platform": "codex",
3
3
  "pairs": [
4
+ {
5
+ "model": "gpt-6.2-astra",
6
+ "effort": "low"
7
+ },
8
+ {
9
+ "model": "gpt-6.2-astra",
10
+ "effort": "medium"
11
+ },
12
+ {
13
+ "model": "gpt-6.2-astra",
14
+ "effort": "high"
15
+ },
16
+ {
17
+ "model": "gpt-6.2-astra",
18
+ "effort": "xhigh"
19
+ },
20
+ {
21
+ "model": "gpt-6.2-astra",
22
+ "effort": "max"
23
+ },
24
+ {
25
+ "model": "gpt-6.2-astra",
26
+ "effort": "ultra"
27
+ },
28
+ {
29
+ "model": "gpt-6.2-sol",
30
+ "effort": "low"
31
+ },
32
+ {
33
+ "model": "gpt-6.2-sol",
34
+ "effort": "medium"
35
+ },
36
+ {
37
+ "model": "gpt-6.2-sol",
38
+ "effort": "high"
39
+ },
40
+ {
41
+ "model": "gpt-6.2-sol",
42
+ "effort": "xhigh"
43
+ },
44
+ {
45
+ "model": "gpt-6.2-sol",
46
+ "effort": "max"
47
+ },
48
+ {
49
+ "model": "gpt-6.2-sol",
50
+ "effort": "ultra"
51
+ },
4
52
  {
5
53
  "model": "gpt-6-astra",
6
54
  "effort": "low"
@@ -21,6 +69,10 @@
21
69
  "model": "gpt-6-astra",
22
70
  "effort": "max"
23
71
  },
72
+ {
73
+ "model": "gpt-6-astra",
74
+ "effort": "ultra"
75
+ },
24
76
  {
25
77
  "model": "gpt-6.1-sol",
26
78
  "effort": "low"
@@ -41,6 +93,10 @@
41
93
  "model": "gpt-6.1-sol",
42
94
  "effort": "max"
43
95
  },
96
+ {
97
+ "model": "gpt-6.1-sol",
98
+ "effort": "ultra"
99
+ },
44
100
  {
45
101
  "model": "gpt-6.1-terra",
46
102
  "effort": "none"
@@ -65,6 +121,10 @@
65
121
  "model": "gpt-6.1-terra",
66
122
  "effort": "max"
67
123
  },
124
+ {
125
+ "model": "gpt-6.1-terra",
126
+ "effort": "ultra"
127
+ },
68
128
  {
69
129
  "model": "gpt-6-sol",
70
130
  "effort": "none"
@@ -89,6 +149,10 @@
89
149
  "model": "gpt-6-sol",
90
150
  "effort": "max"
91
151
  },
152
+ {
153
+ "model": "gpt-6-sol",
154
+ "effort": "ultra"
155
+ },
92
156
  {
93
157
  "model": "gpt-6-luna",
94
158
  "effort": "none"
@@ -137,6 +201,10 @@
137
201
  "model": "gpt-5.6-sol",
138
202
  "effort": "max"
139
203
  },
204
+ {
205
+ "model": "gpt-5.6-sol",
206
+ "effort": "ultra"
207
+ },
140
208
  {
141
209
  "model": "gpt-5.6-terra",
142
210
  "effort": "none"
@@ -161,6 +229,10 @@
161
229
  "model": "gpt-5.6-terra",
162
230
  "effort": "max"
163
231
  },
232
+ {
233
+ "model": "gpt-5.6-terra",
234
+ "effort": "ultra"
235
+ },
164
236
  {
165
237
  "model": "gpt-5.6-luna",
166
238
  "effort": "none"
@@ -0,0 +1,7 @@
1
+ {
2
+ "platform": "grok",
3
+ "pairs": [
4
+ {"model": "grok-4.6", "effort": "default"},
5
+ {"model": "grok-4.5", "effort": "default"}
6
+ ]
7
+ }
@@ -0,0 +1,49 @@
1
+ import {TargetConfigurationError} from '../../installer/target-errors.mjs';
2
+ import {getPlatform} from '../../runtime/platform-registry.mjs';
3
+ import {revisionTag} from '../../runtime/role-dispatch-policy.mjs';
4
+
5
+ const fail = message => {throw new TargetConfigurationError(message);};
6
+ const validRole = role => /^arc_(scouter|planner|implementer|qa|reviewer)$/.test(role);
7
+ const nonStringScalar = /^(?:~|null|true|false|yes|no|on|off|[-+]?(?:\.inf|\.nan|0[xob][0-9a-f_]+|(?:\d[\d_]*(?:\.[\d_]*)?|\.[\d_]+)(?:e[-+]?\d+)?)|\d{4}-\d{2}-\d{2}(?:[Tt ].*)?)$/i;
8
+ // Inline brackets remain valid text for the ARC routing revision tag.
9
+ const validScalar = value => value === value.trim() && !/[\p{Cc}\u2028\u2029{}#&*!|>"']/u.test(value)
10
+ && !/^(?:[-?:](?:\s|$)|[\[\],%@`])/.test(value) && !value.includes(': ') && !nonStringScalar.test(value);
11
+
12
+ // ARC-defined narrow scalar-only frontmatter; not live-verified with Grok.
13
+ // nativeProfile remains off (spec section 6 / U-K10).
14
+ function parse(text) {
15
+ const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]+)$/.exec(text);
16
+ if (!match || !match[2].trim()) fail('Invalid Grok profile frontmatter or instructions');
17
+ const fields = {};
18
+ for (const line of match[1].split(/\r?\n/)) {
19
+ const entry = /^([a-z][a-zA-Z0-9_-]*): (.+)$/.exec(line);
20
+ if (!entry || Object.hasOwn(fields, entry[1]) || !validScalar(entry[2])) fail('Malformed or duplicate Grok frontmatter');
21
+ fields[entry[1]] = entry[2];
22
+ }
23
+ if (Object.keys(fields).length !== 3 || !['name', 'description', 'model'].every(key => fields[key])) fail('Invalid Grok profile fields');
24
+ if (!getPlatform('grok').routing.validatePair(fields.model, 'default')) fail('Invalid Grok profile model');
25
+ return {fields, header: match[1]};
26
+ }
27
+
28
+ export function render(text, role, settings) {
29
+ const {fields, header} = parse(text);
30
+ if (!validRole(role) || fields.name !== role.replace('_', '-') || !getPlatform('grok').routing.validatePair(settings.model, settings.effort)) fail('Invalid Grok profile identity or settings');
31
+ const rendered = header.replace(/^model: .+$/m, line => `model: ${settings.model}${line.endsWith('\r') ? '\r' : ''}`);
32
+ return Buffer.from(text.replace(header, () => rendered));
33
+ }
34
+
35
+ export function isOwnedStandalone(bytes, role) {
36
+ try {
37
+ const text = bytes.toString('utf8'), {fields} = parse(text);
38
+ return validRole(role) && fields.name === role.replace('_', '-') && /^\[ARC role policy: contract begin\]\r?$/m.test(text);
39
+ } catch {return false;}
40
+ }
41
+
42
+ export function renameForRouting(bytes, role, revision) {
43
+ if (typeof revision !== 'string' || !/^[A-Za-z0-9._-]{1,128}$/.test(revision)) fail('Composite revision cannot be tagged');
44
+ const text = bytes.toString('utf8'), {fields, header} = parse(text);
45
+ if (!validRole(role) || fields.name !== role.replace('_', '-')) fail('Cannot identify the managed composite profile name');
46
+ const renamed = header.replace(/^name: .+(\r?)$/m, () => `name: arc-routing-${role.slice(4)}${header.split('\n')[0].endsWith('\r') ? '\r' : ''}`)
47
+ .replace(/^(description: .*?)(\r?)$/m, (_line, description, cr) => `${description} ${revisionTag(revision)}${cr}`);
48
+ return Buffer.from(text.replace(header, () => renamed));
49
+ }
@@ -0,0 +1,14 @@
1
+ import {getPlatform} from '../runtime/platform-registry.mjs';
2
+ import * as format from './formats/grok-markdown.mjs';
3
+ import {renderGrokCompat, removeGrokCompat} from '../installer/grok-compat.mjs';
4
+
5
+ export const GROK_INSTALLER = Object.freeze({
6
+ runtime: getPlatform('grok'),
7
+ payloadPrefix: 'grok', instructionTemplates: Object.freeze(['AGENTS.md', 'instructions.md']), instructionFile: 'AGENTS.md', runtimeConfigFile: 'config.toml',
8
+ globalPaths: Object.freeze(['AGENTS.md', 'config.toml']),
9
+ models: Object.freeze({staticCatalog: new URL('../models/grok-models.json', import.meta.url), effortField: getPlatform('grok').models.effortField}),
10
+ profiles: Object.freeze({render: format.render, isOwnedStandalone: format.isOwnedStandalone, renameForRouting: format.renameForRouting}),
11
+ runtimeConfig: Object.freeze({globalRender: renderGrokCompat, globalRemove: removeGrokCompat}),
12
+ uninstallSummary: 'Grok config.toml is preserved except ARC-managed [compat.claude] lines.',
13
+ isolationEnv: () => ({}),
14
+ });
@@ -2,6 +2,7 @@ import {DEFAULT_PLATFORM_REGISTRY} from '../runtime/platform-registry.mjs';
2
2
  import {CODEX_INSTALLER} from './codex.mjs';
3
3
  import {CLAUDE_INSTALLER} from './claude.mjs';
4
4
  import {GEMINI_INSTALLER} from './gemini.mjs';
5
+ import {GROK_INSTALLER} from './grok.mjs';
5
6
 
6
7
  export function createInstallerRegistry({runtime, descriptors}) {
7
8
  const ids = runtime.platformIds();
@@ -19,7 +20,7 @@ export function createInstallerRegistry({runtime, descriptors}) {
19
20
  });
20
21
  }
21
22
 
22
- export const DEFAULT_INSTALLER_REGISTRY = createInstallerRegistry({runtime: DEFAULT_PLATFORM_REGISTRY, descriptors: [CLAUDE_INSTALLER, CODEX_INSTALLER, GEMINI_INSTALLER]});
23
+ export const DEFAULT_INSTALLER_REGISTRY = createInstallerRegistry({runtime: DEFAULT_PLATFORM_REGISTRY, descriptors: [CLAUDE_INSTALLER, CODEX_INSTALLER, GEMINI_INSTALLER, GROK_INSTALLER]});
23
24
  export const installerRegistryOf = context => context?.platforms ?? DEFAULT_INSTALLER_REGISTRY;
24
25
  export const platformLabel = (id, registry = DEFAULT_INSTALLER_REGISTRY) => registry.getPlatform(id)?.runtime.label ?? id;
25
26
  export const sortByDisplay = (ids, registry = DEFAULT_INSTALLER_REGISTRY) => [...ids].sort((a, b) => registry.getPlatform(a).runtime.displayOrder - registry.getPlatform(b).runtime.displayOrder);
@@ -51,7 +51,8 @@
51
51
  "controls": {
52
52
  "codex": "prompt",
53
53
  "claude": "prompt",
54
- "gemini": "prompt"
54
+ "gemini": "prompt",
55
+ "grok": "prompt"
55
56
  }
56
57
  },
57
58
  {
@@ -84,7 +85,8 @@
84
85
  "controls": {
85
86
  "codex": "prompt",
86
87
  "claude": "prompt",
87
- "gemini": "prompt"
88
+ "gemini": "prompt",
89
+ "grok": "prompt"
88
90
  }
89
91
  },
90
92
  {
@@ -110,7 +112,8 @@
110
112
  "controls": {
111
113
  "codex": "prompt",
112
114
  "claude": "prompt",
113
- "gemini": "prompt"
115
+ "gemini": "prompt",
116
+ "grok": "prompt"
114
117
  }
115
118
  },
116
119
  {
@@ -139,7 +142,8 @@
139
142
  "controls": {
140
143
  "codex": "prompt",
141
144
  "claude": "prompt",
142
- "gemini": "prompt"
145
+ "gemini": "prompt",
146
+ "grok": "prompt"
143
147
  }
144
148
  },
145
149
  {
@@ -160,7 +164,8 @@
160
164
  "controls": {
161
165
  "codex": "prompt",
162
166
  "claude": "prompt",
163
- "gemini": "prompt"
167
+ "gemini": "prompt",
168
+ "grok": "prompt"
164
169
  }
165
170
  },
166
171
  {
@@ -181,7 +186,8 @@
181
186
  "controls": {
182
187
  "codex": "prompt",
183
188
  "claude": "prompt",
184
- "gemini": "prompt"
189
+ "gemini": "prompt",
190
+ "grok": "prompt"
185
191
  }
186
192
  },
187
193
  {
@@ -202,7 +208,8 @@
202
208
  "controls": {
203
209
  "codex": "prompt",
204
210
  "claude": "prompt",
205
- "gemini": "prompt"
211
+ "gemini": "prompt",
212
+ "grok": "prompt"
206
213
  }
207
214
  },
208
215
  {
@@ -224,7 +231,8 @@
224
231
  "controls": {
225
232
  "codex": "prompt",
226
233
  "claude": "prompt",
227
- "gemini": "prompt"
234
+ "gemini": "prompt",
235
+ "grok": "prompt"
228
236
  }
229
237
  },
230
238
  {
@@ -247,7 +255,8 @@
247
255
  "controls": {
248
256
  "codex": "prompt",
249
257
  "claude": "prompt",
250
- "gemini": "prompt"
258
+ "gemini": "prompt",
259
+ "grok": "prompt"
251
260
  }
252
261
  },
253
262
  {
@@ -268,7 +277,8 @@
268
277
  "controls": {
269
278
  "codex": "prompt",
270
279
  "claude": "prompt",
271
- "gemini": "prompt"
280
+ "gemini": "prompt",
281
+ "grok": "prompt"
272
282
  }
273
283
  },
274
284
  {
@@ -294,7 +304,8 @@
294
304
  "controls": {
295
305
  "codex": "prompt",
296
306
  "claude": "prompt",
297
- "gemini": "prompt"
307
+ "gemini": "prompt",
308
+ "grok": "prompt"
298
309
  }
299
310
  },
300
311
  {
@@ -320,7 +331,8 @@
320
331
  "controls": {
321
332
  "codex": "prompt",
322
333
  "claude": "prompt",
323
- "gemini": "prompt"
334
+ "gemini": "prompt",
335
+ "grok": "prompt"
324
336
  }
325
337
  },
326
338
  {
@@ -345,7 +357,8 @@
345
357
  "controls": {
346
358
  "codex": "prompt",
347
359
  "claude": "prompt",
348
- "gemini": "prompt"
360
+ "gemini": "prompt",
361
+ "grok": "prompt"
349
362
  }
350
363
  },
351
364
  {
@@ -369,7 +382,8 @@
369
382
  "controls": {
370
383
  "codex": "prompt",
371
384
  "claude": "prompt",
372
- "gemini": "prompt"
385
+ "gemini": "prompt",
386
+ "grok": "prompt"
373
387
  }
374
388
  },
375
389
  {
@@ -392,7 +406,8 @@
392
406
  "controls": {
393
407
  "codex": "prompt",
394
408
  "claude": "prompt",
395
- "gemini": "prompt"
409
+ "gemini": "prompt",
410
+ "grok": "prompt"
396
411
  }
397
412
  }
398
413
  ],
@@ -408,6 +423,10 @@
408
423
  "gemini": {
409
424
  "level": "prompt",
410
425
  "notice": "Role restrictions are prompt-level contracts, not a filesystem sandbox. Native tool restriction fields, observer hooks and Git guards are unverified. Use only available authorized tools; ARC does not write Gemini settings.json."
426
+ },
427
+ "grok": {
428
+ "level": "prompt",
429
+ "notice": "Role restrictions are prompt-level contracts, not a filesystem sandbox. Grok sandboxing, native tool restriction fields, observer hooks and Git guards are unverified, and Grok may continue without its sandbox. Use only available authorized tools; ARC disables Grok Claude compatibility (agents, skills, rules in config.toml; also MCPs and hooks for bridge children), but whether Grok sessions honor these settings is unverified."
411
430
  }
412
431
  },
413
432
  "review": {
@@ -325,6 +325,76 @@
325
325
  "common.read-only-no-mutations",
326
326
  "scouter.additional-boundaries"
327
327
  ]
328
+ },
329
+ {
330
+ "path": "grok/agents/arc-implementer.md",
331
+ "fragments": [
332
+ "common.brief-boundary",
333
+ "common.specialist-basics",
334
+ "common.preservation-choice-inspection",
335
+ "common.optional-read-exception",
336
+ "common.resume-gates",
337
+ "implementer.execution-steps"
338
+ ]
339
+ },
340
+ {
341
+ "path": "grok/agents/arc-planner.md",
342
+ "fragments": [
343
+ "common.brief-boundary",
344
+ "common.specialist-basics",
345
+ "common.preservation-choice-inspection",
346
+ "common.optional-read-exception",
347
+ "common.resume-gates",
348
+ "planner.target-evidence",
349
+ "planner.workflow-contract",
350
+ "planner.exploration-density",
351
+ "planner.task-shape",
352
+ "planner.commit-boundary",
353
+ "planner.visual-question",
354
+ "planner.final-plan-recheck"
355
+ ]
356
+ },
357
+ {
358
+ "path": "grok/agents/arc-qa.md",
359
+ "fragments": [
360
+ "common.brief-boundary",
361
+ "common.specialist-basics",
362
+ "common.preservation-choice-inspection",
363
+ "common.optional-read-exception",
364
+ "common.resume-gates",
365
+ "qa.contract-intro",
366
+ "common.verification-reference",
367
+ "qa.verification-steps"
368
+ ]
369
+ },
370
+ {
371
+ "path": "grok/agents/arc-reviewer.md",
372
+ "fragments": [
373
+ "common.brief-boundary",
374
+ "common.specialist-basics",
375
+ "common.preservation-choice-inspection",
376
+ "common.optional-read-exception",
377
+ "common.resume-gates",
378
+ "reviewer.contract-intro",
379
+ "common.verification-reference",
380
+ "reviewer.review-steps",
381
+ "common.read-only-no-mutations",
382
+ "reviewer.final-plan-findings"
383
+ ]
384
+ },
385
+ {
386
+ "path": "grok/agents/arc-scouter.md",
387
+ "fragments": [
388
+ "common.brief-boundary",
389
+ "common.specialist-basics",
390
+ "common.preservation-choice-inspection",
391
+ "common.optional-read-exception",
392
+ "common.resume-gates",
393
+ "scouter.research-brief",
394
+ "scouter.research-mode",
395
+ "common.read-only-no-mutations",
396
+ "scouter.additional-boundaries"
397
+ ]
328
398
  }
329
399
  ]
330
400
  }
@@ -125,7 +125,12 @@ const EXPECTED = {
125
125
  "gemini/agents/arc-planner.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "planner.target-evidence", "planner.workflow-contract", "planner.exploration-density", "planner.task-shape", "planner.commit-boundary", "planner.visual-question", "planner.final-plan-recheck"],
126
126
  "gemini/agents/arc-qa.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "qa.contract-intro", "common.verification-reference", "qa.verification-steps"],
127
127
  "gemini/agents/arc-reviewer.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "reviewer.contract-intro", "common.verification-reference", "reviewer.review-steps", "common.read-only-no-mutations", "reviewer.final-plan-findings"],
128
- "gemini/agents/arc-scouter.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "scouter.research-brief", "scouter.research-mode", "common.read-only-no-mutations", "scouter.additional-boundaries"]
128
+ "gemini/agents/arc-scouter.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "scouter.research-brief", "scouter.research-mode", "common.read-only-no-mutations", "scouter.additional-boundaries"],
129
+ "grok/agents/arc-implementer.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "implementer.execution-steps"],
130
+ "grok/agents/arc-planner.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "planner.target-evidence", "planner.workflow-contract", "planner.exploration-density", "planner.task-shape", "planner.commit-boundary", "planner.visual-question", "planner.final-plan-recheck"],
131
+ "grok/agents/arc-qa.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "qa.contract-intro", "common.verification-reference", "qa.verification-steps"],
132
+ "grok/agents/arc-reviewer.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "reviewer.contract-intro", "common.verification-reference", "reviewer.review-steps", "common.read-only-no-mutations", "reviewer.final-plan-findings"],
133
+ "grok/agents/arc-scouter.md": ["common.brief-boundary", "common.specialist-basics", "common.preservation-choice-inspection", "common.optional-read-exception", "common.resume-gates", "scouter.research-brief", "scouter.research-mode", "common.read-only-no-mutations", "scouter.additional-boundaries"]
129
134
  };
130
135
 
131
136
  const marker = /\{\{ARC_AGENT_FRAGMENT:([a-z][a-z0-9.-]*)\}\}/g;
@@ -8,7 +8,7 @@ export const COOPERATIVE_RUNTIME_MODULES=Object.freeze([
8
8
  'cli.mjs','command.mjs','bootstrap.mjs','cooperative-schema.mjs','cooperative.mjs','evaluate.mjs',
9
9
  'scope.mjs','store.mjs','git-evidence.mjs','assignment.mjs','verification.mjs','acceptance.mjs','external.mjs','schema.mjs','operations.mjs','gate.mjs','adapters/codex.mjs','adapters/claude.mjs','capabilities.mjs','identity.mjs','git-query.mjs','target-preparation.mjs',
10
10
  'local-cli.mjs','role-routing-config.mjs','role-routing.mjs','role-bridge.mjs',
11
- 'role-dispatch-policy.mjs','role-dispatch-store.mjs','role-bridge-args.mjs','role-observe.mjs','role-supervisor.mjs','platform-registry.mjs','gemini-stream.mjs'
11
+ 'role-dispatch-policy.mjs','role-dispatch-store.mjs','role-bridge-args.mjs','role-observe.mjs','role-supervisor.mjs','platform-registry.mjs','gemini-stream.mjs','grok-stream.mjs'
12
12
  ]);
13
13
  export const cooperativeCoverage=()=>({enforcement:'cooperative',provenance:'operator-attested',nativeVerified:false});
14
14
  export function commandResult({workflowId,state,input,decision='allow',ruleId='cooperative.recorded',persisted=false,...extra}){
@@ -0,0 +1,46 @@
1
+ // Unverified CLI contract: public documentation only; no live enforcement evidence.
2
+ // Sources: https://github.com/xai-org/grok-build/blob/main/crates/codegen/xai-grok-shell/README.md
3
+ // https://github.com/xai-org/grok-build/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/22-permissions-and-safety.md
4
+ // U-K5: the shell README and permissions guide document rule syntax:
5
+ // ToolPrefix(glob_pattern), bare prefix matches the whole tool type; blocking effect unverified.
6
+ // https://github.com/xai-org/grok-build/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/14-headless-mode.md
7
+ // U-K6: the headless guide example {"type":"text","data":…}.
8
+ // U-K7: the same guide lists end_turn, max_tokens, max_turn_requests, refusal, cancelled.
9
+ export const GROK_CONTRACT = Object.freeze({
10
+ outputFormat: 'streaming-json',
11
+ isolationArgs: Object.freeze(['--no-auto-update', '--no-subagents']),
12
+ childEnv: Object.freeze({
13
+ GROK_DISABLE_AUTOUPDATER: '1',
14
+ GROK_CLAUDE_AGENTS_ENABLED: 'false',
15
+ GROK_CLAUDE_SKILLS_ENABLED: 'false',
16
+ GROK_CLAUDE_RULES_ENABLED: 'false',
17
+ GROK_CLAUDE_MCPS_ENABLED: 'false',
18
+ GROK_CLAUDE_HOOKS_ENABLED: 'false',
19
+ }),
20
+ eventKinds: Object.freeze({text: 'text', thought: 'thought', tool_call: 'tool_call', tool_call_update: 'tool_call_update', usage: 'usage', plan: 'plan', available_commands: 'available_commands', error: 'error', end: 'end'}),
21
+ successStopReasons: Object.freeze(['end_turn']),
22
+ resumeFlag: '--resume',
23
+ delegation: 'undetectable',
24
+ readOnlyDeny: Object.freeze(['Bash', 'Edit', 'Write', 'MCPTool']),
25
+ });
26
+ export function normalizeGrokStreamEvent(line) {
27
+ let raw = line;
28
+ if (typeof line === 'string') {try {raw = JSON.parse(line);} catch {return {kind: 'unknown', raw};}}
29
+ const kind = raw && Object.hasOwn(GROK_CONTRACT.eventKinds, raw.type) ? GROK_CONTRACT.eventKinds[raw.type] : 'unknown';
30
+ if (kind === 'unknown') return {kind, raw};
31
+ return {kind, raw, ...(typeof raw.model === 'string' ? {model: raw.model} : {}),
32
+ ...(kind === 'end' ? {...(typeof raw.sessionId === 'string' ? {sessionId: raw.sessionId} : {}), ...(typeof raw.stopReason === 'string' ? {stopReason: raw.stopReason} : {})} : {}),
33
+ ...(kind === 'text' && typeof raw.data === 'string' ? {text: raw.data} : {})};
34
+ }
35
+ export function evaluateGrokObservation({state, expected, sessionId}) {
36
+ const observedSession = state.grokSessionId, model = state.grokModel;
37
+ const identityOk = observedSession === sessionId && !state.grokSessionMismatch;
38
+ const modelMismatch = state.grokModelMismatch || Boolean(model && model !== expected.model);
39
+ return {reason: !identityOk ? 'execution_identity_unverified' : modelMismatch ? 'model_effort_mismatch' : null,
40
+ claims: {
41
+ identity: identityOk ? {level: 'runtime-observed', source: 'grok-stream-session', observed: observedSession} : {level: 'unverified', source: 'none'},
42
+ model: {level: model && !modelMismatch ? 'runtime-observed' : 'unverified', source: model ? 'grok-stream-model' : 'none', requested: expected.model, observed: model ?? null},
43
+ effort: {level: 'unverified', source: 'none', requested: 'default', observed: null},
44
+ permissions: {level: 'runtime-observed', source: 'worktree-snapshot', details: 'git-visible worktree only'},
45
+ }};
46
+ }
@@ -58,6 +58,9 @@ function resolveHome(platform, {userHome, env = {}, cwd} = {}) {
58
58
  const expanded = expand(raw ?? path.join(userHome, '.codex'));
59
59
  if (path.isAbsolute(expanded)) home = path.resolve(expanded);
60
60
  else { const base = cwd ?? process.cwd(); if (typeof base !== 'string' || !path.isAbsolute(base)) throw Error('cwd must be absolute for relative CODEX_HOME'); home = path.resolve(base, expanded); }
61
+ } else if (platform === 'grok') {
62
+ if (env.GROK_HOME !== undefined) throw Error('GROK_HOME is not verified');
63
+ home = path.join(userHome, '.grok');
61
64
  } else if (platform === 'gemini') {
62
65
  if (env.GEMINI_CLI_HOME !== undefined) throw Error('GEMINI_CLI_HOME is not verified');
63
66
  home = path.join(userHome, '.gemini');
@@ -121,6 +124,24 @@ export const DEFAULT_PLATFORM_REGISTRY = createPlatformRegistry([
121
124
  authProbe: 'no official auth status command', watch: 'watch support out of scope',
122
125
  }).map(([key, reason]) => [key, {state: 'off', reason}]))},
123
126
  },
127
+ {
128
+ id: 'grok', label: 'Grok', displayOrder: 3, anchorOrder: 3,
129
+ home: {env: 'GROK_HOME', resolve: context => resolveHome('grok', context)},
130
+ cli: {command: 'grok', supportedVersions: '>=1.0.0 <1.1.0'},
131
+ auth: {kind: 'none'},
132
+ models: {effortField: 'effort'},
133
+ profile: {
134
+ ext: 'md',
135
+ standaloneName: role => `arc-${role.slice(4)}`,
136
+ routingName: role => `arc-routing-${role.slice(4)}`,
137
+ },
138
+ executionEnvironments: ['grok-cli'],
139
+ routing: {validatePair: (model, effort) => validText(model) && /^[A-Za-z0-9][A-Za-z0-9._:/@+\-]*$/.test(model) && effort === 'default'},
140
+ capabilities: {install: {state: 'verified'}, nativeProfile: {state: 'verified'}, catalog: {state: 'verified'}, standalone: {state: 'verified'}, bridge: {state: 'verified'}, compositeRole: {state: 'verified'}, ...Object.fromEntries(Object.entries({
141
+ compositeHost: 'composite host not verified', authProbe: 'no official auth status command',
142
+ watch: 'watch support out of scope',
143
+ }).map(([key, reason]) => [key, {state: 'off', reason}]))},
144
+ },
124
145
  ]);
125
146
 
126
147
  export const RUNTIME_PLATFORMS = DEFAULT_PLATFORM_REGISTRY.platforms;