@yunhozz/arc 0.2.7 → 0.2.8

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 (118) hide show
  1. package/MANIFEST.sha256 +115 -68
  2. package/README.md +21 -5
  3. package/claude/agents/arc-implementer.md +3 -3
  4. package/claude/agents/arc-planner.md +3 -3
  5. package/claude/agents/arc-qa.md +3 -3
  6. package/claude/agents/arc-reviewer.md +3 -3
  7. package/claude/agents/arc-scouter.md +3 -3
  8. package/claude/skill/SKILL.md +5 -5
  9. package/claude/skill/models.toml +7 -48
  10. package/claude/skill/references/commit.md +7 -7
  11. package/claude/skill/references/coordination.md +39 -3
  12. package/claude/skill/references/git-recovery.md +1 -1
  13. package/claude/skill/references/handoff-prep.md +6 -6
  14. package/claude/skill/references/handoff.md +8 -3
  15. package/claude/skill/references/limits.md +2 -0
  16. package/claude/skill/references/planning.md +8 -8
  17. package/claude/skill/references/verification.md +9 -9
  18. package/claude/skill/runtime/adapters/claude.mjs +4 -0
  19. package/claude/skill/runtime/adapters/codex.mjs +3 -0
  20. package/claude/skill/runtime/bootstrap.mjs +4 -2
  21. package/claude/skill/runtime/command.mjs +21 -4
  22. package/claude/skill/runtime/local-cli.mjs +248 -0
  23. package/claude/skill/runtime/role-bridge-args.mjs +148 -0
  24. package/claude/skill/runtime/role-bridge.mjs +227 -0
  25. package/claude/skill/runtime/role-dispatch-policy.mjs +110 -0
  26. package/claude/skill/runtime/role-dispatch-store.mjs +134 -0
  27. package/claude/skill/runtime/role-observe.mjs +299 -0
  28. package/claude/skill/runtime/role-policy.json +12 -10
  29. package/claude/skill/runtime/role-routing-config.mjs +19 -0
  30. package/claude/skill/runtime/role-routing.mjs +233 -0
  31. package/claude/skill/runtime/role-supervisor.mjs +356 -0
  32. package/claude/skill/scripts/model_config.py +23 -5
  33. package/codex/agents/arc-implementer.toml +3 -3
  34. package/codex/agents/arc-planner.toml +3 -3
  35. package/codex/agents/arc-qa.toml +3 -3
  36. package/codex/agents/arc-reviewer.toml +3 -3
  37. package/codex/agents/arc-scouter.toml +3 -3
  38. package/codex/skill/SKILL.md +5 -5
  39. package/codex/skill/models.toml +7 -48
  40. package/codex/skill/references/commit.md +7 -7
  41. package/codex/skill/references/coordination.md +38 -2
  42. package/codex/skill/references/handoff-prep.md +6 -6
  43. package/codex/skill/references/handoff-worktree.md +3 -3
  44. package/codex/skill/references/handoff.md +8 -3
  45. package/codex/skill/references/limits.md +2 -0
  46. package/codex/skill/references/planning.md +8 -8
  47. package/codex/skill/references/verification.md +9 -9
  48. package/codex/skill/runtime/adapters/claude.mjs +4 -0
  49. package/codex/skill/runtime/adapters/codex.mjs +3 -0
  50. package/codex/skill/runtime/bootstrap.mjs +4 -2
  51. package/codex/skill/runtime/command.mjs +21 -4
  52. package/codex/skill/runtime/local-cli.mjs +248 -0
  53. package/codex/skill/runtime/role-bridge-args.mjs +148 -0
  54. package/codex/skill/runtime/role-bridge.mjs +227 -0
  55. package/codex/skill/runtime/role-dispatch-policy.mjs +110 -0
  56. package/codex/skill/runtime/role-dispatch-store.mjs +134 -0
  57. package/codex/skill/runtime/role-observe.mjs +299 -0
  58. package/codex/skill/runtime/role-policy.json +12 -10
  59. package/codex/skill/runtime/role-routing-config.mjs +19 -0
  60. package/codex/skill/runtime/role-routing.mjs +233 -0
  61. package/codex/skill/runtime/role-supervisor.mjs +356 -0
  62. package/codex/skill/scripts/model_config.py +17 -22
  63. package/lib/cli/root.mjs +3 -2
  64. package/lib/installer/install-mode.mjs +34 -0
  65. package/lib/installer/install.mjs +1 -1
  66. package/lib/installer/plan.mjs +16 -7
  67. package/lib/installer/preset.mjs +18 -11
  68. package/lib/installer/role-routing.mjs +175 -0
  69. package/lib/installer/runtime-assets.mjs +9 -0
  70. package/lib/installer/targets.mjs +2 -7
  71. package/lib/installer/transaction.mjs +1 -1
  72. package/lib/installer/uninstall.mjs +10 -5
  73. package/lib/installer/upgrade-state.mjs +9 -6
  74. package/lib/installer/upgrade.mjs +2 -2
  75. package/lib/management/operations.mjs +94 -5
  76. package/lib/management/status.mjs +12 -6
  77. package/lib/management/update.mjs +3 -1
  78. package/lib/models/catalog.mjs +3 -3
  79. package/lib/models/claude-models.json +297 -0
  80. package/lib/models/codex-catalog.mjs +9 -6
  81. package/lib/models/codex-models.json +189 -0
  82. package/lib/models/config.mjs +25 -20
  83. package/lib/models/index.mjs +1 -1
  84. package/lib/models/static-catalog.mjs +42 -0
  85. package/lib/policy/role-policy.json +12 -10
  86. package/lib/runtime/adapters/claude.mjs +4 -0
  87. package/lib/runtime/adapters/codex.mjs +3 -0
  88. package/lib/runtime/bootstrap.mjs +4 -2
  89. package/lib/runtime/command.mjs +21 -4
  90. package/lib/runtime/local-cli.mjs +248 -0
  91. package/lib/runtime/role-bridge-args.mjs +148 -0
  92. package/lib/runtime/role-bridge.mjs +227 -0
  93. package/lib/runtime/role-dispatch-policy.mjs +110 -0
  94. package/lib/runtime/role-dispatch-store.mjs +134 -0
  95. package/lib/runtime/role-observe.mjs +299 -0
  96. package/lib/runtime/role-routing-config.mjs +19 -0
  97. package/lib/runtime/role-routing.mjs +233 -0
  98. package/lib/runtime/role-supervisor.mjs +356 -0
  99. package/lib/tui/app.mjs +32 -23
  100. package/lib/tui/custom-preset.mjs +138 -66
  101. package/lib/tui/render.mjs +4 -3
  102. package/lib/tui/setup.mjs +96 -51
  103. package/lib/watch/args.mjs +43 -0
  104. package/lib/watch/discover-claude.mjs +63 -0
  105. package/lib/watch/discover-codex.mjs +45 -0
  106. package/lib/watch/dispatch.mjs +133 -0
  107. package/lib/watch/git.mjs +29 -0
  108. package/lib/watch/index.mjs +112 -0
  109. package/lib/watch/labels.mjs +24 -0
  110. package/lib/watch/model.mjs +48 -0
  111. package/lib/watch/normalize-claude.mjs +99 -0
  112. package/lib/watch/normalize-codex.mjs +96 -0
  113. package/lib/watch/policy.mjs +52 -0
  114. package/lib/watch/render.mjs +86 -0
  115. package/lib/watch/scope.mjs +64 -0
  116. package/lib/watch/tail.mjs +75 -0
  117. package/lib/watch/watcher.mjs +337 -0
  118. package/package.json +2 -2
