claude-token-saver 3.2.0 → 3.2.2

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.en.md CHANGED
@@ -251,6 +251,12 @@ Also update `statusLine.command` in `~/.claude/settings.json` to `claude-token-s
251
251
 
252
252
  ## Release notes
253
253
 
254
+ ### v3.2.2 (2026-07-13)
255
+ - **No re-proposing registered rules** — (tier|category|project) combinations that already have a model-fitting rule are excluded from scan candidates (a global rule covers every project). Fixes rules registered outside the promote flow (e.g. migrations) resurfacing as candidates.
256
+
257
+ ### v3.2.1 (2026-07-13)
258
+ - **Instant pattern analysis on first setup** — `install` (including npm postinstall) analyzes your existing session logs inline when no cache exists, so tier-delegation candidates appear from the very first Claude Code session (previously the second).
259
+
254
260
  ### v3.2.0 (2026-07-13)
255
261
  - **Tier classification (T0/T1/T2)** — route-scan grows from a binary easy/other split into three tiers. New signals: mutating tool calls and tool errors; output thresholds auto-calibrate to the user's own distribution (clamped); a dedicated category for pasted screen/log Q&A; conversational episodes (<100 output tokens) excluded. Design and research evidence in `docs/TIER_CRITERIA.md`.
256
262
  - **Model-fitting ratchet separated** — promoted delegation rules live in their own file (`.claude/ratchet-model.md` / `~/.claude/ratchet-model.md`), file-level-separated from hand-written rules, managed via `route-scan rules [rm <N>]`; the harness CLAUDE.md block references both files.
package/README.md CHANGED
@@ -208,6 +208,12 @@ npm uninstall -g claude-cache-monitor && npm i -g claude-token-saver
208
208
 
209
209
  ## 릴리스 노트
210
210
 
211
+ ### v3.2.2 (2026-07-13)
212
+ - **등록 룰 재제안 차단** — 이미 모델 피팅 룰이 있는 (티어|카테고리|프로젝트) 조합은 스캔 후보에서 자동 제외 (글로벌 룰은 전 프로젝트 커버). promote를 거치지 않고 등록된 룰(마이그레이션 등)이 후보로 되살아나던 문제 수정.
213
+
214
+ ### v3.2.1 (2026-07-13)
215
+ - **최초 설치 시 즉시 패턴 분석** — `install`(npm postinstall 포함)이 캐시가 없으면 기존 세션 로그를 그 자리에서 분석해, 첫 Claude Code 세션부터 티어 위임 후보가 표시됩니다 (기존에는 두 번째 세션부터).
216
+
211
217
  ### v3.2.0 (2026-07-13)
212
218
  - **티어 분류 (T0/T1/T2)** — route-scan이 이분법(easy/그외)에서 3티어로 진화. 신호에 변경성 도구 수·도구 에러 수 추가, 출력 임계값은 사용자 분포 기반 자동 보정(클램프 포함), 붙여넣은 화면·로그 질문 전용 카테고리 신설, 대화성 응답(출력 <100토큰) 제외. 기준 설계·리서치 근거는 `docs/TIER_CRITERIA.md`.
213
219
  - **모델 피팅 랫쳇 분리** — 승격된 위임 룰은 별도 파일(`.claude/ratchet-model.md` / `~/.claude/ratchet-model.md`)에 저장돼 사용자 룰과 파일 단위로 분리. `route-scan rules [rm <N>]`로 관리하며, 하네스 CLAUDE.md 블록이 두 파일을 함께 참조.
package/bin/cli.js CHANGED
@@ -412,6 +412,25 @@ async function main() {
412
412
  print('legacy /token-monitor', r.legacy);
413
413
  console.log(' (consolidated into the skill — same workflow, triggered by intent)');
414
414
  }
415
+ // First-time setup: analyze existing session logs right away so the
416
+ // very first session already sees delegation candidates — without this,
417
+ // the initial scan would only start from the first session's hook and
418
+ // its results would surface one session late. Runs inline (a few
419
+ // seconds on a typical 14-day history): a detached child can be reaped
420
+ // by sandboxed installers before it finishes, and postinstall carries
421
+ // `|| true` so a failure here never breaks the install.
422
+ {
423
+ const rs = await import('../src/route-scan.js');
424
+ if (!rs.readRouteScan()) {
425
+ try {
426
+ console.log('');
427
+ console.log(' route-scan: 기존 세션 로그의 사용 패턴을 분석하는 중...');
428
+ const cache = await rs.runRouteScan({ days: 14 });
429
+ console.log(` route-scan: 에피소드 ${cache.totalEpisodes}건 분석 완료 — 위임 후보 ${cache.candidates.length}건.`);
430
+ console.log(' (다음 Claude Code 세션에서 티어 위임 후보가 표시됩니다)');
431
+ } catch { /* hook-triggered scan covers it on first session instead */ }
432
+ }
433
+ }
415
434
  console.log('');
416
435
  console.log('Open Claude Code in any directory and just mention:');
417
436
  console.log(' "cache hit rate" / "1M context" / "5H cap" — the skill auto-activates.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-token-saver",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "description": "Save tokens on Claude Code — spike diagnosis, 1M-context detection, TTL countdown, statusline. (formerly claude-cache-monitor)",
5
5
  "type": "module",
6
6
  "bin": {
package/src/route-scan.js CHANGED
@@ -285,12 +285,25 @@ export async function runRouteScan({ days = 14 } = {}) {
285
285
  const prev = readRouteScan();
286
286
  const resolved = new Set(prev?.resolved || []);
287
287
 
288
+ // Never re-propose a pattern that already has a registered model-fitting
289
+ // rule (a global rule covers the category in every project). Without this,
290
+ // rules that entered the registry outside the promote flow — migrations,
291
+ // future imports — would resurface as candidates forever.
292
+ let registered = [];
293
+ try {
294
+ const { loadModelRules } = await import('./model-rules.js');
295
+ registered = loadModelRules().rules;
296
+ } catch { /* registry unreadable — candidates may repeat until promote */ }
297
+ const hasRule = (g) => registered.some((r) =>
298
+ r.tier === g.tier && r.category === g.category &&
299
+ (r.scope === 'global' || r.project === g.project));
300
+
288
301
  const ruleText = (g) => g.tier === 'T2'
289
302
  ? `"${g.label}" 유형의 단순 요청(예: "${g.example}")은 ${g.agent}(haiku) 서브에이전트로 위임한다`
290
303
  : `"${g.label}" 유형의 중간 난도 요청(예: "${g.example}")은 model: sonnet 서브에이전트로 위임한다 (설계 판단·반복 에러 발생 시 메인 모델이 이어받음)`;
291
304
 
292
305
  const candidates = [...groups.values()]
293
- .filter((g) => g.count >= MIN_RECURRENCE)
306
+ .filter((g) => g.count >= MIN_RECURRENCE && !hasRule(g))
294
307
  .sort((a, b) => b.count - a.count)
295
308
  .slice(0, 8)
296
309
  .map((g, i) => ({