@pugi/cli 0.1.0-beta.22 → 0.1.0-beta.24

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.
@@ -0,0 +1,289 @@
1
+ /**
2
+ * Leak L27 (2026-05-27) — `pugi update` dispatcher.
3
+ *
4
+ * Top-level command + in-REPL `/update` slash share this handler.
5
+ * Both surfaces delegate IO + persistence here so the channel
6
+ * resolution, the registry probe, and the install shell-out stay
7
+ * single-sourced.
8
+ *
9
+ * Command grammar:
10
+ *
11
+ * pugi update -> probe + interactive prompt
12
+ * pugi update --check -> probe + JSON envelope (scripted)
13
+ * pugi update --channel <name> -> switch channel + probe
14
+ * pugi update --apply -> probe + shell `npm i -g …`
15
+ * (confirms unless --yes)
16
+ * pugi update --apply --yes -> probe + shell, no confirmation
17
+ *
18
+ * Exit codes:
19
+ *
20
+ * 0 — happy path (no update OR update completed) OR `--check` JSON
21
+ * 1 — install / probe failure with structured error envelope
22
+ * 2 — argument error (bad channel, conflicting flags)
23
+ *
24
+ * R2 atomic swap deferred (sprint plan L27 mention): the leak research
25
+ * also describes Claude Code's R2-backed binary swap. Pugi ships
26
+ * exclusively via npm today; building a parallel R2 distribution
27
+ * channel + checksum verification + rollback is materially more work
28
+ * than the L27 acceptance criteria allow. Document the deferral in
29
+ * the PR body and revisit when npm's once-per-day rate-limit or
30
+ * outage cadence justifies the parallel pipeline.
31
+ */
32
+ import { spawn } from 'node:child_process';
33
+ import { homedir } from 'node:os';
34
+ import { DEFAULT_UPDATE_CHANNEL, UPDATE_CHANNELS, describeChannel, npmTagForChannel, parseUpdateChannel, } from '../../core/auto-update/channels.js';
35
+ import { checkForChannelUpdate, } from '../../core/auto-update/checker.js';
36
+ import { resolveEffectiveChannel, setUpdateChannel, writeLastCheckedAt, } from '../../core/auto-update/state.js';
37
+ import { PUGI_CLI_VERSION } from '../version.js';
38
+ /**
39
+ * Default subprocess runner. Spawns `npm install -g @pugi/cli@<tag>`
40
+ * inheriting stdio so the operator sees the live npm output.
41
+ */
42
+ export function defaultSpawnInstaller(channel) {
43
+ const tag = npmTagForChannel(channel);
44
+ const args = ['install', '-g', `@pugi/cli@${tag}`];
45
+ return new Promise((resolvePromise) => {
46
+ const child = spawn('npm', args, { stdio: 'inherit' });
47
+ child.on('exit', (code) => {
48
+ resolvePromise(typeof code === 'number' ? code : 1);
49
+ });
50
+ child.on('error', () => {
51
+ // ENOENT / EACCES — npm not on PATH or permission denied. We
52
+ // surface a non-zero code so the dispatcher's JSON envelope
53
+ // tells the operator the apply failed; the inherited stdio
54
+ // already printed the underlying error to the terminal.
55
+ resolvePromise(127);
56
+ });
57
+ });
58
+ }
59
+ /**
60
+ * Parse a CLI / slash argv into our `UpdateCommandFlags`. Returns
61
+ * `null` AND writes the usage error via `writeError` for conflicting
62
+ * combinations. Both `pugi update` and the in-REPL `/update <args>`
63
+ * surface call through this so the validation lives in one place.
64
+ */
65
+ export function parseUpdateArgs(argv, options = {}) {
66
+ let check = false;
67
+ let apply = false;
68
+ let yes = false;
69
+ let json = options.jsonDefault ?? false;
70
+ let channel = null;
71
+ let channelInvalid;
72
+ for (let i = 0; i < argv.length; i += 1) {
73
+ const token = argv[i] ?? '';
74
+ if (token === '--check') {
75
+ check = true;
76
+ }
77
+ else if (token === '--apply') {
78
+ apply = true;
79
+ }
80
+ else if (token === '--yes' || token === '-y') {
81
+ yes = true;
82
+ }
83
+ else if (token === '--json') {
84
+ json = true;
85
+ }
86
+ else if (token === '--channel') {
87
+ const value = argv[i + 1];
88
+ i += 1;
89
+ const parsed = parseUpdateChannel(value);
90
+ if (!parsed) {
91
+ channelInvalid = value ?? '';
92
+ continue;
93
+ }
94
+ channel = parsed;
95
+ }
96
+ else if (token.startsWith('--channel=')) {
97
+ const value = token.slice('--channel='.length);
98
+ const parsed = parseUpdateChannel(value);
99
+ if (!parsed) {
100
+ channelInvalid = value;
101
+ continue;
102
+ }
103
+ channel = parsed;
104
+ }
105
+ else {
106
+ return {
107
+ error: `pugi update: unknown argument '${token}'. See \`pugi update --help\`.`,
108
+ };
109
+ }
110
+ }
111
+ if (channelInvalid !== undefined) {
112
+ return {
113
+ error: `pugi update: unknown channel '${channelInvalid}'. Allowed: ${UPDATE_CHANNELS.join(' / ')}.`,
114
+ };
115
+ }
116
+ return {
117
+ check,
118
+ apply,
119
+ yes,
120
+ json,
121
+ channel,
122
+ };
123
+ }
124
+ /**
125
+ * Run the full command. Returns the structured envelope so the in-
126
+ * REPL slash can decide whether to render the human-readable text OR
127
+ * pretty-print the JSON.
128
+ */
129
+ export async function runUpdateCommand(ctx) {
130
+ const flags = ctx.flags;
131
+ const home = ctx.home;
132
+ // 1. Resolve channel. `--channel <name>` wins; otherwise read the
133
+ // persisted preference; otherwise hard default `beta`.
134
+ const cliFlagChannel = flags.channel;
135
+ const effectiveChannel = resolveEffectiveChannel({
136
+ cliFlag: cliFlagChannel,
137
+ homeDir: home,
138
+ });
139
+ // 2. Persist the channel switch BEFORE the probe so a probe failure
140
+ // still leaves the operator on the channel they asked for.
141
+ let switched = false;
142
+ if (cliFlagChannel) {
143
+ setUpdateChannel(cliFlagChannel, home);
144
+ switched = true;
145
+ }
146
+ // 3. Probe the registry.
147
+ const outcome = await checkForChannelUpdate({
148
+ channel: effectiveChannel,
149
+ currentVersion: PUGI_CLI_VERSION,
150
+ ...(ctx.fetchImpl ? { fetchImpl: ctx.fetchImpl } : {}),
151
+ ...(ctx.registryUrl ? { registryUrl: ctx.registryUrl } : {}),
152
+ });
153
+ // 4. Record the timestamp on a successful probe (regardless of
154
+ // whether an update is available). Failed probes do NOT update
155
+ // the timestamp so the cold-start banner retries on the next
156
+ // invocation.
157
+ if (!outcome.error) {
158
+ const now = ctx.now ? new Date(ctx.now()) : new Date();
159
+ try {
160
+ writeLastCheckedAt(now, home);
161
+ }
162
+ catch {
163
+ // Best-effort — a read-only home should not crash the dispatcher.
164
+ }
165
+ }
166
+ // 5. Build the envelope shape ALL action paths share.
167
+ const baseEnvelope = {
168
+ command: 'update',
169
+ ok: outcome.error === null,
170
+ available: outcome.available,
171
+ channel: outcome.channel,
172
+ npmTag: outcome.npmTag,
173
+ current: outcome.current,
174
+ latest: outcome.latest,
175
+ gap: outcome.gap,
176
+ installCommand: outcome.installCommand,
177
+ action: outcome.error ? 'error' : 'probe',
178
+ error: outcome.error,
179
+ meta: { cliVersion: PUGI_CLI_VERSION },
180
+ };
181
+ // 6. --check: emit the envelope, never prompt, never apply.
182
+ if (flags.check) {
183
+ const text = renderHumanText(baseEnvelope, { switched });
184
+ ctx.writeOutput(baseEnvelope, text);
185
+ return baseEnvelope;
186
+ }
187
+ // 7. No update available — bail with a friendly message.
188
+ if (!outcome.available || !outcome.latest) {
189
+ const envelope = {
190
+ ...baseEnvelope,
191
+ action: outcome.error ? 'error' : (switched ? 'switch' : 'no_update'),
192
+ };
193
+ const text = renderHumanText(envelope, { switched });
194
+ ctx.writeOutput(envelope, text);
195
+ return envelope;
196
+ }
197
+ // 8. Update IS available. Branch on --apply.
198
+ if (!flags.apply) {
199
+ // Default: print the offer, suggest the install command, leave
200
+ // the install to the operator. Mirrors the leak research note:
201
+ // operators install side-effects must remain explicit on the CLI
202
+ // happy path — `pugi update` showing the gap is informational,
203
+ // `pugi update --apply` is the destructive verb.
204
+ const envelope = {
205
+ ...baseEnvelope,
206
+ action: switched ? 'switch' : 'probe',
207
+ };
208
+ const text = renderHumanText(envelope, { switched });
209
+ ctx.writeOutput(envelope, text);
210
+ return envelope;
211
+ }
212
+ // 9. --apply path. Confirm unless --yes, then spawn npm.
213
+ const installer = ctx.spawnInstaller ?? defaultSpawnInstaller;
214
+ let confirmed = flags.yes;
215
+ if (!confirmed) {
216
+ confirmed = await ctx.promptConfirm(`Run \`${outcome.installCommand}\` to update ${outcome.current} -> ${outcome.latest}? [y/N]`);
217
+ }
218
+ if (!confirmed) {
219
+ const envelope = {
220
+ ...baseEnvelope,
221
+ action: 'probe',
222
+ ok: false,
223
+ error: 'apply_cancelled_by_operator',
224
+ };
225
+ const text = `Cancelled. Run \`${outcome.installCommand}\` manually when you are ready.`;
226
+ ctx.writeOutput(envelope, text);
227
+ return envelope;
228
+ }
229
+ const exitCode = await installer(outcome.channel);
230
+ const applyEnvelope = {
231
+ ...baseEnvelope,
232
+ action: 'apply',
233
+ installExitCode: exitCode,
234
+ ok: exitCode === 0,
235
+ error: exitCode === 0 ? null : `npm_install_exit_${exitCode}`,
236
+ };
237
+ const applyText = exitCode === 0
238
+ ? `Updated to @pugi/cli@${outcome.latest}. Restart your shell so the new binary takes effect.`
239
+ : `Update failed (npm exit ${exitCode}). Try \`${outcome.installCommand}\` manually.`;
240
+ ctx.writeOutput(applyEnvelope, applyText);
241
+ return applyEnvelope;
242
+ }
243
+ /**
244
+ * Build the operator-readable hint that lives next to the JSON
245
+ * envelope. The text + the JSON are both passed to `writeOutput`; the
246
+ * caller (`writeOutput` in cli.ts) picks based on `--json`. Exported
247
+ * so the spec can assert the literal strings the operator sees.
248
+ */
249
+ export function renderHumanText(envelope, options = {}) {
250
+ const { current, latest, channel, installCommand, available, error } = envelope;
251
+ const lines = [];
252
+ lines.push(`Channel: ${channel} — ${describeChannel(channel)}`);
253
+ if (options.switched) {
254
+ lines.push(`Persisted channel selection -> ${channel}.`);
255
+ }
256
+ if (error) {
257
+ lines.push(`Update check failed: ${error}`);
258
+ lines.push(`Manual: \`${installCommand}\` (no probe necessary).`);
259
+ return lines.join('\n');
260
+ }
261
+ if (available && latest) {
262
+ lines.push(`Update available: ${current} -> ${latest}.`);
263
+ lines.push(`Run \`${installCommand}\` to upgrade.`);
264
+ lines.push(`Or \`pugi update --apply\` to upgrade with confirmation.`);
265
+ return lines.join('\n');
266
+ }
267
+ lines.push(`Up to date (${current} is the latest on ${channel}).`);
268
+ return lines.join('\n');
269
+ }
270
+ /**
271
+ * Render a one-line cold-start hint that callers (REPL boot, doctor
272
+ * banner) splice above their own UI. Returns `null` when there is
273
+ * nothing to nudge the operator about. Pure — no IO.
274
+ */
275
+ export function renderUpdateHint(outcome) {
276
+ if (!outcome.available || !outcome.latest)
277
+ return null;
278
+ return `Update available: ${outcome.current} -> ${outcome.latest}. Run \`pugi update\`.`;
279
+ }
280
+ /**
281
+ * Convenience entry point — resolve the effective channel from
282
+ * `~/.pugi/config.json` + DEFAULT_UPDATE_CHANNEL without forcing the
283
+ * caller to import multiple modules. Used by the cold-start banner +
284
+ * the doctor probe.
285
+ */
286
+ export function effectiveChannel(home = homedir()) {
287
+ return resolveEffectiveChannel({ homeDir: home }) ?? DEFAULT_UPDATE_CHANNEL;
288
+ }
289
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Leak L26 (2026-05-27) — `pugi vim` top-level command + REPL slash
3
+ * companion.
4
+ *
5
+ * Operator surface:
6
+ *
7
+ * pugi vim Show current vim-mode state.
8
+ * pugi vim on Enable + persist (~/.pugi/config.json).
9
+ * pugi vim off Disable + persist (default).
10
+ * /vim Toggle from inside the REPL.
11
+ * /vim on Enable from inside the REPL.
12
+ * /vim off Disable from inside the REPL.
13
+ *
14
+ * The same runner backs both surfaces so the slash + the shell verb
15
+ * stay single-sourced — operators trained on one read the same
16
+ * payload + banner on the other.
17
+ *
18
+ * Exit codes:
19
+ * 0 — show / enable / disable / toggle happy path
20
+ * 2 — unknown subcommand (e.g. `pugi vim chaos`)
21
+ *
22
+ * NOTE: there are NO `--persist` flag and no workspace tier. Vim mode
23
+ * is a single user-level preference, matching the leak research note
24
+ * that operators expect modal editing to be a body-memory trait, not
25
+ * a per-repo concern (see `core/vim/state.ts` header).
26
+ */
27
+ import { resolveVimMode, setVimMode } from '../../core/vim/state.js';
28
+ /**
29
+ * Banner shown on enable so the operator can see the binding cheat
30
+ * sheet without reaching for `/help`. Echoed by both surfaces.
31
+ */
32
+ export const VIM_ENABLED_BANNER = 'Vim mode on. Esc=normal, i=insert, :w=submit, :q=cancel.';
33
+ /**
34
+ * Entry point. Parses `args`, flips persistence as needed, emits the
35
+ * payload + text via `ctx.writeOutput`, and returns the exit code.
36
+ */
37
+ export async function runVimCommand(args, ctx) {
38
+ // Validate args before reading state so a bad call never has a
39
+ // side-effect.
40
+ if (args.length > 1) {
41
+ const payload = {
42
+ command: 'vim',
43
+ status: 'invalid_args',
44
+ active: resolveVimMode({ env: ctx.env }),
45
+ message: `pugi vim takes at most one argument (on / off / toggle). Got: ${args.join(' ')}`,
46
+ attemptedArg: args.join(' '),
47
+ };
48
+ ctx.writeOutput(payload, payload.message);
49
+ return 2;
50
+ }
51
+ const current = resolveVimMode({ env: ctx.env });
52
+ const verb = args[0]?.toLowerCase() ?? '';
53
+ // No args → toggle (slash convention from the leak research). The
54
+ // CLI shell surface ALSO toggles on bare invocation so the two
55
+ // surfaces converge; if the operator wants the read-only show they
56
+ // can pipe through `pugi vim --json` or query the config directly.
57
+ // We surface the change as a `show` status when nothing flipped so
58
+ // scripts can distinguish read from write.
59
+ if (verb === '') {
60
+ const next = !current;
61
+ setVimMode(next, { env: ctx.env });
62
+ const status = next ? 'enabled' : 'disabled';
63
+ const message = next ? VIM_ENABLED_BANNER : 'Vim mode off.';
64
+ const payload = {
65
+ command: 'vim',
66
+ status,
67
+ active: next,
68
+ previous: current,
69
+ message,
70
+ };
71
+ ctx.writeOutput(payload, payload.message);
72
+ return 0;
73
+ }
74
+ if (verb === 'on' || verb === 'enable' || verb === 'true') {
75
+ if (current) {
76
+ const payload = {
77
+ command: 'vim',
78
+ status: 'unchanged',
79
+ active: true,
80
+ previous: true,
81
+ message: 'Vim mode already on.',
82
+ };
83
+ ctx.writeOutput(payload, payload.message);
84
+ return 0;
85
+ }
86
+ setVimMode(true, { env: ctx.env });
87
+ const payload = {
88
+ command: 'vim',
89
+ status: 'enabled',
90
+ active: true,
91
+ previous: current,
92
+ message: VIM_ENABLED_BANNER,
93
+ };
94
+ ctx.writeOutput(payload, payload.message);
95
+ return 0;
96
+ }
97
+ if (verb === 'off' || verb === 'disable' || verb === 'false') {
98
+ if (!current) {
99
+ const payload = {
100
+ command: 'vim',
101
+ status: 'unchanged',
102
+ active: false,
103
+ previous: false,
104
+ message: 'Vim mode already off.',
105
+ };
106
+ ctx.writeOutput(payload, payload.message);
107
+ return 0;
108
+ }
109
+ setVimMode(false, { env: ctx.env });
110
+ const payload = {
111
+ command: 'vim',
112
+ status: 'disabled',
113
+ active: false,
114
+ previous: current,
115
+ message: 'Vim mode off.',
116
+ };
117
+ ctx.writeOutput(payload, payload.message);
118
+ return 0;
119
+ }
120
+ if (verb === 'status' || verb === 'show') {
121
+ const payload = {
122
+ command: 'vim',
123
+ status: 'show',
124
+ active: current,
125
+ message: current ? 'Vim mode is on.' : 'Vim mode is off.',
126
+ };
127
+ ctx.writeOutput(payload, payload.message);
128
+ return 0;
129
+ }
130
+ const payload = {
131
+ command: 'vim',
132
+ status: 'invalid_args',
133
+ active: current,
134
+ message: `Unknown vim subcommand "${verb}". Try one of: on, off, status.`,
135
+ attemptedArg: verb,
136
+ };
137
+ ctx.writeOutput(payload, payload.message);
138
+ return 2;
139
+ }
140
+ //# sourceMappingURL=vim.js.map
@@ -44,7 +44,7 @@ export function sanitizeSemver(raw) {
44
44
  * during import). When bumping the CLI version BOTH literals must be