@@ -1,7 +1,8 @@
1
+ import {readInstallMode,assertVerifiedInstallMode} from '../installer/install-mode.mjs';
1
2
  import os from 'node:os';
2
3
  import {fileURLToPath} from 'node:url';
3
4
  import {resolveTarget} from '../installer/targets.mjs';
4
- import {buildInstallPlan,validatePlanSet} from '../installer/plan.mjs';
5
+ import {buildInstallPlan,renderStandaloneProfiles,validatePlanSet} from '../installer/plan.mjs';
5
6
  import {verifyPayload} from '../installer/manifest.mjs';
6
7
  import {buildPresetPlan,switchPresetTargets} from '../installer/preset.mjs';
7
8
  import {buildUninstallPlan,uninstallTargets} from '../installer/uninstall.mjs';
@@ -9,6 +10,17 @@ import {installTargets} from '../installer/install.mjs';
9
10
  import {attachShellCompletionCleanup} from '../installer/shell-completion.mjs';
10
11
  import {inspectGlobalArc} from '../npm/context.mjs';
11
12
  import {uninstallGlobal,sameGlobalArc} from '../npm/uninstall.mjs';
13
+ import {collectStatus} from './status.mjs';
14
+ import {loadModelConfig,serializeModelConfig} from '../models/index.mjs';
15
+ import {readModelFileVersion} from '../models/config.mjs';
16
+ import {validateRoleRoutingConfig} from '../runtime/role-routing-config.mjs';
17
+ import {loadStaticModelCatalog,assertCompositeCatalogRoles} from '../models/static-catalog.mjs';
18
+ import {prepareCompositeFiles,publishCompositeFiles,readCompositeRoutingConfig,prepareCompositeDeactivation,publishCompositeDeactivation} from '../installer/role-routing.mjs';
19
+ import {inspectPath,TargetConfigurationError} from '../installer/targets.mjs';
20
+ import {assertPlanSnapshot} from '../installer/transaction.mjs';
21
+ import {acquireRoleRoutingLock} from '../runtime/role-routing.mjs';
22
+ import {parseLanguage} from '../installer/language.mjs';
23
+ import path from 'node:path';
12
24
  /** @typedef {{packageRoot:string,userHome:string,cwd:string,env:object,safeFs:object,signal?:AbortSignal}} ManagementContext */
13
25
  /** @typedef {{kind:string,plans:object[],options:object}} PreparedOperation */
14
26
  /** @typedef {{code:number,exitSession:boolean,results:object[],interrupted:boolean}} OperationResult */
@@ -17,30 +29,107 @@ export async function createManagementContext(options={}){
17
29
  return{packageRoot:fileURLToPath(new URL('../../',import.meta.url)),userHome:os.homedir(),cwd:process.cwd(),env:process.env,...options,safeFs};
18
30
  }
