@yunhozz/arc 0.4.2 → 0.4.4

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 (93) hide show
  1. package/MANIFEST.sha256 +91 -67
  2. package/README.md +7 -6
  3. package/claude/agents/arc-implementer.md +1 -0
  4. package/claude/agents/arc-planner.md +1 -0
  5. package/claude/agents/arc-qa.md +1 -0
  6. package/claude/agents/arc-reviewer.md +1 -0
  7. package/claude/agents/arc-scouter.md +1 -0
  8. package/claude/skill/SKILL.md +6 -3
  9. package/claude/skill/references/coordination.md +1 -1
  10. package/claude/skill/references/planning.md +36 -0
  11. package/codex/agents/arc-implementer.toml +1 -0
  12. package/codex/agents/arc-planner.toml +1 -0
  13. package/codex/agents/arc-qa.toml +1 -0
  14. package/codex/agents/arc-reviewer.toml +1 -0
  15. package/codex/agents/arc-scouter.toml +1 -0
  16. package/codex/skill/SKILL.md +6 -3
  17. package/codex/skill/references/coordination.md +1 -1
  18. package/codex/skill/references/planning.md +36 -0
  19. package/gemini/agents/arc-implementer.md +1 -0
  20. package/gemini/agents/arc-planner.md +1 -0
  21. package/gemini/agents/arc-qa.md +1 -0
  22. package/gemini/agents/arc-reviewer.md +1 -0
  23. package/gemini/agents/arc-scouter.md +1 -0
  24. package/gemini/skill/SKILL.md +6 -3
  25. package/gemini/skill/references/coordination.md +1 -1
  26. package/gemini/skill/references/planning.md +36 -0
  27. package/grok/AGENTS.md +8 -0
  28. package/grok/agents/arc-implementer.md +38 -0
  29. package/grok/agents/arc-planner.md +48 -0
  30. package/grok/agents/arc-qa.md +38 -0
  31. package/grok/agents/arc-reviewer.md +40 -0
  32. package/grok/agents/arc-scouter.md +39 -0
  33. package/grok/instructions.md +4 -0
  34. package/grok/skill/SKILL.md +81 -0
  35. package/grok/skill/models.toml +23 -0
  36. package/grok/skill/references/arc-visual-companion.md +28 -0
  37. package/grok/skill/references/commit.md +55 -0
  38. package/grok/skill/references/coordination.md +149 -0
  39. package/grok/skill/references/git-recovery.md +34 -0
  40. package/grok/skill/references/handoff-prep.md +110 -0
  41. package/grok/skill/references/handoff.md +227 -0
  42. package/grok/skill/references/limits.md +31 -0
  43. package/grok/skill/references/planning.md +204 -0
  44. package/grok/skill/references/verification.md +155 -0
  45. package/grok/skill/references/worktree-creation.md +8 -0
  46. package/lib/installer/global-config.mjs +8 -3
  47. package/lib/installer/grok-compat.mjs +107 -0
  48. package/lib/installer/language.mjs +54 -6
  49. package/lib/installer/plan.mjs +20 -14
  50. package/lib/installer/runtime-assets.mjs +1 -0
  51. package/lib/installer/uninstall.mjs +14 -1
  52. package/lib/installer/upgrade-state.mjs +13 -4
  53. package/lib/installer/upgrade.mjs +8 -3
  54. package/lib/management/operations.mjs +8 -5
  55. package/lib/management/status.mjs +26 -5
  56. package/lib/management/update.mjs +4 -4
  57. package/lib/models/codex-models.json +72 -0
  58. package/lib/models/grok-models.json +7 -0
  59. package/lib/platforms/formats/grok-markdown.mjs +49 -0
  60. package/lib/platforms/grok.mjs +14 -0
  61. package/lib/platforms/index.mjs +2 -1
  62. package/lib/policy/placement.mjs +2 -2
  63. package/lib/policy/render.mjs +1 -1
  64. package/lib/policy/role-policy.json +60 -15
  65. package/lib/prompts/agent-fragments.json +71 -1
  66. package/lib/prompts/render.mjs +7 -2
  67. package/lib/runtime/bootstrap.mjs +1 -1
  68. package/lib/runtime/grok-stream.mjs +46 -0
  69. package/lib/runtime/platform-registry.mjs +21 -0
  70. package/lib/runtime/role-bridge-args.mjs +40 -0
  71. package/lib/runtime/role-bridge.mjs +1 -1
  72. package/lib/runtime/role-dispatch-policy.mjs +4 -2
  73. package/lib/runtime/role-routing.mjs +2 -1
  74. package/lib/runtime/role-supervisor.mjs +57 -13
  75. package/lib/tui/app.mjs +18 -11
  76. package/lib/tui/custom-preset.mjs +6 -4
  77. package/lib/tui/mode.mjs +40 -5
  78. package/lib/tui/render.mjs +19 -8
  79. package/lib/tui/setup.mjs +53 -36
  80. package/lib/tui/terminal.mjs +1 -1
  81. package/lib/watch/status-line.mjs +10 -2
  82. package/package.json +2 -1
  83. package/scripts/update-manifest.mjs +2 -2
  84. package/shared/skill/references/superpowers-provenance.json +1 -1
  85. package/shared/skill/runtime/bootstrap.mjs +1 -1
  86. package/shared/skill/runtime/grok-stream.mjs +46 -0
  87. package/shared/skill/runtime/platform-registry.mjs +21 -0
  88. package/shared/skill/runtime/role-bridge-args.mjs +40 -0
  89. package/shared/skill/runtime/role-bridge.mjs +1 -1
  90. package/shared/skill/runtime/role-dispatch-policy.mjs +4 -2
  91. package/shared/skill/runtime/role-policy.json +60 -15
  92. package/shared/skill/runtime/role-routing.mjs +2 -1
  93. package/shared/skill/runtime/role-supervisor.mjs +57 -13