45
45
  * updated; the release smoke-test (`pack:smoke`) verifies they agree.
46
46
  */
47
- export const PUGI_CLI_VERSION = sanitizeSemver('0.1.0-beta.22');
47
+ export const PUGI_CLI_VERSION = sanitizeSemver('0.1.0-beta.24');
48
48
  /**
49
49
  * Outbound: the CLI's installed semver. Read at request time by
50
50
  * `version-interceptor.ts` and injected on every `fetch` call.
@@ -1,31 +1,46 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from 'ink';
3
- /** Brand-voice palette for status cells. Mirrors the table chrome
4
- * used by `<AgentProgressCard>` so the operator's eye trains on a
5
- * consistent OK/WARN/ERROR/SKIPPED colour grammar. */
6
- const STATUS_COLOR = {
7
- ok: 'green',
8
- warn: 'yellow',
9
- error: 'red',
10
- skipped: 'gray',
11
- };
12
- const OVERALL_COLOR = {
13
- healthy: 'green',
14
- warning: 'yellow',
15
- error: 'red',
16
- };
3
+ import { useTheme } from '../core/theme/context.js';
4
+ /**
5
+ * Leak L30 (2026-05-27): status colors flow through the active theme
6
+ * instead of being hard-coded Ink color names. The `colorblind`
7
+ * preset re-maps OK/WARN/ERROR to a blue-yellow-magenta axis so
8
+ * deuteranopia operators can still distinguish the three states; the
9
+ * `default` / `dark` / `light` themes route to green/yellow/red
10
+ * variants tuned for each background. `skipped` keeps a muted color
11
+ * (theme-controlled muted token) so dimmed rows still pick up the
12
+ * theme tint.
13
+ */
14
+ function buildStatusColor(theme) {
15
+ return {
16
+ ok: theme.success,
17
+ warn: theme.warning,
18
+ error: theme.error,
19
+ skipped: theme.muted,
20
+ };
21
+ }
22
+ function buildOverallColor(theme) {
23
+ return {
24
+ healthy: theme.success,
25
+ warning: theme.warning,
26
+ error: theme.error,
27
+ };
28
+ }
17
29
  export function DoctorTable({ envelope }) {
30
+ const theme = useTheme();
31
+ const statusColor = buildStatusColor(theme);
32
+ const overallColor = buildOverallColor(theme);
18
33
  const nameWidth = Math.max('NAME'.length, ...envelope.probes.map((row) => row.name.length));
19
34
  const statusWidth = Math.max('STATUS'.length, ...envelope.probes.map((row) => row.status.length));
20
- return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { bold: true, children: "Pugi Doctor" }) }), envelope.probes.map((row) => (_jsx(DoctorRow, { row: row, nameWidth: nameWidth, statusWidth: statusWidth }, row.name))), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [envelope.counts.error, " error(s), ", envelope.counts.warn, " warning(s), ", envelope.counts.ok, " ok,", ' ', envelope.counts.skipped, " skipped. Overall:", ' ', _jsx(Text, { color: OVERALL_COLOR[envelope.overall], bold: true, children: envelope.overall.toUpperCase() })] }) }), _jsx(Box, { children: _jsxs(Text, { dimColor: true, children: ["CLI ", envelope.meta.cliVersion, " Node ", envelope.meta.nodeVersion, " cwd ", envelope.meta.cwd] }) })] }));
35
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { bold: true, children: "Pugi Doctor" }) }), envelope.probes.map((row) => (_jsx(DoctorRow, { row: row, nameWidth: nameWidth, statusWidth: statusWidth, statusColor: statusColor }, row.name))), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: [envelope.counts.error, " error(s), ", envelope.counts.warn, " warning(s), ", envelope.counts.ok, " ok,", ' ', envelope.counts.skipped, " skipped. Overall:", ' ', _jsx(Text, { color: overallColor[envelope.overall], bold: true, children: envelope.overall.toUpperCase() })] }) }), _jsx(Box, { children: _jsxs(Text, { dimColor: true, children: ["CLI ", envelope.meta.cliVersion, " Node ", envelope.meta.nodeVersion, " cwd ", envelope.meta.cwd] }) })] }));
21
36
  }
