ltms-reader 0.1.0 → 0.1.1
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/CHANGELOG.md +263 -0
- package/README.md +145 -94
- package/package.json +1 -1
- package/src/app.mjs +4 -4
- package/src/bidi.mjs +9 -8
- package/src/guard.mjs +7 -6
- package/src/reading.mjs +10 -10
- package/src/screen.mjs +31 -15
- package/src/start.mjs +8 -5
- package/src/text.mjs +45 -41
- package/src/view.mjs +1 -1
- package/src/views.mjs +4 -4
package/README.md
CHANGED
|
@@ -65,16 +65,23 @@ screen too small for all of it, its first lines), and `q` still quits.
|
|
|
65
65
|
| `?` | the keys |
|
|
66
66
|
| `q` or Ctrl-C | quit |
|
|
67
67
|
|
|
68
|
-
While a line is typed: Backspace, Ctrl-U to clear it, Enter, Esc to leave it. A paste is text (the reader
|
|
69
|
-
the terminal's bracketed paste)
|
|
70
|
-
|
|
68
|
+
While a line is typed: Backspace, Ctrl-U to clear it, Enter, Esc to leave it. A paste is text, never keys (the reader
|
|
69
|
+
turns on the terminal's bracketed paste), but for two things in it: a Ctrl-C character quits, in a line too, though not
|
|
70
|
+
right after an ESC, which is read with it as one key; and an ESC [201~ ends the paste there, what follows it acting as
|
|
71
|
+
keys. Pasted into a line, its new lines become spaces and do not run it. What reaches the reader is the terminal's to
|
|
72
|
+
say: by their sources (read, not run), Alacritty 0.17.0 takes ESC and Ctrl-C out of a paste, Konsole 26.08.3 takes ESC
|
|
73
|
+
out and asks before it pastes a control character, Ctrl-C among them, and the xterm.js of VS Code 1.147.0 writes ESC as
|
|
74
|
+
`␛` and passes Ctrl-C.
|
|
71
75
|
|
|
72
76
|
## Your transcripts, and who sees them
|
|
73
77
|
|
|
74
|
-
- **It shows their text**, prompts, replies, tool inputs and outputs included, to you, on
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
- **It shows their text**, prompts, replies, tool inputs and outputs included, to you, on the alternate screen of the
|
|
79
|
+
terminal that is its stdout: it starts only when stdin and stdout are terminals, and draws every frame on stdout. It
|
|
80
|
+
writes their text to no file, pipe or log; a program that records that terminal records what it draws (measured with
|
|
81
|
+
util-linux `script` and tmux's `pipe-pane`). When it quits, it leaves the alternate screen, and nothing of it stays
|
|
82
|
+
(measured with a run's bytes replayed into the xterm.js of VS Code 1.147.0). (ltms itself prints no text of a
|
|
83
|
+
transcript but a call's tool name and a word taken from its input, `grep` or `README` say, which reach the reader
|
|
84
|
+
through the pipes of the ltms commands it runs; this reader is for the person whose transcripts they are.)
|
|
78
85
|
- **It writes no file and uses no network.** It reads the transcripts under the folder it is given, and runs ltms's
|
|
79
86
|
commands (`index`, `search`, `skeleton`) as local processes, which read the same files and write only to the reader.
|
|
80
87
|
Run through `npx`, npm writes files of its own: a log of each run under `~/.npm/_logs`, which names the folder or file
|
|
@@ -113,48 +120,80 @@ pasted acts as a key. A Ctrl-C character in a paste is the one exception: it qui
|
|
|
113
120
|
`reader`, the default), by the Unicode Bidirectional Algorithm (UAX #9, Unicode 17.0.0, written in this package: the
|
|
114
121
|
implicit algorithm with paired brackets, its lines reordered and mirrored, a paragraph's direction from its first
|
|
115
122
|
strong character), and writes it in visual order. A line that holds right-to-left text (a character of UAX #9's class
|
|
116
|
-
R, AL or AN) is written inside a left-to-right override, U+202D (LRO)
|
|
117
|
-
takes a column (never at the line's first column: after ZWSP,
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
R, AL or AN) is written inside a left-to-right override: a left-to-right mark (U+200E, LRM) and U+202D (LRO), in that
|
|
124
|
+
order, right after its first grapheme cluster that takes a column (never at the line's first column: after any ZWSP,
|
|
125
|
+
lone mark or RLM that begins the line, after the first cluster that takes one), and U+202C (PDF) at its end, so that a
|
|
126
|
+
terminal that lays bidirectional text out itself with a left-to-right base for each line (Konsole at its default bidi
|
|
127
|
+
settings) keeps the reader's order instead of reordering it a second time; one that takes a line's base from its first
|
|
128
|
+
strong character (Konsole with "force LTR line direction" unchecked; not measured) would still draw a first cluster
|
|
129
|
+
that is right to left at the line's other end. Nothing else is written (no isolate), and a line without right-to-left
|
|
130
|
+
text, or with no cluster that takes a column, is written as it is. No terminal is detected.
|
|
131
|
+
- Measured on four terminals (on 2026-11-16, and again with 0.1.1's own output on 2026-11-21 and 22): Alacritty
|
|
132
|
+
0.17.0, Konsole 26.08.3, tmux 3.6 and the xterm.js of VS Code's terminal (1.146.0's, 6.1.0-beta.304, run in a
|
|
133
|
+
headless browser, not in VS Code's window: on 2026-11-16 with xterm.js's own Unicode 6 widths, on 2026-11-21 with
|
|
134
|
+
those and with Unicode 11's, VS Code's default; 1.147.0's, 6.1.0-beta.337, gave the same). There, after a line's
|
|
135
|
+
first column, LRM, LRO and PDF take no column where they follow a character, as the reader writes its LRM and LRO;
|
|
136
|
+
xterm.js gives one that follows an escape sequence a column of its own, as it does the reader's PDF after a styled
|
|
137
|
+
segment, the last thing on its row, so that no text moves. Konsole, at its default bidi settings, lays text out
|
|
138
|
+
itself with a left-to-right base for each line, and applies the override from a line's second column on; at the
|
|
124
139
|
first column an LRO is not applied by Konsole, dropped by tmux and given a column of its own by xterm.js (hence
|
|
125
|
-
after the first cluster), and xterm.js gives an isolate (LRI, RLI, PDI) a column
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
140
|
+
after the first cluster), and xterm.js with its own Unicode 6 widths gives an isolate (LRI, RLI, PDI) a column
|
|
141
|
+
anywhere (with Unicode 11's, none after a character, one at the first column and after an escape sequence).
|
|
142
|
+
Alacritty, and xterm.js's WebGL renderer (the one VS Code 1.147.0 loads at its default settings), draw the text in
|
|
143
|
+
the order it is written; xterm.js's DOM renderer (VS Code's where WebGL fails to load, or with GPU acceleration off)
|
|
144
|
+
puts a run of cells of one style whose glyphs need the same spacing into one span, which the browser lays out itself
|
|
145
|
+
(measured on 2026-11-22 in headless Chromium with 6.1.0-beta.304 and beta.337: with the Hebrew from a proportional
|
|
146
|
+
font, a span for each letter, both versions in order; with Liberation Mono or Courier New, one span for the row,
|
|
147
|
+
0.1.0's first letter at the row's other end and 0.1.1's row in order; with the Hebrew from a second monospace font,
|
|
148
|
+
a span for each word, and 0.1.1's words after the first reversed in place: a known limit). tmux keeps a mark in the
|
|
149
|
+
cell of the character before it, and redraws that cell to the terminal outside it (with VS Code's xterm.js outside,
|
|
150
|
+
the cells came out as without tmux; with Konsole 26.08.3 outside, measured on 2026-11-22 with tmux's status line
|
|
151
|
+
off, the screen came out pixel for pixel as without tmux). No other terminal was measured (kitty, VTE's, as in GNOME
|
|
152
|
+
Terminal, mlterm, WezTerm, foot, iTerm2, Windows Terminal, GNU screen and the rest are not): one that gives LRM or
|
|
153
|
+
LRO a column shifts such a line, from its second cluster on, by that column; one that gives PDF a column shifts
|
|
154
|
+
nothing, the column falling after the line's end, and on a line as wide as the screen (wrapping is off) taking the
|
|
155
|
+
place of its last character (both modelled on xterm.js with that width changed, not run on such a terminal). Not
|
|
156
|
+
measured either: how Konsole joins Arabic letters that come to it in visual order, under the override and across the
|
|
157
|
+
LRM after the first one. A line whose first cluster that takes a column is itself right to left keeps that cluster
|
|
158
|
+
outside the override; the LRM after it keeps it first on Konsole (measured with the reader in Konsole 26.08.3, its
|
|
159
|
+
default bidi settings, on two Hebrew first letters without points, a vav and a final nun: 0.1.0 drew it at the
|
|
160
|
+
line's other end, 0.1.1 at column 0; a pointed or an Arabic first letter was not run).
|
|
132
161
|
- `LTMS_READER_BIDI=terminal` writes the text as stored instead (mode `terminal`), with a right-to-left mark (RLM) at
|
|
133
|
-
the end of each right-to-left paragraph
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
162
|
+
the end of each line of a right-to-left paragraph (before the whitespace that ends the line; none after the lines of
|
|
163
|
+
a left-to-right paragraph, though they hold Hebrew), for a terminal that lays bidirectional text out itself (on
|
|
164
|
+
Konsole, measured after a Hebrew letter, the RLM puts the paragraph's end punctuation where it belongs, though its
|
|
165
|
+
brackets are not mirrored; after a left-to-right word or a path it would not, by a model of Konsole's layout
|
|
166
|
+
calibrated on its measured rows); `LTMS_READER_BIDI=reader` is the default; a value it does not take is refused.
|
|
167
|
+
Konsole is not detected: it gets the reader's layout, as every terminal does, over ssh too, where `KONSOLE_VERSION`
|
|
168
|
+
does not reach the reader.
|
|
137
169
|
|
|
138
170
|
A paragraph is a cell of a list, the reader's own words before a transcript's text being a paragraph of their own, or
|
|
139
171
|
a text wrapped into lines: a line of a record's text (its lines share its direction), a message, an error. A wrapped
|
|
140
172
|
paragraph's levels are resolved once, and each of its lines is reordered from them, as UAX #9 lays out a paragraph
|
|
141
173
|
broken into lines (its section 3.4): a line reads as its words do in the whole paragraph, the comma that ends a line
|
|
142
|
-
where the sentence has it. Each such line is laid out whole, its spaces at either end with the rest: a space that
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
174
|
+
where the sentence has it. Each such line is laid out whole, its spaces at either end with the rest: a space that ends
|
|
175
|
+
a line takes the paragraph's direction (L1), so that in a right-to-left paragraph it is drawn at the line's left. A
|
|
176
|
+
record's text is cut into lines by columns: the whitespace where a line breaks stays at the end of the line before, as
|
|
177
|
+
UAX #14 has it, drawn there where the line has room for it, and past the screen's edge, not drawn, where it does not.
|
|
178
|
+
A message is broken at its spaces, and the space where a line breaks hangs, as UAX #14 has the whitespace at a break:
|
|
179
|
+
it is in no line, and is not drawn, though the line has room for it; whitespace that ends a message after a break
|
|
180
|
+
hangs too, and makes no line of its own. Either way no line but a paragraph's first begins with whitespace that hangs
|
|
181
|
+
(the figure space, a no-break space, does not hang). A long line of a list is cut in logical order, its beginning
|
|
182
|
+
kept, then laid out by itself, the spaces at its ends (a cell's padding) where they are. A path or a URL in a line
|
|
183
|
+
(`/home/...`, `~/...`, `src/...`, `https://...`) that begins the line or follows a space, an opening bracket or quote,
|
|
184
|
+
`=` or a hyphen is laid out as one left-to-right unit, up to the next space, its parts in order and a Hebrew name in
|
|
185
|
+
it reading right (UAX #9's higher-level protocol HL4), in pieces where a line breaks inside it, as an isolate is; one
|
|
186
|
+
right after Markdown's opening backtick, `**` or `*`, or right after a colon or a comma, is not (in a right-to-left
|
|
187
|
+
line, `/home/user/x.txt` in backticks reads `home/user/x.txt/`); one right after an opening `_` or `__` is one, the
|
|
188
|
+
markers in it, where that marker begins the line or follows a space, an opening bracket or quote, `=` or a hyphen
|
|
189
|
+
(inside bold, `**_/home/x_**`, it is not); and one that follows a space inside any of these markers is one, the
|
|
190
|
+
closing marker with it when it follows the path directly, which a right-to-left line lays out on the path's right (a
|
|
191
|
+
known limit); a path with a space in it is laid out as two, in a right-to-left line in the other order. Each cluster
|
|
192
|
+
is kept whole, its marks after its letter, as a terminal draws them, and so is a mark after characters UAX #9 removes
|
|
193
|
+
(a soft hyphen, ZWSP, WJ: clusters of their own), with the letter before them; the text is aligned left, so the
|
|
194
|
+
columns stay. Checked against Unicode's conformance test (BidiCharacterTest.txt: every case without an explicit
|
|
195
|
+
formatting character, which the reader shows as an escape and never applies) and against GNU FriBidi: its command for
|
|
196
|
+
a line, its library for a paragraph wrapped into lines.
|
|
158
197
|
- Colour follows [NO_COLOR](https://no-color.org): set, there is none; the selected row is still drawn in reverse.
|
|
159
198
|
|
|
160
199
|
## Limits
|
|
@@ -166,9 +205,10 @@ pasted acts as a key. A Ctrl-C character in a paste is the one exception: it qui
|
|
|
166
205
|
commands without its own `NODE_OPTIONS` or flags); one over 480 MB cannot be read at all.
|
|
167
206
|
Node's memory limit is its heap's, or, where `--max-old-space-size` or `--max-old-space-size-percentage` sets the old
|
|
168
207
|
space (in `NODE_OPTIONS` or on node's command line), the old space's: a transcript's parse is kept there, and the
|
|
169
|
-
heap's limit holds beside it a reserve for new objects that
|
|
170
|
-
|
|
171
|
-
26
|
|
208
|
+
heap's limit holds beside it a reserve for new objects that the old space does not size (with
|
|
209
|
+
`--max-old-space-size=16`, measured in containers or a scope of 3 GB: a heap limit of 64 MB on Node 20 and 22, 208 MB
|
|
210
|
+
on Node 24, 112 MB on Node 26; the same for Node 20 and 24 under 6 GB, and for Node 24 on machines of 16 and 25 GB).
|
|
211
|
+
By the heap's limit, under an old space of 16 MB, Node 24 took in a transcript of 12 MB and ran out of memory.
|
|
172
212
|
- A record is shown when its view (up to 16 times the record's size) fits beside the transcript's (up to 8 times the
|
|
173
213
|
file's) in nine tenths of Node's memory limit, and so does what writing the JSON the view writes of it takes, with
|
|
174
214
|
12 MB beside it, the reader's own: JSON is indented once more at each level a value is nested in, so that a record
|
|
@@ -184,13 +224,13 @@ pasted acts as a key. A Ctrl-C character in a paste is the one exception: it qui
|
|
|
184
224
|
screen by its own way out (SIGTERM; if it has not ended within 2 s, SIGKILL, and the command restores the terminal),
|
|
185
225
|
then is printed after the restore, and the command exits with 1. If the command's own process is killed (SIGKILL),
|
|
186
226
|
the screen's process learns of it (an IPC channel between the two closes), restores the terminal and ends; if both
|
|
187
|
-
are killed at once (a whole cgroup, as systemd-oomd does), nothing is left to restore it.
|
|
227
|
+
are killed at once (a whole cgroup, as systemd-oomd does), nothing is left to restore it (reasoned, not run).
|
|
188
228
|
- Under an interactive shell with job control, that shell takes the terminal back as soon as the command's process is
|
|
189
229
|
killed, racing the screen's process. The screen's process then writes the leave sequence and leaves the terminal's
|
|
190
230
|
modes to the shell (it puts back the modes it started with only where they are still the screen's raw ones, as
|
|
191
231
|
under a shell that sets none).
|
|
192
|
-
Measured on 2026-11-16
|
|
193
|
-
|
|
232
|
+
Measured on 2026-11-16, beside the shells a stand-in for a job-control shell that sets no modes: a pseudo-terminal
|
|
233
|
+
of 80 x 24, the shell at its prompt, the reader started from it,
|
|
194
234
|
SIGKILL to the command's process once its frame is up; 10 runs for each of bash 5.3.20, zsh 5.9.2 (`-f`, and `-f`
|
|
195
235
|
with `ttyctl -f` typed first), fish 4.9.3 and the stand-in. The modes 1.5 s after were the shell's own, as at its
|
|
196
236
|
prompt, 10 of 10 for bash, zsh with `ttyctl -f`, fish and the stand-in; a line typed then came back once, 10 of 10,
|
|
@@ -201,30 +241,35 @@ pasted acts as a key. A Ctrl-C character in a paste is the one exception: it qui
|
|
|
201
241
|
(10 of 10: its iflag and lflag not those at its prompt), so that the commands it ran next had the keyboard's signals
|
|
202
242
|
(Ctrl-C) and flow control off, `-isig -ixon`, 10 of 10; with `ttyctl -f` (in `.zshrc`) they had them on, 10 of 10.
|
|
203
243
|
- A list of sessions waits for `ltms index` to read every transcript of the project (on one machine, 39 s for a project
|
|
204
|
-
of 385 sessions), and a search for `ltms search`; the screen says what is being read and for
|
|
205
|
-
took 3 s or more is kept: opened again after its files changed, it is shown as it was read, and
|
|
206
|
-
and how many files changed since; `r` reads it again (as it reads Projects again), and so does
|
|
207
|
-
again.
|
|
244
|
+
of 385 sessions, by ltms's own README), and a search for `ltms search`; the screen says what is being read and for
|
|
245
|
+
how long. A list that took 3 s or more is kept: opened again after its files changed, it is shown as it was read, and
|
|
246
|
+
says when that was and how many files changed since; `r` reads it again (as it reads Projects again), and so does
|
|
247
|
+
`ltms-reader` started again.
|
|
208
248
|
- Some clusters are drawn wider by some terminals than by the cluster rule (an Indic conjunct, an emoji sequence a
|
|
209
|
-
terminal does not join)
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
the
|
|
214
|
-
|
|
249
|
+
terminal does not join): the rest of the row is drawn that much further right, and a row that then reaches past the
|
|
250
|
+
screen's edge stops there, each character past it written over the last column (measured on VS Code 1.147.0's
|
|
251
|
+
xterm.js, its headless build).
|
|
252
|
+
- On a narrow screen some rows are wider than it: the line that says what is being read
|
|
253
|
+
(`reading the sessions with ltms index`, a transcript's name, `searching with ltms search`), which is not cut to the
|
|
254
|
+
screen's width, and the search line where its prompt, which names what is searched, fills the screen (the text typed
|
|
255
|
+
and the cursor go past it); measured at 25 columns, the first 38 columns wide, or 30 with a transcript's name, and the
|
|
256
|
+
search line 26, and at 30 columns, 38 and 31. The reader turns wrapping at the last column off, so a terminal
|
|
257
|
+
stops such a row at its edge, the edge's cell holding the last character written to the row (measured on VS Code
|
|
258
|
+
1.147.0's xterm.js, its headless build; on the other terminals reasoned, not measured). A known limit, left as it is.
|
|
215
259
|
- A paragraph's levels are resolved once, when a line of it is first drawn, and kept for the last two drawn of 4,096
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
its paragraph's: in a right-to-left paragraph of 200,000 paths (3,200,004
|
|
221
|
-
|
|
222
|
-
|
|
260
|
+
UTF-16 code units or more (a character past U+FFFF counts two). For a record of one paragraph of 4,000,000
|
|
261
|
+
characters (`אבג ` 1,000,000 times), measured on 2026-11-22 on one machine, the first frame of a page in its middle
|
|
262
|
+
took 157 to 190 ms on Node 26.13.1 (6 runs), and the 20 frames after it a median of 11.6 to 12.0 ms at 200 x 60 and
|
|
263
|
+
6.9 to 7.0 at 80 x 24; the levels alone 141 to 149 ms (3 runs), and 144 to 148 on Node 20.20.2 (2 runs). A line finds
|
|
264
|
+
the paths in it by a binary search of its paragraph's: in a right-to-left paragraph of 200,000 paths (3,200,004
|
|
265
|
+
characters), the first frame took 160 to 173 ms at 80 x 24 (3 runs), and a page at its start, its middle and its end
|
|
266
|
+
1.5 to 2.3 ms at 80 x 24 and 4.6 to 7.6 at 200 x 60.
|
|
223
267
|
- On Node 20, a long line of text that is not ASCII is laid out about three times slower than on Node 26: Node 20's
|
|
224
268
|
grapheme segmenter is slower, and walked over one long string it costs more at each cluster the longer the string is
|
|
225
|
-
(
|
|
226
|
-
|
|
227
|
-
|
|
269
|
+
(on Node 20.20.2, 4.7 to 4.9 us a cluster at 10,000 units and 118 to 121 at 80,000 for Hebrew, mixed or CJK text; 4.3
|
|
270
|
+
and 28 for ASCII), so the reader walks a long line 256 units at a time. Measured on the record of 4,000,000 characters
|
|
271
|
+
above, at 80 columns: its lines counted in 3.6 to 3.9 s on Node 20.20.2, against 1.15 to 1.23 s on Node 26.13.1 (a
|
|
272
|
+
record of the same size in ASCII: 15 to 16 and 16 to 20 ms).
|
|
228
273
|
|
|
229
274
|
Exit status: 0 after `q`; 130 after Ctrl-C or SIGINT; 129 after SIGHUP; 143 after SIGTERM; 1 after an internal error;
|
|
230
275
|
2 when it is refused before the screen opens (not a terminal, a usage error, a path that is not a folder or a `.jsonl`);
|
|
@@ -240,32 +285,38 @@ npm test
|
|
|
240
285
|
|
|
241
286
|
`npm test` runs `node --test test/*.test.mjs`, the pattern expanded by the shell, which runs the test files on Node 20,
|
|
242
287
|
22, 24 and 26 alike. Given the folder `test/` instead, Node 20 runs every module under it as a test, the fixtures too,
|
|
243
|
-
and Node 22 and 24 run none: they take the folder for a module, and fail. The whole suite was run on
|
|
244
|
-
2026-11-
|
|
245
|
-
there, its command and its library); Node 24.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
`
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
288
|
+
and Node 22 and 24 run none: they take the folder for a module, and fail. The whole suite was run on five Node lines on
|
|
289
|
+
2026-11-22, at this release's code, by default with no failure: Node 26.13.1, 444 tests, 444 passed (GNU FriBidi 1.0.18
|
|
290
|
+
there, its command and its library); Node 24.18.0 on a second machine, 444 tests, 444 passed (GNU FriBidi 1.0.18 there
|
|
291
|
+
too); Node 24.22.3, 22.23.3 and 20.20.2 in docker (the images node:24-slim, node:22-slim and node:20-slim, as a user who
|
|
292
|
+
is not root), 444 tests each, 436 passed and 8 skipped, as there is no GNU FriBidi, no python3 (which the five tests of
|
|
293
|
+
FriBidi's library run) and no Electron in them. Each with the pinned Unicode files named (`LTMS_READER_UCD`,
|
|
294
|
+
`LTMS_READER_EAW`). So it was under `NODE_OPTIONS=--max-old-space-size=500` on each line, and under `=100` on each but
|
|
295
|
+
Node 20 (no test reads the environment's `NODE_OPTIONS` where it means none, and the test of a turn of 33,000 calls
|
|
296
|
+
reads it in a process of its own): on Node 20 under `=100`, the process of the record view's tests was ended by
|
|
297
|
+
SIGABRT in some runs, on 2026-11-22 in 2 of 5 runs of the whole suite and 9 of 20 of that file alone, in a second set 3
|
|
298
|
+
of 5 and 6 of 20, and in a third, at this release's code, 2 of 5 and 5 of 20 (Node's heap ran out in its test of a
|
|
299
|
+
record nested 990 deep, a test that gives the record rule more memory than its process has, after the file's test of a
|
|
300
|
+
paragraph of 200,000 paths: the CHANGELOG's Tests line). The tests run the session, turn and record views (as text and
|
|
301
|
+
as JSON) at 80 x 24 and 200 x 60 over ltms's
|
|
302
|
+
own synthetic transcripts (`test/fixtures/ltms`) and the reader's (`test/fixtures/hebrew-english.jsonl`, `escapes.jsonl`
|
|
303
|
+
and `channels.jsonl`, written by `node test/fixtures/make-fixtures.mjs`), Projects and Sessions at both sizes and Search
|
|
304
|
+
at 80 x 24, compare what each row says with ltms's own commands, read every byte the reader writes for a transcript full
|
|
305
|
+
of escape sequences, and run it end to end in a pseudo-terminal (`script`, on Linux). `LTMS_READER_FIXTURES=<folder>`
|
|
306
|
+
adds every `.jsonl` under a folder to the views' test (the core's own `test/fixtures`, say). The width table's
|
|
307
|
+
regeneration is checked when `LTMS_READER_EAW` names the pinned `EastAsianWidth.txt`; the bidirectional table's
|
|
308
|
+
regeneration, and Unicode's conformance test of the algorithm (`test/bidi.test.mjs`, which reports how many cases passed
|
|
309
|
+
and failed), when `LTMS_READER_UCD` names a folder holding the pinned files (`scripts/bidi-table.mjs` names each with
|
|
310
|
+
its sha256); GNU FriBidi's layout of the right-to-left page and fixtures is compared with the reader's where `fribidi`
|
|
311
|
+
is on the PATH (or `LTMS_READER_FRIBIDI` names it); and each line of paragraphs wrapped into lines (the fixtures', and
|
|
312
|
+
random ones) with its library's, where `python3` can load `libfribidi` (`test/fribidi-lines.py`;
|
|
313
|
+
`LTMS_READER_LIBFRIBIDI` names the library, `LTMS_READER_PYTHON` the Python); and its command with a left-to-right base
|
|
314
|
+
(`fribidi --ltr`, standing for a terminal that lays each line out with one, as Konsole does at its default settings)
|
|
315
|
+
over the reader's own rows whose first cluster is right to left, a pointed and an Arabic one among them. GNU FriBidi
|
|
316
|
+
1.0.18 lays some paragraphs out otherwise than UAX #9 (brackets next to a nonspacing mark): a line on which the reader
|
|
317
|
+
and FriBidi's library differ is laid out by the tests' own reference of UAX #9 too (`test/uba-reference.mjs`, checked on
|
|
318
|
+
`BidiCharacterTest.txt`, every case, and on `BidiTest.txt` when the folder holds it), and counts as FriBidi's
|
|
319
|
+
difference, said and not failed, where FriBidi differs from the reference and the reader does not:
|
|
269
320
|
|
|
270
321
|
```sh
|
|
271
322
|
curl -sS --fail -o EastAsianWidth.txt https://www.unicode.org/Public/17.0.0/ucd/EastAsianWidth.txt
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ltms-reader",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A terminal reader of your own Claude Code sessions: the turns, the tool calls, the compactions, and the text behind every address ltms prints. Read-only, local, no network.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/app.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
// The state is a stack of views: the bottom one is Projects (a folder of projects) or the session (one transcript);
|
|
5
5
|
// Enter pushes the row's view, Esc pops it. A search or an address pushes what it opens on top of where it was, so Esc
|
|
6
|
-
// goes back there; r reads the list on screen again, Projects or a project's Sessions
|
|
6
|
+
// goes back there; r reads the list on screen again, Projects or a project's Sessions. Lists come from the
|
|
7
7
|
// source (src/sources.mjs): the projects at once, a project's sessions by ltms index and a search by ltms search, each
|
|
8
8
|
// while the screen says what is being read; a session is read in this process, after a frame that says which file is
|
|
9
9
|
// being read.
|
|
@@ -55,7 +55,7 @@ export function sessionRows(view) {
|
|
|
55
55
|
export const sessionsRows = (d) => d.sessions.map((s) => ({ kind: 'session', p: s.p, first: s.first, last: s.last, turns: s.turns, calls: s.calls, failures: s.failures, compactions: Array.isArray(s.compactions) ? s.compactions.length : 0, agents: s.agents, file: s.file, firstPrompt: s.firstPrompt, lastReply: s.lastReply, copies: s.copies?.length ?? 0 }));
|
|
56
56
|
|
|
57
57
|
/** Where the selection goes in a list read again: the row `same` finds, when there is one; else the place it was at,
|
|
58
|
-
* within the list
|
|
58
|
+
* within the list. */
|
|
59
59
|
const keptAt = (rows, same, at) => { const i = rows.findIndex(same); return i >= 0 ? i : Math.max(0, Math.min(at, rows.length - 1)); };
|
|
60
60
|
|
|
61
61
|
/** The rows of a turn view: its prompt, then its items in the order they were written; a call's result right after it. */
|
|
@@ -155,8 +155,8 @@ export class App {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
/**
|
|
158
|
-
* r (
|
|
159
|
-
*
|
|
158
|
+
* r (before it, a list was read once, and a project whose files changed showed the list as it was read until the
|
|
159
|
+
* reader started again): the list on screen read again, Projects by the projects folder's walk, a project's
|
|
160
160
|
* Sessions by `ltms index` run afresh (a list kept from an earlier reading too), its view saying what is being read
|
|
161
161
|
* meanwhile, as when it was opened; the selection on the same row when it is still there (a project by its name, a
|
|
162
162
|
* session by its file), else at the place it was. On another view, or while a Sessions list is being read, a note.
|
package/src/bidi.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// src/bidi.mjs — the Unicode Bidirectional Algorithm (UAX #9), version 17.0.0, as the reader lays out a line of text for
|
|
2
|
-
// a terminal that draws text in the order it is written (R1,
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// src/
|
|
2
|
+
// a terminal that draws text in the order it is written (R1: as measured, Alacritty does, and so does the xterm.js of VS
|
|
3
|
+
// Code 1.146.0's terminal, 6.1.0-beta.304, run in a headless browser, with its WebGL renderer), and for every terminal:
|
|
4
|
+
// one that lays bidirectional text out itself, as Konsole does, gets the line inside a left-to-right override
|
|
5
|
+
// (src/screen.mjs). Pure functions over code points; the data is src/bidi-table.mjs, generated
|
|
6
|
+
// from the Unicode Character Database (scripts/bidi-table.mjs).
|
|
6
7
|
//
|
|
7
8
|
// What is implemented: the paragraph's level by P2 and P3 (its first strong character, skipping an isolate; none: left
|
|
8
9
|
// to right), or given (HL1); X9, which removes BN (and the embeddings and overrides); the implicit algorithm, W1 to W7,
|
|
@@ -41,7 +42,7 @@ export function classOf(cp) {
|
|
|
41
42
|
return L;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
/** Each character's class, by code unit (
|
|
45
|
+
/** Each character's class, by code unit (a paragraph's characters, classed at once): at the first unit of a
|
|
45
46
|
* surrogate pair its code point's, at the second BN, which X9 passes over as it passes BN over; a lone surrogate's own. */
|
|
46
47
|
export function classesOf(s) {
|
|
47
48
|
const n = s.length, out = new Uint8Array(n);
|
|
@@ -68,7 +69,7 @@ export const mirrorOf = (cp) => MIRROR.get(cp) ?? cp;
|
|
|
68
69
|
|
|
69
70
|
const isStrong = (c) => c === L || c === R || c === AL;
|
|
70
71
|
/** The classes X9 removes, and the neutral and isolate types N1 and N2 resolve (NI), as tables by class: a paragraph's
|
|
71
|
-
* levels are resolved over all its characters at once (
|
|
72
|
+
* levels are resolved over all its characters at once (R's record is a paragraph of 4,000,000), each looked up. */
|
|
72
73
|
const REMOVED = new Uint8Array(24), NI = new Uint8Array(24);
|
|
73
74
|
for (const c of [BN, LRE, LRO, RLE, RLO, PDF]) REMOVED[c] = 1;
|
|
74
75
|
|
|
@@ -213,8 +214,8 @@ export function resolveLevels(cps, classes, level) {
|
|
|
213
214
|
* characters before it, and those at the line's end, take the paragraph's level (characters X9 removed are passed
|
|
214
215
|
* over, and keep -1). A stretch laid out on its own (ISO) is not one of them: it stands for an isolate's initiator, its
|
|
215
216
|
* content and its PDI, and only the PDI, which is never drawn, would take the paragraph's level; where the content is
|
|
216
|
-
* drawn follows the initiator's level, which L1 leaves as it was (GNU FriBidi's library
|
|
217
|
-
* at a line's end
|
|
217
|
+
* drawn follows the initiator's level, which L1 leaves as it was (as GNU FriBidi's library lays out the content between
|
|
218
|
+
* LRI and PDI at a line's end). Changes `levels` in place.
|
|
218
219
|
*/
|
|
219
220
|
export function lineLevels(classes, levels, level, from = 0, to = classes.length) {
|
|
220
221
|
const ws = (c) => c === WS || c === LRI || c === RLI || c === FSI || c === PDI;
|
package/src/guard.mjs
CHANGED
|
@@ -17,15 +17,16 @@
|
|
|
17
17
|
// loaded through NODE_OPTIONS or --import that throws, say) ends the screen by its own way out, SIGTERM, on which the
|
|
18
18
|
// screen's process restores the terminal and exits; this process waits for that (STOP_WAIT at most; then SIGKILL, and
|
|
19
19
|
// the leave sequence is written here), writes what the screen's process wrote to stderr, then its own report, after the
|
|
20
|
-
// restore, by the error's kind and place, not its message (src/main.mjs errorReport), and ends with 1.
|
|
21
|
-
// own report of such an error, its message with it, was written on the alternate screen while the frame was up,
|
|
22
|
-
// screen's own report went to a pipe no one read. Everything this process writes to stderr is made visible.
|
|
20
|
+
// restore, by the error's kind and place, not its message (src/main.mjs errorReport), and ends with 1. Without this,
|
|
21
|
+
// Node's own report of such an error, its message with it, was written on the alternate screen while the frame was up,
|
|
22
|
+
// and the screen's own report went to a pipe no one read. Everything this process writes to stderr is made visible.
|
|
23
23
|
//
|
|
24
24
|
// Nothing runs in this process when SIGKILL ends it: the screen's process learns of it by an IPC channel this process
|
|
25
25
|
// opens to it, which the kernel closes when this process is gone, and then restores the terminal and ends
|
|
26
|
-
// (src/main.mjs).
|
|
27
|
-
// end of a socketpair on fd 3, each reached a child 3 to 4 ms after its parent's SIGKILL, on Node
|
|
28
|
-
// and neither kept an idle child running once unref'd; the channel needs no flag to say it is
|
|
26
|
+
// (src/main.mjs). Without the channel, it lived on, raw, until the terminal hung up. Measured: the channel's
|
|
27
|
+
// disconnect, and the end of a socketpair on fd 3, each reached a child 3 to 4 ms after its parent's SIGKILL, on Node
|
|
28
|
+
// 26.13.1 and 20.20.2, and neither kept an idle child running once unref'd; the channel needs no flag to say it is
|
|
29
|
+
// there (process.channel).
|
|
29
30
|
import { spawn } from 'node:child_process';
|
|
30
31
|
import { writeSync } from 'node:fs';
|
|
31
32
|
import { constants } from 'node:os';
|
package/src/reading.mjs
CHANGED
|
@@ -45,13 +45,13 @@ function memoryOfNode() {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* The memory limit the size rules read
|
|
48
|
+
* The memory limit the size rules read: Node's heap limit (V8's heap_size_limit, ltms's measure), but no
|
|
49
49
|
* more than the old space's where Node's flags set it. A heap limit is the old space and the young generation's reserve,
|
|
50
50
|
* and the reserve is sized from the machine's memory, not from the old space set: with --max-old-space-size=16, measured,
|
|
51
51
|
* the heap limit is 64 MB on Node 20.20.2 and 22.23.3, 208 MB on 24.22.3 and 112 MB on 26.13.1 (with
|
|
52
52
|
* --max-semi-space-size=1 too, 19 MB). A transcript's text and what its parse makes of it live in the old space: by a
|
|
53
53
|
* tenth of the heap limit, under an old space of 16 MB, Node 24 read a transcript of 8 to 20 MB and its parse ran the old
|
|
54
|
-
* space out (R.F14 on Box B's Node 24.18.0), and Node 26 one of 10 or 11 MB (
|
|
54
|
+
* space out (R.F14 on Box B's Node 24.18.0), and Node 26 one of 10 or 11 MB (measured on 2026-11-17). The flags, as
|
|
55
55
|
* Node and V8 take them (measured on Node 22.23.3 and 24.22.3): --max-old-space-size=N (or --max_old_space_size), in
|
|
56
56
|
* NODE_OPTIONS or on node's command line, the command line's over NODE_OPTIONS', the last given, 0 setting none; and
|
|
57
57
|
* --max-old-space-size-percentage=P (Node 22 and later), the old space at P per cent of the memory Node reads (in MB,
|
|
@@ -76,8 +76,8 @@ export function memoryLimit({ heap = getHeapStatistics().heap_size_limit, execAr
|
|
|
76
76
|
export const sizeLimit = (heapLimit) => Math.min(STRING_MAX, Math.floor(heapLimit / 10));
|
|
77
77
|
|
|
78
78
|
/** n bytes as a refusal says them: in KB under a megabyte, else in MB, rounded by `round`: a size up (Math.ceil), so that
|
|
79
|
-
* it is never said smaller than it is, and a limit down (Math.floor), never said larger.
|
|
80
|
-
* refusal
|
|
79
|
+
* it is never said smaller than it is, and a limit down (Math.floor), never said larger. Rounding both up, a
|
|
80
|
+
* transcript's refusal said "it is 2 MB, and this process reads a transcript of up to 2 MB". */
|
|
81
81
|
const sized = (n, round) => (n < MB ? `${round(n / 1024).toLocaleString('en-US')} KB` : `${round(n / MB).toLocaleString('en-US')} MB`);
|
|
82
82
|
|
|
83
83
|
/** Why a file of `size` bytes is not read here (with the NODE_OPTIONS that would let it be, before `again`, the command
|
|
@@ -100,21 +100,21 @@ export const PARSE_PER_BYTE = 8;
|
|
|
100
100
|
export const RECORD_VIEW_PER_BYTE = 16;
|
|
101
101
|
|
|
102
102
|
/** What writing a record's JSON takes in the old space, for each byte of that JSON (`built`, view.mjs recordViewBytes),
|
|
103
|
-
* the JSON itself included
|
|
103
|
+
* the JSON itself included. Measured on 2026-11-17 (the least --max-old-space-size at
|
|
104
104
|
* which the reader, run as the tests run it, opened a record and laid out its JSON, with the size rules set aside), less
|
|
105
105
|
* what the reader needs for a record of no size (BUILT_MARGIN's measure), over the JSON: for lists nested 200 to 990 deep
|
|
106
106
|
* of 10,000 to 1,000,000 numbers, Latin or Hebrew strings, in files of up to 2.4 MB, up to 1.04 times on Node 22.23.3,
|
|
107
107
|
* 24.22.3 and 26.13.1 (13 records each), and up to 1.41 on Node 20.20.2 (19 records; a list nested 600 deep of 60,000
|
|
108
108
|
* Hebrew strings, 212 MB of JSON, opened from an old space of 306 MB there, from 222 to 224 on the others). */
|
|
109
109
|
export const BUILT_PER_BYTE = 1.5;
|
|
110
|
-
/** What a record's view needs beside what writing its JSON takes and the transcript's parse, in the old space
|
|
111
|
-
*
|
|
110
|
+
/** What a record's view needs beside what writing its JSON takes and the transcript's parse, in the old space: the
|
|
111
|
+
* reader's own, measured as the least old space at which it opened the smallest record (R.F1's shape, a
|
|
112
112
|
* line of 11 KB) and laid out its JSON: 7 MB on Node 20.20.2 and 22.23.3, 8 on 26.13.1, 9 on 24.22.3. With these, the
|
|
113
113
|
* rule refuses at every old space at which a measured record's view ran out (130 records over the four lines: text of
|
|
114
114
|
* 11 KB to 16 MB, lists nested deep, a list of a million numbers, objects of 100,000 and 200,000 keys), and shows the
|
|
115
|
-
* smallest from an old space of 14 MB.
|
|
116
|
-
* young generation's reserve beside the old space;
|
|
117
|
-
*
|
|
115
|
+
* smallest from an old space of 14 MB. An earlier rule had 96 MB here, measured against Node's heap limit, which holds
|
|
116
|
+
* the young generation's reserve beside the old space; once the rule read the old space set, with 96 MB it refused
|
|
117
|
+
* every record under an old space below about 107 MB (found on 2026-11-17: records of 11 KB and 513 KB at 32 and
|
|
118
118
|
* 64 MB, on Node 20, 24 and 26). */
|
|
119
119
|
export const BUILT_MARGIN = 12 * MB;
|
|
120
120
|
|