@hncode/hncode 0.8.3 → 0.8.4
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/package.json +1 -1
- package/src/context-bar.js +5 -4
- package/src/i18n.js +6 -0
- package/src/rows-tool-result.js +10 -1
- package/src/tui.js +26 -13
package/package.json
CHANGED
package/src/context-bar.js
CHANGED
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
// pointing at one prints its full name and value in the row below the bar. That is why step
|
|
33
33
|
// 3 is acceptable — the information stays one pointer away.
|
|
34
34
|
|
|
35
|
-
import { C } from './colors.js';
|
|
35
|
+
import { C } from './colors.js';
|
|
36
|
+
import { visualWidth } from './term.js';
|
|
36
37
|
import { uiText } from './i18n.js';
|
|
37
38
|
|
|
38
39
|
/** The segments, in the order they are drawn. Order is part of the reading: the session
|
|
@@ -142,8 +143,8 @@ export function renderContextBar(segments, usedTokens, window, width, readout) {
|
|
|
142
143
|
const figures = `${compactTokens(usedTokens)}/${compactTokens(window)}`;
|
|
143
144
|
const own = typeof readout === 'string' ? readout : '';
|
|
144
145
|
const forms = [...new Set([own, `${figures} ${pct}`, pct].filter(Boolean))];
|
|
145
|
-
const text = forms.find((f) => f
|
|
146
|
-
const barWidth = Math.max(0, width - text
|
|
146
|
+
const text = forms.find((f) => visualWidth(f) + 1 <= width) || '';
|
|
147
|
+
const barWidth = Math.max(0, width - visualWidth(text) - 1);
|
|
147
148
|
|
|
148
149
|
if (barWidth <= 0) {
|
|
149
150
|
// Too narrow for a bar AND a gap: the readout has the row to itself. Padded to exactly
|
|
@@ -209,7 +210,7 @@ function paintBar(cols, freeCols, _unused, values, readout, width) {
|
|
|
209
210
|
// `at` is the bar's visible width and the row is `width` wide, so the gap is whatever is
|
|
210
211
|
// left minus the figures — at least one column, which is what keeps `11.7k/97` from reading
|
|
211
212
|
// as a continuation of a segment's fill.
|
|
212
|
-
const gap = Math.max(1, width - at - readout
|
|
213
|
+
const gap = Math.max(1, width - at - visualWidth(readout));
|
|
213
214
|
out += C.reset + ' '.repeat(gap) + C.white + readout;
|
|
214
215
|
|
|
215
216
|
return { text: out + C.reset, hits };
|
package/src/i18n.js
CHANGED
|
@@ -682,6 +682,11 @@ export const MESSAGES = {
|
|
|
682
682
|
'plan.summary': { zh: "步骤:{steps} 行数:{lines} 涉及文件:{files}", en: "Steps: {steps} Lines: {lines} Files mentioned: {files}" },
|
|
683
683
|
'plan.andMore': { zh: "… 另有 {n} 个", en: "… and {n} more" },
|
|
684
684
|
'keybindings.header': { zh: "快捷键({n})— {file}", en: "Keybindings ({n}) — {file}" },
|
|
685
|
+
// ---- the status row tallies ----
|
|
686
|
+
'status.turns': { zh: "{n} 轮", en: "{n} turns" },
|
|
687
|
+
'status.turnsOne': { zh: "{n} 轮", en: "{n} turn" },
|
|
688
|
+
'status.steps': { zh: "{n} 步", en: "{n} steps" },
|
|
689
|
+
'status.stepsOne': { zh: "{n} 步", en: "{n} step" },
|
|
685
690
|
};
|
|
686
691
|
|
|
687
692
|
|
|
@@ -1390,6 +1395,7 @@ export const NOTICE_ZH = {
|
|
|
1390
1395
|
"Browse everything with /settings,": "用 /settings 浏览全部,",
|
|
1391
1396
|
"or set one directly: /set <key> <value>": "或直接设置:/set <key> <value>",
|
|
1392
1397
|
"WebSearch keys cleared — searches use keyless mode (rate-limited per IP).": "WebSearch 密钥已清除 — 搜索改用无密钥模式(按 IP 限流)",
|
|
1398
|
+
"cost": "费用",
|
|
1393
1399
|
};
|
|
1394
1400
|
|
|
1395
1401
|
// The UI's active language, shared with the render modules (rows, panels, file tree)
|
package/src/rows-tool-result.js
CHANGED
|
@@ -25,8 +25,17 @@ export function toolResultRows(msg, width, expanded) {
|
|
|
25
25
|
// grey, which on a dark page made it a smudge in the margin rather than a marker. The
|
|
26
26
|
// plain text is kept for the comparisons below and for the width maths; the coloured one
|
|
27
27
|
// is what is drawn.
|
|
28
|
+
//
|
|
29
|
+
// IT CLOSES WITH THE ROW'S OWN COLOUR, NOT A RESET.
|
|
30
|
+
//
|
|
31
|
+
// The body colour is wrapped around the whole line by the caller (`color + text + reset`),
|
|
32
|
+
// so whatever this marker does to the foreground has to be undone before the body text
|
|
33
|
+
// follows. A `ESC[0m` closed the caller's colour too, and on a failed result the first line
|
|
34
|
+
// — the one carrying the marker — came out default grey while every line under it was red.
|
|
35
|
+
// Restating the body colour is the only form that survives either way.
|
|
28
36
|
const PRE = '↳ ';
|
|
29
|
-
const
|
|
37
|
+
const bodyFg = msg.failed ? C.red : C.gray;
|
|
38
|
+
const pre = C.marker + '↳ ' + bodyFg;
|
|
30
39
|
const cont = ' ';
|
|
31
40
|
const bodyW = Math.max(1, width - visualCol(cont));
|
|
32
41
|
// Strip escapes BEFORE splitting: a file or a command can emit raw cursor codes, and letting them through made the
|
package/src/tui.js
CHANGED
|
@@ -1616,15 +1616,15 @@ function messageLines(msg, width, workspace, expanded, spin, pulseStart, rawMode
|
|
|
1616
1616
|
// The comment state travels between the rows, so a block comment that opens on one line and closes on
|
|
1617
1617
|
// the next stays grey all the way down.
|
|
1618
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)));
|
|
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)));
|
|
1628
1628
|
lines.slice(0, MAX).forEach((ln, i) => {
|
|
1629
1629
|
const num = String(i + 1).padStart(wNum);
|
|
1630
1630
|
// A LINE LONGER THAN THE PANEL IS CUT, not wrapped. `raw: true` means the renderer does not wrap it for us,
|
|
@@ -5586,10 +5586,10 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
|
|
|
5586
5586
|
// The text goes through the i18n table so the badge reads the same in every
|
|
5587
5587
|
// language. The English form is kept in the table for the default language.
|
|
5588
5588
|
if (bashTasks > 0) {
|
|
5589
|
-
pushPart(col(tr('status.tasksBash', '[{n} task(s) running]', { n: bashTasks })), { kind: 'statusTasks' });
|
|
5589
|
+
pushPart(col(tr('status.tasksBash', '[{n} task(s) running]', { n: bashTasks }), C.cyan), { kind: 'statusTasks' });
|
|
5590
5590
|
}
|
|
5591
5591
|
if (agentTasks > 0) {
|
|
5592
|
-
pushPart(col(tr('status.tasksAgent', '[{n} agent(s) running]', { n: agentTasks })), { kind: 'statusTasks' });
|
|
5592
|
+
pushPart(col(tr('status.tasksAgent', '[{n} agent(s) running]', { n: agentTasks }), C.spring), { kind: 'statusTasks' });
|
|
5593
5593
|
}
|
|
5594
5594
|
}
|
|
5595
5595
|
if (state.slCwd !== false && cwd) parts.push(col(cwd, C.gray));
|
|
@@ -5628,8 +5628,21 @@ const queueH = takeover ? 0 : queuePanelHeight(state);
|
|
|
5628
5628
|
// AND the model must have prices (its own entry or the models.dev catalog). Either one
|
|
5629
5629
|
// missing would mean inventing the number, so it is omitted rather than shown as `0$`,
|
|
5630
5630
|
// which reads as "this was free".
|
|
5631
|
-
const costSeg = state._costText ? `${state._costText} cost | ` : '';
|
|
5632
|
-
|
|
5631
|
+
const costSeg = state._costText ? `${state._costText} ${uiText('cost')} | ` : '';
|
|
5632
|
+
// THE TALLIES ARE COUNTED NOUNS, so they go through `tr` rather than `uiText`: a template
|
|
5633
|
+
// can sit the number where the language wants it, and the plural only exists in English.
|
|
5634
|
+
const countsRight = col(
|
|
5635
|
+
`${costSeg}`
|
|
5636
|
+
+ (state.rounds === 1
|
|
5637
|
+
? tr('status.turnsOne', '{n} turn', { n: state.rounds })
|
|
5638
|
+
: tr('status.turns', '{n} turns', { n: state.rounds }))
|
|
5639
|
+
+ ' | '
|
|
5640
|
+
+ (state.steps === 1
|
|
5641
|
+
? tr('status.stepsOne', '{n} step', { n: state.steps })
|
|
5642
|
+
: tr('status.steps', '{n} steps', { n: state.steps }))
|
|
5643
|
+
+ ` | ${Math.round(state.tokRate)} tok/s`,
|
|
5644
|
+
C.white,
|
|
5645
|
+
);
|
|
5633
5646
|
const statusRight = countsRight;
|
|
5634
5647
|
// Plugin TUI widgets render into the status bar's right side.
|
|
5635
5648
|
try { const wid = renderWidgets(); if (wid) statusRight && (statusRight += ' '); if (wid) statusRight = (statusRight || '') + wid; } catch {}
|