19
31
  export async function prepareOperation(context,options,{selections=[]}={}){
32
+ if(options.target==='composite')return prepareCompositeOperation(context,options);
20
33
  if(options.kind==='update'){const{prepareUpdate}=await import('./update.mjs');return prepareUpdate(context);}
21
34
  if(!['install','preset','uninstall'].includes(options.kind))throw Object.assign(Error('Unknown management operation'),{code:'ARC_CLI_INPUT'});
35
+ if(['codex','claude'].includes(options.target)||(options.target==='all'&&options.kind!=='uninstall')){
36
+ const targets=compositeTargets(context),mode=readInstallMode({safeFs:context.safeFs,targets});
37
+ if(mode.mode==='unverified')assertVerifiedInstallMode({safeFs:context.safeFs,targets});
38
+ if(mode.mode==='composite'){if(options.target==='all'||!options.switchFromComposite)throw new TargetConfigurationError('Claude & Codex is active; confirm the switch first');return{kind:'switch',operation:options.kind,deactivation:prepareCompositeDeactivation({context,targets,payload:verifyPayload(context)}),options:{...options}};}
39
+ }
22
40
  if(options.kind==='uninstall')options={...options,removeCli:options.removeCli!==false};
23
- const platforms=options.target==='all'?['codex','claude']:[options.target],payload=options.kind==='install'?verifyPayload(context):null;
24
- 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({target,preset:options.preset,safeFs:context.safeFs,customRoles:options.customRoles,verifiedCatalog:options.verifiedCatalog});if(options.kind==='uninstall')return buildUninstallPlan({target,safeFs:context.safeFs,skipGlobal:options.skipGlobal,removeCompletion:options.removeCli!==false});return buildInstallPlan({payload,target,limitsPreview:selection?.preview,languagePreview:selection?.languagePreview,preset:options.preset,customRoles:options.customRoles,preservedCustomRoles:options.preservedCustomRoles,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)});});
41
+ let compositeActivePath;if(options.kind==='uninstall')try{compositeActivePath=path.join(resolveTarget('codex',context).home,'arc-role-platform-routing.json');}catch{}
42
+ const platforms=options.target==='all'?(options.kind==='uninstall'?['claude','codex']:['codex','claude']):[options.target],payload=options.kind==='install'?verifyPayload(context):null;
43
+ 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({loadPayload:()=>verifyPayload(context),target,roles:options.roles,safeFs:context.safeFs,verifiedCatalog:options.verifiedCatalog});if(options.kind==='uninstall')return buildUninstallPlan({target,safeFs:context.safeFs,skipGlobal:options.skipGlobal,removeCompletion:options.removeCli!==false,compositeActivePath});return buildInstallPlan({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)});});
25
44
  if(options.kind==='install')attachShellCompletionCleanup(plans,context);
26
45
  // Uninstall plans initially share the completion snapshot; its executor assigns one owner.
27
46
  if(options.kind!=='uninstall')validatePlanSet(plans);
28
47
  const globalArc=options.kind==='uninstall'&&options.removeCli!==false?await(context.inspectGlobalArc??inspectGlobalArc)({env:context.env,cwd:context.cwd,runNpm:context.runNpm}):undefined;
29
48
  return{kind:options.kind,plans,options:{...options},...(globalArc?{globalArc}:{})};
30
49
  }
