throughline 0.3.1 → 0.3.3

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 CHANGED
@@ -179,12 +179,56 @@ Example output (real values from a running 1M-context Opus session):
179
179
  before drawing, preserving ANSI color codes. The redraw cursor math cannot
180
180
  desync on narrow terminals.
181
181
 
182
- ### VS Code auto-start
183
-
184
- For contributors working on Throughline itself, a `.vscode/tasks.json` in this
185
- repo launches `throughline monitor` automatically in a dedicated terminal when
186
- you open the folder. Drop an equivalent config into your own project's
187
- `.vscode/tasks.json` to get the same behavior.
182
+ ### VS Code auto-start (automatic)
183
+
184
+ After `throughline install`, any VS Code / Cursor / VSCodium project you work in
185
+ gets `.vscode/tasks.json` provisioned automatically on the next assistant turn.
186
+ The file configures `runOn: folderOpen` so the monitor appears in a dedicated
187
+ terminal panel the next time you open that folder.
188
+
189
+ **How it works.** The Stop hook runs at the end of every assistant response.
190
+ Once per project it inspects `.vscode/tasks.json`:
191
+
192
+ - **No file yet** → creates one with a single `Throughline Monitor` task.
193
+ - **Plain JSON with other tasks** → appends the monitor task, preserves your
194
+ existing entries, `version`, and indentation.
195
+ - **JSONC (comments or trailing commas)** → does not touch the file. Prints a
196
+ one-time notice to stderr asking you to paste the snippet below.
197
+ - **Already contains a Throughline Monitor task** → does nothing (idempotent;
198
+ this is the common path on every subsequent turn).
199
+
200
+ The generated task uses `type: 'process'` with the absolute path to Node and
201
+ `bin/throughline.mjs` so Windows `.cmd` shims and missing PATH entries cannot
202
+ break it.
203
+
204
+ **Opt out:** set `THROUGHLINE_NO_VSCODE=1` in the environment used by Claude
205
+ Code. Delete `.vscode/tasks.json` (or just the monitor entry) if you want to
206
+ stop auto-start for a project that already has one.
207
+
208
+ **Manual snippet for JSONC tasks.json files.** If Throughline refused to edit
209
+ your `tasks.json` because it contains comments or trailing commas, add this
210
+ entry to the `tasks` array yourself:
211
+
212
+ ```jsonc
213
+ {
214
+ "label": "Throughline Monitor",
215
+ "type": "shell",
216
+ "command": "throughline monitor",
217
+ "isBackground": true,
218
+ "presentation": {
219
+ "reveal": "always",
220
+ "panel": "dedicated",
221
+ "group": "throughline",
222
+ "close": false,
223
+ "echo": false,
224
+ "focus": false,
225
+ "showReuseMessage": false,
226
+ "clear": true
227
+ },
228
+ "runOptions": { "runOn": "folderOpen" },
229
+ "problemMatcher": []
230
+ }
231
+ ```
188
232
 
189
233
  ---
190
234
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "throughline",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "description": "Claude Code hooks plugin for structured context compression (/clear-safe persistent memory)",
6
6
  "keywords": [
@@ -453,3 +453,17 @@ export const _internal = {
453
453
  needsRerender,
454
454
  resetRenderKeyCache,
455
455
  };
456
+
457
+ // --- エントリポイント自動起動 ---
458
+ // `node src/token-monitor.mjs` 直接起動(VSCode タスク .vscode/tasks.json が使うパターン)
459
+ // のとき main() を自動実行する。
460
+ // dispatcher 経由(`throughline monitor`)は bin/throughline.mjs が明示的に main() を呼ぶ。
461
+ // テスト import(`node --test src/token-monitor.test.mjs`)は argv[1] が `.test.mjs` で終わる。
462
+ // argv[1] が 'token-monitor.mjs' で終わって '.test.mjs' でないケースだけ auto-run する。
463
+ {
464
+ const argv1 = (process.argv[1] || '').replace(/\\/g, '/');
465
+ const isDirectEntry = argv1.endsWith('token-monitor.mjs') && !argv1.endsWith('.test.mjs');
466
+ if (isDirectEntry) {
467
+ main();
468
+ }
469
+ }