throughline 0.3.19 → 0.3.20
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 +15 -8
- package/package.json +1 -1
- package/src/token-monitor.mjs +2 -2
- package/src/token-monitor.test.mjs +2 -2
package/README.md
CHANGED
|
@@ -205,24 +205,31 @@ Example output (real values from a running 1M-context Opus session):
|
|
|
205
205
|
### VS Code auto-start (automatic)
|
|
206
206
|
|
|
207
207
|
After `throughline install`, any VS Code / Cursor / VSCodium project you work in
|
|
208
|
-
gets `.vscode/tasks.json` provisioned automatically on the
|
|
208
|
+
gets `.vscode/tasks.json` provisioned automatically on the first session event.
|
|
209
209
|
The file configures `runOn: folderOpen` so the monitor appears in a dedicated
|
|
210
210
|
terminal panel the next time you open that folder.
|
|
211
211
|
|
|
212
|
-
**How it works.**
|
|
212
|
+
**How it works.** `ensureMonitorTaskFile` is called from **all three hooks
|
|
213
|
+
(SessionStart, UserPromptSubmit, Stop)** as of v0.3.18. Whichever one fires
|
|
214
|
+
first in your environment creates the file; the rest are idempotent no-ops.
|
|
213
215
|
Once per project it inspects `.vscode/tasks.json`:
|
|
214
216
|
|
|
215
|
-
- **No file yet** → creates one with a single `Throughline Monitor` task
|
|
217
|
+
- **No file yet** → creates one with a single `Throughline Monitor` task, and
|
|
218
|
+
emits a one-time `<system-reminder>` to stdout so Claude tells you a
|
|
219
|
+
**Developer: Reload Window** is needed to activate the `folderOpen` task once
|
|
220
|
+
(v0.3.19+).
|
|
216
221
|
- **Plain JSON with other tasks** → appends the monitor task, preserves your
|
|
217
|
-
existing entries, `version`, and indentation.
|
|
222
|
+
existing entries, `version`, and indentation (same notice fires once).
|
|
218
223
|
- **JSONC (comments or trailing commas)** → does not touch the file. Prints a
|
|
219
224
|
one-time notice to stderr asking you to paste the snippet below.
|
|
220
225
|
- **Already contains a Throughline Monitor task** → does nothing (idempotent;
|
|
221
|
-
this is the common path on every subsequent turn).
|
|
226
|
+
this is the common path on every subsequent turn; notice is silent).
|
|
222
227
|
|
|
223
|
-
The generated task uses `type: '
|
|
224
|
-
`bin/throughline.mjs
|
|
225
|
-
|
|
228
|
+
The generated task uses `type: 'shell'` with the absolute path to Node and
|
|
229
|
+
`bin/throughline.mjs`. VS Code wraps shell tasks in a PTY (xterm.js) so the
|
|
230
|
+
monitor sees `isTTY=true`, real `columns`, and resize events. Windows `.cmd`
|
|
231
|
+
shims and missing PATH entries cannot break it because the command is already
|
|
232
|
+
an absolute Node binary path.
|
|
226
233
|
|
|
227
234
|
**Opt out:** set `THROUGHLINE_NO_VSCODE=1` in the environment used by Claude
|
|
228
235
|
Code. Delete `.vscode/tasks.json` (or just the monitor entry) if you want to
|
package/package.json
CHANGED
package/src/token-monitor.mjs
CHANGED
|
@@ -304,8 +304,8 @@ function formatLine({ state, usage, isActive, now = Date.now() }) {
|
|
|
304
304
|
// 90%超: !! + 強い文言 (赤)
|
|
305
305
|
// 70%超: ! + 弱い文言 (黄)
|
|
306
306
|
const warn =
|
|
307
|
-
ratio >= 0.9 ? color(ANSI.red + ANSI.bold, ' !! /
|
|
308
|
-
ratio >= 0.7 ? color(ANSI.yellow, ' ! そろそろ /
|
|
307
|
+
ratio >= 0.9 ? color(ANSI.red + ANSI.bold, ' !! /tl 強く推奨') :
|
|
308
|
+
ratio >= 0.7 ? color(ANSI.yellow, ' ! そろそろ /tl') :
|
|
309
309
|
'';
|
|
310
310
|
|
|
311
311
|
const marker = isActive ? color(ANSI.bold + ANSI.cyan, '▶') : ' ';
|
|
@@ -305,13 +305,13 @@ test('formatLine: 70% 未満は警告テキストなし', () => {
|
|
|
305
305
|
const out = stripColors(formatLine(makeLineArgs(0.5)));
|
|
306
306
|
assert.ok(!out.includes('!!'));
|
|
307
307
|
assert.ok(!out.includes('! '));
|
|
308
|
-
assert.ok(!out.includes('/
|
|
308
|
+
assert.ok(!out.includes('/tl'));
|
|
309
309
|
});
|
|
310
310
|
|
|
311
311
|
test('formatLine: 70% 以上で "!" マーカーと弱めの文言', () => {
|
|
312
312
|
const out = stripColors(formatLine(makeLineArgs(0.75)));
|
|
313
313
|
assert.ok(out.includes('!'), 'should include ! marker');
|
|
314
|
-
assert.ok(out.includes('そろそろ /
|
|
314
|
+
assert.ok(out.includes('そろそろ /tl'), 'should show soft warning');
|
|
315
315
|
assert.ok(!out.includes('!!'), 'should not include critical marker yet');
|
|
316
316
|
});
|
|
317
317
|
|