@hncode/hncode 0.8.2 → 0.8.3
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/bin/hncode +54 -8
- package/package.json +1 -1
- package/src/agent-task.js +14 -12
- package/src/agent.js +1465 -1421
- package/src/animate.js +21 -0
- package/src/colors.js +615 -593
- package/src/config.js +36 -11
- package/src/context-bar.js +280 -278
- package/src/doctor.js +4 -3
- package/src/i18n.js +1432 -1214
- package/src/index.js +822 -730
- package/src/keybindings.js +2 -1
- package/src/markdown.js +37 -10
- package/src/mcp-server.js +409 -0
- package/src/mcp.js +279 -29
- package/src/memory-profile.js +19 -16
- package/src/plan.js +7 -5
- package/src/plugin.js +37 -21
- package/src/registry-browser.js +17 -15
- package/src/rows-tool-result.js +242 -235
- package/src/settings-schema.js +9 -0
- package/src/swarm-progress.js +1 -1
- package/src/tasks-browser.js +28 -28
- package/src/term.js +57 -21
- package/src/text.js +62 -0
- package/src/tools/agent.js +7 -2
- package/src/tools/bash.js +446 -440
- package/src/tools/edit.js +14 -1
- package/src/tui.js +527 -328
package/src/tui.js
CHANGED
|
@@ -39,7 +39,7 @@ const {
|
|
|
39
39
|
reducedMotionOn, spinnerFrame, sweepSettle, sweepPulse,
|
|
40
40
|
LIGHT_FRACTION, SPIN_TICK_MS, lightWidth, TAIL_CHARS, ANIM_FPS, FRAME_MS,
|
|
41
41
|
STEP_MS, TOOL_STEP_MS, ENTRY_EXIT_CHARS, lightMargin, crossMs, REST_MS, cycleMs,
|
|
42
|
-
lightOrigin, lightAt, shimmerText, STEP_CHARS, SWEEP_TICKS, SWEEP_TRAVEL_PAD, bandCharsFor, framesPerChar,
|
|
42
|
+
lightOrigin, lightAt, shimmerText, glintFor, STEP_CHARS, SWEEP_TICKS, SWEEP_TRAVEL_PAD, bandCharsFor, framesPerChar,
|
|
43
43
|
breatheColour,
|
|
44
44
|
} = anim;
|
|
45
45
|
const {
|
|
@@ -81,7 +81,7 @@ import * as md from './markdown.js';
|
|
|
81
81
|
const {
|
|
82
82
|
MD_RENDER_VERSION, renderMdIncremental, splitBlocks, renderMdText, renderTable,
|
|
83
83
|
markdownLineToRows, mathImageCapable, MATH_INK, mathCellHeight, mathBlockRows,
|
|
84
|
-
stripMathDelimiters, placeTex, looksLikeInlineMath, inlineMarkdown,
|
|
84
|
+
stripMathDelimiters, placeTex, looksLikeInlineMath, inlineMarkdown, onMermaidReady,
|
|
85
85
|
} = md;
|
|
86
86
|
|
|
87
87
|
export {
|
|
@@ -162,7 +162,7 @@ import { buildTree, visibleRows, allDirs, renderTree, moveSel } from './file-tre
|
|
|
162
162
|
import { walkFiles } from './tools/ignore.js';
|
|
163
163
|
|
|
164
164
|
|
|
165
|
-
import { Agent, SYSTEM_PROMPT, addUsage } from './agent.js';
|
|
165
|
+
import { Agent, SYSTEM_PROMPT, THINKING_TAGS_INSTRUCTION, needsThinkingTags, addUsage } from './agent.js';
|
|
166
166
|
import { LLM } from './llm.js';
|
|
167
167
|
import * as sess from './session.js';
|
|
168
168
|
import { convRowFor } from './session.js';
|
|
@@ -243,7 +243,6 @@ import { reviewLines, savePlan, filesReferenced, planStats, listPlans, plansDir
|
|
|
243
243
|
import { loadMcpConfig, describeServers, getLiveConnections } from './mcp.js';
|
|
244
244
|
import { killLspClientsSync } from './tools/diagnostics.js';
|
|
245
245
|
import { startControlServer } from './ci.js';
|
|
246
|
-
import { attachToDaemon } from './web-daemon-client.js';
|
|
247
246
|
|
|
248
247
|
const VERSION = localVersion();
|
|
249
248
|
|
|
@@ -330,7 +329,10 @@ export function getUiLang() { return i18nGetUiLang(); }
|
|
|
330
329
|
*/
|
|
331
330
|
export function tr(key, fallback, vars) {
|
|
332
331
|
const s = tOr(uiLang, key, fallback);
|
|
333
|
-
|
|
332
|
+
// The placeholders are filled in WHICHEVER string came back — the translation or the
|
|
333
|
+
// English fallback. Skipping the fallback left `[{n} task(s) running]` in the status
|
|
334
|
+
// line instead of `[{n}]` with the count in it, because the fallback WAS the template.
|
|
335
|
+
if (!vars) return s;
|
|
334
336
|
let out = s;
|
|
335
337
|
for (const k of Object.keys(vars)) out = out.split('{' + k + '}').join(String(vars[k]));
|
|
336
338
|
return out;
|
|
@@ -1528,8 +1530,15 @@ function messageLines(msg, width, workspace, expanded, spin, pulseStart, rawMode
|
|
|
1528
1530
|
// right edge in the one column the scrollbar does not own.
|
|
1529
1531
|
// The same `↳ ` the finished result puts on its first row, so the block does not shift right when the
|
|
1530
1532
|
// command completes. Continuation rows indent by two spaces, matching the result block.
|
|
1533
|
+
//
|
|
1534
|
+
// THE MARKER CARRIES THE STRUCTURAL COLOUR HERE TOO. A raw row is emitted as it is, so a bare `'↳ '`
|
|
1535
|
+
// took the terminal's DEFAULT foreground — dark on a dark page, which made a running command's arrow
|
|
1536
|
+
// the one unreadable thing on the screen while the finished result's arrow (rows-tool-result.js, which
|
|
1537
|
+
// does use `C.marker`) was bright. Same glyph, two colours, depending on whether the command had
|
|
1538
|
+
// finished.
|
|
1539
|
+
const marker = firstLive ? C.marker + '↳ ' + C.reset : ' ';
|
|
1531
1540
|
const rowW = bodyW;
|
|
1532
|
-
out.push({ text: C.termBg + fitAnsi(surfaced, rowW) + C.bgReset, ind:
|
|
1541
|
+
out.push({ text: C.termBg + fitAnsi(surfaced, rowW) + C.bgReset, ind: marker, raw: true });
|
|
1533
1542
|
}
|
|
1534
1543
|
}
|
|
1535
1544
|
}
|
|
@@ -1541,9 +1550,15 @@ function messageLines(msg, width, workspace, expanded, spin, pulseStart, rawMode
|
|
|
1541
1550
|
// the OS exposes no portable "blocked in read". A line that is true either way — this key sends what you
|
|
1542
1551
|
// type to the command — is the honest form, and grey keeps it a footnote rather than a warning.
|
|
1543
1552
|
if (msg.pending && msg.toolName === 'Bash') {
|
|
1544
|
-
|
|
1553
|
+
// ON THE PAGE, NOT ON THE TERMINAL SURFACE.
|
|
1554
|
+
//
|
|
1555
|
+
// This sat inside `C.termBg` — the darkest recess, reserved for the command's own
|
|
1556
|
+
// OUTPUT so it reads as "a terminal ran this". A hint is not output: on that surface
|
|
1557
|
+
// a grey sentence on a near-black block reads as part of the command's result rather
|
|
1558
|
+
// than as a note about a key. Every other hint on this row (Ctrl+B, below) sits on
|
|
1559
|
+
// the page background, and this one now matches.
|
|
1545
1560
|
out.push({
|
|
1546
|
-
text:
|
|
1561
|
+
text: col(uiText('Ctrl+G: send a line to this command'), C.gray),
|
|
1547
1562
|
ind: ' ', raw: true,
|
|
1548
1563
|
});
|
|
1549
1564
|
}
|
|
@@ -1557,7 +1572,9 @@ function messageLines(msg, width, workspace, expanded, spin, pulseStart, rawMode
|
|
|
1557
1572
|
const waited = Date.now() - msg.startAt;
|
|
1558
1573
|
const delay = name === 'Bash' ? DETACH_HINT_DELAY_MS : 0;
|
|
1559
1574
|
if (waited >= delay) {
|
|
1560
|
-
|
|
1575
|
+
// Translated at RENDER time, not at definition: the constant is module level and
|
|
1576
|
+
// `uiText` reads whichever language is active when the row is drawn.
|
|
1577
|
+
out.push({ text: col(uiText(DETACH_HINT_TEXT), C.gray), ind: indent, raw: true });
|
|
1561
1578
|
}
|
|
1562
1579
|
}
|
|
1563
1580
|
|
|
@@ -1599,21 +1616,30 @@ function messageLines(msg, width, workspace, expanded, spin, pulseStart, rawMode
|
|
|
1599
1616
|
// The comment state travels between the rows, so a block comment that opens on one line and closes on
|
|
1600
1617
|
// the next stays grey all the way down.
|
|
1601
1618
|
let writeInComment = false;
|
|
1619
|
+
// THE MARKER AND THE INDENT ARE PADDED TO ONE WIDTH.
|
|
1620
|
+
//
|
|
1621
|
+
// `↳` is East Asian Ambiguous: one column on an English terminal, two on a Chinese
|
|
1622
|
+
// one. A fixed `'↳ '` beside a fixed `' '` therefore disagreed by a column on a CJK
|
|
1623
|
+
// machine, and every continuation row started a column early — a ragged gutter that
|
|
1624
|
+
// only showed up there. Both are built from the marker's own measured width instead,
|
|
1625
|
+
// so the block is square wherever it is drawn.
|
|
1626
|
+
const markerRaw = '↳ ';
|
|
1627
|
+
const contRaw = ' '.repeat(Math.max(1, visualCol(markerRaw)));
|
|
1602
1628
|
lines.slice(0, MAX).forEach((ln, i) => {
|
|
1603
1629
|
const num = String(i + 1).padStart(wNum);
|
|
1604
1630
|
// A LINE LONGER THAN THE PANEL IS CUT, not wrapped. `raw: true` means the renderer does not wrap it for us,
|
|
1605
1631
|
// and letting it through at full width made the terminal wrap it itself — which pushes every later row down
|
|
1606
1632
|
// by one and desynchronises the frame, so the screen scrolled while the file was still arriving.
|
|
1607
|
-
const room = Math.max(1, width - visualCol(
|
|
1633
|
+
const room = Math.max(1, width - visualCol(contRaw) - num.length - 1);
|
|
1608
1634
|
// The whole preview sits on the CODE SURFACE, number included, so the block reads as one recessed field.
|
|
1609
1635
|
if (!writeLang) {
|
|
1610
|
-
out.push({ text: C.codeBg + col(`${num} ${fitAnsi(ln, room)}`.replace(/\x1b\[0m/g, `\x1b[0m${C.codeBg}`), C.white) + C.bgReset, ind: i === 0 ?
|
|
1636
|
+
out.push({ text: C.codeBg + col(`${num} ${fitAnsi(ln, room)}`.replace(/\x1b\[0m/g, `\x1b[0m${C.codeBg}`), C.white) + C.bgReset, ind: i === 0 ? markerRaw : contRaw, raw: true });
|
|
1611
1637
|
return;
|
|
1612
1638
|
}
|
|
1613
1639
|
const painted = paintCode(ln, writeLang, '', writeInComment);
|
|
1614
1640
|
writeInComment = painted.inComment;
|
|
1615
1641
|
const writeRow = (col(num + ' ', C.white) + fitAnsi(painted.text, room)).replace(/\x1b\[0m/g, `\x1b[0m${C.codeBg}`);
|
|
1616
|
-
out.push({ text: C.codeBg + writeRow + C.bgReset, ind: i === 0 ?
|
|
1642
|
+
out.push({ text: C.codeBg + writeRow + C.bgReset, ind: i === 0 ? markerRaw : contRaw, raw: true });
|
|
1617
1643
|
});
|
|
1618
1644
|
const shown = Math.min(lines.length, MAX);
|
|
1619
1645
|
if (totalLines > shown) out.push({ text: col(uiText(`… ${totalLines - shown} more lines, ctrl+o to expand`), C.gray), ind: indent, raw: true });
|
|
@@ -1697,7 +1723,7 @@ function messageLines(msg, width, workspace, expanded, spin, pulseStart, rawMode
|
|
|
1697
1723
|
// The args line is omitted when there are none. `msg.text` is only the NAME and
|
|
1698
1724
|
// `msg.args` the trailing text, so the body is built here rather than wrapped.
|
|
1699
1725
|
if (msg.role === 'skill') {
|
|
1700
|
-
lines.push({ text: prefix + 'Activated skill: ' + C.bold + String(msg.text || ''), ind: '', color: C.blue });
|
|
1726
|
+
lines.push({ text: prefix + uiText('Activated skill: ') + C.bold + String(msg.text || ''), ind: '', color: C.blue });
|
|
1701
1727
|
const args = String(msg.args || '').trim();
|
|
1702
1728
|
if (args) {
|
|
1703
1729
|
const w = Math.max(1, width - 2);
|
|
@@ -2238,6 +2264,15 @@ export function renderChatLines(state, w, viewport) {
|
|
|
2238
2264
|
&& cached.diffRef === m.diff && cached.countsRef === m._diffCounts
|
|
2239
2265
|
&& cached.keyArgs === (m.toolArgs ? fpArgs(m.toolArgs) : '0')
|
|
2240
2266
|
&& cached.spinKey === spinKeyNow
|
|
2267
|
+
// THE GUTTER WIDTH COMES FROM THE LINE COUNT, so the count is part of the layout key.
|
|
2268
|
+
//
|
|
2269
|
+
// A streaming Write preview numbers its rows against the TOTAL line count, which is
|
|
2270
|
+
// what keeps `1` and `10` starting their text in the same column. When the count
|
|
2271
|
+
// crossed a digit (9 -> 10) the text and the content were unchanged, so the cache
|
|
2272
|
+
// still looked valid and the previous frame's rows were reused — the numbers kept
|
|
2273
|
+
// their old width and the stale glyphs stayed on screen, one column short of the
|
|
2274
|
+
// rows now being drawn under them.
|
|
2275
|
+
&& cached.streamLines === (m._streamLineCount || 0)
|
|
2241
2276
|
// The collapsible plugin log renders from `m.expanded` + `m.allLines`, which
|
|
2242
2277
|
// the cache key must include: otherwise Ctrl+L only flipped the flag and the
|
|
2243
2278
|
// cached (collapsed) rows were reused, so nothing visibly changed.
|
|
@@ -2348,6 +2383,9 @@ export function renderChatLines(state, w, viewport) {
|
|
|
2348
2383
|
keyArgs: m.toolArgs ? fpArgs(m.toolArgs) : '0',
|
|
2349
2384
|
pluginExpanded: m.pluginLog ? !!m.expanded : null,
|
|
2350
2385
|
raw: !!state.rawMode,
|
|
2386
|
+
// The gutter width of a streaming preview follows the total line count, so the
|
|
2387
|
+
// count belongs to the layout key — see the `valid` test above.
|
|
2388
|
+
streamLines: m._streamLineCount || 0,
|
|
2351
2389
|
rows: wrapped, spinRows: null,
|
|
2352
2390
|
v: MD_RENDER_VERSION, // invalidates rows built by an older renderer
|
|
2353
2391
|
};
|
|
@@ -2631,6 +2669,13 @@ export function messageSignature(m) {
|
|
|
2631
2669
|
const mix = (v) => { h ^= (v | 0); h = Math.imul(h, 16777619) >>> 0; };
|
|
2632
2670
|
mix(typeof m.text === 'string' ? m.text.length : 0);
|
|
2633
2671
|
mix(typeof m.streamContent === 'string' ? m.streamContent.length : 0);
|
|
2672
|
+
// THE LINE COUNT CHANGES THE ROW'S SHAPE WITHOUT CHANGING ITS TEXT.
|
|
2673
|
+
//
|
|
2674
|
+
// A streaming Write preview pads its gutter to the width of the TOTAL line count, so
|
|
2675
|
+
// crossing 9 -> 10 re-lays out every row. The count is not text, so leaving it out meant
|
|
2676
|
+
// this message's signature did not move, the whole layout was declared unchanged, and the
|
|
2677
|
+
// previous frame's narrower gutter stayed on screen under the new rows.
|
|
2678
|
+
mix(m._streamLineCount || 0);
|
|
2634
2679
|
mix(m.pending ? 1 : 0);
|
|
2635
2680
|
mix(m.pluginLog && m.expanded ? 1 : 0);
|
|
2636
2681
|
mix(m._cache ? 1 : 0);
|
|
@@ -3780,10 +3825,10 @@ export function startupChat(width, opts = {}) {
|
|
|
3780
3825
|
// the two compete.
|
|
3781
3826
|
rows.push(line(C.bold + C.heading + name + C.reset + ' ' + C.gray + 'v' + version + C.reset));
|
|
3782
3827
|
|
|
3783
|
-
const model = modelLabel(cfg) || '(no model)';
|
|
3828
|
+
const model = modelLabel(cfg) || uiText('(no model)');
|
|
3784
3829
|
// The effort is only meaningful when the model reasons; showing "off" for a model that never thinks is noise.
|
|
3785
3830
|
const effort = cfg.reasoning && cfg.effort && cfg.effort !== 'off' ? ` (${cfg.effort})` : '';
|
|
3786
|
-
rows.push(line(C.gray + 'Model: ' + model + effort + C.reset));
|
|
3831
|
+
rows.push(line(C.gray + uiText('Model: ') + model + effort + C.reset));
|
|
3787
3832
|
|
|
3788
3833
|
const dir = opts.workspace || cfg.workspace || '';
|
|
3789
3834
|
if (dir) rows.push(line(C.gray + dir + C.reset));
|
|
@@ -4004,7 +4049,7 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
|
|
|
4004
4049
|
// wrapped it onto a second visual row while the `lines` array still had ONE,
|
|
4005
4050
|
// so every row below — the text body included — sat one row lower on screen
|
|
4006
4051
|
// than the code assumed. Clicks and the caret landed one line off.
|
|
4007
|
-
lines.push(col(fitAnsi(ed.title || 'Edit', w), C.cyan + C.bold));
|
|
4052
|
+
lines.push(col(fitAnsi(ed.title || uiText('Edit'), w), C.cyan + C.bold));
|
|
4008
4053
|
lines.push(rule);
|
|
4009
4054
|
const hint = ed.hint || 'Ctrl+S save · Esc cancel · Enter newline';
|
|
4010
4055
|
// Clamped like the title: an overlong hint would wrap on screen and shift the
|
|
@@ -4524,7 +4569,7 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
|
|
|
4524
4569
|
for (let bi = 0; bi < ov.body.length; bi++) {
|
|
4525
4570
|
const b = ov.body[bi];
|
|
4526
4571
|
if (!b || !b.__categories) continue;
|
|
4527
|
-
const PREFIX = 'Categories: ';
|
|
4572
|
+
const PREFIX = uiText('Categories: ');
|
|
4528
4573
|
// `inner` IS the content box. The overlay already accounts for the panel's one-column
|
|
4529
4574
|
// padding on each side when it pads each row, so subtracting two more made the usable
|
|
4530
4575
|
// width narrower than the card — a strip that fitted the card exactly still wrapped.
|
|
@@ -4554,8 +4599,28 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
|
|
|
4554
4599
|
out.push(line);
|
|
4555
4600
|
}
|
|
4556
4601
|
// Rows go back into the body in place of the sentinel, so the indices the hitbox step
|
|
4557
|
-
// uses (`catBodyRow`) stay correct.
|
|
4602
|
+
// uses (`catBodyRow`) stay correct for the TABS.
|
|
4603
|
+
//
|
|
4604
|
+
// EVERY BODY INDEX RECORDED BEFORE THIS POINT MUST BE SHIFTED BY THE GROWTH. The
|
|
4605
|
+
// sentinel occupied ONE slot; a wrapped strip takes several. Body indices are what
|
|
4606
|
+
// `rowOf()` turns into screen rows, so leaving them unshifted moved every control
|
|
4607
|
+
// below the strip up by (out.length - 1) rows — on /model that made a click one row
|
|
4608
|
+
// too high, so clicking a model selected the one under it. Only a strip that FITS on
|
|
4609
|
+
// one line hid this, because then the growth is zero.
|
|
4610
|
+
const grew = out.length - 1;
|
|
4558
4611
|
ov.body.splice(bi, 1, ...out);
|
|
4612
|
+
if (grew > 0) {
|
|
4613
|
+
const shift = (i) => (i > bi ? i + grew : i);
|
|
4614
|
+
if (Array.isArray(ov.itemBodyRows)) {
|
|
4615
|
+
for (let k = 0; k < ov.itemBodyRows.length; k++) ov.itemBodyRows[k] = shift(ov.itemBodyRows[k]);
|
|
4616
|
+
}
|
|
4617
|
+
if (Array.isArray(ov.fieldBodyRows)) {
|
|
4618
|
+
for (let k = 0; k < ov.fieldBodyRows.length; k++) ov.fieldBodyRows[k] = shift(ov.fieldBodyRows[k]);
|
|
4619
|
+
}
|
|
4620
|
+
if (ov.footerBodyRow > bi) ov.footerBodyRow += grew;
|
|
4621
|
+
if (ov.typeBodyRow > bi) ov.typeBodyRow += grew;
|
|
4622
|
+
if (ov.catBodyRow > bi) ov.catBodyRow += grew;
|
|
4623
|
+
}
|
|
4559
4624
|
// The tabs, with their row recorded ABSOLUTELY: a hitbox carries one row and the
|
|
4560
4625
|
// strip now spans several.
|
|
4561
4626
|
if (Array.isArray(b.tabs)) {
|
|
@@ -4941,6 +5006,39 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
|
|
|
4941
5006
|
const ORANGE_RGB = [255, 140, 0];
|
|
4942
5007
|
const greyEsc = lerpColor(GREY_RGB[0], GREY_RGB[1], GREY_RGB[2], GREY_RGB[0], GREY_RGB[1], GREY_RGB[2], 0);
|
|
4943
5008
|
const orangeEsc = lerpColor(ORANGE_RGB[0], ORANGE_RGB[1], ORANGE_RGB[2], ORANGE_RGB[0], ORANGE_RGB[1], ORANGE_RGB[2], 0);
|
|
5009
|
+
// COMPACTING IS ITS OWN COLOUR, AND IT ARRIVES SMOOTHLY.
|
|
5010
|
+
//
|
|
5011
|
+
// The row used to keep the Working orange and only change its WORDS, so the one
|
|
5012
|
+
// moment the session is doing something expensive looked identical to ordinary
|
|
5013
|
+
// work. Blue separates it, and it is the same blue the context bar uses for the
|
|
5014
|
+
// segments it is about to rewrite — the two read as one story.
|
|
5015
|
+
//
|
|
5016
|
+
// The switch is INTERPOLATED over `COMPACT_FADE_MS`, not swapped: an instant jump
|
|
5017
|
+
// from orange to blue reads as a state change on a row that is otherwise animating,
|
|
5018
|
+
// which is the thing the sweep exists to avoid. `compactingSince` is stamped the
|
|
5019
|
+
// first frame compaction is seen and cleared when it ends, so the fade runs once in
|
|
5020
|
+
// each direction.
|
|
5021
|
+
const BLUE_RGB = [90, 124, 255];
|
|
5022
|
+
const COMPACT_FADE_MS = 600;
|
|
5023
|
+
if (state.compacting && !state.compactingSince) state.compactingSince = Date.now();
|
|
5024
|
+
if (!state.compacting && state.compactingSince) {
|
|
5025
|
+
// Keep the stamp for one fade so the return to orange is smooth too.
|
|
5026
|
+
if (Date.now() - state.compactingSince > COMPACT_FADE_MS) state.compactingSince = null;
|
|
5027
|
+
}
|
|
5028
|
+
const compactT = state.compactingSince
|
|
5029
|
+
? (state.compacting
|
|
5030
|
+
? Math.min(1, (Date.now() - state.compactingSince) / COMPACT_FADE_MS)
|
|
5031
|
+
: Math.max(0, 1 - (Date.now() - state.compactingSince) / COMPACT_FADE_MS))
|
|
5032
|
+
: (state.compacting ? 1 : 0);
|
|
5033
|
+
const mixRgb = (a, b, t) => [
|
|
5034
|
+
Math.round(a[0] + (b[0] - a[0]) * t),
|
|
5035
|
+
Math.round(a[1] + (b[1] - a[1]) * t),
|
|
5036
|
+
Math.round(a[2] + (b[2] - a[2]) * t),
|
|
5037
|
+
];
|
|
5038
|
+
const ACCENT_RGB = compactT > 0 ? mixRgb(ORANGE_RGB, BLUE_RGB, compactT) : ORANGE_RGB;
|
|
5039
|
+
const accentEsc = compactT > 0
|
|
5040
|
+
? lerpColor(ACCENT_RGB[0], ACCENT_RGB[1], ACCENT_RGB[2], ACCENT_RGB[0], ACCENT_RGB[1], ACCENT_RGB[2], 0)
|
|
5041
|
+
: orangeEsc;
|
|
4944
5042
|
const elapsed = state.turnStart
|
|
4945
5043
|
? col(` [${elapsedTail(Date.now() - state.turnStart, state.turnOutputTokens)}]`, greyEsc)
|
|
4946
5044
|
: '';
|
|
@@ -4971,15 +5069,15 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
|
|
|
4971
5069
|
// branches below cannot run at all.
|
|
4972
5070
|
if (still) {
|
|
4973
5071
|
const dim = frameInfo.dim;
|
|
4974
|
-
const dotEsc = dim ? greyEsc :
|
|
5072
|
+
const dotEsc = dim ? greyEsc : accentEsc;
|
|
4975
5073
|
lines.push(
|
|
4976
5074
|
(dim ? C.dim : '') + col(frame, dotEsc) + ' '
|
|
4977
|
-
+ col(workMsg, greyEsc) + elapsed + (dim ? C.reset : ''),
|
|
5075
|
+
+ col(workMsg, compactT > 0 ? accentEsc : greyEsc) + elapsed + (dim ? C.reset : ''),
|
|
4978
5076
|
);
|
|
4979
5077
|
}
|
|
4980
5078
|
// ---- turn-start animation ----
|
|
4981
5079
|
// 0.25s: type out "Working..." in grey (chars appear left→right)
|
|
4982
|
-
// 0.25s: fill with orange
|
|
5080
|
+
// 0.25s: fill with the accent colour — orange, or blue while compacting
|
|
4983
5081
|
// After 0.5s total: start the normal pulse animation
|
|
4984
5082
|
else if (state.startAnim) {
|
|
4985
5083
|
// 0.5s total: 0.25s types `Working... [0s]` out in grey, then 0.25s sweeps the
|
|
@@ -5020,7 +5118,7 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
|
|
|
5020
5118
|
out.push(i < tailTyped ? col(tailAll[i], greyEsc) : ' ');
|
|
5021
5119
|
}
|
|
5022
5120
|
// The tail is already inside `out`, so do NOT append `elapsed` here.
|
|
5023
|
-
lines.push(col(frame,
|
|
5121
|
+
lines.push(col(frame, accentEsc) + ' ' + out.join(''));
|
|
5024
5122
|
} else {
|
|
5025
5123
|
// Colour sweep: only the PHRASE goes grey → orange. The tail stays grey
|
|
5026
5124
|
// (it is appended as the colored `elapsed` chunk after `out`).
|
|
@@ -5038,12 +5136,12 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
|
|
|
5038
5136
|
for (let i = 0; i < phrase.length; i++) {
|
|
5039
5137
|
const charAt = i / phrase.length;
|
|
5040
5138
|
const tChar = sweepSettle(head - charAt, BAND, edge);
|
|
5041
|
-
const r = Math.round(GREY_RGB[0] + (
|
|
5042
|
-
const g = Math.round(GREY_RGB[1] + (
|
|
5043
|
-
const b = Math.round(GREY_RGB[2] + (
|
|
5139
|
+
const r = Math.round(GREY_RGB[0] + (ACCENT_RGB[0] - GREY_RGB[0]) * tChar);
|
|
5140
|
+
const g = Math.round(GREY_RGB[1] + (ACCENT_RGB[1] - GREY_RGB[1]) * tChar);
|
|
5141
|
+
const b = Math.round(GREY_RGB[2] + (ACCENT_RGB[2] - GREY_RGB[2]) * tChar);
|
|
5044
5142
|
out.push(col(phrase[i], lerpColor(r, g, b, r, g, b, 0)));
|
|
5045
5143
|
}
|
|
5046
|
-
lines.push(col(frame,
|
|
5144
|
+
lines.push(col(frame, accentEsc) + ' ' + out.join('') + elapsed + col(stepText, greyEsc));
|
|
5047
5145
|
}
|
|
5048
5146
|
// The cutoff has to be the SAME number as `DUR`. They were separate literals (1000 here, 1000
|
|
5049
5147
|
// above) and changing one alone left the preview exiting early or the animation running on into
|
|
@@ -5083,9 +5181,9 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
|
|
|
5083
5181
|
}
|
|
5084
5182
|
// Colour: orange → grey over the animation. Uses the SAME shared constants
|
|
5085
5183
|
// so the row does not shift shade when the finish morph begins.
|
|
5086
|
-
const r = Math.round(
|
|
5087
|
-
const g = Math.round(
|
|
5088
|
-
const b = Math.round(
|
|
5184
|
+
const r = Math.round(ACCENT_RGB[0] + (GREY_RGB[0] - ACCENT_RGB[0]) * t);
|
|
5185
|
+
const g = Math.round(ACCENT_RGB[1] + (GREY_RGB[1] - ACCENT_RGB[1]) * t);
|
|
5186
|
+
const b = Math.round(ACCENT_RGB[2] + (GREY_RGB[2] - ACCENT_RGB[2]) * t);
|
|
5089
5187
|
const animColor = lerpColor(r, g, b, r, g, b, 0);
|
|
5090
5188
|
lines.push(col(frame, animColor) + ' ' + col('[', animColor) + col(word, animColor) + col(tail, greyEsc));
|
|
5091
5189
|
} else {
|
|
@@ -5128,12 +5226,17 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
|
|
|
5128
5226
|
//
|
|
5129
5227
|
// These are the base with a lift in the same hue, so the animation reads as a sheen travelling across
|
|
5130
5228
|
// the word rather than as the word changing colour.
|
|
5131
|
-
|
|
5229
|
+
//
|
|
5230
|
+
// IT IS DERIVED FROM THE ACCENT, NOT FIXED. A single yellow glint was written for the orange base and
|
|
5231
|
+
// stayed yellow when the row turned blue for a compaction — a warm highlight over a cool base, which
|
|
5232
|
+
// reads as two colours fighting rather than as one sheen. `glintFor` lifts each channel part-way to
|
|
5233
|
+
// white, so the hue of whichever base is in force carries through.
|
|
5234
|
+
const GLINT = glintFor(ACCENT_RGB);
|
|
5132
5235
|
|
|
5133
5236
|
const chars = workMsg;
|
|
5134
5237
|
const lightEdge = state.shimmerEdge || (state.cfg && state.cfg.shimmerEdge) || 'cosine';
|
|
5135
5238
|
// ONE shimmer for both rows — see `shimmerText`.
|
|
5136
|
-
const out = shimmerText(chars, phaseMs,
|
|
5239
|
+
const out = shimmerText(chars, phaseMs, ACCENT_RGB, GLINT, lightEdge);
|
|
5137
5240
|
// A QUIET TURN FADES TOWARD THE WARNING COLOUR.
|
|
5138
5241
|
//
|
|
5139
5242
|
// `state.lastTokenAt` is stamped whenever output arrives; `state.hasActiveTools` is set while a tool
|
|
@@ -5141,14 +5244,20 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
|
|
|
5141
5244
|
//
|
|
5142
5245
|
// The intensity is interpolated into the base colour rather than switching, so a slow model does not
|
|
5143
5246
|
// look like a broken one for one frame and then fine the next.
|
|
5144
|
-
|
|
5247
|
+
// A COMPACTION IS NOT A STALLED MODEL.
|
|
5248
|
+
//
|
|
5249
|
+
// The stall warning exists because a model that has sent nothing for a few seconds is
|
|
5250
|
+
// usually stuck. A manual /compact has no model output at all — its summariser is a
|
|
5251
|
+
// separate one-shot request that never stamps `lastTokenAt` — so the row announced
|
|
5252
|
+
// trouble for the whole round trip, which is the opposite of what is happening.
|
|
5253
|
+
const stall = state.compacting ? 0 : stallIntensity({
|
|
5145
5254
|
sinceLastTokenMs: state.lastTokenAt ? Date.now() - state.lastTokenAt : 0,
|
|
5146
5255
|
hasActiveTools: !!state.hasActiveTools,
|
|
5147
5256
|
});
|
|
5148
5257
|
const baseFrame = stall > 0 ? col(frame, lerpColor(
|
|
5149
|
-
|
|
5258
|
+
ACCENT_RGB[0], ACCENT_RGB[1], ACCENT_RGB[2],
|
|
5150
5259
|
255, 90, 90, stall,
|
|
5151
|
-
)) : col(frame,
|
|
5260
|
+
)) : col(frame, accentEsc);
|
|
5152
5261
|
lines.push(baseFrame + ' ' + out + elapsed + stepNote);
|
|
5153
5262
|
}
|
|
5154
5263
|
}
|
|
@@ -5470,8 +5579,18 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
|
|
|
5470
5579
|
const running = ts.filter((t) => t.status === 'running');
|
|
5471
5580
|
const bashTasks = running.filter((t) => t.kind !== 'agent').length;
|
|
5472
5581
|
const agentTasks = running.filter((t) => t.kind === 'agent').length;
|
|
5473
|
-
|
|
5474
|
-
|
|
5582
|
+
// The badges are CLICKABLE: they open the task panel, which is where the running
|
|
5583
|
+
// tasks are listed and can be read or stopped. A count the user cannot act on is
|
|
5584
|
+
// decoration; this one is a link.
|
|
5585
|
+
//
|
|
5586
|
+
// The text goes through the i18n table so the badge reads the same in every
|
|
5587
|
+
// language. The English form is kept in the table for the default language.
|
|
5588
|
+
if (bashTasks > 0) {
|
|
5589
|
+
pushPart(col(tr('status.tasksBash', '[{n} task(s) running]', { n: bashTasks })), { kind: 'statusTasks' });
|
|
5590
|
+
}
|
|
5591
|
+
if (agentTasks > 0) {
|
|
5592
|
+
pushPart(col(tr('status.tasksAgent', '[{n} agent(s) running]', { n: agentTasks })), { kind: 'statusTasks' });
|
|
5593
|
+
}
|
|
5475
5594
|
}
|
|
5476
5595
|
if (state.slCwd !== false && cwd) parts.push(col(cwd, C.gray));
|
|
5477
5596
|
// GIT badge: branch, then the working-tree diff totals. Placed AFTER the path so
|
|
@@ -5532,7 +5651,7 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
|
|
|
5532
5651
|
//
|
|
5533
5652
|
// No bar when the window is unknown: a bar claiming to be full is worse than no bar, and
|
|
5534
5653
|
// `ctxMax` is 0 until the first usage report lands.
|
|
5535
|
-
const ctxText =
|
|
5654
|
+
const ctxText = `${uiText('context')} ${state.ctxPercent}% (${fmtTokens(state.ctxTokens || 0)}/${fmtTokens(state.ctxMax || 1)})`;
|
|
5536
5655
|
const ctxSegs = contextSegments(state, state.cfg);
|
|
5537
5656
|
const barRow = lines.length;
|
|
5538
5657
|
const bar = state.ctxMax > 0
|
|
@@ -7065,9 +7184,9 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7065
7184
|
openPicker({
|
|
7066
7185
|
title: 'Select permission mode',
|
|
7067
7186
|
items: [
|
|
7068
|
-
{ label: 'Ask', sub: 'read-only tools and read-only shell commands run automatically; everything else asks', current: state.mode === 'ask', value: 'ask' },
|
|
7187
|
+
{ label: 'Ask', sub: uiText('read-only tools and read-only shell commands run automatically; everything else asks'), current: state.mode === 'ask', value: 'ask' },
|
|
7069
7188
|
{ label: 'Yolo', sub: 'runs anything inside the workspace, and any non-destructive command; asks for a path OUTSIDE the workspace and for a destructive command', current: state.mode === 'yolo', value: 'yolo' },
|
|
7070
|
-
{ label: 'Auto', sub: 'never asks and never waits for approval: everything runs and is decided automatically (an explicit deny or ask rule still wins)', current: state.mode === 'auto', value: 'auto' },
|
|
7189
|
+
{ label: 'Auto', sub: uiText('never asks and never waits for approval: everything runs and is decided automatically (an explicit deny or ask rule still wins)'), current: state.mode === 'auto', value: 'auto' },
|
|
7071
7190
|
],
|
|
7072
7191
|
sel: ['ask', 'yolo', 'auto'].indexOf(state.mode),
|
|
7073
7192
|
searchable: false,
|
|
@@ -7085,7 +7204,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7085
7204
|
// `/plan saved` lists the plans persisted to <workspace>/.hncode/plans.
|
|
7086
7205
|
if (a === 'saved' || a === 'list') {
|
|
7087
7206
|
const items = listPlans(state.workspace || cfg.workspace);
|
|
7088
|
-
if (!items.length) { say('No saved plans yet. Approve a plan in Plan mode to save it.'); return; }
|
|
7207
|
+
if (!items.length) { say(uiText('No saved plans yet. Approve a plan in Plan mode to save it.')); return; }
|
|
7089
7208
|
h.openPanel('hncode — saved plans', [
|
|
7090
7209
|
`${items.length} plan(s) in ${plansDir(state.workspace || cfg.workspace)}:`,
|
|
7091
7210
|
'',
|
|
@@ -7093,13 +7212,13 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7093
7212
|
]);
|
|
7094
7213
|
return;
|
|
7095
7214
|
}
|
|
7096
|
-
if (a === 'clear') { state.plan = false; state.planPath = null; persist(); app('Plan cleared.'); return; }
|
|
7215
|
+
if (a === 'clear') { state.plan = false; state.planPath = null; persist(); app(uiText('Plan cleared.')); return; }
|
|
7097
7216
|
if (a === 'on') state.plan = true;
|
|
7098
7217
|
else if (a === 'off') state.plan = false;
|
|
7099
7218
|
else state.plan = !state.plan;
|
|
7100
7219
|
if (state.plan) { state.focus = false; state.swarm = false; }
|
|
7101
7220
|
persist();
|
|
7102
|
-
app(`Plan mode: ${state.plan ? 'ON (read-only planning)' : 'OFF'}`);
|
|
7221
|
+
app(`Plan mode: ${state.plan ? uiText('ON (read-only planning)') : uiText('OFF')}`);
|
|
7103
7222
|
return;
|
|
7104
7223
|
}
|
|
7105
7224
|
case 'focus': {
|
|
@@ -7110,7 +7229,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7110
7229
|
state.focus = want;
|
|
7111
7230
|
if (state.focus) { state.plan = false; state.swarm = false; }
|
|
7112
7231
|
persist();
|
|
7113
|
-
app(`Focus mode: ${state.focus ? 'ON (Read/Write/Edit/Bash only)' : 'OFF (all tools)'}`);
|
|
7232
|
+
app(`Focus mode: ${state.focus ? uiText('ON (Read/Write/Edit/Bash only)') : uiText('OFF (all tools)')}`);
|
|
7114
7233
|
return;
|
|
7115
7234
|
}
|
|
7116
7235
|
case 'websearch-api': {
|
|
@@ -7131,8 +7250,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7131
7250
|
applySetting('web_search_api_key', String(value == null ? '' : value));
|
|
7132
7251
|
const count = String(value || '').split(/\r?\n/).map((s) => s.trim()).filter(Boolean).length;
|
|
7133
7252
|
app(count
|
|
7134
|
-
?
|
|
7135
|
-
: 'WebSearch keys cleared — searches use keyless mode (rate-limited per IP).');
|
|
7253
|
+
? `${uiText('Saved')} ${count} WebSearch ${uiText('key')}${count === 1 ? '' : 's'}. ${uiText('The next search uses them.')}`
|
|
7254
|
+
: uiText('WebSearch keys cleared — searches use keyless mode (rate-limited per IP).'));
|
|
7136
7255
|
},
|
|
7137
7256
|
});
|
|
7138
7257
|
return;
|
|
@@ -7275,12 +7394,12 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7275
7394
|
const show = () => {
|
|
7276
7395
|
const row = (label, v, note) => ` ${label.padEnd(18)} ${v == null ? '(provider default)' : v}${note ? ' ' + note : ''}`;
|
|
7277
7396
|
sayPanel([
|
|
7278
|
-
'Sampling parameters',
|
|
7397
|
+
uiText('Sampling parameters'),
|
|
7279
7398
|
'',
|
|
7280
7399
|
row('send them', cfg.sampling === false ? 'off' : 'on', cfg.sampling === false ? 'nothing is sent' : ''),
|
|
7281
7400
|
row('temperature', cfg.temperature),
|
|
7282
7401
|
row('top_p', cfg.topP),
|
|
7283
|
-
row('presence_penalty', cfg.presencePenalty, 'OpenAI-compatible only'),
|
|
7402
|
+
row('presence_penalty', cfg.presencePenalty, uiText('OpenAI-compatible only')),
|
|
7284
7403
|
'',
|
|
7285
7404
|
'Set with /sampling temperature 0.3, /sampling top_p 0.9, /sampling off',
|
|
7286
7405
|
].join('\n'));
|
|
@@ -7294,7 +7413,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7294
7413
|
}
|
|
7295
7414
|
const key = parts[0] === 'top-p' ? 'top_p' : parts[0] === 'presence-penalty' ? 'presence_penalty' : parts[0];
|
|
7296
7415
|
if (!['temperature', 'top_p', 'presence_penalty'].includes(key)) {
|
|
7297
|
-
appErr('Usage: /sampling [on|off] | temperature <0-2> | top_p <0-1> | presence_penalty <-2-2>');
|
|
7416
|
+
appErr(uiText('Usage: /sampling [on|off] | temperature <0-2> | top_p <0-1> | presence_penalty <-2-2>'));
|
|
7298
7417
|
return;
|
|
7299
7418
|
}
|
|
7300
7419
|
if (parts.length === 1) { show(); return; }
|
|
@@ -7312,8 +7431,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7312
7431
|
if (!parts.length) {
|
|
7313
7432
|
const changed = changedSettings(cfg);
|
|
7314
7433
|
if (!changed.length) {
|
|
7315
|
-
sayPanel(['Nothing is set away from its default.', '', 'Browse everything with /settings,',
|
|
7316
|
-
'or set one directly: /set <key> <value>'].join('\n'));
|
|
7434
|
+
sayPanel([uiText('Nothing is set away from its default.'), '', uiText('Browse everything with /settings,'),
|
|
7435
|
+
uiText('or set one directly: /set <key> <value>')].join('\n'));
|
|
7317
7436
|
return;
|
|
7318
7437
|
}
|
|
7319
7438
|
const lines = [`${changed.length} setting(s) differ from the default:`, ''];
|
|
@@ -7355,17 +7474,17 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7355
7474
|
const want = String(raw || '').trim().toLowerCase();
|
|
7356
7475
|
if (!want) {
|
|
7357
7476
|
const now = getUiLang();
|
|
7358
|
-
app(
|
|
7477
|
+
app(uiText(now === 'zh' ? 'Interface language: 中文' : 'Interface language: English') + ' (/lang zh|en)');
|
|
7359
7478
|
return;
|
|
7360
7479
|
}
|
|
7361
7480
|
if (want !== 'zh' && want !== 'en') {
|
|
7362
|
-
appErr('Usage: /lang zh|en');
|
|
7481
|
+
appErr(uiText('Usage: /lang zh|en'));
|
|
7363
7482
|
return;
|
|
7364
7483
|
}
|
|
7365
7484
|
setUiLang(want);
|
|
7366
7485
|
try { setConfigString('lang', want); } catch { /* an unwritable config must not undo the switch */ }
|
|
7367
7486
|
if (cfg) cfg.lang = want;
|
|
7368
|
-
app(want === 'zh' ? '
|
|
7487
|
+
app(uiText(want === 'zh' ? 'Interface language: 中文' : 'Interface language: English'));
|
|
7369
7488
|
return;
|
|
7370
7489
|
}
|
|
7371
7490
|
|
|
@@ -7375,7 +7494,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7375
7494
|
if (!names.length) {
|
|
7376
7495
|
const pr = (cfg.raw && cfg.raw.providers) || {};
|
|
7377
7496
|
names = Object.keys(pr);
|
|
7378
|
-
if (!names.length) { appErr('No providers configured. Add one first: /provider'); return; }
|
|
7497
|
+
if (!names.length) { appErr(uiText('No providers configured. Add one first: /provider')); return; }
|
|
7379
7498
|
if (raw) {
|
|
7380
7499
|
if (!pr[raw]) { appErr(`Unknown provider: ${raw}`); return; }
|
|
7381
7500
|
applyModel(state, cfg, resolveProvider(cfg, raw));
|
|
@@ -7418,7 +7537,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7418
7537
|
// window, output limit). These are exactly the fields resolveConfig reads,
|
|
7419
7538
|
// so an edit takes effect on the next turn without editing config.toml by hand.
|
|
7420
7539
|
onCtrlE: (item) => {
|
|
7421
|
-
if (!item || item.action === 'add-model') { appErr('Select a model first, then Ctrl+E to edit it.'); return; }
|
|
7540
|
+
if (!item || item.action === 'add-model') { appErr(uiText('Select a model first, then Ctrl+E to edit it.')); return; }
|
|
7422
7541
|
const entry = models[item.label] || {};
|
|
7423
7542
|
const provider = entry.provider || cfg.provider || '';
|
|
7424
7543
|
const modelId = entry.model || bareModelId(provider, item.label, entry);
|
|
@@ -7481,7 +7600,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7481
7600
|
if (it.action === 'add-model') {
|
|
7482
7601
|
const pr = (cfg.raw && cfg.raw.providers) || {};
|
|
7483
7602
|
const providers = Object.keys(pr);
|
|
7484
|
-
if (!providers.length) { appErr('No providers configured. Add one first: /provider'); return true; }
|
|
7603
|
+
if (!providers.length) { appErr(uiText('No providers configured. Add one first: /provider')); return true; }
|
|
7485
7604
|
openPicker({
|
|
7486
7605
|
title: 'Add model — choose a provider',
|
|
7487
7606
|
items: providers.map((n) => ({ label: n, sub: ((pr[n] || {}).base_url || '').replace(/^https?:\/\//, ''), provider: n })),
|
|
@@ -7497,7 +7616,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7497
7616
|
hideType: true,
|
|
7498
7617
|
hint: 'Tab next field · Enter save · Esc cancel (display name defaults to the id)',
|
|
7499
7618
|
onSubmit: (values) => {
|
|
7500
|
-
if (!values.model) { appErr('Cancelled: model id is required.'); return; }
|
|
7619
|
+
if (!values.model) { appErr(uiText('Cancelled: model id is required.')); return; }
|
|
7501
7620
|
const disp = values.display_name || values.model;
|
|
7502
7621
|
addModel(pit.provider, values.model, { display_name: values.display_name });
|
|
7503
7622
|
cfg.raw.models = cfg.raw.models || {};
|
|
@@ -7522,7 +7641,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7522
7641
|
}
|
|
7523
7642
|
case 'effort': {
|
|
7524
7643
|
const opts = effortOptions(cfg);
|
|
7525
|
-
if (!opts.length) { appErr('The current model has no thinking control.'); return; }
|
|
7644
|
+
if (!opts.length) { appErr(uiText('The current model has no thinking control.')); return; }
|
|
7526
7645
|
if (raw) {
|
|
7527
7646
|
const v = raw.toLowerCase();
|
|
7528
7647
|
// NO VALIDATION against `opts`. The list is what a model is KNOWN to accept — from the catalog,
|
|
@@ -7595,7 +7714,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7595
7714
|
// the whole models.dev catalog when the provider is a catalog one. Replaces
|
|
7596
7715
|
// the provider's model entries rather than appending.
|
|
7597
7716
|
onCtrlR: (it) => {
|
|
7598
|
-
if (!it || it.action === 'add') { appErr('Select a provider first, then Ctrl+R to refresh its models.'); return; }
|
|
7717
|
+
if (!it || it.action === 'add') { appErr(uiText('Select a provider first, then Ctrl+R to refresh its models.')); return; }
|
|
7599
7718
|
refreshProviderModels(state, cfg, it.label, h).catch((e) => appErr(`Refresh failed: ${e.message}`));
|
|
7600
7719
|
},
|
|
7601
7720
|
onDelete: (it) => {
|
|
@@ -7642,8 +7761,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7642
7761
|
typeClickSubmits: true,
|
|
7643
7762
|
hint: 'Tab next field · ↑/↓ field · ←/→ type · Enter save · Esc cancel',
|
|
7644
7763
|
onSubmit: (values, type) => {
|
|
7645
|
-
if (!values.name) { appErr('Cancelled: provider name is required.'); return; }
|
|
7646
|
-
if (!type) { appErr('Cancelled: choose a Type (OpenAI / OpenAI Responses / Anthropic).'); return; }
|
|
7764
|
+
if (!values.name) { appErr(uiText('Cancelled: provider name is required.')); return; }
|
|
7765
|
+
if (!type) { appErr(uiText('Cancelled: choose a Type (OpenAI / OpenAI Responses / Anthropic).')); return; }
|
|
7647
7766
|
const protocol = typeToProtocol(type);
|
|
7648
7767
|
// A hand-entered provider is NOT from the catalog: known=false.
|
|
7649
7768
|
registerProvider(state, cfg, h, values.name, values.base_url, values.api_key, protocol, type, false);
|
|
@@ -7652,7 +7771,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7652
7771
|
return true;
|
|
7653
7772
|
}
|
|
7654
7773
|
// Known provider: load catalog and show list
|
|
7655
|
-
app('Loading provider list…');
|
|
7774
|
+
app(uiText('Loading provider list…'));
|
|
7656
7775
|
fetchCatalog().then((catalog) => {
|
|
7657
7776
|
const entries = catalog
|
|
7658
7777
|
? Object.values(catalog)
|
|
@@ -7677,7 +7796,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7677
7796
|
action: 'pickKnown',
|
|
7678
7797
|
}));
|
|
7679
7798
|
if (!items.length) {
|
|
7680
|
-
appErr('No known providers found in catalog.');
|
|
7799
|
+
appErr(uiText('No known providers found in catalog.'));
|
|
7681
7800
|
return;
|
|
7682
7801
|
}
|
|
7683
7802
|
openPicker({
|
|
@@ -7804,7 +7923,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7804
7923
|
typeClickSubmits: true,
|
|
7805
7924
|
hint: 'Tab next field · ←/→ type · Enter save · Esc cancel',
|
|
7806
7925
|
onSubmit: (values, type) => {
|
|
7807
|
-
if (!values.name) { appErr('Cancelled: provider name is required.'); return; }
|
|
7926
|
+
if (!values.name) { appErr(uiText('Cancelled: provider name is required.')); return; }
|
|
7808
7927
|
// The chosen Type arrives as the SECOND arg (`values` holds only the
|
|
7809
7928
|
// text fields) — `values.type` was undefined and silently saved 'openai'.
|
|
7810
7929
|
const protocol = typeToProtocol(type);
|
|
@@ -7882,6 +8001,17 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7882
8001
|
// The fresh session has no title yet, so this restores the default rather than leaving
|
|
7883
8002
|
// the previous session's name on the window.
|
|
7884
8003
|
writeWindowTitle(session, stdout);
|
|
8004
|
+
// A LONG SESSION'S FIRST FRAME IS SLOW, AND IT USED TO BE A BLANK SCREEN. The first paint
|
|
8005
|
+
// lays out every message once to learn the row count the scrollbar needs — ~570ms for a
|
|
8006
|
+
// 4000-message history, 8ms for a normal one — and until it finishes the screen is empty,
|
|
8007
|
+
// which is indistinguishable from a hang. Saying so costs nothing.
|
|
8008
|
+
{
|
|
8009
|
+
const n = (session && session.messages) ? session.messages.length : 0;
|
|
8010
|
+
if (n > 200) {
|
|
8011
|
+
const cols = Math.max(20, (stdout.columns || 80));
|
|
8012
|
+
stdout.write(fitAnsi(col(` ${tr('tui.state.restoring', 'Restoring {n} messages…', { n })}`, C.gray), cols) + '\n');
|
|
8013
|
+
}
|
|
8014
|
+
}
|
|
7885
8015
|
// A fresh session has no history, so the context gauge must go back to 0
|
|
7886
8016
|
// (otherwise it kept showing the PREVIOUS session's usage until the next
|
|
7887
8017
|
// turn reported a new estimate). The window size is a property of the
|
|
@@ -7923,8 +8053,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7923
8053
|
});
|
|
7924
8054
|
if (!list.length) {
|
|
7925
8055
|
app(everyWorkspace
|
|
7926
|
-
? 'No saved sessions.'
|
|
7927
|
-
: (all.length ? `No sessions in this directory (${cwd}). Try /all-sessions.` : 'No saved sessions.'));
|
|
8056
|
+
? uiText('No saved sessions.')
|
|
8057
|
+
: (all.length ? `No sessions in this directory (${cwd}). Try /all-sessions.` : uiText('No saved sessions.')));
|
|
7928
8058
|
return;
|
|
7929
8059
|
}
|
|
7930
8060
|
openPicker({
|
|
@@ -7943,7 +8073,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
7943
8073
|
onDelete: (it) => {
|
|
7944
8074
|
if (!it || !it.id) return false;
|
|
7945
8075
|
if (it.id === session.id) {
|
|
7946
|
-
appErr('That is the session you are in. Use /new first, or pick another one.');
|
|
8076
|
+
appErr(uiText('That is the session you are in. Use /new first, or pick another one.'));
|
|
7947
8077
|
return false;
|
|
7948
8078
|
}
|
|
7949
8079
|
const ok = sess.deleteSession(it.id);
|
|
@@ -8055,7 +8185,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8055
8185
|
}
|
|
8056
8186
|
cfg.raw.swarm_mode = want;
|
|
8057
8187
|
app(want
|
|
8058
|
-
? 'Swarm mode ON - the model will decompose work across parallel subagents (AgentSwarm)'
|
|
8188
|
+
? uiText('Swarm mode ON - the model will decompose work across parallel subagents (AgentSwarm)')
|
|
8059
8189
|
: 'Swarm mode OFF');
|
|
8060
8190
|
return;
|
|
8061
8191
|
}
|
|
@@ -8075,7 +8205,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8075
8205
|
const setSubagentModel = (value) => {
|
|
8076
8206
|
const v = value || '';
|
|
8077
8207
|
try { setConfigString('subagent_model', v); }
|
|
8078
|
-
catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
|
|
8208
|
+
catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
|
|
8079
8209
|
cfg.subagentModel = v;
|
|
8080
8210
|
cfg.raw.subagent_model = v;
|
|
8081
8211
|
app(v ? `Subagent model → ${v}` : `Subagent model → default (this session's model)`);
|
|
@@ -8090,7 +8220,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8090
8220
|
return;
|
|
8091
8221
|
}
|
|
8092
8222
|
if (!names.length) {
|
|
8093
|
-
appErr('No models configured. Add one first: /provider');
|
|
8223
|
+
appErr(uiText('No models configured. Add one first: /provider'));
|
|
8094
8224
|
return;
|
|
8095
8225
|
}
|
|
8096
8226
|
// The same model menu as /model, with a subagent-scoped title and a
|
|
@@ -8155,7 +8285,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8155
8285
|
return;
|
|
8156
8286
|
}
|
|
8157
8287
|
if (!argStr) {
|
|
8158
|
-
if (!promptIdx.length) { app('Nothing to undo.'); return; }
|
|
8288
|
+
if (!promptIdx.length) { app(uiText('Nothing to undo.')); return; }
|
|
8159
8289
|
const items = promptIdx.map((mi, k) => {
|
|
8160
8290
|
const text = String(msgs[mi].content == null ? '' : msgs[mi].content).replace(/\s+/g, ' ').trim();
|
|
8161
8291
|
return {
|
|
@@ -8195,7 +8325,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8195
8325
|
],
|
|
8196
8326
|
onPick: (it) => {
|
|
8197
8327
|
if (it && it.label === 'Rewind') run();
|
|
8198
|
-
else app('Rewind cancelled.');
|
|
8328
|
+
else app(uiText('Rewind cancelled.'));
|
|
8199
8329
|
return true;
|
|
8200
8330
|
},
|
|
8201
8331
|
});
|
|
@@ -8213,7 +8343,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8213
8343
|
if (j < 0) break;
|
|
8214
8344
|
ci = j;
|
|
8215
8345
|
}
|
|
8216
|
-
if (ci >= cur.length) { app('Nothing to undo.'); return; }
|
|
8346
|
+
if (ci >= cur.length) { app(uiText('Nothing to undo.')); return; }
|
|
8217
8347
|
// Truncate the model's context AND rebuild the displayed transcript from that point. The two have different
|
|
8218
8348
|
// row counts because the transcript also contains receipts, notices and shell commands; slicing it by the
|
|
8219
8349
|
// number of removed model messages leaves rows from the discarded turn on screen.
|
|
@@ -8256,12 +8386,12 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8256
8386
|
if (a === 'on') want = true;
|
|
8257
8387
|
else if (a === 'off') want = false;
|
|
8258
8388
|
else if (a === '') { app(`Auto title: ${cfg.autoTitle === false ? 'off' : 'on'}. /auto-title [on|off]`); return; }
|
|
8259
|
-
else { appErr('Usage: /auto-title [on|off]'); return; }
|
|
8389
|
+
else { appErr(uiText('Usage: /auto-title [on|off]')); return; }
|
|
8260
8390
|
cfg.autoTitle = want;
|
|
8261
8391
|
try { setConfigString('auto_title', want ? 'true' : 'false'); }
|
|
8262
8392
|
catch (e) { appErr(`Could not save this setting: ${e.message} — it applies to this session only.`); }
|
|
8263
8393
|
app(want
|
|
8264
|
-
? 'Auto title: ON — the first message names the session.'
|
|
8394
|
+
? uiText('Auto title: ON — the first message names the session.')
|
|
8265
8395
|
: 'Auto title: OFF — the name comes only from /title.');
|
|
8266
8396
|
return;
|
|
8267
8397
|
}
|
|
@@ -8276,12 +8406,12 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8276
8406
|
if (a === 'on') want = true;
|
|
8277
8407
|
else if (a === 'off') want = false;
|
|
8278
8408
|
else if (a === '') { app(`PTC mode: ${state.ptcMode ? 'on' : 'off'}. /ptc [on|off]`); return; }
|
|
8279
|
-
else { appErr('Usage: /ptc [on|off]'); return; }
|
|
8409
|
+
else { appErr(uiText('Usage: /ptc [on|off]')); return; }
|
|
8280
8410
|
state.ptcMode = want;
|
|
8281
8411
|
if (session) session.ptcMode = want;
|
|
8282
8412
|
try { sess.saveSession(session); } catch { /* a preference; a failed save must not block the mode */ }
|
|
8283
8413
|
app(want
|
|
8284
|
-
? 'PTC mode: ON — the model gets only the PTC tool and reaches everything else through its sandbox.'
|
|
8414
|
+
? uiText('PTC mode: ON — the model gets only the PTC tool and reaches everything else through its sandbox.')
|
|
8285
8415
|
: 'PTC mode: OFF — direct tool calls are available again.');
|
|
8286
8416
|
return;
|
|
8287
8417
|
}
|
|
@@ -8291,7 +8421,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8291
8421
|
saveSession(session);
|
|
8292
8422
|
// The window title follows the session, in ONE place (see writeWindowTitle).
|
|
8293
8423
|
writeWindowTitle(session, stdout);
|
|
8294
|
-
app(`Session title set to: "${session.title || 'Untitled'}"`);
|
|
8424
|
+
app(`Session title set to: "${session.title || uiText('Untitled')}"`);
|
|
8295
8425
|
} else {
|
|
8296
8426
|
app(`Session title: ${session.title || 'not set'}`);
|
|
8297
8427
|
}
|
|
@@ -8299,17 +8429,17 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8299
8429
|
}
|
|
8300
8430
|
case 'compact': {
|
|
8301
8431
|
const msgs = session.messages || [];
|
|
8302
|
-
if (msgs.length <= 2) { app('Nothing to compact yet.'); return; }
|
|
8432
|
+
if (msgs.length <= 2) { app(uiText('Nothing to compact yet.')); return; }
|
|
8303
8433
|
const ratio = raw ? parseFloat(raw) : null; // optional slice ratio (0-1)
|
|
8304
8434
|
if (ratio !== null && !(ratio > 0 && ratio < 1)) {
|
|
8305
|
-
app('Invalid ratio; use 0-1 (e.g., 0.2 to drop the oldest 20% of messages)');
|
|
8435
|
+
app(uiText('Invalid ratio; use 0-1 (e.g., 0.2 to drop the oldest 20% of messages)'));
|
|
8306
8436
|
return;
|
|
8307
8437
|
}
|
|
8308
8438
|
|
|
8309
8439
|
// Summarising is a full model round-trip. Without this, a second /compact
|
|
8310
8440
|
// (or a message typed while it works) would edit the same history at the
|
|
8311
8441
|
// same time — `state.running` is what submit() checks to queue instead.
|
|
8312
|
-
if (state.running) { app('Busy — wait for the current turn to finish.'); return; }
|
|
8442
|
+
if (state.running) { app(uiText('Busy — wait for the current turn to finish.')); return; }
|
|
8313
8443
|
state.running = true;
|
|
8314
8444
|
// The Working row takes over the progress display: it shows `Compacting Context...` for as
|
|
8315
8445
|
// long as this runs, so the summary round-trip is visible without adding a transcript row.
|
|
@@ -8469,11 +8599,11 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8469
8599
|
const trimmed = String(value).trim();
|
|
8470
8600
|
try {
|
|
8471
8601
|
setConfigString('system_prompt', trimmed);
|
|
8472
|
-
} catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
|
|
8602
|
+
} catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
|
|
8473
8603
|
cfg.systemPrompt = trimmed;
|
|
8474
8604
|
cfg.raw.system_prompt = trimmed;
|
|
8475
8605
|
if (trimmed) app(`System prompt saved (${trimmed.length} chars) → ${hncodeConfigFile()}`);
|
|
8476
|
-
else app('System prompt override cleared; the built-in prompt is in use again.');
|
|
8606
|
+
else app(uiText('System prompt override cleared; the built-in prompt is in use again.'));
|
|
8477
8607
|
},
|
|
8478
8608
|
});
|
|
8479
8609
|
};
|
|
@@ -8512,10 +8642,10 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8512
8642
|
}
|
|
8513
8643
|
if (it.action === 'restore') {
|
|
8514
8644
|
try { setConfigString('system_prompt', ''); }
|
|
8515
|
-
catch (e) { appErr('Could not write config.toml: ' + e.message); return true; }
|
|
8645
|
+
catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return true; }
|
|
8516
8646
|
cfg.systemPrompt = '';
|
|
8517
8647
|
cfg.raw.system_prompt = '';
|
|
8518
|
-
app('System prompt override cleared; the built-in prompt is in use again.');
|
|
8648
|
+
app(uiText('System prompt override cleared; the built-in prompt is in use again.'));
|
|
8519
8649
|
return true;
|
|
8520
8650
|
}
|
|
8521
8651
|
// Preset picker: the FAMILY is the list (↑↓), the TASK is a footer row
|
|
@@ -8575,7 +8705,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8575
8705
|
caretCol: 0,
|
|
8576
8706
|
onSave: (value) => {
|
|
8577
8707
|
try { writePersonalPrompt(scope, workspace, value); }
|
|
8578
|
-
catch (e) { appErr('Could not write ' + file + ': ' + e.message); return; }
|
|
8708
|
+
catch (e) { appErr(uiText('Could not write ') + file + ': ' + e.message); return; }
|
|
8579
8709
|
if (String(value).trim()) app(`Personal preferences saved (${scope}) → ${file}`);
|
|
8580
8710
|
else app(`Personal preferences cleared (${scope}); nothing will be injected.`);
|
|
8581
8711
|
},
|
|
@@ -8599,7 +8729,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8599
8729
|
});
|
|
8600
8730
|
return;
|
|
8601
8731
|
}
|
|
8602
|
-
appErr('Usage: /personal [global|project]');
|
|
8732
|
+
appErr(uiText('Usage: /personal [global|project]'));
|
|
8603
8733
|
return;
|
|
8604
8734
|
}
|
|
8605
8735
|
|
|
@@ -8620,7 +8750,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8620
8750
|
caretCol: 0,
|
|
8621
8751
|
onSave: (value) => {
|
|
8622
8752
|
try { writeMemoryRaw(scope, workspace, value); }
|
|
8623
|
-
catch (e) { appErr('Could not write ' + file + ': ' + e.message); return; }
|
|
8753
|
+
catch (e) { appErr(uiText('Could not write ') + file + ': ' + e.message); return; }
|
|
8624
8754
|
if (String(value).trim()) app(`Agent memory saved (${scope}) → ${file}`);
|
|
8625
8755
|
else app(`Agent memory cleared (${scope}); nothing will be injected.`);
|
|
8626
8756
|
},
|
|
@@ -8642,7 +8772,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8642
8772
|
onPick: (it) => {
|
|
8643
8773
|
const file = memoryFile(it.label, workspace);
|
|
8644
8774
|
try { writeMemoryRaw(it.label, workspace, ''); }
|
|
8645
|
-
catch (e) { appErr('Could not clear ' + file + ': ' + e.message); return true; }
|
|
8775
|
+
catch (e) { appErr(uiText('Could not clear ') + file + ': ' + e.message); return true; }
|
|
8646
8776
|
app(`Agent memory cleared (${it.label}) — ${file}`);
|
|
8647
8777
|
return true;
|
|
8648
8778
|
},
|
|
@@ -8662,7 +8792,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8662
8792
|
});
|
|
8663
8793
|
return;
|
|
8664
8794
|
}
|
|
8665
|
-
appErr('Usage: /memory [global|project|clear]');
|
|
8795
|
+
appErr(uiText('Usage: /memory [global|project|clear]'));
|
|
8666
8796
|
return;
|
|
8667
8797
|
}
|
|
8668
8798
|
|
|
@@ -8683,7 +8813,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8683
8813
|
caretCol: 0,
|
|
8684
8814
|
onSave: (value) => {
|
|
8685
8815
|
try { fs.writeFileSync(file, String(value)); }
|
|
8686
|
-
catch (e) { appErr('Could not write ' + file + ': ' + e.message); return; }
|
|
8816
|
+
catch (e) { appErr(uiText('Could not write ') + file + ': ' + e.message); return; }
|
|
8687
8817
|
// Re-read so the new rules apply on the NEXT tool call, without a restart.
|
|
8688
8818
|
const fresh = resolveConfig();
|
|
8689
8819
|
cfg.permissions = fresh.permissions;
|
|
@@ -8724,7 +8854,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8724
8854
|
appErr(`${selfTest.failed.length} rule example(s) failed — see /permissions.`);
|
|
8725
8855
|
}
|
|
8726
8856
|
if (!n('allow') && !n('ask') && !n('deny')) {
|
|
8727
|
-
app('No permission rules set — /permissions edit to add some.');
|
|
8857
|
+
app(uiText('No permission rules set — /permissions edit to add some.'));
|
|
8728
8858
|
}
|
|
8729
8859
|
return;
|
|
8730
8860
|
}
|
|
@@ -8743,21 +8873,21 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8743
8873
|
if (a === 'on' || a === 'true' || a === 'yes' || a === '1') want = true;
|
|
8744
8874
|
else if (a === 'off' || a === 'false' || a === 'no' || a === '0') want = false;
|
|
8745
8875
|
else if (a === '') want = !cur;
|
|
8746
|
-
else { appErr('Usage: /external [on|off]'); return; }
|
|
8876
|
+
else { appErr(uiText('Usage: /external [on|off]')); return; }
|
|
8747
8877
|
|
|
8748
8878
|
const envForced = process.env.HNCODE_ALLOW_EXTERNAL === '1';
|
|
8749
8879
|
try { setConfigBool('tool_allow_external_paths', want); }
|
|
8750
|
-
catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
|
|
8880
|
+
catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
|
|
8751
8881
|
cfg.allowExternal = want;
|
|
8752
8882
|
if (cfg.raw) cfg.raw.tool_allow_external_paths = want;
|
|
8753
8883
|
// Push it into the RUNNING agent too: it snapshotted cfg at construction, so
|
|
8754
8884
|
// without this the switch would only take effect on the next turn.
|
|
8755
8885
|
if (state.agent && state.agent.ctx) state.agent.ctx.allowExternal = want;
|
|
8756
8886
|
app(want
|
|
8757
|
-
? 'External paths: ON — tools may read and write outside the workspace.'
|
|
8887
|
+
? uiText('External paths: ON — tools may read and write outside the workspace.')
|
|
8758
8888
|
: 'External paths: OFF — tools are confined to the workspace.');
|
|
8759
8889
|
if (envForced && !want) {
|
|
8760
|
-
appErr('Note: HNCODE_ALLOW_EXTERNAL=1 is set, so access stays ON until you unset it.');
|
|
8890
|
+
appErr(uiText('Note: HNCODE_ALLOW_EXTERNAL=1 is set, so access stays ON until you unset it.'));
|
|
8761
8891
|
}
|
|
8762
8892
|
return;
|
|
8763
8893
|
}
|
|
@@ -8773,10 +8903,10 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8773
8903
|
// of a stable address and a stable token.
|
|
8774
8904
|
const a = raw.trim();
|
|
8775
8905
|
if (a.toLowerCase() === 'off' || a.toLowerCase() === 'stop') {
|
|
8776
|
-
app(h.stopWeb() ? 'Web UI stopped (this session is no longer listed).' : 'Web UI is not running.');
|
|
8906
|
+
app(h.stopWeb() ? uiText('Web UI stopped (this session is no longer listed).') : uiText('Web UI is not running.'));
|
|
8777
8907
|
return;
|
|
8778
8908
|
}
|
|
8779
|
-
if (!h.startWebGlobal) { appErr('Web UI is unavailable in this build.'); return; }
|
|
8909
|
+
if (!h.startWebGlobal) { appErr(uiText('Web UI is unavailable in this build.')); return; }
|
|
8780
8910
|
// Optional "[bindIp] [port]" — the same shapes `--web` accepts. The old
|
|
8781
8911
|
// code threw these away and always bound loopback, so `/web 0.0.0.0` looked
|
|
8782
8912
|
// like it worked while nothing was reachable from the network.
|
|
@@ -8795,7 +8925,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8795
8925
|
sayPanel([
|
|
8796
8926
|
`Web UI (this session only): ${srv.url}`,
|
|
8797
8927
|
'',
|
|
8798
|
-
'The machine-wide daemon is unavailable, so this session is served',
|
|
8928
|
+
uiText('The machine-wide daemon is unavailable, so this session is served'),
|
|
8799
8929
|
'directly. Open the address above; the token is below.',
|
|
8800
8930
|
'',
|
|
8801
8931
|
` ${srv.token}`,
|
|
@@ -8810,15 +8940,15 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8810
8940
|
`Bind: ${daemon.host}:${daemon.port}${lan ? ' (reachable from the network)' : ' (this machine only)'}`,
|
|
8811
8941
|
daemon.spawned ? 'Daemon: started (was not running)' : 'Daemon: reused (already running)',
|
|
8812
8942
|
'',
|
|
8813
|
-
'The root page lists every workspace and session — running ones live,',
|
|
8943
|
+
uiText('The root page lists every workspace and session — running ones live,'),
|
|
8814
8944
|
'finished ones from disk. The token below is stored in config.toml, so',
|
|
8815
8945
|
'it stays the same across restarts.',
|
|
8816
8946
|
'',
|
|
8817
|
-
'Access token (paste it into the login page):',
|
|
8947
|
+
uiText('Access token (paste it into the login page):'),
|
|
8818
8948
|
'',
|
|
8819
8949
|
` ${token || srv.token}`,
|
|
8820
8950
|
'',
|
|
8821
|
-
'Anyone with this token can run commands as you. Stop this session with',
|
|
8951
|
+
uiText('Anyone with this token can run commands as you. Stop this session with'),
|
|
8822
8952
|
'/web off.',
|
|
8823
8953
|
].join('\n'));
|
|
8824
8954
|
notice(`Web UI at ${daemon.rootUrl}`);
|
|
@@ -8842,17 +8972,17 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8842
8972
|
if (a === 'on') want = true;
|
|
8843
8973
|
else if (a === 'off') want = false;
|
|
8844
8974
|
else if (a === '') want = !cfg.calmMode;
|
|
8845
|
-
else { appErr('Usage: /calm-mode [on|off]'); return; }
|
|
8975
|
+
else { appErr(uiText('Usage: /calm-mode [on|off]')); return; }
|
|
8846
8976
|
try { setConfigString('calm_mode', want ? 'true' : 'false'); }
|
|
8847
|
-
catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
|
|
8977
|
+
catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
|
|
8848
8978
|
cfg.calmMode = want;
|
|
8849
8979
|
cfg.raw.calm_mode = want;
|
|
8850
|
-
app(
|
|
8980
|
+
app(`${uiText('Calm mode')}: ${want ? uiText('ON — the model will keep explanations to a minimum') : uiText('OFF')}`);
|
|
8851
8981
|
return;
|
|
8852
8982
|
}
|
|
8853
8983
|
|
|
8854
8984
|
case 'init': {
|
|
8855
|
-
if (!cfg.model) { appErr('LLM not set. Configure a provider with /provider first.'); return; }
|
|
8985
|
+
if (!cfg.model) { appErr(uiText('LLM not set. Configure a provider with /provider first.')); return; }
|
|
8856
8986
|
// Optional free-text instructions, like /compact's optional ratio: whatever
|
|
8857
8987
|
// the user types after `/init` steers what goes into the file (e.g.
|
|
8858
8988
|
// `/init focus on the tRPC routers and our migration rules`). With no
|
|
@@ -8898,16 +9028,16 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8898
9028
|
else say('No goal set. Start one with /goal <objective>.');
|
|
8899
9029
|
return;
|
|
8900
9030
|
}
|
|
8901
|
-
if (a === 'pause') { applyGoal(state.objective, true); app('Goal paused. Use /goal resume to continue.'); return; }
|
|
9031
|
+
if (a === 'pause') { applyGoal(state.objective, true); app(uiText('Goal paused. Use /goal resume to continue.')); return; }
|
|
8902
9032
|
if (a === 'resume') {
|
|
8903
|
-
if (!state.objective) { app('No goal to resume.'); return; }
|
|
9033
|
+
if (!state.objective) { app(uiText('No goal to resume.')); return; }
|
|
8904
9034
|
applyGoal(state.objective, false);
|
|
8905
|
-
app('Goal resumed.');
|
|
9035
|
+
app(uiText('Goal resumed.'));
|
|
8906
9036
|
sendPrompt('Resume the active goal.');
|
|
8907
9037
|
return;
|
|
8908
9038
|
}
|
|
8909
|
-
if (a === 'cancel') { applyGoal('', false); app('Goal cancelled.'); return; }
|
|
8910
|
-
if (a.startsWith('replace ')) { applyGoal(raw.slice(8).trim(), false); app('Goal replaced.'); return; }
|
|
9039
|
+
if (a === uiText('cancel')) { applyGoal('', false); app(uiText('Goal cancelled.')); return; }
|
|
9040
|
+
if (a.startsWith('replace ')) { applyGoal(raw.slice(8).trim(), false); app(uiText('Goal replaced.')); return; }
|
|
8911
9041
|
applyGoal(raw, false);
|
|
8912
9042
|
app(`Goal set: ${raw}`);
|
|
8913
9043
|
// TELL THE MODEL IT IS IN GOAL MODE.
|
|
@@ -8975,13 +9105,15 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
8975
9105
|
h.openPanel(title, [
|
|
8976
9106
|
...panel,
|
|
8977
9107
|
tr('tui.help.skills', 'Skills'),
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
`
|
|
8981
|
-
` /
|
|
8982
|
-
` /skills
|
|
8983
|
-
` /
|
|
8984
|
-
` /
|
|
9108
|
+
// A fixed command column keeps the descriptions aligned even though one command
|
|
9109
|
+
// is much longer than the rest; hand-spaced strings drifted as commands changed.
|
|
9110
|
+
` ${`/${SKILL_PREFIX}<name>`.padEnd(38)} ${tr('tui.help.skillRun', 'run an installed skill (Tab completes the name)')}`,
|
|
9111
|
+
` ${'/import-skill <file.md | owner/repo>'.padEnd(38)} ${tr('tui.help.skillImport', 'add a skill from a file, or install a repository of them')}`,
|
|
9112
|
+
` ${'/skills'.padEnd(38)} ${tr('tui.help.skillOpen', 'open the skill manager (Tab switches tabs)')}`,
|
|
9113
|
+
` ${'/skills install <name>'.padEnd(38)} ${tr('tui.help.skillInstall', 'download one from the repo, without the panel')}`,
|
|
9114
|
+
` ${'/skills remove <name>'.padEnd(38)} ${tr('tui.help.skillRemove', 'delete the local copy')}`,
|
|
9115
|
+
` ${'/plugins'.padEnd(38)} ${tr('tui.help.pluginOpen', 'open the plugin manager')}`,
|
|
9116
|
+
` ${'/plugins install <name>'.padEnd(38)} ${tr('tui.help.pluginInstall', 'download one from the repo')}`,
|
|
8985
9117
|
'',
|
|
8986
9118
|
tr('tui.help.shortcuts', 'Shortcuts'),
|
|
8987
9119
|
` Enter ${tr('tui.key.send', 'send the message')}`,
|
|
@@ -9031,32 +9163,32 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9031
9163
|
const g = C.gray, w = C.white, b = C.bold;
|
|
9032
9164
|
const u = state.usage || {};
|
|
9033
9165
|
const lines = [
|
|
9034
|
-
w + b + 'Session usage' + C.reset,
|
|
9035
|
-
' ' + g + 'messages ' + C.reset + w + msgs.length + C.reset,
|
|
9166
|
+
w + b + uiText('Session usage') + C.reset,
|
|
9167
|
+
' ' + g + uiText('messages') + ' ' + C.reset + w + msgs.length + C.reset,
|
|
9036
9168
|
];
|
|
9037
9169
|
// Provider-reported totals when there are any: they are what the model
|
|
9038
9170
|
// actually billed. The estimate is the fallback for an endpoint that reports
|
|
9039
9171
|
// nothing (or predates `stream_options`).
|
|
9040
9172
|
if (u.calls) {
|
|
9041
9173
|
const cr = u.input ? Math.round((u.cached || 0) / u.input * 100) : 0;
|
|
9042
|
-
lines.push(' ' + g + 'requests ' + C.reset + w + fmtCount(u.calls) + C.reset);
|
|
9043
|
-
lines.push(' ' + g + 'input tokens ' + C.reset + w + fmtCount(u.input || 0) + C.reset
|
|
9174
|
+
lines.push(' ' + g + uiText('requests') + ' ' + C.reset + w + fmtCount(u.calls) + C.reset);
|
|
9175
|
+
lines.push(' ' + g + uiText('input tokens') + ' ' + C.reset + w + fmtCount(u.input || 0) + C.reset
|
|
9044
9176
|
+ (u.cached ? g + ` (${cr}% cached)` + C.reset : ''));
|
|
9045
|
-
lines.push(' ' + g + 'output tokens ' + C.reset + w + fmtCount(u.output || 0) + C.reset);
|
|
9177
|
+
lines.push(' ' + g + uiText('output tokens') + ' ' + C.reset + w + fmtCount(u.output || 0) + C.reset);
|
|
9046
9178
|
if (u.reasoning) {
|
|
9047
|
-
lines.push(' ' + g + 'reasoning ' + C.reset + w + fmtCount(u.reasoning) + C.reset
|
|
9179
|
+
lines.push(' ' + g + uiText('reasoning') + ' ' + C.reset + w + fmtCount(u.reasoning) + C.reset
|
|
9048
9180
|
+ g + ' included in output' + C.reset);
|
|
9049
9181
|
}
|
|
9050
|
-
lines.push(' ' + g + 'total tokens ' + C.reset + w + fmtCount((u.input || 0) + (u.output || 0)) + C.reset);
|
|
9051
|
-
lines.push(' ' + g + 'est. cost ' + C.reset + formatCost(usageCost(u, modelCost(cfg))) + C.reset);
|
|
9182
|
+
lines.push(' ' + g + uiText('total tokens') + ' ' + C.reset + w + fmtCount((u.input || 0) + (u.output || 0)) + C.reset);
|
|
9183
|
+
lines.push(' ' + g + uiText('est. cost') + ' ' + C.reset + formatCost(usageCost(u, modelCost(cfg))) + C.reset);
|
|
9052
9184
|
} else {
|
|
9053
|
-
lines.push(' ' + g + 'approx tokens ' + C.reset + w + fmtCount(approx) + C.reset);
|
|
9054
|
-
lines.push(' ' + g + 'token totals ' + C.reset + C.gray
|
|
9185
|
+
lines.push(' ' + g + uiText('approx tokens') + ' ' + C.reset + w + fmtCount(approx) + C.reset);
|
|
9186
|
+
lines.push(' ' + g + uiText('token totals') + ' ' + C.reset + C.gray
|
|
9055
9187
|
+ 'not reported by this endpoint yet' + C.reset);
|
|
9056
9188
|
}
|
|
9057
9189
|
lines.push('');
|
|
9058
|
-
lines.push(w + b + 'Context window' + C.reset);
|
|
9059
|
-
lines.push(' ' + g + 'used ' + C.reset + w + `${state.ctxPercent}% `
|
|
9190
|
+
lines.push(w + b + uiText('Context window') + C.reset);
|
|
9191
|
+
lines.push(' ' + g + uiText('used') + ' ' + C.reset + w + `${state.ctxPercent}% `
|
|
9060
9192
|
+ g + `(${fmtTokens(state.ctxTokens)} / ${fmtTokens(state.ctxMax)})` + C.reset);
|
|
9061
9193
|
|
|
9062
9194
|
// WHAT THE REQUEST IS MADE OF, itemised.
|
|
@@ -9071,13 +9203,13 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9071
9203
|
.reduce((n, m) => n + messageTokens(m, cfg), 0);
|
|
9072
9204
|
const toolTokens = cfg.toolDefTokens || 0;
|
|
9073
9205
|
const rows = [
|
|
9074
|
-
['system prompt', sysTokens],
|
|
9075
|
-
['conversation', convTokens],
|
|
9076
|
-
['tool schemas', toolTokens],
|
|
9206
|
+
[uiText('system prompt'), sysTokens],
|
|
9207
|
+
[uiText('conversation'), convTokens],
|
|
9208
|
+
[uiText('tool schemas'), toolTokens],
|
|
9077
9209
|
].filter(([, v]) => v > 0).sort((a, b) => b[1] - a[1]);
|
|
9078
9210
|
if (rows.length) {
|
|
9079
9211
|
lines.push('');
|
|
9080
|
-
lines.push(w + b + 'Where it goes' + C.reset);
|
|
9212
|
+
lines.push(w + b + uiText('Where it goes') + C.reset);
|
|
9081
9213
|
for (const [label, v] of rows) {
|
|
9082
9214
|
const share = state.ctxTokens ? Math.round((v / state.ctxTokens) * 100) : 0;
|
|
9083
9215
|
lines.push(' ' + g + label.padEnd(14) + C.reset + w + fmtTokens(v).padStart(8) + C.reset
|
|
@@ -9149,7 +9281,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9149
9281
|
|
|
9150
9282
|
if (byTool.size) {
|
|
9151
9283
|
lines.push('');
|
|
9152
|
-
lines.push(w + b + 'Tools used' + C.reset);
|
|
9284
|
+
lines.push(w + b + uiText('Tools used') + C.reset);
|
|
9153
9285
|
// MOST-USED FIRST: a list in call order is a history of the session, which the transcript already is.
|
|
9154
9286
|
for (const [name, n] of [...byTool.entries()].sort((a, c) => c[1] - a[1])) {
|
|
9155
9287
|
row(name, fmtCount(n));
|
|
@@ -9158,7 +9290,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9158
9290
|
|
|
9159
9291
|
if (files.size) {
|
|
9160
9292
|
lines.push('');
|
|
9161
|
-
lines.push(w + b + 'Files touched' + C.reset + g + ` (${files.size})` + C.reset);
|
|
9293
|
+
lines.push(w + b + uiText('Files touched') + C.reset + g + ` (${files.size})` + C.reset);
|
|
9162
9294
|
// SORTED, because the set is built from calls that can repeat a path; the count is what matters, not order.
|
|
9163
9295
|
for (const f of [...files].sort()) lines.push(' ' + w + f + C.reset);
|
|
9164
9296
|
}
|
|
@@ -9167,10 +9299,10 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9167
9299
|
if (u.calls) {
|
|
9168
9300
|
lines.push('');
|
|
9169
9301
|
lines.push(w + b + 'Spend' + C.reset);
|
|
9170
|
-
row('requests', fmtCount(u.calls));
|
|
9302
|
+
row(uiText('requests'), fmtCount(u.calls));
|
|
9171
9303
|
row('tokens', fmtCount((u.input || 0) + (u.output || 0)),
|
|
9172
9304
|
`${fmtCount(u.input || 0)} in · ${fmtCount(u.output || 0)} out`);
|
|
9173
|
-
row('est. cost', formatCost(usageCost(u, modelCost(cfg))));
|
|
9305
|
+
row(uiText('est. cost'), formatCost(usageCost(u, modelCost(cfg))));
|
|
9174
9306
|
}
|
|
9175
9307
|
sayRich(lines.join('\n'));
|
|
9176
9308
|
return;
|
|
@@ -9193,7 +9325,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9193
9325
|
const current = costCurrency(cfg);
|
|
9194
9326
|
if (asked && asked !== current) {
|
|
9195
9327
|
try { setConfigString('cost_currency', asked); }
|
|
9196
|
-
catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
|
|
9328
|
+
catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
|
|
9197
9329
|
cfg.raw.cost_currency = asked;
|
|
9198
9330
|
}
|
|
9199
9331
|
const wantCurrency = asked || current;
|
|
@@ -9222,9 +9354,9 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9222
9354
|
sayRich(lines.join('\n'));
|
|
9223
9355
|
return;
|
|
9224
9356
|
}
|
|
9225
|
-
lines.push(' ' + g + 'requests ' + C.reset + w + fmtCount(u.calls) + C.reset);
|
|
9357
|
+
lines.push(' ' + g + uiText('requests') + ' ' + C.reset + w + fmtCount(u.calls) + C.reset);
|
|
9226
9358
|
lines.push(' ' + g + 'input tokens ' + C.reset + w + fmtCount(u.input || 0) + C.reset);
|
|
9227
|
-
lines.push(' ' + g + 'output tokens ' + C.reset + w + fmtCount(u.output || 0) + C.reset);
|
|
9359
|
+
lines.push(' ' + g + uiText('output tokens') + ' ' + C.reset + w + fmtCount(u.output || 0) + C.reset);
|
|
9228
9360
|
if (u.cached) lines.push(' ' + g + 'cache reads ' + C.reset + w + fmtCount(u.cached) + C.reset);
|
|
9229
9361
|
if (u.cacheWrite) lines.push(' ' + g + 'cache writes ' + C.reset + w + fmtCount(u.cacheWrite) + C.reset);
|
|
9230
9362
|
lines.push('');
|
|
@@ -9233,7 +9365,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9233
9365
|
// direction that matters. Say the price is unknown, and show the exact TOML
|
|
9234
9366
|
// to paste — a self-hosted or gateway provider (a local proxy, a company
|
|
9235
9367
|
// endpoint) has no entry in models.dev, so the user is the only source.
|
|
9236
|
-
lines.push(' ' + C.red + 'No pricing for this model.' + C.reset);
|
|
9368
|
+
lines.push(' ' + C.red + uiText('No pricing for this model.') + C.reset);
|
|
9237
9369
|
lines.push(' ' + g + 'A provider not added from the models.dev catalog has no' + C.reset);
|
|
9238
9370
|
lines.push(' ' + g + 'price to read. Add one to config.toml:' + C.reset);
|
|
9239
9371
|
lines.push('');
|
|
@@ -9261,7 +9393,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9261
9393
|
lines.push(' ' + w + b + 'estimated total ' + C.reset
|
|
9262
9394
|
+ formatCost(local, wantCurrency) + g + ` (${formatCost(usdCost)} @ ${fx.rate})` + C.reset);
|
|
9263
9395
|
lines.push(' ' + g + `rate ${fx.rate} ${wantCurrency}/USD — ${fx.source}` + C.reset);
|
|
9264
|
-
lines.push(' ' + g + 'Switch back with /cost usd.' + C.reset);
|
|
9396
|
+
lines.push(' ' + g + uiText('Switch back with /cost usd.') + C.reset);
|
|
9265
9397
|
}
|
|
9266
9398
|
sayRich(lines.join('\n'));
|
|
9267
9399
|
return;
|
|
@@ -9274,14 +9406,14 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9274
9406
|
if (a === 'on') want = true;
|
|
9275
9407
|
else if (a === 'off') want = false;
|
|
9276
9408
|
else if (a === '') want = !state.rawMode;
|
|
9277
|
-
else { appErr('Usage: /raw [on|off]'); return; }
|
|
9409
|
+
else { appErr(uiText('Usage: /raw [on|off]')); return; }
|
|
9278
9410
|
state.rawMode = want;
|
|
9279
9411
|
// The layout cache keys on rawMode (see metricsSignature), so invalidating the
|
|
9280
9412
|
// metrics memo is enough — but the per-message row caches also carry it, and
|
|
9281
9413
|
// both are keyed on it now, so nothing else has to be dropped here.
|
|
9282
9414
|
state._metrics = null;
|
|
9283
9415
|
app(want
|
|
9284
|
-
? 'Raw mode: ON — replies shown exactly as the model sent them.'
|
|
9416
|
+
? uiText('Raw mode: ON — replies shown exactly as the model sent them.')
|
|
9285
9417
|
: 'Raw mode: OFF — Markdown rendering restored.');
|
|
9286
9418
|
return;
|
|
9287
9419
|
}
|
|
@@ -9294,11 +9426,11 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9294
9426
|
if (a === 'on') want = true;
|
|
9295
9427
|
else if (a === 'off') want = false;
|
|
9296
9428
|
else if (a === '') want = !state.reducedMotion;
|
|
9297
|
-
else { appErr('Usage: /reduced-motion [on|off]'); return; }
|
|
9429
|
+
else { appErr(uiText('Usage: /reduced-motion [on|off]')); return; }
|
|
9298
9430
|
state.reducedMotion = want;
|
|
9299
9431
|
try { setConfigString('reduced_motion', want ? 'true' : 'false'); } catch (e) { appErr(`Could not save this setting: ${e.message} — it applies to this session only.`); }
|
|
9300
9432
|
app(want
|
|
9301
|
-
? 'Reduced motion: ON — animation is replaced by a slow-breathing dot.'
|
|
9433
|
+
? uiText('Reduced motion: ON — animation is replaced by a slow-breathing dot.')
|
|
9302
9434
|
: 'Reduced motion: OFF — animation restored.');
|
|
9303
9435
|
return;
|
|
9304
9436
|
}
|
|
@@ -9311,7 +9443,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9311
9443
|
app(`Shimmer edge: ${state.shimmerEdge}. /shimmer-edge cosine | linear`);
|
|
9312
9444
|
return;
|
|
9313
9445
|
}
|
|
9314
|
-
if (a !== 'cosine' && a !== 'linear') { appErr('Usage: /shimmer-edge cosine|linear'); return; }
|
|
9446
|
+
if (a !== 'cosine' && a !== 'linear') { appErr(uiText('Usage: /shimmer-edge cosine|linear')); return; }
|
|
9315
9447
|
state.shimmerEdge = a;
|
|
9316
9448
|
try { setConfigString('shimmer_edge', a); } catch (e) { appErr(`Could not save this setting: ${e.message} — it applies to this session only.`); }
|
|
9317
9449
|
app(`Shimmer edge: ${a}.`);
|
|
@@ -9327,19 +9459,19 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9327
9459
|
state.outputStyle = null;
|
|
9328
9460
|
cfg.outputStyle = null;
|
|
9329
9461
|
try { setConfigString('output_style', ''); } catch (e) { appErr(`Could not save this setting: ${e.message} — it applies to this session only.`); }
|
|
9330
|
-
app('Output style cleared.');
|
|
9462
|
+
app(uiText('Output style cleared.'));
|
|
9331
9463
|
return;
|
|
9332
9464
|
}
|
|
9333
9465
|
if (lower === 'edit') {
|
|
9334
9466
|
const file = state.outputStyle && state.outputStyle.file;
|
|
9335
|
-
if (!file) { appErr('No style selected. Pick one with /output-style, or create one with /output-style new <name>.'); return; }
|
|
9467
|
+
if (!file) { appErr(uiText('No style selected. Pick one with /output-style, or create one with /output-style new <name>.')); return; }
|
|
9336
9468
|
openEditor({
|
|
9337
9469
|
title: `Output style — ${file}`,
|
|
9338
9470
|
text: (() => { try { return fs.readFileSync(file, 'utf8'); } catch { return ''; } })(),
|
|
9339
9471
|
caretRow: 0, caretCol: 0,
|
|
9340
9472
|
onSave: (value) => {
|
|
9341
9473
|
try { fs.writeFileSync(file, String(value)); }
|
|
9342
|
-
catch (e) { appErr('Could not write ' + file + ': ' + e.message); return; }
|
|
9474
|
+
catch (e) { appErr(uiText('Could not write ') + file + ': ' + e.message); return; }
|
|
9343
9475
|
// Re-read so an edit takes effect on the NEXT request.
|
|
9344
9476
|
const again = findStyle(state.outputStyle.name, state.cwd);
|
|
9345
9477
|
state.outputStyle = again;
|
|
@@ -9358,7 +9490,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9358
9490
|
text: (() => { try { return fs.readFileSync(file, 'utf8'); } catch { return ''; } })(),
|
|
9359
9491
|
caretRow: 3, caretCol: 0,
|
|
9360
9492
|
onSave: (value) => {
|
|
9361
|
-
try { fs.writeFileSync(file, String(value)); } catch (e) { appErr('Could not write: ' + e.message); return; }
|
|
9493
|
+
try { fs.writeFileSync(file, String(value)); } catch (e) { appErr(uiText('Could not write: ') + e.message); return; }
|
|
9362
9494
|
const s = findStyle(nameFromFile(file), state.cwd);
|
|
9363
9495
|
if (s) { state.outputStyle = s; cfg.outputStyle = s.name; app(`Output style → ${s.name}`); }
|
|
9364
9496
|
else app(`Saved ${file} (no body yet, so it is not selectable).`);
|
|
@@ -9397,7 +9529,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9397
9529
|
if (it.action === 'none') {
|
|
9398
9530
|
state.outputStyle = null; cfg.outputStyle = null;
|
|
9399
9531
|
try { setConfigString('output_style', ''); } catch (e) { appErr(`Could not save this setting: ${e.message} — it applies to this session only.`); }
|
|
9400
|
-
app('Output style cleared.');
|
|
9532
|
+
app(uiText('Output style cleared.'));
|
|
9401
9533
|
return true;
|
|
9402
9534
|
}
|
|
9403
9535
|
state.outputStyle = it.style;
|
|
@@ -9448,17 +9580,17 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9448
9580
|
if (parts[1] === 'on') want = true;
|
|
9449
9581
|
else if (parts[1] === 'off') want = false;
|
|
9450
9582
|
else if (!parts[1]) want = !stateNow[name];
|
|
9451
|
-
else { appErr('Usage: /experiments <name> [on|off]'); return; }
|
|
9583
|
+
else { appErr(uiText('Usage: /experiments <name> [on|off]')); return; }
|
|
9452
9584
|
const merged = mergeExperiments(cfg.raw.experiments, { [name]: want });
|
|
9453
9585
|
try {
|
|
9454
9586
|
setConfigString('experiments', JSON.stringify(merged));
|
|
9455
|
-
} catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
|
|
9587
|
+
} catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
|
|
9456
9588
|
cfg.raw.experiments = merged;
|
|
9457
|
-
app(
|
|
9589
|
+
app(`${uiText('Experiment')} ${name}: ${want ? uiText('ON') : uiText('OFF')}`);
|
|
9458
9590
|
// A flag can only affect code that reads it, and most of them are read when a
|
|
9459
9591
|
// request is built, so the change is announced as taking effect next turn
|
|
9460
9592
|
// rather than pretending to be live.
|
|
9461
|
-
app('Takes effect on the next request.');
|
|
9593
|
+
app(uiText('Takes effect on the next request.'));
|
|
9462
9594
|
return;
|
|
9463
9595
|
}
|
|
9464
9596
|
case 'btw':
|
|
@@ -9474,10 +9606,10 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9474
9606
|
|
|
9475
9607
|
if (!question) {
|
|
9476
9608
|
// Bare `/btw`: open the box (asking nothing yet) or explain it.
|
|
9477
|
-
if (state.btwPanel) { app('The side-thread box is already open — type a question, or press Esc to close it.'); return; }
|
|
9609
|
+
if (state.btwPanel) { app(uiText('The side-thread box is already open — type a question, or press Esc to close it.')); return; }
|
|
9478
9610
|
state.btwPanel = { turns: [], model: '', reasoning: false };
|
|
9479
9611
|
state.btwScroll = 0;
|
|
9480
|
-
app('Side thread box open — type a question and press Enter. Esc closes it.');
|
|
9612
|
+
app(uiText('Side thread box open — type a question and press Enter. Esc closes it.'));
|
|
9481
9613
|
renderFrame();
|
|
9482
9614
|
return;
|
|
9483
9615
|
}
|
|
@@ -9485,7 +9617,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9485
9617
|
state.sideThread = null;
|
|
9486
9618
|
state.btwPanel = null;
|
|
9487
9619
|
state.btwScroll = 0;
|
|
9488
|
-
app('Side thread closed.');
|
|
9620
|
+
app(uiText('Side thread closed.'));
|
|
9489
9621
|
renderFrame();
|
|
9490
9622
|
return;
|
|
9491
9623
|
}
|
|
@@ -9493,7 +9625,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9493
9625
|
if (!state.sideThread) {
|
|
9494
9626
|
const modelCfg = secondaryModelCfg(cfg);
|
|
9495
9627
|
state.sideThread = new SideThread({
|
|
9496
|
-
|
|
9628
|
+
basePrompt: ((cfg.systemPrompt && String(cfg.systemPrompt).trim()) || SYSTEM_PROMPT)
|
|
9629
|
+
+ (needsThinkingTags(cfg) ? `\n\n${THINKING_TAGS_INSTRUCTION}` : ''),
|
|
9497
9630
|
// The fork: the conversation as it stands NOW. A copy, so nothing the side
|
|
9498
9631
|
// thread appends can reach the session.
|
|
9499
9632
|
history: forkMessages(session),
|
|
@@ -9517,7 +9650,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9517
9650
|
const what = String(raw || '').trim().toLowerCase();
|
|
9518
9651
|
const metrics = state._metrics;
|
|
9519
9652
|
if (!metrics || !metrics.rowStart || !state.chat.length) {
|
|
9520
|
-
app('Nothing to jump to yet.');
|
|
9653
|
+
app(uiText('Nothing to jump to yet.'));
|
|
9521
9654
|
return;
|
|
9522
9655
|
}
|
|
9523
9656
|
const totalRows = metrics.total || 0;
|
|
@@ -9543,26 +9676,26 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9543
9676
|
state.scroll = Math.max(0, Math.max(0, totalRows - 20));
|
|
9544
9677
|
dropScrollPin(state);
|
|
9545
9678
|
renderFrame();
|
|
9546
|
-
app('Jumped to the top of the session.');
|
|
9679
|
+
app(uiText('Jumped to the top of the session.'));
|
|
9547
9680
|
return;
|
|
9548
9681
|
}
|
|
9549
9682
|
if (what === 'error' || what === 'fail' || what === 'failure') {
|
|
9550
9683
|
const i = lastIndex((m) => m && (m.failed === true || (m.role === 'tool_result' && /^\s*\[?error/i.test(String(m.text || '')))));
|
|
9551
|
-
if (i < 0) { app('No failure in this session.'); return; }
|
|
9684
|
+
if (i < 0) { app(uiText('No failure in this session.')); return; }
|
|
9552
9685
|
goToRow(rowOf(i));
|
|
9553
9686
|
renderFrame();
|
|
9554
|
-
app('Jumped to the last failure.');
|
|
9687
|
+
app(uiText('Jumped to the last failure.'));
|
|
9555
9688
|
return;
|
|
9556
9689
|
}
|
|
9557
9690
|
if (what === 'reply' || what === 'answer' || what === 'last') {
|
|
9558
9691
|
const i = lastIndex((m) => m && m.role === 'assistant' && String(m.text || '').trim());
|
|
9559
|
-
if (i < 0) { app('No reply to jump to.'); return; }
|
|
9692
|
+
if (i < 0) { app(uiText('No reply to jump to.')); return; }
|
|
9560
9693
|
goToRow(rowOf(i));
|
|
9561
9694
|
renderFrame();
|
|
9562
|
-
app('Jumped to the last reply.');
|
|
9695
|
+
app(uiText('Jumped to the last reply.'));
|
|
9563
9696
|
return;
|
|
9564
9697
|
}
|
|
9565
|
-
app('Use /jump top, /jump error, or /jump reply.');
|
|
9698
|
+
app(uiText('Use /jump top, /jump error, or /jump reply.'));
|
|
9566
9699
|
return;
|
|
9567
9700
|
}
|
|
9568
9701
|
|
|
@@ -9574,7 +9707,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9574
9707
|
// a very long session does not send its opening messages to answer "where am I".
|
|
9575
9708
|
const history = forkMessages(session, { limit: 80 });
|
|
9576
9709
|
if (!history.length) {
|
|
9577
|
-
app('Nothing to recap yet — this session has no conversation.');
|
|
9710
|
+
app(uiText('Nothing to recap yet — this session has no conversation.'));
|
|
9578
9711
|
return;
|
|
9579
9712
|
}
|
|
9580
9713
|
const modelCfg = secondaryModelCfg(cfg);
|
|
@@ -9582,8 +9715,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9582
9715
|
notice(`Recapping (${modelCfg.model || cfg.model})…`, 'info');
|
|
9583
9716
|
try {
|
|
9584
9717
|
const text = await llm.requestText(recapMessages(history), { noTools: true, noReasoning: true });
|
|
9585
|
-
if (text === null) { appErr('The recap request failed.'); return; }
|
|
9586
|
-
if (!text.trim()) { appErr('The recap came back empty.'); return; }
|
|
9718
|
+
if (text === null) { appErr(uiText('The recap request failed.')); return; }
|
|
9719
|
+
if (!text.trim()) { appErr(uiText('The recap came back empty.')); return; }
|
|
9587
9720
|
h.openPanel('Recap', [
|
|
9588
9721
|
`${stats.users} prompt(s), ${stats.assistants} repl(y|ies), ${stats.total} entries`,
|
|
9589
9722
|
'',
|
|
@@ -9613,7 +9746,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9613
9746
|
onPick: (it) => {
|
|
9614
9747
|
const value = it.action === 'off' ? '' : it.model;
|
|
9615
9748
|
try { setConfigString('secondary_model', value); }
|
|
9616
|
-
catch (e) { appErr('Could not write config.toml: ' + e.message); return true; }
|
|
9749
|
+
catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return true; }
|
|
9617
9750
|
cfg.secondaryModel = value;
|
|
9618
9751
|
cfg.raw.secondary_model = value;
|
|
9619
9752
|
app(value ? `Secondary model → ${value}` : 'Secondary model cleared — side work uses this session\'s model.');
|
|
@@ -9626,7 +9759,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9626
9759
|
try { setConfigString('secondary_model', ''); } catch (e) { appErr(e.message); return; }
|
|
9627
9760
|
cfg.secondaryModel = '';
|
|
9628
9761
|
cfg.raw.secondary_model = '';
|
|
9629
|
-
app('Secondary model cleared.');
|
|
9762
|
+
app(uiText('Secondary model cleared.'));
|
|
9630
9763
|
return;
|
|
9631
9764
|
}
|
|
9632
9765
|
// Accept a partial name, like /model does, so the user does not have to type the
|
|
@@ -9646,7 +9779,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9646
9779
|
case 'rollout': {
|
|
9647
9780
|
// Step through the session. A read-only VIEW: nothing is resumed or re-sent.
|
|
9648
9781
|
const steps = buildSteps(session.messages);
|
|
9649
|
-
if (!steps.length) { app('This session has nothing to replay.'); return; }
|
|
9782
|
+
if (!steps.length) { app(uiText('This session has nothing to replay.')); return; }
|
|
9650
9783
|
const arg = raw.trim().toLowerCase();
|
|
9651
9784
|
const pos = (() => {
|
|
9652
9785
|
const cur = Number.isFinite(state.replayStep) ? state.replayStep : steps.length - 1;
|
|
@@ -9683,7 +9816,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9683
9816
|
sendPrompt(entry.prompt, { fromSchedule: id });
|
|
9684
9817
|
return;
|
|
9685
9818
|
}
|
|
9686
|
-
if (sub && sub !== 'list') { appErr('Usage: /schedule [list | run <id>]'); return; }
|
|
9819
|
+
if (sub && sub !== 'list') { appErr(uiText('Usage: /schedule [list | run <id>]')); return; }
|
|
9687
9820
|
const rows = listSchedules(cfg.schedule);
|
|
9688
9821
|
const bad = rows.filter((e) => !e.valid);
|
|
9689
9822
|
h.openPanel('Schedules', [
|
|
@@ -9707,7 +9840,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9707
9840
|
const sub = (parts[0] || '').toLowerCase();
|
|
9708
9841
|
if (sub === 'import') {
|
|
9709
9842
|
const file = parts.slice(1).join(' ');
|
|
9710
|
-
if (!file) { appErr('Usage: /teleport import <file>'); return; }
|
|
9843
|
+
if (!file) { appErr(uiText('Usage: /teleport import <file>')); return; }
|
|
9711
9844
|
let text = '';
|
|
9712
9845
|
try { text = fs.readFileSync(file, 'utf8'); }
|
|
9713
9846
|
catch (e) { appErr(`Could not read ${file}: ${e.message}`); return; }
|
|
@@ -9724,7 +9857,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9724
9857
|
app(`Imported "${imported.title || 'untitled'}" as ${imported.id} — resume it with /sessions.`);
|
|
9725
9858
|
return;
|
|
9726
9859
|
}
|
|
9727
|
-
if (sub && sub !== 'export') { appErr('Usage: /teleport [export [path] | import <file>]'); return; }
|
|
9860
|
+
if (sub && sub !== 'export') { appErr(uiText('Usage: /teleport [export [path] | import <file>]')); return; }
|
|
9728
9861
|
const pack = packSession(session, {
|
|
9729
9862
|
from: state.workspace || cfg.workspace,
|
|
9730
9863
|
to: state.workspace || cfg.workspace,
|
|
@@ -9740,11 +9873,11 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9740
9873
|
'',
|
|
9741
9874
|
describeTeleport(pack),
|
|
9742
9875
|
'',
|
|
9743
|
-
'What travels: the conversation, with paths rewritten.',
|
|
9744
|
-
'What does not: background jobs, token totals, and session approvals —',
|
|
9876
|
+
uiText('What travels: the conversation, with paths rewritten.'),
|
|
9877
|
+
uiText('What does not: background jobs, token totals, and session approvals —'),
|
|
9745
9878
|
'those describe THIS machine and would be wrong on another.',
|
|
9746
9879
|
'',
|
|
9747
|
-
'Move it with scp/ssh, then on the other side:',
|
|
9880
|
+
uiText('Move it with scp/ssh, then on the other side:'),
|
|
9748
9881
|
` /teleport import ${path.basename(out)}`,
|
|
9749
9882
|
]);
|
|
9750
9883
|
return;
|
|
@@ -9789,9 +9922,9 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9789
9922
|
}
|
|
9790
9923
|
// Advice, only when there is something worth saying.
|
|
9791
9924
|
const tips = [];
|
|
9792
|
-
if (byRole.tool > total * 0.4) tips.push('Tool results dominate — /compact or a narrower search would free the most.');
|
|
9793
|
-
if (byRole.system > total * 0.3) tips.push('The system prompt is large — trim AGENTS.md / personal prompt.');
|
|
9794
|
-
if (total / max > 0.8) tips.push('Over 80% — auto-compaction is close. /compact now to keep control.');
|
|
9925
|
+
if (byRole.tool > total * 0.4) tips.push(uiText('Tool results dominate — /compact or a narrower search would free the most.'));
|
|
9926
|
+
if (byRole.system > total * 0.3) tips.push(uiText('The system prompt is large — trim AGENTS.md / personal prompt.'));
|
|
9927
|
+
if (total / max > 0.8) tips.push(uiText('Over 80% — auto-compaction is close. /compact now to keep control.'));
|
|
9795
9928
|
if (tips.length) lines.push('', ...tips.map((t) => g + ' ' + t + C.reset));
|
|
9796
9929
|
sayRich(lines.join('\n'));
|
|
9797
9930
|
return;
|
|
@@ -9855,11 +9988,11 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9855
9988
|
else if (a === 'off') want = false;
|
|
9856
9989
|
else want = !cfg.autoUpdate;
|
|
9857
9990
|
try { setConfigString('auto_update', want ? 'true' : 'false'); }
|
|
9858
|
-
catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
|
|
9991
|
+
catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
|
|
9859
9992
|
cfg.autoUpdate = want;
|
|
9860
9993
|
cfg.raw.auto_update = want;
|
|
9861
9994
|
app(want
|
|
9862
|
-
? 'Auto-update ON — checks npm at startup and every 30 min, installs in the background'
|
|
9995
|
+
? uiText('Auto-update ON — checks npm at startup and every 30 min, installs in the background')
|
|
9863
9996
|
: 'Auto-update OFF');
|
|
9864
9997
|
return;
|
|
9865
9998
|
}
|
|
@@ -9886,7 +10019,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9886
10019
|
if (v === null) { appErr(`Usage: /auto-compact ${sub} <0-1 | n%> (e.g. ${sub === 'threshold' ? '0.85 or 85%' : '0.2 or 20%'})`); return; }
|
|
9887
10020
|
const key = sub === 'threshold' ? 'compact_threshold' : 'compact_keep_ratio';
|
|
9888
10021
|
try { setConfigString(key, String(v)); }
|
|
9889
|
-
catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
|
|
10022
|
+
catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
|
|
9890
10023
|
if (sub === 'threshold') { cfg.compactThreshold = v; cfg.raw.compact_threshold = v; }
|
|
9891
10024
|
else { cfg.compactKeepRatio = v; cfg.raw.compact_keep_ratio = v; }
|
|
9892
10025
|
app(sub === 'threshold'
|
|
@@ -9900,7 +10033,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9900
10033
|
else if (sub === 'off') want = false;
|
|
9901
10034
|
else want = cfg.autoCompact === false; // flip from the current state
|
|
9902
10035
|
try { setConfigString('auto_compact', want ? 'true' : 'false'); }
|
|
9903
|
-
catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
|
|
10036
|
+
catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
|
|
9904
10037
|
cfg.autoCompact = want;
|
|
9905
10038
|
cfg.raw.auto_compact = want;
|
|
9906
10039
|
const pct = Math.round((cfg.compactThreshold == null ? 0.85 : cfg.compactThreshold) * 100);
|
|
@@ -9948,7 +10081,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9948
10081
|
}
|
|
9949
10082
|
const key = sub === 'threshold' ? 'trim_threshold' : 'trim_keep_ratio';
|
|
9950
10083
|
try { setConfigString(key, String(v)); }
|
|
9951
|
-
catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
|
|
10084
|
+
catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
|
|
9952
10085
|
if (sub === 'threshold') { cfg.trimThreshold = v; cfg.raw.trim_threshold = v; }
|
|
9953
10086
|
else { cfg.trimKeepRatio = v; cfg.raw.trim_keep_ratio = v; }
|
|
9954
10087
|
app(sub === 'threshold'
|
|
@@ -9964,14 +10097,14 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
9964
10097
|
else if (sub === 'off') wantTrim = false;
|
|
9965
10098
|
else wantTrim = cfg.autoTrim === false; // flip from the current state
|
|
9966
10099
|
try { setConfigString('auto_trim', wantTrim ? 'true' : 'false'); }
|
|
9967
|
-
catch (e) { appErr('Could not write config.toml: ' + e.message); return; }
|
|
10100
|
+
catch (e) { appErr(uiText('Could not write config.toml: ') + e.message); return; }
|
|
9968
10101
|
cfg.autoTrim = wantTrim;
|
|
9969
10102
|
cfg.raw.auto_trim = wantTrim;
|
|
9970
10103
|
const thr = Math.round((cfg.trimThreshold == null ? 0.5 : cfg.trimThreshold) * 100);
|
|
9971
10104
|
const keepPct = Math.round((cfg.trimKeepRatio == null ? 0.3 : cfg.trimKeepRatio) * 100);
|
|
9972
10105
|
app(wantTrim
|
|
9973
10106
|
? `Auto-trim ON — old tool results are elided from the request once it reaches ${thr}% of the window, keeping ~${keepPct}% of them (use /trim to do it now)`
|
|
9974
|
-
: 'Auto-trim OFF — tool results are sent in full (use /trim to elide them once)');
|
|
10107
|
+
: uiText('Auto-trim OFF — tool results are sent in full (use /trim to elide them once)'));
|
|
9975
10108
|
return;
|
|
9976
10109
|
}
|
|
9977
10110
|
case 'trim': {
|
|
@@ -10008,10 +10141,10 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10008
10141
|
keepRatio = v;
|
|
10009
10142
|
}
|
|
10010
10143
|
const target = (state.agent && state.agent.messages) || (session && session.messages);
|
|
10011
|
-
if (!target || !target.length) { app('Nothing to trim.'); return; }
|
|
10144
|
+
if (!target || !target.length) { app(uiText('Nothing to trim.')); return; }
|
|
10012
10145
|
const before = estimateMessagesTokens(target);
|
|
10013
10146
|
const res = trimToolResults(target, { sessionId: session && session.id, keepRatio });
|
|
10014
|
-
if (!res || !res.elided) { app('Nothing to trim — no tool result is large enough to elide.'); return; }
|
|
10147
|
+
if (!res || !res.elided) { app(uiText('Nothing to trim — no tool result is large enough to elide.')); return; }
|
|
10015
10148
|
// `trimToolResults` rewrote content IN PLACE, and the target may be the agent's
|
|
10016
10149
|
// own live message array. The agent keeps a rolling token total over it, so it
|
|
10017
10150
|
// has to be told: otherwise its ledger still describes the pre-trim bodies, the
|
|
@@ -10044,7 +10177,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10044
10177
|
// Manual update check. The automatic background check is silent, so this is where a
|
|
10045
10178
|
// pending install is also reported: the install runs detached and its outcome lands in
|
|
10046
10179
|
// the stamp file, which is the only thing that can say whether it worked.
|
|
10047
|
-
app('Checking for updates...');
|
|
10180
|
+
app(uiText('Checking for updates...'));
|
|
10048
10181
|
// A previous install may have failed without anyone seeing it.
|
|
10049
10182
|
const prev = upd.readUpdateStamp();
|
|
10050
10183
|
if (prev && prev.status === 'error' && prev.error) {
|
|
@@ -10057,9 +10190,9 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10057
10190
|
if (r.status === 'installing') app(r.message);
|
|
10058
10191
|
else if (r.status === 'busy') app(r.message);
|
|
10059
10192
|
else if (r.status === 'uptodate') app(r.message);
|
|
10060
|
-
else app('Update check: ' + (r.message || 'failed'));
|
|
10193
|
+
else app(uiText('Update check: ') + (r.message || uiText('failed')));
|
|
10061
10194
|
} catch (e) {
|
|
10062
|
-
appErr('Update check failed: ' + (e && e.message || e));
|
|
10195
|
+
appErr(uiText('Update check failed: ') + (e && e.message || e));
|
|
10063
10196
|
} finally {
|
|
10064
10197
|
cfg.updateRunning = false;
|
|
10065
10198
|
}
|
|
@@ -10073,11 +10206,11 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10073
10206
|
const cfgMcp = loadMcpConfig(state.workspace || cfg.workspace);
|
|
10074
10207
|
const conns = getLiveConnections();
|
|
10075
10208
|
const lines = describeServers(cfgMcp, conns);
|
|
10076
|
-
if (cfgMcp.errors.length) lines.push('', 'Config problems:', ...cfgMcp.errors.map((e) => ` ! ${e}`));
|
|
10209
|
+
if (cfgMcp.errors.length) lines.push('', uiText('Config problems:'), ...cfgMcp.errors.map((e) => ` ! ${e}`));
|
|
10077
10210
|
const showTools = String(raw || '').toLowerCase() === 'tools';
|
|
10078
10211
|
if (showTools) {
|
|
10079
10212
|
const found = conns.filter((c) => c.ok).map((c) => ` ${c.name}: ${c.toolCount} tool(s)`);
|
|
10080
|
-
lines.push('', found.length ? 'Discovered tools:' : 'No servers connected — they connect at startup.');
|
|
10213
|
+
lines.push('', found.length ? uiText('Discovered tools:') : 'No servers connected — they connect at startup.');
|
|
10081
10214
|
lines.push(...found);
|
|
10082
10215
|
}
|
|
10083
10216
|
h.openPanel('hncode — mcp', lines);
|
|
@@ -10180,7 +10313,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10180
10313
|
onSubmit: (values) => {
|
|
10181
10314
|
const n = (values.name || '').trim();
|
|
10182
10315
|
const target = (values.target || '').trim();
|
|
10183
|
-
if (!n || !target) { appErr('Name and command/URL are required.'); return; }
|
|
10316
|
+
if (!n || !target) { appErr(uiText('Name and command/URL are required.')); return; }
|
|
10184
10317
|
const d = readDoc();
|
|
10185
10318
|
d.mcpServers[n] = /^https?:\/\//.test(target)
|
|
10186
10319
|
? { url: target }
|
|
@@ -10232,13 +10365,13 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10232
10365
|
}
|
|
10233
10366
|
if (action === 'add') {
|
|
10234
10367
|
const target = rest[0] || '';
|
|
10235
|
-
if (!name || !target) { appErr('Usage: /mcp-config add <name> <command|url> [args...]'); return; }
|
|
10368
|
+
if (!name || !target) { appErr(uiText('Usage: /mcp-config add <name> <command|url> [args...]')); return; }
|
|
10236
10369
|
doc.mcpServers[name] = /^https?:\/\//.test(target) ? { url: target } : { command: target, args: rest.slice(1) };
|
|
10237
10370
|
writeDoc(doc);
|
|
10238
10371
|
app(`MCP server added: ${name} → ${mcpFile}. Start a new session to apply.`);
|
|
10239
10372
|
return;
|
|
10240
10373
|
}
|
|
10241
|
-
appErr('Usage: /mcp-config (manage) | list | add <name> <command|url> [args...] | remove <name>');
|
|
10374
|
+
appErr(uiText('Usage: /mcp-config (manage) | list | add <name> <command|url> [args...] | remove <name>'));
|
|
10242
10375
|
return;
|
|
10243
10376
|
}
|
|
10244
10377
|
|
|
@@ -10269,7 +10402,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10269
10402
|
session.saveThinking = false;
|
|
10270
10403
|
persist();
|
|
10271
10404
|
} else if (what) {
|
|
10272
|
-
appErr('Usage: /save-history [on|off|thinking|nothinking]');
|
|
10405
|
+
appErr(uiText('Usage: /save-history [on|off|thinking|nothinking]'));
|
|
10273
10406
|
return;
|
|
10274
10407
|
}
|
|
10275
10408
|
say(`Saved history — display rows: ${on(state.saveHistory)} · reasoning: ${on(state.saveThinking)}`);
|
|
@@ -10349,7 +10482,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10349
10482
|
if (sub === 'add') {
|
|
10350
10483
|
const from = parts[1];
|
|
10351
10484
|
const to = parts.slice(2).join(' ');
|
|
10352
|
-
if (!from || !to) { appErr('Usage: /keybindings add <key> <key|/command> e.g. /keybindings add ctrl+e /theme'); return; }
|
|
10485
|
+
if (!from || !to) { appErr(uiText('Usage: /keybindings add <key> <key|/command> e.g. /keybindings add ctrl+e /theme')); return; }
|
|
10353
10486
|
const src = normalizeKey(from);
|
|
10354
10487
|
if (!src) { appErr(`"${from}" is not a usable key name.`); return; }
|
|
10355
10488
|
// Validate BEFORE writing: a file the loader would reject is worse than a refusal,
|
|
@@ -10358,7 +10491,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10358
10491
|
else {
|
|
10359
10492
|
const dst = normalizeKey(to);
|
|
10360
10493
|
if (!dst) { appErr(`"${to}" is not a usable key name or a /command.`); return; }
|
|
10361
|
-
if (dst === src) { appErr('A key cannot be bound to itself.'); return; }
|
|
10494
|
+
if (dst === src) { appErr(uiText('A key cannot be bound to itself.')); return; }
|
|
10362
10495
|
doc[src] = dst;
|
|
10363
10496
|
}
|
|
10364
10497
|
try { writeKeybindings(undefined, doc); } catch (e) { appErr(`Could not write: ${e.message}`); return; }
|
|
@@ -10370,7 +10503,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10370
10503
|
}
|
|
10371
10504
|
if (sub === 'remove' || sub === 'rm' || sub === 'delete') {
|
|
10372
10505
|
const src = normalizeKey(parts[1] || '');
|
|
10373
|
-
if (!src) { appErr('Usage: /keybindings remove <key>'); return; }
|
|
10506
|
+
if (!src) { appErr(uiText('Usage: /keybindings remove <key>')); return; }
|
|
10374
10507
|
if (!(src in doc)) { appErr(`No binding for ${src}.`); return; }
|
|
10375
10508
|
delete doc[src];
|
|
10376
10509
|
try { writeKeybindings(undefined, doc); } catch (e) { appErr(`Could not write: ${e.message}`); return; }
|
|
@@ -10386,7 +10519,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10386
10519
|
if (to.startsWith('/')) doc[src] = to.trim();
|
|
10387
10520
|
else {
|
|
10388
10521
|
const dst = normalizeKey(to);
|
|
10389
|
-
if (!dst || dst === src) { appErr('Target must be a different key or a /command.'); return; }
|
|
10522
|
+
if (!dst || dst === src) { appErr(uiText('Target must be a different key or a /command.')); return; }
|
|
10390
10523
|
doc[src] = dst;
|
|
10391
10524
|
}
|
|
10392
10525
|
try { writeKeybindings(undefined, doc); } catch (e) { appErr(`Could not write: ${e.message}`); return; }
|
|
@@ -10395,7 +10528,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10395
10528
|
return;
|
|
10396
10529
|
}
|
|
10397
10530
|
}
|
|
10398
|
-
appErr('Usage: /keybindings [list | add <key> <key|/command> | remove <key> | edit]');
|
|
10531
|
+
appErr(uiText('Usage: /keybindings [list | add <key> <key|/command> | remove <key> | edit]'));
|
|
10399
10532
|
return;
|
|
10400
10533
|
}
|
|
10401
10534
|
case 'agents': {
|
|
@@ -10412,7 +10545,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10412
10545
|
if (sub === 'message' || sub === 'msg') {
|
|
10413
10546
|
const id = parts[1];
|
|
10414
10547
|
const text = parts.slice(2).join(' ');
|
|
10415
|
-
if (!id || !text) { appErr('Usage: /agents message <agent-id> <text>'); return; }
|
|
10548
|
+
if (!id || !text) { appErr(uiText('Usage: /agents message <agent-id> <text>')); return; }
|
|
10416
10549
|
const r = sendToRun(id, text);
|
|
10417
10550
|
if (r.ok) app(r.message); else appErr(r.message);
|
|
10418
10551
|
return;
|
|
@@ -10421,7 +10554,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10421
10554
|
const id = parts[1];
|
|
10422
10555
|
if (!id || id === 'all') {
|
|
10423
10556
|
const all = interruptAll();
|
|
10424
|
-
app(all.ok ? `Interrupted ${all.count} subagent(s): ${all.agents.join(', ')}` : 'No subagent is running.');
|
|
10557
|
+
app(all.ok ? `Interrupted ${all.count} subagent(s): ${all.agents.join(', ')}` : uiText('No subagent is running.'));
|
|
10425
10558
|
return;
|
|
10426
10559
|
}
|
|
10427
10560
|
const r = interruptRun(id);
|
|
@@ -10430,12 +10563,12 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10430
10563
|
}
|
|
10431
10564
|
if (sub === 'close') {
|
|
10432
10565
|
const id = parts[1];
|
|
10433
|
-
if (!id) { appErr('Usage: /agents close <agent-id>'); return; }
|
|
10566
|
+
if (!id) { appErr(uiText('Usage: /agents close <agent-id>')); return; }
|
|
10434
10567
|
const r = closeRun(id);
|
|
10435
10568
|
if (r.ok) app(r.message); else appErr(r.message);
|
|
10436
10569
|
return;
|
|
10437
10570
|
}
|
|
10438
|
-
appErr('Usage: /agents [list | message <id> <text> | interrupt [id|all] | close <id>]');
|
|
10571
|
+
appErr(uiText('Usage: /agents [list | message <id> <text> | interrupt [id|all] | close <id>]'));
|
|
10439
10572
|
return;
|
|
10440
10573
|
}
|
|
10441
10574
|
case 'team': {
|
|
@@ -10453,7 +10586,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10453
10586
|
const current = () => leadTeam();
|
|
10454
10587
|
|
|
10455
10588
|
const doAdd = (name, model) => {
|
|
10456
|
-
if (!current()) { appErr('No team. Create one: /team create <name>'); return; }
|
|
10589
|
+
if (!current()) { appErr(uiText('No team. Create one: /team create <name>')); return; }
|
|
10457
10590
|
const r = teamMod.addMember(current(), { name, model: model || '' });
|
|
10458
10591
|
if (!r.ok) { appErr(r.error); return; }
|
|
10459
10592
|
const shown = model
|
|
@@ -10513,7 +10646,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10513
10646
|
|
|
10514
10647
|
if (verb === 'create') {
|
|
10515
10648
|
const name = parts.slice(1).join(' ').trim();
|
|
10516
|
-
if (!name) { appErr('Usage: /team create <name>'); return; }
|
|
10649
|
+
if (!name) { appErr(uiText('Usage: /team create <name>')); return; }
|
|
10517
10650
|
const r = teamMod.createTeam({
|
|
10518
10651
|
teamName: name,
|
|
10519
10652
|
leadSessionId: (session && session.id) || '',
|
|
@@ -10522,13 +10655,13 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10522
10655
|
if (!r.ok) { appErr(r.error); return; }
|
|
10523
10656
|
setLeadTeam(name);
|
|
10524
10657
|
app(`Team "${name}" created — you are team-lead.`);
|
|
10525
|
-
app('Add members with /team add <name>; it asks which model each should run.');
|
|
10658
|
+
app(uiText('Add members with /team add <name>; it asks which model each should run.'));
|
|
10526
10659
|
return;
|
|
10527
10660
|
}
|
|
10528
10661
|
|
|
10529
10662
|
if (verb === 'add') {
|
|
10530
10663
|
const name = parts[1];
|
|
10531
|
-
if (!name) { appErr('Usage: /team add <name> [model]'); return; }
|
|
10664
|
+
if (!name) { appErr(uiText('Usage: /team add <name> [model]')); return; }
|
|
10532
10665
|
if (parts[2]) { doAdd(name, parts.slice(2).join(' ')); return; }
|
|
10533
10666
|
askModel(name);
|
|
10534
10667
|
return;
|
|
@@ -10537,8 +10670,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10537
10670
|
if (verb === 'msg' || verb === 'message' || verb === 'tell') {
|
|
10538
10671
|
const who = parts[1];
|
|
10539
10672
|
const body = parts.slice(2).join(' ').trim();
|
|
10540
|
-
if (!current()) { appErr('No team. Create one: /team create <name>'); return; }
|
|
10541
|
-
if (!who || !body) { appErr('Usage: /team msg <name> <text> -- "*" reaches every member'); return; }
|
|
10673
|
+
if (!current()) { appErr(uiText('No team. Create one: /team create <name>')); return; }
|
|
10674
|
+
if (!who || !body) { appErr(uiText('Usage: /team msg <name> <text> -- "*" reaches every member')); return; }
|
|
10542
10675
|
|
|
10543
10676
|
const roster = teamMod.rosterOf(current());
|
|
10544
10677
|
const name = who === '*' ? null : who;
|
|
@@ -10559,7 +10692,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10559
10692
|
const targets = name
|
|
10560
10693
|
? [name]
|
|
10561
10694
|
: roster.filter((m) => m.name !== TEAM_LEAD_NAME).map((m) => m.name);
|
|
10562
|
-
if (!targets.length) { appErr('There is nobody else on the team.'); return; }
|
|
10695
|
+
if (!targets.length) { appErr(uiText('There is nobody else on the team.')); return; }
|
|
10563
10696
|
for (const t of targets) {
|
|
10564
10697
|
mailMod.writeToMailbox(current(), t, { from: TEAM_LEAD_NAME, text: body });
|
|
10565
10698
|
}
|
|
@@ -10568,20 +10701,20 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10568
10701
|
}
|
|
10569
10702
|
|
|
10570
10703
|
if (verb === 'panel' || verb === 'ui') {
|
|
10571
|
-
if (!current()) { appErr('No team. Create one: /team create <name>'); return; }
|
|
10704
|
+
if (!current()) { appErr(uiText('No team. Create one: /team create <name>')); return; }
|
|
10572
10705
|
state.teamPanel = makeTeamPanel(current());
|
|
10573
10706
|
renderFrame();
|
|
10574
10707
|
return;
|
|
10575
10708
|
}
|
|
10576
10709
|
|
|
10577
10710
|
if (verb === 'list') {
|
|
10578
|
-
if (!current()) { appErr('No team. Create one: /team create <name>'); return; }
|
|
10711
|
+
if (!current()) { appErr(uiText('No team. Create one: /team create <name>')); return; }
|
|
10579
10712
|
sayPanel(teamMod.readRoster(current()));
|
|
10580
10713
|
return;
|
|
10581
10714
|
}
|
|
10582
10715
|
|
|
10583
10716
|
if (verb === 'delete' || verb === 'disband') {
|
|
10584
|
-
if (!current()) { appErr('No team to delete.'); return; }
|
|
10717
|
+
if (!current()) { appErr(uiText('No team to delete.')); return; }
|
|
10585
10718
|
// The name is captured BEFORE clearing, which is what the message needs. Reading
|
|
10586
10719
|
// `current()` after the clear produced `Team "null" dissolved.` — the lead was gone by
|
|
10587
10720
|
// the time it was asked for.
|
|
@@ -10613,7 +10746,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10613
10746
|
hint: 'Enter create · Esc cancel',
|
|
10614
10747
|
onSubmit: (values) => {
|
|
10615
10748
|
const name = String((values && values.name) || '').trim();
|
|
10616
|
-
if (!name) { appErr('Cancelled: a team needs a name.'); return; }
|
|
10749
|
+
if (!name) { appErr(uiText('Cancelled: a team needs a name.')); return; }
|
|
10617
10750
|
const r = teamMod.createTeam({
|
|
10618
10751
|
teamName: name,
|
|
10619
10752
|
leadSessionId: (session && session.id) || '',
|
|
@@ -10630,7 +10763,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10630
10763
|
// Ask who, then which model: two questions, one flow. `askModel` is the same chooser
|
|
10631
10764
|
// `/team add <name>` uses, so the two paths cannot offer different models.
|
|
10632
10765
|
const askAdd = () => {
|
|
10633
|
-
if (!leadTeam()) { appErr('No team. Create one first.'); return; }
|
|
10766
|
+
if (!leadTeam()) { appErr(uiText('No team. Create one first.')); return; }
|
|
10634
10767
|
openForm({
|
|
10635
10768
|
title: 'Add a member',
|
|
10636
10769
|
fields: [{ key: 'name', label: 'Name' }],
|
|
@@ -10641,7 +10774,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10641
10774
|
hint: 'Enter next · Esc cancel',
|
|
10642
10775
|
onSubmit: (values) => {
|
|
10643
10776
|
const name = String((values && values.name) || '').trim();
|
|
10644
|
-
if (!name) { appErr('Cancelled: a member needs a name.'); return; }
|
|
10777
|
+
if (!name) { appErr(uiText('Cancelled: a member needs a name.')); return; }
|
|
10645
10778
|
askModel(name);
|
|
10646
10779
|
},
|
|
10647
10780
|
});
|
|
@@ -10728,13 +10861,13 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10728
10861
|
return;
|
|
10729
10862
|
}
|
|
10730
10863
|
const n = Number(parts[1]);
|
|
10731
|
-
if (!Number.isFinite(n) || n < 1) { appErr('Usage: /checkpoints [list | restore <n> | diff <n>]'); return; }
|
|
10864
|
+
if (!Number.isFinite(n) || n < 1) { appErr(uiText('Usage: /checkpoints [list | restore <n> | diff <n>]')); return; }
|
|
10732
10865
|
const all = listCheckpoints(sid);
|
|
10733
10866
|
const entry = all.find((c) => c.index === n);
|
|
10734
10867
|
if (!entry) { appErr(`No checkpoint ${n}. /checkpoints lists them.`); return; }
|
|
10735
10868
|
if (sub === 'diff') {
|
|
10736
10869
|
const d = checkpointDelta(entry);
|
|
10737
|
-
if (!d) { appErr('No size comparison available for that checkpoint.'); return; }
|
|
10870
|
+
if (!d) { appErr(uiText('No size comparison available for that checkpoint.')); return; }
|
|
10738
10871
|
const rel = entry.path;
|
|
10739
10872
|
sayPanel(`${rel}\nthen: ${d.before} line(s)\nnow: ${d.after} line(s)\nchange: ${d.lines >= 0 ? '+' : ''}${d.lines}`);
|
|
10740
10873
|
return;
|
|
@@ -10747,7 +10880,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10747
10880
|
: `Restored ${entry.path} from checkpoint ${n}.`);
|
|
10748
10881
|
return;
|
|
10749
10882
|
}
|
|
10750
|
-
appErr('Usage: /checkpoints [list | restore <n> | diff <n>]');
|
|
10883
|
+
appErr(uiText('Usage: /checkpoints [list | restore <n> | diff <n>]'));
|
|
10751
10884
|
return;
|
|
10752
10885
|
}
|
|
10753
10886
|
case 'statusline':
|
|
@@ -10784,7 +10917,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10784
10917
|
return;
|
|
10785
10918
|
case 'export-md': {
|
|
10786
10919
|
const msgs = session.messages || [];
|
|
10787
|
-
if (!msgs.length) { appErr('Nothing to export (empty session).'); return; }
|
|
10920
|
+
if (!msgs.length) { appErr(uiText('Nothing to export (empty session).')); return; }
|
|
10788
10921
|
const out = raw || path.join(state.cwd, `hncode-export-${session.id}.md`);
|
|
10789
10922
|
try {
|
|
10790
10923
|
fs.mkdirSync(path.dirname(out), { recursive: true });
|
|
@@ -10801,14 +10934,14 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10801
10934
|
if (!target) return;
|
|
10802
10935
|
let abs;
|
|
10803
10936
|
try { abs = path.resolve(state.cwd, target); } catch { abs = target; }
|
|
10804
|
-
if (!/\.(md|markdown)$/i.test(abs)) { appErr('Only Markdown files are supported (.md / .markdown).'); return; }
|
|
10937
|
+
if (!/\.(md|markdown)$/i.test(abs)) { appErr(uiText('Only Markdown files are supported (.md / .markdown).')); return; }
|
|
10805
10938
|
let text;
|
|
10806
10939
|
try {
|
|
10807
10940
|
const st = fs.statSync(abs);
|
|
10808
|
-
if (!st.isFile()) { appErr('Not a file: ' + target); return; }
|
|
10941
|
+
if (!st.isFile()) { appErr(uiText('Not a file: ') + target); return; }
|
|
10809
10942
|
text = fs.readFileSync(abs, 'utf8');
|
|
10810
|
-
} catch (e) { appErr('Could not read ' + target + ': ' + e.message); return; }
|
|
10811
|
-
if (!text.trim()) { appErr('That Markdown file is empty: ' + target); return; }
|
|
10943
|
+
} catch (e) { appErr(uiText('Could not read ') + target + ': ' + e.message); return; }
|
|
10944
|
+
if (!text.trim()) { appErr(uiText('That Markdown file is empty: ') + target); return; }
|
|
10812
10945
|
const rel = path.relative(state.cwd, abs).replace(/\\/g, '/') || target;
|
|
10813
10946
|
say(`/import-session — attaching ${rel} (${text.length} chars) to the prompt…`);
|
|
10814
10947
|
// The file content travels WITH the message, so the model does not need
|
|
@@ -10837,7 +10970,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10837
10970
|
}
|
|
10838
10971
|
} catch { /* ignore */ }
|
|
10839
10972
|
if (!found.length) {
|
|
10840
|
-
appErr('No Markdown files found in ' + state.cwd + '. Pass a path: /import-session <file.md>');
|
|
10973
|
+
appErr(uiText('No Markdown files found in ') + state.cwd + '. Pass a path: /import-session <file.md>');
|
|
10841
10974
|
return;
|
|
10842
10975
|
}
|
|
10843
10976
|
openPicker({
|
|
@@ -10855,28 +10988,28 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10855
10988
|
}
|
|
10856
10989
|
case 'copy': {
|
|
10857
10990
|
const last = [...state.chat].reverse().find((m) => m.role === 'assistant' && (m.text || '').trim());
|
|
10858
|
-
if (!last) { appErr('No assistant message to copy.'); return; }
|
|
10991
|
+
if (!last) { appErr(uiText('No assistant message to copy.')); return; }
|
|
10859
10992
|
try {
|
|
10860
10993
|
if (process.platform === 'win32') cp.execSync('clip', { input: last.text });
|
|
10861
10994
|
else cp.execSync('pbcopy', { input: last.text });
|
|
10862
10995
|
app(`Copied to clipboard (${last.text.length} characters).`);
|
|
10863
|
-
} catch { appErr('Clipboard unavailable.'); }
|
|
10996
|
+
} catch { appErr(uiText('Clipboard unavailable.')); }
|
|
10864
10997
|
return;
|
|
10865
10998
|
}
|
|
10866
10999
|
case 'add-dir': {
|
|
10867
11000
|
state.addDirs = state.addDirs || [];
|
|
10868
11001
|
if (!raw || raw === 'list') {
|
|
10869
|
-
sayPanel(state.addDirs.length ? 'Additional directories:\n' + state.addDirs.map((d) => ` ${d}`).join('\n') : 'No additional directories.');
|
|
11002
|
+
sayPanel(state.addDirs.length ? 'Additional directories:\n' + state.addDirs.map((d) => ` ${d}`).join('\n') : uiText('No additional directories.'));
|
|
10870
11003
|
return;
|
|
10871
11004
|
}
|
|
10872
11005
|
const dir = path.resolve(state.cwd, raw.replace(/^~/, os.homedir()));
|
|
10873
|
-
if (!fs.existsSync(dir)) { appErr(
|
|
11006
|
+
if (!fs.existsSync(dir)) { appErr(`${uiText('Directory does not exist')}: ${dir}`); return; }
|
|
10874
11007
|
openPicker({
|
|
10875
|
-
title:
|
|
11008
|
+
title: `${uiText('Add directory to workspace')}: ${dir}`,
|
|
10876
11009
|
items: [
|
|
10877
|
-
{ label: 'Yes, for this session', value: 'session' },
|
|
10878
|
-
{ label: 'Yes, and remember this directory', value: 'persist' },
|
|
10879
|
-
{ label: 'No', value: 'no' },
|
|
11010
|
+
{ label: uiText('Yes, for this session'), value: 'session' },
|
|
11011
|
+
{ label: uiText('Yes, and remember this directory'), value: 'persist' },
|
|
11012
|
+
{ label: uiText('No'), value: 'no' },
|
|
10880
11013
|
],
|
|
10881
11014
|
searchable: false,
|
|
10882
11015
|
onPick: (it) => {
|
|
@@ -10894,7 +11027,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10894
11027
|
}
|
|
10895
11028
|
|
|
10896
11029
|
case 'move': {
|
|
10897
|
-
if (!raw) { appErr('Usage: /move <target-directory>'); return; }
|
|
11030
|
+
if (!raw) { appErr(uiText('Usage: /move <target-directory>')); return; }
|
|
10898
11031
|
const target = path.resolve(state.cwd, raw.replace(/^~/, os.homedir()));
|
|
10899
11032
|
if (!fs.existsSync(target)) { appErr(`Directory does not exist: ${target}`); return; }
|
|
10900
11033
|
// Create a new session in the target directory with the same messages.
|
|
@@ -10957,7 +11090,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10957
11090
|
case 'vim': {
|
|
10958
11091
|
// An external editor needs the actual terminal, not the TUI's alternate screen. The host owns the TTY and
|
|
10959
11092
|
// restores its mouse/keyboard modes afterwards; dispatch only transfers the composer text.
|
|
10960
|
-
if (!h.editComposerExternal) { appErr('External editor is unavailable in this session.'); return; }
|
|
11093
|
+
if (!h.editComposerExternal) { appErr(uiText('External editor is unavailable in this session.')); return; }
|
|
10961
11094
|
// The command itself is consumed by submit before dispatch; the editor starts from an empty buffer and
|
|
10962
11095
|
// creates its file only when the user writes it.
|
|
10963
11096
|
const result = h.editComposerExternal('');
|
|
@@ -10988,8 +11121,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
10988
11121
|
const changed = beforeMax !== state.ctxMax;
|
|
10989
11122
|
app(changed
|
|
10990
11123
|
? `Config reloaded. Context window: ${fmtTokens(beforeMax)} -> ${fmtTokens(state.ctxMax)} (now ${state.ctxPercent}% used)`
|
|
10991
|
-
: 'Config reloaded.');
|
|
10992
|
-
app('Config and plugins reloaded.');
|
|
11124
|
+
: uiText('Config reloaded.'));
|
|
11125
|
+
app(uiText('Config and plugins reloaded.'));
|
|
10993
11126
|
}
|
|
10994
11127
|
// Re-load plugins so an added/edited plugin takes effect without a restart.
|
|
10995
11128
|
if (h.reloadPlugins) {
|
|
@@ -11016,7 +11149,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11016
11149
|
const changed = beforeMax !== state.ctxMax;
|
|
11017
11150
|
app(changed
|
|
11018
11151
|
? `Config reloaded. Context window: ${fmtTokens(beforeMax)} -> ${fmtTokens(state.ctxMax)} (now ${state.ctxPercent}% used)`
|
|
11019
|
-
: 'Config reloaded.');
|
|
11152
|
+
: uiText('Config reloaded.'));
|
|
11020
11153
|
}
|
|
11021
11154
|
} catch (e) { appErr(`Reload failed: ${e.message}`); }
|
|
11022
11155
|
return;
|
|
@@ -11029,7 +11162,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11029
11162
|
|
|
11030
11163
|
if (sub === 'remove' || sub === 'rm' || sub === 'delete') {
|
|
11031
11164
|
const name = parts[1];
|
|
11032
|
-
if (!name) { appErr('Usage: /plugins remove <name>'); return; }
|
|
11165
|
+
if (!name) { appErr(uiText('Usage: /plugins remove <name>')); return; }
|
|
11033
11166
|
const ok = remote.removeLocalPlugin(name);
|
|
11034
11167
|
if (!ok) { appErr(`No such plugin: ${name}`); return; }
|
|
11035
11168
|
// Removing the files does not unload the code already registered in this
|
|
@@ -11045,14 +11178,14 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11045
11178
|
const res = await remote.installRemotePlugin(name);
|
|
11046
11179
|
if (!res.ok) { appErr(`Install failed: ${res.error}`); return; }
|
|
11047
11180
|
app(`Plugin ${res.replaced ? 'updated' : 'installed'}: ${res.name} (${res.files.join(', ')})`);
|
|
11048
|
-
app('Reload them with /plugins reload, or restart hncode.');
|
|
11181
|
+
app(uiText('Reload them with /plugins reload, or restart hncode.'));
|
|
11049
11182
|
return;
|
|
11050
11183
|
}
|
|
11051
11184
|
if (sub === 'reload') {
|
|
11052
11185
|
// Hot reload: unload every plugin (running its dispose + collected teardown),
|
|
11053
11186
|
// then re-import the files with cache busting. The alternative was a restart,
|
|
11054
11187
|
// which is what made plugin development painful.
|
|
11055
|
-
if (!h.reloadPlugins) { appErr('Reload is unavailable in this host.'); return; }
|
|
11188
|
+
if (!h.reloadPlugins) { appErr(uiText('Reload is unavailable in this host.')); return; }
|
|
11056
11189
|
const notes = await h.reloadPlugins();
|
|
11057
11190
|
const errs = (notes || []).filter((n) => n.level === 'error').length;
|
|
11058
11191
|
if (errs) {
|
|
@@ -11066,7 +11199,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11066
11199
|
// kimi's panel). An unknown subcommand still errors rather than silently opening
|
|
11067
11200
|
// it as if the word had been understood.
|
|
11068
11201
|
if (sub !== 'list' && sub !== '') {
|
|
11069
|
-
appErr('Usage: /plugins [list] | install <name> | remove <name> | reload');
|
|
11202
|
+
appErr(uiText('Usage: /plugins [list] | install <name> | remove <name> | reload'));
|
|
11070
11203
|
return;
|
|
11071
11204
|
}
|
|
11072
11205
|
await h.openRegistryBrowser('plugins');
|
|
@@ -11078,7 +11211,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11078
11211
|
const remote = await import('./remote.js');
|
|
11079
11212
|
if (sub === 'remove' || sub === 'rm' || sub === 'delete') {
|
|
11080
11213
|
const name = parts[1];
|
|
11081
|
-
if (!name) { appErr('Usage: /skills remove <name>'); return; }
|
|
11214
|
+
if (!name) { appErr(uiText('Usage: /skills remove <name>')); return; }
|
|
11082
11215
|
const ok = deleteSkill(name);
|
|
11083
11216
|
app(ok ? `Skill removed: ${normalizeSkillName(name)}` : `No such skill: ${name}`);
|
|
11084
11217
|
return;
|
|
@@ -11099,7 +11232,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11099
11232
|
await h.openRegistryBrowser('skills');
|
|
11100
11233
|
return;
|
|
11101
11234
|
}
|
|
11102
|
-
appErr('Usage: /skills [list] | install <name> | remove <name>');
|
|
11235
|
+
appErr(uiText('Usage: /skills [list] | install <name> | remove <name>'));
|
|
11103
11236
|
return;
|
|
11104
11237
|
}
|
|
11105
11238
|
case 'import-skill': {
|
|
@@ -11107,7 +11240,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11107
11240
|
const parts = raw.split(/\s+/).filter(Boolean);
|
|
11108
11241
|
const source = parts[0];
|
|
11109
11242
|
const nameArg = parts[1];
|
|
11110
|
-
if (!source) { appErr('Usage: /import-skill <file.md | owner/repo[/subdir]> [name]'); return; }
|
|
11243
|
+
if (!source) { appErr(uiText('Usage: /import-skill <file.md | owner/repo[/subdir]> [name]')); return; }
|
|
11111
11244
|
|
|
11112
11245
|
// A repository spec has no extension and carries a slash — a local Markdown path always ends in .md, and a
|
|
11113
11246
|
// path that does not is not something this command ever accepted.
|
|
@@ -11128,7 +11261,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11128
11261
|
|
|
11129
11262
|
const res = importSkill(source, nameArg);
|
|
11130
11263
|
if (!res.ok) { appErr(res.error); return; }
|
|
11131
|
-
app(`${res.replaced ? 'Skill overwritten' : 'Skill imported'}: ${res.name} → ${res.path}`);
|
|
11264
|
+
app(`${res.replaced ? uiText('Skill overwritten') : uiText('Skill imported')}: ${res.name} → ${res.path}`);
|
|
11132
11265
|
say(`Activate it with /${SKILL_PREFIX}${res.name}`);
|
|
11133
11266
|
return;
|
|
11134
11267
|
}
|
|
@@ -11159,7 +11292,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11159
11292
|
}
|
|
11160
11293
|
const { hooks, errors } = loadHooks(workspace);
|
|
11161
11294
|
const lines = describeHooks({ hooks }, workspace);
|
|
11162
|
-
if (errors.length) lines.push('', 'Config problems:', ...errors.map((e) => ` ! ${e}`));
|
|
11295
|
+
if (errors.length) lines.push('', uiText('Config problems:'), ...errors.map((e) => ` ! ${e}`));
|
|
11163
11296
|
h.openPanel('hncode — hooks', lines);
|
|
11164
11297
|
return;
|
|
11165
11298
|
}
|
|
@@ -11190,7 +11323,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11190
11323
|
const r = gitmod.stage(paths, cwd);
|
|
11191
11324
|
if (!r.ok) { appErr(`git add failed: ${r.error}`); return; }
|
|
11192
11325
|
const staged = gitmod.stagedFiles(cwd);
|
|
11193
|
-
app(paths.length ? `Staged ${paths.length} path(s).` : 'Staged all changes.');
|
|
11326
|
+
app(paths.length ? `Staged ${paths.length} path(s).` : uiText('Staged all changes.'));
|
|
11194
11327
|
sayPanel(`Index now holds ${staged.length} file(s):\n` + staged.map((f) => ' ' + f).join('\n'));
|
|
11195
11328
|
return;
|
|
11196
11329
|
}
|
|
@@ -11201,8 +11334,8 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11201
11334
|
const path = raw.replace(/--staged|--cached/g, '').trim();
|
|
11202
11335
|
const r = gitmod.diffText(cwd, { staged, path: path || undefined });
|
|
11203
11336
|
if (!r.ok) { appErr(`git diff failed: ${r.error}`); return; }
|
|
11204
|
-
if (r.empty) { say(staged ? 'No staged changes.' : 'No uncommitted changes.'); return; }
|
|
11205
|
-
sayPanel((staged ? 'Staged changes' : 'Uncommitted changes') + (path ? ` in ${path}` : '') + ':\n' + r.text);
|
|
11337
|
+
if (r.empty) { say(staged ? uiText('No staged changes.') : uiText('No uncommitted changes.')); return; }
|
|
11338
|
+
sayPanel((staged ? uiText('Staged changes') : uiText('Uncommitted changes')) + (path ? ` in ${path}` : '') + ':\n' + r.text);
|
|
11206
11339
|
return;
|
|
11207
11340
|
}
|
|
11208
11341
|
case 'log': {
|
|
@@ -11213,7 +11346,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11213
11346
|
const path = parts.join(' ') || undefined;
|
|
11214
11347
|
const r = gitmod.logText(cwd, { count, path });
|
|
11215
11348
|
if (!r.ok) { appErr(`git log failed: ${r.error}`); return; }
|
|
11216
|
-
if (r.empty) { say('No commits yet.'); return; }
|
|
11349
|
+
if (r.empty) { say(uiText('No commits yet.')); return; }
|
|
11217
11350
|
sayPanel(`Recent commits${path ? ` for ${path}` : ''}:\n` + r.text);
|
|
11218
11351
|
return;
|
|
11219
11352
|
}
|
|
@@ -11237,7 +11370,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11237
11370
|
searchable: false,
|
|
11238
11371
|
hint: '↑↓ navigate · Enter select · Esc cancel',
|
|
11239
11372
|
onPick: (it) => {
|
|
11240
|
-
if (it.label !== 'Push') { app('Push cancelled.'); return true; }
|
|
11373
|
+
if (it.label !== 'Push') { app(uiText('Push cancelled.')); return true; }
|
|
11241
11374
|
const r = gitmod.push(cwd, { branch: branchArg || undefined, force, setUpstream: !upstream });
|
|
11242
11375
|
if (!r.ok) appErr(`Push failed: ${r.error}`);
|
|
11243
11376
|
else { app(`Pushed ${branch}.`); sayPanel(`git push output:\n${r.output}`); }
|
|
@@ -11260,23 +11393,23 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11260
11393
|
const msg = parts.slice(1).join(' ') || undefined;
|
|
11261
11394
|
const r = gitmod.stashPush(cwd, msg);
|
|
11262
11395
|
if (!r.ok) { appErr(`git stash failed: ${r.error}`); return; }
|
|
11263
|
-
app('Stashed changes.'); sayPanel(r.output || 'Changes stashed.');
|
|
11396
|
+
app(uiText('Stashed changes.')); sayPanel(r.output || uiText('Changes stashed.'));
|
|
11264
11397
|
return;
|
|
11265
11398
|
}
|
|
11266
11399
|
if (sub === 'pop') {
|
|
11267
11400
|
const r = gitmod.stashPop(cwd);
|
|
11268
11401
|
if (!r.ok) { appErr(`git stash pop failed: ${r.error}`); return; }
|
|
11269
|
-
app('Restored from stash.'); sayPanel(r.output || 'Stash popped.');
|
|
11402
|
+
app(uiText('Restored from stash.')); sayPanel(r.output || uiText('Stash popped.'));
|
|
11270
11403
|
return;
|
|
11271
11404
|
}
|
|
11272
|
-
appErr('Usage: /stash [list] | push [message] | pop');
|
|
11405
|
+
appErr(uiText('Usage: /stash [list] | push [message] | pop'));
|
|
11273
11406
|
return;
|
|
11274
11407
|
}
|
|
11275
11408
|
case 'rebase': {
|
|
11276
11409
|
const cwd = state.cwd || cfg.workspace || process.cwd();
|
|
11277
11410
|
if (!gitmod.isRepo(cwd)) { appErr(`Not a git repository: ${cwd}`); return; }
|
|
11278
11411
|
const onto = String(raw || '').trim();
|
|
11279
|
-
if (!onto) { appErr('Usage: /rebase <branch>'); return; }
|
|
11412
|
+
if (!onto) { appErr(uiText('Usage: /rebase <branch>')); return; }
|
|
11280
11413
|
const cur = gitmod.currentBranch(cwd);
|
|
11281
11414
|
// Rewrites history on the current branch: confirm before running.
|
|
11282
11415
|
h.openPicker({
|
|
@@ -11288,10 +11421,10 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11288
11421
|
searchable: false,
|
|
11289
11422
|
hint: '↑↓ navigate · Enter select · Esc cancel',
|
|
11290
11423
|
onPick: (it) => {
|
|
11291
|
-
if (it.label !== 'Rebase') { app('Rebase cancelled.'); return true; }
|
|
11424
|
+
if (it.label !== 'Rebase') { app(uiText('Rebase cancelled.')); return true; }
|
|
11292
11425
|
const r = gitmod.rebase(cwd, onto);
|
|
11293
11426
|
if (!r.ok) appErr(`Rebase failed (resolve conflicts, then /rebase --continue or git rebase --abort): ${r.error}`);
|
|
11294
|
-
else { app(`Rebased ${cur} onto ${onto}.`); sayPanel(r.output || 'Rebase complete.'); }
|
|
11427
|
+
else { app(`Rebased ${cur} onto ${onto}.`); sayPanel(r.output || uiText('Rebase complete.')); }
|
|
11295
11428
|
return true;
|
|
11296
11429
|
},
|
|
11297
11430
|
});
|
|
@@ -11307,9 +11440,9 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11307
11440
|
const status = gitmod.status(cwd);
|
|
11308
11441
|
if (!status.ok) { appErr(`git status failed: ${status.error}`); return; }
|
|
11309
11442
|
const relevant = target ? status.entries.filter((e) => e.path === target || e.path.startsWith(target + '/')) : status.entries;
|
|
11310
|
-
if (!relevant.length) { app('No uncommitted changes to review.'); return; }
|
|
11443
|
+
if (!relevant.length) { app(uiText('No uncommitted changes to review.')); return; }
|
|
11311
11444
|
if (stagedOnly && !relevant.some((e) => e.x !== ' ' && e.x !== '?')) {
|
|
11312
|
-
app('No staged changes to review.'); return;
|
|
11445
|
+
app(uiText('No staged changes to review.')); return;
|
|
11313
11446
|
}
|
|
11314
11447
|
const scope = stagedOnly ? 'staged changes' : 'working tree changes, including staged and untracked files';
|
|
11315
11448
|
const pathHint = target ? `Limit the review to ${JSON.stringify(target)}. ` : '';
|
|
@@ -11334,7 +11467,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11334
11467
|
const message = String(raw || '').trim();
|
|
11335
11468
|
if (!message) {
|
|
11336
11469
|
const s = gitmod.status(cwd);
|
|
11337
|
-
if (s.ok && !s.entries.length) { app('Nothing to commit — working tree is clean.'); return; }
|
|
11470
|
+
if (s.ok && !s.entries.length) { app(uiText('Nothing to commit — working tree is clean.')); return; }
|
|
11338
11471
|
const branch = gitmod.currentBranch(cwd);
|
|
11339
11472
|
const pending = gitmod.statusLines(cwd).slice(0, 40).join('\n');
|
|
11340
11473
|
await submit(
|
|
@@ -11371,7 +11504,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11371
11504
|
}
|
|
11372
11505
|
if (sub === '-c' || sub === 'create' || sub === 'new') {
|
|
11373
11506
|
const name = parts[1];
|
|
11374
|
-
if (!name) { appErr('Usage: /branch -c <name> [from]'); return; }
|
|
11507
|
+
if (!name) { appErr(uiText('Usage: /branch -c <name> [from]')); return; }
|
|
11375
11508
|
const r = gitmod.createBranch(name, cwd, parts[2]);
|
|
11376
11509
|
if (!r.ok) { appErr(`Could not create branch: ${r.error}`); return; }
|
|
11377
11510
|
app(`Switched to new branch: ${name}`);
|
|
@@ -11387,7 +11520,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11387
11520
|
if (!gitmod.isRepo(cwd)) { appErr(`Not a git repository: ${cwd}`); return; }
|
|
11388
11521
|
const base = String(raw || '').trim() || 'main';
|
|
11389
11522
|
const url = gitmod.prUrl(cwd, base);
|
|
11390
|
-
if (!url) { appErr('No git remote named "origin" — cannot build a PR URL.'); return; }
|
|
11523
|
+
if (!url) { appErr(uiText('No git remote named "origin" — cannot build a PR URL.')); return; }
|
|
11391
11524
|
const branch = gitmod.currentBranch(cwd);
|
|
11392
11525
|
sayPanel(`Open a pull request for ${branch} → ${base}:\n ${url}`);
|
|
11393
11526
|
// ACTUALLY COPY IT, and report what happened.
|
|
@@ -11397,7 +11530,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11397
11530
|
// so its result is what decides the message — a try/catch around it announced success either way.
|
|
11398
11531
|
let copied = false;
|
|
11399
11532
|
try { copied = copyText(url); } catch { copied = false; }
|
|
11400
|
-
if (copied) app('PR link copied to your clipboard');
|
|
11533
|
+
if (copied) app(uiText('PR link copied to your clipboard'));
|
|
11401
11534
|
else app('Could not reach the clipboard \u2014 the link is on screen above.');
|
|
11402
11535
|
return;
|
|
11403
11536
|
}
|
|
@@ -11415,7 +11548,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11415
11548
|
? 'The stable prefix (tools + system + conversation head) is marked cacheable.\n'
|
|
11416
11549
|
+ 'Providers bill cached input at a fraction of the normal rate. Effective\n'
|
|
11417
11550
|
+ 'for: anthropic (cache_control), openai-compatible (prompt_cache_key).'
|
|
11418
|
-
: 'Prompt caching disabled — every request sends the full prompt as fresh input.');
|
|
11551
|
+
: uiText('Prompt caching disabled — every request sends the full prompt as fresh input.'));
|
|
11419
11552
|
return;
|
|
11420
11553
|
}
|
|
11421
11554
|
case 'worktree': {
|
|
@@ -11430,7 +11563,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11430
11563
|
}
|
|
11431
11564
|
if (sub === 'add') {
|
|
11432
11565
|
const dir = parts[1];
|
|
11433
|
-
if (!dir) { appErr('Usage: /worktree add <dir> [branch]'); return; }
|
|
11566
|
+
if (!dir) { appErr(uiText('Usage: /worktree add <dir> [branch]')); return; }
|
|
11434
11567
|
const r = gitmod.addWorktree(dir, parts[2], cwd);
|
|
11435
11568
|
if (!r.ok) { appErr(`Could not add worktree: ${r.error}`); return; }
|
|
11436
11569
|
app(r.reused ? `Worktree already exists: ${r.path}` : `Worktree created: ${r.path}${r.branch ? ` [${r.branch}]` : ''}`);
|
|
@@ -11467,7 +11600,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11467
11600
|
}
|
|
11468
11601
|
if (sub === 'remove' || sub === 'rm') {
|
|
11469
11602
|
const dir = parts[1];
|
|
11470
|
-
if (!dir) { appErr('Usage: /worktree remove <dir>'); return; }
|
|
11603
|
+
if (!dir) { appErr(uiText('Usage: /worktree remove <dir>')); return; }
|
|
11471
11604
|
const force = parts.includes('--force');
|
|
11472
11605
|
const doRemove = () => {
|
|
11473
11606
|
const r = gitmod.removeWorktree(dir, cwd, { force });
|
|
@@ -11488,7 +11621,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11488
11621
|
],
|
|
11489
11622
|
onPick: (it) => {
|
|
11490
11623
|
if (it && it.label === 'Force remove') doRemove();
|
|
11491
|
-
else app('Worktree removal cancelled.');
|
|
11624
|
+
else app(uiText('Worktree removal cancelled.'));
|
|
11492
11625
|
return true;
|
|
11493
11626
|
},
|
|
11494
11627
|
});
|
|
@@ -11498,13 +11631,13 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11498
11631
|
doRemove();
|
|
11499
11632
|
return;
|
|
11500
11633
|
}
|
|
11501
|
-
appErr('Usage: /worktree [list] | new [name] [--branch] | add <dir> [branch] | remove <dir>');
|
|
11634
|
+
appErr(uiText('Usage: /worktree [list] | new [name] [--branch] | add <dir> [branch] | remove <dir>'));
|
|
11502
11635
|
return;
|
|
11503
11636
|
}
|
|
11504
11637
|
case 'logout': {
|
|
11505
11638
|
const pr = (cfg.raw && cfg.raw.providers) || {};
|
|
11506
11639
|
const names = Object.keys(pr);
|
|
11507
|
-
if (!names.length) { app('Nothing to logout.'); return; }
|
|
11640
|
+
if (!names.length) { app(uiText('Nothing to logout.')); return; }
|
|
11508
11641
|
const doLogout = (name) => {
|
|
11509
11642
|
const p = pr[name] || {};
|
|
11510
11643
|
delete p.api_key;
|
|
@@ -11532,7 +11665,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11532
11665
|
// Without a `|` the FIRST word is the title and the rest is the body, which
|
|
11533
11666
|
// keeps the common one-liner short to type.
|
|
11534
11667
|
const parts = String(raw || '').trim();
|
|
11535
|
-
if (!parts) { appErr('Usage: /feedback <title> | <body>'); return; }
|
|
11668
|
+
if (!parts) { appErr(uiText('Usage: /feedback <title> | <body>')); return; }
|
|
11536
11669
|
const bar = parts.indexOf('|');
|
|
11537
11670
|
let title, body;
|
|
11538
11671
|
if (bar !== -1) {
|
|
@@ -11543,7 +11676,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11543
11676
|
title = sp === -1 ? parts : parts.slice(0, sp);
|
|
11544
11677
|
body = sp === -1 ? '' : parts.slice(sp + 1).trim();
|
|
11545
11678
|
}
|
|
11546
|
-
if (!title) { appErr('Usage: /feedback <title> | <body>'); return; }
|
|
11679
|
+
if (!title) { appErr(uiText('Usage: /feedback <title> | <body>')); return; }
|
|
11547
11680
|
// The body is EXACTLY what the user typed. Nothing is appended — a report
|
|
11548
11681
|
// the user did not write (an environment footer, a template) reads as noise
|
|
11549
11682
|
// in the issue form and has to be deleted before submitting.
|
|
@@ -11551,7 +11684,7 @@ export async function dispatch(cmdRaw, arg, state, cfg, session, h, submit, stdo
|
|
|
11551
11684
|
+ `?title=${encodeURIComponent(title)}`
|
|
11552
11685
|
+ (body ? `&body=${encodeURIComponent(body)}` : '');
|
|
11553
11686
|
sayPanel(`Open a GitHub issue:\n ${url}`);
|
|
11554
|
-
app('Issue link copied to the transcript (Ctrl+Shift+C to copy).');
|
|
11687
|
+
app(uiText('Issue link copied to the transcript (Ctrl+Shift+C to copy).'));
|
|
11555
11688
|
return;
|
|
11556
11689
|
}
|
|
11557
11690
|
case 'exit': quit(); return;
|
|
@@ -11749,7 +11882,8 @@ export async function askSideQuestion(state, cfg, question, repaint) {
|
|
|
11749
11882
|
try {
|
|
11750
11883
|
if (!state.sideThread) {
|
|
11751
11884
|
state.sideThread = new SideThread({
|
|
11752
|
-
basePrompt: (cfg.systemPrompt && String(cfg.systemPrompt).trim()) || SYSTEM_PROMPT
|
|
11885
|
+
basePrompt: ((cfg.systemPrompt && String(cfg.systemPrompt).trim()) || SYSTEM_PROMPT)
|
|
11886
|
+
+ (needsThinkingTags(cfg) ? `\n\n${THINKING_TAGS_INSTRUCTION}` : ''),
|
|
11753
11887
|
tools: SIDE_RO_TOOLS,
|
|
11754
11888
|
model: modelCfg.model || cfg.model,
|
|
11755
11889
|
});
|
|
@@ -12501,6 +12635,19 @@ async function runTurn(deps, text, opts = {}, viewArg) {
|
|
|
12501
12635
|
const basePrompt = (cfg.systemPrompt && String(cfg.systemPrompt).trim()) || SYSTEM_PROMPT;
|
|
12502
12636
|
let sysText = basePrompt;
|
|
12503
12637
|
|
|
12638
|
+
// THE INLINE-REASONING INSTRUCTION, ONLY WHERE IT IS THE ONLY WAY TO GET IT.
|
|
12639
|
+
//
|
|
12640
|
+
// A model with its own reasoning channel reports it through the API (Anthropic's
|
|
12641
|
+
// `thinking`, OpenAI's and DeepSeek's `reasoning_content`), and hncode already renders
|
|
12642
|
+
// that as the thinking block. Telling such a model to ALSO wrap its reasoning in
|
|
12643
|
+
// `<|thinking|>…<|/thinking|>` asks for the same reasoning twice — once in the channel
|
|
12644
|
+
// and once as literal text in the answer, which ends up duplicated on screen or left in
|
|
12645
|
+
// the reply as noise. A model with no channel has nothing but the tag, so there it is
|
|
12646
|
+
// attached.
|
|
12647
|
+
if (needsThinkingTags(cfg)) {
|
|
12648
|
+
sysText += '\n\n' + THINKING_TAGS_INSTRUCTION;
|
|
12649
|
+
}
|
|
12650
|
+
|
|
12504
12651
|
// APPEND rather than replace — the safer of the two prompt knobs, and the one to reach
|
|
12505
12652
|
// for when the built-in prompt already does most of what you want.
|
|
12506
12653
|
if (cfg.appendSystemPrompt && String(cfg.appendSystemPrompt).trim()) {
|
|
@@ -13581,15 +13728,38 @@ const agents = readAgentsMd(state.cwd || state.workspace || cfg.workspace, state
|
|
|
13581
13728
|
if (state.running) return;
|
|
13582
13729
|
const label = task.status === 'completed' ? 'finished' : String(task.status || 'finished');
|
|
13583
13730
|
const id = task.taskId || task.id || '';
|
|
13584
|
-
|
|
13585
|
-
|
|
13731
|
+
// THE CONCLUSION, NOT THE OUTPUT.
|
|
13732
|
+
//
|
|
13733
|
+
// This used to hand the model the first 40 lines of the task's raw output. A
|
|
13734
|
+
// backgrounded build, a test run or a deploy log is thousands of lines, and
|
|
13735
|
+
// pasting a slice of it into the conversation costs tokens on EVERY later turn,
|
|
13736
|
+
// because the history keeps it. The model does not need the log to decide what
|
|
13737
|
+
// to do — it needs to know the task finished, what it was, and that the output
|
|
13738
|
+
// is there to be read.
|
|
13739
|
+
//
|
|
13740
|
+
// So the message is a status line and a pointer. If the model decides the output
|
|
13741
|
+
// matters, it calls TaskOutput for the slice it wants; if it does not, the log
|
|
13742
|
+
// never enters the conversation at all.
|
|
13743
|
+
const lines = [
|
|
13586
13744
|
`A background task you started has ${label}${id ? ': ' + id : ''}.`,
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13745
|
+
];
|
|
13746
|
+
const what = String(task.description || task.command || '').trim();
|
|
13747
|
+
if (what) lines.push(`What it was: ${what}`);
|
|
13748
|
+
if (task.exitCode != null) lines.push(`Exit code: ${task.exitCode}`);
|
|
13749
|
+
if (task.stopReason) lines.push(`Reason: ${String(task.stopReason).slice(0, 200)}`);
|
|
13750
|
+
const outBytes = Number(task._bytes) || 0;
|
|
13751
|
+
lines.push(
|
|
13752
|
+
outBytes
|
|
13753
|
+
? `Its output is ${Math.round(outBytes / 1024)} KB and has NOT been included here.`
|
|
13754
|
+
: 'It produced no output.',
|
|
13755
|
+
);
|
|
13756
|
+
lines.push('');
|
|
13757
|
+
lines.push(
|
|
13758
|
+
'Do not guess at the result from the status alone. If the output matters, read it with '
|
|
13759
|
+
+ `TaskOutput { task_id: "${id}" } — it takes a head_limit. Then decide what to do next: `
|
|
13760
|
+
+ 'if it finished, summarise the result for the user; if it failed, say why and what you will change.',
|
|
13761
|
+
);
|
|
13762
|
+
void sessHost.submit(lines.join('\n'));
|
|
13593
13763
|
};
|
|
13594
13764
|
}
|
|
13595
13765
|
await agent.run();
|
|
@@ -14734,6 +14904,15 @@ export async function startTUI(opts) {
|
|
|
14734
14904
|
if (wait === 0) { setImmediate(paintNow); return; }
|
|
14735
14905
|
setTimeout(paintNow, wait);
|
|
14736
14906
|
}
|
|
14907
|
+
// THE MERMAID REPAINT HOOK.
|
|
14908
|
+
//
|
|
14909
|
+
// The mermaid renderer is loaded on first use, so the first frame of a diagram draws
|
|
14910
|
+
// its source and the module arrives a moment later. Nothing repainted at that point, so
|
|
14911
|
+
// the source stayed on screen for the rest of the session — the diagram never appeared
|
|
14912
|
+
// at all. The renderer cannot ask for a frame itself (it is a pure function), so the
|
|
14913
|
+
// repaint is injected here.
|
|
14914
|
+
onMermaidReady(() => renderSoon());
|
|
14915
|
+
|
|
14737
14916
|
function openPicker(p) {
|
|
14738
14917
|
let footer = p.footer ? { focused: false, ...p.footer } : null;
|
|
14739
14918
|
if (p.footerFor) {
|
|
@@ -15151,9 +15330,9 @@ export async function startTUI(opts) {
|
|
|
15151
15330
|
if (!ap) return [];
|
|
15152
15331
|
const out = [];
|
|
15153
15332
|
const tool = String(ap.toolName || 'a tool');
|
|
15154
|
-
out.push('The agent is waiting for permission to run ' + tool + '.');
|
|
15333
|
+
out.push(uiText('The agent is waiting for permission to run ') + tool + '.');
|
|
15155
15334
|
out.push('');
|
|
15156
|
-
if (ap.desc) { out.push('Summary: ' + ap.desc); out.push(''); }
|
|
15335
|
+
if (ap.desc) { out.push(uiText('Summary: ') + ap.desc); out.push(''); }
|
|
15157
15336
|
|
|
15158
15337
|
// EVERY ARGUMENT, ITS OWN NAME, IN FULL.
|
|
15159
15338
|
const args = ap.args && typeof ap.args === 'object' ? ap.args : null;
|
|
@@ -16236,7 +16415,7 @@ export async function startTUI(opts) {
|
|
|
16236
16415
|
} else if (stamp && stamp.status === 'error') {
|
|
16237
16416
|
// Left in place: /update reports it with the full npm output on demand, and the
|
|
16238
16417
|
// one-line summary here would be lost in the startup scroll.
|
|
16239
|
-
notice('The last background update failed. Run /update to see why.');
|
|
16418
|
+
notice(uiText('The last background update failed. Run /update to see why.'));
|
|
16240
16419
|
}
|
|
16241
16420
|
}
|
|
16242
16421
|
const runAutoCheck = async () => {
|
|
@@ -16522,6 +16701,13 @@ export async function startTUI(opts) {
|
|
|
16522
16701
|
dispatchFromStatusBar('model');
|
|
16523
16702
|
return true;
|
|
16524
16703
|
}
|
|
16704
|
+
case 'statusTasks': {
|
|
16705
|
+
// Click the running-task badge -> the task panel, where the tasks are listed and
|
|
16706
|
+
// can be read or stopped. The count is the only place on the screen that says
|
|
16707
|
+
// something is running, so it is the place to open the list from.
|
|
16708
|
+
dispatchFromStatusBar('tasks');
|
|
16709
|
+
return true;
|
|
16710
|
+
}
|
|
16525
16711
|
case 'composerRow': {
|
|
16526
16712
|
const { cols } = dims();
|
|
16527
16713
|
const insideW = Math.max(0, cols - 2);
|
|
@@ -16904,7 +17090,7 @@ export async function startTUI(opts) {
|
|
|
16904
17090
|
// The notice line is the second half of the cue: the highlight says WHICH, the hint says WHAT a
|
|
16905
17091
|
// click would do. It is cleared when the pointer leaves, so it never outlives the pointer being
|
|
16906
17092
|
// on the chip.
|
|
16907
|
-
if (pasteHover != null) notice('Ctrl+Click to expand it', 'info');
|
|
17093
|
+
if (pasteHover != null) notice(uiText('Ctrl+Click to expand it'), 'info');
|
|
16908
17094
|
else clearNotice();
|
|
16909
17095
|
renderFrame();
|
|
16910
17096
|
}
|
|
@@ -17138,14 +17324,14 @@ export async function startTUI(opts) {
|
|
|
17138
17324
|
// clipboard, and the old code ignored that — it announced "Copied 0 chars"
|
|
17139
17325
|
// while the clipboard kept whatever was in it, which reads as "copy did not
|
|
17140
17326
|
// work" with no way to tell why.
|
|
17141
|
-
if (!text) { notice('Nothing to copy', 'error'); return; }
|
|
17327
|
+
if (!text) { notice(uiText('Nothing to copy'), 'error'); return; }
|
|
17142
17328
|
try {
|
|
17143
17329
|
const ok = copyText(text); // src/clipboard.js: clip.exe on Windows
|
|
17144
|
-
if (ok === false) { notice('Clipboard unavailable', 'error'); return; }
|
|
17330
|
+
if (ok === false) { notice(uiText('Clipboard unavailable'), 'error'); return; }
|
|
17145
17331
|
const n = text.split('\n').length;
|
|
17146
17332
|
notice(`Copied ${text.length} chars (${n} line${n === 1 ? '' : 's'})`, 'info');
|
|
17147
17333
|
} catch (e) {
|
|
17148
|
-
notice('Clipboard unavailable: ' + (e && e.message ? e.message : e), 'error');
|
|
17334
|
+
notice(uiText('Clipboard unavailable: ') + (e && e.message ? e.message : e), 'error');
|
|
17149
17335
|
}
|
|
17150
17336
|
}
|
|
17151
17337
|
// Insert pasted text into the composer, collapsing a multi-line paste into a
|
|
@@ -17284,19 +17470,19 @@ export async function startTUI(opts) {
|
|
|
17284
17470
|
// temp file path. On submit the chip expands back to that path, which is what
|
|
17285
17471
|
// the agent's ReadMediaFile needs.
|
|
17286
17472
|
insertComposerPaste(text, via === 'image' ? 'image' : 'paste');
|
|
17287
|
-
notice(via === 'image' ? 'Pasted image' : (via === 'text' ? 'Pasted' : `Pasted ${via} as path`), 'info');
|
|
17473
|
+
notice(via === 'image' ? uiText('Pasted image') : (via === 'text' ? 'Pasted' : `Pasted ${via} as path`), 'info');
|
|
17288
17474
|
renderFrame();
|
|
17289
17475
|
return;
|
|
17290
17476
|
}
|
|
17291
17477
|
// Fast path failed — only fall back to the slow warm-helper reader when this
|
|
17292
17478
|
// is a full paste (Ctrl+Shift+V), not a right-click quick paste.
|
|
17293
17479
|
if (fastPathOnly) {
|
|
17294
|
-
notice('Clipboard empty or unavailable', 'error');
|
|
17480
|
+
notice(uiText('Clipboard empty or unavailable'), 'error');
|
|
17295
17481
|
renderFrame();
|
|
17296
17482
|
return;
|
|
17297
17483
|
}
|
|
17298
17484
|
const result = await readText();
|
|
17299
|
-
if (!result.text) { notice('Clipboard empty or unavailable', 'error'); renderFrame(); return; }
|
|
17485
|
+
if (!result.text) { notice(uiText('Clipboard empty or unavailable'), 'error'); renderFrame(); return; }
|
|
17300
17486
|
insertComposerPaste(result.text);
|
|
17301
17487
|
notice(`Pasted via ${result.via}`, 'info');
|
|
17302
17488
|
renderFrame();
|
|
@@ -17308,7 +17494,7 @@ export async function startTUI(opts) {
|
|
|
17308
17494
|
// call, since nothing can be injected into a request already in flight.
|
|
17309
17495
|
function steerAll() {
|
|
17310
17496
|
if (!state.running || !state.agent) {
|
|
17311
|
-
notice('Nothing to steer into (the agent is idle)', 'error');
|
|
17497
|
+
notice(uiText('Nothing to steer into (the agent is idle)'), 'error');
|
|
17312
17498
|
renderFrame();
|
|
17313
17499
|
return;
|
|
17314
17500
|
}
|
|
@@ -17322,7 +17508,7 @@ export async function startTUI(opts) {
|
|
|
17322
17508
|
const draft = rawDraft.trim() ? expandPastes(rawDraft, state.pastes).trim() : '';
|
|
17323
17509
|
if (draft) items.push(draft);
|
|
17324
17510
|
if (!items.length) {
|
|
17325
|
-
notice('Nothing queued to steer', 'error');
|
|
17511
|
+
notice(uiText('Nothing queued to steer'), 'error');
|
|
17326
17512
|
renderFrame();
|
|
17327
17513
|
return;
|
|
17328
17514
|
}
|
|
@@ -17381,11 +17567,11 @@ export async function startTUI(opts) {
|
|
|
17381
17567
|
onPick: (it) => {
|
|
17382
17568
|
if (it.action === 'editor-copy') {
|
|
17383
17569
|
const text = editorSelectedText();
|
|
17384
|
-
if (text) copyToClipboard(text); else notice('Nothing selected', 'error');
|
|
17570
|
+
if (text) copyToClipboard(text); else notice(uiText('Nothing selected'), 'error');
|
|
17385
17571
|
}
|
|
17386
17572
|
else if (it.action === 'editor-cut') {
|
|
17387
17573
|
const text = editorSelectedText();
|
|
17388
|
-
if (!text) { notice('Nothing selected', 'error'); return true; }
|
|
17574
|
+
if (!text) { notice(uiText('Nothing selected'), 'error'); return true; }
|
|
17389
17575
|
copyToClipboard(text);
|
|
17390
17576
|
editorReplace('');
|
|
17391
17577
|
}
|
|
@@ -17393,7 +17579,7 @@ export async function startTUI(opts) {
|
|
|
17393
17579
|
const clip = readClipboardContentAsync();
|
|
17394
17580
|
void clip.then((r) => {
|
|
17395
17581
|
const text = r && r.text ? String(r.text) : '';
|
|
17396
|
-
if (!text) { notice('Clipboard is empty', 'error'); return; }
|
|
17582
|
+
if (!text) { notice(uiText('Clipboard is empty'), 'error'); return; }
|
|
17397
17583
|
editorReplace(text);
|
|
17398
17584
|
});
|
|
17399
17585
|
}
|
|
@@ -17434,7 +17620,7 @@ export async function startTUI(opts) {
|
|
|
17434
17620
|
// guard returned '' — Copy always answered "Nothing to copy".
|
|
17435
17621
|
const text = selectionText(true);
|
|
17436
17622
|
if (text) copyToClipboard(text);
|
|
17437
|
-
else notice('Nothing to copy — select text first', 'error');
|
|
17623
|
+
else notice(uiText('Nothing to copy — select text first'), 'error');
|
|
17438
17624
|
}
|
|
17439
17625
|
else if (it.action === 'copy-composer') {
|
|
17440
17626
|
const sel = state.composerSel;
|
|
@@ -17455,7 +17641,7 @@ export async function startTUI(opts) {
|
|
|
17455
17641
|
}
|
|
17456
17642
|
else if (it.action === 'copy-last') {
|
|
17457
17643
|
const last = [...state.chat].reverse().find((m) => m.role === 'assistant' && (m.text || '').trim());
|
|
17458
|
-
if (last) copyToClipboard(last.text); else notice('No assistant message to copy', 'error');
|
|
17644
|
+
if (last) copyToClipboard(last.text); else notice(uiText('No assistant message to copy'), 'error');
|
|
17459
17645
|
} else if (it.action === 'clear') { state.selection = null; }
|
|
17460
17646
|
else if (it.action === 'clear-composer') { state.composerSel = null; }
|
|
17461
17647
|
else if (it.action === 'paste') {
|
|
@@ -17673,7 +17859,7 @@ export async function startTUI(opts) {
|
|
|
17673
17859
|
try { state.agent.interrupt(); } catch { /* an already-finished turn */ }
|
|
17674
17860
|
// THE GOAL MUST NOT RESTART THIS TURN. See `_userInterrupted` at the goal decision below.
|
|
17675
17861
|
state._userInterrupted = true;
|
|
17676
|
-
notice('Interrupted', 'info');
|
|
17862
|
+
notice(uiText('Interrupted'), 'info');
|
|
17677
17863
|
renderFrame();
|
|
17678
17864
|
return;
|
|
17679
17865
|
}
|
|
@@ -17722,6 +17908,15 @@ export async function startTUI(opts) {
|
|
|
17722
17908
|
// exit" prompt, because a key whose whole meaning here is "stop this" must not also be able
|
|
17723
17909
|
// to quit. An open overlay is excluded so Esc keeps its other job of closing one.
|
|
17724
17910
|
if (state.agent) state.agent.interrupt();
|
|
17911
|
+
// MANUAL /compact RUNS WITHOUT AN AGENT, so `interrupt()` above does nothing and
|
|
17912
|
+
// this branch used to return having done NOTHING AT ALL — Esc appeared dead for the
|
|
17913
|
+
// whole summariser round-trip, which is the one operation the user most wants to
|
|
17914
|
+
// stop (it can take a minute on a long history). The summariser is abortable, and
|
|
17915
|
+
// the /compact handler checks the flag before it trims.
|
|
17916
|
+
if (state._compactLlm) {
|
|
17917
|
+
state._compactAborted = true;
|
|
17918
|
+
try { state._compactLlm.abort(); } catch { /* already finished */ }
|
|
17919
|
+
}
|
|
17725
17920
|
// THE GOAL MUST NOT RESTART THIS TURN. See `_userInterrupted` at the goal decision below.
|
|
17726
17921
|
state._userInterrupted = true;
|
|
17727
17922
|
return;
|
|
@@ -17901,7 +18096,7 @@ export async function startTUI(opts) {
|
|
|
17901
18096
|
// next question and left this one unanswered. The user could not tell "submitted nothing" from
|
|
17902
18097
|
// "submitted", and the skipped question came back at the end looking like a fresh prompt.
|
|
17903
18098
|
if (!labels.length) {
|
|
17904
|
-
appErr('Pick at least one option with Space, or type an answer under Other.');
|
|
18099
|
+
appErr(uiText('Pick at least one option with Space, or type an answer under Other.'));
|
|
17905
18100
|
renderFrame();
|
|
17906
18101
|
return;
|
|
17907
18102
|
}
|
|
@@ -17953,7 +18148,7 @@ export async function startTUI(opts) {
|
|
|
17953
18148
|
if (!(state.picker || state.form || state.panel || state.editor || state.question || state.menuOpen)) {
|
|
17954
18149
|
const current = (cfg && cfg.provider) || '';
|
|
17955
18150
|
if (!current) {
|
|
17956
|
-
notice('No provider selected — use /model to pick one.', 'error');
|
|
18151
|
+
notice(uiText('No provider selected — use /model to pick one.'), 'error');
|
|
17957
18152
|
} else {
|
|
17958
18153
|
// Fire and forget: the notice reports the outcome, and blocking the key handler on a network
|
|
17959
18154
|
// round-trip would freeze input for as long as the endpoint takes.
|
|
@@ -18026,7 +18221,7 @@ export async function startTUI(opts) {
|
|
|
18026
18221
|
const cur = state.input || '';
|
|
18027
18222
|
if (!cur) {
|
|
18028
18223
|
// Nothing to select: say so rather than silently doing nothing, which reads as a dead key.
|
|
18029
|
-
notice('Nothing to select', 'error');
|
|
18224
|
+
notice(uiText('Nothing to select'), 'error');
|
|
18030
18225
|
renderFrame();
|
|
18031
18226
|
return;
|
|
18032
18227
|
}
|
|
@@ -18056,7 +18251,7 @@ export async function startTUI(opts) {
|
|
|
18056
18251
|
copyToClipboard(removed);
|
|
18057
18252
|
refreshMenu(state);
|
|
18058
18253
|
} else {
|
|
18059
|
-
notice('Nothing selected to cut', 'error');
|
|
18254
|
+
notice(uiText('Nothing selected to cut'), 'error');
|
|
18060
18255
|
}
|
|
18061
18256
|
renderFrame();
|
|
18062
18257
|
return;
|
|
@@ -18076,7 +18271,7 @@ export async function startTUI(opts) {
|
|
|
18076
18271
|
if (state.selection && state.selection.anchor && state.selection.head) {
|
|
18077
18272
|
const sel = selectionText();
|
|
18078
18273
|
if (sel) copyToClipboard(sel);
|
|
18079
|
-
else notice('Nothing to copy — the selection is empty', 'error');
|
|
18274
|
+
else notice(uiText('Nothing to copy — the selection is empty'), 'error');
|
|
18080
18275
|
} else {
|
|
18081
18276
|
const composerSel = state.composerSel;
|
|
18082
18277
|
if (composerSel && composerSel.anchor !== composerSel.head) {
|
|
@@ -18084,7 +18279,7 @@ export async function startTUI(opts) {
|
|
|
18084
18279
|
const h = Math.max(composerSel.anchor, composerSel.head);
|
|
18085
18280
|
copyToClipboard((state.input || '').slice(a, h));
|
|
18086
18281
|
} else {
|
|
18087
|
-
notice('Nothing to copy — select text first (or use the right-click menu)', 'error');
|
|
18282
|
+
notice(uiText('Nothing to copy — select text first (or use the right-click menu)'), 'error');
|
|
18088
18283
|
}
|
|
18089
18284
|
}
|
|
18090
18285
|
renderFrame();
|
|
@@ -18126,8 +18321,8 @@ export async function startTUI(opts) {
|
|
|
18126
18321
|
// SAY SO. Ctrl+B with no foreground command used to fall through silently, so there was no way to tell "the
|
|
18127
18322
|
// shortcut is broken" from "nothing was running" — and a steer arriving mid-turn made that confusion easy.
|
|
18128
18323
|
notice(state.running
|
|
18129
|
-
? 'Nothing to background — no command is running in the foreground'
|
|
18130
|
-
: 'Nothing to background — the agent is idle', 'error');
|
|
18324
|
+
? uiText('Nothing to background — no command is running in the foreground')
|
|
18325
|
+
: uiText('Nothing to background — the agent is idle'), 'error');
|
|
18131
18326
|
renderFrame();
|
|
18132
18327
|
return;
|
|
18133
18328
|
}
|
|
@@ -18137,7 +18332,7 @@ export async function startTUI(opts) {
|
|
|
18137
18332
|
// because the composer has to go back to the model when the answer is done.
|
|
18138
18333
|
const fg = state.agent && state.agent.ctx && state.agent.ctx._foreground;
|
|
18139
18334
|
if (!fg || typeof fg.write !== 'function') {
|
|
18140
|
-
notice('Nothing is waiting for input — no command is running in the foreground', 'error');
|
|
18335
|
+
notice(uiText('Nothing is waiting for input — no command is running in the foreground'), 'error');
|
|
18141
18336
|
renderFrame();
|
|
18142
18337
|
return;
|
|
18143
18338
|
}
|
|
@@ -18145,8 +18340,8 @@ export async function startTUI(opts) {
|
|
|
18145
18340
|
// The renderer is module-level and cannot read `state`, so the mode rides on the RUNNING Bash message.
|
|
18146
18341
|
for (const m of state.chat || []) if (m.role === 'tool' && m.toolName === 'Bash' && m.pending) m._stdinMode = state.stdinMode;
|
|
18147
18342
|
notice(state.stdinMode
|
|
18148
|
-
? 'Input goes to the running command (Ctrl+G to stop)'
|
|
18149
|
-
: 'Input goes back to the model', 'info');
|
|
18343
|
+
? uiText('Input goes to the running command (Ctrl+G to stop)')
|
|
18344
|
+
: uiText('Input goes back to the model'), 'info');
|
|
18150
18345
|
renderFrame();
|
|
18151
18346
|
return;
|
|
18152
18347
|
}
|
|
@@ -18174,7 +18369,7 @@ export async function startTUI(opts) {
|
|
|
18174
18369
|
const after = todoRowCount(state);
|
|
18175
18370
|
if (before === after) {
|
|
18176
18371
|
state.todosExpanded = !state.todosExpanded; // undo: nothing to toggle
|
|
18177
|
-
notice(total ? `Todo panel already shows all ${total}` : 'No todos yet', 'info');
|
|
18372
|
+
notice(total ? `Todo panel already shows all ${total}` : uiText('No todos yet'), 'info');
|
|
18178
18373
|
renderFrame();
|
|
18179
18374
|
return;
|
|
18180
18375
|
}
|
|
@@ -18187,7 +18382,7 @@ export async function startTUI(opts) {
|
|
|
18187
18382
|
|
|
18188
18383
|
if (t.key === 'c-o' && !state.editor) {
|
|
18189
18384
|
state.expanded = !state.expanded;
|
|
18190
|
-
notice(state.expanded ? 'Expanded tool output' : 'Collapsed tool output', 'info');
|
|
18385
|
+
notice(state.expanded ? uiText('Expanded tool output') : uiText('Collapsed tool output'), 'info');
|
|
18191
18386
|
renderFrame();
|
|
18192
18387
|
return;
|
|
18193
18388
|
}
|
|
@@ -18217,7 +18412,7 @@ export async function startTUI(opts) {
|
|
|
18217
18412
|
const target = [...state.chat].reverse().find((m) => m
|
|
18218
18413
|
&& (m.role === 'tool_result' || m.role === 'assistant')
|
|
18219
18414
|
&& String(m.text || '').trim());
|
|
18220
|
-
if (!target) { notice('Nothing to show yet', 'info'); renderFrame(); return; }
|
|
18415
|
+
if (!target) { notice(uiText('Nothing to show yet'), 'info'); renderFrame(); return; }
|
|
18221
18416
|
const title = target.role === 'tool_result'
|
|
18222
18417
|
? `Output — ${target.toolName || 'tool'}`
|
|
18223
18418
|
: 'Reply';
|
|
@@ -18395,7 +18590,7 @@ export async function startTUI(opts) {
|
|
|
18395
18590
|
if (t.key === 'c-s') {
|
|
18396
18591
|
const cb = ed.onSave;
|
|
18397
18592
|
state.editor = null;
|
|
18398
|
-
try { if (cb) cb(ed.text); } catch (e) { notice('Save failed: ' + e.message, 'error'); }
|
|
18593
|
+
try { if (cb) cb(ed.text); } catch (e) { notice(uiText('Save failed: ') + e.message, 'error'); }
|
|
18399
18594
|
renderFrame();
|
|
18400
18595
|
return;
|
|
18401
18596
|
}
|
|
@@ -18686,7 +18881,7 @@ export async function startTUI(opts) {
|
|
|
18686
18881
|
state.btwPanel = null;
|
|
18687
18882
|
state.btwScroll = 0;
|
|
18688
18883
|
state.sideThread = null;
|
|
18689
|
-
notice('Side thread closed.', 'info');
|
|
18884
|
+
notice(uiText('Side thread closed.'), 'info');
|
|
18690
18885
|
renderFrame();
|
|
18691
18886
|
return;
|
|
18692
18887
|
}
|
|
@@ -19286,14 +19481,14 @@ function wheelStep(state, family) {
|
|
|
19286
19481
|
if (text.startsWith('@')) {
|
|
19287
19482
|
const m = /^@([\w-]+)\s+([\s\S]+)$/.exec(text);
|
|
19288
19483
|
if (!m) {
|
|
19289
|
-
notice('Use `@name message` to send straight to a member.', 'error');
|
|
19484
|
+
notice(uiText('Use `@name message` to send straight to a member.'), 'error');
|
|
19290
19485
|
renderFrame();
|
|
19291
19486
|
return;
|
|
19292
19487
|
}
|
|
19293
19488
|
const [, who, body] = m;
|
|
19294
19489
|
const teamName = leadTeam();
|
|
19295
19490
|
if (!teamName) {
|
|
19296
|
-
notice('No team. Create one: /team create <name>', 'error');
|
|
19491
|
+
notice(uiText('No team. Create one: /team create <name>'), 'error');
|
|
19297
19492
|
renderFrame();
|
|
19298
19493
|
return;
|
|
19299
19494
|
}
|
|
@@ -19356,7 +19551,7 @@ function wheelStep(state, family) {
|
|
|
19356
19551
|
// The command is gone; the write reported failure, so the line was NOT delivered.
|
|
19357
19552
|
state.stdinMode = false;
|
|
19358
19553
|
for (const m of state.chat || []) if (m._stdinMode) m._stdinMode = false;
|
|
19359
|
-
notice('That command has finished — input goes to the model again', 'error');
|
|
19554
|
+
notice(uiText('That command has finished — input goes to the model again'), 'error');
|
|
19360
19555
|
renderFrame();
|
|
19361
19556
|
return;
|
|
19362
19557
|
}
|
|
@@ -19950,7 +20145,7 @@ function wheelStep(state, family) {
|
|
|
19950
20145
|
}
|
|
19951
20146
|
|
|
19952
20147
|
function stopWeb() {
|
|
19953
|
-
if (!web) { notice('Web UI is not running', 'error'); return false; }
|
|
20148
|
+
if (!web) { notice(uiText('Web UI is not running'), 'error'); return false; }
|
|
19954
20149
|
// Tell the daemon first, so its directory stops listing this session instead
|
|
19955
20150
|
// of showing a link to a port that is about to disappear.
|
|
19956
20151
|
if (webDaemon) {
|
|
@@ -19987,6 +20182,10 @@ function wheelStep(state, family) {
|
|
|
19987
20182
|
// The session's own server first: the daemon needs a port to proxy to.
|
|
19988
20183
|
const srv = await startWeb(host, port == null ? 0 : port);
|
|
19989
20184
|
try {
|
|
20185
|
+
// IMPORTED HERE, NOT AT THE TOP. This chain pulls in web-daemon.js and measures ~76ms
|
|
20186
|
+
// to evaluate, and only /web ever reaches it — every other session paid that on
|
|
20187
|
+
// startup for a command it never runs.
|
|
20188
|
+
const { attachToDaemon } = await import('./web-daemon-client.js');
|
|
19990
20189
|
webDaemon = await attachToDaemon({
|
|
19991
20190
|
id: (session && session.id) || 'session',
|
|
19992
20191
|
port: srv.port,
|
|
@@ -20665,7 +20864,7 @@ function quit() {
|
|
|
20665
20864
|
`Web UI: ${srv.url}`,
|
|
20666
20865
|
`Bind: ${srv.host}:${srv.port}${lan ? ' (reachable from the network)' : ' (this machine only)'}`,
|
|
20667
20866
|
'',
|
|
20668
|
-
'Access token (paste it into the login page):',
|
|
20867
|
+
uiText('Access token (paste it into the login page):'),
|
|
20669
20868
|
'',
|
|
20670
20869
|
` ${srv.token}`,
|
|
20671
20870
|
'',
|