22
- function DoctorRow({ row, nameWidth, statusWidth }) {
37
+ function DoctorRow({ row, nameWidth, statusWidth, statusColor }) {
23
38
  const namePart = row.name.padEnd(nameWidth, ' ');
24
39
  const statusPart = row.status.toUpperCase().padEnd(statusWidth, ' ');
25
40
  const latencyPart = typeof row.latencyMs === 'number' ? ` (${row.latencyMs}ms)` : '';
26
41
  const showRemediation = typeof row.remediation === 'string' &&
27
42
  row.remediation.length > 0 &&
28
43
  (row.status === 'warn' || row.status === 'error');
29
- return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsxs(Text, { children: [namePart, " "] }), _jsx(Text, { color: STATUS_COLOR[row.status], bold: true, children: statusPart }), _jsxs(Text, { children: [' ', row.detail, latencyPart] })] }), showRemediation && (_jsx(Box, { marginLeft: nameWidth + statusWidth + 4, children: _jsxs(Text, { dimColor: true, children: ["\u2192 ", row.remediation] }) }))] }));
44
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsxs(Text, { children: [namePart, " "] }), _jsx(Text, { color: statusColor[row.status], bold: true, children: statusPart }), _jsxs(Text, { children: [' ', row.detail, latencyPart] })] }), showRemediation && (_jsx(Box, { marginLeft: nameWidth + statusWidth + 4, children: _jsxs(Text, { dimColor: true, children: ["\u2192 ", row.remediation] }) }))] }));
30
45
  }
