tring-chat 0.1.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.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +325 -0
  3. package/dist/tring.js +1504 -0
  4. package/dist/web/assets/index-BftoNEAK.js +66 -0
  5. package/dist/web/assets/index-CNNs5rrz.css +32 -0
  6. package/dist/web/assets/inter-cyrillic-400-normal-HOLc17fK.woff +0 -0
  7. package/dist/web/assets/inter-cyrillic-400-normal-obahsSVq.woff2 +0 -0
  8. package/dist/web/assets/inter-cyrillic-600-normal-4D_pXhcN.woff +0 -0
  9. package/dist/web/assets/inter-cyrillic-600-normal-CWCymEST.woff2 +0 -0
  10. package/dist/web/assets/inter-cyrillic-ext-400-normal-BQZuk6qB.woff2 +0 -0
  11. package/dist/web/assets/inter-cyrillic-ext-400-normal-DQukG94-.woff +0 -0
  12. package/dist/web/assets/inter-cyrillic-ext-600-normal-Bcila6Z-.woff +0 -0
  13. package/dist/web/assets/inter-cyrillic-ext-600-normal-Dfes3d0z.woff2 +0 -0
  14. package/dist/web/assets/inter-greek-400-normal-B4URO6DV.woff2 +0 -0
  15. package/dist/web/assets/inter-greek-400-normal-q2sYcFCs.woff +0 -0
  16. package/dist/web/assets/inter-greek-600-normal-BZpKdvQh.woff +0 -0
  17. package/dist/web/assets/inter-greek-600-normal-plRanbMR.woff2 +0 -0
  18. package/dist/web/assets/inter-greek-ext-400-normal-DGGRlc-M.woff2 +0 -0
  19. package/dist/web/assets/inter-greek-ext-400-normal-KugGGMne.woff +0 -0
  20. package/dist/web/assets/inter-greek-ext-600-normal-B8X0CLgF.woff +0 -0
  21. package/dist/web/assets/inter-greek-ext-600-normal-DRtmH8MT.woff2 +0 -0
  22. package/dist/web/assets/inter-latin-400-normal-C38fXH4l.woff2 +0 -0
  23. package/dist/web/assets/inter-latin-400-normal-CyCys3Eg.woff +0 -0
  24. package/dist/web/assets/inter-latin-600-normal-CiBQ2DWP.woff +0 -0
  25. package/dist/web/assets/inter-latin-600-normal-LgqL8muc.woff2 +0 -0
  26. package/dist/web/assets/inter-latin-ext-400-normal-77YHD8bZ.woff +0 -0
  27. package/dist/web/assets/inter-latin-ext-400-normal-C1nco2VV.woff2 +0 -0
  28. package/dist/web/assets/inter-latin-ext-600-normal-CIVaiw4L.woff +0 -0
  29. package/dist/web/assets/inter-latin-ext-600-normal-D2bJ5OIk.woff2 +0 -0
  30. package/dist/web/assets/inter-vietnamese-400-normal-Bbgyi5SW.woff +0 -0
  31. package/dist/web/assets/inter-vietnamese-400-normal-DMkecbls.woff2 +0 -0
  32. package/dist/web/assets/inter-vietnamese-600-normal-BuLX-rYi.woff +0 -0
  33. package/dist/web/assets/inter-vietnamese-600-normal-Cc8MFFhd.woff2 +0 -0
  34. package/dist/web/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
  35. package/dist/web/assets/jetbrains-mono-cyrillic-400-normal-ugxPyKxw.woff +0 -0
  36. package/dist/web/assets/jetbrains-mono-cyrillic-700-normal-BWTpRfYl.woff2 +0 -0
  37. package/dist/web/assets/jetbrains-mono-cyrillic-700-normal-CEoEElIJ.woff +0 -0
  38. package/dist/web/assets/jetbrains-mono-greek-400-normal-B9oWc5Lo.woff +0 -0
  39. package/dist/web/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
  40. package/dist/web/assets/jetbrains-mono-greek-700-normal-C6CZE3T8.woff2 +0 -0
  41. package/dist/web/assets/jetbrains-mono-greek-700-normal-DEigVDxa.woff +0 -0
  42. package/dist/web/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  43. package/dist/web/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  44. package/dist/web/assets/jetbrains-mono-latin-700-normal-BYuf6tUa.woff2 +0 -0
  45. package/dist/web/assets/jetbrains-mono-latin-700-normal-D3wTyLJW.woff +0 -0
  46. package/dist/web/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
  47. package/dist/web/assets/jetbrains-mono-latin-ext-400-normal-fXTG6kC5.woff +0 -0
  48. package/dist/web/assets/jetbrains-mono-latin-ext-700-normal-CZipNAKV.woff2 +0 -0
  49. package/dist/web/assets/jetbrains-mono-latin-ext-700-normal-CxPITLHs.woff +0 -0
  50. package/dist/web/assets/jetbrains-mono-vietnamese-400-normal-CqNFfHCs.woff +0 -0
  51. package/dist/web/assets/jetbrains-mono-vietnamese-700-normal-BDLVIk2r.woff +0 -0
  52. package/dist/web/index.html +19 -0
  53. package/package.json +52 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Matogen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,325 @@