@@ -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);
@@ -1,9 +1,9 @@
1
1
  // Instruction placement only; runtime policy and role authority remain canonical.
2
2
  const reviews = ['review.significant-no-plan', 'review.significant-plan', 'review.final-plan-recheck'];
3
3
  export const POLICY_PROJECTIONS = Object.freeze(Object.fromEntries(Object.entries({
4
- core: ['scope.non-escalation', 'external.explicit-user-authority', 'role.orchestrator-boundary'],
4
+ core: ['scope.non-escalation', 'external.explicit-user-authority', 'approval.run-mode', 'role.orchestrator-boundary'],
5
5
  assignment: ['git.specialists-deny', 'role.scouter-read-only', 'role.planner-draft-only', 'role.implementer-implementation', 'role.qa-verification', 'role.reviewer-independent'],
6
- planning: ['git.orchestrator-accept-commit', ...reviews, 'planning.plan-revision', 'planning.planner-brief'],
6
+ planning: ['git.orchestrator-accept-commit', ...reviews, 'planning.plan-revision', 'planning.planner-brief', 'approval.run-mode'],
7
7
  handoff: ['git.specialists-deny', 'role.implementer-implementation', ...reviews],
8
8
  preparation: ['scope.non-escalation', 'git.specialists-deny', 'git.orchestrator-accept-commit', 'external.explicit-user-authority', 'planning.plan-revision'],
9
9
  verification: ['git.orchestrator-accept-commit', ...reviews, 'planning.plan-revision'],
@@ -20,7 +20,7 @@ export function validateRolePolicy(input) {
20
20
  if (!strings(rule.roles) || rule.roles.some(x=>!ROLES.includes(x)) || !['allow','deny','require'].includes(rule.effect) || !strings(rule.operations) || !strings(rule.evidence) || !['user','orchestrator'].includes(rule.authority) || typeof rule.text !== 'string' || !rule.text || /[\r\n]/.test(rule.text)) fail(`invalid rule ${rule.id}`);
21
21
  if (!object(rule.controls) || !same(Object.keys(rule.controls).sort(),[...platformIds()].sort()) || Object.values(rule.controls).some(x=>!CONTROLS.includes(x))) fail(`invalid control level for ${rule.id}`);
22
22
  }
23
- for (const id of ['scope.non-escalation','git.specialists-deny','git.orchestrator-accept-commit','external.explicit-user-authority',...ROLES.map(x=>({orchestrator:'role.orchestrator-boundary',scouter:'role.scouter-read-only',planner:'role.planner-draft-only',implementer:'role.implementer-implementation',qa:'role.qa-verification',reviewer:'role.reviewer-independent'})[x]),'review.significant-no-plan','review.significant-plan','review.final-plan-recheck']) if(!ids.has(id)) fail(`missing required rule ${id}`);
23
+ for (const id of ['scope.non-escalation','git.specialists-deny','git.orchestrator-accept-commit','external.explicit-user-authority','approval.run-mode',...ROLES.map(x=>({orchestrator:'role.orchestrator-boundary',scouter:'role.scouter-read-only',planner:'role.planner-draft-only',implementer:'role.implementer-implementation',qa:'role.qa-verification',reviewer:'role.reviewer-independent'})[x]),'review.significant-no-plan','review.significant-plan','review.final-plan-recheck']) if(!ids.has(id)) fail(`missing required rule ${id}`);
24
24
  for (const platform of POLICY_PLATFORMS) if (!object(input.platforms?.[platform]) || !CONTROLS.includes(input.platforms[platform].level) || typeof input.platforms[platform].notice !== 'string' || !input.platforms[platform].notice) fail(`invalid ${platform} controls`);
25
25
  // These are workflow invariants, not customizable scheduling options.
26
26
  const routes = {noPlan:['implementer','qa','reviewer','orchestrator-accept'],planTask:['implementer','fresh-qa','orchestrator-accept','orchestrator-commit'],planFinal:['required-qa','reviewer'],planFinding:['implementer','reviewer']};
@@ -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,34 @@
139
142
  "controls": {
140
143
  "codex": "prompt",
141
144
  "claude": "prompt",
142
- "gemini": "prompt"
145
+ "gemini": "prompt",
146
+ "grok": "prompt"
147
+ }
148
+ },
149
+ {
150
+ "id": "approval.run-mode",
151
+ "roles": [
152
+ "orchestrator",
153
+ "scouter",
154
+ "planner",
155
+ "implementer",
156
+ "qa",
157
+ "reviewer"
158
+ ],
159
+ "effect": "require",
160
+ "operations": [
161
+ "gate-decision"
162
+ ],
163
+ "evidence": [
164
+ "user-choice-or-recorded-full-auto-decision"
165
+ ],
166
+ "authority": "user",
167
+ "text": "The installed ARC Run mode is Supervised unless the installed skill states Full Auto. In Full Auto, an Orchestrator decision recorded as `auto-decided (Full Auto)` with gate, choice, reason and evidence counts as the explicit choice or approval for that listed gate only; briefs cite it as `full-auto:<doc>@<version>` or the recorded decision. It never authorizes new product decisions outside the original request, external actions, resolution of failures, holds, unknown state or ownership conflicts, preservation-rule Git actions, permission or sandbox changes, or unknown slots and exhausted capacity, and it changes no plan-depth, commit, QA, Reviewer or acceptance rule. A user request to stop or use Supervised applies from the next gate.",
168
+ "controls": {
169
+ "codex": "prompt",
170
+ "claude": "prompt",
171
+ "gemini": "prompt",
172
+ "grok": "prompt"
143
173
  }
144
174
  },
145
175
  {
@@ -160,7 +190,8 @@
160
190
  "controls": {
161
191
  "codex": "prompt",
162
192
  "claude": "prompt",
163
- "gemini": "prompt"
193
+ "gemini": "prompt",
194
+ "grok": "prompt"
164
195
  }
165
196
  },
166
197
  {
@@ -181,7 +212,8 @@
181
212
  "controls": {
182
213
  "codex": "prompt",
183
214
  "claude": "prompt",
184
- "gemini": "prompt"
215
+ "gemini": "prompt",
216
+ "grok": "prompt"
185
217
  }
186
218
  },
187
219
  {
@@ -202,7 +234,8 @@
202
234
  "controls": {
203
235
  "codex": "prompt",
204
236
  "claude": "prompt",
205
- "gemini": "prompt"
237
+ "gemini": "prompt",
238
+ "grok": "prompt"
206
239
  }
207
240
  },
208
241
  {
@@ -224,7 +257,8 @@
224
257
  "controls": {
225
258
  "codex": "prompt",
226
259
  "claude": "prompt",
227
- "gemini": "prompt"
260
+ "gemini": "prompt",
261
+ "grok": "prompt"
228
262
  }
229
263
  },
230
264
  {
@@ -247,7 +281,8 @@
247
281
  "controls": {
248
282
  "codex": "prompt",
249
283
  "claude": "prompt",
250
- "gemini": "prompt"
284
+ "gemini": "prompt",
285
+ "grok": "prompt"
251
286
  }
252
287
  },
253
288
  {
@@ -268,7 +303,8 @@
268
303
  "controls": {
269
304
  "codex": "prompt",
270
305
  "claude": "prompt",
271
- "gemini": "prompt"
306
+ "gemini": "prompt",
307
+ "grok": "prompt"
272
308
  }
273
309
  },
274
310
  {
@@ -294,7 +330,8 @@
294
330
  "controls": {
295
331
  "codex": "prompt",
296
332
  "claude": "prompt",
297
- "gemini": "prompt"
333
+ "gemini": "prompt",
334
+ "grok": "prompt"
298
335
  }
299
336
  },
300
337
  {
@@ -320,7 +357,8 @@
320
357
  "controls": {
321
358
  "codex": "prompt",
322
359
  "claude": "prompt",
323
- "gemini": "prompt"
360
+ "gemini": "prompt",
361
+ "grok": "prompt"
324
362
  }
325
363
  },
326
364
  {
@@ -345,7 +383,8 @@
345
383
  "controls": {
346
384
  "codex": "prompt",
347
385
  "claude": "prompt",
348
- "gemini": "prompt"
386
+ "gemini": "prompt",
387
+ "grok": "prompt"
349
388
  }
350
389
  },
351
390
  {
@@ -369,7 +408,8 @@
369
408
  "controls": {
370
409
  "codex": "prompt",
371
410
  "claude": "prompt",
372
- "gemini": "prompt"
411
+ "gemini": "prompt",
412
+ "grok": "prompt"
373
413
  }
374
414
  },
375
415
  {
@@ -392,7 +432,8 @@
392
432
  "controls": {
393
433
  "codex": "prompt",
394
434
  "claude": "prompt",
395
- "gemini": "prompt"
435
+ "gemini": "prompt",
436
+ "grok": "prompt"
396
437
  }
397
438
  }
398
439
  ],
@@ -408,6 +449,10 @@
408
449
  "gemini": {
409
450
  "level": "prompt",
410
451
  "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."
452
+ },
453
+ "grok": {
454
+ "level": "prompt",
455
+ "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
456
  }
412
457
  },
413
458
  "review": {
@@ -11,7 +11,7 @@
11
11
  },
12
12
  {
13
13
  "id": "common.preservation-choice-inspection",
14
- "text": "- **Preservation rule:** Preserve unrelated staged, unstaged and untracked changes and edit ownership. NEVER automatically stash, reset, clean, unstage, discard, amend or delete branches/worktrees. DO NOT change permissions, delete locks or bypass the sandbox to proceed. Stop and report to Orchestrator, who reports to the user.\n- **Explicit choice:** Only a clear user selection counts. Planning approval, silence, refusal of another option and ambiguous replies do not.\n- **Stop and inspect:** On failure or partial completion, stop dependent work. Record actual path, branch or detached HEAD, HEAD, index, files and completed steps. DO NOT automatically retry, fall back or repeat completed work. Revalidate affected gates after resolution."
14
+ "text": "- **Preservation rule:** Preserve unrelated staged, unstaged and untracked changes and edit ownership. NEVER automatically stash, reset, clean, unstage, discard, amend or delete branches/worktrees. DO NOT change permissions, delete locks or bypass the sandbox to proceed. Stop and report to Orchestrator, who reports to the user.\n- **Explicit choice:** Only a clear user selection counts, or a recorded Full Auto auto-decision under [approval.run-mode]. Planning approval, silence, refusal of another option and ambiguous replies do not.\n- **Stop and inspect:** On failure or partial completion, stop dependent work. Record actual path, branch or detached HEAD, HEAD, index, files and completed steps. DO NOT automatically retry, fall back or repeat completed work. Revalidate affected gates after resolution."
15
15
  },
16
16
  {
17
17
  "id": "common.optional-read-exception",
@@ -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;
@@ -137,7 +142,7 @@ export function validateAgentRegistry(registry) {
137
142
  const ids = new Set(Object.values(EXPECTED).flat());
138
143
  const fragments = new Map();
139
144
  for (const item of registry.fragments) {
140
- if (!keys(item, ['id', 'text']) || !ids.has(item.id) || fragments.has(item.id) || typeof item.text !== 'string' || !item.text || /ARC_AGENT_FRAGMENT|ARC_OUTPUT_LANGUAGE_POLICY|\[ARC role policy: contract (?:begin|end)\]/.test(item.text) || item.text.includes('\r')) throw Error('Invalid fragment');
145
+ if (!keys(item, ['id', 'text']) || !ids.has(item.id) || fragments.has(item.id) || typeof item.text !== 'string' || !item.text || /ARC_AGENT_FRAGMENT|ARC_OUTPUT_LANGUAGE_POLICY|ARC_RUN_MODE_POLICY|\[ARC role policy: contract (?:begin|end)\]/.test(item.text) || item.text.includes('\r')) throw Error('Invalid fragment');
141
146
  fragments.set(item.id, item.text);
142
147
  }
143
148
  if (fragments.size !== ids.size || registry.targets.length !== Object.keys(EXPECTED).length) throw Error('Incomplete fragment inventory');
@@ -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;
@@ -1,6 +1,7 @@
1
1
  // Pure helpers that turn an installed arc-routing profile into role-specific Claude/Codex CLI arguments. No processes are started here.
2
2
  import crypto from 'node:crypto';
3
3
  import path from 'node:path';
4
+ import {GROK_CONTRACT} from './grok-stream.mjs';
4
5
  import {GEMINI_CONTRACT} from './gemini-stream.mjs';
5
6
  import {DEFAULT_POLICY, effectiveClaudeSandboxSettings} from './role-dispatch-policy.mjs';
6
7
 
@@ -15,6 +16,13 @@ export const ROLE_BRIDGE_PERMISSIONS = deepFreeze({
15
16
  arc_scouter: {approvalMode: 'plan', sandbox: false}, arc_planner: {approvalMode: 'plan', sandbox: false},
16
17
  arc_implementer: {approvalMode: 'auto_edit', sandbox: true}, arc_qa: {approvalMode: 'auto_edit', sandbox: true}, arc_reviewer: {approvalMode: 'plan', sandbox: false}
17
18
  },
19
+ grok: {
20
+ arc_scouter: {permissionMode: 'plan', sandbox: 'read-only', deny: GROK_CONTRACT.readOnlyDeny},
21
+ arc_planner: {permissionMode: 'plan', sandbox: 'read-only', deny: GROK_CONTRACT.readOnlyDeny},
22
+ arc_reviewer: {permissionMode: 'plan', sandbox: 'read-only', deny: GROK_CONTRACT.readOnlyDeny},
23
+ arc_implementer: {permissionMode: 'acceptEdits', sandbox: 'workspace', deny: []},
24
+ arc_qa: {permissionMode: 'acceptEdits', sandbox: 'workspace', deny: []},
25
+ },
18
26
  codex: {
19
27
  arc_scouter: {sandboxMode: 'read-only', search: true}, arc_planner: {sandboxMode: 'read-only', search: false},
20
28
  arc_implementer: {sandboxMode: 'workspace-write', search: false}, arc_qa: {sandboxMode: 'workspace-write', search: false}, arc_reviewer: {sandboxMode: 'read-only', search: false}
@@ -25,6 +33,7 @@ const BRIDGE_IMPLEMENTATIONS = new Map([
25
33
  ['claude', {parse: parseClaude, buildArgs: buildClaudeArgs}],
26
34
  ['codex', {parse: parseCodex, buildArgs: buildCodexArgs}],
27
35
  ['gemini', {parse: parseGemini, buildArgs: buildGeminiArgs}],
36
+ ['grok', {parse: parseGrok, buildArgs: buildGrokArgs}],
28
37
  ]);
29
38
  export const BRIDGE_PLATFORM_IDS = Object.freeze([...BRIDGE_IMPLEMENTATIONS.keys()]);
30
39
 
@@ -79,6 +88,26 @@ function parseGemini(text) {
79
88
  return {name: fields.name, description: fields.description, model: fields.model, effort: 'default', tools: null, instructions: match[2].replaceAll('\r\n', '\n')};
80
89
  }
81
90
 
91
+ // ARC Grok metadata uses the same scalar grammar with an exact key set.
92
+ export function parseGrok(text) {
93
+ const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]+)$/.exec(text);
94
+ if (!match || !match[2].trim()) bad('missing Grok frontmatter or instructions');
95
+ const fields = {};
96
+ 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;
97
+ for (const line of match[1].split(/\r?\n/)) {
98
+ const entry = /^([a-z][a-zA-Z0-9_-]*): (.+)$/.exec(line);
99
+ if (!entry || Object.hasOwn(fields, entry[1])) bad('malformed or duplicate Grok field');
100
+ const value = entry[2];
101
+ if (value !== value.trim() || /[\p{Cc}\u2028\u2029{}#&*!|>"']/u.test(value)
102
+ || /^(?:[-?:](?:\s|$)|[\[\],%@`])/.test(value) || value.includes(': ') || nonStringScalar.test(value)) bad('unsupported Grok scalar');
103
+ fields[entry[1]] = value;
104
+ }
105
+ for (const key of ['name', 'description', 'model']) if (!fields[key]) bad(`missing ${key}`);
106
+ if (Object.keys(fields).length !== 3) bad('Grok fields must be exactly name, description, model');
107
+ if (!/^[A-Za-z0-9][A-Za-z0-9._:/@+\-]*$/.test(fields.model)) bad('invalid Grok model');
108
+ return {name: fields.name, description: fields.description, model: fields.model, effort: 'default', tools: null, instructions: match[2].replaceAll('\r\n', '\n')};
109
+ }
110
+
82
111
  const ESCAPES = {b: '\b', t: '\t', n: '\n', f: '\f', r: '\r', '"': '"', '\\': '\\'};
83
112
  // Decodes a TOML multiline basic string body; returns null when it is not terminated by """ on the same logical line.
84
113
  function readMultiline(lines, index, rest) {
@@ -201,3 +230,14 @@ export function buildGeminiArgs({role, model, profile, sessionId, policyFile, pr
201
230
  if (resume) args.push(GEMINI_CONTRACT.resumeFlag, sessionId);
202
231
  return args;
203
232
  }
233
+
234
+ export function buildGrokArgs({role, profile, sessionId, promptFile}) {
235
+ const permissions = permissionsFor('grok', role);
236
+ if (typeof promptFile !== 'string' || !path.isAbsolute(promptFile)) throw Error('Absolute promptFile required');
237
+ if (typeof sessionId !== 'string' || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(sessionId)) throw Error('Grok sessionId must be a UUID');
238
+ const model = requireText(profile?.model, 'model');
239
+ if (!/^[A-Za-z0-9][A-Za-z0-9._:/@+\-]*$/.test(model)) throw Error('Invalid Grok model');
240
+ return ['--prompt-file', promptFile, '--output-format', GROK_CONTRACT.outputFormat, '-m', model, '--session-id', sessionId,
241
+ '--permission-mode', permissions.permissionMode, '--sandbox', permissions.sandbox,
242
+ ...permissions.deny.flatMap(rule => ['--deny', rule]), ...GROK_CONTRACT.isolationArgs];
243
+ }
@@ -143,7 +143,7 @@ export async function resumeRoleDispatch({context,dispatchId,brief,now=Date.now(
143
143
  const lease=await readLease(anchorHome,dispatchId,{runtimePlatforms});
144
144
  if(!lease||lease.workflowId!==context.workflowId||lease.hostPlatform!==context.hostPlatform||lease.route!=='bridge'||!['completed','failed'].includes(lease.state)){result=blank(context,dispatchId,'deny','invalid_request');return;}
145
145
  const targetPlatform=leaseTargetPlatform(lease,runtimePlatforms);
146
- if(targetPlatform==='gemini'&&!['on','verified'].includes(supervisorImplementations.get(targetPlatform)?.resume)){result=blank(context,dispatchId,'hold','resume_unverified');return;}
146
+ if((targetPlatform==='gemini'||targetPlatform==='grok')&&!['on','verified'].includes(supervisorImplementations.get(targetPlatform)?.resume)){result=blank(context,dispatchId,'hold','resume_unverified');return;}
147
147
  if(!lease.sessionId){result=blank(context,dispatchId,'hold','execution_identity_unverified');return;}
148
148
  let config;
149
149
  try{config=await readActivation(homes,lease.revision,{anchorHome,host:context.hostPlatform,runtimePlatforms});}
@@ -1,6 +1,6 @@
1
1
  import {runtimeRegistryOf} from './platform-registry.mjs';
2
2
  // Fixed policy values for composite role dispatch. G2 'escalation' means the bridge runs only with per-call user escalation approval on a Codex host; it is not a verified pass.
3
- export const BRIDGE_GATE_RESULTS = Object.freeze({G1: 'fail', G2: 'escalation', G3: 'pass', G4: 'pass', G5: 'wide', G6: 'strict', G7: 'pass', G8: 'pass', GG1: 'fail', GG2: 'fail'});
3
+ export const BRIDGE_GATE_RESULTS = Object.freeze({G1: 'fail', G2: 'escalation', G3: 'pass', G4: 'pass', G5: 'wide', G6: 'strict', G7: 'pass', G8: 'pass', GG1: 'fail', GG2: 'fail', GK1: 'fail', GK2: 'fail'});
4
4
  // No sandbox settings JSON has been recorded: G1 failed, so there is nothing to apply.
5
5
  const RECORDED_CLAUDE_SANDBOX_SETTINGS = null;
6
6
  const isRecordedObject = value => value !== null && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length > 0;
@@ -41,7 +41,7 @@ export const DEFAULT_POLICY = Object.freeze({
41
41
 
42
42
  export const RELEASE_CONDITIONS = Object.freeze({
43
43
  activation_unverified: 'Verify the active configuration, all prepared markers, installed bytes, host limits and the shared lock, and inspect the lease records in <anchor home>/arc-role-dispatch for unreadable or corrupted files.',
44
- resume_unverified: 'Update ARC after verifying Gemini session resume against the recorded session UUID.',
44
+ resume_unverified: 'Update ARC after verifying platform session resume against the recorded session UUID.',
45
45
  capability_not_verified: 'Update ARC to a release that verifies this platform capability.',
46
46
  'Not Available': 'Install the target platform CLI so that it is found on PATH.',
47
47
  Unauthorized: 'Authenticate the target platform CLI.',
@@ -87,6 +87,8 @@ export function bridgeGateReasons({platform, role, hostPlatform, policy = DEFAUL
87
87
  const gates = policy.gates ?? BRIDGE_GATE_RESULTS, codes = [];
88
88
  if (platform === 'claude' && (role === 'arc_implementer' || role === 'arc_qa') && effectiveClaudeSandboxSettings({gates, claudeSandboxSettings: policy.claudeSandboxSettings}) === null) codes.push('permission_scope_unverified');
89
89
  if (platform === 'gemini' && (role === 'arc_implementer' || role === 'arc_qa') && gates.GG1 !== 'pass') codes.push('permission_scope_unverified');
90
+ if (platform === 'grok' && (role === 'arc_implementer' || role === 'arc_qa') && gates.GK1 !== 'pass') codes.push('permission_scope_unverified');
91
+ if (hostPlatform === 'grok' && gates.GK2 !== 'pass') codes.push('host_sandbox_blocked');
90
92
  if (hostPlatform === 'gemini' && gates.GG2 !== 'pass') codes.push('host_sandbox_blocked');
91
93
  if (platform === 'codex' && gates.G4 === 'fail') codes.push('permission_scope_unverified');
92
94
  if (hostPlatform === 'codex' && gates.G2 === 'fail') codes.push('host_sandbox_blocked');
@@ -231,6 +231,7 @@ export async function prepareRoleDispatch({context,assignment,expectedRevision,n
231
231
  const leases=await listLeases(anchorHome,{runtimePlatforms});
232
232
  const live=leases.filter(lease=>NON_TERMINAL_STATES.includes(lease.state));
233
233
  if(leases.some(lease=>lease.requestId===assignment.requestId)||live.some(lease=>lease.workflowId===context.workflowId&&lease.taskId===assignment.taskId&&lease.role===role)){duplicate=true;codes.add('duplicate_dispatch');}
234
+ if(host==='grok'&&(policy.gates?.GK2??DEFAULT_POLICY.gates.GK2)!=='pass')codes.add('host_sandbox_blocked');
234
235
  if(host==='gemini'&&(policy.gates?.GG2??DEFAULT_POLICY.gates.GG2)!=='pass')codes.add('host_sandbox_blocked');
235
236
  if(route==='bridge'){
236
237
  let limits;try{limits=readHostLimits(resolveConfigHome(host,context));}catch{codes.add('activation_unverified');}
@@ -243,7 +244,7 @@ export async function prepareRoleDispatch({context,assignment,expectedRevision,n
243
244
  result.reasons=[...codes].map(reason);
244
245
  if(codes.size){result.decision=duplicate?'deny':'hold';return;}
245
246
  const claims=initialClaims(route,policy,requested),iso=new Date(now).toISOString(),dispatchId=crypto.randomUUID();
246
- const lease=await createLease(anchorHome,{version:2,targetPlatform:route==='native'?host:requested.platform,dispatchId,workflowId:context.workflowId,taskId:assignment.taskId,requestId:assignment.requestId,role,route,hostPlatform:host,executionEnvironment:environment,revision:config.revision,profileHash:await readProfileHash(homes[requested.platform],role),argsDigest:null,state:'reserved',supervisor:null,child:null,sessionId:route==='bridge'&&requested.platform==='gemini'?crypto.randomUUID():null,timeoutMinutes:policy.roleTimeoutMinutes[role],claims,reasons:[],allowedPaths:assignment.allowedPaths??[],resultPath:null,segment:0,nativeAgentId:null,createdAt:iso,updatedAt:iso},{runtimePlatforms,config});
247
+ const lease=await createLease(anchorHome,{version:2,targetPlatform:route==='native'?host:requested.platform,dispatchId,workflowId:context.workflowId,taskId:assignment.taskId,requestId:assignment.requestId,role,route,hostPlatform:host,executionEnvironment:environment,revision:config.revision,profileHash:await readProfileHash(homes[requested.platform],role),argsDigest:null,state:'reserved',supervisor:null,child:null,sessionId:route==='bridge'&&(requested.platform==='gemini'||requested.platform==='grok')?crypto.randomUUID():null,timeoutMinutes:policy.roleTimeoutMinutes[role],claims,reasons:[],allowedPaths:assignment.allowedPaths??[],resultPath:null,segment:0,nativeAgentId:null,createdAt:iso,updatedAt:iso},{runtimePlatforms,config});
247
248
  Object.assign(result,{decision:'allow',routeStatus:'reserved',dispatchId:lease.dispatchId,claims});
248
249
  },{retryMs:policy.lockRetryMs});
249
250
  }catch(error){