@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
@@ -1,13 +1,61 @@
1
1
  import {parseToml} from '../models/config.mjs';
2
2
  const MARKER='{{ARC_OUTPUT_LANGUAGE_POLICY}}';
3
+ const RUN_MODE_MARKER = '{{ARC_RUN_MODE_POLICY}}';
4
+ export const RUN_MODES = Object.freeze(['supervised', 'full-auto']);
5
+
3
6
  export function validateLanguage(language){if(!['en','ko'].includes(language))throw new Error(`Invalid language: ${language}`);return language;}
4
- export function parseLanguage(bytes){
5
- if(!Buffer.isBuffer(bytes))throw new Error('Language settings must be bytes');
6
- const data=parseToml(new TextDecoder('utf-8',{fatal:true,ignoreBOM:true}).decode(bytes));
7
- if(Object.keys(data).length!==2||!Object.hasOwn(data,'version')||!Object.hasOwn(data,'language')||data.version!==1n&&data.version!==1)throw new Error('Invalid language settings schema or version');
8
- return{version:1,language:validateLanguage(data.language)};
7
+
8
+ export function validateRunMode(value) {
9
+ if (!RUN_MODES.includes(value)) throw new Error(`Invalid run mode: ${String(value)}`);
10
+ return value;
9
11
  }
10
- export function serializeLanguage(language){return Buffer.from(`version = 1\nlanguage = "${validateLanguage(language)}"\n`);}
12
+
13
+ export function parseSettings(bytes) {
14
+ if (!Buffer.isBuffer(bytes)) throw new Error('Language settings must be bytes');
15
+ const data = parseToml(new TextDecoder('utf-8', {fatal: true, ignoreBOM: true}).decode(bytes));
16
+ const keyCount = Object.keys(data).length;
17
+ const isV1 = (data.version === 1 || data.version === 1n) && keyCount === 2;
18
+ const isV2 = (data.version === 2 || data.version === 2n) && keyCount === 3 && Object.hasOwn(data, 'run_mode');
19
+ if (!Object.hasOwn(data, 'version') || !Object.hasOwn(data, 'language') || (!isV1 && !isV2)) {
20
+ throw new Error('Invalid ARC settings schema or version');
21
+ }
22
+ return {
23
+ version: isV1 ? 1 : 2,
24
+ language: validateLanguage(data.language),
25
+ runMode: isV1 ? 'supervised' : validateRunMode(data.run_mode),
26
+ };
27
+ }
28
+
29
+ export function serializeSettings({language, runMode = 'supervised'}) {
30
+ const validatedLanguage = validateLanguage(language);
31
+ if (validateRunMode(runMode) === 'supervised') {
32
+ return Buffer.from(`version = 1\nlanguage = "${validatedLanguage}"\n`);
33
+ }
34
+ return Buffer.from(`version = 2\nlanguage = "${validatedLanguage}"\nrun_mode = "full-auto"\n`);
35
+ }
36
+
37
+ export function parseLanguage(bytes) {
38
+ const {version, language} = parseSettings(bytes);
39
+ return {version, language};
40
+ }
41
+
42
+ export function serializeLanguage(language) {
43
+ return serializeSettings({language});
44
+ }
45
+
11
46
  export function defaultLanguage(existing){return existing.length&&existing.every(value=>value===existing[0])&&existing[0]?validateLanguage(existing[0]):'en';}
12
47
  export function languagePolicy(language){return `Use ${validateLanguage(language)==='ko'?'Korean':'English'} by default for user-facing responses, progress updates, reports, and document titles and prose, including designs, specs, and plans. An explicit user language request overrides this installed default. Preserve identifiers, skill/API names, code, paths, commands, and literal values exactly.`;}
13
48
  export function renderLanguagePolicy(bytes,language){const text=new TextDecoder('utf-8',{fatal:true}).decode(bytes);if(text.split(MARKER).length!==2)throw new Error('Expected exactly one ARC output language policy marker');return Buffer.from(text.replace(MARKER,languagePolicy(language)));}
49
+
50
+ export function runModePolicy(runMode) {
51
+ if (validateRunMode(runMode) === 'supervised') {
52
+ return "**Run mode:** Supervised. Every approval and choice gate in this skill and its references requires the user's explicit answer; Orchestrator does not auto-decide gates.";
53
+ }
54
+ return "**Run mode:** Full Auto. Orchestrator decides the gates listed in [planning](references/planning.md#full-auto-run-mode) itself: it completes that gate's required checks first, then chooses the recommended option; without a recommendation and supporting evidence, it asks the user. New product decisions outside the original request, external actions, failures, partial completion, holds, unknown state, ownership conflicts, preservation-rule Git actions, permission or sandbox approvals, and unknown slots or exhausted capacity still go to the user. Plan depth, local commit rules, QA, Reviewer and acceptance are unchanged. Record each decision as `auto-decided (Full Auto): <gate> → <choice>; reason; alternatives; evidence` in a user-visible progress message and in the canonical handoff record. If the user asks in this chat to stop auto-deciding or to use Supervised, apply Supervised from the next gate; this overrides the installed default, and earlier auto-decisions stay recorded.";
55
+ }
56
+
57
+ export function renderRunModePolicy(bytes, runMode) {
58
+ const text = new TextDecoder('utf-8', {fatal: true}).decode(bytes);
59
+ if (text.split(RUN_MODE_MARKER).length !== 2) throw new Error('Expected exactly one ARC run mode policy marker');
60
+ return Buffer.from(text.replace(RUN_MODE_MARKER, runModePolicy(runMode)));
61
+ }
@@ -3,7 +3,7 @@ import {installerRegistryOf} from '../platforms/index.mjs';
3
3
  import {renderAgentProfile} from '../prompts/render.mjs';
4
4
  import {PayloadValidationError} from './manifest.mjs';
5
5
  import {composeSkillSources} from './skill-sources.mjs';
6
- import{parseLanguage,serializeLanguage,renderLanguagePolicy,validateLanguage}from'./language.mjs';
6
+ import{parseSettings,serializeSettings,renderLanguagePolicy,renderRunModePolicy,validateLanguage,validateRunMode}from'./language.mjs';
7
7
  import{resolveLimits}from'../limits.mjs';import{parseLimits,serializeLimits}from'./limits.mjs';import{assertPlanSnapshot}from'./transaction.mjs';
8
8
  import{validateModelConfig}from'../models/config.mjs';
9
9
  import{assertCatalogRoles}from'../models/catalog.mjs';
@@ -18,8 +18,8 @@ export function previewLimits({target,safeFs}){
18
18
  export function previewLanguage({target,safeFs}){
19
19
  const snapshot=new Map(),filename=path.join(target.home,'skills/arc/settings.toml');
20
20
  const current=inspectPath(safeFs,filename,{kind:'file',read:true,snapshot});
21
- let existing=null;try{if(current.exists)existing=parseLanguage(current.bytes).language;}catch(cause){fail(`Invalid ARC language settings: ${cause.message}`);}
22
- return{existing,snapshot};
21
+ let settings;try{if(current.exists)settings=parseSettings(current.bytes);}catch(cause){fail(`Invalid ARC language settings: ${cause.message}`);}
22
+ return{existing:settings?.language??null,existingRunMode:settings?.runMode??null,snapshot};
23
23
  }
24
24
  function renderModelAssets({payload,target,roles,modelConfig,language,verifiedCatalog,platforms,runtimePlatforms}){
25
25
  const input=payload.modelInputs[target.platform];if(!input)fail('Selected payload platform is unavailable');
@@ -30,45 +30,51 @@ function renderModelAssets({payload,target,roles,modelConfig,language,verifiedCa
30
30
  return{profiles,modelBytes};
31
31
  }
32
32
  export function renderStandaloneProfiles({payload,target,modelConfig,language,platforms,runtimePlatforms}){return renderModelAssets({payload,target,modelConfig,language,platforms,runtimePlatforms}).profiles;}
33
- function renderSkillPayload({payload,target,language,modelBytes,limits,platforms}){
33
+ function renderSkillPayload({payload,target,language,runMode,modelBytes,limits,platforms}){
34
34
  let skill;try{skill=composeSkillSources(payload.files,target.platform,{platforms});}catch(cause){throw new PayloadValidationError(`Payload skill composition failed: ${cause.message}`,{cause});}
35
- skill.set('SKILL.md',renderLanguagePolicy(skill.get('SKILL.md'),language));skill.set('settings.toml',serializeLanguage(language));skill.set('models.toml',modelBytes);skill.set('limits.toml',serializeLimits(limits));
35
+ skill.set('SKILL.md',renderRunModePolicy(renderLanguagePolicy(skill.get('SKILL.md'),language),runMode));
36
+ skill.set('settings.toml',serializeSettings({language,runMode}));skill.set('models.toml',modelBytes);skill.set('limits.toml',serializeLimits(limits));
36
37
  return skill;
37
38
  }
38
- function renderNativeChanges({target,safeFs,snapshot,skipGlobal,preview,concurrentExplicit,limits,summary,language,platforms}){
39
+ function renderNativeChanges({target,safeFs,snapshot,skipGlobal,preview,concurrentExplicit,limits,summary,language,runMode,platforms}){
39
40
  const home=target.home;
40
41
  const globalChanges=[];
41
42
  if(limits.max_concurrent_subagents>limits.max_total_subagents)summary.push(`Effective concurrency is at most ${limits.max_total_subagents} for a fresh ARC session; it may be lower after cumulative use or due to native capacity.`);
42
- if(skipGlobal)summary.push('Native concurrency update skipped (--skip-global).');
43
+ const runtimeConfig=installerRegistryOf({platforms}).getPlatform(target.platform).runtimeConfig;
44
+ if(skipGlobal){summary.push('Native concurrency update skipped (--skip-global).');if(typeof runtimeConfig.globalRender==='function')summary.push(`${target.runtimeConfigPath}: compatibility settings update skipped (--skip-global).`);}
43
45
  else for(const filename of target.globalPaths){
44
- if(filename!==target.instructionPath&&!installerRegistryOf({platforms}).getPlatform(target.platform).runtimeConfig.renderConcurrency)continue;
46
+ if(filename!==target.instructionPath&&!runtimeConfig.renderConcurrency&&typeof runtimeConfig.globalRender!=='function')continue;
45
47
  const current=inspectPath(safeFs,filename,{kind:'file',read:true,snapshot}),original=current.bytes??null;
46
48
  let rendered;
47
- if(filename===target.instructionPath)rendered=renderManagedBlock(original,agentsBlockBody(home,target.userHome,language,target.platform));
49
+ if(filename===target.instructionPath)rendered=renderManagedBlock(original,agentsBlockBody(home,target.userHome,language,target.platform,runMode));
48
50
  else{
49
- const runtimeConfig=installerRegistryOf({platforms}).getPlatform(target.platform).runtimeConfig;
51
+ if(typeof runtimeConfig.globalRender==='function'){
52
+ try{rendered=runtimeConfig.globalRender(original);}catch(cause){fail(`Cannot update ${filename}: ${cause.message}; fix it or use --skip-global`);}
53
+ }else{
50
54
  let previous;try{previous=runtimeConfig.readConcurrency(original);}catch(cause){fail(`Invalid native configuration: ${cause.message}`);}
51
55
  if(preview.existing&&previous!==null&&previous!==preview.existing.max_concurrent_subagents&&!concurrentExplicit)fail(`Native concurrency drift at ${filename}; explicitly select --max-concurrent-subagents to update it`);
52
56
  let base=original;if(runtimeConfig.extraRender){const extra=runtimeConfig.extraRender(original);base=extra.content??original;if(extra.content===null)summary.push(`${filename}: ${extra.action}`);}
53
57
  try{rendered=runtimeConfig.renderConcurrency(base,limits.max_concurrent_subagents);}catch(cause){fail(`Cannot merge native concurrency: ${cause.message}`);}
54
58
  summary.push(`${filename}: native concurrency ${previous??'missing'} -> ${limits.max_concurrent_subagents}`);
59
+ }
55
60
  }
56
61
  if(rendered.content!==null&&(original===null||!rendered.content.equals(original)))globalChanges.push({path:filename,original,content:rendered.content,action:rendered.action});
57
62
  for(const note of rendered.notes??[])summary.push(`${filename}: ${note}`);
58
63
  }
59
64
  return globalChanges;
60
65
  }
61
- export function buildInstallPlan({payload,target,roles,profiles:profileMode='write',skipGlobal=false,safeFs,limits,concurrentExplicit=false,limitsPreview,language='en',languagePreview,modelConfig,verifiedCatalog,platforms,runtimePlatforms}){
66
+ export function buildInstallPlan({payload,target,roles,profiles:profileMode='write',skipGlobal=false,safeFs,limits,concurrentExplicit=false,limitsPreview,language='en',languagePreview,runMode,modelConfig,verifiedCatalog,platforms,runtimePlatforms}){
62
67
  validateLanguage(language);
63
68
  if(languagePreview)assertPlanSnapshot({snapshot:languagePreview.snapshot},{safeFs});
64
69
  const languageState=languagePreview??previewLanguage({target,safeFs});
70
+ runMode=runMode!==undefined?validateRunMode(runMode):languageState.existingRunMode??'supervised';
65
71
  if(limitsPreview)assertPlanSnapshot({snapshot:limitsPreview.snapshot},{safeFs});
66
72
  const preview=limitsPreview??previewLimits({target,safeFs});
67
73
  limits=resolveLimits({existing:preview.existing,overrides:limits??{}});
68
74
  const modelSnapshot=new Map();
69
75
  if(modelConfig===undefined&&roles===undefined){const installed=inspectPath(safeFs,path.join(target.home,'skills/arc/models.toml'),{kind:'file',read:true,snapshot:modelSnapshot});if(installed.exists)modelConfig=loadModelConfig(installed.bytes,target.platform,{runtimePlatforms});}
70
76
  const {profiles,modelBytes}=renderModelAssets({payload,target,roles,modelConfig,language,verifiedCatalog,platforms,runtimePlatforms});
71
- const skill=renderSkillPayload({payload,target,language,modelBytes,limits,platforms});
77
+ const skill=renderSkillPayload({payload,target,language,runMode,modelBytes,limits,platforms});
72
78
  const snapshot=new Map(),home=target.home;const skills=path.join(home,'skills'),agents=path.join(home,'agents'),arc=path.join(skills,'arc');
73
79
  for(const name of [home,skills,agents])inspectPath(safeFs,name,{kind:'directory',snapshot});
74
80
  inspectPath(safeFs,arc,{kind:'directory',tree:true,allowLinks:true,snapshot});
@@ -76,13 +82,13 @@ export function buildInstallPlan({payload,target,roles,profiles:profileMode='wri
76
82
  if(profileMode!=='omit')for(const [name,bytes]of profiles){const found=inspectStandaloneProfile({safeFs,target,role:name.split('.')[0].replace('-','_'),snapshot,platforms});if(found.exists&&!found.owned){residualPaths.push(found.path);continue;}profilePaths.push(found.path);profileWrites.set(name,bytes);}
77
83
  const externalPaths=[],summary=['Verified packaged Superpowers references will be installed inside ARC'];
78
84
  summary.push(`ARC limits: total ${limits.max_total_subagents}; concurrent ${limits.max_concurrent_subagents} (policy: ${arc}/limits.toml)`);
79
- const globalChanges=renderNativeChanges({target,safeFs,snapshot,skipGlobal,preview,concurrentExplicit,limits,summary,language,platforms});
85
+ const globalChanges=renderNativeChanges({target,safeFs,snapshot,skipGlobal,preview,concurrentExplicit,limits,summary,language,runMode,platforms});
80
86
  const managedPaths=[arc,...profilePaths,...globalChanges.map(change=>change.path)];
81
87
  for(const [filename,metadata]of preview.snapshot)snapshot.set(filename,metadata);
82
88
  for(const [filename,metadata]of languageState.snapshot)snapshot.set(filename,metadata);
83
89
  summary.push(`ARC output language: ${language}`);
84
90
  for(const item of modelSnapshot)snapshot.set(...item);
85
- const plan={target,language,roles,skipGlobal,limits,concurrentExplicit,profileWrites,residualPaths,generated:{models:modelBytes,profiles,skill},globalChanges,managedPaths,externalPaths,snapshot,summary};validatePlanSet([plan]);return plan;
91
+ const plan={target,language,runMode,roles,skipGlobal,limits,concurrentExplicit,profileWrites,residualPaths,generated:{models:modelBytes,profiles,skill},globalChanges,managedPaths,externalPaths,snapshot,summary};validatePlanSet([plan]);return plan;
86
92
  }
87
93
  function overlaps(a,b){return a===b||a.startsWith(b+'/')||b.startsWith(a+'/');}
88
94
  export function validatePlanSet(plans){
@@ -17,6 +17,7 @@ export const RUNTIME_MODULE_PATHS = Object.freeze([
17
17
  'lib/runtime/gemini-stream.mjs',
18
18
  'lib/runtime/git-evidence.mjs',
19
19
  'lib/runtime/git-query.mjs',
20
+ 'lib/runtime/grok-stream.mjs',
20
21
  'lib/runtime/identity.mjs',
21
22
  'lib/runtime/local-cli.mjs',
22
23
  'lib/runtime/operations.mjs',
@@ -19,9 +19,22 @@ export function buildUninstallPlan({target,safeFs,skipGlobal=false,removeComplet
19
19
  }
20
20
  for(const skill of linkedSkills){const root=arc+'/references/superpowers/'+skill,directory=safeFs.openRoot(root);try{if(!sameIdentity(snapshot.get(root),directory.stat()))throw new TargetConfigurationError('Removal reference root changed');snapshotSkill(directory,root,[]);}finally{directory.close();}}
21
21
  if(!skipGlobal){const filename=target.instructionPath??target.globalPaths[0],found=inspectPath(safeFs,filename,{kind:'file',read:true,snapshot});managedPaths.push(filename);if(found.exists){const removed=removeManagedBlock(found.bytes);if(removed.changed)globalChanges.push({path:filename,content:removed.content});}}
22
+ const {runtimeConfig,uninstallSummary}=installerRegistryOf({platforms}).getPlatform(target.platform),summary=[uninstallSummary];
23
+ if(typeof runtimeConfig.globalRemove==='function'){
24
+ const filename=target.runtimeConfigPath;
25
+ if(skipGlobal)summary.push(`${filename}: compatibility settings not restored (--skip-global).`);
26
+ else{
27
+ const found=inspectPath(safeFs,filename,{kind:'file',read:true,snapshot});
28
+ if(found.exists){
29
+ let removed;
30
+ try{removed=runtimeConfig.globalRemove(found.bytes);}catch(cause){summary.push(`${filename}: ARC-managed [compat.claude] lines were not restored (${cause.message}); remove lines marked # arc:managed manually`);}
31
+ if(removed?.content!==null&&removed!==undefined){managedPaths.push(filename);globalChanges.push({path:filename,content:removed.content});for(const note of removed.notes??[])summary.push(`${filename}: ${note}`);}
32
+ }
33
+ }
34
+ }
22
35
  const composite=inspectCompositeRemoval({target,safeFs,activeConfigPath:compositeActivePath,snapshot,runtimePlatforms});
23
36
  removals.push(...composite.removals);managedPaths.push(...composite.removals);
24
- const plan={target,skipGlobal,snapshot,removals,managedPaths,externalPaths:[],globalChanges,compositeOwned:composite.removals.length>0,compositeResidual:[...standaloneResidual,...composite.residualPaths],summary:[installerRegistryOf({platforms}).getPlatform(target.platform).uninstallSummary]};
37
+ const plan={target,skipGlobal,snapshot,removals,managedPaths,externalPaths:[],globalChanges,compositeOwned:composite.removals.length>0,compositeResidual:[...standaloneResidual,...composite.residualPaths],summary};
25
38
  if(removeCompletion)attachShellCompletionCleanup([plan],{safeFs});return plan;
26
39
  }
27
40
  import {assertPlanSnapshot,applyUninstallTransaction} from './transaction.mjs';
@@ -4,7 +4,7 @@ import path from 'node:path';
4
4
  import {createHash} from 'node:crypto';
5
5
  import {resolveTargets,inspectPath,TargetConfigurationError} from './targets.mjs';
6
6
  import {loadModelConfig} from '../models/index.mjs';
7
- import {parseLanguage} from './language.mjs';
7
+ import {parseSettings} from './language.mjs';
8
8
  import {parseLimits} from './limits.mjs';
9
9
  import {removeManagedBlock} from './global-config.mjs';
10
10
  import {removeShellCompletion} from './shell-completion.mjs';
@@ -15,6 +15,7 @@ export function collectInstalledState({safeFs,userHome,env={},cwd,platforms,runt
15
15
  const resolved=resolveTargets({userHome,env,cwd,platforms}),modeSnapshot=new Map(),installation=readInstallMode({safeFs,...resolved,snapshot:modeSnapshot,platforms}),mode=installation.mode,targets=[],residualPaths=[];
16
16
  if(resolved.unresolved.some(({platform})=>installation.platforms.includes(platform)))fail('Mixed routing configuration cannot be verified.');
17
17
  for(const platform of ids){
18
+ if(registry.getPlatform(platform).runtime.capabilities.install.state!=='verified')continue;
18
19
  const target=resolved.targets[platform];if(!target)continue;
19
20
  const snapshot=new Map(),arc=path.join(target.home,'skills/arc');
20
21
  const skill=inspectPath(safeFs,arc,{kind:'directory',tree:true,allowLinks:true,snapshot});
@@ -23,13 +24,21 @@ export function collectInstalledState({safeFs,userHome,env={},cwd,platforms,runt
23
24
  if(!skill.exists){if(profiles.some(item=>item.exists&&item.owned)||managed.changed)fail(`Incomplete ARC installation: ${target.home}`);residualPaths.push(...profiles.filter(item=>item.exists&&!item.owned).map(item=>item.path));continue;}
24
25
  function mandatory(name){const found=inspectPath(safeFs,path.join(arc,name),{kind:'file',read:true,snapshot});if(!found.exists||!found.bytes.length)fail(`Incomplete ARC installation: missing ${name} at ${target.home}`);return found.bytes;}
25
26
  mandatory('SKILL.md');if(profiles.some(item=>!item.exists))fail(`Incomplete ARC installation: missing profile at ${target.home}`);
26
- let language,modelConfig,limits;try{language=parseLanguage(mandatory('settings.toml')).language;modelConfig=loadModelConfig(mandatory('models.toml'),platform,{runtimePlatforms});limits=parseLimits(mandatory('limits.toml'));}catch(cause){throw new TargetConfigurationError(`Invalid installed ARC settings at ${target.home}: ${cause.message}`,{cause});}
27
+ let language,runMode,modelConfig,limits;
28
+ try{
29
+ const parsed=parseSettings(mandatory('settings.toml'));
30
+ language=parsed.language;
31
+ runMode=parsed.runMode;
32
+ modelConfig=loadModelConfig(mandatory('models.toml'),platform,{runtimePlatforms});
33
+ limits=parseLimits(mandatory('limits.toml'));
34
+ }catch(cause){throw new TargetConfigurationError(`Invalid installed ARC settings at ${target.home}: ${cause.message}`,{cause});}
27
35
  const runtimeConfig=registry.getPlatform(platform).runtimeConfig;
28
36
  if(typeof runtimeConfig.readConcurrency==='function'){const native=inspectPath(safeFs,target.runtimeConfigPath,{kind:'file',read:true,snapshot});if(native.exists)try{runtimeConfig.readConcurrency(native.bytes);}catch(cause){throw new TargetConfigurationError(`Invalid native configuration at ${target.runtimeConfigPath}: ${cause.message}`,{cause});}}
29
37
  const shell=inspectPath(safeFs,path.join(userHome,'.zshrc'),{kind:'file',read:true,snapshot});if(shell.exists)removeShellCompletion(shell.bytes);
30
- if(mode==='composite')for(const [filename,value]of modeSnapshot)if(value)snapshot.set(filename,value);
38
+ const modeKeys=new Set();
39
+ if(mode==='composite')for(const [filename,value]of modeSnapshot)if(value){snapshot.set(filename,value);modeKeys.add(filename);}
31
40
  for(const [filename,value]of snapshot)if(!value)snapshot.delete(filename);
32
- targets.push({target,language,modelConfig,limits,snapshot,residualPaths:profiles.filter(item=>item.exists&&!item.owned).map(item=>item.path)});
41
+ targets.push({target,language,runMode,modelConfig,limits,snapshot,modeKeys,residualPaths:profiles.filter(item=>item.exists&&!item.owned).map(item=>item.path)});
33
42
  }
34
43
  const hash=createHash('sha256');for(const entry of targets){hash.update(entry.target.platform+'\0'+entry.target.home+'\0');for(const [name,value]of [...entry.snapshot].sort(([a],[b])=>a.localeCompare(b)))hash.update(JSON.stringify([name,value],(key,value)=>key==='atimeNs'?undefined:typeof value==='bigint'?value.toString():value));}
35
44
  return{targets,mode,platforms:installation.platforms,registry,residualPaths,stateToken:hash.digest('hex')};
@@ -7,17 +7,22 @@ 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});
13
14
  const plans=state.targets.map(entry=>{
14
- const {target,language,modelConfig,limits}=entry;
15
- const plan=buildInstallPlan({payload,target,profiles:state.mode==='composite'&&state.platforms.includes(target.platform)?'omit':'write',language,modelConfig,limits,skipGlobal:true,safeFs,platforms,runtimePlatforms});
15
+ const {target,language,runMode,modelConfig,limits}=entry;
16
+ const plan=buildInstallPlan({payload,target,profiles:state.mode==='composite'&&state.platforms.includes(target.platform)?'omit':'write',language,runMode,modelConfig,limits,skipGlobal:true,safeFs,platforms,runtimePlatforms});
16
17
  for(const [name,value]of entry.snapshot)plan.snapshot.set(name,value);
17
18
  const current=inspectPath(safeFs,target.instructionPath,{kind:'file',read:true,snapshot:plan.snapshot});
18
- 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
+ if(current.exists&&removeManagedBlock(current.bytes).changed){const rendered=renderManagedBlock(current.bytes,agentsBlockBody(target.home,target.userHome,language,target.platform,runMode));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
  }
@@ -21,7 +21,7 @@ import {prepareCompositeFiles,publishCompositeFiles,readCompositeRoutingConfig,p
21
21
  import {inspectPath,sameObjectIdentity,TargetConfigurationError} from '../installer/targets.mjs';
22
22
  import {assertPlanSnapshot} from '../installer/transaction.mjs';
23
23
  import {acquireRoleRoutingLock} from '../runtime/role-routing.mjs';
24
- import {parseLanguage} from '../installer/language.mjs';
24
+ import {parseSettings} from '../installer/language.mjs';
25
25
  import path from 'node:path';
26
26
  /** @typedef {{packageRoot:string,userHome:string,cwd:string,env:object,safeFs:object,signal?:AbortSignal}} ManagementContext */
27
27
  /** @typedef {{kind:string,plans:object[],options:object}} PreparedOperation */
@@ -50,7 +50,7 @@ export async function prepareOperation(context,options,{selections=[]}={}){
50
50
  if(options.kind==='uninstall')options={...options,removeCli:options.removeCli!==false};
51
51
  let compositeActivePath,compositeUninstallAnchor;if(options.kind==='uninstall'){const mode=readInstallMode(modeOptions),anchor=mode.mode==='composite'?mode.anchor:registry.byAnchorOrder().find(descriptor=>targets[descriptor.runtime.id])?.runtime.id;if(anchor)compositeActivePath=path.join(targets[anchor].home,'arc-role-platform-routing.json');if(mode.mode==='composite')compositeUninstallAnchor=anchor;}
52
52
  const platforms=platformOrder.filter(platform=>!skipped.some(item=>item.platform===platform)),payload=options.kind==='install'?verifyPayload(context):null;
53
- const plans=platforms.map(platform=>{const target=resolveTarget(platform,context),selection=selections.find(item=>item.target.platform===platform&&item.target.home===target.home);if(options.kind==='preset')return buildPresetPlan({platforms:registry,runtimePlatforms:context.runtimePlatforms,loadPayload:()=>verifyPayload(context),target,roles:options.roles,safeFs:context.safeFs,verifiedCatalog:options.verifiedCatalog});if(options.kind==='uninstall')return buildUninstallPlan({platforms:registry,runtimePlatforms:context.runtimePlatforms,target,safeFs:context.safeFs,skipGlobal:options.skipGlobal,removeCompletion:options.removeCli!==false,compositeActivePath});return buildInstallPlan({platforms:registry,runtimePlatforms:context.runtimePlatforms,payload,target,limitsPreview:selection?.preview,languagePreview:selection?.languagePreview,roles:options.roles,verifiedCatalog:options.verifiedCatalog,language:options.language,skipGlobal:options.skipGlobal,safeFs:context.safeFs,limits:{...(options.maxTotalSubagents===undefined?{}:{max_total_subagents:options.maxTotalSubagents}),...(options.maxConcurrentSubagents===undefined?{}:{max_concurrent_subagents:options.maxConcurrentSubagents})},concurrentExplicit:options.maxConcurrentSubagents!==undefined||Boolean(options.concurrentSelected)});});
53
+ const plans=platforms.map(platform=>{const target=resolveTarget(platform,context),selection=selections.find(item=>item.target.platform===platform&&item.target.home===target.home);if(options.kind==='preset')return buildPresetPlan({platforms:registry,runtimePlatforms:context.runtimePlatforms,loadPayload:()=>verifyPayload(context),target,roles:options.roles,safeFs:context.safeFs,verifiedCatalog:options.verifiedCatalog});if(options.kind==='uninstall')return buildUninstallPlan({platforms:registry,runtimePlatforms:context.runtimePlatforms,target,safeFs:context.safeFs,skipGlobal:options.skipGlobal,removeCompletion:options.removeCli!==false,compositeActivePath});return buildInstallPlan({platforms:registry,runtimePlatforms:context.runtimePlatforms,payload,target,limitsPreview:selection?.preview,languagePreview:selection?.languagePreview,roles:options.roles,verifiedCatalog:options.verifiedCatalog,language:options.language,runMode:options.runMode,skipGlobal:options.skipGlobal,safeFs:context.safeFs,limits:{...(options.maxTotalSubagents===undefined?{}:{max_total_subagents:options.maxTotalSubagents}),...(options.maxConcurrentSubagents===undefined?{}:{max_concurrent_subagents:options.maxConcurrentSubagents})},concurrentExplicit:options.maxConcurrentSubagents!==undefined||Boolean(options.concurrentSelected)});});
54
54
  // Retain the active config until every other uninstall snapshot has read it.
55
55
  if(compositeUninstallAnchor&&options.target==='all')plans.sort((a,b)=>Number(a.target.platform===compositeUninstallAnchor)-Number(b.target.platform===compositeUninstallAnchor));
56
56
  if(options.kind==='install')attachShellCompletionCleanup(plans,context);
@@ -96,8 +96,11 @@ export async function prepareCompositeOperation(context,options){
96
96
  const payload=verifyPayload(context);
97
97
  for(const platform of platforms){
98
98
  const target=targets[platform],status=statuses.find(item=>item.platform===platform),existing=new Map(),modelFile=inspectPath(context.safeFs,path.join(target.home,'skills/arc/models.toml'),{kind:'file',read:true,snapshot:existing}),languageFile=inspectPath(context.safeFs,path.join(target.home,'skills/arc/settings.toml'),{kind:'file',read:true,snapshot:existing});
99
- const modelConfig=loadModelConfig(modelFile.exists?modelFile.bytes:payload.modelInputs[platform].models,platform,context),language=options.settings?.language??(languageFile.exists?parseLanguage(languageFile.bytes).language:'en');
100
- const plan=buildInstallPlan({platforms:registry,runtimePlatforms:context.runtimePlatforms,payload,target,profiles:mode.mode==='composite'&&mode.platforms.includes(platform)?'omit':'write',modelConfig,language,safeFs:context.safeFs,limits:{...(options.settings?.maxTotalSubagents===undefined?{}:{max_total_subagents:options.settings.maxTotalSubagents}),...(options.settings?.maxConcurrentSubagents===undefined?{}:{max_concurrent_subagents:options.settings.maxConcurrentSubagents})},skipGlobal:options.settings?.skipGlobal??false,concurrentExplicit:Boolean(options.settings?.concurrentSelected)||options.settings?.maxConcurrentSubagents!==undefined});assertPlanSnapshot({snapshot:existing},{safeFs:context.safeFs});
99
+ const modelConfig=loadModelConfig(modelFile.exists?modelFile.bytes:payload.modelInputs[platform].models,platform,context);
100
+ const parsed=languageFile.exists?parseSettings(languageFile.bytes):null;
101
+ const language=options.settings?.language??parsed?.language??'en';
102
+ const runMode=options.settings?.runMode??parsed?.runMode??'supervised';
103
+ const plan=buildInstallPlan({platforms:registry,runtimePlatforms:context.runtimePlatforms,payload,target,profiles:mode.mode==='composite'&&mode.platforms.includes(platform)?'omit':'write',modelConfig,language,runMode,safeFs:context.safeFs,limits:{...(options.settings?.maxTotalSubagents===undefined?{}:{max_total_subagents:options.settings.maxTotalSubagents}),...(options.settings?.maxConcurrentSubagents===undefined?{}:{max_concurrent_subagents:options.settings.maxConcurrentSubagents})},skipGlobal:options.settings?.skipGlobal??false,concurrentExplicit:Boolean(options.settings?.concurrentSelected)||options.settings?.maxConcurrentSubagents!==undefined});assertPlanSnapshot({snapshot:existing},{safeFs:context.safeFs});
101
104
  plans.push(plan);profileInputs[platform]=plan.generated.profiles;modelConfigs[platform]=modelConfig;
102
105
  }
103
106
  attachShellCompletionCleanup(plans,context);validatePlanSet(plans);
@@ -143,7 +146,7 @@ export async function executeCompositeOperation(context,prepared){
143
146
  if(!moving)await ready();
144
147
  const publication=await publishCompositeFiles({context,prepared:prepared.files,...(moving?{beforePublish:ready}:{})});
145
148
  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)]};
149
+ 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
150
  }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
151
  }
149
152
  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};}
@@ -2,7 +2,7 @@ import {readInstallMode,inspectStandaloneProfile} from '../installer/install-mod
2
2
  import path from 'node:path';
3
3
  import {resolveTarget,resolveTargets,inspectPath} from '../installer/targets.mjs';
4
4
  import {installerRegistryOf} from '../platforms/index.mjs';
5
- import {parseLanguage} from '../installer/language.mjs';
5
+ import {parseSettings} from '../installer/language.mjs';
6
6
  import {parseLimits} from '../installer/limits.mjs';
7
7
  import {loadModelConfig} from '../models/index.mjs';
8
8
  import {removeManagedBlock} from '../installer/global-config.mjs';
@@ -14,13 +14,34 @@ export async function collectStatus(context,{codexCheck='refresh'}={}){const reg
14
14
  if(!skill.exists&&!profiles.some(x=>x.exists&&x.owned)&&!managed)return{platform,target,state:'absent',residualPaths:profiles.filter(x=>x.exists&&!x.owned).map(x=>x.path),diagnostics:[]};
15
15
  const mandatory=name=>{const found=read(path.join(arc,name));if(!found.exists||!found.bytes.length)throw Error(`Incomplete ARC installation: missing ${name} at ${target.home}`);return found.bytes;};
16
16
  mandatory('SKILL.md');if(profiles.some(x=>!x.exists))throw Error(`Incomplete ARC installation: missing profile at ${target.home}`);
17
- const settings={language:parseLanguage(mandatory('settings.toml')).language,modelConfig:loadModelConfig(mandatory('models.toml'),platform,context),limits:parseLimits(mandatory('limits.toml'))},runtimeConfig=registry.getPlatform(platform).runtimeConfig;if(typeof runtimeConfig.readConcurrency==='function'){const native=read(target.runtimeConfigPath);if(native.exists)runtimeConfig.readConcurrency(native.bytes);}const shell=read(path.join(context.userHome,'.zshrc'));if(shell.exists)removeShellCompletion(shell.bytes);
17
+ const {language,runMode}=parseSettings(mandatory('settings.toml'));
18
+ const settings={language,runMode,modelConfig:loadModelConfig(mandatory('models.toml'),platform,context),limits:parseLimits(mandatory('limits.toml'))},runtimeConfig=registry.getPlatform(platform).runtimeConfig;if(typeof runtimeConfig.readConcurrency==='function'){const native=read(target.runtimeConfigPath);if(native.exists)runtimeConfig.readConcurrency(native.bytes);}const shell=read(path.join(context.userHome,'.zshrc'));if(shell.exists)removeShellCompletion(shell.bytes);
18
19
  return{platform,target,state:'installed',settings,snapshot,residualPaths:profiles.filter(x=>x.exists&&!x.owned).map(x=>x.path),diagnostics:[]};
19
- }catch(error){return{platform,target,state:'incomplete',diagnostics:[error]};}
20
+ }catch(error){
21
+ const status={platform,target,state:'incomplete',diagnostics:[error]};
22
+ if(!target)return status;
23
+ const arc=path.join(target.home,'skills/arc');
24
+ const read=name=>inspectPath(context.safeFs,path.join(arc,name),{kind:'file',read:true});
25
+ const settings={};
26
+ try{
27
+ const found=read('settings.toml');
28
+ if(found.exists){
29
+ const {language,runMode}=parseSettings(found.bytes);
30
+ Object.assign(settings,{language,runMode});
31
+ }
32
+ }catch{}
33
+ try{
34
+ const found=read('limits.toml');
35
+ if(found.exists)settings.limits=parseLimits(found.bytes);
36
+ }catch{}
37
+ return Object.keys(settings).length?{...status,settings}:status;
38
+ }
20
39
  });return Promise.all(statuses.map(async status=>{
40
+ const runtime=registry.getPlatform(status.platform).runtime;
41
+ if(runtime.capabilities.install.state!=='verified')return{...status,cliVersion:{version:null,reason:'capability_not_verified'},authentication:{authStatus:'unknown',reason:'capability_not_verified'}};
21
42
  const cli=resolveLocalCli(status.platform,context);
22
- const kind=registry.getPlatform(status.platform).runtime.auth.kind;
43
+ const kind=runtime.auth.kind;
23
44
  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
45
  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.')]}:{})};
46
+ 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
47
  }));}
@@ -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
+ });