@bolt-cli/cli 0.13.0 → 0.15.0
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/README.md +1 -1
- package/lib/agent.js +1 -1
- package/lib/cli.js +38 -50
- package/lib/permissions.js +1 -1
- package/lib/present.js +12 -11
- package/lib/tools.js +1 -1
- package/lib/ui.js +62 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -100,7 +100,7 @@ Press **Esc** during any run to stop it — the session is saved, no need to kil
|
|
|
100
100
|
|
|
101
101
|
Colors and glyphs follow your terminal: full color on a TTY, plain text on pipes and CI so logs and `--format json > file` stay parseable. Git Bash, Windows Terminal, and VS Code are detected even without a TTY. Override either way with `FORCE_COLOR=1|2|3` (force on) or `NO_COLOR=1` (force off).
|
|
102
102
|
|
|
103
|
-
## Interactive mode (
|
|
103
|
+
## Interactive mode (modern terminal)
|
|
104
104
|
|
|
105
105
|
```bash
|
|
106
106
|
bolt
|
package/lib/agent.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// The agent loop: multi-turn tool use in the style of
|
|
2
|
+
// The agent loop: multi-turn tool use in the style of modern agent CLIs.
|
|
3
3
|
//
|
|
4
4
|
// The Bolt backend is a text-in/text-out agent, so the loop is client-driven:
|
|
5
5
|
// the CLI describes the tool protocol in the prompt, parses ```tool blocks
|
package/lib/cli.js
CHANGED
|
@@ -49,7 +49,7 @@ Install: npm install -g @bolt-cli/cli Update: npm update -g @bolt-cli
|
|
|
49
49
|
Web: https://bolt.beerasafe.com Bugs: security@beerasafe.com
|
|
50
50
|
|
|
51
51
|
Usage:
|
|
52
|
-
bolt interactive agent (
|
|
52
|
+
bolt interactive agent (Bolt backend only)
|
|
53
53
|
bolt login | signin sign in through your browser
|
|
54
54
|
bolt auth status | logout session info, sign out this machine
|
|
55
55
|
bolt run "<prompt>" [options] single autonomous run
|
|
@@ -214,7 +214,7 @@ function finishSignin(url, data) {
|
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
/**
|
|
217
|
-
*
|
|
217
|
+
* Task-first entry: a missing token signs you in instead of stopping
|
|
218
218
|
* you. On an interactive terminal the browser flow starts automatically and
|
|
219
219
|
* the command continues once it completes; without a TTY (pipes, CI) there
|
|
220
220
|
* is nothing to open, so it stays an error telling you exactly what to run.
|
|
@@ -278,7 +278,7 @@ async function cmdSession(rest) {
|
|
|
278
278
|
const s = id ? session.load(id) : null;
|
|
279
279
|
if (!s) throw new Error("Usage: bolt session show <id>");
|
|
280
280
|
for (const [i, t] of s.turns.entries()) {
|
|
281
|
-
console.log(`\n--- turn ${i + 1} [${t.mode}] ${t.at} ---\
|
|
281
|
+
console.log(`\n--- turn ${i + 1} [${t.mode}] ${t.at} ---\n${ui.userTurn(t.prompt)}\nA: ${t.response.slice(0, 2000)}`);
|
|
282
282
|
if (t.tools && t.tools.length) {
|
|
283
283
|
console.log(`tools: ${t.tools.map((tool) => `${tool.tool}${tool.ok === false ? " (failed)" : ""}`).join(", ")}`);
|
|
284
284
|
}
|
|
@@ -681,7 +681,7 @@ function positionalPrompt(rest) {
|
|
|
681
681
|
.trim();
|
|
682
682
|
}
|
|
683
683
|
|
|
684
|
-
// Agents:
|
|
684
|
+
// Agents: modern terminal presets, explicit opt-in. Arming one wraps the next
|
|
685
685
|
// objective with its template client-side; unarmed runs stay verbatim.
|
|
686
686
|
const AGENTS = {
|
|
687
687
|
sweep: {
|
|
@@ -787,7 +787,7 @@ function readEvidence(rest) {
|
|
|
787
787
|
return parts.join("\n\n");
|
|
788
788
|
}
|
|
789
789
|
|
|
790
|
-
// Approval asker for tool calls,
|
|
790
|
+
// Approval asker for tool calls, modern agent CLI style: an arrow-key
|
|
791
791
|
// dropdown with Allow once / Always allow / Deny. Elevated commands (sudo,
|
|
792
792
|
// system installs, service control) render a shield card explaining why they
|
|
793
793
|
// need admin. A throwaway readline is used for the text fallback only (never
|
|
@@ -921,7 +921,10 @@ function handleToolEvent(event) {
|
|
|
921
921
|
} else {
|
|
922
922
|
toolStarted.set(toolTimingKey(event.call), Date.now());
|
|
923
923
|
const elevated = event.call && event.call.tool === "bash" ? permissions.isElevatedCommand(event.call.command) : false;
|
|
924
|
-
|
|
924
|
+
// Transcript-style tool row: a quiet mark plus the call, the way a
|
|
925
|
+
// full-screen agent renders activity. The elevated warning keeps its
|
|
926
|
+
// colour so the one thing that must be seen, is.
|
|
927
|
+
ui.status(`${ui.toolLine(tools.describeCall(event.call))}${elevated ? ` ${ui.c.warning("[elevated]")}` : ""}`);
|
|
925
928
|
}
|
|
926
929
|
return;
|
|
927
930
|
}
|
|
@@ -931,13 +934,15 @@ function handleToolEvent(event) {
|
|
|
931
934
|
if (event.call.tool === "(parse error)") {
|
|
932
935
|
ui.warn(`tool request ignored: ${r.summary || "bad block"}`);
|
|
933
936
|
} else {
|
|
934
|
-
|
|
937
|
+
// Result rows mirror the call row; failure keeps an error tone so a scan
|
|
938
|
+
// down the transcript still catches it.
|
|
939
|
+
ui.status(ui.toolLine(r.ok ? "ok" : "FAILED", r.summary || "", { ok: r.ok, duration: took || undefined }));
|
|
935
940
|
}
|
|
936
941
|
}
|
|
937
942
|
}
|
|
938
943
|
|
|
939
944
|
// Start timestamps for approved tool calls, so the result row can carry an
|
|
940
|
-
//
|
|
945
|
+
// modern terminal elapsed time. Keyed by the rendered call description; a
|
|
941
946
|
// repeated call re-arms the timer, which is the honest behaviour for a map
|
|
942
947
|
// (the newest start wins). Unmatched results simply show no duration.
|
|
943
948
|
const toolStarted = new Map();
|
|
@@ -961,8 +966,7 @@ function takeToolElapsed(call) {
|
|
|
961
966
|
if (!key || !toolStarted.has(key)) return "";
|
|
962
967
|
const ms = Date.now() - toolStarted.get(key);
|
|
963
968
|
toolStarted.delete(key);
|
|
964
|
-
|
|
965
|
-
return text ? ` ${ui.c.muted(`· ${text}`)}` : "";
|
|
969
|
+
return formatElapsed(ms);
|
|
966
970
|
}
|
|
967
971
|
|
|
968
972
|
function copyToClipboard(text) {
|
|
@@ -1554,7 +1558,7 @@ function resolvePalettePick(raw, items) {
|
|
|
1554
1558
|
return { action: "filter", text: text.replace(/^\//, "") };
|
|
1555
1559
|
}
|
|
1556
1560
|
|
|
1557
|
-
// Grouped help box,
|
|
1561
|
+
// Grouped help box, `?`-overlay style: four small menus with stable
|
|
1558
1562
|
// numbers so the picker flow keeps working - the operator answers with a
|
|
1559
1563
|
// number exactly like the flat list. Returns the flat row list for
|
|
1560
1564
|
// pendingPalette. Pure rows in, console lines out.
|
|
@@ -1614,35 +1618,23 @@ function pickTip(n) {
|
|
|
1614
1618
|
return TIPS[((Number(n) || 0) % TIPS.length + TIPS.length) % TIPS.length];
|
|
1615
1619
|
}
|
|
1616
1620
|
|
|
1617
|
-
//
|
|
1618
|
-
//
|
|
1619
|
-
//
|
|
1620
|
-
|
|
1621
|
+
// REPL home surface: half-block wordmark, identity/session chrome, and one
|
|
1622
|
+
// mechanics line. The wordmark is the only decoration; everything else stays
|
|
1623
|
+
// muted so the prompt below remains the focus. Pure (ui.c degrades on a pipe),
|
|
1624
|
+
// tested for the hint phrases the docs promise.
|
|
1625
|
+
function replWelcomeLines({ sid, version, host, cwd, update }) {
|
|
1626
|
+
const identity = [version ? `v${version}` : "", host, cwd].filter(Boolean);
|
|
1621
1627
|
const lines = [
|
|
1622
|
-
|
|
1623
|
-
|
|
1628
|
+
...ui.wordmark(" "),
|
|
1629
|
+
"",
|
|
1630
|
+
` ${ui.c.muted(identity.join(` ${ui.GLYPH.dot} `))}`,
|
|
1631
|
+
` ${ui.c.muted(`session ${sid.slice(0, 8)} ${ui.GLYPH.dot} type a task and press enter`)}`,
|
|
1632
|
+
"",
|
|
1633
|
+
` ${ui.c.primary("/")} ${ui.c.muted("opens the command dropdown")} ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.primary("Tab fills")} ${ui.c.muted("and keeps your place")} ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.primary("@path")} ${ui.c.muted("attaches a file")}`,
|
|
1624
1634
|
];
|
|
1625
|
-
if (host || cwd) {
|
|
1626
|
-
const where = [];
|
|
1627
|
-
if (host) where.push(`${ui.c.muted("backend")} ${host}`);
|
|
1628
|
-
if (cwd) where.push(`${ui.c.muted("cwd")} ${cwd}`);
|
|
1629
|
-
lines.push(where.join(` ${ui.c.muted(ui.GLYPH.dot)} `));
|
|
1630
|
-
}
|
|
1631
1635
|
if (update) {
|
|
1632
|
-
lines.push("",
|
|
1636
|
+
lines.push("", ` ${ui.c.warning("update")} ${update}`);
|
|
1633
1637
|
}
|
|
1634
|
-
lines.push(
|
|
1635
|
-
"",
|
|
1636
|
-
ui.bullets([
|
|
1637
|
-
"type a task and press enter to run it",
|
|
1638
|
-
`${ui.c.bold("/")} opens the command dropdown ${ui.c.muted(ui.GLYPH.dot)} type to filter, up/down to pick, ${ui.c.bold("Tab")} fills and keeps your place`,
|
|
1639
|
-
`${ui.c.bold("Tab")} completes commands and their arguments ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.bold("@path")} attaches a file ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.bold("/help <cmd>")} detail`,
|
|
1640
|
-
`${ui.c.bold("/status")} dashboard ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.bold("/sessions")} resume ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.bold("?")} help ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.bold("/keys")} shortcuts ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.bold("/help <cmd>")} detail`,
|
|
1641
|
-
`${ui.c.bold("/agents")} presets ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.bold("/target")} scope ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.bold("/init")} map repo ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.bold("/mode")} offensive or defensive`,
|
|
1642
|
-
`${ui.c.bold("/doctor")} health ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.bold("/export")} file ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.bold("/undo")} restore ${ui.c.muted(ui.GLYPH.dot)} ${ui.c.bold("/exit")} save and quit`,
|
|
1643
|
-
]),
|
|
1644
|
-
);
|
|
1645
|
-
if (tip) lines.push("", `${ui.c.muted("tip")} ${tip}`);
|
|
1646
1638
|
return lines;
|
|
1647
1639
|
}
|
|
1648
1640
|
|
|
@@ -1682,7 +1674,7 @@ function completeFileFrag(frag) {
|
|
|
1682
1674
|
|
|
1683
1675
|
function completer(line) {
|
|
1684
1676
|
// Tab-completes slash commands, their arguments, and agent names,
|
|
1685
|
-
//
|
|
1677
|
+
// modern terminal. @-mentions and /file complete filesystem paths,
|
|
1686
1678
|
// Claude Code style. /resume and /session complete saved session ids.
|
|
1687
1679
|
const atMatch = line.match(/@([^\s@]*)$/);
|
|
1688
1680
|
if (atMatch && !line.startsWith("/")) {
|
|
@@ -1827,7 +1819,7 @@ async function cmdRepl() {
|
|
|
1827
1819
|
let allowAll = false;
|
|
1828
1820
|
const sessionAllowed = new Set();
|
|
1829
1821
|
// Persistent always-allow store: "Always allow" survives restarts via
|
|
1830
|
-
// ~/.bolt/permissions.json (
|
|
1822
|
+
// ~/.bolt/permissions.json (modern agent CLI style).
|
|
1831
1823
|
const alwaysStore = permissions.load();
|
|
1832
1824
|
const persistAlways = (call) => {
|
|
1833
1825
|
const next = permissions.allowAlways(permissions.load(), call);
|
|
@@ -1855,23 +1847,19 @@ async function cmdRepl() {
|
|
|
1855
1847
|
const setPrompt = () => rl.setPrompt(present.promptLine(state()));
|
|
1856
1848
|
|
|
1857
1849
|
console.log("");
|
|
1858
|
-
|
|
1850
|
+
// Quiet polished welcome: two header lines, not a logo wall in a box.
|
|
1859
1851
|
// Update notice comes from the cache first (instant, no network); a stale
|
|
1860
1852
|
// cache is refreshed in the background for the next session, and a newly
|
|
1861
1853
|
// discovered update prints one line mid-session.
|
|
1862
1854
|
const cachedUpdate = updatecheck.cachedNotice(VERSION);
|
|
1863
1855
|
console.log(
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
tip: pickTip(Math.floor(Date.now() / 86400000)),
|
|
1872
|
-
update: cachedUpdate || undefined,
|
|
1873
|
-
}),
|
|
1874
|
-
}),
|
|
1856
|
+
replWelcomeLines({
|
|
1857
|
+
sid: sess.id,
|
|
1858
|
+
version: VERSION,
|
|
1859
|
+
host: backendHost(cfg.url),
|
|
1860
|
+
cwd: process.cwd(),
|
|
1861
|
+
update: cachedUpdate || undefined,
|
|
1862
|
+
}).join("\n"),
|
|
1875
1863
|
);
|
|
1876
1864
|
console.log("");
|
|
1877
1865
|
void updatecheck
|
package/lib/permissions.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Persistent permission store for the bolt agent loop.
|
|
3
3
|
//
|
|
4
|
-
//
|
|
4
|
+
// Modern agent CLIs remember "allow always" decisions across sessions.
|
|
5
5
|
// Session-only approvals live in memory (a Set passed around the loop); this
|
|
6
6
|
// module persists the "always" tier to ~/.bolt/permissions.json so a tool the
|
|
7
7
|
// operator trusts never asks again. File mode 600, same as the auth token.
|
package/lib/present.js
CHANGED
|
@@ -67,18 +67,19 @@ function turnFooter({ done, elapsed, turns }) {
|
|
|
67
67
|
return ui.isTTY() ? `${ui.c.border(ui.GLYPH.rule.repeat(6))} ${joined}` : joined;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
// The prompt doubles as the status line, the way
|
|
70
|
+
// The prompt doubles as the status line, the way quiet terminals keep state visible:
|
|
71
71
|
// mode, target, armed agent and attachment count all live here so you never
|
|
72
|
-
// have to remember what you set.
|
|
73
|
-
|
|
72
|
+
// have to remember what you set. One quiet caret leads, mode carries the only
|
|
73
|
+
// emphasis, everything else is muted; the session id lives in /status and the
|
|
74
|
+
// welcome line, not on every keystroke.
|
|
75
|
+
function promptLine({ mode, target, agent, files, balance, tools }) {
|
|
74
76
|
const bits = [ui.c.primary(ui.c.bold(mode))];
|
|
75
|
-
if (target) bits.push(ui.c.
|
|
76
|
-
if (agent) bits.push(
|
|
77
|
+
if (target) bits.push(ui.c.muted(target));
|
|
78
|
+
if (agent) bits.push(ui.c.muted(`agent ${agent}`));
|
|
77
79
|
if (files) bits.push(ui.c.muted(`${files} file${files === 1 ? "" : "s"}`));
|
|
78
|
-
if (tools !== undefined) bits.push(
|
|
80
|
+
if (tools !== undefined) bits.push(ui.c.muted(tools ? "tools" : "no-tools"));
|
|
79
81
|
if (balance !== undefined && balance !== null) bits.push(ui.c.muted(`${balance} tok`));
|
|
80
|
-
bits.
|
|
81
|
-
return `${ui.c.primary(ui.GLYPH.bar)} ${bits.join(ui.c.muted(` ${ui.GLYPH.dot} `))} ${ui.c.primary(ui.GLYPH.caret)} `;
|
|
82
|
+
return `${ui.c.primary(">")} ${bits.join(ui.c.muted(` ${ui.GLYPH.dot} `))} `;
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
// Palette rows for `select()`; label is what gets typed back into the prompt.
|
|
@@ -109,7 +110,7 @@ function filterPalette(query, commands, agents) {
|
|
|
109
110
|
return all.filter((it) => `${it.label} ${it.hint || ""}`.toLowerCase().includes(q));
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
// Grouped help,
|
|
113
|
+
// Grouped help, `?`-overlay style: commands read as four small
|
|
113
114
|
// menus (run, session, safety, system) instead of one flat list. Pure:
|
|
114
115
|
// group membership is by command base, rows keep their COMMANDS text.
|
|
115
116
|
const HELP_GROUPS = [
|
|
@@ -142,7 +143,7 @@ function helpDetail(query, commands) {
|
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
// Status dashboard rows for the `/status` box: everything about the live
|
|
145
|
-
// session in one glance,
|
|
146
|
+
// session in one glance, status-dialog style. All fields optional;
|
|
146
147
|
// missing values read as "(none)" or are skipped. Pure.
|
|
147
148
|
function statusLines({ sid, mode, target, agent, files, tools, balance, turns, memChars, cwd, backend } = {}) {
|
|
148
149
|
const rows = [];
|
|
@@ -164,7 +165,7 @@ function statusLines({ sid, mode, target, agent, files, tools, balance, turns, m
|
|
|
164
165
|
return rows;
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
// Session picker rows for `/sessions`,
|
|
168
|
+
// Session picker rows for `/sessions`, session-list style: newest
|
|
168
169
|
// first, title plus turn count plus relative age in the hint, and the live
|
|
169
170
|
// session flagged so resuming it is never a surprise. Pure.
|
|
170
171
|
function sessionRows(sessions, currentId) {
|
package/lib/tools.js
CHANGED
package/lib/ui.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Terminal presentation layer. Zero deps: hand-rolled ANSI only.
|
|
3
3
|
//
|
|
4
|
-
// Scope note: this is deliberately *not* a full-screen TUI.
|
|
5
|
-
//
|
|
6
|
-
// free so `npm i -g @bolt-cli/cli` is
|
|
7
|
-
// vocabulary and feel -- semantic colour
|
|
8
|
-
//
|
|
9
|
-
// command palette, and quiet
|
|
4
|
+
// Scope note: this is deliberately *not* a full-screen TUI. Full-screen
|
|
5
|
+
// terminal interfaces ship native binaries and tens of megabytes of
|
|
6
|
+
// dependencies; bolt stays dependency free so `npm i -g @bolt-cli/cli` is
|
|
7
|
+
// instant. What we reproduce is the vocabulary and feel -- semantic colour
|
|
8
|
+
// tokens with the names polished terminal UIs use, a status-carrying prompt,
|
|
9
|
+
// a thinking indicator, an arrow-key command palette, and quiet prose.
|
|
10
10
|
//
|
|
11
11
|
// Every helper degrades to plain text when stdout is not a TTY, when NO_COLOR
|
|
12
12
|
// is set, or when the terminal only supports 16 colours, so piped output and CI
|
|
@@ -168,21 +168,34 @@ function width() {
|
|
|
168
168
|
return typeof columns === "number" && columns > 20 ? Math.min(columns, 100) : 78;
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
//
|
|
172
|
-
//
|
|
173
|
-
//
|
|
174
|
-
//
|
|
175
|
-
// holds. Pure, tested.
|
|
171
|
+
// Half-block wordmark in the register used by full-screen agent terminals:
|
|
172
|
+
// solid upper blocks, a dim baseline, `_` holes and a `~` shadow. One cell per
|
|
173
|
+
// glyph so visible-length maths holds; `_` is a blank cell, never a literal
|
|
174
|
+
// underscore. Colour degrades to identity on a pipe. Pure, width-tested.
|
|
176
175
|
const LOGO_RAW = [
|
|
177
|
-
"
|
|
178
|
-
"
|
|
179
|
-
"
|
|
180
|
-
"
|
|
181
|
-
"██████╔╝ ██║ ██║ ██║ █",
|
|
182
|
-
"╚═════╝ ╚════╝ ██║▄▄▄▄",
|
|
176
|
+
" ",
|
|
177
|
+
"█▀▀▄ █▀▀█ █___ █▀▀▀",
|
|
178
|
+
"█▄▄▀ █__█ █___ _█__",
|
|
179
|
+
"▀~~▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀",
|
|
183
180
|
];
|
|
184
|
-
|
|
185
|
-
|
|
181
|
+
function wordmark(pad = "") {
|
|
182
|
+
if (!U) return [`${pad}bolt`];
|
|
183
|
+
return LOGO_RAW.map((line, i) => {
|
|
184
|
+
const baseline = i === LOGO_RAW.length - 1;
|
|
185
|
+
return (
|
|
186
|
+
pad +
|
|
187
|
+
[...line]
|
|
188
|
+
.map((ch) => {
|
|
189
|
+
if (ch === "_" || ch === " ") return " ";
|
|
190
|
+
if (ch === "~") return c.border("▀");
|
|
191
|
+
if (ch === "▀" && baseline) return c.muted(ch);
|
|
192
|
+
return c.primary(ch);
|
|
193
|
+
})
|
|
194
|
+
.join("")
|
|
195
|
+
);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
const LOGO = wordmark();
|
|
186
199
|
|
|
187
200
|
// Relative timestamps for pickers and dashboards ("5m ago"). Pure, tested:
|
|
188
201
|
// `now` injects the clock, unparseable input yields "".
|
|
@@ -248,7 +261,7 @@ function rule(w = width()) {
|
|
|
248
261
|
return c.border(GLYPH.rule.repeat(Math.max(8, w)));
|
|
249
262
|
}
|
|
250
263
|
|
|
251
|
-
function box({ title = "", lines = [], w = width(), tone = "
|
|
264
|
+
function box({ title = "", lines = [], w = width(), tone = "border" }) {
|
|
252
265
|
const paint = c[tone] || c.primary;
|
|
253
266
|
const inner = w - 4;
|
|
254
267
|
const head = title ? ` ${c.bold(title)} ` : "";
|
|
@@ -270,10 +283,33 @@ function bullets(rows, { marker = GLYPH.dot } = {}) {
|
|
|
270
283
|
return rows.map((r) => ` ${c.muted(marker)} ${r}`).join("\n");
|
|
271
284
|
}
|
|
272
285
|
|
|
286
|
+
// Transcript shapes shared by the REPL and the tool-event renderer. A user
|
|
287
|
+
// turn gets a bright `>` marker and default-foreground text; tool activity gets
|
|
288
|
+
// a compact indented row with a semantic mark. Both are pure strings, so a
|
|
289
|
+
// piped log keeps the same readable shape without ANSI.
|
|
290
|
+
function userTurn(text) {
|
|
291
|
+
return String(text ?? "")
|
|
292
|
+
.split("\n")
|
|
293
|
+
.map((line, i) => (i === 0 ? `${c.primary(">")} ${c.bold(line)}` : ` ${line}`))
|
|
294
|
+
.join("\n");
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function toolLine(name, detail, { ok: state, duration } = {}) {
|
|
298
|
+
const mark = state === undefined ? c.info(GLYPH.dot) : state ? c.success(GLYPH.tick) : c.error(GLYPH.cross);
|
|
299
|
+
const label = state === undefined ? c.primary(name) : state ? c.success(name) : c.error(name);
|
|
300
|
+
const bits = [label];
|
|
301
|
+
if (detail) bits.push(c.muted(String(detail)));
|
|
302
|
+
if (duration) bits.push(c.border(String(duration)));
|
|
303
|
+
return ` ${mark} ${bits.join(` ${c.muted(GLYPH.dot)} `)}`;
|
|
304
|
+
}
|
|
305
|
+
|
|
273
306
|
// ---------------------------------------------------------------- status
|
|
274
307
|
|
|
308
|
+
// Quiet progress line for tool activity: reference terminals render tool traffic as
|
|
309
|
+
// plain dim text, not branded announcements, so no wordmark here either.
|
|
310
|
+
// Callers pass pre-styled text.
|
|
275
311
|
function status(text) {
|
|
276
|
-
errWrite(`${
|
|
312
|
+
errWrite(`${text}\n`);
|
|
277
313
|
}
|
|
278
314
|
|
|
279
315
|
function ok(text) {
|
|
@@ -454,7 +490,7 @@ function selectable(items) {
|
|
|
454
490
|
}
|
|
455
491
|
|
|
456
492
|
// Scroll window for a picker whose rows outnumber `max`: the selected row
|
|
457
|
-
// stays visible by sliding the viewport,
|
|
493
|
+
// stays visible by sliding the viewport, selection-menu style. Pure, tested:
|
|
458
494
|
// returns the [start, end) slice bounds to display. When everything fits the
|
|
459
495
|
// whole list shows; a non-positive max degrades to the whole list too.
|
|
460
496
|
function pickWindow(index, total, max) {
|
|
@@ -697,7 +733,7 @@ function selectLive({ title = "", items = [], max = 12, initialFilter = "", filt
|
|
|
697
733
|
|
|
698
734
|
// ---------------------------------------------------------------- approvals
|
|
699
735
|
|
|
700
|
-
// Permission options for a tool approval,
|
|
736
|
+
// Permission options for a tool approval, modern agent CLI style.
|
|
701
737
|
// Elevated commands (sudo, system installs) get the shield treatment and no
|
|
702
738
|
// silent path; installers only offer once/deny (never always).
|
|
703
739
|
function permissionItems({ elevated = false, install = false } = {}) {
|
|
@@ -745,6 +781,9 @@ module.exports = {
|
|
|
745
781
|
ESC,
|
|
746
782
|
GLYPH,
|
|
747
783
|
LOGO,
|
|
784
|
+
wordmark,
|
|
785
|
+
userTurn,
|
|
786
|
+
toolLine,
|
|
748
787
|
PALETTE,
|
|
749
788
|
c,
|
|
750
789
|
enabled: c.enabled,
|
package/package.json
CHANGED