@yanzc/claude-pro 0.9.4 → 0.9.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yanzc/claude-pro",
3
- "version": "0.9.4",
3
+ "version": "0.9.5",
4
4
  "description": "claude-pro: a command line coding agent for the codex-gateway. Full access with no permission prompts; file edits are checkpointed and can be rewound.",
5
5
  "type": "module",
6
6
  "repository": {
package/src/commands.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import fs from 'node:fs';
4
4
  import path from 'node:path';
5
- import { c, padEnd, truncate } from './ui/ansi.js';
5
+ import { c, glyphs, padEnd, truncate } from './ui/ansi.js';
6
6
  import { SelectDialog } from './ui/dialogs.js';
7
7
  import { renderTodos, resultLines, formatTokens, formatDuration } from './ui/render.js';
8
8
  import { loadConfig, settingsFiles, configEntries, writeConfigSetting, unsetConfigSetting, rememberChoice, applyRememberedChoices, VERSION, APP_NAME, CONFIG_DIR } from './config.js';
@@ -663,7 +663,7 @@ export function buildCommands(app) {
663
663
  const fill = Math.min(barW, Math.round((used / window) * barW));
664
664
  const mark = Math.min(barW - 1, Math.round((threshold / window) * barW));
665
665
  let bar = '';
666
- for (let i = 0; i < barW; i++) bar += i < fill ? c.claude('█') : i === mark ? c.yellow('┃') : c.dim('░');
666
+ for (let i = 0; i < barW; i++) bar += i < fill ? c.claude('█') : i === mark ? c.yellow('┃') : c.dim(glyphs.track);
667
667
  out([
668
668
  `${bar} ${c.bold(formatTokens(used))} / ${formatTokens(window)} tokens (${Math.round((used / window) * 100)}%)`,
669
669
  c.dim(`System prompt ~${formatTokens(sys)} · Tools ~${formatTokens(tools)} · Messages ~${formatTokens(msgs)} (${a.messages.length})`),
package/src/ui/ansi.js CHANGED
@@ -153,8 +153,20 @@ export function setTerminalWidths(widths) {
153
153
  for (const [char, width] of widths) {
154
154
  if (width === 1 || width === 2) terminalWidths.set(char.codePointAt(0), width);
155
155
  }
156
+ Object.assign(glyphs, terminalWidths.get(0xb7) === 2 ? FONT_GLYPHS : GLYPHS);
156
157
  }
157
158
 
159
+ // The interface's symbols that not every terminal can draw, by what they are for. The Windows console that sizes
160
+ // characters by its Chinese font (the one that draws · in two cells) has no glyph for some of them and draws an
161
+ // empty box two cells wide instead, over the character behind it, and it draws a round corner half a cell to the
162
+ // right, so that a left one stands under the border's line, not at its end. There they are characters that
163
+ // font has; their widths differ (※ and ⊙ take two cells), so what is drawn with them is measured, not counted.
164
+ // `lineGap` is what stands between a border's line and coloured text behind it: that console draws ─ two cells
165
+ // wide, and the last one of a line covers a space that differs from it only in colour.
166
+ const GLYPHS = { topLeft: '╭', topRight: '╮', bottomLeft: '╰', bottomRight: '╯', clock: '◷', restart: '↻', update: '⇣', find: '⌕', track: '░', pointer: '❯', lineGap: ' ' };
167
+ const FONT_GLYPHS = { topLeft: '┌', topRight: '┐', bottomLeft: '└', bottomRight: '┘', clock: '⊙', restart: '※', update: '↓', find: '/', track: '─', pointer: '>', lineGap: ' ' };
168
+ export const glyphs = { ...GLYPHS };
169
+
158
170
  export function codePointWidth(cp) {
159
171
  if (cp < 32 || (cp >= 0x7f && cp < 0xa0)) return 0;
160
172
  if (inRanges(cp, ZERO)) return 0;
package/src/ui/dialogs.js CHANGED
@@ -1,19 +1,19 @@
1
1
  // Modal dialogs rendered in the live region: selection menus (questions, the model and session pickers, /rewind),
2
2
  // with a typed answer of their own when they offer "Other".
3
3
 
4
- import { c, padEnd, stringWidth, truncate, wordWrap } from './ansi.js';
4
+ import { c, glyphs, padEnd, stringWidth, truncate, wordWrap } from './ansi.js';
5
5
  import { Editor } from './editor.js';
6
6
 
7
7
  function box(lines, width, color) {
8
8
  const w = Math.max(20, width - 1);
9
9
  const inner = w - 4;
10
- const out = [color('╭' + '─'.repeat(w - 2) + '╮')];
10
+ const out = [color(glyphs.topLeft + '─'.repeat(w - 2) + glyphs.topRight)];
11
11
  for (const l of lines) {
12
12
  for (const part of stringWidth(l) > inner ? wordWrap(l, inner) : [l]) {
13
13
  out.push(color('│') + ' ' + padEnd(part, inner) + ' ' + color('│'));
14
14
  }
15
15
  }
16
- out.push(color('╰' + '─'.repeat(w - 2) + '╯'));
16
+ out.push(color(glyphs.bottomLeft + '─'.repeat(w - 2) + glyphs.bottomRight));
17
17
  return out;
18
18
  }
19
19
 
@@ -112,7 +112,7 @@ export class SelectDialog {
112
112
  const o = this.options[i];
113
113
  const sel = i === this.selected;
114
114
  const mark = this.multi ? (this.checked.has(i) ? c.green('[✔] ') : '[ ] ') : '';
115
- const label = `${sel ? '❯' : ' '} ${i + 1}. ${mark}${o.label}`;
115
+ const label = `${sel ? glyphs.pointer : ' '} ${i + 1}. ${mark}${o.label}`;
116
116
  lines.push(sel ? this.color(truncate(label, inner)) : truncate(label, inner));
117
117
  if (o.description) lines.push(c.dim(' ' + truncate(o.description, inner - 6)));
118
118
  }
package/src/ui/editor.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // The prompt input box: multi-line editing, history, paste handling and completions.
2
2
 
3
- import { c, graphemes, graphemeWidth, stringWidth, truncate, padEnd } from './ansi.js';
3
+ import { c, glyphs, graphemes, graphemeWidth, stringWidth, truncate, padEnd } from './ansi.js';
4
4
 
5
5
  const PASTE_THRESHOLD_CHARS = 800;
6
6
  const PASTE_THRESHOLD_LINES = 8;
@@ -27,11 +27,12 @@ export function shownQuotes(text) {
27
27
 
28
28
  // "╭─ left ───── right ─╮", the parts cut short to fit (the start of the directory goes first).
29
29
  export function topBorder(boxW, color, title) {
30
- const plain = () => color('╭' + '─'.repeat(boxW - 2) + '╮');
30
+ const plain = () => color(glyphs.topLeft + '─'.repeat(boxW - 2) + glyphs.topRight);
31
31
  if (!title || (!title.left && !title.right)) return plain();
32
32
  const room = boxW - 6; // the corners, a dash at each end and a space each side of a part
33
33
  const right = title.right ? truncate(title.right, Math.max(0, Math.floor(room / 3))).replace(/\x1b\[0m$/, '') : '';
34
- const rightW = right ? stringWidth(right) + 2 : 0;
34
+ const rightPart = right ? `${glyphs.lineGap}${right} ` : '';
35
+ const rightW = stringWidth(rightPart);
35
36
  let left = title.left || '';
36
37
  const leftRoom = room - rightW - (right && left ? 1 : 0) - 2;
37
38
  if (leftRoom < 4) left = '';
@@ -42,10 +43,9 @@ export function topBorder(boxW, color, title) {
42
43
  }
43
44
  if (!left && !right) return plain();
44
45
  const leftPart = left ? ` ${left} ` : '';
45
- const rightPart = right ? ` ${right} ` : '';
46
46
  const dashes = boxW - 4 - stringWidth(leftPart) - stringWidth(rightPart);
47
47
  if (dashes < 1) return plain();
48
- return color('╭─') + c.dim(leftPart) + color('─'.repeat(dashes)) + (right ? c.blue(rightPart) : '') + color('─╮');
48
+ return color(glyphs.topLeft + '─') + c.dim(leftPart) + color('─'.repeat(dashes)) + (right ? c.blue(rightPart) : '') + color('─' + glyphs.topRight);
49
49
  }
50
50
 
51
51
  // Start of the line the cursor is on. (lastIndexOf with a negative start still looks at index 0, so a
@@ -615,7 +615,7 @@ export class Editor {
615
615
  const below = laid.length - top - shown;
616
616
  const hidden = [top ? `↑ ${top} more rows` : '', below ? `↓ ${below} more rows` : ''].filter(Boolean).join(' · ');
617
617
  const label = hidden && boxW > stringWidth(hidden) + 6 ? ` ${hidden} ` : '';
618
- lines.push(color('╰─') + c.dim(label) + color('─'.repeat(boxW - 3 - stringWidth(label)) + '╯'));
618
+ lines.push(color(glyphs.bottomLeft + '─') + c.dim(label) + color('─'.repeat(boxW - 3 - stringWidth(label)) + glyphs.bottomRight));
619
619
  // `text`: where the text is in `lines` (its first row, how many, the column it starts at), for the mouse
620
620
  return { lines, cursor: active ? { row: r - top + 1, col: 4 + col } : null, text: { row: 1, rows: shown, col: 4 } };
621
621
  }
package/src/ui/repl.js CHANGED
@@ -6,7 +6,7 @@ import path from 'node:path';
6
6
  import os from 'node:os';
7
7
  import readline from 'node:readline';
8
8
  import { spawn } from 'node:child_process';
9
- import { c, ESC, stringWidth, stripAnsi, truncate, padEnd, wordWrap } from './ansi.js';
9
+ import { c, ESC, glyphs, stringWidth, stripAnsi, truncate, padEnd, wordWrap } from './ansi.js';
10
10
  import { Screen, queryCursorRow, mouseFilter } from './screen.js';
11
11
  import { Editor, topBorder, shownQuotes } from './editor.js';
12
12
  import { SelectDialog } from './dialogs.js';
@@ -1132,7 +1132,7 @@ export class App {
1132
1132
  this.seedOutput = [line];
1133
1133
  return;
1134
1134
  }
1135
- this.screen.log(c.dim(`↻ Restarted${state.reason ? `: ${state.reason}` : ''}${state.continueWith ? ' · continuing' : ''}`), '');
1135
+ this.screen.log(c.dim(`${glyphs.restart} Restarted${state.reason ? `: ${state.reason}` : ''}${state.continueWith ? ' · continuing' : ''}`), '');
1136
1136
  }
1137
1137
 
1138
1138
  // The turn that goes on after a restart: the note for the model, and what the user had queued meanwhile.
@@ -1293,7 +1293,7 @@ export class App {
1293
1293
  const row = (s) => c.claude('│') + ' ' + padEnd(truncate(s, inner), inner) + ' ' + c.claude('│');
1294
1294
  const model = cfg.model;
1295
1295
  const lines = [
1296
- c.claude('╭' + '─'.repeat(w - 2) + '╮'),
1296
+ c.claude(glyphs.topLeft + '─'.repeat(w - 2) + glyphs.topRight),
1297
1297
  row(`${c.claude('✻')} Welcome to ${c.bold(APP_NAME)}! ${c.dim(`v${VERSION} · a command line coding agent`)}`),
1298
1298
  row(''),
1299
1299
  row(c.dim(' /help for help, /status for your current setup')),
@@ -1301,7 +1301,7 @@ export class App {
1301
1301
  row(c.dim(` cwd: ${this.cwd}`)),
1302
1302
  row(c.dim(` model: ${model.label}${cfg.effort ? ` · effort ${cfg.effort}` : ''} · ${formatTokens(model.contextWindow)} context`)),
1303
1303
  row(c.dim(` backend: ${cfg.endpointLabel}`)),
1304
- c.claude('╰' + '─'.repeat(w - 2) + '╯'),
1304
+ c.claude(glyphs.bottomLeft + '─'.repeat(w - 2) + glyphs.bottomRight),
1305
1305
  ];
1306
1306
  lines.push('', c.dim(' Full access: every tool runs immediately, nothing is ever asked. File edits are checkpointed;'), c.dim(' /rewind puts files and/or the conversation back (shell-command changes are not tracked).'));
1307
1307
  if (!gatewayLogin(cfg.gatewayUrl)) lines.push('', c.yellow(` ⚠ Not logged in to the gateway ${cfg.gatewayUrl}. Run /login.`));
@@ -1769,8 +1769,8 @@ export class App {
1769
1769
  const content = f.selected && shown ? c.inverse(shown) : shown;
1770
1770
  const lines = [
1771
1771
  topBorder(boxW, c.yellow, title),
1772
- c.yellow('│') + ' ' + c.yellow('⌕') + ' ' + padEnd(content, textW) + ' ' + c.yellow('│'),
1773
- c.yellow('╰' + '─'.repeat(boxW - 2) + '╯'),
1772
+ c.yellow('│') + ' ' + c.yellow(glyphs.find) + ' ' + padEnd(content, textW) + ' ' + c.yellow('│'),
1773
+ c.yellow(glyphs.bottomLeft + '─'.repeat(boxW - 2) + glyphs.bottomRight),
1774
1774
  ];
1775
1775
  return { lines, cursor: { row: 1, col: 4 + stringWidth(before) } };
1776
1776
  }
@@ -2532,7 +2532,7 @@ export class App {
2532
2532
  // cache use.
2533
2533
  cacheClock() {
2534
2534
  const clock = this.agent?.cache.clock();
2535
- return !clock ? '' : clock.cold ? c.red('◷') : c.dim(`◷ ${clock.minutes}m`);
2535
+ return !clock ? '' : clock.cold ? c.red(glyphs.clock) : c.dim(`${glyphs.clock} ${clock.minutes}m`);
2536
2536
  }
2537
2537
 
2538
2538
  footer(w) {
@@ -2542,7 +2542,7 @@ export class App {
2542
2542
  else if (flash) left = (flash.kind === 'warn' ? c.yellow : c.dim)(' ' + truncate(flash.text, w - 4));
2543
2543
  else if (this.screen.full && this.screen.selection) left = c.dim(' ctrl+c to copy · ctrl+q to quote it in your message');
2544
2544
  else if (this.editor.selection) left = c.dim(' ctrl+c to copy · esc to clear');
2545
- else if (this.restartRequest) left = c.dim(' ↻ restarting when this turn ends');
2545
+ else if (this.restartRequest) left = c.dim(` ${glyphs.restart} restarting when this turn ends`);
2546
2546
  else if (this.editor.mode === 'bash') left = c.magenta(' ! for bash mode');
2547
2547
  else if (this.editor.mode === 'memory') left = c.blue(' # to memorize');
2548
2548
  else left = c.dim(' ? for shortcuts');
@@ -2550,9 +2550,9 @@ export class App {
2550
2550
  left += c.dim(' · ') + c.green(`⇄ ${this.remote.viewers} watching`);
2551
2551
  }
2552
2552
  if (!flash) {
2553
- if (this.updating) left += c.dim(' · ') + c.blue(`⇣ updating ${APP_NAME} to ${this.updating}…`);
2554
- else if (this.updateRestart && this.sourceChanged && !this.restartRequest) left += c.dim(' · ') + c.blue(`↻ ${this.updateRestart} installed: restarts ${this.working() ? 'when the work is done' : 'now'}`);
2555
- else if (this.sourceChanged && !this.sourceChangedInTurn && !this.restartRequest && !this.reloading && !this.working() && this.sourceQuietAt > Date.now()) left += c.dim(' · ') + c.dim('↻ source changed: restarts once it is left alone (/restart: now)');
2553
+ if (this.updating) left += c.dim(' · ') + c.blue(`${glyphs.update} updating ${APP_NAME} to ${this.updating}…`);
2554
+ else if (this.updateRestart && this.sourceChanged && !this.restartRequest) left += c.dim(' · ') + c.blue(`${glyphs.restart} ${this.updateRestart} installed: restarts ${this.working() ? 'when the work is done' : 'now'}`);
2555
+ else if (this.sourceChanged && !this.sourceChangedInTurn && !this.restartRequest && !this.reloading && !this.working() && this.sourceQuietAt > Date.now()) left += c.dim(' · ') + c.dim(`${glyphs.restart} source changed: restarts once it is left alone (/restart: now)`);
2556
2556
  else if (this.pendingUpdate) left += c.dim(' · ') + c.dim(`update ${this.pendingUpdate} ready · ${this.updateWaitingFor ? `installs when @${this.updateWaitingFor.split(',')[0]} is idle` : 'installs when idle'}`);
2557
2557
  }
2558
2558
  const cfg = this.config;