1
+ # tring.chat
2
+
3
+ A focus-centred terminal deck for agentic work.
4
+
5
+ Run many agent sessions at once — Claude Code, other coding agents, plain shells — and
6
+ stay focused on one. The session you are working in fills the centre of the screen.
7
+ Up to 16 others run in zoomed-out live thumbnails around it, so you can see them
8
+ working. When a session finishes and is waiting for you, its tile turns green.
9
+ Press `Ctrl+Space`, then one key, and that session is in the centre.
10
+
11
+ ```
12
+ ┌────┬────┬────┬────┬────┐
13
+ │ 1 │ 2 │ 3 │ 4 │ 5 │
14
+ ├────┼────┴────┴────┼────┤
15
+ │ 16 │ │ 6 │
16
+ ├────┤ focus ├────┤
17
+ │ 15 │ terminal │ 7 │
18
+ ├────┤ ├────┤
19
+ │ 14 │ │ 8 │
20
+ ├────┼────┬────┬────┼────┤
21
+ │ 13 │ 12 │ 11 │ 10 │ 9 │
22
+ └────┴────┴────┴────┴────┘
23
+ ```
24
+
25
+ Slots are fixed. Focusing a session shows it in the centre without moving it, so the
26
+ ring never shuffles and slot numbers stay in muscle memory.
27
+
28
+ Sixteen is the default, not the only option — the gear in the tab bar switches to 12, 8
29
+ or 4. See [Ring size](#ring-size).
30
+
31
+ ## Install
32
+
33
+ ```
34
+ npm i -g tring-chat
35
+ tring
36
+ ```
37
+
38
+ Node 20 or newer. node-pty ships prebuilt binaries for macOS and Windows —
39
+ `darwin-x64`, `darwin-arm64`, `win32-x64`, `win32-arm64` — so those install with no
40
+ compiler step.
41
+
42
+ **Linux and WSL build node-pty from source.** There is no Linux prebuild, so the
43
+ install runs `node-gyp` and needs a toolchain:
44
+
45
+ ```
46
+ sudo apt install -y build-essential python3 # Debian/Ubuntu/WSL
47
+ sudo dnf install -y gcc-c++ make python3 # Fedora/RHEL
48
+ ```
49
+
50
+ Without those, `npm i -g tring-chat` fails while building node-pty. It takes a few seconds
51
+ once they are present.
52
+
53
+ `tring` starts the daemon and opens a chromeless browser window — no address bar, no
54
+ tab strip, its own taskbar entry. In that window the browser stops reserving
55
+ `Ctrl+1`–`Ctrl+8` for tab switching, so slots 11–16 get their natural keys.
56
+
57
+ ### Windows
58
+
59
+ node-pty ships prebuilt binaries for `win32-x64` and `win32-arm64`, so no Visual
60
+ Studio Build Tools, Python or node-gyp are needed. From PowerShell:
61
+
62
+ ```powershell
63
+ npm i -g tring-chat
64
+ tring
65
+ ```
66
+
67
+ That is all that is needed to *use* it. The rest of this section applies only
68
+ if you are working on tring itself from a checkout.
69
+
70
+ **Use a separate clone for Windows.** `node_modules` holds a compiled
71
+ `node-pty` binary for one platform only, so running `npm install` on Windows in
72
+ a folder you also use from WSL replaces the Linux binary and breaks the WSL
73
+ side, and vice versa. Two checkouts, or `rm -rf node_modules && npm install`
74
+ each time you switch.
75
+
76
+ Sessions default to `powershell.exe`. To choose otherwise:
77
+
78
+ ```powershell
79
+ tring --shell pwsh.exe # PowerShell 7
80
+ tring --shell cmd.exe
81
+ tring --shell wsl.exe # WSL shells from the Windows app
82
+ ```
83
+
84
+ `--shell wsl.exe` is worth knowing about: it runs the daemon natively on
85
+ Windows while every terminal is a WSL bash shell, which is usually where the
86
+ dev tooling and Claude Code actually live.
87
+
88
+ Config lives at `%USERPROFILE%\.config\tring\projects.json`.
89
+
90
+ To run from a checkout instead:
91
+
92
+ ```
93
+ npm install
94
+ npm run build && npm start # daemon on http://127.0.0.1:7331
95
+ npm run dev # tsx watch, no window (TRING_NO_OPEN)
96
+ npm test # vitest
97
+ npm i -g ./packages/server # install this checkout as `tring`
98
+ ```
99
+
100
+ Flags: `--port` (7331), `--host` (127.0.0.1), `--token`, `--scrollback` (5000),
101
+ `--idle-ms` (3000), `--shell`, `--no-open`, `--no-update-check`, `--version`.
102
+
103
+ ## Projects
104
+
105
+ A project is a name and a root directory, and it owns its own 16 slots and its own
106
+ picker. The first run asks you to create one. Add more with `+` in the tab bar, and
107
+ switch with a click or `p` inside the picker.
108
+
109
+ So you can keep one project with 16 terminals, or one project per repository — each
110
+ with its own ring.
111
+
112
+ Sessions in projects you are **not** looking at keep running and keep being tracked.
113
+ Their tab shows a green badge counting how many have finished, so a background agent
114
+ finishing is visible without rendering its ring. Only the project you are viewing
115
+ streams thumbnails, which is what keeps several projects cheap.
116
+
117
+ ## How it works
118
+
119
+ - A local Node daemon owns every terminal (PTY) and keeps a headless copy of its
120
+ screen and scrollback. Reloading the browser loses nothing.
121
+ - The browser runs one real terminal (xterm.js) for the centre. Thumbnails are small
122
+ canvases repainted from throttled screen snapshots, so 16 busy sessions stay cheap.
123
+ - A session is **busy** while it produces output, **done** (green) when it goes quiet,
124
+ when the shell prompt returns (OSC 133), when it rings the bell, or when a Claude Code
125
+ Stop hook calls back. It stays green until you type into it, so you can read the
126
+ result first.
127
+
128
+ ## Keys
129
+
130
+ | Key | Action |
131
+ |---|---|
132
+ | `Ctrl+Space` | open the picker |
133
+ | `1`–`9`, `0` | focus slot 1–10 |
134
+ | `Ctrl+1`–`Ctrl+6` or `Shift+1`–`Shift+6` | focus slot 11–16 |
135
+ | `n` | focus the next finished session |
136
+ | `p` | switch project |
137
+ | `Space` | back to the previous session |
138
+ | `c` / `r` / `x` | new session / rename and colour / kill |
139
+ | `m` | mark seen |
140
+ | `Esc` | close the picker |
141
+
142
+ Browsers reserve `Ctrl+1`–`Ctrl+8` for tab switching, so `Shift+digit` is the
143
+ fallback that always works in an ordinary tab. Clicking a thumbnail also focuses it,
144
+ and right-clicking one opens the same dialog `r` does.
145
+
146
+ ## Naming and colouring tiles
147
+
148
+ Right-click a tile — or press `r` in the picker — to give it a name and a colour.
149
+
150
+ The colour is a ring *outside* the status border, never instead of it, so a tile you
151
+ have tinted still reports whether it is busy, finished or dead. Twenty-four choices:
152
+ twelve hues — red, orange, gold, lime, green, teal, cyan, blue, indigo, violet, pink,
153
+ slate — in a bright and a deep tier.
154
+
155
+ Red, gold and green are in there, which means a tint can echo a status colour that means
156
+ something else. That stays readable because they are separate rings, but it is worth
157
+ knowing when you pick: mint means *finished*, amber means *busy* and red means *dead*,
158
+ and those meanings belong to the border, not to your tint.
159
+
160
+ Names and colours are per session and survive a restart, alongside the slot and the
161
+ working directory.
162
+
163
+ ## Updating
164
+
165
+ A global npm install is a frozen snapshot: npm never checks for new versions
166
+ and never notifies. So tring asks the registry itself, at most once a day, and
167
+ shows a notice in the tab bar when a newer release exists.
168
+
169
+ ```
170
+ npm i -g tring-chat
171
+ ```
172
+
173
+ Running sessions are unaffected until you restart the daemon. The check never
174
+ blocks startup and fails silently when offline. Opt out with
175
+ `--no-update-check` or `TRING_NO_UPDATE_CHECK=1`.
176
+
177
+ ## Ring size
178
+
179
+ Sixteen terminals is the default. The gear in the tab bar offers 4, 8, 12 and 16, and the
180
+ choice is remembered per browser.
181
+
182
+ Twelve and sixteen are rings. Four and eight are bands — a row above and a row below, with
183
+ the focus terminal spanning the full width, because below twelve slots a ring's side
184
+ columns cost the centre more width than the tiles are worth:
185
+
186
+ ```
187
+ 4 slots 8 slots
188
+ ┌────────┬────────┐ ┌────┬────┬────┬────┐
189
+ │ 1 │ 2 │ │ 1 │ 2 │ 3 │ 4 │
190
+ ├────────┴────────┤ ├────┴────┴────┴────┤
191
+ │ focus │ │ focus │
192
+ ├────────┬────────┤ ├────┬────┬────┬────┤
193
+ │ 4 │ 3 │ │ 8 │ 7 │ 6 │ 5 │
194
+ └────────┴────────┘ └────┴────┴────┴────┘
195
+ ```
196
+
197
+ The daemon is unaffected: every project still owns sixteen slots, so this is a view onto
198
+ them rather than a limit on them. Shrinking below a slot that is in use is refused with a
199
+ notice rather than hiding a session that would still ring and still count in the tab badge
200
+ — close those sessions first, or switch back up.
201
+
202
+ ## Claude usage
203
+
204
+ Optional, off by default. Turn on **Enable Claude usage monitoring** in the gear, and a
205
+ pinned `Usage` tab appears in the tab bar — a quick glance at what Claude Code has spent,
206
+ without leaving tring.
207
+
208
+ ```
209
+ Session ████░░░░░░░░ 27% resets Sep 4, 11:29am
210
+ Week (all models) ████░░░░░░░░ 27% resets Sep 7, 9:59am
211
+ Week (Fable) ████░░░░░░░░ 28% resets Sep 7, 9:59am
212
+ from Claude Code’s own /usage
213
+
214
+ 1.7M tokens today · $34.55 today · $622.47 this week · 750B cache reads
215
+ ```
216
+
217
+ **The percentages are the real ones.** Opening the tab runs `claude -p "/usage"`, which
218
+ Claude Code answers locally — zero turns, zero tokens, no API call — so the numbers are
219
+ exactly what `/usage` shows in a session. Nothing is read out of your credential file and
220
+ nothing leaves the machine. The answer is cached for 30 seconds, so the first look costs
221
+ about 1.8s and the rest are instant.
222
+
223
+ Underneath, the token counts and cost estimates come from Claude Code's transcripts in
224
+ `~/.claude/projects` (or `CLAUDE_CONFIG_DIR`), which is also where the per-project split
225
+ comes from — `/usage` does not break usage down by repository. A full scan of a year of
226
+ history takes about half a second.
227
+
228
+ The token count is `input + output + cache creation`. Cache reads are shown separately
229
+ rather than folded in: a typical week here is 750B cache reads against 22M other tokens,
230
+ so including them would make the bar 99% cache and tell you nothing. Costs are estimates
231
+ from a built-in price table.
232
+
233
+ If the `claude` command is not on the daemon's PATH — running tring natively on Windows
234
+ against a WSL install, say — the tab reports the transcript numbers on their own and says
235
+ why there is no percentage. There is nothing to configure either way: a bar needs a real
236
+ ceiling, and inventing one would be worse than having none.
237
+
238
+ Reloading while the tab is open leaves you on it.
239
+
240
+ ## Sound
241
+
242
+ When a session turns green, tring rings — two short strikes, synthesised rather
243
+ than shipped as an audio file. Toggle it with the bell in the tab bar; the
244
+ choice is remembered per browser.
245
+
246
+ It rings only on the transition to green, so reconnecting or reloading a page
247
+ full of finished sessions stays silent.
248
+
249
+ It also rings only when the daemon is *confident* something finished. An
250
+ explicit signal — a Claude Code Stop hook, an OSC 133 prompt marker, a terminal
251
+ bell — always rings, because each means exactly one thing. Silence after output
252
+ is a guess, and an app that has merely finished starting up looks identical to
253
+ one that has finished working: Claude Code draws its interface for a few
254
+ seconds and then waits. So an inferred finish only rings after ten seconds of
255
+ sustained work, while the tile still turns green either way.
256
+
257
+ Installing the Stop hook below is what makes this exact for Claude Code.
258
+
259
+ ## Restarting
260
+
261
+ Switching projects puts you back in the session you were last using in that project,
262
+ rather than an empty centre.
263
+
264
+ Reopening brings back every project with its tabs, slots, names and working
265
+ directories. The active project's shells spawn immediately; other projects spawn when
266
+ you first switch to them.
267
+
268
+ If your shell's startup file changes directory — `cd /mnt/c` in a `~/.bashrc`,
269
+ say — it runs *after* the shell has been placed in the directory you chose, and
270
+ would otherwise silently discard that choice. tring puts the shell back once,
271
+ shortly after start, unless you have already typed something: at that point the
272
+ shell is yours.
273
+
274
+ Sessions come back in the directory the shell was actually in, not the one it
275
+ was started in — `cd` somewhere and that is where you return. The daemon reads
276
+ this from the shell's own process on Linux and WSL, and from OSC 7 on shells
277
+ that emit it.
278
+
279
+ Two things are deliberate:
280
+
281
+ - **Scrollback is not restored.** The buffer lives in daemon memory, and persisting
282
+ dozens of sessions of history to disk continuously is a different product.
283
+ - **A recorded command is offered, never re-run.** A restored slot gets a plain shell
284
+ in the right directory, with its old command on the tile as a one-click re-run.
285
+ Auto-executing whatever was there last time is how four dev servers end up fighting
286
+ over a port.
287
+
288
+ ## Claude Code
289
+
290
+ Optional. Add a `Stop` hook to `~/.claude/settings.json` so a tile turns green the
291
+ instant Claude ends its turn instead of after the idle timeout:
292
+
293
+ ```json
294
+ {
295
+ "hooks": {
296
+ "Stop": [
297
+ { "hooks": [ { "type": "command",
298
+ "command": "curl -s -X POST \"$TRING_URL/api/sessions/$TRING_SESSION_ID/done\"" } ] }
299
+ ]
300
+ }
301
+ }
302
+ ```
303
+
304
+ In a PowerShell session the same hook is:
305
+
306
+ ```powershell
307
+ curl.exe -s -X POST "$env:TRING_URL/api/sessions/$env:TRING_SESSION_ID/done"
308
+ ```
309
+
310
+ `curl.exe` rather than `curl`, which PowerShell aliases to `Invoke-WebRequest`.
311
+
312
+ `TRING_URL`, `TRING_SESSION_ID`, `TRING_SLOT` and `TRING_PROJECT` are set in every
313
+ session's environment. Session ids are globally unique, so this one snippet is correct
314
+ in every session of every project and does not change as projects come and go.
315
+
316
+ ## Stack
317
+
318
+ TypeScript throughout. Server: Node, `node-pty`, `@xterm/headless`, `ws`.
319
+ Web: Vite, `@xterm/xterm`, no UI framework. Tests: vitest.
320
+
321
+ Design: [`docs/superpowers/specs/2026-09-03-tring-design.md`](docs/superpowers/specs/2026-09-03-tring-design.md).
322
+
323
+ ## Licence
324
+
325
+ MIT.