@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.
- package/dist/core/auth/env-provider.js +238 -0
- package/dist/core/auto-update/channels.js +122 -0
- package/dist/core/auto-update/checker.js +241 -0
- package/dist/core/auto-update/state.js +235 -0
- package/dist/core/diagnostics/probes/pugi-md.js +89 -0
- package/dist/core/engine/native-pugi.js +34 -1
- package/dist/core/pugi-md/context-injector.js +76 -0
- package/dist/core/pugi-md/walk-up.js +207 -0
- package/dist/core/release-notes/parser.js +241 -0
- package/dist/core/release-notes/state.js +116 -0
- package/dist/core/repl/session.js +156 -0
- package/dist/core/repl/slash-commands.js +50 -0
- package/dist/core/theme/context.js +91 -0
- package/dist/core/theme/presets.js +228 -0
- package/dist/core/theme/state.js +181 -0
- package/dist/core/vim/keymap.js +288 -0
- package/dist/core/vim/state.js +92 -0
- package/dist/runtime/cli.js +297 -14
- package/dist/runtime/commands/doctor.js +13 -0
- package/dist/runtime/commands/release-notes.js +229 -0
- package/dist/runtime/commands/theme.js +196 -0
- package/dist/runtime/commands/update.js +289 -0
- package/dist/runtime/commands/vim.js +140 -0
- package/dist/runtime/version.js +1 -1
- package/dist/tui/doctor-table.js +32 -17
- package/dist/tui/repl-render.js +17 -2
- package/dist/tui/repl.js +9 -1
- package/dist/tui/style-table.js +9 -3
- package/dist/tui/theme-table.js +29 -0
- package/dist/tui/vim-input.js +267 -0
- package/package.json +2 -2
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keep-a-Changelog parser — Leak L24 (2026-05-27).
|
|
3
|
+
*
|
|
4
|
+
* Parses a `CHANGELOG.md` written в the Keep-a-Changelog v1.1 layout
|
|
5
|
+
* (https://keepachangelog.com) into an ordered list of version
|
|
6
|
+
* sections. The parser is intentionally minimal — it understands the
|
|
7
|
+
* `## [<version>] - <date>` header marker and the section body up к
|
|
8
|
+
* the next header, and ignores every other Markdown construct (links,
|
|
9
|
+
* footnotes, sub-sub-headers). That is enough к drive the
|
|
10
|
+
* `pugi release-notes` diff between last-seen and current.
|
|
11
|
+
*
|
|
12
|
+
* # Module contract
|
|
13
|
+
*
|
|
14
|
+
* - Pure function. Takes the raw CHANGELOG text + returns parsed
|
|
15
|
+
* sections. Zero IO; the file read happens at the call site so the
|
|
16
|
+
* spec can pin fixtures without touching disk.
|
|
17
|
+
*
|
|
18
|
+
* - Header grammar: `## [<version>] - <YYYY-MM-DD>`. The leading
|
|
19
|
+
* `## ` is required (h2). The version is everything between the
|
|
20
|
+
* square brackets — semver-shaped strings are not validated
|
|
21
|
+
* beyond non-emptiness so pre-release tags like `0.1.0-beta.21`
|
|
22
|
+
* parse correctly. The date is captured verbatim; the comparator
|
|
23
|
+
* does not parse it — version ordering is enough.
|
|
24
|
+
*
|
|
25
|
+
* - Section body: every line from the header (exclusive) up к the
|
|
26
|
+
* next `## [...] - ...` header (exclusive). Lines are joined
|
|
27
|
+
* verbatim with `\n`; leading + trailing blank lines are trimmed
|
|
28
|
+
* so the renderer can paste sections back-to-back without double
|
|
29
|
+
* blank lines piling up.
|
|
30
|
+
*
|
|
31
|
+
* - Pre-header content (the leading `# Changelog` + introduction
|
|
32
|
+
* blurb) is discarded. The parser only surfaces version sections;
|
|
33
|
+
* callers that want к render the introduction read the source
|
|
34
|
+
* file directly.
|
|
35
|
+
*
|
|
36
|
+
* - Sections appear в the order they are written in the file. The
|
|
37
|
+
* Keep-a-Changelog convention is newest-first; the parser does
|
|
38
|
+
* NOT re-sort. The slicing helpers (`sliceVersionsBetween`) trust
|
|
39
|
+
* the input order so a malformed CHANGELOG with shuffled
|
|
40
|
+
* versions produces a deterministic — if surprising — diff
|
|
41
|
+
* instead of silently swallowing entries.
|
|
42
|
+
*
|
|
43
|
+
* - Semver comparison (`compareSemver`) handles the canonical
|
|
44
|
+
* `MAJOR.MINOR.PATCH[-PRERELEASE]` shape. The pre-release tail
|
|
45
|
+
* is compared lexicographically by dot-separated identifier per
|
|
46
|
+
* semver §11. Unknown / malformed input compares lower than any
|
|
47
|
+
* valid semver so an accidental `unknown` last-seen marker
|
|
48
|
+
* never blocks the operator from seeing new notes.
|
|
49
|
+
*/
|
|
50
|
+
const SECTION_HEADER_RE = /^##\s+\[([^\]]+)\](?:\s*-\s*(.+))?\s*$/u;
|
|
51
|
+
/**
|
|
52
|
+
* Parse the raw `CHANGELOG.md` text into ordered version sections.
|
|
53
|
+
*
|
|
54
|
+
* Returns sections in the same order they appear in the source. The
|
|
55
|
+
* Keep-a-Changelog convention is newest-first; the parser does not
|
|
56
|
+
* re-sort.
|
|
57
|
+
*/
|
|
58
|
+
export function parseChangelog(raw) {
|
|
59
|
+
const lines = raw.split(/\r?\n/u);
|
|
60
|
+
const sections = [];
|
|
61
|
+
let current = null;
|
|
62
|
+
const flush = () => {
|
|
63
|
+
if (!current)
|
|
64
|
+
return;
|
|
65
|
+
sections.push({
|
|
66
|
+
version: current.version,
|
|
67
|
+
date: current.date,
|
|
68
|
+
body: trimBlankEdges(current.lines).join('\n'),
|
|
69
|
+
});
|
|
70
|
+
current = null;
|
|
71
|
+
};
|
|
72
|
+
for (const line of lines) {
|
|
73
|
+
const match = SECTION_HEADER_RE.exec(line);
|
|
74
|
+
if (match) {
|
|
75
|
+
flush();
|
|
76
|
+
const version = (match[1] ?? '').trim();
|
|
77
|
+
const date = (match[2] ?? '').trim();
|
|
78
|
+
if (version.length === 0) {
|
|
79
|
+
// Malformed `## []` header — skip entirely instead of
|
|
80
|
+
// emitting a zero-version row that would corrupt the diff.
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
current = { version, date, lines: [] };
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (current) {
|
|
87
|
+
current.lines.push(line);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
flush();
|
|
91
|
+
return sections;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Slice the section list к those strictly newer than `lastSeen` and
|
|
95
|
+
* up к (and including) `current`. Both bounds are matched on the
|
|
96
|
+
* verbatim version string — the comparator runs on every section к
|
|
97
|
+
* decide membership.
|
|
98
|
+
*
|
|
99
|
+
* Semantics:
|
|
100
|
+
*
|
|
101
|
+
* - If `lastSeen` is null OR empty OR matches no section, every
|
|
102
|
+
* section ≤ current is returned. This is the first-run path —
|
|
103
|
+
* the operator has never run the command before, so the entire
|
|
104
|
+
* bundled changelog is fair game.
|
|
105
|
+
*
|
|
106
|
+
* - If `lastSeen` equals `current`, the empty array is returned.
|
|
107
|
+
* The caller renders the "no new release notes" copy.
|
|
108
|
+
*
|
|
109
|
+
* - If `lastSeen` is newer than `current`, the empty array is
|
|
110
|
+
* returned. This is the dev-build path — operators running a
|
|
111
|
+
* local build of `0.1.0-beta.30` against a registry that
|
|
112
|
+
* publishes `0.1.0-beta.22` would otherwise see the stale
|
|
113
|
+
* bundled notes; the caller still surfaces the same no-op copy.
|
|
114
|
+
*
|
|
115
|
+
* - Otherwise: sections strictly newer than `lastSeen` and ≤
|
|
116
|
+
* `current`, in the source order (newest-first by convention).
|
|
117
|
+
*
|
|
118
|
+
* The function is pure — no IO, no clock — so the spec can pin every
|
|
119
|
+
* branch with hand-rolled fixtures.
|
|
120
|
+
*/
|
|
121
|
+
export function sliceVersionsBetween(sections, lastSeen, current) {
|
|
122
|
+
if (sections.length === 0)
|
|
123
|
+
return [];
|
|
124
|
+
// Treat а blank / sentinel last-seen as "never seen".
|
|
125
|
+
const lastSeenValue = typeof lastSeen === 'string' && lastSeen.trim().length > 0 && lastSeen !== 'none'
|
|
126
|
+
? lastSeen.trim()
|
|
127
|
+
: null;
|
|
128
|
+
// Dev-build path: operator's last-seen marker is strictly newer than
|
|
129
|
+
// the installed CLI version. This happens when running а local build
|
|
130
|
+
// older than the registry, or when the operator manually edited the
|
|
131
|
+
// marker. Either way, return the empty array — re-rendering the
|
|
132
|
+
// bundled notes would be misleading. The renderer surfaces the same
|
|
133
|
+
// "no new release notes" copy as the up-to-date branch.
|
|
134
|
+
if (lastSeenValue !== null && compareSemver(lastSeenValue, current) > 0) {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
// Diff path: surface sections strictly newer than the marker and ≤
|
|
138
|
+
// current. The comparator drives every section — а marker that does
|
|
139
|
+
// not appear in the bundled changelog (operator on а stale build,
|
|
140
|
+
// hand-edited marker, version no longer published) still bisects
|
|
141
|
+
// correctly because every comparison runs against the marker value
|
|
142
|
+
// directly, not the matching-section guard.
|
|
143
|
+
const out = [];
|
|
144
|
+
for (const section of sections) {
|
|
145
|
+
// Anything newer than current is а future entry that should not
|
|
146
|
+
// surface until the operator actually upgrades — guards against а
|
|
147
|
+
// dev build of CHANGELOG.md leaking unreleased notes к а customer
|
|
148
|
+
// install.
|
|
149
|
+
if (compareSemver(section.version, current) > 0)
|
|
150
|
+
continue;
|
|
151
|
+
if (lastSeenValue !== null && compareSemver(section.version, lastSeenValue) <= 0) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
out.push(section);
|
|
155
|
+
}
|
|
156
|
+
return out;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Semver comparator. Returns a negative number when `a < b`, zero
|
|
160
|
+
* when equal, and a positive number when `a > b`. Pre-release tags
|
|
161
|
+
* compare lexicographically by dot-separated identifier per semver §11.
|
|
162
|
+
*
|
|
163
|
+
* Unknown / malformed input compares lower than any valid semver so
|
|
164
|
+
* an accidental sentinel like `unknown` or `none` never accidentally
|
|
165
|
+
* blocks the diff from surfacing newer entries.
|
|
166
|
+
*/
|
|
167
|
+
export function compareSemver(a, b) {
|
|
168
|
+
const left = parseSemver(a);
|
|
169
|
+
const right = parseSemver(b);
|
|
170
|
+
if (!left && !right)
|
|
171
|
+
return 0;
|
|
172
|
+
if (!left)
|
|
173
|
+
return -1;
|
|
174
|
+
if (!right)
|
|
175
|
+
return 1;
|
|
176
|
+
for (let i = 0; i < 3; i += 1) {
|
|
177
|
+
const cmp = (left.core[i] ?? 0) - (right.core[i] ?? 0);
|
|
178
|
+
if (cmp !== 0)
|
|
179
|
+
return cmp;
|
|
180
|
+
}
|
|
181
|
+
// A version without a pre-release tag is newer than the same core
|
|
182
|
+
// with a pre-release tag (per semver §11: 1.0.0 > 1.0.0-rc).
|
|
183
|
+
if (left.pre.length === 0 && right.pre.length === 0)
|
|
184
|
+
return 0;
|
|
185
|
+
if (left.pre.length === 0)
|
|
186
|
+
return 1;
|
|
187
|
+
if (right.pre.length === 0)
|
|
188
|
+
return -1;
|
|
189
|
+
const len = Math.max(left.pre.length, right.pre.length);
|
|
190
|
+
for (let i = 0; i < len; i += 1) {
|
|
191
|
+
const li = left.pre[i];
|
|
192
|
+
const ri = right.pre[i];
|
|
193
|
+
if (li === undefined)
|
|
194
|
+
return -1;
|
|
195
|
+
if (ri === undefined)
|
|
196
|
+
return 1;
|
|
197
|
+
const ln = Number.parseInt(li, 10);
|
|
198
|
+
const rn = Number.parseInt(ri, 10);
|
|
199
|
+
const liNumeric = Number.isFinite(ln) && String(ln) === li;
|
|
200
|
+
const riNumeric = Number.isFinite(rn) && String(rn) === ri;
|
|
201
|
+
if (liNumeric && riNumeric) {
|
|
202
|
+
if (ln !== rn)
|
|
203
|
+
return ln - rn;
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
if (liNumeric)
|
|
207
|
+
return -1; // numeric < alphanumeric per §11
|
|
208
|
+
if (riNumeric)
|
|
209
|
+
return 1;
|
|
210
|
+
if (li < ri)
|
|
211
|
+
return -1;
|
|
212
|
+
if (li > ri)
|
|
213
|
+
return 1;
|
|
214
|
+
}
|
|
215
|
+
return 0;
|
|
216
|
+
}
|
|
217
|
+
function parseSemver(raw) {
|
|
218
|
+
if (typeof raw !== 'string')
|
|
219
|
+
return null;
|
|
220
|
+
const trimmed = raw.trim();
|
|
221
|
+
if (trimmed.length === 0)
|
|
222
|
+
return null;
|
|
223
|
+
const match = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/u.exec(trimmed);
|
|
224
|
+
if (!match)
|
|
225
|
+
return null;
|
|
226
|
+
const major = Number.parseInt(match[1] ?? '0', 10);
|
|
227
|
+
const minor = Number.parseInt(match[2] ?? '0', 10);
|
|
228
|
+
const patch = Number.parseInt(match[3] ?? '0', 10);
|
|
229
|
+
const pre = match[4] ? match[4].split('.') : [];
|
|
230
|
+
return { core: [major, minor, patch], pre };
|
|
231
|
+
}
|
|
232
|
+
function trimBlankEdges(lines) {
|
|
233
|
+
let start = 0;
|
|
234
|
+
let end = lines.length;
|
|
235
|
+
while (start < end && (lines[start] ?? '').trim().length === 0)
|
|
236
|
+
start += 1;
|
|
237
|
+
while (end > start && (lines[end - 1] ?? '').trim().length === 0)
|
|
238
|
+
end -= 1;
|
|
239
|
+
return lines.slice(start, end);
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `~/.pugi/.last-seen-version` state I/O — Leak L24 (2026-05-27).
|
|
3
|
+
*
|
|
4
|
+
* The `pugi release-notes` command renders the diff between the
|
|
5
|
+
* version the operator last saw notes for and the currently
|
|
6
|
+
* installed CLI version. This module owns the on-disk marker that
|
|
7
|
+
* tracks the last-seen value.
|
|
8
|
+
*
|
|
9
|
+
* # Module contract
|
|
10
|
+
*
|
|
11
|
+
* - File path: `<home>/.pugi/.last-seen-version`. The leading dot
|
|
12
|
+
* keeps it out of casual `ls` output; the file is plain ASCII
|
|
13
|
+
* (one line, the version string) so operators can edit it by
|
|
14
|
+
* hand when reproducing scenarios. Missing parent dir is
|
|
15
|
+
* created on write.
|
|
16
|
+
*
|
|
17
|
+
* - Reads: missing file → null. Unreadable / blank file → null.
|
|
18
|
+
* The caller treats null as "operator has never run the command"
|
|
19
|
+
* and surfaces every bundled section. Read failures NEVER throw —
|
|
20
|
+
* the command surface is informational and must keep working on
|
|
21
|
+
* a read-only mount or a misconfigured permission bit.
|
|
22
|
+
*
|
|
23
|
+
* - Writes: best-effort. EACCES / EROFS / ENOSPC log а warning к
|
|
24
|
+
* the caller-supplied logger and return the failure code so the
|
|
25
|
+
* command renderer can footer the output with "could not persist
|
|
26
|
+
* last-seen — re-run will show the same notes". The command
|
|
27
|
+
* itself stays exit 0 because the value of the render did not
|
|
28
|
+
* depend on the write succeeding.
|
|
29
|
+
*
|
|
30
|
+
* - The helpers are pure I/O wrappers — no clock, no random, no
|
|
31
|
+
* env reads. Callers pass `home` explicitly so the spec can
|
|
32
|
+
* pin a tmp dir without monkey-patching `os.homedir`.
|
|
33
|
+
*/
|
|
34
|
+
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
35
|
+
import { resolve } from 'node:path';
|
|
36
|
+
/** Filename inside `<home>/.pugi/` that holds the last-seen marker. */
|
|
37
|
+
export const LAST_SEEN_VERSION_FILE = '.last-seen-version';
|
|
38
|
+
/**
|
|
39
|
+
* Resolve the absolute path of the last-seen marker file inside the
|
|
40
|
+
* passed home directory. Pure helper — no IO.
|
|
41
|
+
*/
|
|
42
|
+
export function lastSeenVersionPath(home) {
|
|
43
|
+
return resolve(home, '.pugi', LAST_SEEN_VERSION_FILE);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Read the last-seen marker. Returns null when the file is missing,
|
|
47
|
+
* unreadable, or empty. Never throws.
|
|
48
|
+
*/
|
|
49
|
+
export function readLastSeenVersion(home) {
|
|
50
|
+
const path = lastSeenVersionPath(home);
|
|
51
|
+
try {
|
|
52
|
+
if (!existsSync(path))
|
|
53
|
+
return null;
|
|
54
|
+
const raw = readFileSync(path, 'utf8').trim();
|
|
55
|
+
if (raw.length === 0)
|
|
56
|
+
return null;
|
|
57
|
+
return raw;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Read-only mount, permission denied, race with another process
|
|
61
|
+
// unlinking the file — every read failure degrades к null so the
|
|
62
|
+
// command treats the operator as a first-time viewer instead of
|
|
63
|
+
// dropping out of the slash dispatcher with an unhandled error.
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Persist the last-seen marker. Creates `<home>/.pugi/` if it does
|
|
69
|
+
* not exist. Returns a structured envelope describing success or the
|
|
70
|
+
* failure reason so the renderer can footer а warning when the write
|
|
71
|
+
* could not be made durable.
|
|
72
|
+
*/
|
|
73
|
+
export function writeLastSeenVersion(home, version) {
|
|
74
|
+
const path = lastSeenVersionPath(home);
|
|
75
|
+
try {
|
|
76
|
+
const dir = resolve(home, '.pugi');
|
|
77
|
+
if (!existsSync(dir)) {
|
|
78
|
+
mkdirSync(dir, { recursive: true });
|
|
79
|
+
}
|
|
80
|
+
// Trailing newline so `cat ~/.pugi/.last-seen-version` reads
|
|
81
|
+
// nicely in shells that do not auto-append one for the prompt.
|
|
82
|
+
writeFileSync(path, `${version}\n`, { encoding: 'utf8', mode: 0o600 });
|
|
83
|
+
return { status: 'ok', path };
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
return {
|
|
87
|
+
status: 'failed',
|
|
88
|
+
path,
|
|
89
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Clear the last-seen marker — used by `pugi release-notes --reset`
|
|
95
|
+
* so the operator can force the full bundled changelog к re-render.
|
|
96
|
+
* Returns `absent` when the marker did not exist, `cleared` on
|
|
97
|
+
* success, `failed` on permission errors.
|
|
98
|
+
*/
|
|
99
|
+
export function clearLastSeenVersion(home) {
|
|
100
|
+
const path = lastSeenVersionPath(home);
|
|
101
|
+
try {
|
|
102
|
+
if (!existsSync(path)) {
|
|
103
|
+
return { status: 'absent', path };
|
|
104
|
+
}
|
|
105
|
+
unlinkSync(path);
|
|
106
|
+
return { status: 'cleared', path };
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
return {
|
|
110
|
+
status: 'failed',
|
|
111
|
+
path,
|
|
112
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
* verbatim - the brand gate on those happens at the controller.
|
|
28
28
|
*/
|
|
29
29
|
import { randomUUID } from 'node:crypto';
|
|
30
|
+
import { homedir } from 'node:os';
|
|
30
31
|
import { getPersona } from '@pugi/personas';
|
|
31
32
|
import { listRoles, getPersonaForRole } from '../agents/registry.js';
|
|
32
33
|
import { evaluateCap, describeVerdict } from './cap-warning.js';
|
|
@@ -788,6 +789,39 @@ export class ReplSession {
|
|
|
788
789
|
}
|
|
789
790
|
return verdict;
|
|
790
791
|
}
|
|
792
|
+
case 'theme': {
|
|
793
|
+
// Leak L30 (2026-05-27): /theme [name] [--persist|--reset|--list]
|
|
794
|
+
// forwards to the shared `runThemeCommand` runner. Same async
|
|
795
|
+
// buffer-then-flush pattern as `/style` so a future async
|
|
796
|
+
// write path inside the runner cannot drop a tail emission
|
|
797
|
+
// and so multi-line payloads (banner + preview table) land
|
|
798
|
+
// one row per visual line in the conversation pane.
|
|
799
|
+
try {
|
|
800
|
+
const { runThemeCommand } = await import('../../runtime/commands/theme.js');
|
|
801
|
+
const lines = [];
|
|
802
|
+
await runThemeCommand(verdict.args, {
|
|
803
|
+
workspaceRoot: process.cwd(),
|
|
804
|
+
writeOutput: (_payload, text) => {
|
|
805
|
+
for (const raw of text.split('\n')) {
|
|
806
|
+
const trimmed = raw.replace(/\s+$/u, '');
|
|
807
|
+
lines.push(trimmed);
|
|
808
|
+
}
|
|
809
|
+
},
|
|
810
|
+
});
|
|
811
|
+
if (lines.length === 0) {
|
|
812
|
+
this.appendSystemLine('/theme: no output.');
|
|
813
|
+
}
|
|
814
|
+
else {
|
|
815
|
+
for (const line of lines)
|
|
816
|
+
this.appendSystemLine(line);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
catch (error) {
|
|
820
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
821
|
+
this.appendSystemLine(`/theme failed: ${message}`);
|
|
822
|
+
}
|
|
823
|
+
return verdict;
|
|
824
|
+
}
|
|
791
825
|
case 'style': {
|
|
792
826
|
// Leak L18 (2026-05-27): /style [name] [--persist|--reset|--list]
|
|
793
827
|
// forwards to the shared `runStyleCommand` runner so the slash
|
|
@@ -871,6 +905,45 @@ export class ReplSession {
|
|
|
871
905
|
}
|
|
872
906
|
return verdict;
|
|
873
907
|
}
|
|
908
|
+
case 'vim': {
|
|
909
|
+
// Leak L26 (2026-05-27): /vim forwards to the shared
|
|
910
|
+
// `runVimCommand` runner so the slash + top-level surfaces
|
|
911
|
+
// stay single-sourced. Dynamic import mirrors /style so the
|
|
912
|
+
// dispatcher does not drag the vim module graph into every
|
|
913
|
+
// keystroke.
|
|
914
|
+
//
|
|
915
|
+
// The runner mutates `~/.pugi/config.json::vimMode`; the
|
|
916
|
+
// active REPL session does NOT live-pick-up the flip (the
|
|
917
|
+
// VimInput wrapper is mounted once at REPL boot). Operators
|
|
918
|
+
// get a hint that the next session will reflect the change.
|
|
919
|
+
// A follow-up sprint can plumb a state-store subscriber so
|
|
920
|
+
// the flip takes effect mid-session.
|
|
921
|
+
try {
|
|
922
|
+
const { runVimCommand } = await import('../../runtime/commands/vim.js');
|
|
923
|
+
const lines = [];
|
|
924
|
+
await runVimCommand(verdict.args, {
|
|
925
|
+
env: process.env,
|
|
926
|
+
writeOutput: (_payload, text) => {
|
|
927
|
+
for (const raw of text.split('\n')) {
|
|
928
|
+
const trimmed = raw.replace(/\s+$/u, '');
|
|
929
|
+
lines.push(trimmed);
|
|
930
|
+
}
|
|
931
|
+
},
|
|
932
|
+
});
|
|
933
|
+
if (lines.length === 0) {
|
|
934
|
+
this.appendSystemLine('/vim: no output.');
|
|
935
|
+
}
|
|
936
|
+
else {
|
|
937
|
+
for (const line of lines)
|
|
938
|
+
this.appendSystemLine(line);
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
catch (error) {
|
|
942
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
943
|
+
this.appendSystemLine(`/vim failed: ${message}`);
|
|
944
|
+
}
|
|
945
|
+
return verdict;
|
|
946
|
+
}
|
|
874
947
|
case 'doctor': {
|
|
875
948
|
// L17 (2026-05-27): run the doctor probe sweep inline. We
|
|
876
949
|
// dynamic-import the runtime/commands/doctor module so the
|
|
@@ -1017,6 +1090,41 @@ export class ReplSession {
|
|
|
1017
1090
|
}
|
|
1018
1091
|
return verdict;
|
|
1019
1092
|
}
|
|
1093
|
+
case 'release-notes': {
|
|
1094
|
+
// Leak L24 (2026-05-27): changelog diff between the operator's
|
|
1095
|
+
// last-seen + installed CLI versions. Delegate к the shared
|
|
1096
|
+
// `runReleaseNotesCommand` runner so the slash + top-level
|
|
1097
|
+
// paths stay single-sourced. The renderer collects each line
|
|
1098
|
+
// into the system pane via `appendSystemLine` — no fresh Ink
|
|
1099
|
+
// mount, no boxed render. `--reset` is honoured via the
|
|
1100
|
+
// `verdict.reset` field parsed in slash-commands.ts.
|
|
1101
|
+
try {
|
|
1102
|
+
const { runReleaseNotesCommand, defaultReleaseNotesHome } = await import('../../runtime/commands/release-notes.js');
|
|
1103
|
+
const lines = [];
|
|
1104
|
+
runReleaseNotesCommand({
|
|
1105
|
+
home: defaultReleaseNotesHome(),
|
|
1106
|
+
json: false,
|
|
1107
|
+
reset: verdict.reset,
|
|
1108
|
+
writeOutput: (_payload, text) => {
|
|
1109
|
+
for (const line of text.split('\n')) {
|
|
1110
|
+
lines.push(line.replace(/\s+$/u, ''));
|
|
1111
|
+
}
|
|
1112
|
+
},
|
|
1113
|
+
});
|
|
1114
|
+
if (lines.length === 0) {
|
|
1115
|
+
this.appendSystemLine('/release-notes: no output.');
|
|
1116
|
+
}
|
|
1117
|
+
else {
|
|
1118
|
+
for (const line of lines)
|
|
1119
|
+
this.appendSystemLine(line);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
catch (error) {
|
|
1123
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1124
|
+
this.appendSystemLine(`/release-notes failed: ${message}`);
|
|
1125
|
+
}
|
|
1126
|
+
return verdict;
|
|
1127
|
+
}
|
|
1020
1128
|
case 'stickers': {
|
|
1021
1129
|
// Leak L33 (2026-05-27): brand-personality gimmick. Delegate to
|
|
1022
1130
|
// the shared `runStickersCommand` so the slash + top-level
|
|
@@ -1060,6 +1168,54 @@ export class ReplSession {
|
|
|
1060
1168
|
}
|
|
1061
1169
|
return verdict;
|
|
1062
1170
|
}
|
|
1171
|
+
case 'update': {
|
|
1172
|
+
// Leak L27 (2026-05-27): /update probes the npm registry for a
|
|
1173
|
+
// newer @pugi/cli version on the configured channel and prints
|
|
1174
|
+
// the install command. The slash form NEVER spawns `npm install
|
|
1175
|
+
// -g` — that would corrupt the binary we are currently running.
|
|
1176
|
+
// Operators see the install command + run it manually (or run
|
|
1177
|
+
// `pugi update --apply` from a fresh shell after the REPL
|
|
1178
|
+
// exits). The slash + top-level paths share the dispatcher so
|
|
1179
|
+
// channel resolution + last-check persistence stay single-
|
|
1180
|
+
// sourced.
|
|
1181
|
+
try {
|
|
1182
|
+
const { parseUpdateArgs, runUpdateCommand } = await import('../../runtime/commands/update.js');
|
|
1183
|
+
const parsed = parseUpdateArgs(verdict.args);
|
|
1184
|
+
if ('error' in parsed) {
|
|
1185
|
+
this.appendSystemLine(parsed.error);
|
|
1186
|
+
return verdict;
|
|
1187
|
+
}
|
|
1188
|
+
// Force `apply=false` on the slash path — see comment above.
|
|
1189
|
+
const slashFlags = { ...parsed, apply: false };
|
|
1190
|
+
const lines = [];
|
|
1191
|
+
await runUpdateCommand({
|
|
1192
|
+
cwd: process.cwd(),
|
|
1193
|
+
home: homedir(),
|
|
1194
|
+
env: process.env,
|
|
1195
|
+
flags: slashFlags,
|
|
1196
|
+
promptConfirm: async () => false,
|
|
1197
|
+
writeOutput: (_payload, text) => {
|
|
1198
|
+
for (const line of text.split('\n')) {
|
|
1199
|
+
const trimmed = line.replace(/\s+$/u, '');
|
|
1200
|
+
if (trimmed.length > 0)
|
|
1201
|
+
lines.push(trimmed);
|
|
1202
|
+
}
|
|
1203
|
+
},
|
|
1204
|
+
});
|
|
1205
|
+
if (lines.length === 0) {
|
|
1206
|
+
this.appendSystemLine('/update: no output.');
|
|
1207
|
+
}
|
|
1208
|
+
else {
|
|
1209
|
+
for (const line of lines)
|
|
1210
|
+
this.appendSystemLine(line);
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
catch (error) {
|
|
1214
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1215
|
+
this.appendSystemLine(`/update failed: ${message}`);
|
|
1216
|
+
}
|
|
1217
|
+
return verdict;
|
|
1218
|
+
}
|
|
1063
1219
|
case 'feedback': {
|
|
1064
1220
|
// Leak L21 (2026-05-27): in-CLI feedback collector. The wizard
|
|
1065
1221
|
// mounts a fresh Ink tree (renderFeedbackPrompt) outside the
|
|
@@ -83,7 +83,9 @@ export const SLASH_COMMAND_HELP = Object.freeze([
|
|
|
83
83
|
{ name: 'budget', args: '', gloss: 'Show usage budget', group: 'Settings', stub: true },
|
|
84
84
|
{ name: 'mcp', args: '[sub]', gloss: 'MCP servers — list / trust / deny / install / serve / perms', group: 'Settings' },
|
|
85
85
|
{ name: 'style', args: '[name] [--persist|--reset|--list]', gloss: 'Output-style preset (default / terse / explanatory / russian-formal / casual)', group: 'Settings' },
|
|
86
|
+
{ name: 'theme', args: '[name] [--persist|--reset|--list]', gloss: 'TUI color palette (default / dark / light / colorblind)', group: 'Settings' },
|
|
86
87
|
{ name: 'onboarding', args: '[--reset|--non-interactive]', gloss: 'First-run wizard — auth / mode / style / MCP / telemetry (leak L25)', group: 'Settings' },
|
|
88
|
+
{ name: 'vim', args: '[on|off|status]', gloss: 'Toggle vim-style modal editing in the input buffer (leak L26)', group: 'Settings' },
|
|
87
89
|
{ name: 'undo', args: '', gloss: 'Undo last write', group: 'Settings', stub: true },
|
|
88
90
|
// Meta
|
|
89
91
|
{ name: 'help', args: '', gloss: 'Show this help overlay', group: 'Meta' },
|
|
@@ -92,6 +94,8 @@ export const SLASH_COMMAND_HELP = Object.freeze([
|
|
|
92
94
|
{ name: 'stickers', args: '', gloss: 'show Pugi brand stickers (gimmick)', group: 'Meta' },
|
|
93
95
|
{ name: 'feedback', args: '', gloss: 'file a bug / feature / general comment without leaving the REPL', group: 'Meta' },
|
|
94
96
|
{ name: 'share', args: '[--gist|--pugi] [--redact] [--preview]', gloss: 'Export session transcript to gist / pugi.io (leak L20)', group: 'Meta' },
|
|
97
|
+
{ name: 'release-notes', args: '[--reset]', gloss: 'Show changelog diff since last upgrade (leak L24)', group: 'Meta' },
|
|
98
|
+
{ name: 'update', args: '[--check|--apply [--yes]] [--channel <name>]', gloss: 'Check for / apply CLI update on stable / beta / canary (leak L27)', group: 'Meta' },
|
|
95
99
|
{ name: 'quit', args: '', gloss: 'Exit the REPL', group: 'Meta' },
|
|
96
100
|
]);
|
|
97
101
|
/**
|
|
@@ -388,6 +392,17 @@ export function parseSlashCommand(input) {
|
|
|
388
392
|
const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
|
|
389
393
|
return { kind: 'style', args: tokens };
|
|
390
394
|
}
|
|
395
|
+
case 'theme':
|
|
396
|
+
case 'palette':
|
|
397
|
+
case 'colors': {
|
|
398
|
+
// Leak L30 (2026-05-27): forward the tokenized tail unchanged so
|
|
399
|
+
// the slash + top-level `pugi theme` surfaces share one parser
|
|
400
|
+
// inside `runThemeCommand`. Aliases `/palette` and `/colors`
|
|
401
|
+
// exist because the leak-landscape audit found operators reach
|
|
402
|
+
// for either word interchangeably — same surface, same handler.
|
|
403
|
+
const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
|
|
404
|
+
return { kind: 'theme', args: tokens };
|
|
405
|
+
}
|
|
391
406
|
case 'onboarding':
|
|
392
407
|
case 'onboard':
|
|
393
408
|
case 'setup': {
|
|
@@ -399,6 +414,14 @@ export function parseSlashCommand(input) {
|
|
|
399
414
|
const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
|
|
400
415
|
return { kind: 'onboarding', args: tokens };
|
|
401
416
|
}
|
|
417
|
+
case 'vim': {
|
|
418
|
+
// Leak L26 (2026-05-27): forward the tokenized tail unchanged so
|
|
419
|
+
// the slash + top-level CLI surfaces share one parser inside
|
|
420
|
+
// `runVimCommand`. Subcommands are single tokens (on / off /
|
|
421
|
+
// status); a bare `/vim` toggles.
|
|
422
|
+
const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
|
|
423
|
+
return { kind: 'vim', args: tokens };
|
|
424
|
+
}
|
|
402
425
|
case 'doctor':
|
|
403
426
|
case 'health': {
|
|
404
427
|
// L17 (2026-05-27): run the probe sweep inline. Tail is ignored —
|
|
@@ -439,6 +462,33 @@ export function parseSlashCommand(input) {
|
|
|
439
462
|
const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
|
|
440
463
|
return { kind: 'share', args: tokens };
|
|
441
464
|
}
|
|
465
|
+
case 'release-notes':
|
|
466
|
+
case 'releasenotes':
|
|
467
|
+
case 'changelog': {
|
|
468
|
+
// Leak L24 (2026-05-27): changelog diff between last-seen +
|
|
469
|
+
// installed CLI version. Tail args are tokenized so `--reset`
|
|
470
|
+
// can flip the marker-clear bit; no other flags are honoured —
|
|
471
|
+
// the surface mirrors the CLI top-level's intentional minimalism.
|
|
472
|
+
// `changelog` alias matches operator muscle memory from npm /
|
|
473
|
+
// cargo / brew, all of which ship `changelog` subcommands.
|
|
474
|
+
const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
|
|
475
|
+
const reset = tokens.includes('--reset') || tokens.includes('-r');
|
|
476
|
+
return { kind: 'release-notes', reset };
|
|
477
|
+
}
|
|
478
|
+
case 'update': {
|
|
479
|
+
// Leak L27 (2026-05-27): forward the tokenized argv to the
|
|
480
|
+
// session module which delegates to `runUpdateCommand`. The
|
|
481
|
+
// dispatcher owns argv validation (unknown channel / flag) so
|
|
482
|
+
// the slash parser stays as thin as the rest of the surface.
|
|
483
|
+
// The slash form does NOT support `--apply` because spawning
|
|
484
|
+
// `npm install -g` from inside a running REPL session would
|
|
485
|
+
// corrupt the operator's running binary — the dispatcher treats
|
|
486
|
+
// `--apply` from a slash as a non-interactive offer (probe +
|
|
487
|
+
// install command, no shell-out). Top-level `pugi update --apply`
|
|
488
|
+
// remains the recommended path for the actual install.
|
|
489
|
+
const tokens = tail.length === 0 ? [] : tail.split(/\s+/).filter((s) => s.length > 0);
|
|
490
|
+
return { kind: 'update', args: tokens };
|
|
491
|
+
}
|
|
442
492
|
case 'memory':
|
|
443
493
|
case 'config':
|
|
444
494
|
case 'budget':
|