afyx-engineering-kit 0.1.0-alpha.7 → 0.1.0-alpha.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 (55) hide show
  1. package/.afyx-source-revision +1 -1
  2. package/afyx-context/src/budget.js +39 -153
  3. package/afyx-context/src/documentation.js +116 -0
  4. package/afyx-context/src/index.js +2 -0
  5. package/afyx-context/src/memory.js +122 -229
  6. package/afyx-context/src/usage.js +91 -0
  7. package/afyx-forge/src/cli.js +14 -1
  8. package/afyx-forge/src/index.js +3 -0
  9. package/afyx-forge/src/workflow-refiner.js +48 -15
  10. package/afyx-forge/src/workflow.js +226 -0
  11. package/afyx-graph/engine/release/RELEASE-MANIFEST.json +16 -6
  12. package/afyx-graph/engine/release/SHA256SUMS +4 -2
  13. package/afyx-graph/engine/release/afyx-graph-darwin-arm64.tar.gz +0 -0
  14. package/afyx-graph/engine/release/afyx-graph-darwin-x64.tar.gz +0 -0
  15. package/afyx-graph/engine/release/afyx-graph-linux-x64.tar.gz +0 -0
  16. package/afyx-graph/engine/release/afyx-graph-win32-x64.zip +0 -0
  17. package/bin/afyx-engineering-kit.mjs +14 -6
  18. package/install.ps1 +52 -6
  19. package/install.sh +11 -7
  20. package/package.json +3 -1
  21. package/scripts/afyx-capability-orchestrator.mjs +159 -41
  22. package/scripts/afyx-graph-artifact.mjs +1 -1
  23. package/scripts/afyx-graph-targets.mjs +8 -0
  24. package/scripts/afyx-host-adapters.mjs +52 -0
  25. package/scripts/afyx-host-bridge-lifecycle.mjs +4 -0
  26. package/scripts/afyx-host-bridge.mjs +25 -0
  27. package/scripts/afyx-install-backend.mjs +34 -13
  28. package/scripts/afyx-install-contract.mjs +5 -2
  29. package/scripts/afyx-install-progress.mjs +88 -0
  30. package/scripts/afyx-installer-environment.mjs +150 -0
  31. package/scripts/afyx-local-link-ownership.mjs +16 -0
  32. package/scripts/afyx-midnight-circuit.mjs +322 -79
  33. package/scripts/afyx-modular-integration.mjs +3 -0
  34. package/scripts/afyx-modular-runtime.mjs +3 -0
  35. package/scripts/afyx-native-execution.mjs +168 -0
  36. package/scripts/afyx-native-github.mjs +155 -0
  37. package/scripts/afyx-npm-installer.mjs +56 -28
  38. package/scripts/afyx-provider-inventory.mjs +6 -3
  39. package/scripts/afyx-security-auditor.mjs +61 -64
  40. package/scripts/afyx-skill-catalog.mjs +83 -0
  41. package/scripts/afyx-skill-engineering.mjs +2 -0
  42. package/scripts/afyx-universal-runtime.mjs +74 -12
  43. package/scripts/install-afyx-graph.sh +4 -4
  44. package/scripts/lib/AfyxInstallerProgress.psm1 +11 -0
  45. package/scripts/lib/AfyxSkillLifecycle.psm1 +42 -6
  46. package/scripts/lib/afyx-installer-progress.sh +30 -0
  47. package/scripts/link-global-dev.ps1 +10 -3
  48. package/scripts/link-global-dev.sh +10 -8
  49. package/scripts/prepare-g6-package.mjs +13 -28
  50. package/scripts/resolve-git-release-artifacts.mjs +5 -4
  51. package/scripts/stage-npm-release.mjs +3 -1
  52. package/scripts/validate-release-zip-graph.mjs +2 -2
  53. package/uninstall.ps1 +2 -0
  54. package/verify.ps1 +7 -1
  55. package/verify.sh +5 -3