50
+ const compositeTargets=context=>Object.fromEntries(['codex','claude'].map(platform=>[platform,resolveTarget(platform,context)]));
51
+ function assertCompositeAvailability(statuses){
52
+ for(const status of statuses)if(status.authentication?.authStatus!=='authenticated')throw new TargetConfigurationError(`${status.platform}: ${status.authentication?.authStatus==='unauthorized'?'Unauthorized':status.authentication?.reason==='cli_not_found'?'Not Available':'Incomplete'}`);
53
+ }
54
+ async function assertCompositeCatalog(config,signal){
55
+ const platforms=['codex','claude'],results=await Promise.all(platforms.map(platform=>loadStaticModelCatalog(platform,{signal}))),catalogs={};
56
+ for(const [index,platform] of platforms.entries()){if(results[index].status!=='ready')throw new TargetConfigurationError(`${platform} model catalog is unavailable or invalid`);catalogs[platform]=results[index].catalog;}
57
+ try{assertCompositeCatalogRoles({roles:config.roles,catalogs});}catch(error){throw new TargetConfigurationError(error.message);}
58
+ }
59
+ export function currentInstallMode(context){return readInstallMode({safeFs:context.safeFs,targets:compositeTargets(context)}).mode;}
60
+ export function readCompositeConfig(context){return readCompositeRoutingConfig(context,compositeTargets(context));}
61
+ export async function prepareCompositeOperation(context,options){
62
+ if(!['install','preset'].includes(options.kind))throw new TargetConfigurationError('Unsupported composite operation');
63
+ const config=validateRoleRoutingConfig(options.config),targets=compositeTargets(context),mode=assertVerifiedInstallMode({safeFs:context.safeFs,targets}).mode,statuses=await collectStatus(context);assertCompositeAvailability(statuses);await assertCompositeCatalog(config,context.signal);
64
+ if(targets.codex.home===targets.claude.home||targets.codex.home.startsWith(targets.claude.home+'/')||targets.claude.home.startsWith(targets.codex.home+'/'))throw new TargetConfigurationError('Selected platform homes overlap');
65
+ if(options.kind==='preset'&&statuses.some(status=>status.state!=='installed'))throw new TargetConfigurationError('Both ARC installations are required to change composite settings');
66
+ const plans=[],profileInputs={},modelConfigs={},sourceSnapshot=new Map(),externalPaths=[];
67
+ if(options.kind==='install'){
68
+ const payload=verifyPayload(context);
69
+ for(const platform of ['codex','claude']){
70
+ 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});
71
+ const modelConfig=loadModelConfig(modelFile.exists?modelFile.bytes:payload.modelInputs[platform].models,platform),language=options.settings?.language??(languageFile.exists?parseLanguage(languageFile.bytes).language:'en');
72
+ const plan=buildInstallPlan({payload,target,profiles:mode==='composite'?'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});
73
+ plans.push(plan);profileInputs[platform]=plan.generated.profiles;modelConfigs[platform]=modelConfig;
74
+ }
75
+ attachShellCompletionCleanup(plans,context);validatePlanSet(plans);
76
+ }else for(const platform of ['codex','claude']){
77
+ const target=targets[platform],status=statuses.find(item=>item.platform===platform);modelConfigs[platform]=status.settings.modelConfig;profileInputs[platform]=new Map();
78
+ profileInputs[platform]=renderStandaloneProfiles({payload:verifyPayload(context),target,modelConfig:status.settings.modelConfig,language:status.settings.language});
79
+ for(const name of ['models.toml','settings.toml']){const filename=path.join(target.home,'skills/arc',name);inspectPath(context.safeFs,filename,{kind:'file',read:true,snapshot:sourceSnapshot});externalPaths.push(filename);}
80
+ }
81
+ const files=prepareCompositeFiles({context,targets,config,profileInputs,modelConfigs});for(const item of sourceSnapshot)files.snapshot.set(...item);
82
+ files.modelWrites=[];
83
+ if(options.kind==='preset')for(const platform of ['codex','claude']){
84
+ const filename=path.join(targets[platform].home,'skills/arc/models.toml'),found=inspectPath(context.safeFs,filename,{kind:'file',read:true,snapshot:files.snapshot});
85
+ if(found.exists&&readModelFileVersion(found.bytes)<3){files.modelWrites.push({path:filename,bytes:Buffer.from(serializeModelConfig(modelConfigs[platform]))});files.managedPaths.push(filename);}
86
+ }
87
+ files.externalPaths.push(...externalPaths.filter(filename=>!files.modelWrites.some(write=>write.path===filename)));
88
+ return {kind:'composite',operation:options.kind,plans,files,config,options:{target:'composite'},summary:['Composite configuration will be published only after both targets are ready.','Per-role execution support is reported by routing-status.']};
89
+ }
90
+ export async function executeCompositeOperation(context,prepared){
91
+ const held={routeStatus:'held',supportStatus:'unverified',reason:'Per-role execution support is reported by routing-status.'};
92
+ let result={results:[],interrupted:false};
93
+ try{
94
+ assertCompositeAvailability(await collectStatus(context,{codexCheck:'local'}));
95
+ const refreshCatalog=()=>assertCompositeCatalog(prepared.config,context.signal);
96
+ await refreshCatalog();
97
+ assertPlanSnapshot(prepared.files,{safeFs:context.safeFs});
98
+ if(prepared.operation==='install'){result=await installTargets(prepared.plans,{safeFs:context.safeFs,signal:context.signal,hooks:context.hooks});if(result.interrupted||result.results.some(item=>item.status!=='installed'||item.error))return {...operationResult(result),activation:'held',support:held};}
99
+ if(prepared.operation==='install')for(const plan of prepared.plans)for(const name of plan.profileWrites.keys()){const filename=path.join(plan.target.home,'agents',name);inspectPath(context.safeFs,filename,{kind:'file',read:true,snapshot:prepared.files.snapshot});if(!prepared.files.standaloneRemovals.includes(filename)){prepared.files.standaloneRemovals.push(filename);prepared.files.managedPaths.push(filename);}}
100
+ if(context.signal?.aborted)return {...operationResult({...result,interrupted:true}),activation:'held',support:held};
101
+ const statuses=await collectStatus(context,{codexCheck:'local'});assertCompositeAvailability(statuses);if(prepared.operation!=='install'&&statuses.some(status=>status.state!=='installed'))throw new TargetConfigurationError('Both ARC installations must be complete before publication');await refreshCatalog();
102
+ const publication=await publishCompositeFiles({context,prepared:prepared.files});
103
+ return {...operationResult(result),code:publication.cleanupError?1:0,activation:'published',publication,support:held,...(publication.cleanupError?{error:publication.cleanupError}:{}),messages:['Claude & Codex activated.','After upgrading ARC, run Install / Update again.',...(publication.residualPaths??[]).map(value=>'Residual path: '+value)]};
104
+ }catch(error){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)?[`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)]};}
105
+ }
31
106
  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};}
107
+ async function uninstallPrepared(context,prepared,options){
108
+ let release,result,error,home;
109
+ try{if(prepared.plans.some(plan=>plan.compositeOwned)){home=resolveTarget('codex',context).home;release=await acquireRoleRoutingLock(home);}result=await uninstallTargets(prepared.plans,options);}catch(cause){error=cause;}
110
+ const released=release?await release():true;if(error)throw error;
111
+ if(!released){const failure=new TargetConfigurationError('Composite removal lock ownership could not be verified');return {...result,results:result.results.map((item,index)=>index?item:{...item,error:failure,residualPaths:[...item.residualPaths,path.join(home,'arc-role-platform-routing.lock')]})};}
112
+ return result;
113
+ }
32
114
  export async function executeOperation(context,prepared){
115
+ if(prepared.kind==='switch'){
116
+ let deactivation;const messages=[];
117
+ try{deactivation=await publishCompositeDeactivation({context,prepared:prepared.deactivation});messages.push('Claude & Codex turned off.',...deactivation.residualPaths.map(p=>'Residual path: '+p));if(deactivation.cleanupError)return{code:1,exitSession:false,interrupted:false,results:[],messages,error:deactivation.cleanupError};
118
+ const next=await prepareOperation(context,{...prepared.options,switchFromComposite:false}),result=await executeOperation(context,next);return{...result,messages:[...messages,...(result.messages??[])]};
119
+ }catch(error){return{code:context.signal?.aborted?130:1,exitSession:false,interrupted:Boolean(context.signal?.aborted),results:[],error,messages:[...messages,...(error.activeDispatches?[`Active bridge dispatches: ${error.activeDispatches.join(', ')}`]:[]),...(error.residualPaths??[]).map(p=>'Residual path: '+p)]};}
120
+ }
121
+ if(prepared.kind==='composite')return executeCompositeOperation(context,prepared);
33
122
  if(prepared.kind==='update'){const{executeUpdate}=await import('./update.mjs');return executeUpdate(context,prepared);}
34
123
  const options={safeFs:context.safeFs,signal:context.signal,hooks:context.hooks};
35
124
  if(prepared.kind==='install')return operationResult(await installTargets(prepared.plans,options));
36
125
  if(prepared.kind==='preset')return operationResult(await switchPresetTargets(prepared.plans,options),['updated','unchanged']);
37
126
  if(prepared.kind==='uninstall'){
38
- if(prepared.options?.removeCli===false)return operationResult(await uninstallTargets(prepared.plans,options),['uninstalled']);
127
+ if(prepared.options?.removeCli===false)return operationResult(await uninstallPrepared(context,prepared,options),['uninstalled']);
39
128
  let result;
40
129
  try{
41
130
  const current=await(context.inspectGlobalArc??inspectGlobalArc)({context:prepared.globalArc,env:context.env,cwd:context.cwd,runNpm:context.runNpm});
42
131
  if(!sameGlobalArc(prepared.globalArc,current))throw Error('Global ARC installation changed; prepare uninstall again');
43
- result=operationResult(await uninstallTargets(prepared.plans,options),['uninstalled']);
132
+ result=operationResult(await uninstallPrepared(context,prepared,options),['uninstalled']);
44
133
  if(result.code!==0||context.signal?.aborted)return{...result,code:context.signal?.aborted?130:result.code,cli:{status:'skipped'}};
45
134
  const cli=await(context.uninstallGlobal??uninstallGlobal)({context:prepared.globalArc,env:context.env,cwd:context.cwd,signal:context.signal,runNpm:context.runNpm});
46
135
  return{...result,code:cli.code??(cli.packageStatus==='failed'?1:0),interrupted:result.interrupted||Boolean(cli.interrupted),exitSession:Boolean(cli.started),cli:{...cli,status:cli.packageStatus},stdout:cli.stdout,stderr:cli.stderr};
@@ -1,3 +1,4 @@
1
+ import {readInstallMode,inspectStandaloneProfile} from '../installer/install-mode.mjs';
1
2
  import path from 'node:path';
2
3
  import {resolveTarget,inspectPath} from '../installer/targets.mjs';
3
4
  import {parseLanguage} from '../installer/language.mjs';
@@ -6,13 +7,18 @@ import {loadModelConfig} from '../models/index.mjs';
6
7
  import {removeManagedBlock} from '../installer/global-config.mjs';
7
8
  import {readRuntimeConcurrency} from '../installer/runtime-config.mjs';
8
9
  import {removeShellCompletion} from '../installer/shell-completion.mjs';
10
+ import {resolveLocalCli,probePlatformAuth,probeCodexAuthStatus,probeCodexLoginStatus} from '../runtime/local-cli.mjs';
9
11
  /** @typedef {{platform:string,target?:object,state:'absent'|'installed'|'incomplete',settings?:object,diagnostics:Error[]}} TargetStatus */
10
- export async function collectStatus(context){return ['codex','claude'].map(platform=>{
11
- let target;try{target=resolveTarget(platform,context);const snapshot=new Map(),read=(name,kind='file')=>inspectPath(context.safeFs,name,{kind,read:true,snapshot,tree:kind==='directory',allowLinks:kind==='directory'}),arc=path.join(target.home,'skills/arc'),skill=read(arc,'directory'),profiles=target.profileNames.map(name=>read(path.join(target.home,'agents',name))),instruction=read(target.instructionPath),managed=instruction.exists&&removeManagedBlock(instruction.bytes).changed;
12
- if(!skill.exists&&!profiles.some(x=>x.exists)&&!managed)return{platform,target,state:'absent',diagnostics:[]};
12
+ export async function collectStatus(context,{codexCheck='refresh'}={}){let mode='unverified';try{mode=readInstallMode({safeFs:context.safeFs,targets:Object.fromEntries(['codex','claude'].map(p=>[p,resolveTarget(p,context)]))}).mode;}catch{}const statuses=['codex','claude'].map(platform=>{
13
+ let target;try{target=resolveTarget(platform,context);const snapshot=new Map(),read=(name,kind='file')=>inspectPath(context.safeFs,name,{kind,read:true,snapshot,tree:kind==='directory',allowLinks:kind==='directory'}),arc=path.join(target.home,'skills/arc'),skill=read(arc,'directory'),profiles=mode==='composite'?[]:target.profileNames.map(name=>inspectStandaloneProfile({safeFs:context.safeFs,target,role:name.split('.')[0].replace('-','_'),snapshot})),instruction=read(target.instructionPath),managed=instruction.exists&&removeManagedBlock(instruction.bytes).changed;
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:[]};
13
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;};
14
- mandatory('SKILL.md');if(profiles.some(x=>!x.exists||!x.bytes.length))throw Error(`Incomplete ARC installation: missing profile at ${target.home}`);
16
+ mandatory('SKILL.md');if(profiles.some(x=>!x.exists))throw Error(`Incomplete ARC installation: missing profile at ${target.home}`);
15
17
  const settings={language:parseLanguage(mandatory('settings.toml')).language,modelConfig:loadModelConfig(mandatory('models.toml'),platform),limits:parseLimits(mandatory('limits.toml'))};const native=read(target.runtimeConfigPath);if(native.exists)readRuntimeConcurrency(platform,native.bytes);const shell=read(path.join(context.userHome,'.zshrc'));if(shell.exists)removeShellCompletion(shell.bytes);
16
- return{platform,target,state:'installed',settings,snapshot,diagnostics:[]};
18
+ return{platform,target,state:'installed',settings,snapshot,residualPaths:profiles.filter(x=>x.exists&&!x.owned).map(x=>x.path),diagnostics:[]};
17
19
  }catch(error){return{platform,target,state:'incomplete',diagnostics:[error]};}
18
- });}
20
+ });return Promise.all(statuses.map(async status=>{
21
+ const cli=resolveLocalCli(status.platform,context);
22
+ const authentication=cli.reason?{platform:status.platform,authStatus:'unknown',reason:cli.reason}:await (status.platform==='codex'?(codexCheck==='local'?probeCodexLoginStatus:probeCodexAuthStatus)(cli,{signal:context.signal}):probePlatformAuth(cli,{signal:context.signal}));
23
+ return {...status,authentication};
24
+ }));}
@@ -12,7 +12,9 @@ export async function runtime(deps){
12
12
  return{...context,...state,...upgrade,...npm,...deps,safeFs};
13
13
  }
14
14
  export function report(result,output,error){
15
- for(const item of result.results){output.write(item.platform+': '+item.status+'\n');for(const filename of item.residualPaths??[])output.write('Residual path: '+filename+'\n');if(item.error)error.write('Error: '+item.error.message+'\n');}
15
+ const residualPaths=new Set(),writeResidual=filename=>{if(residualPaths.has(filename))return;residualPaths.add(filename);output.write('Residual path: '+filename+'\n');};
16
+ for(const item of result.results){output.write(item.platform+': '+item.status+'\n');for(const filename of item.residualPaths??[])writeResidual(filename);if(item.error)error.write('Error: '+item.error.message+'\n');}
17
+ for(const filename of result.residualPaths??[])writeResidual(filename);
16
18
  if(result.interrupted)return 130;
17
19
  if(result.results.every(item=>item.status==='installed'&&!item.error)){output.write('ARC version '+result.version+' harness upgraded! Previous harness version: not recorded.\n');return 0;}
18
20
  error.write('Harness update did not complete. Run arc again and choose Install / Update to retry the harness update.\n');return 1;
@@ -33,8 +33,8 @@ export async function discoverModelCatalog({ platform, env = process.env, fetchI
33
33
  const timer = setTimeout(() => { timedOut = true; onAbort(); }, Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : 10000);
34
34
  const operation = Promise.resolve().then(async () => platform === 'codex'
35
35
  ? { status: 'ready', catalog: codexCatalog(await listCodexModels({ env, signal: controller.signal }), [env?.OPENAI_API_KEY, env?.ANTHROPIC_API_KEY].filter(value => typeof value === 'string' && value.length)) }
36
- : discoverAnthropicCatalog({ apiKey: env?.ANTHROPIC_API_KEY, fetchImpl, signal: controller.signal }));
37
- const settled = operation.then(value => ({ value }), () => ({ failed: true }));
36
+ : discoverAnthropicCatalog({ apiKey: env?.ANTHROPIC_API_KEY, fetchImpl, signal: controller.signal }).then(result => result.status === 'ready' ? { ...result, catalog: { ...result.catalog, source: 'anthropic_api', cliAccountVerified: false } } : result));
37
+ const settled = operation.then(value => ({ value }), error => ({ failed: true, code: error?.code }));
38
38
  try {
39
39
  const first = await Promise.race([settled, abortPromise.then(() => ({ aborted: true }))]);
40
40
  if (first.aborted) {
@@ -45,7 +45,7 @@ export async function discoverModelCatalog({ platform, env = process.env, fetchI
45
45
  }
46
46
  return timedOut ? unavailable('timeout', 'Catalog lookup timed out.') : unavailable('aborted', 'Catalog lookup was cancelled.');
47
47
  }
48
- return first.failed ? unavailable('unavailable', 'Catalog is unavailable.') : first.value;
48
+ return first.failed ? unavailable(['execution_error', 'protocol_error'].includes(first.code) ? first.code : 'unavailable', 'Catalog is unavailable.') : first.value;
49
49
  } finally { clearTimeout(timer); signal?.removeEventListener('abort', onAbort); }
50
50
  }
51
51
 
@@ -0,0 +1,297 @@
1
+ {
2
+ "platform": "claude",
3
+ "pairs": [
4
+ {
5
+ "model": "fable",
6
+ "effort": "low"
7
+ },
8
+ {
9
+ "model": "fable",
10
+ "effort": "medium"
11
+ },
12
+ {
13
+ "model": "fable",
14
+ "effort": "high"
15
+ },
16
+ {
17
+ "model": "fable",
18
+ "effort": "xhigh"
19
+ },
20
+ {
21
+ "model": "fable",
22
+ "effort": "max"
23
+ },
24
+ {
25
+ "model": "opus",
26
+ "effort": "low"
27
+ },
28
+ {
29
+ "model": "opus",
30
+ "effort": "medium"
31
+ },
32
+ {
33
+ "model": "opus",
34
+ "effort": "high"
35
+ },
36
+ {
37
+ "model": "opus",
38
+ "effort": "xhigh"
39
+ },
40
+ {
41
+ "model": "opus",
42
+ "effort": "max"
43
+ },
44
+ {
45
+ "model": "sonnet",
46
+ "effort": "low"
47
+ },
48
+ {
49
+ "model": "sonnet",
50
+ "effort": "medium"
51
+ },
52
+ {
53
+ "model": "sonnet",
54
+ "effort": "high"
55
+ },
56
+ {
57
+ "model": "sonnet",
58
+ "effort": "xhigh"
59
+ },
60
+ {
61
+ "model": "sonnet",
62
+ "effort": "max"
63
+ },
64
+ {
65
+ "model": "haiku",
66
+ "effort": "low"
67
+ },
68
+ {
69
+ "model": "haiku",
70
+ "effort": "medium"
71
+ },
72
+ {
73
+ "model": "haiku",
74
+ "effort": "high"
75
+ },
76
+ {
77
+ "model": "haiku",
78
+ "effort": "xhigh"
79
+ },
80
+ {
81
+ "model": "haiku",
82
+ "effort": "max"
83
+ },
84
+ {
85
+ "model": "claude-fable-5-1",
86
+ "effort": "low"
87
+ },
88
+ {
89
+ "model": "claude-fable-5-1",
90
+ "effort": "medium"
91
+ },
92
+ {
93
+ "model": "claude-fable-5-1",
94
+ "effort": "high"
95
+ },
96
+ {
97
+ "model": "claude-fable-5-1",
98
+ "effort": "xhigh"
99
+ },
100
+ {
101
+ "model": "claude-fable-5-1",
102
+ "effort": "max"
103
+ },
104
+ {
105
+ "model": "claude-fable-5",
106
+ "effort": "low"
107
+ },
108
+ {
109
+ "model": "claude-fable-5",
110
+ "effort": "medium"
111
+ },
112
+ {
113
+ "model": "claude-fable-5",
114
+ "effort": "high"
115
+ },
116
+ {
117
+ "model": "claude-fable-5",
118
+ "effort": "xhigh"
119
+ },
120
+ {
121
+ "model": "claude-fable-5",
122
+ "effort": "max"
123
+ },
124
+ {
125
+ "model": "claude-opus-5-5",
126
+ "effort": "low"
127
+ },
128
+ {
129
+ "model": "claude-opus-5-5",
130
+ "effort": "medium"
131
+ },
132
+ {
133
+ "model": "claude-opus-5-5",
134
+ "effort": "high"
135
+ },
136
+ {
137
+ "model": "claude-opus-5-5",
138
+ "effort": "xhigh"
139
+ },
140
+ {
141
+ "model": "claude-opus-5-5",
142
+ "effort": "max"
143
+ },
144
+ {
145
+ "model": "claude-opus-5",
146
+ "effort": "low"
147
+ },
148
+ {
149
+ "model": "claude-opus-5",
150
+ "effort": "medium"
151
+ },
152
+ {
153
+ "model": "claude-opus-5",
154
+ "effort": "high"
155
+ },
156
+ {
157
+ "model": "claude-opus-5",
158
+ "effort": "xhigh"
159
+ },
160
+ {
161
+ "model": "claude-opus-5",
162
+ "effort": "max"
163
+ },
164
+ {
165
+ "model": "claude-opus-4-8",
166
+ "effort": "low"
167
+ },
168
+ {
169
+ "model": "claude-opus-4-8",
170
+ "effort": "medium"
171
+ },
172
+ {
173
+ "model": "claude-opus-4-8",
174
+ "effort": "high"
175
+ },
176
+ {
177
+ "model": "claude-opus-4-8",
178
+ "effort": "xhigh"
179
+ },
180
+ {
181
+ "model": "claude-opus-4-8",
182
+ "effort": "max"
183
+ },
184
+ {
185
+ "model": "claude-opus-4-7",
186
+ "effort": "low"
187
+ },
188
+ {
189
+ "model": "claude-opus-4-7",
190
+ "effort": "medium"
191
+ },
192
+ {
193
+ "model": "claude-opus-4-7",
194
+ "effort": "high"
195
+ },
196
+ {
197
+ "model": "claude-opus-4-7",
198
+ "effort": "xhigh"
199
+ },
200
+ {
201
+ "model": "claude-opus-4-7",
202
+ "effort": "max"
203
+ },
204
+ {
205
+ "model": "claude-sonnet-5-5",
206
+ "effort": "low"
207
+ },
208
+ {
209
+ "model": "claude-sonnet-5-5",
210
+ "effort": "medium"
211
+ },
212
+ {
213
+ "model": "claude-sonnet-5-5",
214
+ "effort": "high"
215
+ },
216
+ {
217
+ "model": "claude-sonnet-5-5",
218
+ "effort": "xhigh"
219
+ },
220
+ {
221
+ "model": "claude-sonnet-5-5",
222
+ "effort": "max"
223
+ },
224
+ {
225
+ "model": "claude-sonnet-5",
226
+ "effort": "low"
227
+ },
228
+ {
229
+ "model": "claude-sonnet-5",
230
+ "effort": "medium"
231
+ },
232
+ {
233
+ "model": "claude-sonnet-5",
234
+ "effort": "high"
235
+ },
236
+ {
237
+ "model": "claude-sonnet-5",
238
+ "effort": "xhigh"
239
+ },
240
+ {
241
+ "model": "claude-sonnet-5",
242
+ "effort": "max"
243
+ },
244
+ {
245
+ "model": "claude-haiku-5-5",
246
+ "effort": "low"
247
+ },
248
+ {
249
+ "model": "claude-haiku-5-5",
250
+ "effort": "medium"
251
+ },
252
+ {
253
+ "model": "claude-haiku-5-5",
254
+ "effort": "high"
255
+ },
256
+ {
257
+ "model": "claude-haiku-5-5",
258
+ "effort": "xhigh"
259
+ },
260
+ {
261
+ "model": "claude-haiku-5-5",
262
+ "effort": "max"
263
+ },
264
+ {
265
+ "model": "claude-opus-4-6",
266
+ "effort": "low"
267
+ },
268
+ {
269
+ "model": "claude-opus-4-6",
270
+ "effort": "medium"
271
+ },
272
+ {
273
+ "model": "claude-opus-4-6",
274
+ "effort": "high"
275
+ },
276
+ {
277
+ "model": "claude-opus-4-6",
278
+ "effort": "max"
279
+ },
280
+ {
281
+ "model": "claude-sonnet-4-6",
282
+ "effort": "low"
283
+ },
284
+ {
285
+ "model": "claude-sonnet-4-6",
286
+ "effort": "medium"
287
+ },
288
+ {
289
+ "model": "claude-sonnet-4-6",
290
+ "effort": "high"
291
+ },
292
+ {
293
+ "model": "claude-sonnet-4-6",
294
+ "effort": "max"
295
+ }
296
+ ]
297
+ }
@@ -1,28 +1,31 @@
1
1
  import path from 'node:path';
2
+ import os from 'node:os';
2
3
  import { spawn } from 'node:child_process';
3
4
  import { StringDecoder } from 'node:string_decoder';
5
+ import { resolveConfigHome } from '../runtime/local-cli.mjs';
4
6
 
5
7
  const ENV_KEYS = ['PATH', 'HOME', 'USERPROFILE', 'HOMEDRIVE', 'HOMEPATH', 'APPDATA', 'LOCALAPPDATA', 'SYSTEMROOT', 'WINDIR', 'TMPDIR', 'TEMP', 'TMP', 'CODEX_HOME', 'XDG_CONFIG_HOME', 'XDG_DATA_HOME'];
6
8
  const validText = value => typeof value === 'string' && value.length > 0 && value === value.trim() && !/[\p{Cc}\u2028\u2029]/u.test(value);
7
- const failure = () => new Error('Codex catalog is unavailable.');
9
+ const failure = (code = 'protocol_error') => Object.assign(new Error('Codex catalog is unavailable.'), { code });
8
10
 
9
11
  export async function listCodexModelCapabilities({ env = process.env, cwd, spawnImpl = spawn, signal, timeoutMs = 10000 } = {}) {
10
12
  if (typeof cwd !== 'string' || !path.isAbsolute(cwd) || path.normalize(cwd) !== cwd || typeof spawnImpl !== 'function' || signal?.aborted) throw failure();
11
13
  const childEnv = Object.fromEntries(ENV_KEYS.filter(key => typeof env?.[key] === 'string').map(key => [key, env[key]]));
14
+ try { childEnv.CODEX_HOME = resolveConfigHome('codex', { userHome: env?.HOME ?? env?.USERPROFILE ?? os.homedir(), env, cwd }); } catch { throw failure('execution_error'); }
12
15
  const secrets = [env?.OPENAI_API_KEY, env?.ANTHROPIC_API_KEY].filter(value => typeof value === 'string' && value.length);
13
16
  const containsSecret = value => secrets.some(secret => value.includes(secret));
14
17
  let child;
15
18
  try { child = spawnImpl('codex', ['app-server'], { cwd, env: childEnv, stdio: ['pipe', 'pipe', 'pipe'], shell: false }); }
16
- catch { throw failure(); }
19
+ catch { throw failure('execution_error'); }
17
20
  if (!child?.stdin || !child?.stdout || !child?.stderr || typeof child.on !== 'function' || typeof child.kill !== 'function') throw failure();
18
21
 
19
22
  let closed = false, interrupted = false, cancelled = false, nextId = 0, buffer = '';
20
23
  const pending = new Map(), decoder = new StringDecoder('utf8');
21
24
  let resolveClosed;
22
25
  const closedPromise = new Promise(resolve => { resolveClosed = resolve; });
23
- const rejectPending = () => { interrupted = true; for (const entry of pending.values()) entry.reject(failure()); pending.clear(); };
24
- const onClose = () => { closed = true; resolveClosed(); rejectPending(); };
25
- const onError = () => rejectPending();
26
+ const rejectPending = (code = 'protocol_error') => { interrupted = true; for (const entry of pending.values()) entry.reject(failure(code)); pending.clear(); };
27
+ const onClose = () => { closed = true; resolveClosed(); rejectPending('execution_error'); };
28
+ const onError = () => rejectPending('execution_error');
26
29
  const onData = chunk => {
27
30
  buffer += decoder.write(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
28
31
  if (buffer.length > 1048576) { rejectPending(); return; }
@@ -75,7 +78,7 @@ export async function listCodexModelCapabilities({ env = process.env, cwd, spawn
75
78
  cursors.add(page.nextCursor); cursor = page.nextCursor;
76
79
  }
77
80
  if (!result) throw failure();
78
- } catch { error = failure(); }
81
+ } catch (caught) { error = failure(caught?.code === 'execution_error' ? 'execution_error' : 'protocol_error'); }
79
82
  finally {
80
83
  rejectPending();
81
84
  try { child.stdin.end(); } catch { error = failure(); }