31
46
  //# sourceMappingURL=doctor-table.js.map
@@ -22,6 +22,8 @@ import React from 'react';
22
22
  import { render } from 'ink';
23
23
  import { Repl } from './repl.js';
24
24
  import { printPugMascotPreInk } from './repl-splash-mascot.js';
25
+ import { ThemeProvider } from '../core/theme/context.js';
26
+ import { resolveTheme } from '../core/theme/state.js';
25
27
  import { ReplSession, } from '../core/repl/session.js';
26
28
  import { resolveWorkspaceContext } from '../core/repl/workspace-context.js';
27
29
  import { SqliteSessionStore } from '../core/repl/store/index.js';
@@ -181,13 +183,26 @@ export async function renderRepl(options) {
181
183
  // (operator opted out via --no-splash), we suppress the pre-print
182
184
  // too so the boot stays silent.
183
185
  const mascotPrePrinted = options.skipSplash === true ? false : printPugMascotPreInk(process.stdout);
184
- const instance = render(React.createElement(Repl, {
186
+ // Leak L30 (2026-05-27): resolve the active theme ONCE at mount
187
+ // and wrap `<Repl />` in `<ThemeProvider>` so every Ink consumer
188
+ // (`<Header>`, `<DoctorTable>`, `<StyleTable>`, `<ThemeTable>`,
189
+ // …) picks up the same color tokens. The provider is stable for
190
+ // the lifetime of the REPL — operator `/theme <name>` writes to
191
+ // disk + appends a system line, and the next `pugi` launch re-
192
+ // mounts with the new slug. Re-mounting mid-session would race
193
+ // against Ink's raw-mode handler so we deliberately keep the
194
+ // session-lifetime contract instead of polling the config file.
195
+ const resolvedTheme = resolveTheme({
196
+ workspaceRoot: process.cwd(),
197
+ env: process.env,
198
+ });
199
+ const instance = render(React.createElement(ThemeProvider, { slug: resolvedTheme.slug }, React.createElement(Repl, {
185
200
  session,
186
201
  updateBanner: options.updateBanner ?? null,
187
202
  skipSplash: options.skipSplash === true,
188
203
  hideToolStream: options.hideToolStream === true,
189
204
  mascotPrePrinted,
190
- }));
205
+ })));
191
206
  // Make sure we leave the alt screen on abrupt exits too. Without
192
207
  // this the operator's shell stays "frozen" on the Pugi splash.
193
208
  process.once('exit', bootstrap.restore);
package/dist/tui/repl.js CHANGED
@@ -29,6 +29,7 @@ import { StatusBar } from './status-bar.js';
29
29
  import { ToolStreamPane } from './tool-stream-pane.js';
30
30
  import { UpdateBanner } from './update-banner.js';
31
31
  import { collectWorkspaceContext } from './workspace-context.js';
32
+ import { useTheme } from '../core/theme/context.js';
32
33
  import { slugForCwd } from '../core/repl/history.js';
33
34
  import { SLASH_COMMAND_HELP, SLASH_COMMAND_GROUPS } from '../core/repl/slash-commands.js';
34
35
  const TICK_INTERVAL_MS = 200;
@@ -202,7 +203,14 @@ export function Repl(props) {
202
203
  sessionTokensIn: state.sessionTokensIn, sessionTokensOut: state.sessionTokensOut, sessionCostUsd: state.sessionCostUsd, sessionStartedAtEpochMs: state.sessionStartedAtEpochMs, lastTurnDelta: state.lastTurnDelta })] })] }));
