throughline 0.3.16 → 0.3.18
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/README.md +11 -3
- package/package.json +1 -1
- package/src/prompt-submit.mjs +11 -0
- package/src/session-start.mjs +13 -0
- package/src/token-monitor.mjs +7 -2
package/README.md
CHANGED
|
@@ -178,9 +178,16 @@ Example output (real values from a running 1M-context Opus session):
|
|
|
178
178
|
- **Line-wrap safe.** Each line is truncated to `process.stdout.columns - 1`
|
|
179
179
|
before drawing, preserving ANSI color codes. The redraw cursor math cannot
|
|
180
180
|
desync on narrow terminals.
|
|
181
|
-
- **Resize resilient
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
- **Resize resilient via OSC 18t.** Windows ConPTY + VS Code task terminals
|
|
182
|
+
freeze `process.stdout.columns` at the PTY's initial size and never
|
|
183
|
+
propagate panel resizes into Node, so polling or `resize` events can't
|
|
184
|
+
catch them. Throughline queries the terminal itself with the CSI `18 t`
|
|
185
|
+
escape (`\x1b[18t`) every tick, parses the `\x1b[8;rows;cols t` reply off
|
|
186
|
+
stdin in raw mode, and uses the real current width for truncation. On
|
|
187
|
+
terminals that don't answer the query, the renderer falls back to
|
|
188
|
+
`process.stdout.columns → env.COLUMNS → 80`. When the width changes the
|
|
189
|
+
viewport is cleared in full (`\x1b[2J\x1b[3J\x1b[H`) before the next
|
|
190
|
+
frame so the previous, wrongly-sized frame can't stack beneath it.
|
|
184
191
|
- **Per-row "last updated" stamp.** Each session row carries an 8-cell
|
|
185
192
|
`just now` / `24m ago` stamp right after the session id, placed before the
|
|
186
193
|
bar so narrow terminals don't truncate it. It resets to `just now` on every
|
|
@@ -256,6 +263,7 @@ entry to the `tasks` array yourself:
|
|
|
256
263
|
| `throughline install --project` | Register hooks in `.claude/settings.json` for this repo only |
|
|
257
264
|
| `throughline uninstall` | Remove Throughline hooks from the settings file |
|
|
258
265
|
| `throughline monitor [--all] [--session <id>]` | Run the multi-session token monitor |
|
|
266
|
+
| `throughline monitor --diag` | Dump TTY/columns/env diagnostics (for debugging monitor render bugs) |
|
|
259
267
|
| `throughline detail <time>` | Retrieve L2 body text and L3 tool I/O for a turn (see below) |
|
|
260
268
|
| `throughline save-inflight` | Called by `/tl` to attach an in-flight memo (stdin) to the current baton |
|
|
261
269
|
| `throughline doctor` | Check Node version, hook registration, DB writability, PATH |
|
package/package.json
CHANGED
package/src/prompt-submit.mjs
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import { getDb } from './db.mjs';
|
|
16
16
|
import { writeBaton } from './baton.mjs';
|
|
17
|
+
import { ensureMonitorTaskFile } from './vscode-task.mjs';
|
|
17
18
|
import { appendFileSync, mkdirSync } from 'node:fs';
|
|
18
19
|
import { join, dirname } from 'node:path';
|
|
19
20
|
import { homedir } from 'node:os';
|
|
@@ -54,6 +55,16 @@ async function main() {
|
|
|
54
55
|
const payload = JSON.parse(raw);
|
|
55
56
|
const { session_id, cwd, prompt } = payload;
|
|
56
57
|
|
|
58
|
+
// VSCode 新規プロジェクトへの tasks.json 自動プロビジョニング。
|
|
59
|
+
// SessionStart/Stop に加えここでも呼ぶことで、どれか 1 つでも発火すれば初回メッセージ送信で
|
|
60
|
+
// tasks.json が生える。冪等性は ensureMonitorTaskFile 側で保証。/tl 判定より前に置く。
|
|
61
|
+
try {
|
|
62
|
+
ensureMonitorTaskFile({ cwd: cwd ?? process.cwd(), env: process.env });
|
|
63
|
+
} catch (err) {
|
|
64
|
+
const msg = err instanceof Error ? err.message : 'unknown';
|
|
65
|
+
process.stderr.write(`[vscode-task] ${msg}\n`);
|
|
66
|
+
}
|
|
67
|
+
|
|
57
68
|
if (!isBatonCommand(prompt)) {
|
|
58
69
|
process.exit(0);
|
|
59
70
|
return;
|
package/src/session-start.mjs
CHANGED
|
@@ -21,6 +21,7 @@ import { getDb } from './db.mjs';
|
|
|
21
21
|
import { consumeBaton } from './baton.mjs';
|
|
22
22
|
import { mergeSpecificPredecessor, resolveMergeTarget } from './session-merger.mjs';
|
|
23
23
|
import { buildResumeContext } from './resume-context.mjs';
|
|
24
|
+
import { ensureMonitorTaskFile } from './vscode-task.mjs';
|
|
24
25
|
import { appendFileSync, mkdirSync } from 'node:fs';
|
|
25
26
|
import { join, dirname } from 'node:path';
|
|
26
27
|
import { homedir } from 'node:os';
|
|
@@ -55,6 +56,18 @@ async function main() {
|
|
|
55
56
|
const db = getDb();
|
|
56
57
|
const now = Date.now();
|
|
57
58
|
|
|
59
|
+
// 0. VSCode で開かれた新規プロジェクトに .vscode/tasks.json を自動プロビジョニング。
|
|
60
|
+
// Stop hook 側にも同じ呼び出しがあるが、Stop が発火しない環境(応答中断・IDE 挙動差)
|
|
61
|
+
// でも SessionStart は必ず走るので、新規プロジェクトでの自動起動を確実化する保険。
|
|
62
|
+
// 冪等性は ensureMonitorTaskFile 側で保証されており、Stop/UserPromptSubmit と重複呼び
|
|
63
|
+
// 出しされても安全。
|
|
64
|
+
try {
|
|
65
|
+
ensureMonitorTaskFile({ cwd: projectPath, env: process.env });
|
|
66
|
+
} catch (err) {
|
|
67
|
+
const msg = err instanceof Error ? err.message : 'unknown';
|
|
68
|
+
process.stderr.write(`[vscode-task] ${msg}\n`);
|
|
69
|
+
}
|
|
70
|
+
|
|
58
71
|
// 1. sessions テーブルに INSERT OR IGNORE
|
|
59
72
|
db.prepare(
|
|
60
73
|
`INSERT OR IGNORE INTO sessions (session_id, project_path, status, created_at, updated_at)
|
package/src/token-monitor.mjs
CHANGED
|
@@ -587,7 +587,10 @@ export function main() {
|
|
|
587
587
|
setMeasuredColumns(cols);
|
|
588
588
|
const curr = resolveColumns();
|
|
589
589
|
if (prev !== curr) {
|
|
590
|
-
//
|
|
590
|
+
// 幅が変わると前フレームは別幅で wrap している可能性があり、CUU ベースの
|
|
591
|
+
// 部分再描画では消し残る。全画面クリアで確実にリセットしてから描き直す。
|
|
592
|
+
// greeting も消えるが、resize の瞬間だけの一時的コスト。
|
|
593
|
+
process.stdout.write(ANSI.clearScreen);
|
|
591
594
|
lastRenderedLines = 0;
|
|
592
595
|
resetRenderKeyCache();
|
|
593
596
|
safeRenderFrame(args);
|
|
@@ -612,6 +615,7 @@ export function main() {
|
|
|
612
615
|
const currCols = process.stdout.columns ?? 0;
|
|
613
616
|
if (shouldForceFullRedraw(lastColumns, currCols)) {
|
|
614
617
|
lastColumns = currCols;
|
|
618
|
+
process.stdout.write(ANSI.clearScreen);
|
|
615
619
|
lastRenderedLines = 0;
|
|
616
620
|
resetRenderKeyCache();
|
|
617
621
|
safeRenderFrame(args);
|
|
@@ -631,8 +635,9 @@ export function main() {
|
|
|
631
635
|
if (resizeTimer) clearTimeout(resizeTimer);
|
|
632
636
|
resizeTimer = setTimeout(() => {
|
|
633
637
|
resizeTimer = null;
|
|
634
|
-
//
|
|
638
|
+
// 既存描画が新しい幅では崩れている可能性があるため全画面クリアで描き直す
|
|
635
639
|
lastColumns = process.stdout.columns ?? 0;
|
|
640
|
+
process.stdout.write(ANSI.clearScreen);
|
|
636
641
|
lastRenderedLines = 0;
|
|
637
642
|
resetRenderKeyCache();
|
|
638
643
|
safeRenderFrame(args);
|