@yunhozz/arc 0.3.5 → 0.4.1

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 (135) hide show
  1. package/MANIFEST.sha256 +133 -94
  2. package/README.md +56 -21
  3. package/claude/skill/SKILL.md +1 -1
  4. package/claude/skill/references/commit.md +10 -8
  5. package/claude/skill/references/coordination.md +6 -4
  6. package/claude/skill/references/handoff-prep.md +12 -12
  7. package/claude/skill/references/handoff.md +2 -0
  8. package/claude/skill/references/planning.md +8 -8
  9. package/claude/skill/references/verification.md +6 -6
  10. package/codex/skill/SKILL.md +1 -1
  11. package/codex/skill/references/commit.md +10 -8
  12. package/codex/skill/references/coordination.md +6 -4
  13. package/codex/skill/references/handoff-prep.md +12 -12
  14. package/codex/skill/references/handoff.md +2 -0
  15. package/codex/skill/references/planning.md +8 -8
  16. package/codex/skill/references/verification.md +6 -6
  17. package/gemini/GEMINI.md +8 -0
  18. package/gemini/agents/arc-implementer.md +37 -0
  19. package/gemini/agents/arc-planner.md +47 -0
  20. package/gemini/agents/arc-qa.md +37 -0
  21. package/gemini/agents/arc-reviewer.md +39 -0
  22. package/gemini/agents/arc-scouter.md +38 -0
  23. package/gemini/instructions.md +4 -0
  24. package/gemini/skill/SKILL.md +78 -0
  25. package/gemini/skill/models.toml +23 -0
  26. package/gemini/skill/references/arc-visual-companion.md +28 -0
  27. package/gemini/skill/references/commit.md +55 -0
  28. package/gemini/skill/references/coordination.md +149 -0
  29. package/gemini/skill/references/git-recovery.md +34 -0
  30. package/gemini/skill/references/handoff-prep.md +110 -0
  31. package/gemini/skill/references/handoff.md +227 -0
  32. package/gemini/skill/references/limits.md +31 -0
  33. package/gemini/skill/references/planning.md +168 -0
  34. package/gemini/skill/references/verification.md +155 -0
  35. package/gemini/skill/references/worktree-creation.md +8 -0
  36. package/lib/color/palette.mjs +6 -0
  37. package/lib/installer/acquisition.mjs +7 -5
  38. package/lib/installer/install-mode.mjs +49 -26
  39. package/lib/installer/install.mjs +3 -2
  40. package/lib/installer/manifest.mjs +20 -14
  41. package/lib/installer/plan.mjs +24 -21
  42. package/lib/installer/preset.mjs +9 -8
  43. package/lib/installer/role-routing.mjs +160 -81
  44. package/lib/installer/runtime-assets.mjs +2 -0
  45. package/lib/installer/runtime-config.mjs +3 -0
  46. package/lib/installer/skill-sources.mjs +4 -3
  47. package/lib/installer/superpowers.mjs +2 -1
  48. package/lib/installer/target-errors.mjs +1 -0
  49. package/lib/installer/targets.mjs +14 -6
  50. package/lib/installer/uninstall.mjs +5 -4
  51. package/lib/installer/upgrade-state.mjs +14 -10
  52. package/lib/installer/upgrade.mjs +9 -5
  53. package/lib/management/operations.mjs +96 -48
  54. package/lib/management/status.mjs +10 -8
  55. package/lib/management/update.mjs +8 -7
  56. package/lib/models/catalog-gemini.mjs +48 -0
  57. package/lib/models/catalog.mjs +27 -12
  58. package/lib/models/config.mjs +23 -22
  59. package/lib/models/gemini-models.json +12 -0
  60. package/lib/models/profiles.mjs +7 -5
  61. package/lib/models/static-catalog.mjs +13 -14
  62. package/lib/npm/upgrade.mjs +2 -2
  63. package/lib/platforms/availability.mjs +98 -0
  64. package/lib/platforms/claude.mjs +14 -0
  65. package/lib/platforms/codex.mjs +16 -0
  66. package/lib/platforms/formats/gemini-markdown.mjs +48 -0
  67. package/lib/platforms/formats/markdown.mjs +39 -0
  68. package/lib/platforms/formats/toml.mjs +39 -0
  69. package/lib/platforms/gemini.mjs +14 -0
  70. package/lib/platforms/index.mjs +27 -0
  71. package/lib/policy/placement.mjs +4 -4
  72. package/lib/policy/render.mjs +13 -8
  73. package/lib/policy/role-policy.json +40 -21
  74. package/lib/prompts/agent-fragments.json +71 -1
  75. package/lib/prompts/render.mjs +32 -11
  76. package/lib/runtime/bootstrap.mjs +1 -1
  77. package/lib/runtime/cooperative-schema.mjs +0 -23
  78. package/lib/runtime/cooperative.mjs +13 -34
  79. package/lib/runtime/evaluate.mjs +3 -69
  80. package/lib/runtime/gemini-stream.mjs +32 -0
  81. package/lib/runtime/git-evidence.mjs +0 -98
  82. package/lib/runtime/identity.mjs +2 -1
  83. package/lib/runtime/local-cli.mjs +14 -24
  84. package/lib/runtime/operations.mjs +2 -2
  85. package/lib/runtime/platform-registry.mjs +130 -0
  86. package/lib/runtime/role-bridge-args.mjs +57 -2
  87. package/lib/runtime/role-bridge.mjs +86 -65
  88. package/lib/runtime/role-dispatch-policy.mjs +17 -7
  89. package/lib/runtime/role-dispatch-store.mjs +20 -14
  90. package/lib/runtime/role-observe.mjs +1 -0
  91. package/lib/runtime/role-routing-config.mjs +36 -9
  92. package/lib/runtime/role-routing.mjs +62 -29
  93. package/lib/runtime/role-supervisor.mjs +114 -49
  94. package/lib/runtime/schema.mjs +5 -4
  95. package/lib/tui/app.mjs +84 -35
  96. package/lib/tui/custom-preset.mjs +114 -68
  97. package/lib/tui/derive-install-plan.mjs +19 -0
  98. package/lib/tui/diagram.mjs +68 -0
  99. package/lib/tui/mode.mjs +77 -0
  100. package/lib/tui/render.mjs +47 -16
  101. package/lib/tui/setup.mjs +168 -100
  102. package/lib/tui/terminal.mjs +9 -6
  103. package/lib/watch/anchor-store.mjs +44 -0
  104. package/lib/watch/dispatch.mjs +3 -3
  105. package/lib/watch/index.mjs +37 -24
  106. package/lib/watch/model.mjs +1 -0
  107. package/lib/watch/normalize-claude.mjs +50 -10
  108. package/lib/watch/normalize-codex.mjs +79 -5
  109. package/lib/watch/render.mjs +30 -13
  110. package/lib/watch/scope.mjs +2 -1
  111. package/lib/watch/status-line.mjs +51 -0
  112. package/lib/watch/tail.mjs +27 -0
  113. package/lib/watch/watcher.mjs +193 -53
  114. package/package.json +2 -1
  115. package/scripts/update-manifest.mjs +2 -2
  116. package/shared/skill/runtime/bootstrap.mjs +1 -1
  117. package/shared/skill/runtime/cooperative-schema.mjs +0 -23
  118. package/shared/skill/runtime/cooperative.mjs +13 -34
  119. package/shared/skill/runtime/evaluate.mjs +3 -69
  120. package/shared/skill/runtime/gemini-stream.mjs +32 -0
  121. package/shared/skill/runtime/git-evidence.mjs +0 -98
  122. package/shared/skill/runtime/identity.mjs +2 -1
  123. package/shared/skill/runtime/local-cli.mjs +14 -24
  124. package/shared/skill/runtime/operations.mjs +2 -2
  125. package/shared/skill/runtime/platform-registry.mjs +130 -0
  126. package/shared/skill/runtime/role-bridge-args.mjs +57 -2
  127. package/shared/skill/runtime/role-bridge.mjs +86 -65
  128. package/shared/skill/runtime/role-dispatch-policy.mjs +17 -7
  129. package/shared/skill/runtime/role-dispatch-store.mjs +20 -14
  130. package/shared/skill/runtime/role-observe.mjs +1 -0
  131. package/shared/skill/runtime/role-policy.json +40 -21
  132. package/shared/skill/runtime/role-routing-config.mjs +36 -9
  133. package/shared/skill/runtime/role-routing.mjs +62 -29
  134. package/shared/skill/runtime/role-supervisor.mjs +114 -49
  135. package/shared/skill/runtime/schema.mjs +5 -4
