modelstat 0.0.43 → 0.0.44

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/dist/cli.mjs CHANGED
@@ -4550,6 +4550,8 @@ function sourceEventId(deviceId, sourceOrFilePath, byteOffsetMaybe) {
4550
4550
  key = `fs::${sourceOrFilePath}::${byteOffset}`;
4551
4551
  } else if ("file" in sourceOrFilePath) {
4552
4552
  key = `fs::${sourceOrFilePath.file}::${sourceOrFilePath.byteOffset}`;
4553
+ } else if ("lineUuid" in sourceOrFilePath) {
4554
+ key = `uuid::${sourceOrFilePath.lineUuid}`;
4553
4555
  } else {
4554
4556
  key = `web::${sourceOrFilePath.host}::${sourceOrFilePath.conversationId}::${sourceOrFilePath.messageId}`;
4555
4557
  }
@@ -4682,8 +4684,9 @@ var init_src = __esm({
4682
4684
 
4683
4685
  // ../../packages/parsers/src/claude-code/index.ts
4684
4686
  import { createHash } from "crypto";
4685
- import { createReadStream } from "fs";
4687
+ import { createReadStream, existsSync as existsSync2, readdirSync } from "fs";
4686
4688
  import { stat } from "fs/promises";
4689
+ import { dirname as dirname2, join } from "path";
4687
4690
  import { createInterface } from "readline";
4688
4691
  function extractExcerpt(content) {
4689
4692
  if (!content) return void 0;
@@ -4722,6 +4725,37 @@ async function parseClaudeCodeJsonl(ctx) {
4722
4725
  let cwd = null;
4723
4726
  let gitBranch = null;
4724
4727
  let lastModel = null;
4728
+ const filenameSessionId = deriveSessionIdFromFilename(ctx.sourceFile);
4729
+ const ancestorExistsCache = /* @__PURE__ */ new Map();
4730
+ function ancestorFileExists(sid) {
4731
+ const cached2 = ancestorExistsCache.get(sid);
4732
+ if (cached2 !== void 0) return cached2;
4733
+ let found = false;
4734
+ const dir = dirname2(ctx.sourceFile);
4735
+ try {
4736
+ if (existsSync2(join(dir, `${sid}.jsonl`))) {
4737
+ found = true;
4738
+ } else {
4739
+ const root = dirname2(dir);
4740
+ for (const entry of readdirSync(root, { withFileTypes: true })) {
4741
+ if (!entry.isDirectory()) continue;
4742
+ if (existsSync2(join(root, entry.name, `${sid}.jsonl`))) {
4743
+ found = true;
4744
+ break;
4745
+ }
4746
+ }
4747
+ }
4748
+ } catch {
4749
+ }
4750
+ ancestorExistsCache.set(sid, found);
4751
+ return found;
4752
+ }
4753
+ function dedupeIdFor(lineUuid, byteOffset) {
4754
+ const isResumeCopy = filenameSessionId !== null && sessionId !== filenameSessionId;
4755
+ if (!isResumeCopy) return sourceEventId(ctx.deviceId, ctx.sourceFile, byteOffset);
4756
+ if (ancestorFileExists(sessionId)) return null;
4757
+ return sourceEventId(ctx.deviceId, { lineUuid });
4758
+ }
4725
4759
  for await (const line of rl) {
4726
4760
  const byteLen = Buffer.byteLength(line, "utf8") + 1;
4727
4761
  const offsetAtLineStart = startOffset + bytePos;
@@ -4758,10 +4792,15 @@ async function parseClaudeCodeJsonl(ctx) {
4758
4792
  skipped += 1;
4759
4793
  continue;
4760
4794
  }
4795
+ const eventId = dedupeIdFor(a.uuid, offsetAtLineStart);
4796
+ if (eventId === null) {
4797
+ skipped += 1;
4798
+ continue;
4799
+ }
4761
4800
  const slug = guessRepoSlugFromPath(cwd);
4762
4801
  const excerpt = extractExcerpt(a.message?.content);
4763
4802
  events.push({
4764
- source_event_id: sourceEventId(ctx.deviceId, ctx.sourceFile, offsetAtLineStart),
4803
+ source_event_id: eventId,
4765
4804
  ts: a.timestamp,
4766
4805
  kind: "assistant_message",
4767
4806
  tool: "claude_code",
@@ -4803,9 +4842,14 @@ async function parseClaudeCodeJsonl(ctx) {
4803
4842
  skipped += 1;
4804
4843
  continue;
4805
4844
  }
4845
+ const eventId = dedupeIdFor(u.uuid, offsetAtLineStart);
4846
+ if (eventId === null) {
4847
+ skipped += 1;
4848
+ continue;
4849
+ }
4806
4850
  const excerpt = extractExcerpt(u.message?.content);
4807
4851
  events.push({
4808
- source_event_id: sourceEventId(ctx.deviceId, ctx.sourceFile, offsetAtLineStart),
4852
+ source_event_id: eventId,
4809
4853
  ts: u.timestamp,
4810
4854
  kind: "user_message",
4811
4855
  tool: "claude_code",
@@ -4835,6 +4879,10 @@ async function parseClaudeCodeJsonl(ctx) {
4835
4879
  sourceFile: ctx.sourceFile
4836
4880
  };
4837
4881
  }
4882
+ function deriveSessionIdFromFilename(path5) {
4883
+ const m = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/.exec(path5);
4884
+ return m ? m[1] ?? null : null;
4885
+ }
4838
4886
  async function quickChecksum(path5) {
4839
4887
  const st = await stat(path5);
4840
4888
  const stream = createReadStream(path5, {
@@ -7155,9 +7203,9 @@ var init_cursor = __esm({
7155
7203
 
7156
7204
  // ../../packages/parsers/src/discovery/index.ts
7157
7205
  import { execFile as execFile2, execSync } from "child_process";
7158
- import { existsSync as existsSync2, statSync } from "fs";
7206
+ import { existsSync as existsSync3, statSync } from "fs";
7159
7207
  import { homedir, platform } from "os";
7160
- import { join, resolve as resolve2 } from "path";
7208
+ import { join as join2, resolve as resolve2 } from "path";
7161
7209
  import { promisify as promisify2 } from "util";
7162
7210
  async function discover(options = {}) {
7163
7211
  const os2 = platform() === "darwin" ? "macos" : "linux";
@@ -7173,7 +7221,7 @@ async function discover(options = {}) {
7173
7221
  }
7174
7222
  for (const extra of options.extraDataDirs?.[spec.tool] ?? []) candidates.add(expandPath(extra));
7175
7223
  for (const p of candidates) {
7176
- if (existsSync2(p) && statSync(p).isDirectory()) {
7224
+ if (existsSync3(p) && statSync(p).isDirectory()) {
7177
7225
  installations.push({
7178
7226
  tool: spec.tool,
7179
7227
  install_method: "manual",
@@ -7190,8 +7238,8 @@ async function discover(options = {}) {
7190
7238
  for (const spec of SOURCES) {
7191
7239
  for (const bin of spec.binaries ?? []) {
7192
7240
  for (const dir of binDirs) {
7193
- const p = join(dir, bin);
7194
- if (existsSync2(p)) {
7241
+ const p = join2(dir, bin);
7242
+ if (existsSync3(p)) {
7195
7243
  const version = await safeVersionProbe(p);
7196
7244
  installations.push({
7197
7245
  tool: spec.tool,
@@ -7341,7 +7389,7 @@ async function probeIdentities(os2) {
7341
7389
  `${homedir()}/.codex/auth.json`,
7342
7390
  `${homedir()}/.config/codex/auth.json`
7343
7391
  ]) {
7344
- if (!existsSync2(candidate)) continue;
7392
+ if (!existsSync3(candidate)) continue;
7345
7393
  try {
7346
7394
  const data = await fs4.promises.readFile(candidate, "utf8");
7347
7395
  const obj = JSON.parse(data);
@@ -7389,7 +7437,7 @@ async function probeIdentities(os2) {
7389
7437
  `${homedir()}/.gemini/oauth_creds.json`,
7390
7438
  `${homedir()}/.config/gemini/oauth_creds.json`
7391
7439
  ]) {
7392
- if (!existsSync2(candidate)) continue;
7440
+ if (!existsSync3(candidate)) continue;
7393
7441
  try {
7394
7442
  const data = await fs4.promises.readFile(candidate, "utf8");
7395
7443
  const obj = JSON.parse(data);
@@ -7411,7 +7459,7 @@ async function probeIdentities(os2) {
7411
7459
  `${homedir()}/Library/Application Support/Cursor/User/globalStorage/storage.json`,
7412
7460
  `${homedir()}/.config/Cursor/User/globalStorage/storage.json`
7413
7461
  ]) {
7414
- if (!existsSync2(candidate)) continue;
7462
+ if (!existsSync3(candidate)) continue;
7415
7463
  try {
7416
7464
  const data = await fs4.promises.readFile(candidate, "utf8");
7417
7465
  const obj = JSON.parse(data);
@@ -7571,10 +7619,10 @@ import {
7571
7619
  readFileSync as readFileSync2,
7572
7620
  renameSync,
7573
7621
  writeFileSync,
7574
- existsSync as existsSync3
7622
+ existsSync as existsSync4
7575
7623
  } from "fs";
7576
7624
  import { homedir as homedir2, hostname as osHostname } from "os";
7577
- import { join as join2 } from "path";
7625
+ import { join as join3 } from "path";
7578
7626
  function ensureRoot() {
7579
7627
  mkdirSync(ROOT, { recursive: true, mode: 448 });
7580
7628
  }
@@ -7592,7 +7640,7 @@ function identityPath() {
7592
7640
  return IDENTITY_FILE;
7593
7641
  }
7594
7642
  function hasIdentityFile() {
7595
- return existsSync3(IDENTITY_FILE);
7643
+ return existsSync4(IDENTITY_FILE);
7596
7644
  }
7597
7645
  function parseFile() {
7598
7646
  try {
@@ -7643,7 +7691,7 @@ function saveIdentity(meta) {
7643
7691
  writeAtomic(meta);
7644
7692
  }
7645
7693
  function backupIdentity() {
7646
- if (!existsSync3(IDENTITY_FILE)) return null;
7694
+ if (!existsSync4(IDENTITY_FILE)) return null;
7647
7695
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
7648
7696
  const dest = `${IDENTITY_FILE}.bak-${stamp}`;
7649
7697
  renameSync(IDENTITY_FILE, dest);
@@ -7660,8 +7708,8 @@ var ROOT, IDENTITY_FILE;
7660
7708
  var init_identity = __esm({
7661
7709
  "src/identity.ts"() {
7662
7710
  "use strict";
7663
- ROOT = join2(homedir2(), ".modelstat");
7664
- IDENTITY_FILE = join2(ROOT, "identity.json");
7711
+ ROOT = join3(homedir2(), ".modelstat");
7712
+ IDENTITY_FILE = join3(ROOT, "identity.json");
7665
7713
  }
7666
7714
  });
7667
7715
 
@@ -21162,7 +21210,7 @@ var require_snapshot_recorder = __commonJS({
21162
21210
  "../../node_modules/.pnpm/undici@7.25.0/node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
21163
21211
  "use strict";
21164
21212
  var { writeFile, readFile, mkdir: mkdir2 } = __require("fs/promises");
21165
- var { dirname: dirname8, resolve: resolve6 } = __require("path");
21213
+ var { dirname: dirname9, resolve: resolve6 } = __require("path");
21166
21214
  var { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = __require("timers");
21167
21215
  var { InvalidArgumentError, UndiciError } = require_errors();
21168
21216
  var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
@@ -21393,7 +21441,7 @@ var require_snapshot_recorder = __commonJS({
21393
21441
  throw new InvalidArgumentError("Snapshot path is required");
21394
21442
  }
21395
21443
  const resolvedPath = resolve6(path5);
21396
- await mkdir2(dirname8(resolvedPath), { recursive: true });
21444
+ await mkdir2(dirname9(resolvedPath), { recursive: true });
21397
21445
  const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
21398
21446
  hash,
21399
21447
  snapshot
@@ -43947,9 +43995,9 @@ var init_source = __esm({
43947
43995
  });
43948
43996
 
43949
43997
  // src/config.ts
43950
- import { existsSync as existsSync4 } from "fs";
43998
+ import { existsSync as existsSync5 } from "fs";
43951
43999
  import { hostname } from "os";
43952
- import { dirname as dirname2, resolve as resolve3 } from "path";
44000
+ import { dirname as dirname3, resolve as resolve3 } from "path";
43953
44001
  import { fileURLToPath } from "url";
43954
44002
  function migrateFromConf() {
43955
44003
  const bearer = store.get("bearerToken");
@@ -43989,10 +44037,10 @@ var init_config2 = __esm({
43989
44037
  import_dotenv = __toESM(require_main(), 1);
43990
44038
  init_source();
43991
44039
  init_identity();
43992
- here = dirname2(fileURLToPath(import.meta.url));
44040
+ here = dirname3(fileURLToPath(import.meta.url));
43993
44041
  for (let d = here, i = 0; i < 8; i++, d = resolve3(d, "..")) {
43994
44042
  const candidate = resolve3(d, ".env");
43995
- if (existsSync4(candidate)) {
44043
+ if (existsSync5(candidate)) {
43996
44044
  (0, import_dotenv.config)({ path: candidate });
43997
44045
  break;
43998
44046
  }
@@ -44801,7 +44849,7 @@ var init_src3 = __esm({
44801
44849
 
44802
44850
  // ../../packages/companion-core/src/node/file-queue-store.ts
44803
44851
  import { promises as fs3 } from "fs";
44804
- import { dirname as dirname3 } from "path";
44852
+ import { dirname as dirname4 } from "path";
44805
44853
  var SENT_TTL_MS, FileQueueStore;
44806
44854
  var init_file_queue_store = __esm({
44807
44855
  "../../packages/companion-core/src/node/file-queue-store.ts"() {
@@ -44857,7 +44905,7 @@ var init_file_queue_store = __esm({
44857
44905
  items: Object.fromEntries(this.items.entries())
44858
44906
  };
44859
44907
  const tmp = `${this.filePath}.tmp`;
44860
- await fs3.mkdir(dirname3(this.filePath), { recursive: true });
44908
+ await fs3.mkdir(dirname4(this.filePath), { recursive: true });
44861
44909
  await fs3.writeFile(tmp, JSON.stringify(snap), "utf8");
44862
44910
  try {
44863
44911
  await fs3.rename(this.filePath, `${this.filePath}.bak`);
@@ -45034,14 +45082,14 @@ var init_ollama = __esm({
45034
45082
 
45035
45083
  // ../../packages/companion-core/src/node/llama.ts
45036
45084
  import { mkdir } from "fs/promises";
45037
- import { existsSync as existsSync5 } from "fs";
45085
+ import { existsSync as existsSync6 } from "fs";
45038
45086
  import { homedir as homedir4 } from "os";
45039
- import { dirname as dirname4, join as join3 } from "path";
45087
+ import { dirname as dirname5, join as join4 } from "path";
45040
45088
  function defaultLlamaConfig() {
45041
45089
  const env2 = globalThis.process?.env ?? {};
45042
- const modelsDir = env2.MODELSTAT_MODELS_DIR ?? join3(homedir4(), ".modelstat", "models");
45090
+ const modelsDir = env2.MODELSTAT_MODELS_DIR ?? join4(homedir4(), ".modelstat", "models");
45043
45091
  const modelUrl = env2.MODELSTAT_LLAMA_MODEL_URL ?? DEFAULT_LLAMA_MODEL_URL;
45044
- const modelPath = env2.MODELSTAT_LLAMA_MODEL_PATH ?? join3(modelsDir, basenameFromUrl(modelUrl));
45092
+ const modelPath = env2.MODELSTAT_LLAMA_MODEL_PATH ?? join4(modelsDir, basenameFromUrl(modelUrl));
45045
45093
  return {
45046
45094
  modelPath,
45047
45095
  modelUrl,
@@ -45062,8 +45110,8 @@ function basenameFromUrl(url) {
45062
45110
  return parts[parts.length - 1] || "model.gguf";
45063
45111
  }
45064
45112
  async function ensureLlamaModel(cfg = defaultLlamaConfig()) {
45065
- if (existsSync5(cfg.modelPath)) return cfg.modelPath;
45066
- await mkdir(dirname4(cfg.modelPath), { recursive: true });
45113
+ if (existsSync6(cfg.modelPath)) return cfg.modelPath;
45114
+ await mkdir(dirname5(cfg.modelPath), { recursive: true });
45067
45115
  const res = await fetch(cfg.modelUrl);
45068
45116
  if (!res.ok || !res.body) {
45069
45117
  throw new Error(
@@ -45534,7 +45582,7 @@ var init_pipeline2 = __esm({
45534
45582
  // src/scan.ts
45535
45583
  import { readdir, stat as stat2 } from "fs/promises";
45536
45584
  import { homedir as homedir5 } from "os";
45537
- import { join as join4 } from "path";
45585
+ import { join as join5 } from "path";
45538
45586
  function withNonNullTokens(e) {
45539
45587
  return e.tokens ? e : { ...e, tokens: { ...ZERO_TOKENS } };
45540
45588
  }
@@ -45543,16 +45591,16 @@ async function scanAll(cb = {}) {
45543
45591
  if (!deviceId) throw new Error("agent not enrolled \u2014 run `register` first");
45544
45592
  const jobs = [];
45545
45593
  try {
45546
- const base = join4(homedir5(), ".claude/projects");
45594
+ const base = join5(homedir5(), ".claude/projects");
45547
45595
  const projects = await readdir(base).catch(() => []);
45548
45596
  for (const p of projects) {
45549
- const dir = join4(base, p);
45597
+ const dir = join5(base, p);
45550
45598
  const ds = await stat2(dir).catch(() => null);
45551
45599
  if (!ds?.isDirectory()) continue;
45552
45600
  const files = await readdir(dir);
45553
45601
  for (const f of files) {
45554
45602
  if (!f.endsWith(".jsonl")) continue;
45555
- const full = join4(dir, f);
45603
+ const full = join5(dir, f);
45556
45604
  jobs.push({
45557
45605
  path: full,
45558
45606
  parse: async () => {
@@ -45566,17 +45614,17 @@ async function scanAll(cb = {}) {
45566
45614
  console.warn("claude scan skipped:", e.message);
45567
45615
  }
45568
45616
  try {
45569
- const base = join4(homedir5(), ".codex/sessions");
45617
+ const base = join5(homedir5(), ".codex/sessions");
45570
45618
  const years = await readdir(base).catch(() => []);
45571
45619
  for (const y of years) {
45572
- const months = await readdir(join4(base, y)).catch(() => []);
45620
+ const months = await readdir(join5(base, y)).catch(() => []);
45573
45621
  for (const m of months) {
45574
- const days = await readdir(join4(base, y, m)).catch(() => []);
45622
+ const days = await readdir(join5(base, y, m)).catch(() => []);
45575
45623
  for (const d of days) {
45576
- const files = await readdir(join4(base, y, m, d)).catch(() => []);
45624
+ const files = await readdir(join5(base, y, m, d)).catch(() => []);
45577
45625
  for (const f of files) {
45578
45626
  if (!f.startsWith("rollout-") || !f.endsWith(".jsonl")) continue;
45579
- const full = join4(base, y, m, d, f);
45627
+ const full = join5(base, y, m, d, f);
45580
45628
  jobs.push({
45581
45629
  path: full,
45582
45630
  parse: async () => {
@@ -45671,7 +45719,7 @@ var init_scan = __esm({
45671
45719
  init_pipeline2();
45672
45720
  init_config2();
45673
45721
  init_api();
45674
- AGENT_VERSION = true ? "agent-0.0.43" : "agent-dev";
45722
+ AGENT_VERSION = true ? "agent-0.0.44" : "agent-dev";
45675
45723
  BATCH_MAX_EVENTS = 2e3;
45676
45724
  ZERO_TOKENS = {
45677
45725
  input: 0,
@@ -45686,7 +45734,7 @@ var init_scan = __esm({
45686
45734
  // src/lock.ts
45687
45735
  import {
45688
45736
  closeSync,
45689
- existsSync as existsSync7,
45737
+ existsSync as existsSync8,
45690
45738
  mkdirSync as mkdirSync3,
45691
45739
  openSync,
45692
45740
  readFileSync as readFileSync4,
@@ -45696,7 +45744,7 @@ import {
45696
45744
  writeSync
45697
45745
  } from "fs";
45698
45746
  import { homedir as homedir7 } from "os";
45699
- import { join as join6 } from "path";
45747
+ import { join as join7 } from "path";
45700
45748
  function isProcessAlive(pid) {
45701
45749
  if (!pid || pid <= 0) return false;
45702
45750
  try {
@@ -45797,8 +45845,8 @@ var LOCK_DIR, LOCK_FILE;
45797
45845
  var init_lock = __esm({
45798
45846
  "src/lock.ts"() {
45799
45847
  "use strict";
45800
- LOCK_DIR = join6(homedir7(), ".modelstat");
45801
- LOCK_FILE = join6(LOCK_DIR, "daemon.lock");
45848
+ LOCK_DIR = join7(homedir7(), ".modelstat");
45849
+ LOCK_FILE = join7(LOCK_DIR, "daemon.lock");
45802
45850
  }
45803
45851
  });
45804
45852
 
@@ -46599,9 +46647,9 @@ var init_handler = __esm({
46599
46647
  if (this.fsw.closed) {
46600
46648
  return;
46601
46649
  }
46602
- const dirname8 = sysPath.dirname(file);
46650
+ const dirname9 = sysPath.dirname(file);
46603
46651
  const basename4 = sysPath.basename(file);
46604
- const parent = this.fsw._getWatchedDir(dirname8);
46652
+ const parent = this.fsw._getWatchedDir(dirname9);
46605
46653
  let prevStats = stats;
46606
46654
  if (parent.has(basename4))
46607
46655
  return;
@@ -46628,7 +46676,7 @@ var init_handler = __esm({
46628
46676
  prevStats = newStats2;
46629
46677
  }
46630
46678
  } catch (error) {
46631
- this.fsw._remove(dirname8, basename4);
46679
+ this.fsw._remove(dirname9, basename4);
46632
46680
  }
46633
46681
  } else if (parent.has(basename4)) {
46634
46682
  const at = newStats.atimeMs;
@@ -47594,7 +47642,7 @@ __export(daemon_exports, {
47594
47642
  setQueue: () => setQueue,
47595
47643
  setStat: () => setStat
47596
47644
  });
47597
- import { existsSync as existsSync8, statSync as statSync2 } from "fs";
47645
+ import { existsSync as existsSync9, statSync as statSync2 } from "fs";
47598
47646
  function setPhase(phase, message) {
47599
47647
  status.phase = phase;
47600
47648
  status.message = message ?? null;
@@ -47674,15 +47722,15 @@ async function sendHeartbeat() {
47674
47722
  }
47675
47723
  async function writeLocalStatus(snapshot) {
47676
47724
  const { homedir: homedir9 } = await import("os");
47677
- const { join: join10 } = await import("path");
47725
+ const { join: join11 } = await import("path");
47678
47726
  const { writeFile, mkdir: mkdir2, rename } = await import("fs/promises");
47679
47727
  if (!lastStatusPath) {
47680
- const dir = join10(homedir9(), ".modelstat");
47728
+ const dir = join11(homedir9(), ".modelstat");
47681
47729
  try {
47682
47730
  await mkdir2(dir, { recursive: true });
47683
47731
  } catch {
47684
47732
  }
47685
- lastStatusPath = join10(dir, "last-status.json");
47733
+ lastStatusPath = join11(dir, "last-status.json");
47686
47734
  }
47687
47735
  const tmp = `${lastStatusPath}.tmp`;
47688
47736
  try {
@@ -47805,20 +47853,20 @@ async function runDaemon(opts = {}) {
47805
47853
  await requestScan("startup");
47806
47854
  const chokidar = (await Promise.resolve().then(() => (init_esm2(), esm_exports))).default;
47807
47855
  const { homedir: homedir9, platform: platform5 } = await import("os");
47808
- const { join: join10 } = await import("path");
47856
+ const { join: join11 } = await import("path");
47809
47857
  const home2 = homedir9();
47810
47858
  const dirs = [
47811
- join10(home2, ".claude/projects"),
47812
- join10(home2, ".codex/sessions"),
47813
- join10(home2, ".cursor/ai-tracking"),
47814
- join10(home2, ".gemini"),
47859
+ join11(home2, ".claude/projects"),
47860
+ join11(home2, ".codex/sessions"),
47861
+ join11(home2, ".cursor/ai-tracking"),
47862
+ join11(home2, ".gemini"),
47815
47863
  ...platform5() === "darwin" ? [
47816
- join10(home2, "Library/Application Support/Cursor/User/workspaceStorage"),
47817
- join10(home2, "Library/Application Support/Claude")
47864
+ join11(home2, "Library/Application Support/Cursor/User/workspaceStorage"),
47865
+ join11(home2, "Library/Application Support/Claude")
47818
47866
  ] : [
47819
- join10(home2, ".config/Cursor/User/workspaceStorage")
47867
+ join11(home2, ".config/Cursor/User/workspaceStorage")
47820
47868
  ]
47821
- ].filter((p) => existsSync8(p) && statSync2(p).isDirectory());
47869
+ ].filter((p) => existsSync9(p) && statSync2(p).isDirectory());
47822
47870
  setPhase("watching", `Watching ${dirs.length} directories`);
47823
47871
  const watcher = chokidar.watch(dirs, {
47824
47872
  persistent: true,
@@ -47871,7 +47919,7 @@ var init_daemon = __esm({
47871
47919
  init_lock();
47872
47920
  init_scan();
47873
47921
  init_single_flight();
47874
- AGENT_VERSION2 = true ? "agent-0.0.43" : "agent-dev";
47922
+ AGENT_VERSION2 = true ? "agent-0.0.44" : "agent-dev";
47875
47923
  HEARTBEAT_INTERVAL_MS = 1e4;
47876
47924
  SCAN_INTERVAL_MS = 5 * 60 * 1e3;
47877
47925
  DISCOVERY_INTERVAL_MS = 6e4;
@@ -47897,37 +47945,37 @@ var watch_exports = {};
47897
47945
  __export(watch_exports, {
47898
47946
  watchForever: () => watchForever
47899
47947
  });
47900
- import { existsSync as existsSync9 } from "fs";
47948
+ import { existsSync as existsSync10 } from "fs";
47901
47949
  import { homedir as homedir8, platform as platform3 } from "os";
47902
- import { join as join9 } from "path";
47950
+ import { join as join10 } from "path";
47903
47951
  function resolveWatchDirs() {
47904
47952
  const home2 = homedir8();
47905
- const xdgConfig = process.env.XDG_CONFIG_HOME ?? join9(home2, ".config");
47906
- const xdgData = process.env.XDG_DATA_HOME ?? join9(home2, ".local/share");
47953
+ const xdgConfig = process.env.XDG_CONFIG_HOME ?? join10(home2, ".config");
47954
+ const xdgData = process.env.XDG_DATA_HOME ?? join10(home2, ".local/share");
47907
47955
  const candidates = [
47908
47956
  // universal (default HOME-rooted CLI data dirs)
47909
- join9(home2, ".claude/projects"),
47910
- join9(home2, ".codex/sessions"),
47911
- join9(home2, ".cursor/ai-tracking"),
47912
- join9(home2, ".gemini"),
47913
- join9(home2, ".aider"),
47957
+ join10(home2, ".claude/projects"),
47958
+ join10(home2, ".codex/sessions"),
47959
+ join10(home2, ".cursor/ai-tracking"),
47960
+ join10(home2, ".gemini"),
47961
+ join10(home2, ".aider"),
47914
47962
  // XDG / Linux
47915
- join9(xdgConfig, "claude/projects"),
47916
- join9(xdgConfig, "codex/sessions"),
47917
- join9(xdgConfig, "Cursor/User/workspaceStorage"),
47918
- join9(xdgConfig, "Code/User/workspaceStorage"),
47919
- join9(xdgConfig, "Code - Insiders/User/workspaceStorage"),
47920
- join9(xdgData, "claude/projects"),
47963
+ join10(xdgConfig, "claude/projects"),
47964
+ join10(xdgConfig, "codex/sessions"),
47965
+ join10(xdgConfig, "Cursor/User/workspaceStorage"),
47966
+ join10(xdgConfig, "Code/User/workspaceStorage"),
47967
+ join10(xdgConfig, "Code - Insiders/User/workspaceStorage"),
47968
+ join10(xdgData, "claude/projects"),
47921
47969
  // macOS
47922
47970
  ...platform3() === "darwin" ? [
47923
- join9(home2, "Library/Application Support/Cursor/User/workspaceStorage"),
47924
- join9(home2, "Library/Application Support/Claude"),
47925
- join9(home2, "Library/Application Support/Code/User/workspaceStorage"),
47926
- join9(home2, "Library/Application Support/Windsurf/User/workspaceStorage"),
47927
- join9(home2, "Library/Application Support/Zed")
47971
+ join10(home2, "Library/Application Support/Cursor/User/workspaceStorage"),
47972
+ join10(home2, "Library/Application Support/Claude"),
47973
+ join10(home2, "Library/Application Support/Code/User/workspaceStorage"),
47974
+ join10(home2, "Library/Application Support/Windsurf/User/workspaceStorage"),
47975
+ join10(home2, "Library/Application Support/Zed")
47928
47976
  ] : []
47929
47977
  ];
47930
- return Array.from(new Set(candidates)).filter((p) => existsSync9(p));
47978
+ return Array.from(new Set(candidates)).filter((p) => existsSync10(p));
47931
47979
  }
47932
47980
  async function safeScan(reason) {
47933
47981
  if (scanning) {
@@ -48002,7 +48050,7 @@ import { createInterface as createInterface3 } from "readline";
48002
48050
  import { spawnSync } from "child_process";
48003
48051
  import {
48004
48052
  copyFileSync,
48005
- existsSync as existsSync6,
48053
+ existsSync as existsSync7,
48006
48054
  mkdirSync as mkdirSync2,
48007
48055
  readFileSync as readFileSync3,
48008
48056
  realpathSync,
@@ -48011,7 +48059,7 @@ import {
48011
48059
  } from "fs";
48012
48060
  import { createRequire } from "module";
48013
48061
  import { homedir as homedir6, platform as platform2, userInfo } from "os";
48014
- import { dirname as dirname5, join as join5 } from "path";
48062
+ import { dirname as dirname6, join as join6 } from "path";
48015
48063
  import { fileURLToPath as fileURLToPath2 } from "url";
48016
48064
  var SERVICE_LABEL = "ai.modelstat.agent";
48017
48065
  var SYSTEMD_UNIT = "modelstat";
@@ -48019,16 +48067,16 @@ function home() {
48019
48067
  return homedir6();
48020
48068
  }
48021
48069
  function stateDir() {
48022
- return join5(home(), ".modelstat");
48070
+ return join6(home(), ".modelstat");
48023
48071
  }
48024
48072
  function binDir() {
48025
- return join5(stateDir(), "bin");
48073
+ return join6(stateDir(), "bin");
48026
48074
  }
48027
48075
  function logDir() {
48028
- return join5(stateDir(), "logs");
48076
+ return join6(stateDir(), "logs");
48029
48077
  }
48030
48078
  function installedCliPath() {
48031
- return join5(binDir(), "modelstat.mjs");
48079
+ return join6(binDir(), "modelstat.mjs");
48032
48080
  }
48033
48081
  function runningCliPath() {
48034
48082
  return fileURLToPath2(import.meta.url).replace(/service\.(mjs|js|ts)$/, "cli.mjs");
@@ -48038,7 +48086,7 @@ function installBundle() {
48038
48086
  mkdirSync2(logDir(), { recursive: true });
48039
48087
  const src = runningCliPath();
48040
48088
  const dest = installedCliPath();
48041
- if (!existsSync6(src)) {
48089
+ if (!existsSync7(src)) {
48042
48090
  throw new Error(
48043
48091
  `Can't find the CLI bundle to install from (${src}). Are you running a local dev build?`
48044
48092
  );
@@ -48054,14 +48102,14 @@ var NODE_LLAMA_CPP_FALLBACK_VERSION = "3.18.1";
48054
48102
  function sourceLlamaVersion(sourceCli) {
48055
48103
  try {
48056
48104
  const req = createRequire(sourceCli);
48057
- let d = dirname5(realpathSync(req.resolve("node-llama-cpp")));
48105
+ let d = dirname6(realpathSync(req.resolve("node-llama-cpp")));
48058
48106
  for (let i = 0; i < 10; i++) {
48059
- const pj = join5(d, "package.json");
48060
- if (existsSync6(pj)) {
48107
+ const pj = join6(d, "package.json");
48108
+ if (existsSync7(pj)) {
48061
48109
  const p = JSON.parse(readFileSync3(pj, "utf8"));
48062
48110
  if (p.name === "node-llama-cpp" && p.version) return p.version;
48063
48111
  }
48064
- const up = dirname5(d);
48112
+ const up = dirname6(d);
48065
48113
  if (up === d) break;
48066
48114
  d = up;
48067
48115
  }
@@ -48075,7 +48123,7 @@ function installNativeRuntime(sourceCli) {
48075
48123
  try {
48076
48124
  const have = JSON.parse(
48077
48125
  readFileSync3(
48078
- join5(dest, "node_modules", "node-llama-cpp", "package.json"),
48126
+ join6(dest, "node_modules", "node-llama-cpp", "package.json"),
48079
48127
  "utf8"
48080
48128
  )
48081
48129
  );
@@ -48116,21 +48164,21 @@ function nodeBinary() {
48116
48164
  return process.execPath;
48117
48165
  }
48118
48166
  function plistPath() {
48119
- return join5(home(), "Library", "LaunchAgents", `${SERVICE_LABEL}.plist`);
48167
+ return join6(home(), "Library", "LaunchAgents", `${SERVICE_LABEL}.plist`);
48120
48168
  }
48121
48169
  function locateTrayExecutable() {
48122
48170
  const candidates = [
48123
- join5(home(), "Applications", "ModelstatTray.app", "Contents", "MacOS", "modelstat-tray"),
48171
+ join6(home(), "Applications", "ModelstatTray.app", "Contents", "MacOS", "modelstat-tray"),
48124
48172
  "/Applications/ModelstatTray.app/Contents/MacOS/modelstat-tray"
48125
48173
  ];
48126
48174
  for (const p of candidates) {
48127
- if (existsSync6(p)) return p;
48175
+ if (existsSync7(p)) return p;
48128
48176
  }
48129
48177
  return null;
48130
48178
  }
48131
48179
  function writePlist(cliPath) {
48132
48180
  const p = plistPath();
48133
- mkdirSync2(dirname5(p), { recursive: true });
48181
+ mkdirSync2(dirname6(p), { recursive: true });
48134
48182
  const tray = locateTrayExecutable();
48135
48183
  const programArgs = tray ? ` <string>${tray}</string>` : [
48136
48184
  ` <string>${nodeBinary()}</string>`,
@@ -48150,8 +48198,8 @@ ${programArgs}
48150
48198
  <key>KeepAlive</key>
48151
48199
  <dict><key>SuccessfulExit</key><false/></dict>
48152
48200
  <key>ThrottleInterval</key><integer>30</integer>
48153
- <key>StandardOutPath</key><string>${join5(logDir(), "out.log")}</string>
48154
- <key>StandardErrorPath</key><string>${join5(logDir(), "err.log")}</string>
48201
+ <key>StandardOutPath</key><string>${join6(logDir(), "out.log")}</string>
48202
+ <key>StandardErrorPath</key><string>${join6(logDir(), "err.log")}</string>
48155
48203
  <key>EnvironmentVariables</key>
48156
48204
  <dict>
48157
48205
  <key>PATH</key><string>/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin</string>
@@ -48196,7 +48244,7 @@ function macUninstall() {
48196
48244
  const target = `gui/${uid}/${SERVICE_LABEL}`;
48197
48245
  launchctl(["bootout", target]);
48198
48246
  const plist = plistPath();
48199
- if (existsSync6(plist)) {
48247
+ if (existsSync7(plist)) {
48200
48248
  try {
48201
48249
  unlinkSync(plist);
48202
48250
  } catch {
@@ -48209,12 +48257,12 @@ function macStatus() {
48209
48257
  return { running: r.ok, hint: r.ok ? "launchd managed" : "not installed" };
48210
48258
  }
48211
48259
  function systemdUnitPath() {
48212
- const xdg = process.env.XDG_CONFIG_HOME ?? join5(home(), ".config");
48213
- return join5(xdg, "systemd", "user", `${SYSTEMD_UNIT}.service`);
48260
+ const xdg = process.env.XDG_CONFIG_HOME ?? join6(home(), ".config");
48261
+ return join6(xdg, "systemd", "user", `${SYSTEMD_UNIT}.service`);
48214
48262
  }
48215
48263
  function writeSystemdUnit(cliPath) {
48216
48264
  const unitPath = systemdUnitPath();
48217
- mkdirSync2(dirname5(unitPath), { recursive: true });
48265
+ mkdirSync2(dirname6(unitPath), { recursive: true });
48218
48266
  const unit = `[Unit]
48219
48267
  Description=modelstat agent
48220
48268
  Documentation=https://modelstat.ai
@@ -48233,8 +48281,8 @@ RestartSec=10
48233
48281
  # Don't restart-storm if the service is persistently unreachable.
48234
48282
  StartLimitIntervalSec=300
48235
48283
  StartLimitBurst=10
48236
- StandardOutput=append:${join5(logDir(), "out.log")}
48237
- StandardError=append:${join5(logDir(), "err.log")}
48284
+ StandardOutput=append:${join6(logDir(), "out.log")}
48285
+ StandardError=append:${join6(logDir(), "err.log")}
48238
48286
 
48239
48287
  [Install]
48240
48288
  WantedBy=default.target
@@ -48259,7 +48307,7 @@ function linuxInstall() {
48259
48307
  function linuxUninstall() {
48260
48308
  systemctl(["disable", "--now", `${SYSTEMD_UNIT}.service`]);
48261
48309
  const unit = systemdUnitPath();
48262
- if (existsSync6(unit)) {
48310
+ if (existsSync7(unit)) {
48263
48311
  try {
48264
48312
  unlinkSync(unit);
48265
48313
  } catch {
@@ -48303,9 +48351,9 @@ function logsDir() {
48303
48351
  }
48304
48352
  function installTrayApp(sourceAppPath) {
48305
48353
  if (platform2() !== "darwin") return null;
48306
- if (!existsSync6(sourceAppPath)) return null;
48307
- const dest = join5(home(), "Applications", "ModelstatTray.app");
48308
- mkdirSync2(dirname5(dest), { recursive: true });
48354
+ if (!existsSync7(sourceAppPath)) return null;
48355
+ const dest = join6(home(), "Applications", "ModelstatTray.app");
48356
+ mkdirSync2(dirname6(dest), { recursive: true });
48309
48357
  spawnSync("rm", ["-rf", dest]);
48310
48358
  const r = spawnSync("cp", ["-R", sourceAppPath, dest], { encoding: "utf8" });
48311
48359
  if (r.status !== 0) {
@@ -48315,28 +48363,28 @@ function installTrayApp(sourceAppPath) {
48315
48363
  }
48316
48364
  function bundledTrayAppPath() {
48317
48365
  if (platform2() !== "darwin") return null;
48318
- const here2 = dirname5(fileURLToPath2(import.meta.url));
48366
+ const here2 = dirname6(fileURLToPath2(import.meta.url));
48319
48367
  const candidates = [
48320
48368
  // Pre-built .app — CI with codesigning drops one here.
48321
- join5(here2, "..", "vendor", "ModelstatTray.app"),
48369
+ join6(here2, "..", "vendor", "ModelstatTray.app"),
48322
48370
  // Local dev layout: apps/agent-dev/src/service.ts → ../../tray-mac/build/ModelstatTray.app
48323
- join5(here2, "..", "..", "tray-mac", "build", "ModelstatTray.app")
48371
+ join6(here2, "..", "..", "tray-mac", "build", "ModelstatTray.app")
48324
48372
  ];
48325
48373
  for (const c of candidates) {
48326
- if (existsSync6(c)) return c;
48374
+ if (existsSync7(c)) return c;
48327
48375
  }
48328
48376
  const sourceDirs = [
48329
- join5(here2, "..", "vendor", "tray-mac"),
48330
- join5(here2, "..", "..", "tray-mac")
48377
+ join6(here2, "..", "vendor", "tray-mac"),
48378
+ join6(here2, "..", "..", "tray-mac")
48331
48379
  ];
48332
48380
  for (const src of sourceDirs) {
48333
- const build = join5(src, "build-app.sh");
48334
- if (!existsSync6(build)) continue;
48381
+ const build = join6(src, "build-app.sh");
48382
+ if (!existsSync7(build)) continue;
48335
48383
  if (!hasSwift()) return null;
48336
48384
  const r = spawnSync("bash", [build], { cwd: src, encoding: "utf8" });
48337
48385
  if (r.status === 0) {
48338
- const app = join5(src, "build", "ModelstatTray.app");
48339
- if (existsSync6(app)) return app;
48386
+ const app = join6(src, "build", "ModelstatTray.app");
48387
+ if (existsSync7(app)) return app;
48340
48388
  }
48341
48389
  }
48342
48390
  return null;
@@ -48381,7 +48429,7 @@ function tryOpenBrowser(url) {
48381
48429
  return false;
48382
48430
  }
48383
48431
  }
48384
- var AGENT_VERSION3 = true ? "agent-0.0.43" : "agent-dev";
48432
+ var AGENT_VERSION3 = true ? "agent-0.0.44" : "agent-dev";
48385
48433
  function osFamily() {
48386
48434
  const p = platform4();
48387
48435
  if (p === "darwin") return "macos";
@@ -48776,9 +48824,9 @@ function fmtTokens(v) {
48776
48824
  async function readLocalStatus() {
48777
48825
  try {
48778
48826
  const { homedir: homedir9 } = await import("os");
48779
- const { join: join10 } = await import("path");
48827
+ const { join: join11 } = await import("path");
48780
48828
  const { readFile } = await import("fs/promises");
48781
- const p = join10(homedir9(), ".modelstat", "last-status.json");
48829
+ const p = join11(homedir9(), ".modelstat", "last-status.json");
48782
48830
  const txt = await readFile(p, "utf8");
48783
48831
  return JSON.parse(txt);
48784
48832
  } catch {