203
204
  }
204
205
  function Header({ state }) {
205
- return (_jsxs(Box, { children: [_jsx(Text, { bold: true, children: "Pugi" }), _jsx(Text, { bold: true, color: "#3da9fc", children: ".io" }), _jsx(Text, { dimColor: true, children: ` · workspace: ${state.workspaceLabel} · v${state.cliVersion} · ` }), _jsx(Text, { color: "#3da9fc", children: state.connection === 'on_watch' ? 'on watch' : state.connection.replace('_', ' ') })] }));
206
+ // Leak L30 (2026-05-27): the header `.io` brand accent + connection
207
+ // pill route through `useTheme()` so the operator's `/theme` flip
208
+ // (default / dark / light / colorblind) re-tints the chrome on
209
+ // re-mount. The `useTheme` hook returns the `default` preset's
210
+ // colors when no provider is mounted, preserving the previous
211
+ // `#3da9fc` constants for tests that import `<Repl />` standalone.
212
+ const theme = useTheme();
213
+ return (_jsxs(Box, { children: [_jsx(Text, { bold: true, children: "Pugi" }), _jsx(Text, { bold: true, color: theme.accent, children: ".io" }), _jsx(Text, { dimColor: true, children: ` · workspace: ${state.workspaceLabel} · v${state.cliVersion} · ` }), _jsx(Text, { color: theme.accent, children: state.connection === 'on_watch' ? 'on watch' : state.connection.replace('_', ' ') })] }));
206
214
  }