@@ -1,26 +1,35 @@
1
- import { execFileSync } from 'node:child_process';
2
- import { readFileSync } from 'node:fs';
3
- import { join } from 'node:path';
1
+ import { execFile } from 'node:child_process';
2
+ import { appendFileSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
3
+ import { tmpdir } from 'node:os';
4
+ import { stripVTControlCharacters } from 'node:util';
5
+ import { InstallerProgress, INSTALL_PROGRESS_PREFIX } from './afyx-install-progress.mjs';
6
+ import { dirname, join } from 'node:path';
4
7
  import readline from 'node:readline';
5
- import { PACKAGE_ROOT } from './afyx-npm-installer.mjs';
8
+ import { PACKAGE_ROOT, getPackageVersion } from './afyx-npm-installer.mjs';
6
9
  import { createBackendAdapter, summarizeExecution } from './afyx-install-backend.mjs';
10
+ import { GRAPH_PACKAGE_TARGETS } from './afyx-graph-targets.mjs';
11
+ import { detectInstallerEnvironment, environmentLines, recordBackendExecution } from './afyx-installer-environment.mjs';
7
12
 
8
13
  const stages = ['DETECT', 'SELECT', 'CONFIGURE', 'REVIEW / APPLY', 'FINISH'];
9
14
  const supported = ['antigravity', 'claude', 'codex'];
10
15
 
11
16
  export function terminalMode({ input = process.stdin, output = process.stdout, env = process.env, requested = 'auto' } = {}) {
12
17
  const interactive = Boolean(input.isTTY && output.isTTY && !env.CI);
13
- const ansi = interactive && !env.NO_COLOR && !env.AFYX_PLAIN_OUTPUT && env.TERM !== 'dumb' &&
18
+ const ansi = interactive && env.NO_COLOR === undefined && !env.AFYX_PLAIN_OUTPUT && env.TERM !== 'dumb' &&
14
19
  (output.columns || 80) >= 80 && (output.rows || 24) >= 24;
15
20
  if (requested === 'tui' && !ansi) throw new Error('--ui tui requires an interactive ANSI terminal at least 80 columns by 24 rows. Use --ui plain.');
16
21
  return requested === 'plain' ? 'plain' : ansi ? 'tui' : 'plain';
17
22
  }
18
23
 
19
- export function discoverHosts(pkgRoot = PACKAGE_ROOT) {
20
- try {
21
- const raw = execFileSync(process.execPath, [join(pkgRoot, 'scripts', 'afyx-provider-inventory.mjs'), '--json'], { encoding: 'utf8', timeout: 10000 });
22
- return JSON.parse(raw).filter((entry) => supported.includes(entry.id));
23
- } catch { return []; }
24
+ export function discoverHosts(pkgRoot = PACKAGE_ROOT, signal) {
25
+ return new Promise((resolve, reject) => {
26
+ execFile(process.execPath, [join(pkgRoot, 'scripts', 'afyx-provider-inventory.mjs'), '--json'],
27
+ { encoding: 'utf8', timeout: 10_000, maxBuffer: 2 * 1024 * 1024, windowsHide: true, signal }, (error, raw) => {
28
+ if (error) { reject(new Error(`Provider discovery failed: ${error.message}`)); return; }
29
+ try { const result = JSON.parse(raw); if (!Array.isArray(result)) throw new Error('Invalid inventory'); resolve(result); }
30
+ catch (parseError) { reject(parseError); }
31
+ });
32
+ });
24
33
  }
25
34
 
26
35
  export function providerSelectable(entry, platform = process.platform) {
@@ -39,73 +48,193 @@ export function presetComponents(preset, selected = [], pkgRoot = PACKAGE_ROOT)
39
48
 
40
49
  export function runtimeSupport(preset, platform = process.platform, arch = process.arch) {
41
50
  if (preset !== 'full') return { supported: true, reason: '' };
42
- if (platform === 'darwin') return { supported: false, reason: 'Full requires a verified macOS Graph archive; choose Recommended or Minimal.' };
43
- if (arch !== 'x64') return { supported: false, reason: `Full Graph archive is unavailable for ${platform}/${arch}.` };
51
+ if (!GRAPH_PACKAGE_TARGETS.includes(`${platform}-${arch}`)) return { supported: false, reason: `Full Graph archive is unavailable for ${platform}/${arch}.` };
44
52
  return { supported: true, reason: '' };
45
53
  }
46
54
 
47
55
  function fit(value, width) {
48
- const text = String(value).replace(/[\r\n\t]/g, ' ');
49
- return text.length > width ? `${text.slice(0, Math.max(0, width - 1))}…` : text;
56
+ const text = stripVTControlCharacters(String(value)).replace(/[\r\n\t\x00-\x1f\x7f]/g, ' ');
57
+ const characters = Array.from(text);
58
+ return characters.length > width ? `${characters.slice(0, Math.max(0, width - 1)).join('')}…` : text;
50
59
  }
51
60
 
52
61
  function wrapLines(lines, inner) {
53
62
  return lines.flatMap((line) => {
54
- const text = String(line).replace(/[\r\n\t]/g, ' ');
63
+ const text = stripVTControlCharacters(String(line)).replace(/[\r\n\t\x00-\x1f\x7f]/g, ' ');
55
64
  if (!text) return [''];
56
65
  const chunks = [];
57
- for (let index = 0; index < text.length; index += inner) chunks.push(text.slice(index, index + inner));
66
+ const characters = Array.from(text);
67
+ for (let index = 0; index < characters.length; index += inner) chunks.push(characters.slice(index, index + inner).join(''));
58
68
  return chunks;
59
69
  });
60
70
  }
61
71
 
62
- function panel(title, lines, width, limit, offset = 0) {
72
+ const tones = { cyan: '96', blue: '94', indigo: '94', purple: '95', text: '97', muted: '90', success: '92', error: '91', warning: '93' };
73
+ const rgb = {
74
+ cyan: '34;211;238',
75
+ blue: '96;165;250',
76
+ indigo: '99;102;241',
77
+ purple: '139;92;246',
78
+ text: '229;242;255',
79
+ muted: '147;164;187',
80
+ success: '52;211;153',
81
+ error: '251;113;133',
82
+ warning: '251;191;36',
83
+ dark: '11;16;32',
84
+ };
85
+ const surfaces = { base: '48;2;11;16;32', panel: '48;2;17;25;43', focus: '48;2;34;211;238' };
86
+ const styled = (text, tone, color, surface) => {
87
+ if (!color) return text;
88
+ if (color === 24) {
89
+ const fg = tone === 'focus' ? `1;38;2;${rgb.dark}` : `38;2;${rgb[tone] || rgb.text}`;
90
+ const bg = surface ? `;${surfaces[surface]}` : '';
91
+ return `\x1b[${fg}${bg}m${text}\x1b[0m`;
92
+ }
93
+ if (tone === 'focus') return `\x1b[1;46;30m${text}\x1b[0m`;
94
+ return `\x1b[${tones[tone] || tones.text}m${text}\x1b[0m`;
95
+ };
96
+ const paintLine = (text, tone, color, width, surface = 'base') =>
97
+ color === 24 ? styled(text.padEnd(width), tone, color, surface) : styled(text, tone, color);
98
+ const plainOutputs = new WeakSet();
99
+ const previousFrames = new WeakMap();
100
+
101
+ export function recordInstallerDiagnostic(error) {
102
+ const directory = mkdtempSync(join(tmpdir(), 'afyx-installer-diagnostic-'));
103
+ const path = join(directory, 'diagnostic.log');
104
+ writeFileSync(path, `${error?.stack || String(error)}\n`, { mode: 0o600 });
105
+ return path;
106
+ }
107
+
108
+ function drawScreen(output, screen) {
109
+ if (plainOutputs.has(output)) { output.write(`${stripVTControlCharacters(screen)}\n`); return; }
110
+ const rows = screen.split('\n');
111
+ const before = previousFrames.get(output) || [];
112
+ let patch = '\x1b[?25l';
113
+ for (let row = 0; row < Math.max(rows.length, before.length); row++) {
114
+ if (rows[row] !== before[row]) patch += `\x1b[${row + 1};1H\x1b[2K${rows[row] || ''}`;
115
+ }
116
+ if (patch.length > 6) output.write(patch);
117
+ previousFrames.set(output, rows);
118
+ }
119
+
120
+ function panel(title, lines, width, limit, offset = 0, color = false, tone = 'cyan') {
63
121
  const inner = Math.max(16, width - 4);
64
- const top = `┌ ${fit(title, inner)} ${'─'.repeat(Math.max(0, inner - title.length))}┐`;
122
+ const caption = fit(title, width - 4);
123
+ const top = `╭ ${caption} ${'─'.repeat(Math.max(0, width - caption.length - 4))}╮`;
65
124
  let wrapped = wrapLines(lines, inner);
66
125
  if (limit && wrapped.length > limit) {
67
126
  const start = Math.max(0, Math.min(offset, wrapped.length - Math.max(1, limit - 1)));
68
127
  const total = wrapped.length;
69
128
  wrapped = [...wrapped.slice(start, start + Math.max(1, limit - 1)), fit(`Tab: focus activity; ↑/↓ scroll (${start + 1}/${total})`, inner)];
70
129
  }
71
- return [top, ...wrapped.map((line) => `│ ${line.padEnd(inner)} │`), `└${'─'.repeat(inner + 2)}┘`];
130
+ return [styled(top, tone, color, 'panel'), ...wrapped.map((line) => {
131
+ const isFocus = /^›/.test(line);
132
+ const state = isFocus ? 'focus'
133
+ : /\b(FAILED|FAIL|BLOCKED)\b/.test(line) ? 'error'
134
+ : /\b(PASS|COMPLETED|HEALTHY)\b/.test(line) ? 'success'
135
+ : /\b(WARNING|RESTART)\b/.test(line) ? 'warning'
136
+ : /COMING SOON|OTHER DETECTED/.test(line) ? 'purple'
137
+ : /INDETERMINATE|RUNNING/.test(line) ? 'blue'
138
+ : /^─+$|^RECENT ACTIVITY\b/.test(line) ? 'muted'
139
+ : 'text';
140
+ const rowSurface = isFocus ? 'focus' : 'panel';
141
+ const borderLeft = styled('│ ', tone, color, 'panel');
142
+ const borderRight = styled(' │', tone, color, 'panel');
143
+ return `${borderLeft}${styled(line.padEnd(inner), state, color, rowSurface)}${borderRight}`;
144
+ }), styled(`╰${'─'.repeat(width - 2)}╯`, tone, color, 'panel')];
72
145
  }
73
146
 
74
- export function renderFrame({ stage = 0, providers = [], providerSummary, selection = [], activity = [], width = 80, height = 24, activityOffset = 0, hint = '' } = {}) {
147
+ export function renderFrame({ stage = 0, providers = [], providerSummary, selection = [], activity = [], width = 80, height = 24, activityOffset = 0, providerOffset = 0, hint = '', color = false, ascii = false, failed = false, installing = false, receipt = false, discovering = false, runtime = '', environment } = {}) {
75
148
  const safeWidth = Math.max(40, width);
76
- const stepLine = stages.map((name, index) => `${index + 1} ${name}${index === stage ? ' ●' : ''}`).join(' → ');
77
- const providerLines = providerSummary || (providers.length ? providers.flatMap((entry) => {
149
+ const labels = safeWidth < 112 ? ['DETECT', 'SELECT', 'CONFIG', 'APPLY', 'FINISH'] : stages;
150
+ const stepParts = labels.map((name, index) => styled(`${index === stage ? '[' : ''}${String(index + 1).padStart(2, '0')} ${name}${index < stage ? ' +' : index === stage ? failed ? ' FAILED]' : ' *]' : ''}`, index < stage ? 'success' : index === stage ? failed ? 'error' : 'cyan' : 'muted', color, 'base'));
151
+ const stepText = stepParts.join(paintLine(' ', 'muted', color, 2, 'base'));
152
+ const stepPlainLen = stripVTControlCharacters(stepText).length;
153
+ const stepPad = color === 24 && stepPlainLen < safeWidth ? styled(' '.repeat(safeWidth - stepPlainLen), 'muted', color, 'base') : '';
154
+ const stepLine = stepPlainLen <= safeWidth ? `${stepText}${stepPad}` : paintLine(fit(`STEP ${stage + 1}/5 ${stages[stage]}`, safeWidth), failed ? 'error' : 'cyan', color, safeWidth);
155
+ const ordered = [...providers].sort((a, b) => a.name.localeCompare(b.name));
156
+ const inventoryLines = (entries) => entries.flatMap((entry) => {
78
157
  const products = (entry.products || []).map((product) => `${product.type}${product.version ? ` ${product.version}` : ''}`);
79
- const compact = `${entry.name}: ${products.join(', ') || 'not detected'}`;
80
- if (safeWidth < 112 && compact.length <= safeWidth - 4) return [compact];
81
- return [`${entry.name}: ${products.length ? 'detected' : 'not detected'}`, ...products.map((product) => ` ${product}`)];
82
- }) : ['No supported provider detected']);
158
+ return [`${entry.name}: ${entry.supported === false ? 'COMING SOON' : products.length ? 'detected' : 'not detected'}`, ...products.map((product) => ` ${product}`)];
159
+ });
160
+ const supportedLines = inventoryLines(ordered.filter((entry) => entry.supported !== false));
161
+ const otherLines = inventoryLines(ordered.filter((entry) => entry.supported === false));
162
+ const providerLines = [...(providerSummary || []), ...supportedLines, ...(otherLines.length ? ['OTHER DETECTED', ...otherLines] : [])];
163
+ if (!providerLines.length) providerLines.push(discovering ? 'Discovery in progress' : 'No supported provider detected');
164
+ const footer = wrapLines([hint], safeWidth).slice(0, 2);
165
+ const identity = environment ? wrapLines(environmentLines(environment), safeWidth) : [];
166
+ const budget = Math.max(9, height - 4 - identity.length - footer.length);
167
+ const rightTone = failed ? 'error' : receipt ? 'success' : installing ? 'blue' : 'cyan';
83
168
  let body;
84
- if (safeWidth >= 112) {
85
- const columnWidth = Math.floor((safeWidth - 4) / 3);
86
- const panelLimit = Math.max(3, height - 8);
87
- const pad = (lines) => [...lines, ...Array(Math.max(0, panelLimit - lines.length)).fill('')];
88
- const columns = [
89
- panel('PROVIDERS / HOST', pad(providerLines), columnWidth, panelLimit),
90
- panel('SELECTION / STATUS', pad(selection), columnWidth, panelLimit),
91
- panel('PLAN / ACTIVITY', pad(activity), columnWidth, panelLimit, activityOffset),
92
- ];
93
- body = columns[0].map((_, index) => columns.map((column) => column[index]).join(' '));
169
+ if (safeWidth >= 80) {
170
+ const providerWidth = Math.max(28, Math.floor((safeWidth - 1) * 0.30));
171
+ const selectionWidth = safeWidth - providerWidth - 1;
172
+ const contentLimit = Math.max(6, budget - 2);
173
+ const choicesLimit = Math.max(3, Math.min(8, Math.floor(contentLimit * 0.5)));
174
+ const recentLimit = Math.max(2, contentLimit - choicesLimit - 2);
175
+ const activityLines = wrapLines(activity, selectionWidth - 4);
176
+ const start = Math.max(0, Math.min(activityOffset, Math.max(0, activityLines.length - recentLimit)));
177
+ const rightLines = [...selection.slice(0, choicesLimit).map((line) => fit(line, selectionWidth - 4)),
178
+ '─'.repeat(selectionWidth - 4), `RECENT ACTIVITY${activityLines.length > recentLimit ? ` (${start + 1}/${activityLines.length}; Tab, ↑/↓)` : ''}`,
179
+ ...activityLines.slice(start, start + recentLimit)];
180
+ const left = panel('PROVIDERS / HOST', providerLines, providerWidth, contentLimit, providerOffset, color, 'indigo');
181
+ const title = failed ? 'INSTALLATION FAILED' : installing ? 'INSTALLATION PROGRESS' : receipt ? 'VERIFIED RECEIPT'
182
+ : stage === 3 ? 'REVIEW / APPLY' : stage === 4 ? 'FINISH / VERIFICATION' : 'SELECTION / CONFIGURATION';
183
+ const right = panel(title, rightLines, selectionWidth, contentLimit, 0, color, rightTone);
184
+ const rows = Math.max(left.length, right.length);
185
+ const gutter = color === 24 ? styled(' ', 'text', color, 'base') : ' ';
186
+ body = Array.from({ length: rows }, (_, index) => `${left[index] || paintLine('', 'text', color, providerWidth, 'base')}${gutter}${right[index] || paintLine('', 'text', color, selectionWidth, 'base')}`);
94
187
  } else {
95
- const activityLimit = Math.max(3, height - 14 - wrapLines(providerLines, safeWidth - 4).length - wrapLines(selection, safeWidth - 4).length);
96
- body = [panel('PROVIDERS / HOST', providerLines, safeWidth), panel('SELECTION / STATUS', selection, safeWidth), panel('PLAN / ACTIVITY', activity, safeWidth, activityLimit, activityOffset)].flatMap((lines) => [...lines, '']);
188
+ const providerLimit = 2;
189
+ const selectionLimit = Math.max(3, Math.floor((budget - 6 - providerLimit) / 2));
190
+ const activityLimit = Math.max(2, budget - 6 - providerLimit - selectionLimit);
191
+ body = [panel('PROVIDERS / HOST', providerLines, safeWidth, providerLimit, 0, color, 'indigo'),
192
+ panel('SELECTION / STATUS', selection, safeWidth, selectionLimit, 0, color, rightTone),
193
+ panel('PLAN / ACTIVITY', activity, safeWidth, activityLimit, activityOffset, color, 'purple')].flat();
97
194
  }
98
- return [
99
- 'AFYX / ENGINEERING KIT',
100
- 'MIDNIGHT CIRCUIT | ALPHA INSTALLER',
101
- fit(stepLine, safeWidth),
102
- '',
195
+ const screen = [
196
+ paintLine('AFYX / ENGINEERING KIT', 'cyan', color, safeWidth),
197
+ paintLine(fit(`Unified Installer | ${runtime || `v${getPackageVersion()}`} | I choose my path.`, safeWidth), 'purple', color, safeWidth),
198
+ ...identity.map((line) => paintLine(line, 'muted', color, safeWidth)),
199
+ stepLine,
200
+ paintLine('─'.repeat(safeWidth), 'indigo', color, safeWidth),
103
201
  ...body,
104
- fit(hint, safeWidth),
202
+ ...footer.map((line) => paintLine(line, 'muted', color, safeWidth)),
105
203
  ].join('\n');
204
+ return ascii ? stripVTControlCharacters(screen).replace(/[╭╮╰╯]/g, '+').replace(/─/g, '-').replace(/│/g, '|')
205
+ .replace(/[›→]/g, '>').replace(/↑/g, '^').replace(/↓/g, 'v').replace(/●/g, '*').replace(/○/g, 'o')
206
+ .replace(/[—–]/g, '-').replace(/…/g, '.').replace(/[^\x20-\x7e\n]/g, '?') : screen;
207
+ }
208
+
209
+ async function choosePlain({ input, output, frame, options, selected, multiple }) {
210
+ const rows = options.map((option, index) => `${index + 1}. ${option.label}`);
211
+ // Plain terminals have no panel scrolling: show every numbered option after
212
+ // the context frame, including choices below the terminal's visible height.
213
+ drawScreen(output, frame([], selected, { activityOffset: 0, activityFocus: false }));
214
+ output.write(rows.map((row) => fit(row, Number.MAX_SAFE_INTEGER).replace(/[—–]/g, '-').replace(/[^\x20-\x7e]/g, '?')).join('\n') + '\n');
215
+ const reader = readline.createInterface({ input, output, terminal: false });
216
+ try {
217
+ for (;;) {
218
+ const answer = await new Promise((resolve) => {
219
+ const closed = () => resolve('q');
220
+ reader.once('close', closed);
221
+ reader.question(multiple ? 'Select numbers separated by commas (empty = none; q = back): ' : `Select number (Enter = ${selected + 1}; q = back): `, (value) => {
222
+ reader.off('close', closed); resolve(value.trim());
223
+ });
224
+ });
225
+ if (/^(q|quit|back)$/i.test(answer)) return null;
226
+ if (!answer) return multiple ? [] : options[selected].id;
227
+ const indices = answer.split(',').map((value) => /^\d+$/.test(value.trim()) ? Number(value.trim()) - 1 : -1);
228
+ if (indices.some((index) => index < 0 || index >= options.length) || (!multiple && indices.length !== 1)) {
229
+ output.write('Invalid selection; use the displayed numbers.\n'); continue;
230
+ }
231
+ return multiple ? [...new Set(indices)].map((index) => options[index].id) : options[indices[0]].id;
232
+ }
233
+ } finally { reader.close(); }
106
234
  }
107
235
 
108
236
  async function choose({ input, output, frame, options, selected = 0, multiple = false }) {
237
+ if (plainOutputs.has(output)) return choosePlain({ input, output, frame, options, selected, multiple });
109
238
  readline.emitKeypressEvents(input);
110
239
  input.setRawMode(true);
111
240
  input.resume();
@@ -113,22 +242,24 @@ async function choose({ input, output, frame, options, selected = 0, multiple =
113
242
  let cursor = selected;
114
243
  let activityOffset = 0;
115
244
  let activityFocus = false;
245
+ let providerOffset = 0;
246
+ let providerFocus = false;
116
247
  const tooSmall = () => (output.columns || 80) < 80 || (output.rows || 24) < 24;
117
248
  const draw = () => {
118
249
  if (tooSmall()) {
119
250
  output.write('\x1b[H\x1b[0JResize the terminal to at least 80 columns by 24 rows. Esc cancels safely.\n');
120
251
  return;
121
252
  }
122
- const capacity = Math.max(3, Math.min(8, (output.rows || 24) - 21));
253
+ const capacity = Math.max(3, Math.min(8, Math.floor(((output.rows || 24) - 12) / 2)));
123
254
  const start = Math.max(0, Math.min(cursor - Math.floor(capacity / 2), options.length - capacity));
124
255
  const rows = options.slice(start, start + capacity).map((option, offset) => {
125
256
  const index = start + offset;
126
- return `${index === cursor ? '›' : ' '} ${multiple ? checks.has(index) ? '[x]' : '[ ]' : index === cursor ? '●' : '○'} ${option.label}`;
257
+ const width = output.columns || 80;
258
+ const paneWidth = width >= 80 ? width - Math.max(28, Math.floor((width - 1) * 0.30)) - 1 : width;
259
+ return fit(`${index === cursor ? '›' : ' '} ${multiple ? checks.has(index) ? '[x]' : '[ ]' : index === cursor ? '●' : '○'} ${option.label}`, paneWidth - 4);
127
260
  });
128
- const screen = frame(rows, cursor, { activityOffset, activityFocus })
129
- .replace(/^›[^\n]*/gm, (line) => `\x1b[1;36m${line}\x1b[0m`)
130
- .replace(/\b(PASS|FAILED|SKIPPED|NOT SUPPORTED)\b/g, (status) => `\x1b[${status === 'PASS' ? '32' : status === 'FAILED' ? '31' : '33'}m${status}\x1b[0m`);
131
- output.write(`\x1b[H\x1b[0J${screen}`);
261
+ const screen = frame(rows, cursor, { activityOffset, activityFocus, providerOffset, providerFocus });
262
+ drawScreen(output, screen);
132
263
  };
133
264
  draw();
134
265
  try {
@@ -137,13 +268,21 @@ async function choose({ input, output, frame, options, selected = 0, multiple =
137
268
  if (key.ctrl && key.name === 'c') { cleanup(); reject(new Error('Installer canceled (Ctrl+C).')); return; }
138
269
  if (key.name === 'escape') { cleanup(); resolve(null); return; }
139
270
  if (tooSmall()) return;
140
- if (key.name === 'tab' || key.name === 'left' || key.name === 'right') activityFocus = !activityFocus;
271
+ if (key.name === 'tab' || key.name === 'left' || key.name === 'right') {
272
+ if (activityFocus) { activityFocus = false; providerFocus = true; }
273
+ else if (providerFocus) providerFocus = false;
274
+ else activityFocus = true;
275
+ }
276
+ else if (providerFocus && (key.name === 'up' || key.name === 'k')) providerOffset = Math.max(0, providerOffset - 1);
277
+ else if (providerFocus && (key.name === 'down' || key.name === 'j')) providerOffset++;
278
+ else if (key.name === 'home' && !activityFocus && !providerFocus) cursor = 0;
279
+ else if (key.name === 'end' && !activityFocus && !providerFocus) cursor = options.length - 1;
141
280
  else if (activityFocus && (key.name === 'up' || key.name === 'k')) activityOffset = Math.max(0, activityOffset - 1);
142
281
  else if (activityFocus && (key.name === 'down' || key.name === 'j')) activityOffset++;
143
282
  else if (key.name === 'up' || key.name === 'k') { cursor = (cursor - 1 + options.length) % options.length; activityOffset = 0; }
144
283
  else if (key.name === 'down' || key.name === 'j') { cursor = (cursor + 1) % options.length; activityOffset = 0; }
145
- else if (multiple && key.name === 'space') { checks.has(cursor) ? checks.delete(cursor) : checks.add(cursor); }
146
- else if (key.name === 'return') { if (activityFocus) activityFocus = false; else { cleanup(); resolve(multiple ? [...checks].map((index) => options[index].id) : options[cursor].id); return; } }
284
+ else if (multiple && key.name === 'space' && !activityFocus && !providerFocus) { checks.has(cursor) ? checks.delete(cursor) : checks.add(cursor); }
285
+ else if (key.name === 'return') { if (activityFocus || providerFocus) { activityFocus = false; providerFocus = false; } else { cleanup(); resolve(multiple ? [...checks].map((index) => options[index].id) : options[cursor].id); return; } }
147
286
  draw();
148
287
  };
149
288
  const onResize = () => draw();
@@ -163,18 +302,25 @@ async function choose({ input, output, frame, options, selected = 0, multiple =
163
302
  } finally {
164
303
  input.setRawMode(false);
165
304
  input.pause();
166
- output.write('\n');
305
+ output.write('\x1b[0m\x1b[?25h');
167
306
  }
168
307
  }
169
308
 
170
- export async function runMidnightCircuit({ input = process.stdin, output = process.stdout, pkgRoot = PACKAGE_ROOT, platform = process.platform, arch = process.arch, hosts, options = {}, backend = createBackendAdapter({ platform, pkgRoot }) } = {}) {
171
- const providers = hosts ?? discoverHosts(pkgRoot);
172
- const available = providers.filter((entry) => providerSelectable(entry, platform)).map((entry) => entry.id);
309
+ export async function runMidnightCircuit({ input = process.stdin, output = process.stdout, pkgRoot = PACKAGE_ROOT, platform = process.platform, arch = process.arch, hosts, options = {}, plain = false, environment, detectEnvironment = detectInstallerEnvironment, backend = createBackendAdapter({ platform, pkgRoot }) } = {}) {
310
+ if (plain) plainOutputs.add(output); else plainOutputs.delete(output);
311
+ previousFrames.delete(output);
312
+ let providers = hosts ?? [];
313
+ let available = [];
314
+ const progressModel = new InstallerProgress({ reducedMotion: process.env.AFYX_REDUCED_MOTION === '1' });
173
315
  const frame = (stage, selection, activity, hint, view = {}) => renderFrame({ stage, providers,
174
- providerSummary: stage >= 3 ? [`Selected: ${provider.join(', ') || 'skipped'}; scope: ${scope}`] : undefined,
175
- selection, activity, width: output.columns || 80, height: output.rows || 24, ...view,
176
- hint: `${hint}${view.activityFocus ? ' [ACTIVITY FOCUS]' : ''}` });
177
- let providerMode = available.length ? 'all' : 'skip';
316
+ providerSummary: stage >= 3 ? [`Selected: ${provider.join(', ') || 'skipped'}`, `Scope: ${scope}`] : undefined,
317
+ selection, activity, width: output.columns || 80, height: plain ? Math.max(40, 20 + providers.length * 6 + selection.length + activity.length) : output.rows || 24, ...view,
318
+ color: !plain && process.env.NO_COLOR === undefined ? output.getColorDepth?.() >= 24 ? 24 : 16 : false, ascii: plain,
319
+ runtime: `v${environment?.package?.version || getPackageVersion()} | Node ${process.versions.node} | source ${environment?.package?.sourceRevision?.slice(0, 8) || 'Unknown'}${environment?.package?.dirty ? '+' : ''}`,
320
+ environment,
321
+ discovering: [...progressModel.operations.values()].some((item) => item.phase === 'discovery' && item.state === 'running'),
322
+ hint: `${hint}${view.activityFocus ? ' [ACTIVITY FOCUS]' : view.providerFocus ? ' [PROVIDERS FOCUS]' : ''}` });
323
+ let providerMode = 'skip';
178
324
  let preset = 'recommended';
179
325
  let provider = [];
180
326
  let scope = 'global';
@@ -186,7 +332,37 @@ export async function runMidnightCircuit({ input = process.stdin, output = proce
186
332
  customComponents: custom, skipProviderConfiguration: provider.length === 0, nonInteractive: true });
187
333
  const selectedComponents = () => presetComponents(preset, custom, pkgRoot)
188
334
  .filter((id) => id !== 'codex-usage-tracking' || (platform === 'win32' && provider.includes('codex')));
189
- output.write('\x1b[2J\x1b[H');
335
+ if (!plain) output.write('\x1b[2J\x1b[H');
336
+ const operation = async (phase, message, stage, action) => {
337
+ const id = progressModel.begin(phase, message);
338
+ const show = () => drawScreen(output, frame(stage, [progressModel.current()], progressModel.activity.slice(-5), 'Working — Ctrl+C interrupts safely.'));
339
+ show();
340
+ const timer = !plain ? setInterval(show, progressModel.reducedMotion ? 1000 : 80) : null;
341
+ const controller = new AbortController();
342
+ const cancel = () => { controller.abort(); progressModel.stop('cancelled'); if (!plain) output.write('\x1b[0m\x1b[?25h'); };
343
+ process.once('SIGINT', cancel); process.once('SIGTERM', cancel);
344
+ try { const result = await action(controller.signal); if (controller.signal.aborted) throw new Error('Installer operation canceled'); progressModel.end(id); return result; }
345
+ catch (error) { progressModel.end(id, controller.signal.aborted ? 'cancelled' : 'failed', `${message}: ${String(error.message).split('\n')[0].slice(0, 512)}`); throw error; }
346
+ finally { if (timer) clearInterval(timer); process.off('SIGINT', cancel); process.off('SIGTERM', cancel); }
347
+ };
348
+ environment ??= await operation('discovery', 'Identifying OS, invoking shell, terminal and backend', 0,
349
+ (signal) => detectEnvironment({ platform, arch, pkgRoot, signal }));
350
+ providers = hosts ?? await operation('discovery', 'Discovering CLI, IDE and extension inventory', 0, (signal) => discoverHosts(pkgRoot, signal));
351
+ available = providers.filter((entry) => providerSelectable(entry, platform)).map((entry) => entry.id);
352
+ providerMode = available.length ? 'all' : 'skip';
353
+ const plan = async (phase = 'planning') => {
354
+ try {
355
+ const result = await operation(phase, phase === 'revalidation' ? 'Revalidating plan fingerprint' : 'Generating read-only installation plan', 3, (signal) => backend.plan(backendOptions(), { signal }));
356
+ recordBackendExecution(environment, backend.executionShell);
357
+ return result;
358
+ }
359
+ catch (error) {
360
+ const diagnostic = recordInstallerDiagnostic(error);
361
+ drawScreen(output, frame(3, ['FAILED — backend plan unavailable'],
362
+ [String(error.message).split('\n')[0], `Diagnostic log: ${diagnostic}`, 'No installation has been applied.'], 'Run again after resolving the diagnostic.', { failed: true }));
363
+ throw new Error(`Backend plan failed. Diagnostic log: ${diagnostic}`);
364
+ }
365
+ };
190
366
  while (true) {
191
367
  if (step === 0) {
192
368
  const result = await choose({ input, output, frame: (rows) => frame(0, rows, ['Inspecting supported host installations.', 'No configuration changes before confirmation.'], 'Enter: continue Esc: cancel Ctrl+C: cancel'), options: [{ id: 'continue', label: 'Continue to selection' }] });
@@ -210,7 +386,7 @@ export async function runMidnightCircuit({ input = process.stdin, output = proce
210
386
  step = 2;
211
387
  } else if (step === 2) {
212
388
  const choices = ['recommended', 'minimal', 'full', 'custom'].map((id) => ({ id, label: `${id[0].toUpperCase()}${id.slice(1)} — ${id === 'full' ? 'all applicable components' : id === 'custom' ? 'select exact components' : id === 'recommended' ? 'core skills + Engineering Expert' : 'core engineering skills'}` }));
213
- const chosen = await choose({ input, output, frame: (rows) => frame(2, rows, ['Choose a component preset.'], '↑/↓: move Enter: choose Esc: back'), options: choices, selected: choices.findIndex((x) => x.id === preset) });
389
+ const chosen = await choose({ input, output, frame: (rows) => frame(1, rows, ['Choose a component preset.'], '↑/↓: move Enter: choose Esc: back'), options: choices, selected: choices.findIndex((x) => x.id === preset) });
214
390
  if (chosen === null) { step = 1; continue; }
215
391
  preset = chosen;
216
392
  const support = runtimeSupport(preset, platform, arch);
@@ -236,8 +412,8 @@ export async function runMidnightCircuit({ input = process.stdin, output = proce
236
412
  scope = chosen;
237
413
  step = 4;
238
414
  } else if (step === 4) {
239
- output.write(`\x1b[H\x1b[0J${frame(3, ['Reading the backend installation plan…'], ['Read-only inspection; no installation changes yet.'], '')}`);
240
- reviewedPlan = await backend.plan(backendOptions());
415
+ drawScreen(output, frame(3, ['Reading the backend installation plan…'], ['Read-only inspection; no installation changes yet.'], ''));
416
+ reviewedPlan = await plan();
241
417
  const items = reviewedPlan.components;
242
418
  const choices = items.map((item) => ({ id: item.id, label: `${item.name}: ${item.backendAction.toUpperCase()} (${item.currentState})` }));
243
419
  choices.push({ id: 'apply', label: 'Apply exactly this reviewed plan' }, { id: 'cancel', label: 'Cancel without changes' });
@@ -262,8 +438,8 @@ export async function runMidnightCircuit({ input = process.stdin, output = proce
262
438
  reviewNotice = 'The backend plan is BLOCKED. Resolve the displayed ownership/prerequisite issue first.';
263
439
  continue;
264
440
  }
265
- output.write(`\x1b[H\x1b[0J${frame(3, ['Revalidating the reviewed plan…'], ['Owned program files and provider configuration must still match.'], '')}`);
266
- const currentPlan = await backend.plan(backendOptions());
441
+ drawScreen(output, frame(3, ['Revalidating the reviewed plan…'], ['Owned program files and provider configuration must still match.'], ''));
442
+ const currentPlan = await plan('revalidation');
267
443
  if (currentPlan.fingerprint !== reviewedPlan.fingerprint) {
268
444
  reviewNotice = 'PLAN CHANGED: installation state changed. Inspect and confirm the updated plan.';
269
445
  continue;
@@ -271,24 +447,88 @@ export async function runMidnightCircuit({ input = process.stdin, output = proce
271
447
  break;
272
448
  }
273
449
  }
274
- output.write(`\x1b[2J\x1b[H${frame(3, ['Applying confirmed plan…'], ['Platform installer output follows.'], '')}\n`);
450
+ const tracePath = join(mkdtempSync(join(tmpdir(), 'afyx-installer-execution-')), 'backend.log');
451
+ writeFileSync(tracePath, `Source root: ${pkgRoot}\nPlan: ${reviewedPlan.fingerprint}\n`, { mode: 0o600 });
452
+ const applyId = progressModel.begin('install', 'Applying confirmed installation plan');
453
+ const selectedItems = reviewedPlan.components.filter((item) => item.desired);
454
+ const plannedOperations = new Set(selectedItems.filter((item) => item.backendAction !== 'skip').map((item) => item.id));
455
+ const completedOperations = new Set();
456
+ if (plannedOperations.size) progressModel.accept({ operationId: applyId, phase: 'install', state: 'running', completed: 0, total: plannedOperations.size, message: 'Component operations; final verification pending' });
457
+ const buffers = new Map();
458
+ const showProgress = () => {
459
+ const known = new Map([...progressModel.operations.values()].filter((item) => item.componentId).map((item) => [item.componentId, item]));
460
+ const lines = selectedItems.map((item) => `${item.name}: ${known.has(item.id) ? progressModel.describe(known.get(item.id)) : item.backendAction === 'skip' ? 'UNCHANGED; VERIFY PENDING' : 'QUEUED'}`);
461
+ drawScreen(output, frame(3, lines, [progressModel.current(), 'Final installation verification is pending.', ...progressModel.activity.slice(-5), `Backend log: ${tracePath}`], 'Ctrl+C: interrupt safely; completed changes require verification.', { installing: true }));
462
+ };
463
+ const consume = (raw) => {
464
+ const line = stripVTControlCharacters(raw).trim();
465
+ if (line.startsWith(INSTALL_PROGRESS_PREFIX)) {
466
+ try {
467
+ const event = JSON.parse(line.slice(INSTALL_PROGRESS_PREFIX.length));
468
+ if (event.componentId && !reviewedPlan.components.some((item) => item.id === event.componentId)) throw new Error('Unknown progress component');
469
+ const accepted = progressModel.accept(event);
470
+ if (plannedOperations.has(accepted.componentId) && accepted.state === 'completed' && ['install', 'update', 'repair'].includes(accepted.phase)) {
471
+ completedOperations.add(accepted.componentId);
472
+ progressModel.accept({ operationId: applyId, phase: 'install', state: 'running', completed: completedOperations.size,
473
+ total: plannedOperations.size, message: 'Component operations; final verification pending' });
474
+ }
475
+ } catch {
476
+ progressModel.activity.push('WARNING: malformed backend progress; see complete backend log.');
477
+ }
478
+ } else if (/\b(error|failed|warning|rollback|recovery)\b/i.test(line)) {
479
+ progressModel.activity.push(`Backend diagnostic: ${line.slice(0, 512)}`);
480
+ }
481
+ if (progressModel.activity.length > 64) progressModel.activity.splice(0, progressModel.activity.length - 64);
482
+ };
483
+ let lastPlainActivity = '';
484
+ const onOutput = (chunk, stream = 'stdout') => {
485
+ appendFileSync(tracePath, chunk);
486
+ const lines = ((buffers.get(stream) || '') + chunk).split(/\r?\n/);
487
+ buffers.set(stream, lines.pop().slice(-65_536));
488
+ for (const line of lines) consume(line);
489
+ if (plain && progressModel.activity.at(-1) !== lastPlainActivity) {
490
+ lastPlainActivity = progressModel.activity.at(-1);
491
+ output.write(`${lastPlainActivity}\n`);
492
+ }
493
+ };
494
+ showProgress();
495
+ let animation = null;
496
+ const startProgress = () => {
497
+ if (!animation && !plain) animation = setInterval(showProgress, progressModel.reducedMotion ? 1000 : 80);
498
+ };
275
499
  const finish = async (exitCode) => {
500
+ if (animation) clearInterval(animation);
501
+ for (const pending of buffers.values()) if (pending) consume(pending);
502
+ progressModel.accept({ operationId: applyId, phase: 'install', state: exitCode === 0 ? 'completed' : 'failed',
503
+ completed: completedOperations.size === plannedOperations.size && plannedOperations.size ? completedOperations.size : null,
504
+ total: completedOperations.size === plannedOperations.size && plannedOperations.size ? plannedOperations.size : null,
505
+ message: 'Backend execution ended; final verification determines installation status' });
506
+ if (exitCode !== 0) progressModel.stop('failed');
276
507
  try {
277
- output.write(`\x1b[H\x1b[0J${frame(4, ['Verifying installed components…'], [`Installer exit: ${exitCode}; awaiting backend verification.`], '')}`);
278
- const actual = await backend.plan(backendOptions());
279
- const verification = await backend.verify(backendOptions());
280
- const result = summarizeExecution(actual, verification, exitCode, reviewedPlan);
281
- const checks = verification.rows.filter((row) => /^(Afyx Graph MCP|Antigravity MCP|Claude Code MCP|Afyx workflow MCP|Provider MCP|Afyx Context Engine|Afyx Forge Core|Core readiness)$/.test(row.name));
508
+ drawScreen(output, frame(4, ['Verifying installed components…'], [`Installer exit: ${exitCode}; awaiting backend verification.`], ''));
509
+ const actual = await operation('validation', 'Inspecting installed component state', 4, (signal) => backend.plan(backendOptions(), { signal }));
510
+ const verification = await operation('verify', 'Verifying installed components and provider configuration', 4, (signal) => backend.verify(backendOptions(), { signal }));
511
+ const verificationPath = join(dirname(tracePath), 'verification.json');
512
+ recordBackendExecution(environment, backend.executionShell);
513
+ writeFileSync(verificationPath, JSON.stringify({ ...verification, environment }, null, 2) + '\n', { mode: 0o600 });
514
+ const result = await operation('receipt', 'Generating verified installation receipt', 4, () => summarizeExecution(actual, verification, exitCode, reviewedPlan));
515
+ const checks = verification.rows.filter((row) => row.state === 'FAIL' || /^(Afyx Graph MCP|Antigravity MCP|Claude Code MCP|Afyx workflow MCP|Provider MCP|Afyx Context Engine|Afyx Forge Core|Core readiness)$/.test(row.name));
516
+ const failedChecks = checks.filter((row) => row.state === 'FAIL' && row.name !== 'Core readiness');
282
517
  const receiptChoices = [
283
518
  ...result.components.map((item, index) => ({ id: `component:${index}`, label: `${item.name}: ${item.outcome}; ${item.version || 'n/a'}` })),
284
519
  ...checks.map((row, index) => ({ id: `check:${index}`, label: `${row.name}: ${row.state}` })),
285
520
  { id: 'close', label: `Finish — ${result.status}; verify exit=${verification.exitCode}` },
286
521
  ];
287
522
  const summary = [`Result: ${result.status}; installer exit=${exitCode}; verify exit=${verification.exitCode}`,
523
+ ...failedChecks.map((row) => `FAILED CHECK: ${row.name}: ${row.detail || 'Inspect the verification diagnostic.'}`),
524
+ ...(result.status === 'PASS' ? [] : ['Recovery: review the failed checks before making changes.',
525
+ 'Preserve user changes; authorize prerequisite/configuration changes or repairs, then verify.']),
526
+ `Verification log: ${verificationPath}`,
288
527
  `Provider configuration: ${provider.length ? 'see backend checks' : 'SKIPPED by user'}`,
528
+ `Backend log: ${tracePath}`, provider.length ? 'Provider MCP changes may require restarting the agent host.' : 'No provider registration requested.',
289
529
  'Inspect component versions and backend checks with ↑/↓.',
290
530
  result.status === 'PASS' ? 'Maintenance: use verify, update, or selective uninstall.'
291
- : 'Recovery: resolve the displayed backend failures, repair the affected component, then verify.'];
531
+ : 'Inspect each failed readiness check and the full verification log.'];
292
532
  if (input.isTTY && output.isTTY) {
293
533
  let selected = receiptChoices.length - 1;
294
534
  try {
@@ -305,7 +545,7 @@ export async function runMidnightCircuit({ input = process.stdin, output = proce
305
545
  const row = checks[cursor - result.components.length];
306
546
  detail = [`${row.name}: ${row.state}`, row.detail];
307
547
  }
308
- return frame(4, rows, detail, '↑/↓: inspect Tab: focus activity Enter: select Esc: finish', view);
548
+ return frame(4, rows, detail, '↑/↓: inspect Tab: focus activity Enter: select Esc: finish', { ...view, failed: result.status !== 'PASS', receipt: result.status === 'PASS' });
309
549
  } });
310
550
  if (choice === null || choice === 'close') break;
311
551
  selected = receiptChoices.findIndex((item) => item.id === choice);
@@ -314,15 +554,18 @@ export async function runMidnightCircuit({ input = process.stdin, output = proce
314
554
  output.write(`\nReceipt closed: ${error.message} Verified result: ${result.status}.\n`);
315
555
  return /Ctrl\+C|SIGTERM/.test(error.message) ? 130 : 1;
316
556
  }
317
- } else output.write(`${frame(4, result.components.map((item) => `${item.name}: ${item.status}; ${item.version || 'n/a'}`), summary, '')}\n`);
557
+ } else drawScreen(output, frame(4, result.components.map((item) => `${item.name}: ${item.status}; ${item.version || 'n/a'}`), summary, '', { failed: result.status !== 'PASS', receipt: result.status === 'PASS' }));
558
+ if (!plain) output.write('\x1b[0m\x1b[?25h\n');
318
559
  return result.status === 'PASS' ? 0 : 1;
319
560
  } catch (error) {
320
- output.write(`\x1b[2J\x1b[H${frame(4, ['Verification: NOT TESTED / FAILED'],
321
- [`Installer exit: ${exitCode}`, error.message, 'Run verify and resolve the backend diagnostic before retrying.'], '')}\n`);
561
+ const diagnostic = recordInstallerDiagnostic(error);
562
+ drawScreen(output, frame(4, ['Verification: NOT TESTED / FAILED'],
563
+ [`Installer exit: ${exitCode}`, String(error.message).split('\n')[0], `Diagnostic log: ${diagnostic}`, `Backend log: ${tracePath}`], 'Run verify and resolve the backend diagnostic before retrying.', { failed: true }));
564
+ if (!plain) output.write('\x1b[0m\x1b[?25h\n');
322
565
  return 1;
323
566
  }
324
567
  };
325
568
  return { preset, provider: provider.join(','), providerScope: scope, customComponents: custom,
326
569
  skipProviderConfiguration: provider.length === 0, nonInteractive: true,
327
- expectedPlan: reviewedPlan.fingerprint, finish };
570
+ expectedPlan: reviewedPlan.fingerprint, finish, onOutput, startProgress };
328
571
  }
@@ -159,6 +159,9 @@ export const PRODUCT_INVENTORY = Object.freeze({
159
159
  productionReady: false, activationMode: 'ON_DEMAND',
160
160
  providers: Object.freeze(['codex', 'antigravity', 'claude']),
161
161
  }),
162
+ 'afyx-native-github': Object.freeze({ id: 'afyx-native-github', canonicalName: 'Afyx Native GitHub', type: 'runtime', primaryCapability: 'scoped-github-evidence', ownershipClass: 'AFYX', maturity: 'SOURCE_READY', activationMode: 'ON_DEMAND' }),
163
+ 'afyx-native-execution': Object.freeze({ id: 'afyx-native-execution', canonicalName: 'Afyx Native Execution', type: 'runtime', primaryCapability: 'validated-local-execution', ownershipClass: 'AFYX', maturity: 'SOURCE_READY', activationMode: 'ON_DEMAND' }),
164
+ 'afyx-security-auditor': Object.freeze({ id: 'afyx-security-auditor', canonicalName: 'Afyx Security Auditor', type: 'runtime', primaryCapability: 'source-security-candidates', ownershipClass: 'AFYX', maturity: 'SOURCE_READY', activationMode: 'ON_DEMAND' }),
162
165
  'afyx-credential-broker': Object.freeze({
163
166
  id: 'afyx-credential-broker', canonicalName: 'Afyx Credential Broker',
164
167
  type: 'toolset', primaryCapability: 'credential-use-authorization',
@@ -72,6 +72,9 @@ export const DOMAIN_AUTHORITY_MATRIX = Object.freeze({
72
72
  primaryOwner: 'afyx-skill-engineering',
73
73
  description: 'Skill authoring, validation, packaging, review and installation.',
74
74
  },
75
+ 'scoped-github-evidence': { primaryOwner: 'afyx-native-github', description: 'Scoped read-only GitHub evidence via trusted host credentials.' },
76
+ 'validated-local-execution': { primaryOwner: 'afyx-native-execution', description: 'Trusted CLI catalog execution with bounded arguments and host approval.' },
77
+ 'source-security-candidates': { primaryOwner: 'afyx-security-auditor', description: 'Bounded read-only heuristic security candidates.' },
75
78
  'credential-use-authorization': {
76
79
  primaryOwner: 'afyx-credential-broker',
77
80
  description: 'Host-scoped credential use authorization without secret disclosure.',