@@ -1,4 +1,5 @@
1
1
  import { parseToml, exactKeys, validateRoles, effortField, ROLES, fail } from './config.mjs';
2
+ import { runtimeRegistryOf } from '../runtime/platform-registry.mjs';
2
3
  const tools = {
3
4
  arc_scouter: ['Read', 'Grep', 'Glob', 'WebFetch', 'WebSearch'],
4
5
  arc_planner: ['Read', 'Grep', 'Glob'],
@@ -49,7 +50,7 @@ function locateRootFields(lines) {
49
50
  }
50
51
  return { fields, firstTable };
51
52
  }
52
- function renderCodex(text, role, settings) {
53
+ export function renderCodex(text, role, settings) {
53
54
  const parsed = parseToml(text); if (parsed.name !== role) fail('Codex profile name does not match role filename');
54
55
  const lines = linesOf(text), { fields, firstTable } = locateRootFields(lines);
55
56
  const missing = [];
@@ -73,7 +74,7 @@ function renderCodex(text, role, settings) {
73
74
  if (checked.name !== role || Object.entries(settings).some(([key, value]) => checked[key] !== value)) fail('Rendered Codex profile does not match settings');
74
75
  return Buffer.from(output);
75
76
  }
76
- function renderClaude(text, role, settings) {
77
+ export function renderClaude(text, role, settings) {
77
78
  const lines = linesOf(text); if (lines[0]?.replace(/\r?\n$/, '') !== '---') fail('Missing opening Claude frontmatter');
78
79
  const fields = {}, indices = {}; let current, closed = false;
79
80
  for (let i = 1; i < lines.length; i++) {
@@ -96,14 +97,15 @@ function renderClaude(text, role, settings) {
96
97
  for (const key of ['model', 'effort']) { const index = indices[key], eol = /\r?\n$/.exec(lines[index])?.[0] ?? ''; lines[index] = `${key}: ${settings[key]}${eol}`; }
97
98
  return Buffer.from(lines.join(''));
98
99
  }
99
- export function renderProfiles(profileBuffers, config) {
100
+ export function renderProfiles(profileBuffers, config, opts = {}) {
100
101
  exactKeys(config, ['platform', 'roles'], 'effective model settings');
101
- const platform = config.platform, validated = {roles: validateRoles(config.roles, platform)}, extension = platform === 'codex' ? 'toml' : 'md';
102
+ const platform = config.platform, validated = {roles: validateRoles(config.roles, platform, opts)}, extension = runtimeRegistryOf(opts).getPlatform(platform).profile.ext;
103
+ const renderProfile = opts.renderProfile ?? (extension === 'toml' ? renderCodex : renderClaude);
102
104
  if (profileBuffers instanceof Map) profileBuffers = Object.fromEntries(profileBuffers);
103
105
  const names = ROLES.map(role => `${role.replace('_', '-')}.${extension}`);
104
106
  if (!profileBuffers || Object.keys(profileBuffers).length !== names.length || names.some(name => !Object.hasOwn(profileBuffers, name))) fail('Profile set must contain exactly the five platform role files');
105
107
  return new Map(names.map((name, index) => {
106
108
  const role = ROLES[index], text = decode(profileBuffers[name]);
107
- return [name, platform === 'codex' ? renderCodex(text, role, validated.roles[role]) : renderClaude(text, role, validated.roles[role])];
109
+ return [name, renderProfile(text, role, validated.roles[role])];
108
110
  }));
109
111
  }
@@ -1,18 +1,15 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import { ROUTING_ROLES, validRoleValues } from '../runtime/role-routing-config.mjs';
3
+ import { installerRegistryOf } from '../platforms/index.mjs';
3
4
 
4
- const files = {
5
- codex: new URL('./codex-models.json', import.meta.url),
6
- claude: new URL('./claude-models.json', import.meta.url),
7
- };
8
5
  const pairKey = (model, effort) => JSON.stringify([model, effort]);
9
6
  const exact = (value, keys) => value && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length === keys.length && keys.every(key => Object.hasOwn(value, key));
10
7
 
11
- function validateCatalog(platform, catalog, { strict = true } = {}) {
8
+ function validateCatalog(platform, catalog, { strict = true, validatePair = (model, effort) => validRoleValues(platform, model, effort) } = {}) {
12
9
  if (!catalog || typeof catalog !== 'object' || Array.isArray(catalog) || (strict && !exact(catalog, ['platform', 'pairs'])) || catalog.platform !== platform || !Array.isArray(catalog.pairs) || !catalog.pairs.length) throw Error(`${platform} model catalog is invalid`);
13
10
  const pairs = new Set();
14
11
  for (const pair of catalog.pairs) {
15
- if (!exact(pair, ['model', 'effort']) || !validRoleValues(platform, pair.model, pair.effort)) throw Error(`${platform} model catalog is invalid`);
12
+ if (!exact(pair, ['model', 'effort']) || !validatePair(pair.model, pair.effort)) throw Error(`${platform} model catalog is invalid`);
16
13
  const key = pairKey(pair.model, pair.effort);
17
14
  if (pairs.has(key)) throw Error(`${platform} model catalog is invalid`);
18
15
  pairs.add(key);
@@ -20,23 +17,25 @@ function validateCatalog(platform, catalog, { strict = true } = {}) {
20
17
  return pairs;
21
18
  }
22
19
 
23
- export async function loadStaticModelCatalog(platform, { signal } = {}) {
24
- if (!Object.hasOwn(files, platform)) return { status: 'unavailable', code: 'unsupported_platform', message: `${platform} model catalog is unavailable` };
20
+ export async function loadStaticModelCatalog(platform, { signal, platforms } = {}) {
21
+ const descriptor = installerRegistryOf({platforms}).getPlatform(platform);
22
+ if (!descriptor) return { status: 'unavailable', code: 'unsupported_platform', message: `${platform} model catalog is unavailable` };
25
23
  try {
26
- const catalog = JSON.parse(await readFile(files[platform], { encoding: 'utf8', signal }));
27
- validateCatalog(platform, catalog);
24
+ const catalog = JSON.parse(await readFile(descriptor.models.staticCatalog, { encoding: 'utf8', signal }));
25
+ validateCatalog(platform, catalog, {validatePair: descriptor.runtime.routing.validatePair});
28
26
  return { status: 'ready', catalog };
29
27
  } catch {
30
28
  return { status: 'unavailable', code: signal?.aborted ? 'aborted' : 'unavailable', message: `${platform} model catalog is unavailable or invalid` };
31
29
  }
32
30
  }
33
31
 
34
- export function assertCompositeCatalogRoles({ roles, catalogs }) {
35
- const available = Object.fromEntries(['codex', 'claude'].map(platform => [platform, validateCatalog(platform, catalogs?.[platform], { strict: false })]));
32
+ export function assertCompositeCatalogRoles({ roles, catalogs, platforms }) {
33
+ const registry = installerRegistryOf({platforms});
34
+ const available = Object.fromEntries(Object.keys(catalogs ?? {}).map(platform => [platform, validateCatalog(platform, catalogs[platform], { strict: false, validatePair: registry.getPlatform(platform)?.runtime.routing.validatePair })]));
36
35
  if (!exact(roles, ROUTING_ROLES)) throw Error('Invalid composite roles');
37
36
  for (const role of ROUTING_ROLES) {
38
37
  const value = roles[role];
39
- if (!exact(value, ['platform', 'model', 'effort']) || !validRoleValues(value.platform, value.model, value.effort)) throw Error(`Invalid role routing values for ${role}`);
40
- if (!available[value.platform].has(pairKey(value.model, value.effort))) throw Error(`${value.platform} model and effort are unavailable for ${role}`);
38
+ if (!exact(value, ['platform', 'model', 'effort']) || !registry.getPlatform(value.platform)?.runtime.routing.validatePair(value.model, value.effort)) throw Error(`Invalid role routing values for ${role}`);
39
+ if (!available[value.platform]?.has(pairKey(value.model, value.effort))) throw Error(`${value.platform} model and effort are unavailable for ${role}`);
41
40
  }
42
41
  }
@@ -45,10 +45,10 @@ export async function runNpxUpgrade({context,expectedVersion,expectedStateToken,
45
45
  if(typeof api.inspectNpmContext!=='function'||typeof api.collectInstalledState!=='function'||typeof api.upgradeInstalledTargets!=='function')throw Error('Pinned ARC management API is unavailable');
46
46
  const context=await api.inspectNpmContext({packageRoot:root,entryPath:entry,env:process.env,cwd});
47
47
  if(context.kind!=='npx'||context.packageRoot!==root)throw Error('Cannot verify pinned npm exec context');
48
- const state=api.collectInstalledState({safeFs:api.safeFs,userHome:os.homedir(),env:process.env,cwd});
48
+ const state=api.collectInstalledState({safeFs:api.safeFs,userHome:os.homedir(),env:process.env,cwd,platforms:api.platforms,runtimePlatforms:api.runtimePlatforms});
49
49
  if(state.stateToken!==expectedStateToken||!state.targets.length)throw Error('Installed ARC settings changed before pinned upgrade');
50
50
  const controller=new AbortController(),abort=()=>controller.abort();process.once('SIGINT',abort);process.once('SIGTERM',abort);
51
- try{process.exitCode=management.report(await api.upgradeInstalledTargets({packageRoot:root,state,safeFs:api.safeFs,signal:controller.signal}),process.stdout,process.stderr);}finally{process.removeListener('SIGINT',abort);process.removeListener('SIGTERM',abort);}
51
+ try{process.exitCode=management.report(await api.upgradeInstalledTargets({packageRoot:root,state,safeFs:api.safeFs,signal:controller.signal,registry:api.platforms}),process.stdout,process.stderr);}finally{process.removeListener('SIGINT',abort);process.removeListener('SIGTERM',abort);}
52
52
  }catch(error){console.error('Error: '+error.message);process.exitCode=2;}`;
53
53
  return runNpm(context.npmCli,['exec','--yes','--package','@yunhozz/arc@'+expectedVersion,'--',process.execPath,'--input-type=module','-e',bootstrap],{env,cwd,signal});
54
54
  }
@@ -0,0 +1,98 @@
1
+ import {DEFAULT_INSTALLER_REGISTRY, platformLabel} from './index.mjs';
2
+
3
+ export const REASON_TEXT = Object.freeze({
4
+ capability_not_verified: 'capability not verified',
5
+ not_installed: 'not installed',
6
+ unsupported_version: 'unsupported version',
7
+ unauthorized: 'unauthorized',
8
+ auth_check_failed: 'auth check failed',
9
+ catalog_error: 'catalog error',
10
+ });
11
+
12
+ // Range evaluation stays local: the installer has no runtime package dependencies.
13
+ function versionParts(text, partial = false) {
14
+ if (typeof text !== 'string') return null;
15
+ const match = /^(?:v|=)?(0|[1-9]\d*|[xX*])(?:\.(0|[1-9]\d*|[xX*]))?(?:\.(0|[1-9]\d*|[xX*]))?(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(text);
16
+ if (!match) return null;
17
+ const numbers = match.slice(1, 4).map(value => value === undefined || /^[xX*]$/.test(value) ? null : Number(value));
18
+ if (!partial && numbers.includes(null)) return null;
19
+ if (numbers.some(value => value !== null && !Number.isSafeInteger(value))) return null;
20
+ const pre = match[4]?.split('.') ?? [];
21
+ if (pre.some(value => /^\d+$/.test(value) && value.length > 1 && value.startsWith('0'))) return null;
22
+ return {numbers, pre};
23
+ }
24
+ function compare(a, b) {
25
+ for (let i = 0; i < 3; i++) if (a.numbers[i] !== b.numbers[i]) return a.numbers[i] < b.numbers[i] ? -1 : 1;
26
+ if (!a.pre.length || !b.pre.length) return a.pre.length === b.pre.length ? 0 : a.pre.length ? -1 : 1;
27
+ for (let i = 0; i < Math.max(a.pre.length, b.pre.length); i++) {
28
+ const x = a.pre[i], y = b.pre[i];
29
+ if (x === y) continue;
30
+ if (x === undefined || y === undefined) return x === undefined ? -1 : 1;
31
+ const xn = /^\d+$/.test(x), yn = /^\d+$/.test(y);
32
+ if (xn && yn) return BigInt(x) < BigInt(y) ? -1 : 1;
33
+ if (xn !== yn) return xn ? -1 : 1;
34
+ return x < y ? -1 : 1;
35
+ }
36
+ return 0;
37
+ }
38
+ const bound = numbers => ({numbers, pre: []});
39
+ function comparators(token) {
40
+ const match = /^(>=|<=|>|<|=|\^|~)?(.*)$/.exec(token), op = match[1] ?? '=', value = versionParts(match[2], true);
41
+ if (!value) return null;
42
+ const missing = value.numbers.indexOf(null), low = {...value, numbers: value.numbers.map(n => n ?? 0)}, [major, minor, patch] = low.numbers;
43
+ const next = missing === 0 ? null : bound(missing === 1 ? [major + 1, 0, 0] : [major, minor + 1, 0]);
44
+ if (op === '^' || op === '~') {
45
+ if (missing === 0) return [];
46
+ const high = op === '~' ? (missing === 1 ? [major + 1, 0, 0] : [major, minor + 1, 0])
47
+ : major > 0 || missing === 1 ? [major + 1, 0, 0] : minor > 0 || missing === 2 ? [0, minor + 1, 0] : [0, 0, patch + 1];
48
+ return [['>=', low], ['<', bound(high)]];
49
+ }
50
+ if (missing < 0) return [[op, low]];
51
+ if (missing === 0) return op === '>' || op === '<' ? null : [];
52
+ if (op === '=') return [['>=', low], ['<', next]];
53
+ if (op === '>') return [['>=', next]];
54
+ if (op === '<=') return [['<', next]];
55
+ return [[op, low]];
56
+ }
57
+ export function supportedVersion(version, range) {
58
+ if (range === null) return true;
59
+ const current = versionParts(version);
60
+ if (!current || typeof range !== 'string') return false;
61
+ return range.split('||').some(part => {
62
+ const expanded = part.trim().replace(/(\S+)\s+-\s+(\S+)/g, '>= $1 <= $2').replace(/(>=|<=|>|<|=|\^|~)\s+/g, '$1');
63
+ const groups = expanded ? expanded.split(/\s+/).map(comparators) : [[]];
64
+ if (groups.includes(null)) return false;
65
+ const checks = groups.flat();
66
+ if (current.pre.length && !checks.some(([, target]) => target.pre.length && target.numbers.every((n, i) => n === current.numbers[i]))) return false;
67
+ return checks.every(([op, target]) => {
68
+ const result = compare(current, target);
69
+ return op === '>=' ? result >= 0 : op === '<=' ? result <= 0 : op === '>' ? result > 0 : op === '<' ? result < 0 : result === 0;
70
+ });
71
+ });
72
+ }
73
+
74
+ export function platformAvailability(id, {status, catalog, usage, registry = DEFAULT_INSTALLER_REGISTRY} = {}) {
75
+ const runtime = registry.getPlatform(id)?.runtime;
76
+ const required = usage === 'standalone' ? ['install', 'standalone'] : [usage === 'role' ? 'compositeRole' : 'compositeHost'];
77
+ const blocked = reason => ({selectable: false, reason, warning: null});
78
+ if (!runtime || required.some(key => runtime.capabilities[key]?.state !== 'verified')) return blocked('capability_not_verified');
79
+ let warning = null;
80
+ if (usage !== 'standalone') {
81
+ const auth = status?.authentication;
82
+ if (auth?.reason === 'cli_not_found' || status?.cliVersion?.reason === 'cli_not_found') return blocked('not_installed');
83
+ if (!supportedVersion(status?.cliVersion?.version, runtime.cli.supportedVersions)) return blocked('unsupported_version');
84
+ if (auth?.authStatus === 'unauthorized') return blocked('unauthorized');
85
+ if (auth?.authStatus !== 'authenticated') {
86
+ if (runtime.auth.kind !== 'none') return blocked('auth_check_failed');
87
+ warning = 'auth_unverified';
88
+ }
89
+ }
90
+ if (catalog !== undefined && (catalog?.status !== 'ready' || !Array.isArray(catalog.catalog?.pairs) || !catalog.catalog.pairs.length)) return blocked('catalog_error');
91
+ return {selectable: true, reason: null, warning};
92
+ }
93
+
94
+ export function reasonDetail(id, availability, status, registry = DEFAULT_INSTALLER_REGISTRY) {
95
+ if (!availability?.reason) return availability?.warning === 'auth_unverified' ? `${platformLabel(id, registry)}: auth unverified — ARC cannot confirm ${platformLabel(id, registry)} CLI login.` : '';
96
+ const messages = [status?.authentication?.reason, ...(status?.diagnostics ?? []).map(error => error?.message)].filter(Boolean);
97
+ return `${platformLabel(id, registry)}: ${REASON_TEXT[availability.reason]}${messages.length ? ': ' + messages.join('; ') : ''}`;
98
+ }
@@ -0,0 +1,14 @@
1
+ import {getPlatform} from '../runtime/platform-registry.mjs';
2
+ import * as format from './formats/markdown.mjs';
3
+ import {discoverAnthropicCatalog} from '../models/catalog-anthropic.mjs';
4
+
5
+ export const CLAUDE_INSTALLER = Object.freeze({
6
+ runtime: getPlatform('claude'),
7
+ payloadPrefix: 'claude', instructionFile: 'CLAUDE.md', runtimeConfigFile: 'settings.json',
8
+ globalPaths: Object.freeze(['CLAUDE.md', 'settings.json']),
9
+ models: Object.freeze({staticCatalog: new URL('../models/claude-models.json', import.meta.url), effortField: getPlatform('claude').models.effortField, discover: discoverAnthropicCatalog}),
10
+ profiles: Object.freeze({render: format.render, isOwnedStandalone: format.isOwnedStandalone, renameForRouting: format.renameForRouting}),
11
+ runtimeConfig: Object.freeze({readConcurrency: format.readConcurrency, renderConcurrency: format.renderConcurrency, extraRender: null}),
12
+ uninstallSummary: 'Claude settings.json native concurrency key is preserved.',
13
+ isolationEnv: () => ({}),
14
+ });
@@ -0,0 +1,16 @@
1
+ import path from 'node:path';
2
+ import {getPlatform} from '../runtime/platform-registry.mjs';
3
+ import * as format from './formats/toml.mjs';
4
+ import {renderWaitSettings} from '../installer/global-config.mjs';
5
+ import {listCodexModelCapabilities} from '../models/codex-catalog.mjs';
6
+
7
+ export const CODEX_INSTALLER = Object.freeze({
8
+ runtime: getPlatform('codex'),
9
+ payloadPrefix: 'codex', instructionFile: 'AGENTS.md', runtimeConfigFile: 'config.toml',
10
+ globalPaths: Object.freeze(['AGENTS.md', 'config.toml']),
11
+ models: Object.freeze({staticCatalog: new URL('../models/codex-models.json', import.meta.url), effortField: getPlatform('codex').models.effortField, discover: listCodexModelCapabilities}),
12
+ profiles: Object.freeze({render: format.render, isOwnedStandalone: format.isOwnedStandalone, renameForRouting: format.renameForRouting}),
13
+ runtimeConfig: Object.freeze({readConcurrency: format.readConcurrency, renderConcurrency: format.renderConcurrency, extraRender: renderWaitSettings}),
14
+ uninstallSummary: 'Codex config.toml wait settings and native concurrency key are preserved.',
15
+ isolationEnv: work => ({CODEX_HOME: path.join(work, 'codex-runtime')}),
16
+ });
@@ -0,0 +1,48 @@
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
+ // A deliberately narrow scalar-only frontmatter format, verified live by L3 evidence (2026-11-16).
13
+ function parse(text) {
14
+ const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]+)$/.exec(text);
15
+ if (!match || !match[2].trim()) fail('Invalid Gemini profile frontmatter or instructions');
16
+ const fields = {};
17
+ for (const line of match[1].split(/\r?\n/)) {
18
+ const entry = /^([a-z][a-zA-Z0-9_-]*): (.+)$/.exec(line);
19
+ if (!entry || Object.hasOwn(fields, entry[1]) || !validScalar(entry[2])) fail('Malformed or duplicate Gemini frontmatter');
20
+ fields[entry[1]] = entry[2];
21
+ }
22
+ if (!['name', 'description', 'model'].every(key => fields[key]) || Object.hasOwn(fields, 'effort')) fail('Invalid Gemini profile fields');
23
+ if (!getPlatform('gemini').routing.validatePair(fields.model, 'default')) fail('Invalid Gemini profile model');
24
+ return {fields, header: match[1]};
25
+ }
26
+
27
+ export function render(text, role, settings) {
28
+ const {fields, header} = parse(text);
29
+ if (!validRole(role) || fields.name !== role.replace('_', '-') || !getPlatform('gemini').routing.validatePair(settings.model, settings.effort)) fail('Invalid Gemini profile identity or settings');
30
+ const rendered = header.replace(/^model: .+$/m, line => `model: ${settings.model}${line.endsWith('\r') ? '\r' : ''}`);
31
+ return Buffer.from(text.replace(header, () => rendered));
32
+ }
33
+
34
+ export function isOwnedStandalone(bytes, role) {
35
+ try {
36
+ const text = bytes.toString('utf8'), {fields} = parse(text);
37
+ return validRole(role) && fields.name === role.replace('_', '-') && /^\[ARC role policy: contract begin\]\r?$/m.test(text);
38
+ } catch {return false;}
39
+ }
40
+
41
+ export function renameForRouting(bytes, role, revision) {
42
+ if (typeof revision !== 'string' || !/^[A-Za-z0-9._-]{1,128}$/.test(revision)) fail('Composite revision cannot be tagged');
43
+ const text = bytes.toString('utf8'), {fields, header} = parse(text);
44
+ if (!validRole(role) || fields.name !== role.replace('_', '-')) fail('Cannot identify the managed composite profile name');
45
+ const renamed = header.replace(/^name: .+(\r?)$/m, () => `name: arc-routing-${role.slice(4)}${header.split('\n')[0].endsWith('\r') ? '\r' : ''}`)
46
+ .replace(/^(description: .*?)(\r?)$/m, (_line, description, cr) => `${description} ${revisionTag(revision)}${cr}`);
47
+ return Buffer.from(text.replace(header, () => renamed));
48
+ }
@@ -0,0 +1,39 @@
1
+ import {TargetConfigurationError} from '../../installer/target-errors.mjs';
2
+ import {revisionTag} from '../../runtime/role-dispatch-policy.mjs';
3
+ export {renderClaude as render} from '../../models/profiles.mjs';
4
+ export {readClaudeConcurrency as readConcurrency, renderClaudeConcurrency as renderConcurrency} from '../../installer/runtime-config.mjs';
5
+
6
+ const fail=message=>{throw new TargetConfigurationError(message);};
7
+ export function isOwnedStandalone(bytes,role){
8
+ const platform='claude';
9
+ if(!/^arc_(scouter|planner|implementer|qa|reviewer)$/.test(role))return false;
10
+ const text=bytes.toString('utf8'),suffix=role.slice(4);
11
+ if(!/^\[ARC role policy: contract begin\]\r?$/m.test(text))return false;
12
+ if(platform==='claude'){
13
+ const front=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text);if(!front)return false;
14
+ const names=front[1].match(/^name: .*\r?$/gm)??[];return names.length===1&&new RegExp(`^name: arc-${suffix}\\r?$`).test(names[0]);
15
+ }
16
+ if(platform!=='codex')return false;
17
+ const names=text.match(/^name[ \t]*=.*\r?$/gm)??[];
18
+ return names.length===1&&new RegExp(`^name[ \\t]*=[ \\t]*"arc_${suffix}"[ \\t]*(#.*)?\\r?$`).test(names[0]);
19
+ }
20
+ export function renameForRouting(bytes,role,revision){
21
+ const platform='claude';
22
+ if(typeof revision!=='string'||!/^[A-Za-z0-9._-]{1,128}$/.test(revision))fail('Composite revision cannot be tagged');
23
+ const suffix=role.slice(4),old=platform==='codex'?`arc_${suffix}`:`arc-${suffix}`,next=platform==='codex'?`arc_routing_${suffix}`:`arc-routing-${suffix}`;
24
+ const text=bytes.toString('utf8'),pattern=platform==='codex'?new RegExp(`^name[ \\t]*=[ \\t]*["']${old}["']([ \\t]*(?:#[^\\r\\n]*)?)(\\r?)$`,'m'):new RegExp(`^name: ${old}(\\r?)$`,'m');
25
+ const matches=[...text.matchAll(new RegExp(pattern.source,'gm'))];if(matches.length!==1)fail('Cannot identify the managed composite profile name');
26
+ const renamed=platform==='codex'?text.replace(pattern,(_match,comment,cr)=>`name = "${next}"${comment}${cr}`):text.replace(pattern,(_match,cr)=>`name: ${next}${cr}`);
27
+ return Buffer.from(tagDescription(renamed,platform,revision));
28
+ }
29
+
30
+ /** Only the header (before developer_instructions or the closing frontmatter fence) is searched, so instruction text cannot be mistaken for a description. */
31
+ function tagDescription(text,platform,revision){
32
+ const tag=revisionTag(revision),lines=text.split('\n'),codex=platform==='codex',end=lines.findIndex((line,index)=>codex?/^developer_instructions[ \t]*=/.test(line):index>0&&line.replace(/\r$/,'')==='---'),limit=end<0?lines.length:end;
33
+ const pattern=codex?/^(description[ \t]*=[ \t]*"(?:[^"\\]|\\.)*)("[ \t]*(?:#[^\r\n]*)?\r?)$/:/^(description: .*?)(\r?)$/,hits=[];
34
+ for(let i=0;i<limit;i++)if(/^description[ \t]*[=:]/.test(lines[i]))hits.push(i);
35
+ const match=hits.length===1?pattern.exec(lines[hits[0]]):null;if(!match)fail('Composite revision cannot be tagged');
36
+ lines[hits[0]]=`${match[1]} ${tag}${match[2]}`;
37
+ return lines.join('\n');
38
+ }
39
+
@@ -0,0 +1,39 @@
1
+ import {TargetConfigurationError} from '../../installer/target-errors.mjs';
2
+ import {revisionTag} from '../../runtime/role-dispatch-policy.mjs';
3
+ export {renderCodex as render} from '../../models/profiles.mjs';
4
+ export {readCodexConcurrency as readConcurrency, renderCodexConcurrency as renderConcurrency} from '../../installer/runtime-config.mjs';
5
+
6
+ const fail=message=>{throw new TargetConfigurationError(message);};
7
+ export function isOwnedStandalone(bytes,role){
8
+ const platform='codex';
9
+ if(!/^arc_(scouter|planner|implementer|qa|reviewer)$/.test(role))return false;
10
+ const text=bytes.toString('utf8'),suffix=role.slice(4);
11
+ if(!/^\[ARC role policy: contract begin\]\r?$/m.test(text))return false;
12
+ if(platform==='claude'){
13
+ const front=/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text);if(!front)return false;
14
+ const names=front[1].match(/^name: .*\r?$/gm)??[];return names.length===1&&new RegExp(`^name: arc-${suffix}\\r?$`).test(names[0]);
15
+ }
16
+ if(platform!=='codex')return false;
17
+ const names=text.match(/^name[ \t]*=.*\r?$/gm)??[];
18
+ return names.length===1&&new RegExp(`^name[ \\t]*=[ \\t]*"arc_${suffix}"[ \\t]*(#.*)?\\r?$`).test(names[0]);
19
+ }
20
+ export function renameForRouting(bytes,role,revision){
21
+ const platform='codex';
22
+ if(typeof revision!=='string'||!/^[A-Za-z0-9._-]{1,128}$/.test(revision))fail('Composite revision cannot be tagged');
23
+ const suffix=role.slice(4),old=platform==='codex'?`arc_${suffix}`:`arc-${suffix}`,next=platform==='codex'?`arc_routing_${suffix}`:`arc-routing-${suffix}`;
24
+ const text=bytes.toString('utf8'),pattern=platform==='codex'?new RegExp(`^name[ \\t]*=[ \\t]*["']${old}["']([ \\t]*(?:#[^\\r\\n]*)?)(\\r?)$`,'m'):new RegExp(`^name: ${old}(\\r?)$`,'m');
25
+ const matches=[...text.matchAll(new RegExp(pattern.source,'gm'))];if(matches.length!==1)fail('Cannot identify the managed composite profile name');
26
+ const renamed=platform==='codex'?text.replace(pattern,(_match,comment,cr)=>`name = "${next}"${comment}${cr}`):text.replace(pattern,(_match,cr)=>`name: ${next}${cr}`);
27
+ return Buffer.from(tagDescription(renamed,platform,revision));
28
+ }
29
+
30
+ /** Only the header (before developer_instructions or the closing frontmatter fence) is searched, so instruction text cannot be mistaken for a description. */
31
+ function tagDescription(text,platform,revision){
32
+ const tag=revisionTag(revision),lines=text.split('\n'),codex=platform==='codex',end=lines.findIndex((line,index)=>codex?/^developer_instructions[ \t]*=/.test(line):index>0&&line.replace(/\r$/,'')==='---'),limit=end<0?lines.length:end;
33
+ const pattern=codex?/^(description[ \t]*=[ \t]*"(?:[^"\\]|\\.)*)("[ \t]*(?:#[^\r\n]*)?\r?)$/:/^(description: .*?)(\r?)$/,hits=[];
34
+ for(let i=0;i<limit;i++)if(/^description[ \t]*[=:]/.test(lines[i]))hits.push(i);
35
+ const match=hits.length===1?pattern.exec(lines[hits[0]]):null;if(!match)fail('Composite revision cannot be tagged');
36
+ lines[hits[0]]=`${match[1]} ${tag}${match[2]}`;
37
+ return lines.join('\n');
38
+ }
39
+
@@ -0,0 +1,14 @@
1
+ import {getPlatform} from '../runtime/platform-registry.mjs';
2
+ import * as format from './formats/gemini-markdown.mjs';
3
+ import {discoverGeminiCatalog} from '../models/catalog-gemini.mjs';
4
+
5
+ export const GEMINI_INSTALLER = Object.freeze({
6
+ runtime: getPlatform('gemini'),
7
+ payloadPrefix: 'gemini', instructionTemplates: Object.freeze(['GEMINI.md', 'instructions.md']), instructionFile: 'GEMINI.md', runtimeConfigFile: 'settings.json',
8
+ globalPaths: Object.freeze(['GEMINI.md', 'settings.json']),
9
+ models: Object.freeze({staticCatalog: new URL('../models/gemini-models.json', import.meta.url), effortField: getPlatform('gemini').models.effortField, discover: discoverGeminiCatalog}),
10
+ profiles: Object.freeze({render: format.render, isOwnedStandalone: format.isOwnedStandalone, renameForRouting: format.renameForRouting}),
11
+ runtimeConfig: Object.freeze({}),
12
+ uninstallSummary: 'Gemini settings.json is preserved.',
13
+ isolationEnv: () => ({}),
14
+ });
@@ -0,0 +1,27 @@
1
+ import {DEFAULT_PLATFORM_REGISTRY} from '../runtime/platform-registry.mjs';
2
+ import {CODEX_INSTALLER} from './codex.mjs';
3
+ import {CLAUDE_INSTALLER} from './claude.mjs';
4
+ import {GEMINI_INSTALLER} from './gemini.mjs';
5
+
6
+ export function createInstallerRegistry({runtime, descriptors}) {
7
+ const ids = runtime.platformIds();
8
+ if (descriptors.length !== ids.length || descriptors.some((descriptor, index) => descriptor.runtime !== runtime.getPlatform(ids[index]))) throw Error('Installer platforms must match runtime ids, order and descriptor references');
9
+ const platforms = Object.freeze(descriptors.map(descriptor => Object.freeze({...descriptor})));
10
+ const byId = new Map(platforms.map(descriptor => [descriptor.runtime.id, descriptor]));
11
+ const displayOrder = Object.freeze(runtime.byDisplayOrder().map(descriptor => byId.get(descriptor.id)));
12
+ return Object.freeze({
13
+ platforms,
14
+ platformIds: () => ids,
15
+ getPlatform: id => byId.get(id) ?? null,
16
+ byDisplayOrder: () => displayOrder,
17
+ byAnchorOrder: () => platforms,
18
+ isPlatformId: value => byId.has(value),
19
+ });
20
+ }
21
+
22
+ export const DEFAULT_INSTALLER_REGISTRY = createInstallerRegistry({runtime: DEFAULT_PLATFORM_REGISTRY, descriptors: [CLAUDE_INSTALLER, CODEX_INSTALLER, GEMINI_INSTALLER]});
23
+ export const installerRegistryOf = context => context?.platforms ?? DEFAULT_INSTALLER_REGISTRY;
24
+ export const platformLabel = (id, registry = DEFAULT_INSTALLER_REGISTRY) => registry.getPlatform(id)?.runtime.label ?? id;
25
+ export const sortByDisplay = (ids, registry = DEFAULT_INSTALLER_REGISTRY) => [...ids].sort((a, b) => registry.getPlatform(a).runtime.displayOrder - registry.getPlatform(b).runtime.displayOrder);
26
+ export const sortByAnchor = (ids, registry = DEFAULT_INSTALLER_REGISTRY) => [...ids].sort((a, b) => registry.getPlatform(a).runtime.anchorOrder - registry.getPlatform(b).runtime.anchorOrder);
27
+ export const mixedLabel = (ids, registry = DEFAULT_INSTALLER_REGISTRY) => `Mixed (${sortByDisplay(ids, registry).map(id => platformLabel(id, registry)).join(' + ')})`;
@@ -3,11 +3,11 @@ const reviews = ['review.significant-no-plan', 'review.significant-plan', 'revie
3
3
  export const POLICY_PROJECTIONS = Object.freeze(Object.fromEntries(Object.entries({
4
4
  core: ['scope.non-escalation', 'external.explicit-user-authority', 'role.orchestrator-boundary'],
5
5
  assignment: ['git.specialists-deny', 'role.scouter-read-only', 'role.planner-draft-only', 'role.implementer-implementation', 'role.qa-verification', 'role.reviewer-independent'],
6
- planning: ['git.orchestrator-accept-commit', ...reviews, 'planning.plan-amend', 'planning.planner-brief'],
6
+ planning: ['git.orchestrator-accept-commit', ...reviews, 'planning.plan-revision', 'planning.planner-brief'],
7
7
  handoff: ['git.specialists-deny', 'role.implementer-implementation', ...reviews],
8
- preparation: ['scope.non-escalation', 'git.specialists-deny', 'git.orchestrator-accept-commit', 'external.explicit-user-authority', 'planning.plan-amend'],
9
- verification: ['git.orchestrator-accept-commit', ...reviews, 'planning.plan-amend'],
10
- commit: ['scope.non-escalation', 'git.orchestrator-accept-commit', 'external.explicit-user-authority', 'planning.plan-amend'],
8
+ preparation: ['scope.non-escalation', 'git.specialists-deny', 'git.orchestrator-accept-commit', 'external.explicit-user-authority', 'planning.plan-revision'],
9
+ verification: ['git.orchestrator-accept-commit', ...reviews, 'planning.plan-revision'],
10
+ commit: ['scope.non-escalation', 'git.orchestrator-accept-commit', 'external.explicit-user-authority', 'planning.plan-revision'],
11
11
  }).map(([name, ids]) => [name, Object.freeze(ids)])));
12
12
 
13
13
  export function validatePolicyProjections(policy, projections = POLICY_PROJECTIONS) {
@@ -1,6 +1,9 @@
1
1
  import {POLICY_PROJECTIONS, validatePolicyProjections} from './placement.mjs';
2
2
  import {validateGitPolicy} from '../runtime/git-query.mjs';
3
+ import {platformIds, getPlatform, isPlatformId} from '../runtime/platform-registry.mjs';
3
4
  import source from './role-policy.json' with {type: 'json'};
5
+ // Payload targets are declared by policy metadata; registered platforms may have no payload yet.
6
+ const POLICY_PLATFORMS = Object.freeze(Object.keys(source.platforms));
4
7
  const ROLES = ['orchestrator','scouter','planner','implementer','qa','reviewer'];
5
8
  const CONTROLS = ['prompt','capability','hook'];
6
9
  const fail = message => { throw new Error(`Role policy: ${message}`); };
@@ -15,10 +18,10 @@ export function validateRolePolicy(input) {
15
18
  if (!object(rule) || typeof rule.id !== 'string' || !/^[a-z][a-z0-9.-]+$/.test(rule.id) || ids.has(rule.id)) fail('invalid or duplicate rule ID');
16
19
  ids.add(rule.id);
17
20
  if (!strings(rule.roles) || rule.roles.some(x=>!ROLES.includes(x)) || !['allow','deny','require'].includes(rule.effect) || !strings(rule.operations) || !strings(rule.evidence) || !['user','orchestrator'].includes(rule.authority) || typeof rule.text !== 'string' || !rule.text || /[\r\n]/.test(rule.text)) fail(`invalid rule ${rule.id}`);
18
- if (!object(rule.controls) || !same(Object.keys(rule.controls).sort(),['claude','codex']) || Object.values(rule.controls).some(x=>!CONTROLS.includes(x))) fail(`invalid control level for ${rule.id}`);
21
+ if (!object(rule.controls) || !same(Object.keys(rule.controls).sort(),[...platformIds()].sort()) || Object.values(rule.controls).some(x=>!CONTROLS.includes(x))) fail(`invalid control level for ${rule.id}`);
19
22
  }
20
23
  for (const id of ['scope.non-escalation','git.specialists-deny','git.orchestrator-accept-commit','external.explicit-user-authority',...ROLES.map(x=>({orchestrator:'role.orchestrator-boundary',scouter:'role.scouter-read-only',planner:'role.planner-draft-only',implementer:'role.implementer-implementation',qa:'role.qa-verification',reviewer:'role.reviewer-independent'})[x]),'review.significant-no-plan','review.significant-plan','review.final-plan-recheck']) if(!ids.has(id)) fail(`missing required rule ${id}`);
21
- for (const platform of ['codex','claude']) if (!object(input.platforms?.[platform]) || !CONTROLS.includes(input.platforms[platform].level) || typeof input.platforms[platform].notice !== 'string' || !input.platforms[platform].notice) fail(`invalid ${platform} controls`);
24
+ for (const platform of POLICY_PLATFORMS) if (!object(input.platforms?.[platform]) || !CONTROLS.includes(input.platforms[platform].level) || typeof input.platforms[platform].notice !== 'string' || !input.platforms[platform].notice) fail(`invalid ${platform} controls`);
22
25
  // These are workflow invariants, not customizable scheduling options.
23
26
  const routes = {noPlan:['implementer','qa','reviewer','orchestrator-accept'],planTask:['implementer','fresh-qa','orchestrator-accept','orchestrator-commit'],planFinal:['required-qa','reviewer'],planFinding:['implementer','reviewer']};
24
27
  if (!object(input.review) || Object.keys(input.review).length !== 4 || Object.entries(routes).some(([key,value])=>!same(input.review[key],value))) fail('invalid review routing');
@@ -27,14 +30,14 @@ export function validateRolePolicy(input) {
27
30
  return input;
28
31
  }
29
32
  export const defaultRolePolicy = source;
30
- export const POLICY_TARGETS = ['codex','claude'].flatMap(platform => [
33
+ export const POLICY_TARGETS = POLICY_PLATFORMS.flatMap(platform => [
31
34
  {path:`${platform}/skill/SKILL.md`,platform,audience:'orchestrator',projection:'core'},
32
- ...ROLES.slice(1).map(audience=>({path:`${platform}/agents/arc-${audience}.${platform==='codex'?'toml':'md'}`,platform,audience})),
35
+ ...ROLES.slice(1).map(audience=>({path:`${platform}/agents/arc-${audience}.${getPlatform(platform).profile.ext}`,platform,audience})),
33
36
  ...Object.entries({coordination:'assignment',planning:'planning',handoff:'handoff','handoff-prep':'preparation',commit:'commit',verification:'verification'}).map(([name,projection])=>({path:`${platform}/skill/references/${name}.md`,platform,audience:'orchestrator',projection})),
34
37
  ]);
35
38
  export function renderPolicySection(policy, {platform, audience, section = 'contract', skillPath, projection = 'full'} = {}) {
36
39
  validateRolePolicy(policy);
37
- if (!['codex','claude'].includes(platform) || !ROLES.includes(audience) || !['contract','global'].includes(section)) fail('unknown render target');
40
+ if (!isPlatformId(platform) || !POLICY_PLATFORMS.includes(platform) || !ROLES.includes(audience) || !['contract','global'].includes(section)) fail('unknown render target');
38
41
  let selected;
39
42
  if (projection !== 'full') {
40
43
  if (!Object.hasOwn(POLICY_PROJECTIONS, projection)) fail('unknown policy projection');
@@ -65,11 +68,13 @@ export function replaceManagedPolicyBlocks(text, blocks) {
65
68
  for(const {start,end,body} of ranges.sort((a,b)=>b.start-a.start)) result=result.slice(0,start)+body+result.slice(end);
66
69
  return result;
67
70
  }
68
- export function buildPolicyOutputs(inputs, policy = source) {
71
+ export function buildPolicyOutputs(inputs, policy = source, {platforms = POLICY_PLATFORMS} = {}) {
69
72
  validateRolePolicy(policy);
70
- if (!(inputs instanceof Map) || inputs.size !== POLICY_TARGETS.length) fail('expected complete target map');
73
+ if (!Array.isArray(platforms) || new Set(platforms).size !== platforms.length || platforms.some(platform => !POLICY_PLATFORMS.includes(platform))) fail('unknown output platforms');
74
+ const targets = POLICY_TARGETS.filter(target => platforms.includes(target.platform));
75
+ if (!(inputs instanceof Map) || inputs.size !== targets.length) fail('expected complete target map');
71
76
  const outputs=new Map();
72
- for(const target of POLICY_TARGETS) {
77
+ for(const target of targets) {
73
78
  const bytes=inputs.get(target.path); if(!Buffer.isBuffer(bytes)) fail(`missing target ${target.path}`);
74
79
  let text; try{text=new TextDecoder('utf-8',{fatal:true,ignoreBOM:true}).decode(bytes);}catch{fail(`invalid UTF-8 target ${target.path}`);}
75
80
  let rendered=replaceManagedPolicyBlocks(text,{contract:renderPolicySection(policy,{...target,section:'contract'})});