|
7 | 7 | // the launch args (the one lever that is NOT interactivity-gated). Edits |
8 | 8 | // nothing. |
9 | 9 | // 2026-07-07: cannot override the server-side experiment that blanks Opus |
10 | | -// 4.8 summaries (x-cc-atis header); see the README's 2026-07-07 update. |
| 10 | +// 4.8 summaries (x-cc-atis header); see the README's 2026-07-07 update. The |
| 11 | +// launcher can apply that update's mitigation - opt in with CC_ATIS_OPTOUT=1 |
| 12 | +// (OFF by default; see the section below and the README for its caveats). |
11 | 13 | // 2. Restores the always-visible context-usage icon in the VS Code chat input. |
12 | 14 | // Recent extension builds (2.1.165+) hide that icon until you have used |
13 | 15 | // >50% of the context window; with the 1M window that is ~500k tokens, so it |
|
50 | 52 | // set CC_WORKAROUNDS=0 master: disable every fix (default: 1) |
51 | 53 | // set CC_RECONCILE=0 do not touch the webview bundle (default: 1) |
52 | 54 | // set CC_SCRUB_ROUTING=1 force the default Anthropic account (default: 0) |
| 55 | +// set CC_ATIS_OPTOUT=1 purge cached x-cc-atis experiment assignment |
| 56 | +// + DISABLE_GROWTHBOOK=1 (default: 0) |
53 | 57 | // |
54 | 58 | // The real `claude` must be installed. This wrapper finds it automatically |
55 | 59 | // (native install `claude.exe` or npm `claude.cmd`); if it cannot, set the |
@@ -550,6 +554,86 @@ if (process.env.CC_SCRUB_ROUTING && process.env.CC_SCRUB_ROUTING !== "0") { |
550 | 554 | // >>> ccwa-local-env >>> |
551 | 555 | // <<< ccwa-local-env <<< |
552 | 556 |
|
| 557 | +// --- x-cc-atis experiment opt-out (OFF by default) --------------------------- |
| 558 | +// CC_ATIS_OPTOUT=1 applies the verified 2026-07-07 mitigation for the |
| 559 | +// server-side experiment that blanks Opus 4.8 thinking summaries (README |
| 560 | +// "2026-07-07 update"): purge any cached x-cc-atis experiment assignment from |
| 561 | +// the CLI config (%USERPROFILE%\.claude.json) and launch with |
| 562 | +// DISABLE_GROWTHBOOK=1 so the next remote feature refresh cannot re-enroll this |
| 563 | +// install. Both halves are required - the env var alone still sends the |
| 564 | +// already-cached token, and the purge alone lasts only until the next refresh |
| 565 | +// (both measured). |
| 566 | +// |
| 567 | +// OFF by default, unlike the other fixes, because it is not free: it edits the |
| 568 | +// CLI's own config file, and DISABLE_GROWTHBOOK=1 opts the install out of |
| 569 | +// Claude Code's client-side feature gating ENTIRELY, not just this experiment. |
| 570 | +// Enable it deliberately. |
| 571 | +// |
| 572 | +// Safety model matches the bundle patches: idempotent (no rewrite when nothing |
| 573 | +// is cached), one-time backup (.claude.json.bak-cc-workarounds, only if |
| 574 | +// absent), temp + rename write (a failed parse or write leaves the original |
| 575 | +// untouched), best-effort (never blocks the launch). |
| 576 | +function atisOptout() { |
| 577 | + try { |
| 578 | + if (process.env.CC_WORKAROUNDS === "0") return; |
| 579 | + if (!process.env.CC_ATIS_OPTOUT || process.env.CC_ATIS_OPTOUT === "0") return; |
| 580 | + process.env.DISABLE_GROWTHBOOK = "1"; |
| 581 | + const home = process.env.USERPROFILE || process.env.HOME || ""; |
| 582 | + if (!home) return; |
| 583 | + const cfg = path.join(home, ".claude.json"); |
| 584 | + if (!fs.existsSync(cfg)) return; |
| 585 | + let data; |
| 586 | + try { |
| 587 | + data = JSON.parse(fs.readFileSync(cfg, "utf8")); |
| 588 | + } catch (_) { |
| 589 | + return; // unreadable or malformed -> leave the file intact |
| 590 | + } |
| 591 | + if (!data || typeof data !== "object" || Array.isArray(data)) return; |
| 592 | + let changed = false; |
| 593 | + const slots = data.clientDataCacheSlots; |
| 594 | + if (slots && typeof slots === "object" && !Array.isArray(slots)) { |
| 595 | + for (const k of Object.keys(slots)) { |
| 596 | + const v = slots[k]; |
| 597 | + if (v && v.data && typeof v.data === "object" && v.data.atis != null) { |
| 598 | + delete slots[k]; |
| 599 | + changed = true; |
| 600 | + } |
| 601 | + } |
| 602 | + } |
| 603 | + if ( |
| 604 | + data.clientDataCache && |
| 605 | + typeof data.clientDataCache === "object" && |
| 606 | + "atis" in data.clientDataCache |
| 607 | + ) { |
| 608 | + delete data.clientDataCache.atis; |
| 609 | + changed = true; |
| 610 | + } |
| 611 | + if (!changed) return; // idempotent: nothing of the experiment's is cached |
| 612 | + const bak = cfg + ".bak-cc-workarounds"; |
| 613 | + if (!fs.existsSync(bak)) { |
| 614 | + try { |
| 615 | + fs.copyFileSync(cfg, bak); |
| 616 | + } catch (_) { |
| 617 | + /* best-effort backup */ |
| 618 | + } |
| 619 | + } |
| 620 | + const tmp = cfg + ".ccatis." + process.pid; |
| 621 | + try { |
| 622 | + fs.writeFileSync(tmp, JSON.stringify(data, null, 2) + "\n"); |
| 623 | + fs.renameSync(tmp, cfg); // atomic on the same volume |
| 624 | + } catch (_) { |
| 625 | + try { |
| 626 | + fs.unlinkSync(tmp); |
| 627 | + } catch (_) { |
| 628 | + /* nothing to clean up */ |
| 629 | + } |
| 630 | + } |
| 631 | + } catch (_) { |
| 632 | + /* never block the launch */ |
| 633 | + } |
| 634 | +} |
| 635 | +atisOptout(); |
| 636 | + |
553 | 637 | // --- Inject the thinking-display fix into the launch args ------------------- |
554 | 638 | // Fire on a real agent invocation. Surfaces signal a real run differently: |
555 | 639 | // - the VS Code extension passes "--max-thinking-tokens N" (N > 0) plus the |
|
0 commit comments