@alexwkleung/reika 0.4.0 → 0.6.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.
@@ -1,3 +1,4 @@
1
+ import { stripHarnessEcho } from './harnessecho.js';
1
2
  // The endpoint's reasoning parser ends the thinking channel at the first literal think tag it sees
2
3
  // in the stream — including one the model wrote *inside* its own reasoning, e.g. while quoting
3
4
  // `--reasoning-format`, or describing this very bug. The parser consumes the tag, ends
@@ -51,6 +52,12 @@ export function foldedAssistantFields(msg) {
51
52
  const folded = foldSpilledReasoning(msg.reasoning, msg.content);
52
53
  return {
53
54
  ...(folded.reasoning ? { reasoning: folded.reasoning } : {}),
54
- content: folded.content,
55
+ content: stripHarnessEcho(folded.content),
55
56
  };
56
57
  }
58
+ // The live region's half of the same display pass, so a streamed reply that opens on a copied
59
+ // harness marker never shows it and then drops it on commit.
60
+ export function foldedLiveFields(reasoning, content) {
61
+ const folded = foldSpilledReasoning(reasoning, content);
62
+ return { reasoning: folded.reasoning, content: stripHarnessEcho(folded.content) };
63
+ }
@@ -18,6 +18,7 @@
18
18
  //
19
19
  // Writes are only queued for a real TTY; a pipe (tests, CI) gets the stream back untouched.
20
20
  // `REIKA_SYNC_OUTPUT=0` is the kill switch for a terminal that misbehaves on mode 2026.
21
+ import { recordFrame } from './framedrops.js';
21
22
  // Ink gives every code point its own grid cell, so `⏺︎` (U+23FA + VS15) spends two cells on a
22
23
  // glyph the terminal draws in one, and a bordered row comes up a column short (#450). Components
23
24
  // write a bare `⏺` — one cell, no phantom — and the selector goes back on here, after Ink has laid
@@ -28,7 +29,7 @@ export function restoreTextPresentation(text) {
28
29
  }
29
30
  export const BEGIN_SYNC = '\x1b[?2026h';
30
31
  export const END_SYNC = '\x1b[?2026l';
31
- export function createFrameWriter(target) {
32
+ export function createFrameWriter(target, onFrame) {
32
33
  let pending = [];
33
34
  let scheduled = false;
34
35
  let closed = false;
@@ -38,6 +39,7 @@ export function createFrameWriter(target) {
38
39
  return;
39
40
  const frame = pending.join('');
40
41
  pending = [];
42
+ onFrame?.(frame);
41
43
  target.write(BEGIN_SYNC + restoreTextPresentation(frame) + END_SYNC);
42
44
  };
43
45
  return {
@@ -73,8 +75,11 @@ export function createSyncedStdout(target, env = process.env) {
73
75
  // The kill switch drops the frame batching, not the presentation fix: without it the dialog
74
76
  // marker would be a bare `⏺` some terminals draw as an emoji.
75
77
  let write;
78
+ // Measured per frame only: unbatched, Ink's erase and its reprint arrive as separate writes, and
79
+ // the erase alone would read as a drop.
80
+ const onFrame = env.REIKA_DEBUG ? recordFrame : undefined;
76
81
  if (syncedOutputEnabled(env)) {
77
- const writer = createFrameWriter(target);
82
+ const writer = createFrameWriter(target, onFrame);
78
83
  process.once('exit', writer.close);
79
84
  write = writer.write;
80
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexwkleung/reika",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "Coding agent CLI for local and hosted models, designed around small local models first.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Alex Leung",