@alexwkleung/reika 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/compaction.js +9 -4
- package/dist/agent/liveusage.js +58 -0
- package/dist/agent/loop.js +155 -73
- package/dist/agent/readfirst.js +30 -8
- package/dist/cli.js +3 -3
- package/dist/headless/headless.js +65 -6
- package/dist/headless/headlessargs.js +1 -1
- package/dist/headless/headlessprompt.js +2 -1
- package/dist/provider/client.js +65 -5
- package/dist/provider/latches.js +2 -0
- package/dist/provider/toolcall.js +29 -7
- package/dist/search/_chrome.js +38 -0
- package/dist/tools/_readonly.js +17 -1
- package/dist/tools/_sandbox.js +139 -20
- package/dist/ui/App.js +73 -34
- package/dist/ui/Approval.js +1 -6
- package/dist/ui/Scrollback.js +11 -3
- package/dist/ui/Working.js +18 -7
- package/dist/ui/format.js +23 -0
- package/dist/ui/layout.js +6 -0
- package/dist/ui/markdown.js +30 -2
- package/dist/ui/termtext.js +11 -0
- package/dist/ui/theme.js +5 -1
- package/package.json +1 -1
package/dist/ui/markdown.js
CHANGED
|
@@ -6,7 +6,7 @@ import { supportsHyperlink } from 'supports-hyperlinks';
|
|
|
6
6
|
import { theme, themeChalk } from './theme.js';
|
|
7
7
|
import { highlightCode } from './highlight.js';
|
|
8
8
|
import { drawnWidth, sanitizeTerminalText } from './termtext.js';
|
|
9
|
-
import { contentWidth, wrapStyledRows } from './layout.js';
|
|
9
|
+
import { contentWidth, dropWrapWhitespace, wrapStyledRows } from './layout.js';
|
|
10
10
|
// Left indent of a top-level list.
|
|
11
11
|
const TAB_WIDTH = 2;
|
|
12
12
|
// Narrowest a nested block wraps at, however deep it sits: below this a line holds a word or two.
|
|
@@ -20,6 +20,16 @@ function proseWidth(ctx) {
|
|
|
20
20
|
function wrapProse(text, ctx) {
|
|
21
21
|
return wrapStyledRows(text, proseWidth(ctx), true).join('\n');
|
|
22
22
|
}
|
|
23
|
+
// Wrapped here, not left to Ink: a fence that reached Ink overflowed its list or quote column and
|
|
24
|
+
// lost its colors from the second row on, the same two defects wrapProse exists to prevent. By
|
|
25
|
+
// source line because only a break's whitespace is noise; a line's own indent is the code. Chalk
|
|
26
|
+
// closes its styles at a newline, so no style crosses that split.
|
|
27
|
+
function wrapCode(code, ctx) {
|
|
28
|
+
return code
|
|
29
|
+
.split('\n')
|
|
30
|
+
.flatMap(line => wrapStyledRows(line, proseWidth(ctx)).map((row, i) => i === 0 ? row : dropWrapWhitespace(row)))
|
|
31
|
+
.join('\n');
|
|
32
|
+
}
|
|
23
33
|
function renderBlocks(tokens, ctx) {
|
|
24
34
|
return tokens
|
|
25
35
|
.map(token => renderBlock(token, ctx))
|
|
@@ -38,7 +48,7 @@ function renderBlock(token, ctx) {
|
|
|
38
48
|
// Flush with the prose, no fence lines. The info string's first word is the language: a
|
|
39
49
|
// ```ts title="x" fence is TypeScript, not an unknown language.
|
|
40
50
|
case 'code':
|
|
41
|
-
return highlightCode(token.text, token.lang?.split(/\s/)[0] ?? '');
|
|
51
|
+
return wrapCode(highlightCode(token.text, token.lang?.split(/\s/)[0] ?? ''), ctx);
|
|
42
52
|
case 'hr':
|
|
43
53
|
return chalk.dim('─'.repeat(Math.min(40, proseWidth(ctx))));
|
|
44
54
|
case 'blockquote':
|
|
@@ -294,6 +304,20 @@ export function renderInlineMarkdown(text) {
|
|
|
294
304
|
export function renderReasoningMarkdown(text, width) {
|
|
295
305
|
return stripAnsi(renderDocument(text, { width, listDepth: 0, plainLinks: true }));
|
|
296
306
|
}
|
|
307
|
+
// The fence line a live tail needs put back when it was cut out of `text` inside a code block, or
|
|
308
|
+
// ''. Without the opener the tail's code parses as prose, and its closer opens a block of its own
|
|
309
|
+
// that swallows the prose after it. A closer is the opener's character, at least as long, bare.
|
|
310
|
+
export function openFenceBefore(text, end) {
|
|
311
|
+
let open = null;
|
|
312
|
+
for (const [line, fence, info] of text.slice(0, end).matchAll(/^ {0,3}(`{3,}|~{3,})(.*)$/gm)) {
|
|
313
|
+
if (!open)
|
|
314
|
+
open = { line, fence };
|
|
315
|
+
else if (fence[0] === open.fence[0] && fence.length >= open.fence.length && !info.trim()) {
|
|
316
|
+
open = null;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return open?.line ?? '';
|
|
320
|
+
}
|
|
297
321
|
// A live stream's last line ends mid-span often: `**the loo` renders as literal asterisks until
|
|
298
322
|
// the closer arrives, then they vanish, which reads as the markup parsing in front of the user.
|
|
299
323
|
// Holding back an unmatched opener on that line lets the text gain its styling in place instead.
|
|
@@ -309,6 +333,10 @@ export function hideDanglingMarkers(text) {
|
|
|
309
333
|
const fences = text.slice(0, start).match(/^ {0,3}(```|~~~)/gm);
|
|
310
334
|
if (fences && fences.length % 2 === 1)
|
|
311
335
|
return text;
|
|
336
|
+
// A bullet's first `-` under a paragraph line reads as a setext underline, so the line above
|
|
337
|
+
// flashed as a heading until the bullet's text arrived. Hidden whole until its newline, like a fence.
|
|
338
|
+
if (/^ {0,3}(-+|=+)[ \t]*$/.test(line))
|
|
339
|
+
return text.slice(0, start);
|
|
312
340
|
const drop = [];
|
|
313
341
|
// A code span closes on a backtick run of its opener's length. Past an unclosed opener is a
|
|
314
342
|
// span still streaming, so its stars are not markup.
|
package/dist/ui/termtext.js
CHANGED
|
@@ -77,6 +77,17 @@ function isControl(ch) {
|
|
|
77
77
|
const c = ch.codePointAt(0);
|
|
78
78
|
return c < 0x20 || (c >= 0x7f && c <= 0x9f);
|
|
79
79
|
}
|
|
80
|
+
// For text written straight to a terminal with no frame to keep in step, in pieces that may split a
|
|
81
|
+
// line: sanitizeTerminalText replays whole lines, so a chunk's trailing space would be lost. A
|
|
82
|
+
// sequence split across two chunks leaves its printable tail as plain text, which instructs nothing.
|
|
83
|
+
export function stripTerminalControls(text) {
|
|
84
|
+
let out = '';
|
|
85
|
+
for (const ch of stripAnsi(text).replace(/\r\n/g, '\n')) {
|
|
86
|
+
if (ch === '\n' || ch === '\t' || !isControl(ch))
|
|
87
|
+
out += ch;
|
|
88
|
+
}
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
80
91
|
// The other direction from the tab above: a glyph the terminal draws in ONE column that Ink's
|
|
81
92
|
// measurement spends TWO on. string-width asks the emoji regex, which holds the pictographs that
|
|
82
93
|
// default to TEXT presentation too — `✔`, `⚠`, `♦`, `❤`, the record glyph `⏺` (syncframe.ts) —
|
package/dist/ui/theme.js
CHANGED
|
@@ -15,6 +15,9 @@ const truecolor = {
|
|
|
15
15
|
secondary: '#a0a0a0',
|
|
16
16
|
muted: '#808080',
|
|
17
17
|
reasoning: '#6495ed', // cornflower blue: thinking-block bar, dimmer than the accent
|
|
18
|
+
// The busy line during a prefill (#912). A warmer, softer cornflower: the family of the reasoning
|
|
19
|
+
// blue it hands over to, tinted by Working to about 10° off it, so the two do not read as one.
|
|
20
|
+
prefill: '#7a90ee',
|
|
18
21
|
warning: '#e5d49a', // soft pastel yellow — luminous but easy on the eyes, matches the other accents
|
|
19
22
|
queued: '#e8b87a', // soft pastel orange — `next ›` label on the queued list, complements the yellow warning
|
|
20
23
|
// The `▎` bar on a nested (subagent) user bubble. `▎` is a legend, not decoration: the same
|
|
@@ -67,7 +70,7 @@ const truecolor = {
|
|
|
67
70
|
// place of the pastels. Chalk downsamples a hex to the nearest of 16, and nearly every pastel above
|
|
68
71
|
// is nearest to white — accent, warning and every mode tag collapsed into one, so the colors meant
|
|
69
72
|
// nothing. The hues are chosen per slot; 16 colors cannot keep every distinction, so the ones that
|
|
70
|
-
// share a color (queued/subagent, link/reasoning) never meet on screen. `userBg` and the named
|
|
73
|
+
// share a color (queued/subagent, link/reasoning/prefill) never meet on screen. `userBg` and the named
|
|
71
74
|
// slots already downsample fine and are left alone.
|
|
72
75
|
const ansi16 = {
|
|
73
76
|
accent: 'magentaBright',
|
|
@@ -76,6 +79,7 @@ const ansi16 = {
|
|
|
76
79
|
secondary: 'gray',
|
|
77
80
|
muted: 'gray',
|
|
78
81
|
reasoning: 'blueBright',
|
|
82
|
+
prefill: 'blueBright',
|
|
79
83
|
warning: 'yellowBright',
|
|
80
84
|
queued: 'yellow',
|
|
81
85
|
subagent: 'yellow',
|
package/package.json
CHANGED