207
215
  function MainArea({ state, personaNames, nowEpochMs, hideToolStream, toolStreamCollapsed, }) {
208
216
  // α6.12: three vertical panes stacked above the input box.
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from 'ink';
3
3
  import { OUTPUT_STYLES, OUTPUT_STYLE_SLUGS, } from '../core/output-style/presets.js';
4
+ import { useTheme } from '../core/theme/context.js';
4
5
  /**
5
6
  * Banner above the table. Plain text (not bold) so the prefix `*`
6
7
  * remains the dominant active-row cue.
@@ -9,14 +10,19 @@ function buildBanner(active, source) {
9
10
  return `Active style: ${active} (${source})`;
10
11
  }
11
12
  export function StyleTable({ active, source }) {
13
+ // Leak L30 (2026-05-27): the active-row marker color flows through
14
+ // the theme so `colorblind` operators see cyan instead of green
15
+ // (which their palette re-maps to `success`). Falls back to the
16
+ // default theme's `success` token when no provider is mounted.
17
+ const theme = useTheme();
12
18
  const slugWidth = Math.max('NAME'.length, ...OUTPUT_STYLE_SLUGS.map((slug) => slug.length));
13
- return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { bold: true, children: "Pugi output styles" }) }), _jsx(Box, { children: _jsx(Text, { dimColor: true, children: ` ${'NAME'.padEnd(slugWidth)} GLOSS` }) }), OUTPUT_STYLE_SLUGS.map((slug) => (_jsx(StyleRow, { slug: slug, active: active, slugWidth: slugWidth }, slug))), _jsx(Box, { marginTop: 1, children: _jsx(Text, { children: buildBanner(active, source) }) })] }));
19
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { bold: true, children: "Pugi output styles" }) }), _jsx(Box, { children: _jsx(Text, { dimColor: true, children: ` ${'NAME'.padEnd(slugWidth)} GLOSS` }) }), OUTPUT_STYLE_SLUGS.map((slug) => (_jsx(StyleRow, { slug: slug, active: active, slugWidth: slugWidth, activeColor: theme.success }, slug))), _jsx(Box, { marginTop: 1, children: _jsx(Text, { children: buildBanner(active, source) }) })] }));
14
20
  }
15
- function StyleRow({ slug, active, slugWidth }) {
21
+ function StyleRow({ slug, active, slugWidth, activeColor }) {
16
22
  const isActive = slug === active;
17
23
  const marker = isActive ? '*' : ' ';
18
24
  const slugPart = slug.padEnd(slugWidth, ' ');
19
25
  const gloss = OUTPUT_STYLES[slug].gloss;
20
- return (_jsxs(Box, { children: [_jsx(Text, { color: isActive ? 'green' : undefined, bold: isActive, children: `${marker} ${slugPart}` }), _jsx(Text, { children: ` ${gloss}` })] }));
26
+ return (_jsxs(Box, { children: [_jsx(Text, { color: isActive ? activeColor : undefined, bold: isActive, children: `${marker} ${slugPart}` }), _jsx(Text, { children: ` ${gloss}` })] }));
21
27
  }
22
28
  //# sourceMappingURL=style-table.js.map
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from 'ink';
3
+ import { compileSampleRow, THEMES, THEME_SLUGS, } from '../core/theme/presets.js';
4
+ /**
5
+ * Banner above the table. Plain text (not bold) so the prefix `*`
6
+ * remains the dominant active-row cue. Mirrors `<StyleTable>` so the
7
+ * Settings-group surfaces read identically.
8
+ */
9
+ function buildBanner(active, source) {
10
+ return `Active theme: ${active} (${source})`;
11
+ }
12
+ export function ThemeTable({ active, source }) {
13
+ const slugWidth = Math.max('NAME'.length, ...THEME_SLUGS.map((slug) => slug.length));
14
+ // The gloss column gets sized to the widest gloss + 2 padding so
15
+ // the sample column lines up. Computed once per render so the
16
+ // layout stays stable when the catalogue grows.
17
+ const glossWidth = Math.max('GLOSS'.length, ...THEME_SLUGS.map((slug) => THEMES[slug].gloss.length));
18
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { bold: true, children: "Pugi themes" }) }), _jsx(Box, { children: _jsx(Text, { dimColor: true, children: ` ${'NAME'.padEnd(slugWidth)} ${'GLOSS'.padEnd(glossWidth)} SAMPLE` }) }), THEME_SLUGS.map((slug) => (_jsx(ThemeRow, { slug: slug, active: active, slugWidth: slugWidth, glossWidth: glossWidth }, slug))), _jsx(Box, { marginTop: 1, children: _jsx(Text, { children: buildBanner(active, source) }) })] }));
19
+ }
20
+ function ThemeRow({ slug, active, slugWidth, glossWidth }) {
21
+ const isActive = slug === active;
22
+ const marker = isActive ? '*' : ' ';
23
+ const slugPart = slug.padEnd(slugWidth, ' ');
24
+ const preset = THEMES[slug];
25
+ const gloss = preset.gloss.padEnd(glossWidth, ' ');
26
+ const sample = compileSampleRow(slug);
27
+ return (_jsxs(Box, { children: [_jsx(Text, { color: isActive ? preset.colors.accent : undefined, bold: isActive, children: `${marker} ${slugPart}` }), _jsx(Text, { children: ` ${gloss} ` }), _jsx(Text, { color: preset.colors.foreground, children: sample.foreground }), _jsx(Text, { children: ' ' }), _jsx(Text, { color: preset.colors.accent, children: sample.accent }), _jsx(Text, { children: ' ' }), _jsx(Text, { color: preset.colors.success, children: sample.success }), _jsx(Text, { children: ' ' }), _jsx(Text, { color: preset.colors.warning, children: sample.warning }), _jsx(Text, { children: ' ' }), _jsx(Text, { color: preset.colors.error, children: sample.error })] }));
28
+ }
29
+ //# sourceMappingURL=theme-table.js.map