claude-discover 1.10.11 → 1.10.13

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/out/main/main.js CHANGED
@@ -9,7 +9,7 @@ import { LAUNCH_MODES, launchMode } from "electron-update-from-npm/launch-mode";
9
9
  import fsp from "node:fs/promises";
10
10
  import { pathToFileURL } from "node:url";
11
11
  import { execFile } from "node:child_process";
12
- import { promisify } from "node:util";
12
+ import { promisify, stripVTControlCharacters } from "node:util";
13
13
  import windowStateKeeper from "electron-window-state";
14
14
  import process$1 from "node:process";
15
15
  import { FindOverlay } from "electron-find-overlay";
@@ -1037,6 +1037,14 @@ var SessionFile = class {
1037
1037
  return null;
1038
1038
  }
1039
1039
  }
1040
+ async agentMeta() {
1041
+ if (!this.parentSessionId) return null;
1042
+ try {
1043
+ return JSON.parse(await fsp.readFile(this.filePath.replace(/\.jsonl$/, ".meta.json"), "utf8"));
1044
+ } catch {
1045
+ return null;
1046
+ }
1047
+ }
1040
1048
  async stream(onLine) {
1041
1049
  let leftover = "";
1042
1050
  await new Promise((resolve) => {
@@ -1138,7 +1146,8 @@ var classifyRequest = (req, url) => {
1138
1146
  var isLoop = (kind) => !kind || [
1139
1147
  "main",
1140
1148
  "tools",
1141
- "agent"
1149
+ "agent",
1150
+ "compact"
1142
1151
  ].includes(kind[0]);
1143
1152
  var REMINDER_LABELS = [
1144
1153
  ["As you answer the user", "Session Context"],
@@ -1428,15 +1437,24 @@ var RequestFile = class {
1428
1437
  async readInstructions(range = null) {
1429
1438
  const parser = new RequestParser();
1430
1439
  const strips = [];
1440
+ const compacts = [];
1431
1441
  for (const rec of await this.read()) {
1432
1442
  if (!rec.request || rec.kind?.[0] === "count") continue;
1433
1443
  const found = parser.strips(rec);
1434
- if (!isLoop(rec.kind) && inRange(rec.timestamp, range)) strips.push(...found.map((f) => ({
1444
+ if (!inRange(rec.timestamp, range)) continue;
1445
+ if (rec.kind?.[0] === "compact" && rec.response?.usage) compacts.push({
1446
+ timestamp: rec.timestamp,
1447
+ usage: rec.response.usage
1448
+ });
1449
+ if (!isLoop(rec.kind)) strips.push(...found.map((f) => ({
1435
1450
  timestamp: rec.timestamp,
1436
1451
  ...f
1437
1452
  })));
1438
1453
  }
1439
- return strips;
1454
+ return {
1455
+ strips,
1456
+ compacts
1457
+ };
1440
1458
  }
1441
1459
  };
1442
1460
  // src/main/requests/TranscriptInstructions.js
@@ -1505,6 +1523,52 @@ var pickParts = (byModel, part) => Object.fromEntries(Object.entries(byModel).ma
1505
1523
  function addUsage(target, delta) {
1506
1524
  for (const k of TOKEN_FIELDS) target[k] += delta[k];
1507
1525
  }
1526
+ function usageOf(u) {
1527
+ const cc = u.cache_creation || {};
1528
+ return {
1529
+ input: u.input_tokens || 0,
1530
+ output: u.output_tokens || 0,
1531
+ cacheRead: u.cache_read_input_tokens || 0,
1532
+ cacheCreation: u.cache_creation_input_tokens || 0,
1533
+ cacheCreation5m: cc.ephemeral_5m_input_tokens || 0,
1534
+ cacheCreation1h: cc.ephemeral_1h_input_tokens || 0
1535
+ };
1536
+ }
1537
+ var CACHE_TTL_MS = {
1538
+ "5m": 3e5,
1539
+ "1h": 36e5
1540
+ };
1541
+ var writeTtl = (u) => u.cacheCreation1h ? CACHE_TTL_MS["1h"] : u.cacheCreation ? CACHE_TTL_MS["5m"] : null;
1542
+ function promptCosts(calls, pricing) {
1543
+ const costs = {
1544
+ "5m": 0,
1545
+ "1h": 0
1546
+ };
1547
+ const prevByModel = /* @__PURE__ */ new Map();
1548
+ let ttl = writeTtl(calls.find((c) => c.usage.cacheCreation)?.usage ?? {}) ?? CACHE_TTL_MS["5m"];
1549
+ for (const { ts, model, fast, usage: u } of calls) {
1550
+ const price = (bucket) => pricing.costForDelta(model, bucket, { fast }) || 0;
1551
+ const prefix = u.cacheRead + u.cacheCreation;
1552
+ const prev = prevByModel.get(model);
1553
+ const gap = prev ? ts - prev.ts : Infinity;
1554
+ for (const [policy, ms] of Object.entries(CACHE_TTL_MS)) {
1555
+ const warm = gap <= ms;
1556
+ const read = warm === gap <= ttl ? u.cacheRead : !warm ? 0 : prefix >= prev.prefix ? Math.max(u.cacheRead, prev.prefix) : u.cacheRead;
1557
+ costs[policy] += price({
1558
+ input: u.input,
1559
+ cacheRead: read,
1560
+ cacheCreation: prefix - read,
1561
+ [`cacheCreation${policy}`]: prefix - read
1562
+ });
1563
+ }
1564
+ ttl = writeTtl(u) ?? ttl;
1565
+ prevByModel.set(model, {
1566
+ ts,
1567
+ prefix
1568
+ });
1569
+ }
1570
+ return costs;
1571
+ }
1508
1572
  function extractText(content) {
1509
1573
  if (typeof content === "string") return content;
1510
1574
  if (!Array.isArray(content)) return "";
@@ -1570,6 +1634,7 @@ function freshMetrics() {
1570
1634
  tokensByModel: {},
1571
1635
  tokensByModelFast: {},
1572
1636
  lastContextTokens: 0,
1637
+ contextCompacted: false,
1573
1638
  serverToolUse: {
1574
1639
  webSearch: 0,
1575
1640
  webFetch: 0
@@ -1601,6 +1666,7 @@ var SessionParser = class {
1601
1666
  this.seenUuids = /* @__PURE__ */ new Set();
1602
1667
  this.typedCommands = /* @__PURE__ */ new Map();
1603
1668
  this.appliedById = /* @__PURE__ */ new Map();
1669
+ this.calls = [];
1604
1670
  this.branchStarted = false;
1605
1671
  }
1606
1672
  feed(obj) {
@@ -1632,6 +1698,8 @@ var SessionParser = class {
1632
1698
  if (this.range && (ts < this.range.start || ts > this.range.end)) {
1633
1699
  if (inherited != null && ts < this.range.start && ts > meta.continuesFrom) meta.continuesFrom = ts;
1634
1700
  if (inherited != null && ts > this.range.end && (meta.continuesTo == null || ts < meta.continuesTo)) meta.continuesTo = ts;
1701
+ const msg = obj.message;
1702
+ if (ts < this.range.start && msg?.usage && msg.id) this._growth(msg.id, usageOf(msg.usage));
1635
1703
  return false;
1636
1704
  }
1637
1705
  obj._ts = ts;
@@ -1646,6 +1714,10 @@ var SessionParser = class {
1646
1714
  }
1647
1715
  this.seenUuids.add(obj.uuid);
1648
1716
  }
1717
+ if (obj.subtype === "compact_boundary" && obj.compactMetadata?.postTokens) {
1718
+ meta.lastContextTokens = obj.compactMetadata.postTokens;
1719
+ meta.contextCompacted = true;
1720
+ }
1649
1721
  if (t === "attachment") {
1650
1722
  obj.isMeta = true;
1651
1723
  return true;
@@ -1686,6 +1758,7 @@ var SessionParser = class {
1686
1758
  Object.assign(this.meta, freshMetrics());
1687
1759
  this.lastSeenTs = null;
1688
1760
  this.appliedById.clear();
1761
+ this.calls = [];
1689
1762
  }
1690
1763
  _feedUser(obj) {
1691
1764
  const meta = this.meta;
@@ -1724,15 +1797,7 @@ var SessionParser = class {
1724
1797
  const u = msg?.usage;
1725
1798
  const msgId = msg?.id;
1726
1799
  if (!u || !msgId) return;
1727
- const cc = u.cache_creation || {};
1728
- const usage = {
1729
- input: u.input_tokens || 0,
1730
- output: u.output_tokens || 0,
1731
- cacheRead: u.cache_read_input_tokens || 0,
1732
- cacheCreation: u.cache_creation_input_tokens || 0,
1733
- cacheCreation5m: cc.ephemeral_5m_input_tokens || 0,
1734
- cacheCreation1h: cc.ephemeral_1h_input_tokens || 0
1735
- };
1800
+ const usage = usageOf(u);
1736
1801
  const model = msg.model || "unknown";
1737
1802
  const fast = u.speed === "fast";
1738
1803
  const contextSize = usage.input + usage.cacheRead + usage.cacheCreation;
@@ -1741,9 +1806,16 @@ var SessionParser = class {
1741
1806
  this._stampRunningTotals(obj, contextSize, usage.output);
1742
1807
  }
1743
1808
  if (this.excludeIds?.has(msgId)) return;
1744
- const applied = this.appliedById.get(msgId);
1745
- if (!applied) {
1809
+ if (!this.appliedById.has(msgId)) {
1810
+ const sentAt = this.prevMessage?.type === "user" ? Math.min(this.prevMessage._ts, obj._ts) : obj._ts;
1811
+ this.calls.push({
1812
+ ts: sentAt,
1813
+ model,
1814
+ fast,
1815
+ usage
1816
+ });
1746
1817
  meta.lastContextTokens = contextSize;
1818
+ meta.contextCompacted = false;
1747
1819
  if (u.service_tier) meta.serviceTier = u.service_tier;
1748
1820
  if (this.pricing && this.pricing.priceFor(model) == null) meta.priceUnknown = true;
1749
1821
  if (fast) {
@@ -1755,15 +1827,8 @@ var SessionParser = class {
1755
1827
  meta.serverToolUse.webFetch += u.server_tool_use.web_fetch_requests || 0;
1756
1828
  }
1757
1829
  }
1758
- const growth = emptyBucket();
1759
- let changed = false;
1760
- for (const k of TOKEN_FIELDS) {
1761
- growth[k] = Math.max(0, usage[k] - (applied?.[k] ?? 0));
1762
- if (growth[k] !== 0) changed = true;
1763
- }
1764
- if (applied) addUsage(applied, growth);
1765
- else this.appliedById.set(msgId, usage);
1766
- if (!changed) return;
1830
+ const growth = this._growth(msgId, usage);
1831
+ if (TOKEN_FIELDS.every((k) => !growth[k])) return;
1767
1832
  const byModel = fast ? meta.tokensByModelFast : meta.tokensByModel;
1768
1833
  addUsage(meta.tokens, growth);
1769
1834
  addUsage(byModel[model] ??= emptyBucket(), growth);
@@ -1779,10 +1844,24 @@ var SessionParser = class {
1779
1844
  });
1780
1845
  }
1781
1846
  }
1847
+ _growth(msgId, usage) {
1848
+ const applied = this.appliedById.get(msgId);
1849
+ if (!applied) {
1850
+ this.appliedById.set(msgId, usage);
1851
+ return usage;
1852
+ }
1853
+ const growth = Object.fromEntries(TOKEN_FIELDS.map((k) => [k, Math.max(0, usage[k] - applied[k])]));
1854
+ addUsage(applied, growth);
1855
+ return growth;
1856
+ }
1782
1857
  finalize(mtimeFallback) {
1783
1858
  const meta = this.meta;
1784
1859
  if (meta.startedAt == null) meta.startedAt = mtimeFallback;
1785
1860
  if (meta.lastActivityAt == null) meta.lastActivityAt = mtimeFallback;
1861
+ if (!meta.models.length && this.modelId) {
1862
+ meta.model = this.modelId;
1863
+ meta.models.push(this.modelId);
1864
+ }
1786
1865
  meta.source = classifySource(meta);
1787
1866
  meta.activeMs = meta.activityPeriods.reduce((sum, p) => sum + Math.max(0, p.end - p.start), 0);
1788
1867
  const t = meta.tokens;
@@ -1795,7 +1874,8 @@ var SessionParser = class {
1795
1874
  }) || 0);
1796
1875
  meta.cost = costOf({});
1797
1876
  meta.costByType = Object.fromEntries(Object.entries(COST_PARTS).map(([type, part]) => [type, costOf({}, part)]));
1798
- meta.savings = { using5mCache: meta.cost - costOf({ ignoreCache1hPremium: true }) };
1877
+ const prompt = this.pricing ? promptCosts(this.calls, this.pricing) : null;
1878
+ meta.cacheCosts = prompt && Object.fromEntries(Object.entries(prompt).map(([p, c]) => [p, meta.costByType.output + c]));
1799
1879
  return meta;
1800
1880
  }
1801
1881
  };
@@ -2342,11 +2422,11 @@ var Pricing = class extends EventEmitter {
2342
2422
  fastMultiplier(model) {
2343
2423
  return this.priceFor(model)?.fastModeMplr ?? null;
2344
2424
  }
2345
- costForDelta(model, bucket, { ignoreCache1hPremium = false, fast = false } = {}) {
2425
+ costForDelta(model, bucket, { fast = false } = {}) {
2346
2426
  const p = this.priceFor(model);
2347
2427
  if (!p || !bucket) return null;
2348
- const tokens5m = ignoreCache1hPremium ? 0 : bucket.cacheCreation5m || 0;
2349
- const tokens1h = ignoreCache1hPremium ? 0 : bucket.cacheCreation1h || 0;
2428
+ const tokens5m = bucket.cacheCreation5m || 0;
2429
+ const tokens1h = bucket.cacheCreation1h || 0;
2350
2430
  const tokensUnknown = (bucket.cacheCreation || 0) - tokens5m - tokens1h;
2351
2431
  const base = ((bucket.input || 0) * p.input + (bucket.output || 0) * p.output + (bucket.cacheRead || 0) * p.cacheRead + tokens5m * p.cacheWrite + tokens1h * (p.cacheWrite1h ?? p.cacheWrite) + tokensUnknown * p.cacheWrite) / MILLION;
2352
2432
  return fast ? base * (this.fastMultiplier(model) ?? 1) : base;
@@ -2477,7 +2557,10 @@ var SessionsService = class extends EventEmitter {
2477
2557
  await reader.stream((obj) => {
2478
2558
  if (feed(obj, parser.feed(obj))) items.push(obj);
2479
2559
  });
2480
- const side = [...await sides, ...source.side.filter((s) => inRange(s.timestamp, range))];
2560
+ const own = await sides;
2561
+ const shown = (list) => list.filter((s) => inRange(s.timestamp, range));
2562
+ const side = [...own.strips, ...shown(source.side)];
2563
+ const compacts = [...shown(source.compacts), ...own.compacts];
2481
2564
  if (start?.length && !loop.includes(start[0])) loop.unshift(...start);
2482
2565
  items.sort((a, b) => a._ts - b._ts);
2483
2566
  const keys = new Set(loop.map((s) => s.hash));
@@ -2489,7 +2572,8 @@ var SessionsService = class extends EventEmitter {
2489
2572
  items,
2490
2573
  instructions: {
2491
2574
  loop,
2492
- side
2575
+ side,
2576
+ compacts
2493
2577
  },
2494
2578
  requestLog: await requests.exists() ? requests.filePath : null
2495
2579
  };
@@ -2497,7 +2581,8 @@ var SessionsService = class extends EventEmitter {
2497
2581
  #branchSource({ filePath, forkedFrom, forkedAt }) {
2498
2582
  if (!forkedFrom) return {
2499
2583
  records: [],
2500
- side: []
2584
+ side: [],
2585
+ compacts: []
2501
2586
  };
2502
2587
  const key = `${filePath} ${forkedAt}`;
2503
2588
  if (this.#branch?.key !== key) this.#branch = {
@@ -2508,7 +2593,7 @@ var SessionsService = class extends EventEmitter {
2508
2593
  }
2509
2594
  async #readBranchSource(filePath, sessionId, at) {
2510
2595
  const records = [];
2511
- const [side] = await Promise.all([new RequestFile(sessionId).readInstructions({
2596
+ const [{ strips: side, compacts }] = await Promise.all([new RequestFile(sessionId).readInstructions({
2512
2597
  start: 0,
2513
2598
  end: at
2514
2599
  }), new SessionFile(path.join(path.dirname(filePath), `${sessionId}.jsonl`)).stream((obj) => {
@@ -2516,7 +2601,8 @@ var SessionsService = class extends EventEmitter {
2516
2601
  })]);
2517
2602
  return {
2518
2603
  records: records.slice(0, records.findLastIndex((o) => o.type === "api-request" && Date.parse(o.timestamp) <= at) + 1),
2519
- side
2604
+ side,
2605
+ compacts
2520
2606
  };
2521
2607
  }
2522
2608
  async readRequests(filePath, date = null, granularity = "day") {
@@ -2612,7 +2698,13 @@ var SessionsService = class extends EventEmitter {
2612
2698
  });
2613
2699
  await reader.stream((obj) => parser.feed(obj));
2614
2700
  const meta = parser.finalize(stat.mtimeMs);
2615
- const [project, avatar] = await Promise.all([this.projects.resolve(meta.project), this.projects.avatar(meta.project)]);
2701
+ const [project, avatar, agent] = await Promise.all([
2702
+ this.projects.resolve(meta.project),
2703
+ this.projects.avatar(meta.project),
2704
+ reader.agentMeta()
2705
+ ]);
2706
+ meta.agentName ??= agent?.name ?? agent?.agentType ?? null;
2707
+ meta.agentDescription = agent?.description ?? null;
2616
2708
  return Object.assign(meta, project, { avatar });
2617
2709
  }
2618
2710
  async _dedupSessions(metas, range) {
@@ -2828,7 +2920,10 @@ var AgentRunner = class {
2828
2920
  settingSources: []
2829
2921
  }
2830
2922
  });
2831
- return withTimeout(q.usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET({ skipBehaviors: true }), USAGE_TIMEOUT, () => q.close());
2923
+ return withTimeout(Promise.all([q.usage_EXPERIMENTAL_MAY_CHANGE_DO_NOT_RELY_ON_THIS_API_YET({ skipBehaviors: true }), q.accountInfo()]).then(([usage, account]) => ({
2924
+ ...usage,
2925
+ account
2926
+ })), USAGE_TIMEOUT, () => q.close());
2832
2927
  }
2833
2928
  };
2834
2929
  // node_modules/isexe/dist/commonjs/index.min.js
@@ -3482,10 +3577,10 @@ var RateLimits = class {
3482
3577
  }
3483
3578
  async #fetch() {
3484
3579
  try {
3485
- const { subscription_type: plan, rate_limits: rl } = await this.#agentRunner.usage();
3580
+ const { subscription_type: type, account, rate_limits: rl } = await this.#agentRunner.usage();
3486
3581
  return rl && {
3487
3582
  at: Date.now(),
3488
- plan,
3583
+ plan: account?.subscriptionType?.replace(/^Claude /, "") ?? type,
3489
3584
  fiveHour: toWindow(rl.five_hour),
3490
3585
  sevenDay: toWindow(rl.seven_day),
3491
3586
  models: (rl.model_scoped ?? []).filter((m) => m.utilization != null).map((m) => ({
@@ -3506,9 +3601,13 @@ var RateLimits = class {
3506
3601
  };
3507
3602
  // node_modules/ansi-styles/index.js
3508
3603
  var ANSI_BACKGROUND_OFFSET = 10;
3509
- var wrapAnsi16 = (offset = 0) => (code) => `\u001B[${code + offset}m`;
3510
- var wrapAnsi256 = (offset = 0) => (code) => `\u001B[${38 + offset};5;${code}m`;
3511
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
3604
+ var ANSI_UNDERLINE_OFFSET = 20;
3605
+ var wrapAnsi16 = (offset = 0) => (code) => `\u{1B}[${code + offset}m`;
3606
+ var wrapAnsi256 = (offset = 0) => (code) => `\u{1B}[${38 + offset};5;${code}m`;
3607
+ var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u{1B}[${38 + offset};2;${red};${green};${blue}m`;
3608
+ var wrapUnderlineAnsi = (code) => `\u{1B}[58;5;${code < 90 ? code - 30 : code - 90 + 8}m`;
3609
+ var blackBright = [90, 39];
3610
+ var bgBlackBright = [100, 49];
3512
3611
  var styles = {
3513
3612
  modifier: {
3514
3613
  reset: [0, 0],
@@ -3516,6 +3615,10 @@ var styles = {
3516
3615
  dim: [2, 22],
3517
3616
  italic: [3, 23],
3518
3617
  underline: [4, 24],
3618
+ underlineDouble: ["4:2", 24],
3619
+ underlineCurly: ["4:3", 24],
3620
+ underlineDotted: ["4:4", 24],
3621
+ underlineDashed: ["4:5", 24],
3519
3622
  overline: [53, 55],
3520
3623
  inverse: [7, 27],
3521
3624
  hidden: [8, 28],
@@ -3530,9 +3633,9 @@ var styles = {
3530
3633
  magenta: [35, 39],
3531
3634
  cyan: [36, 39],
3532
3635
  white: [37, 39],
3533
- blackBright: [90, 39],
3534
- gray: [90, 39],
3535
- grey: [90, 39],
3636
+ blackBright,
3637
+ gray: blackBright,
3638
+ grey: blackBright,
3536
3639
  redBright: [91, 39],
3537
3640
  greenBright: [92, 39],
3538
3641
  yellowBright: [93, 39],
@@ -3550,9 +3653,9 @@ var styles = {
3550
3653
  bgMagenta: [45, 49],
3551
3654
  bgCyan: [46, 49],
3552
3655
  bgWhite: [47, 49],
3553
- bgBlackBright: [100, 49],
3554
- bgGray: [100, 49],
3555
- bgGrey: [100, 49],
3656
+ bgBlackBright,
3657
+ bgGray: bgBlackBright,
3658
+ bgGrey: bgBlackBright,
3556
3659
  bgRedBright: [101, 49],
3557
3660
  bgGreenBright: [102, 49],
3558
3661
  bgYellowBright: [103, 49],
@@ -3560,22 +3663,43 @@ var styles = {
3560
3663
  bgMagentaBright: [105, 49],
3561
3664
  bgCyanBright: [106, 49],
3562
3665
  bgWhiteBright: [107, 49]
3666
+ },
3667
+ underlineColor: {
3668
+ underlineBlack: ["58;5;0", 59],
3669
+ underlineRed: ["58;5;1", 59],
3670
+ underlineGreen: ["58;5;2", 59],
3671
+ underlineYellow: ["58;5;3", 59],
3672
+ underlineBlue: ["58;5;4", 59],
3673
+ underlineMagenta: ["58;5;5", 59],
3674
+ underlineCyan: ["58;5;6", 59],
3675
+ underlineWhite: ["58;5;7", 59],
3676
+ underlineBlackBright: ["58;5;8", 59],
3677
+ underlineGray: ["58;5;8", 59],
3678
+ underlineGrey: ["58;5;8", 59],
3679
+ underlineRedBright: ["58;5;9", 59],
3680
+ underlineGreenBright: ["58;5;10", 59],
3681
+ underlineYellowBright: ["58;5;11", 59],
3682
+ underlineBlueBright: ["58;5;12", 59],
3683
+ underlineMagentaBright: ["58;5;13", 59],
3684
+ underlineCyanBright: ["58;5;14", 59],
3685
+ underlineWhiteBright: ["58;5;15", 59]
3563
3686
  }
3564
3687
  };
3565
3688
  Object.keys(styles.modifier);
3566
3689
  var foregroundColorNames = Object.keys(styles.color);
3567
3690
  var backgroundColorNames = Object.keys(styles.bgColor);
3691
+ Object.keys(styles.underlineColor);
3568
3692
  [...foregroundColorNames, ...backgroundColorNames];
3569
3693
  function assembleStyles() {
3570
3694
  const codes = /* @__PURE__ */ new Map();
3571
3695
  for (const [groupName, group] of Object.entries(styles)) {
3572
3696
  for (const [styleName, style] of Object.entries(group)) {
3573
3697
  styles[styleName] = {
3574
- open: `\u001B[${style[0]}m`,
3575
- close: `\u001B[${style[1]}m`
3698
+ open: `\u{1B}[${style[0]}m`,
3699
+ close: `\u{1B}[${style[1]}m`
3576
3700
  };
3577
3701
  group[styleName] = styles[styleName];
3578
- codes.set(style[0], style[1]);
3702
+ codes.set(Number(String(style[0]).split(/[:;]/v, 1)[0]), style[1]);
3579
3703
  }
3580
3704
  Object.defineProperty(styles, groupName, {
3581
3705
  value: group,
@@ -3588,12 +3712,16 @@ function assembleStyles() {
3588
3712
  });
3589
3713
  styles.color.close = "\x1B[39m";
3590
3714
  styles.bgColor.close = "\x1B[49m";
3715
+ styles.underlineColor.close = "\x1B[59m";
3591
3716
  styles.color.ansi = wrapAnsi16();
3592
3717
  styles.color.ansi256 = wrapAnsi256();
3593
3718
  styles.color.ansi16m = wrapAnsi16m();
3594
3719
  styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
3595
3720
  styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
3596
3721
  styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
3722
+ styles.underlineColor.ansi = wrapUnderlineAnsi;
3723
+ styles.underlineColor.ansi256 = wrapAnsi256(ANSI_UNDERLINE_OFFSET);
3724
+ styles.underlineColor.ansi16m = wrapAnsi16m(ANSI_UNDERLINE_OFFSET);
3597
3725
  Object.defineProperties(styles, {
3598
3726
  rgbToAnsi256: {
3599
3727
  value(red, green, blue) {
@@ -3608,7 +3736,7 @@ function assembleStyles() {
3608
3736
  },
3609
3737
  hexToRgb: {
3610
3738
  value(hex) {
3611
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
3739
+ const matches = /[\da-f]{6}|[\da-f]{3}/iv.exec(hex.toString(16));
3612
3740
  if (!matches) return [
3613
3741
  0,
3614
3742
  0,
@@ -3667,6 +3795,21 @@ function assembleStyles() {
3667
3795
  return styles;
3668
3796
  }
3669
3797
  var ansiStyles = assembleStyles();
3798
+ // node_modules/ansi-regex/index.js
3799
+ function ansiRegex({ onlyFirst = false } = {}) {
3800
+ const ST = String.raw`(?:\u0007|\u001B\u005C|\u009C)`;
3801
+ const osc = String.raw`(?:(?:\u001B\]|\u009D)[^\u0007\u001B\u009C\u009D]*${ST})`;
3802
+ const csi = String.raw`[\u001B\u009B][[\]()#;?]*(?:\d{1,4}(?:[;:]\d{0,4})*)?[A-PR-TZcf-nq-uy=><~]`;
3803
+ const pattern = `${osc}|${String.raw`(?:\u001B\[|\u009B)[<=>][0-9;:]*[A-PR-TZcf-nq-uy~]`}|${csi}`;
3804
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
3805
+ }
3806
+ // node_modules/strip-ansi/index.js
3807
+ var regex = ansiRegex();
3808
+ function stripAnsi(string) {
3809
+ if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
3810
+ if (!string.includes("\x1B") && !string.includes("›")) return string;
3811
+ return string.replace(regex, "");
3812
+ }
3670
3813
  var ambiguousRanges = [
3671
3814
  161,
3672
3815
  161,
@@ -4346,10 +4489,111 @@ function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
4346
4489
  if (isFullwidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) return 2;
4347
4490
  return 1;
4348
4491
  }
4349
- // node_modules/is-fullwidth-code-point/index.js
4350
- function isFullwidthCodePoint(codePoint) {
4351
- if (!Number.isInteger(codePoint)) return false;
4352
- return isFullwidth(codePoint) || isWide(codePoint);
4492
+ // node_modules/string-width/index.js
4493
+ /**
4494
+ Logic:
4495
+ - Segment graphemes to match how terminals render clusters.
4496
+ - Width rules:
4497
+ 1. Skip non-printing clusters (Default_Ignorable, Control, pure nonspacing/enclosing Mark, lone Surrogates). Tabs are ignored by design.
4498
+ 2. RGI emoji clusters (\p{RGI_Emoji}) are double-width.
4499
+ 3. Minimally-qualified/unqualified emoji clusters (ZWJ sequences with 2+ Extended_Pictographic, or keycap sequences) are double-width.
4500
+ 4. Hangul jamo collapse each standard modern Hangul L+V or L+V+T syllable piece to width 2.
4501
+ Unmatched repeated leading/vowel/trailing jamo stay additive because that matches how the terminals we target render them.
4502
+ 5. Otherwise use East Asian Width of the cluster's first visible code point, and add widths for trailing spacing marks and Halfwidth/Fullwidth Forms within the same cluster (e.g., dakuten/handakuten/prolonged sound mark).
4503
+ */
4504
+ var segmenter = new Intl.Segmenter();
4505
+ var visibleCharacterRegex = /[^\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]/v;
4506
+ var spacingMarkRegex = /\p{Spacing_Mark}/v;
4507
+ var rgiEmojiRegex = /^\p{RGI_Emoji}$/v;
4508
+ var unqualifiedKeycapRegex = /^[\d#*]\u20E3$/;
4509
+ var extendedPictographicRegex = /\p{Extended_Pictographic}/gu;
4510
+ function isDoubleWidthNonRgiEmojiSequence(segment) {
4511
+ if (segment.length > 50) return false;
4512
+ if (unqualifiedKeycapRegex.test(segment)) return true;
4513
+ if (segment.includes("‍")) {
4514
+ const pictographics = segment.match(extendedPictographicRegex);
4515
+ return pictographics !== null && pictographics.length >= 2;
4516
+ }
4517
+ return false;
4518
+ }
4519
+ function baseVisible(segment) {
4520
+ const index = segment.search(visibleCharacterRegex);
4521
+ return index === -1 ? void 0 : segment.slice(index);
4522
+ }
4523
+ function isHangulLeadingJamo(codePoint) {
4524
+ return codePoint >= 4352 && codePoint <= 4447 || codePoint >= 43360 && codePoint <= 43388;
4525
+ }
4526
+ function isHangulVowelJamo(codePoint) {
4527
+ return codePoint >= 4448 && codePoint <= 4519 || codePoint >= 55216 && codePoint <= 55238;
4528
+ }
4529
+ function isHangulTrailingJamo(codePoint) {
4530
+ return codePoint >= 4520 && codePoint <= 4607 || codePoint >= 55243 && codePoint <= 55291;
4531
+ }
4532
+ function isHangulJamo(codePoint) {
4533
+ return isHangulLeadingJamo(codePoint) || isHangulVowelJamo(codePoint) || isHangulTrailingJamo(codePoint);
4534
+ }
4535
+ function hangulClusterWidth(visibleSegment, eastAsianWidthOptions) {
4536
+ const codePoints = [];
4537
+ for (const character of visibleSegment) {
4538
+ if (!visibleCharacterRegex.test(character)) continue;
4539
+ codePoints.push(character.codePointAt(0));
4540
+ }
4541
+ if (codePoints.length === 0) return;
4542
+ let width = 0;
4543
+ for (let index = 0; index < codePoints.length; index++) {
4544
+ const codePoint = codePoints[index];
4545
+ if (!isHangulJamo(codePoint)) {
4546
+ if (width === 0) return;
4547
+ for (let remaining = index; remaining < codePoints.length; remaining++) width += eastAsianWidth(codePoints[remaining], eastAsianWidthOptions);
4548
+ return width;
4549
+ }
4550
+ if (isHangulLeadingJamo(codePoint) && isHangulVowelJamo(codePoints[index + 1])) {
4551
+ width += 2;
4552
+ index += isHangulTrailingJamo(codePoints[index + 2]) ? 2 : 1;
4553
+ continue;
4554
+ }
4555
+ width += eastAsianWidth(codePoint, eastAsianWidthOptions);
4556
+ }
4557
+ return width;
4558
+ }
4559
+ function trailingWidth(visibleSegment, eastAsianWidthOptions) {
4560
+ let extra = 0;
4561
+ let first = true;
4562
+ for (const character of visibleSegment) {
4563
+ if (first) {
4564
+ first = false;
4565
+ continue;
4566
+ }
4567
+ if (spacingMarkRegex.test(character) || character >= "＀" && character <= "￯") extra += eastAsianWidth(character.codePointAt(0), eastAsianWidthOptions);
4568
+ }
4569
+ return extra;
4570
+ }
4571
+ function stringWidth(input, options = {}) {
4572
+ if (typeof input !== "string" || input.length === 0) return 0;
4573
+ const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
4574
+ let string = input;
4575
+ if (!countAnsiEscapeCodes && (string.includes("\x1B") || string.includes("›"))) string = stripAnsi(string);
4576
+ if (string.length === 0) return 0;
4577
+ if (/^[\u0020-\u007E]*$/.test(string)) return string.length;
4578
+ let width = 0;
4579
+ const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
4580
+ for (const { segment } of segmenter.segment(string)) {
4581
+ const visibleSegment = baseVisible(segment);
4582
+ if (visibleSegment === void 0) continue;
4583
+ if (rgiEmojiRegex.test(segment) || isDoubleWidthNonRgiEmojiSequence(segment)) {
4584
+ width += 2;
4585
+ continue;
4586
+ }
4587
+ const hangulWidth = hangulClusterWidth(visibleSegment, eastAsianWidthOptions);
4588
+ if (hangulWidth !== void 0) {
4589
+ width += hangulWidth;
4590
+ continue;
4591
+ }
4592
+ const codePoint = visibleSegment.codePointAt(0);
4593
+ width += eastAsianWidth(codePoint, eastAsianWidthOptions);
4594
+ width += trailingWidth(visibleSegment, eastAsianWidthOptions);
4595
+ }
4596
+ return width;
4353
4597
  }
4354
4598
  // node_modules/slice-ansi/tokenize-ansi.js
4355
4599
  var ESCAPE_CODE_POINT = 27;
@@ -4397,8 +4641,6 @@ var CODE_POINT_CSI_INTERMEDIATE_START = " ".codePointAt(0);
4397
4641
  var CODE_POINT_CSI_INTERMEDIATE_END = "/".codePointAt(0);
4398
4642
  var CODE_POINT_CSI_FINAL_START = "@".codePointAt(0);
4399
4643
  var CODE_POINT_CSI_FINAL_END = "~".codePointAt(0);
4400
- var REGIONAL_INDICATOR_SYMBOL_LETTER_A = 127462;
4401
- var REGIONAL_INDICATOR_SYMBOL_LETTER_Z = 127487;
4402
4644
  var SGR_RESET_CODE = 0;
4403
4645
  var SGR_EXTENDED_FOREGROUND_CODE = 38;
4404
4646
  var SGR_DEFAULT_FOREGROUND_CODE = 39;
@@ -4410,9 +4652,6 @@ var SGR_ANSI_256_FRAGMENT_LENGTH = 3;
4410
4652
  var SGR_TRUECOLOR_FRAGMENT_LENGTH = 5;
4411
4653
  var SGR_ANSI_256_LAST_PARAMETER_OFFSET = 2;
4412
4654
  var SGR_TRUECOLOR_LAST_PARAMETER_OFFSET = 4;
4413
- var VARIATION_SELECTOR_16_CODE_POINT = 65039;
4414
- var COMBINING_ENCLOSING_KEYCAP_CODE_POINT = 8419;
4415
- var EMOJI_PRESENTATION_GRAPHEME_REGEX = /\p{Emoji_Presentation}/v;
4416
4655
  var GRAPHEME_SEGMENTER = new Intl.Segmenter(void 0, { granularity: "grapheme" });
4417
4656
  var endCodeNumbers = /* @__PURE__ */ new Set();
4418
4657
  for (const [, end] of ansiStyles.codes) endCodeNumbers.add(end);
@@ -4428,9 +4667,6 @@ function isCsiIntermediateCharacter(codePoint) {
4428
4667
  function isCsiFinalCharacter(codePoint) {
4429
4668
  return codePoint >= CODE_POINT_CSI_FINAL_START && codePoint <= CODE_POINT_CSI_FINAL_END;
4430
4669
  }
4431
- function isRegionalIndicatorCodePoint(codePoint) {
4432
- return codePoint >= REGIONAL_INDICATOR_SYMBOL_LETTER_A && codePoint <= REGIONAL_INDICATOR_SYMBOL_LETTER_Z;
4433
- }
4434
4670
  function createControlParseResult(code, endIndex) {
4435
4671
  return {
4436
4672
  token: {
@@ -4440,28 +4676,8 @@ function createControlParseResult(code, endIndex) {
4440
4676
  endIndex
4441
4677
  };
4442
4678
  }
4443
- function isEmojiStyleGrapheme(grapheme) {
4444
- if (EMOJI_PRESENTATION_GRAPHEME_REGEX.test(grapheme)) return true;
4445
- for (const character of grapheme) {
4446
- const codePoint = character.codePointAt(0);
4447
- if (codePoint === VARIATION_SELECTOR_16_CODE_POINT || codePoint === COMBINING_ENCLOSING_KEYCAP_CODE_POINT) return true;
4448
- }
4449
- return false;
4450
- }
4451
- function getGraphemeWidth(grapheme) {
4452
- let regionalIndicatorCount = 0;
4453
- for (const character of grapheme) {
4454
- const codePoint = character.codePointAt(0);
4455
- if (isFullwidthCodePoint(codePoint)) return 2;
4456
- if (isRegionalIndicatorCodePoint(codePoint)) regionalIndicatorCount++;
4457
- }
4458
- if (regionalIndicatorCount >= 1) return 2;
4459
- if (isEmojiStyleGrapheme(grapheme)) return 2;
4460
- return 1;
4461
- }
4462
4679
  function getSgrPrefix(code) {
4463
- if (code.startsWith("›")) return "›";
4464
- return `${ESCAPE}${ANSI_CSI}`;
4680
+ return code.startsWith("›") ? "›" : `${ESCAPE}${ANSI_CSI}`;
4465
4681
  }
4466
4682
  function createSgrCode(prefix, values) {
4467
4683
  return `${prefix}${values.join(";")}${ANSI_SGR_TERMINATOR}`;
@@ -4560,7 +4776,7 @@ function parseCsiCode(string, index) {
4560
4776
  const codePoint = string.codePointAt(sequenceIndex);
4561
4777
  if (isCsiFinalCharacter(codePoint)) {
4562
4778
  const code = string.slice(index, sequenceIndex + 1);
4563
- if (string[sequenceIndex] !== ANSI_SGR_TERMINATOR || !hasCanonicalSgrParameters) return createControlParseResult(code, sequenceIndex + 1);
4779
+ if (!hasCanonicalSgrParameters || string[sequenceIndex] !== ANSI_SGR_TERMINATOR) return createControlParseResult(code, sequenceIndex + 1);
4564
4780
  return {
4565
4781
  token: {
4566
4782
  type: "sgr",
@@ -4634,13 +4850,13 @@ function parseHyperlinkCode(string, index) {
4634
4850
  function parseControlStringCode(string, index) {
4635
4851
  const codePoint = string.codePointAt(index);
4636
4852
  let sequenceStartIndex;
4637
- let supportsBellTerminator = false;
4853
+ let isBellTerminatorSupported = false;
4638
4854
  switch (codePoint) {
4639
4855
  case ESCAPE_CODE_POINT:
4640
4856
  switch (string[index + 1]) {
4641
4857
  case ANSI_OSC:
4642
4858
  sequenceStartIndex = index + 2;
4643
- supportsBellTerminator = true;
4859
+ isBellTerminatorSupported = true;
4644
4860
  break;
4645
4861
  case ANSI_DCS:
4646
4862
  case ANSI_SOS:
@@ -4654,7 +4870,7 @@ function parseControlStringCode(string, index) {
4654
4870
  break;
4655
4871
  case C1_OSC_CODE_POINT:
4656
4872
  sequenceStartIndex = index + 1;
4657
- supportsBellTerminator = true;
4873
+ isBellTerminatorSupported = true;
4658
4874
  break;
4659
4875
  case C1_DCS_CODE_POINT:
4660
4876
  case C1_SOS_CODE_POINT:
@@ -4666,7 +4882,7 @@ function parseControlStringCode(string, index) {
4666
4882
  default: return;
4667
4883
  }
4668
4884
  for (let sequenceIndex = sequenceStartIndex; sequenceIndex < string.length; sequenceIndex++) {
4669
- if (supportsBellTerminator && string[sequenceIndex] === ANSI_BELL) return createControlParseResult(string.slice(index, sequenceIndex + 1), sequenceIndex + 1);
4885
+ if (isBellTerminatorSupported && string[sequenceIndex] === ANSI_BELL) return createControlParseResult(string.slice(index, sequenceIndex + 1), sequenceIndex + 1);
4670
4886
  if (string[sequenceIndex] === ESCAPE && string[sequenceIndex + 1] === ANSI_OSC_TERMINATOR) return createControlParseResult(string.slice(index, sequenceIndex + 2), sequenceIndex + 2);
4671
4887
  if (string[sequenceIndex] === C1_STRING_TERMINATOR) return createControlParseResult(string.slice(index, sequenceIndex + 1), sequenceIndex + 1);
4672
4888
  }
@@ -4678,9 +4894,7 @@ function parseAnsiCode(string, index) {
4678
4894
  const hyperlinkCode = parseHyperlinkCode(string, index);
4679
4895
  if (hyperlinkCode) return hyperlinkCode;
4680
4896
  }
4681
- const controlStringCode = parseControlStringCode(string, index);
4682
- if (controlStringCode) return controlStringCode;
4683
- return parseCsiCode(string, index);
4897
+ return parseControlStringCode(string, index) || parseCsiCode(string, index);
4684
4898
  }
4685
4899
  function appendTrailingAnsiTokens(string, index, tokens) {
4686
4900
  while (index < string.length) {
@@ -4700,7 +4914,7 @@ function parseCharacterTokenWithRawSegmentation(string, index, graphemeSegments)
4700
4914
  token: {
4701
4915
  type: "character",
4702
4916
  value: segment.segment,
4703
- visibleWidth: getGraphemeWidth(segment.segment),
4917
+ visibleWidth: stringWidth(segment.segment),
4704
4918
  isGraphemeContinuation: false
4705
4919
  },
4706
4920
  endIndex: index + segment.segment.length
@@ -4743,7 +4957,7 @@ function applyGraphemeMetadata(visibleCharacters) {
4743
4957
  let graphemeIndex = scalarIndex;
4744
4958
  let isFirstInGrapheme = true;
4745
4959
  while (graphemeIndex < visibleCharacters.length && scalarOffsets[graphemeIndex] < segment.index + segment.segment.length) {
4746
- visibleCharacters[graphemeIndex].visibleWidth = isFirstInGrapheme ? getGraphemeWidth(segment.segment) : 0;
4960
+ visibleCharacters[graphemeIndex].visibleWidth = isFirstInGrapheme ? stringWidth(segment.segment) : 0;
4747
4961
  visibleCharacters[graphemeIndex].isGraphemeContinuation = !isFirstInGrapheme;
4748
4962
  isFirstInGrapheme = false;
4749
4963
  graphemeIndex++;
@@ -4751,7 +4965,7 @@ function applyGraphemeMetadata(visibleCharacters) {
4751
4965
  scalarIndex = graphemeIndex;
4752
4966
  }
4753
4967
  }
4754
- function tokenizeAnsiWithVisibleSegmentation(string, { endCharacter = Number.POSITIVE_INFINITY } = {}) {
4968
+ function tokenizeAnsiWithVisibleSegmentation(string, { endCharacter = Infinity } = {}) {
4755
4969
  const tokens = [];
4756
4970
  const visibleCharacters = collectVisibleCharacters(string);
4757
4971
  applyGraphemeMetadata(visibleCharacters);
@@ -4770,24 +4984,21 @@ function tokenizeAnsiWithVisibleSegmentation(string, { endCharacter = Number.POS
4770
4984
  }
4771
4985
  const value = String.fromCodePoint(codePoint);
4772
4986
  const visibleCharacter = visibleCharacters[visibleCharacterIndex];
4773
- let visibleWidth = isFullwidthCodePoint(codePoint) ? 2 : value.length;
4774
- if (visibleCharacter) visibleWidth = visibleCharacter.visibleWidth;
4775
4987
  const token = {
4776
4988
  type: "character",
4777
4989
  value,
4778
- visibleWidth,
4779
- isGraphemeContinuation: visibleCharacter ? visibleCharacter.isGraphemeContinuation : false
4990
+ visibleWidth: visibleCharacter.visibleWidth,
4991
+ isGraphemeContinuation: visibleCharacter.isGraphemeContinuation
4780
4992
  };
4781
4993
  tokens.push(token);
4782
4994
  index += value.length;
4783
4995
  visibleCharacterIndex++;
4784
4996
  visibleCount += token.visibleWidth;
4785
- if (visibleCount >= endCharacter) {
4786
- const nextVisibleCharacter = visibleCharacters[visibleCharacterIndex];
4787
- if (!nextVisibleCharacter || !nextVisibleCharacter.isGraphemeContinuation) {
4788
- index = appendTrailingAnsiTokens(string, index, tokens);
4789
- break;
4790
- }
4997
+ if (visibleCount < endCharacter) continue;
4998
+ const nextVisibleCharacter = visibleCharacters[visibleCharacterIndex];
4999
+ if (!nextVisibleCharacter || !nextVisibleCharacter.isGraphemeContinuation) {
5000
+ index = appendTrailingAnsiTokens(string, index, tokens);
5001
+ break;
4791
5002
  }
4792
5003
  }
4793
5004
  return tokens;
@@ -4817,12 +5028,11 @@ function hasAnsiSplitContinuationAhead(string, startIndex, previousVisibleValue,
4817
5028
  }
4818
5029
  if (!hasAnsiCode) return false;
4819
5030
  const characterToken = parseCharacterTokenWithRawSegmentation(string, index, graphemeSegments);
4820
- if (!characterToken) return true;
4821
- return areValuesInSameGrapheme(previousVisibleValue, characterToken.token.value);
5031
+ return characterToken ? areValuesInSameGrapheme(previousVisibleValue, characterToken.token.value) : true;
4822
5032
  }
4823
5033
  return false;
4824
5034
  }
4825
- function tokenizeAnsi(string, { endCharacter = Number.POSITIVE_INFINITY } = {}) {
5035
+ function tokenizeAnsi(string, { endCharacter = Infinity } = {}) {
4826
5036
  const tokens = [];
4827
5037
  const graphemeSegments = GRAPHEME_SEGMENTER.segment(string);
4828
5038
  let index = 0;
@@ -4958,22 +5168,22 @@ function applyCharacterToken(state) {
4958
5168
  }
4959
5169
  state.position += state.token.visibleWidth;
4960
5170
  }
4961
- var tokenHandlers = {
4962
- sgr: applySgrToken,
4963
- hyperlink: applyHyperlinkToken,
4964
- control: applyControlToken,
4965
- character: applyCharacterToken
4966
- };
5171
+ var tokenHandlers = /* @__PURE__ */ new Map([
5172
+ ["sgr", applySgrToken],
5173
+ ["hyperlink", applyHyperlinkToken],
5174
+ ["control", applyControlToken],
5175
+ ["character", applyCharacterToken]
5176
+ ]);
4967
5177
  function applyToken(state) {
4968
- tokenHandlers[state.token.type]?.(state);
5178
+ tokenHandlers.get(state.token.type)?.(state);
4969
5179
  }
4970
5180
  function createHasContinuationAheadMap(tokens) {
4971
5181
  const hasContinuationAhead = Array.from({ length: tokens.length }, () => false);
4972
- let nextCharacterIsContinuation = false;
5182
+ let isNextCharacterContinuation = false;
4973
5183
  for (let tokenIndex = tokens.length - 1; tokenIndex >= 0; tokenIndex--) {
4974
5184
  const token = tokens[tokenIndex];
4975
- hasContinuationAhead[tokenIndex] = nextCharacterIsContinuation;
4976
- if (token.type === "character") nextCharacterIsContinuation = Boolean(token.isGraphemeContinuation);
5185
+ hasContinuationAhead[tokenIndex] = isNextCharacterContinuation;
5186
+ if (token.type === "character") isNextCharacterContinuation = Boolean(token.isGraphemeContinuation);
4977
5187
  }
4978
5188
  return hasContinuationAhead;
4979
5189
  }
@@ -5021,138 +5231,33 @@ function sliceAnsi(string, start, end) {
5021
5231
  state.returnValue += undoAnsiCodes(state.activeStyles);
5022
5232
  return state.returnValue;
5023
5233
  }
5024
- // node_modules/ansi-regex/index.js
5025
- function ansiRegex({ onlyFirst = false } = {}) {
5026
- return new RegExp(`(?:(?:\\u001B\\]|\\u009D)[^\\u0007\\u001B\\u009C\\u009D]*(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`, onlyFirst ? void 0 : "g");
5027
- }
5028
- // node_modules/strip-ansi/index.js
5029
- var regex = ansiRegex();
5030
- function stripAnsi(string) {
5031
- if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
5032
- if (!string.includes("\x1B") && !string.includes("›")) return string;
5033
- return string.replace(regex, "");
5034
- }
5035
- // node_modules/string-width/index.js
5036
- /**
5037
- Logic:
5038
- - Segment graphemes to match how terminals render clusters.
5039
- - Width rules:
5040
- 1. Skip non-printing clusters (Default_Ignorable, Control, pure nonspacing/enclosing Mark, lone Surrogates). Tabs are ignored by design.
5041
- 2. RGI emoji clusters (\p{RGI_Emoji}) are double-width.
5042
- 3. Minimally-qualified/unqualified emoji clusters (ZWJ sequences with 2+ Extended_Pictographic, or keycap sequences) are double-width.
5043
- 4. Hangul jamo collapse each standard modern Hangul L+V or L+V+T syllable piece to width 2.
5044
- Unmatched repeated leading/vowel/trailing jamo stay additive because that matches how the terminals we target render them.
5045
- 5. Otherwise use East Asian Width of the cluster's first visible code point, and add widths for trailing spacing marks and Halfwidth/Fullwidth Forms within the same cluster (e.g., dakuten/handakuten/prolonged sound mark).
5046
- */
5047
- var segmenter = new Intl.Segmenter();
5048
- var visibleCharacterRegex = /[^\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]/v;
5049
- var spacingMarkRegex = /\p{Spacing_Mark}/v;
5050
- var rgiEmojiRegex = /^\p{RGI_Emoji}$/v;
5051
- var unqualifiedKeycapRegex = /^[\d#*]\u20E3$/;
5052
- var extendedPictographicRegex = /\p{Extended_Pictographic}/gu;
5053
- function isDoubleWidthNonRgiEmojiSequence(segment) {
5054
- if (segment.length > 50) return false;
5055
- if (unqualifiedKeycapRegex.test(segment)) return true;
5056
- if (segment.includes("‍")) {
5057
- const pictographics = segment.match(extendedPictographicRegex);
5058
- return pictographics !== null && pictographics.length >= 2;
5059
- }
5060
- return false;
5061
- }
5062
- function baseVisible(segment) {
5063
- const index = segment.search(visibleCharacterRegex);
5064
- return index === -1 ? void 0 : segment.slice(index);
5065
- }
5066
- function isHangulLeadingJamo(codePoint) {
5067
- return codePoint >= 4352 && codePoint <= 4447 || codePoint >= 43360 && codePoint <= 43388;
5068
- }
5069
- function isHangulVowelJamo(codePoint) {
5070
- return codePoint >= 4448 && codePoint <= 4519 || codePoint >= 55216 && codePoint <= 55238;
5071
- }
5072
- function isHangulTrailingJamo(codePoint) {
5073
- return codePoint >= 4520 && codePoint <= 4607 || codePoint >= 55243 && codePoint <= 55291;
5074
- }
5075
- function isHangulJamo(codePoint) {
5076
- return isHangulLeadingJamo(codePoint) || isHangulVowelJamo(codePoint) || isHangulTrailingJamo(codePoint);
5077
- }
5078
- function hangulClusterWidth(visibleSegment, eastAsianWidthOptions) {
5079
- const codePoints = [];
5080
- for (const character of visibleSegment) {
5081
- if (!visibleCharacterRegex.test(character)) continue;
5082
- codePoints.push(character.codePointAt(0));
5083
- }
5084
- if (codePoints.length === 0) return;
5085
- let width = 0;
5086
- for (let index = 0; index < codePoints.length; index++) {
5087
- const codePoint = codePoints[index];
5088
- if (!isHangulJamo(codePoint)) {
5089
- if (width === 0) return;
5090
- for (let remaining = index; remaining < codePoints.length; remaining++) width += eastAsianWidth(codePoints[remaining], eastAsianWidthOptions);
5091
- return width;
5092
- }
5093
- if (isHangulLeadingJamo(codePoint) && isHangulVowelJamo(codePoints[index + 1])) {
5094
- width += 2;
5095
- index += isHangulTrailingJamo(codePoints[index + 2]) ? 2 : 1;
5096
- continue;
5097
- }
5098
- width += eastAsianWidth(codePoint, eastAsianWidthOptions);
5099
- }
5100
- return width;
5101
- }
5102
- function trailingWidth(visibleSegment, eastAsianWidthOptions) {
5103
- let extra = 0;
5104
- let first = true;
5105
- for (const character of visibleSegment) {
5106
- if (first) {
5107
- first = false;
5108
- continue;
5109
- }
5110
- if (spacingMarkRegex.test(character) || character >= "＀" && character <= "￯") extra += eastAsianWidth(character.codePointAt(0), eastAsianWidthOptions);
5111
- }
5112
- return extra;
5113
- }
5114
- function stringWidth(input, options = {}) {
5115
- if (typeof input !== "string" || input.length === 0) return 0;
5116
- const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
5117
- let string = input;
5118
- if (!countAnsiEscapeCodes && (string.includes("\x1B") || string.includes("›"))) string = stripAnsi(string);
5119
- if (string.length === 0) return 0;
5120
- if (/^[\u0020-\u007E]*$/.test(string)) return string.length;
5121
- let width = 0;
5122
- const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
5123
- for (const { segment } of segmenter.segment(string)) {
5124
- const visibleSegment = baseVisible(segment);
5125
- if (visibleSegment === void 0) continue;
5126
- if (rgiEmojiRegex.test(segment) || isDoubleWidthNonRgiEmojiSequence(segment)) {
5127
- width += 2;
5128
- continue;
5129
- }
5130
- const hangulWidth = hangulClusterWidth(visibleSegment, eastAsianWidthOptions);
5131
- if (hangulWidth !== void 0) {
5132
- width += hangulWidth;
5133
- continue;
5134
- }
5135
- const codePoint = visibleSegment.codePointAt(0);
5136
- width += eastAsianWidth(codePoint, eastAsianWidthOptions);
5137
- width += trailingWidth(visibleSegment, eastAsianWidthOptions);
5138
- }
5139
- return width;
5140
- }
5141
5234
  // node_modules/cli-truncate/index.js
5142
5235
  var validPositions = /* @__PURE__ */ new Set([
5143
5236
  "start",
5144
5237
  "middle",
5145
5238
  "end"
5146
5239
  ]);
5147
- function getIndexOfNearestSpace(string, wantedIndex, shouldSearchRight) {
5148
- if (string.charAt(wantedIndex) === " ") return wantedIndex;
5240
+ function getVisibleColumns(text) {
5241
+ const visibleColumns = [];
5242
+ for (const { segment } of new Intl.Segmenter().segment(stripVTControlCharacters(text))) {
5243
+ const width = stringWidth(segment);
5244
+ for (let column = 0; column < width; column++) visibleColumns.push(column === 0 ? segment : "");
5245
+ }
5246
+ return visibleColumns;
5247
+ }
5248
+ function getIndexOfNearestSpace(visibleColumns, wantedIndex, shouldSearchRight) {
5249
+ if (visibleColumns[wantedIndex] === " ") return wantedIndex;
5149
5250
  const direction = shouldSearchRight ? 1 : -1;
5150
5251
  for (let index = 0; index <= 3; index++) {
5151
5252
  const finalIndex = wantedIndex + index * direction;
5152
- if (string.charAt(finalIndex) === " ") return finalIndex;
5253
+ if (visibleColumns[finalIndex] === " ") return finalIndex;
5153
5254
  }
5154
5255
  return wantedIndex;
5155
5256
  }
5257
+ function getIndexAfterSpaces(visibleColumns, index) {
5258
+ while (visibleColumns[index] === " ") index++;
5259
+ return index;
5260
+ }
5156
5261
  function validateInput(text, columns, position, truncationCharacter) {
5157
5262
  if (typeof text !== "string") throw new TypeError(`Expected \`input\` to be a string, got ${typeof text}`);
5158
5263
  if (typeof columns !== "number") throw new TypeError(`Expected \`columns\` to be a number, got ${typeof columns}`);
@@ -5168,6 +5273,7 @@ function cliTruncate(text, columns, options = {}) {
5168
5273
  const length = stringWidth(text);
5169
5274
  if (length <= columns) return text;
5170
5275
  if (columns === 1) return truncationCharacter;
5276
+ const visibleColumns = preferTruncationOnSpace ? getVisibleColumns(text) : void 0;
5171
5277
  const ANSI = {
5172
5278
  ESC: 27,
5173
5279
  LEFT_BRACKET: 91,
@@ -5202,17 +5308,15 @@ function cliTruncate(text, columns, options = {}) {
5202
5308
  }
5203
5309
  function appendWithInheritedStyleFromEnd(visible, suffix) {
5204
5310
  const start = trailingSgrSpanStartIndex(visible);
5205
- if (start === visible.length) return visible + suffix;
5206
- return visible.slice(0, start) + suffix + visible.slice(start);
5311
+ return start === visible.length ? visible + suffix : visible.slice(0, start) + suffix + visible.slice(start);
5207
5312
  }
5208
5313
  function prependWithInheritedStyleFromStart(prefix, visible) {
5209
5314
  const end = leadingSgrSpanEndIndex(visible);
5210
- if (end === 0) return prefix + visible;
5211
- return visible.slice(0, end) + prefix + visible.slice(end);
5315
+ return end === 0 ? prefix + visible : visible.slice(0, end) + prefix + visible.slice(end);
5212
5316
  }
5213
5317
  if (position === "start") {
5214
5318
  if (preferTruncationOnSpace) {
5215
- const right = sliceAnsi(text, getIndexOfNearestSpace(text, length - columns + stringWidth(truncationCharacter), true), length).trim();
5319
+ const right = sliceAnsi(text, getIndexAfterSpaces(visibleColumns, getIndexOfNearestSpace(visibleColumns, length - columns + stringWidth(truncationCharacter), true)), length);
5216
5320
  return prependWithInheritedStyleFromStart(truncationCharacter, right);
5217
5321
  }
5218
5322
  if (space) truncationCharacter += " ";
@@ -5227,17 +5331,15 @@ function cliTruncate(text, columns, options = {}) {
5227
5331
  const truncationWidth = stringWidth(truncationCharacter);
5228
5332
  const half = Math.min(Math.floor(columns / 2), Math.max(0, columns - truncationWidth));
5229
5333
  if (preferTruncationOnSpace) {
5230
- const spaceNearFirstBreakPoint = getIndexOfNearestSpace(text, half);
5231
- const spaceNearSecondBreakPoint = getIndexOfNearestSpace(text, length - (columns - half) + truncationWidth, true);
5232
- return sliceAnsi(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi(text, spaceNearSecondBreakPoint, length).trim();
5334
+ const spaceNearFirstBreakPoint = getIndexOfNearestSpace(visibleColumns, half);
5335
+ const spaceNearSecondBreakPoint = getIndexOfNearestSpace(visibleColumns, length - (columns - half) + truncationWidth, true);
5336
+ return sliceAnsi(text, 0, spaceNearFirstBreakPoint) + truncationCharacter + sliceAnsi(text, getIndexAfterSpaces(visibleColumns, spaceNearSecondBreakPoint), length);
5233
5337
  }
5234
5338
  return sliceAnsi(text, 0, half) + truncationCharacter + sliceAnsi(text, length - (columns - half) + truncationWidth, length);
5235
5339
  }
5236
- if (position === "end") {
5237
- if (preferTruncationOnSpace) return appendWithInheritedStyleFromEnd(sliceAnsi(text, 0, getIndexOfNearestSpace(text, columns - stringWidth(truncationCharacter))), truncationCharacter);
5238
- if (space) truncationCharacter = ` ${truncationCharacter}`;
5239
- return appendWithInheritedStyleFromEnd(sliceAnsi(text, 0, columns - stringWidth(truncationCharacter)), truncationCharacter);
5240
- }
5340
+ if (preferTruncationOnSpace) return appendWithInheritedStyleFromEnd(sliceAnsi(text, 0, getIndexOfNearestSpace(visibleColumns, columns - stringWidth(truncationCharacter))), truncationCharacter);
5341
+ if (space) truncationCharacter = ` ${truncationCharacter}`;
5342
+ return appendWithInheritedStyleFromEnd(sliceAnsi(text, 0, columns - stringWidth(truncationCharacter)), truncationCharacter);
5241
5343
  }
5242
5344
  Object.freeze([
5243
5345
  "",
@@ -5264,7 +5366,7 @@ function assertSafeFilename(filename) {
5264
5366
  if (typeof filename !== "string") throw new TypeError("Expected a string");
5265
5367
  if (!isSafeFilename(filename)) throw new Error(`Unsafe filename: ${JSON.stringify(filename)}`);
5266
5368
  }
5267
- // node_modules/path-exists/index.js
5369
+ // node_modules/unused-filename/node_modules/path-exists/index.js
5268
5370
  function pathExistsSync(path) {
5269
5371
  try {
5270
5372
  fs.accessSync(path);
@@ -13675,7 +13777,7 @@ var MainWindow = class {
13675
13777
  // src/main/updater.js
13676
13778
  var updater = new NpmUpdater({
13677
13779
  name: "claude-discover",
13678
- version: "1.10.11",
13780
+ version: "1.10.13",
13679
13781
  bin: { "claude-discover": "bin/claude-discover.mjs" }
13680
13782
  }, { dev: false });
13681
13783
  // src/main/Application.js