repowisestage 0.0.76 → 0.0.78

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.
Files changed (2) hide show
  1. package/dist/bin/repowise.js +305 -154
  2. package/package.json +1 -1
@@ -3133,13 +3133,13 @@ var init_telemetry = __esm({
3133
3133
  // bin/repowise.ts
3134
3134
  import { readFileSync as readFileSync3 } from "fs";
3135
3135
  import { fileURLToPath as fileURLToPath4 } from "url";
3136
- import { dirname as dirname23, join as join63 } from "path";
3136
+ import { dirname as dirname24, join as join63 } from "path";
3137
3137
  import { Command } from "commander";
3138
3138
 
3139
3139
  // ../listener/dist/main.js
3140
3140
  init_config_dir();
3141
3141
  import { readFile as readFile14, writeFile as writeFile16, mkdir as mkdir16, stat as fsStat } from "fs/promises";
3142
- import { join as join42, dirname as dirname17 } from "path";
3142
+ import { join as join42, dirname as dirname18 } from "path";
3143
3143
  import { fileURLToPath as fileURLToPath3 } from "url";
3144
3144
  import lockfile5 from "proper-lockfile";
3145
3145
 
@@ -6157,6 +6157,93 @@ function createGraphDownloader(options) {
6157
6157
 
6158
6158
  // ../listener/dist/mcp/heartbeat.js
6159
6159
  import { setTimeout as delay2 } from "timers/promises";
6160
+
6161
+ // ../listener/dist/mcp/heartbeat-queue.js
6162
+ import { promises as fs5 } from "fs";
6163
+ import { randomUUID } from "crypto";
6164
+ import { dirname as dirname11 } from "path";
6165
+ var DEFAULT_MAX_ENTRIES = 336;
6166
+ function createFileHeartbeatQueue(opts) {
6167
+ const maxEntries = opts.maxEntries ?? DEFAULT_MAX_ENTRIES;
6168
+ const warn = opts.warn ?? ((m) => console.warn(m));
6169
+ let chain = Promise.resolve();
6170
+ async function read() {
6171
+ let raw;
6172
+ try {
6173
+ raw = await fs5.readFile(opts.path, "utf-8");
6174
+ } catch (err) {
6175
+ if (err.code === "ENOENT")
6176
+ return [];
6177
+ throw err;
6178
+ }
6179
+ const entries = [];
6180
+ for (const line of raw.split("\n")) {
6181
+ const trimmed = line.trim();
6182
+ if (!trimmed)
6183
+ continue;
6184
+ try {
6185
+ const e = JSON.parse(trimmed);
6186
+ if (e && typeof e.id === "string" && e.payload)
6187
+ entries.push(e);
6188
+ } catch {
6189
+ }
6190
+ }
6191
+ return entries;
6192
+ }
6193
+ async function write(entries) {
6194
+ await fs5.mkdir(dirname11(opts.path), { recursive: true });
6195
+ const tmp = `${opts.path}.tmp`;
6196
+ const body = entries.map((e) => JSON.stringify(e)).join("\n") + (entries.length ? "\n" : "");
6197
+ await fs5.writeFile(tmp, body, { mode: 384 });
6198
+ await fs5.rename(tmp, opts.path);
6199
+ }
6200
+ function mutate(fn) {
6201
+ const run = chain.then(async () => {
6202
+ const entries = await read();
6203
+ const { next, result } = fn(entries);
6204
+ await write(next);
6205
+ return result;
6206
+ });
6207
+ chain = run.then(() => void 0, () => void 0);
6208
+ return run;
6209
+ }
6210
+ return {
6211
+ enqueue(payload) {
6212
+ return mutate((entries) => {
6213
+ const next = [...entries, { id: randomUUID(), payload }];
6214
+ while (next.length > maxEntries) {
6215
+ next.shift();
6216
+ warn(`[heartbeat] queue full (${maxEntries.toString()}) \u2014 dropped the oldest un-sent bucket`);
6217
+ }
6218
+ return { next, result: void 0 };
6219
+ });
6220
+ },
6221
+ list() {
6222
+ return chain.then(() => read());
6223
+ },
6224
+ remove(id) {
6225
+ return mutate((entries) => ({ next: entries.filter((e) => e.id !== id), result: void 0 }));
6226
+ }
6227
+ };
6228
+ }
6229
+ function createInMemoryHeartbeatQueue() {
6230
+ let entries = [];
6231
+ return {
6232
+ enqueue(payload) {
6233
+ entries.push({ id: randomUUID(), payload });
6234
+ return Promise.resolve();
6235
+ },
6236
+ list() {
6237
+ return Promise.resolve([...entries]);
6238
+ },
6239
+ remove(id) {
6240
+ entries = entries.filter((e) => e.id !== id);
6241
+ return Promise.resolve();
6242
+ }
6243
+ };
6244
+ }
6245
+
6246
+ // ../listener/dist/mcp/heartbeat.js
6160
6247
  var DEFAULT_WINDOW = 60 * 60 * 1e3;
6161
6248
  function emptyStatusCounts() {
6162
6249
  return { ok: 0, error: 0, timeout: 0, rejected: 0 };
@@ -6174,6 +6261,7 @@ function emptyHealthCounters() {
6174
6261
  function createHeartbeatEmitter(opts) {
6175
6262
  const windowMs = opts.windowMs ?? DEFAULT_WINDOW;
6176
6263
  const now = opts.now ?? (() => Date.now());
6264
+ const queue = opts.queue ?? createInMemoryHeartbeatQueue();
6177
6265
  let bucketStart = Math.floor(now() / windowMs) * windowMs;
6178
6266
  let toolCounts = /* @__PURE__ */ new Map();
6179
6267
  let missCounts = /* @__PURE__ */ new Map();
@@ -6208,17 +6296,61 @@ function createHeartbeatEmitter(opts) {
6208
6296
  statusCounts = emptyStatusCounts();
6209
6297
  healthCounters = emptyHealthCounters();
6210
6298
  }
6299
+ const maxUnpersisted = opts.maxUnpersisted ?? 336;
6300
+ const unpersisted = [];
6301
+ let drainChain = Promise.resolve();
6302
+ function rollBucket(nextBucket) {
6303
+ const payload = buildPayload();
6304
+ bucketStart = nextBucket;
6305
+ clearCounters();
6306
+ return payload;
6307
+ }
6308
+ async function persist(payload) {
6309
+ try {
6310
+ await queue.enqueue(payload);
6311
+ } catch {
6312
+ unpersisted.push(payload);
6313
+ while (unpersisted.length > maxUnpersisted) {
6314
+ unpersisted.shift();
6315
+ console.warn("[heartbeat] in-memory hold full \u2014 dropped the oldest un-persisted bucket");
6316
+ }
6317
+ }
6318
+ }
6211
6319
  async function flushIfDue(currentBucket) {
6212
6320
  if (currentBucket === bucketStart)
6213
6321
  return;
6214
- const payload = buildPayload();
6215
- bucketStart = currentBucket;
6216
- clearCounters();
6322
+ await persist(rollBucket(currentBucket));
6323
+ }
6324
+ async function drainOnce() {
6325
+ while (unpersisted.length > 0) {
6326
+ try {
6327
+ await queue.enqueue(unpersisted[0]);
6328
+ unpersisted.shift();
6329
+ } catch {
6330
+ break;
6331
+ }
6332
+ }
6333
+ let pending;
6217
6334
  try {
6218
- await opts.sink.post(payload);
6335
+ pending = await queue.list();
6219
6336
  } catch {
6337
+ return;
6338
+ }
6339
+ pending.sort((a, b) => a.payload.windowStartsAt < b.payload.windowStartsAt ? -1 : a.payload.windowStartsAt > b.payload.windowStartsAt ? 1 : 0);
6340
+ for (const entry of pending) {
6341
+ try {
6342
+ await opts.sink.post(entry.payload);
6343
+ } catch {
6344
+ return;
6345
+ }
6346
+ await queue.remove(entry.id).catch(() => void 0);
6220
6347
  }
6221
6348
  }
6349
+ function drain() {
6350
+ const run = drainChain.then(() => drainOnce());
6351
+ drainChain = run.then(() => void 0, () => void 0);
6352
+ return run;
6353
+ }
6222
6354
  return {
6223
6355
  record(tool, outcome) {
6224
6356
  toolCounts.set(tool, (toolCounts.get(tool) ?? 0) + 1);
@@ -6236,16 +6368,15 @@ function createHeartbeatEmitter(opts) {
6236
6368
  async tick(nowOverride) {
6237
6369
  const current = Math.floor((nowOverride ?? now()) / windowMs) * windowMs;
6238
6370
  await flushIfDue(current);
6371
+ await drain();
6239
6372
  },
6240
6373
  async flush() {
6241
- if (!hasData())
6242
- return;
6243
- const payload = buildPayload();
6244
- clearCounters();
6245
- try {
6246
- await opts.sink.post(payload);
6247
- } catch {
6374
+ if (hasData()) {
6375
+ const payload = buildPayload();
6376
+ clearCounters();
6377
+ await persist(payload);
6248
6378
  }
6379
+ await drain();
6249
6380
  }
6250
6381
  };
6251
6382
  }
@@ -6261,7 +6392,7 @@ async function runHeartbeatLoop(emitter, opts = {}) {
6261
6392
  // ../listener/dist/mcp/log-encryption.js
6262
6393
  import { createCipheriv, createDecipheriv, randomBytes } from "crypto";
6263
6394
  import { mkdir as mkdir11, readFile as readFile11, stat as stat4, writeFile as writeFile12 } from "fs/promises";
6264
- import { dirname as dirname11 } from "path";
6395
+ import { dirname as dirname12 } from "path";
6265
6396
  var KEY_BYTES = 32;
6266
6397
  var IV_BYTES = 12;
6267
6398
  var TAG_BYTES = 16;
@@ -6308,7 +6439,7 @@ function createFileKeyStore(keyPath) {
6308
6439
  return parsed;
6309
6440
  }
6310
6441
  const fresh = randomBytes(KEY_BYTES);
6311
- await mkdir11(dirname11(keyPath), { recursive: true });
6442
+ await mkdir11(dirname12(keyPath), { recursive: true });
6312
6443
  const tmp = `${keyPath}.tmp`;
6313
6444
  await writeFile12(tmp, fresh.toString("base64") + "\n", {
6314
6445
  encoding: "utf-8",
@@ -6350,7 +6481,7 @@ function decryptLine(encoded, key) {
6350
6481
 
6351
6482
  // ../listener/dist/mcp/mcp-logger.js
6352
6483
  import { appendFile, mkdir as mkdir12, stat as stat5, unlink as unlink10, writeFile as writeFile13, readFile as readFile12 } from "fs/promises";
6353
- import { dirname as dirname12 } from "path";
6484
+ import { dirname as dirname13 } from "path";
6354
6485
  var DEFAULT_MAX_BYTES = 100 * 1024 * 1024;
6355
6486
  function createMcpLogger(options) {
6356
6487
  const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
@@ -6373,7 +6504,7 @@ function createMcpLogger(options) {
6373
6504
  await migrateLegacyPlaintext();
6374
6505
  const key = await options.keyStore.getKey();
6375
6506
  const encoded = encryptLine(JSON.stringify(entry), key) + "\n";
6376
- await mkdir12(dirname12(options.filePath), { recursive: true });
6507
+ await mkdir12(dirname13(options.filePath), { recursive: true });
6377
6508
  await appendFile(options.filePath, encoded, { encoding: "utf-8", mode: 384 });
6378
6509
  try {
6379
6510
  const s = await stat5(options.filePath);
@@ -6405,15 +6536,15 @@ async function rotate(path, size) {
6405
6536
  }
6406
6537
 
6407
6538
  // ../listener/dist/mcp/mcp-log-uploader.js
6408
- import { randomUUID } from "crypto";
6539
+ import { randomUUID as randomUUID2 } from "crypto";
6409
6540
  import { readFile as readFile13, writeFile as writeFile14, mkdir as mkdir13 } from "fs/promises";
6410
- import { dirname as dirname13 } from "path";
6541
+ import { dirname as dirname14 } from "path";
6411
6542
  var MCP_LOG_UPLOAD_TIMEOUT_MS = 3e4;
6412
- var DEFAULT_MAX_ENTRIES = 5e3;
6543
+ var DEFAULT_MAX_ENTRIES2 = 5e3;
6413
6544
  var DEFAULT_MAX_BYTES2 = 1 * 1024 * 1024;
6414
6545
  function createMcpLogUploader(options) {
6415
6546
  const fetchImpl = options.fetchImpl ?? fetch;
6416
- const maxEntries = options.maxEntriesPerBatch ?? DEFAULT_MAX_ENTRIES;
6547
+ const maxEntries = options.maxEntriesPerBatch ?? DEFAULT_MAX_ENTRIES2;
6417
6548
  const maxBytes = options.maxBytesPerBatch ?? DEFAULT_MAX_BYTES2;
6418
6549
  let consentRevoked = false;
6419
6550
  return {
@@ -6491,7 +6622,7 @@ function createMcpLogUploader(options) {
6491
6622
  const token = await options.getAuthToken();
6492
6623
  let batchId = await readPendingBatch(options.watermarkFilePath);
6493
6624
  if (!batchId) {
6494
- batchId = randomUUID();
6625
+ batchId = randomUUID2();
6495
6626
  await writePendingBatch(options.watermarkFilePath, batchId);
6496
6627
  }
6497
6628
  const uploadBody = JSON.stringify({
@@ -6560,7 +6691,7 @@ async function readPendingBatch(watermarkPath) {
6560
6691
  }
6561
6692
  }
6562
6693
  async function writePendingBatch(watermarkPath, batchId) {
6563
- await mkdir13(dirname13(watermarkPath), { recursive: true });
6694
+ await mkdir13(dirname14(watermarkPath), { recursive: true });
6564
6695
  await writeFile14(pendingPath(watermarkPath), batchId, { encoding: "utf-8", mode: 384 });
6565
6696
  }
6566
6697
  async function clearPendingBatch(watermarkPath) {
@@ -6582,7 +6713,7 @@ async function readWatermark(path) {
6582
6713
  }
6583
6714
  }
6584
6715
  async function writeWatermark(path, offset) {
6585
- await mkdir13(dirname13(path), { recursive: true });
6716
+ await mkdir13(dirname14(path), { recursive: true });
6586
6717
  const tmp = `${path}.tmp`;
6587
6718
  await writeFile14(tmp, offset.toString() + "\n", { encoding: "utf-8", mode: 384 });
6588
6719
  const { rename: rename8 } = await import("fs/promises");
@@ -6602,8 +6733,8 @@ async function isLocallyConsented(flagPath2) {
6602
6733
  init_config_dir();
6603
6734
  import { createServer } from "http";
6604
6735
  import { mkdir as mkdir14, writeFile as writeFile15, unlink as unlink11 } from "fs/promises";
6605
- import { dirname as dirname14, join as join23 } from "path";
6606
- import { createHash as createHash4, randomUUID as randomUUID2 } from "crypto";
6736
+ import { dirname as dirname15, join as join23 } from "path";
6737
+ import { createHash as createHash4, randomUUID as randomUUID3 } from "crypto";
6607
6738
 
6608
6739
  // ../listener/dist/mcp/sanitize.js
6609
6740
  var MCP_RESPONSE_BYTE_CAP = 200 * 1024;
@@ -7728,7 +7859,7 @@ function handleRequest(req, res, options, sessions, secretCtx) {
7728
7859
  if (!body?.repoId)
7729
7860
  return sendJson(res, 400, { error: "missing_repoId" });
7730
7861
  return options.graphCache.acquire(body.repoId).then(() => {
7731
- const sessionId = randomUUID2();
7862
+ const sessionId = randomUUID3();
7732
7863
  sessions.set(sessionId, { repoId: body.repoId });
7733
7864
  return sendJson(res, 200, { sessionId });
7734
7865
  });
@@ -8221,7 +8352,7 @@ async function readJson(req) {
8221
8352
  }
8222
8353
  }
8223
8354
  async function writeEndpointFile(path, endpoint, secret) {
8224
- await mkdir14(dirname14(path), { recursive: true });
8355
+ await mkdir14(dirname15(path), { recursive: true });
8225
8356
  await writeFile15(path, formatEndpointFile({ endpoint, secret }), {
8226
8357
  encoding: "utf-8",
8227
8358
  mode: 384
@@ -8301,9 +8432,14 @@ async function startMcp(options) {
8301
8432
  sink: createHeartbeatSink({
8302
8433
  apiUrl: heartbeatApiUrl,
8303
8434
  getAuthToken: options.getAuthToken,
8435
+ ...options.getAuthTokenForceRefresh ? { getAuthTokenForceRefresh: options.getAuthTokenForceRefresh } : {},
8304
8436
  flagFilePath,
8305
8437
  ...options.fetchImpl ? { fetchImpl: options.fetchImpl } : {}
8306
- })
8438
+ }),
8439
+ // Durable delivery: a rolled bucket is persisted before the POST, so a
8440
+ // transient failure (network / auth gap / 5xx) is retried next tick and
8441
+ // survives a restart instead of dropping the hour's counts.
8442
+ queue: createFileHeartbeatQueue({ path: join24(mcpHome, "heartbeat-queue.jsonl") })
8307
8443
  }) : null;
8308
8444
  const heartbeatAbort = heartbeatEmitter ? new AbortController() : null;
8309
8445
  const server = await startMcpServer({
@@ -8449,6 +8585,7 @@ async function startMcp(options) {
8449
8585
  }
8450
8586
  };
8451
8587
  }
8588
+ var HEARTBEAT_UPLOAD_TIMEOUT_MS = 3e4;
8452
8589
  function createHeartbeatSink(deps) {
8453
8590
  const fetchImpl = deps.fetchImpl ?? fetch;
8454
8591
  return {
@@ -8463,21 +8600,35 @@ function createHeartbeatSink(deps) {
8463
8600
  try {
8464
8601
  token = await deps.getAuthToken();
8465
8602
  } catch {
8466
- return;
8603
+ throw new Error("mcp-heartbeat: no auth token (transient \u2014 will retry)");
8467
8604
  }
8468
8605
  if (!token)
8469
- return;
8470
- const res = await fetchImpl(`${deps.apiUrl}/v1/listeners/mcp-heartbeat`, {
8606
+ throw new Error("mcp-heartbeat: no auth token (transient \u2014 will retry)");
8607
+ const doPost = (bearer) => fetchImpl(`${deps.apiUrl}/v1/listeners/mcp-heartbeat`, {
8471
8608
  method: "POST",
8472
8609
  headers: {
8473
8610
  "Content-Type": "application/json",
8474
- Authorization: `Bearer ${token}`
8611
+ Authorization: `Bearer ${bearer}`
8475
8612
  },
8476
- body: JSON.stringify(payload)
8613
+ body: JSON.stringify(payload),
8614
+ signal: AbortSignal.timeout(HEARTBEAT_UPLOAD_TIMEOUT_MS)
8477
8615
  });
8478
- if (res && !res.ok) {
8479
- console.warn(`[mcp-heartbeat] upload rejected (HTTP ${res.status}) \u2014 possible payload/contract drift`);
8616
+ let res = await doPost(token);
8617
+ if (res.status === 401 && deps.getAuthTokenForceRefresh) {
8618
+ try {
8619
+ const fresh = await deps.getAuthTokenForceRefresh();
8620
+ if (fresh)
8621
+ res = await doPost(fresh);
8622
+ } catch {
8623
+ }
8624
+ }
8625
+ if (res.ok)
8626
+ return;
8627
+ const retryable = res.status >= 500 || res.status === 401 || res.status === 408 || res.status === 429;
8628
+ if (retryable) {
8629
+ throw new Error(`mcp-heartbeat: upload failed (HTTP ${res.status.toString()}) \u2014 will retry`);
8480
8630
  }
8631
+ console.warn(`[mcp-heartbeat] upload rejected (HTTP ${res.status.toString()}) \u2014 dropping (payload/contract or permission drift)`);
8481
8632
  }
8482
8633
  };
8483
8634
  }
@@ -8523,10 +8674,10 @@ async function ensureServerConsent(opts) {
8523
8674
  });
8524
8675
  if (!res.ok)
8525
8676
  return;
8526
- const fs31 = await import("fs/promises");
8677
+ const fs32 = await import("fs/promises");
8527
8678
  const path = await import("path");
8528
- await fs31.mkdir(path.dirname(opts.markerPath), { recursive: true });
8529
- await fs31.writeFile(opts.markerPath, (/* @__PURE__ */ new Date()).toISOString() + "\n", {
8679
+ await fs32.mkdir(path.dirname(opts.markerPath), { recursive: true });
8680
+ await fs32.writeFile(opts.markerPath, (/* @__PURE__ */ new Date()).toISOString() + "\n", {
8530
8681
  encoding: "utf-8",
8531
8682
  mode: 384
8532
8683
  });
@@ -8539,12 +8690,12 @@ import { homedir as homedir6 } from "os";
8539
8690
  import { basename as basename3 } from "path";
8540
8691
 
8541
8692
  // ../listener/dist/mcp/auto-config/writers/claude-code.js
8542
- import { promises as fs6 } from "fs";
8693
+ import { promises as fs7 } from "fs";
8543
8694
  import { join as join25 } from "path";
8544
8695
 
8545
8696
  // ../listener/dist/mcp/auto-config/markers.js
8546
- import { promises as fs5 } from "fs";
8547
- import { dirname as dirname15 } from "path";
8697
+ import { promises as fs6 } from "fs";
8698
+ import { dirname as dirname16 } from "path";
8548
8699
  function repoWiseServerName(ctx) {
8549
8700
  return `RepoWise MCP for ${ctx.repoName}${ctx.envSuffix ?? ""}`;
8550
8701
  }
@@ -8557,8 +8708,8 @@ async function writeMergedConfig(params) {
8557
8708
  const existing = safeExistingContent(params.path, current);
8558
8709
  if (existing === canonical)
8559
8710
  return "unchanged";
8560
- await fs5.mkdir(dirname15(params.path), { recursive: true });
8561
- await fs5.writeFile(params.path, canonical, "utf-8");
8711
+ await fs6.mkdir(dirname16(params.path), { recursive: true });
8712
+ await fs6.writeFile(params.path, canonical, "utf-8");
8562
8713
  return "written";
8563
8714
  }
8564
8715
  async function removeFromConfig(path, serverName) {
@@ -8571,11 +8722,11 @@ async function removeFromConfig(path, serverName) {
8571
8722
  if (Object.keys(servers).length === 0) {
8572
8723
  delete next.mcpServers;
8573
8724
  }
8574
- await fs5.writeFile(path, canonicalize(next), "utf-8");
8725
+ await fs6.writeFile(path, canonicalize(next), "utf-8");
8575
8726
  }
8576
8727
  async function readConfig(path) {
8577
8728
  try {
8578
- const raw = await fs5.readFile(path, "utf-8");
8729
+ const raw = await fs6.readFile(path, "utf-8");
8579
8730
  return JSON.parse(raw);
8580
8731
  } catch (err) {
8581
8732
  if (err.code === "ENOENT")
@@ -8643,7 +8794,7 @@ var claudeCodeWriter = {
8643
8794
  };
8644
8795
  async function fileExists2(path) {
8645
8796
  try {
8646
- await fs6.access(path);
8797
+ await fs7.access(path);
8647
8798
  return true;
8648
8799
  } catch {
8649
8800
  return false;
@@ -8654,7 +8805,7 @@ async function hasClaudeBinary(home) {
8654
8805
  }
8655
8806
 
8656
8807
  // ../listener/dist/mcp/auto-config/writers/claude-code-hooks.js
8657
- import { promises as fs7 } from "fs";
8808
+ import { promises as fs8 } from "fs";
8658
8809
  import { join as join26 } from "path";
8659
8810
  var claudeCodeHooksWriter = {
8660
8811
  tool: "claude-code-hooks",
@@ -8671,7 +8822,7 @@ var claudeCodeHooksWriter = {
8671
8822
  };
8672
8823
  async function fileExists3(path) {
8673
8824
  try {
8674
- await fs7.access(path);
8825
+ await fs8.access(path);
8675
8826
  return true;
8676
8827
  } catch {
8677
8828
  return false;
@@ -8679,7 +8830,7 @@ async function fileExists3(path) {
8679
8830
  }
8680
8831
 
8681
8832
  // ../listener/dist/mcp/auto-config/writers/cline.js
8682
- import { promises as fs8 } from "fs";
8833
+ import { promises as fs9 } from "fs";
8683
8834
  import { join as join27 } from "path";
8684
8835
  var clineWriter = {
8685
8836
  tool: "cline",
@@ -8704,7 +8855,7 @@ var clineWriter = {
8704
8855
  };
8705
8856
  async function fileExists4(path) {
8706
8857
  try {
8707
- await fs8.access(path);
8858
+ await fs9.access(path);
8708
8859
  return true;
8709
8860
  } catch {
8710
8861
  return false;
@@ -8712,7 +8863,7 @@ async function fileExists4(path) {
8712
8863
  }
8713
8864
 
8714
8865
  // ../listener/dist/mcp/auto-config/writers/cline-hooks.js
8715
- import { promises as fs9 } from "fs";
8866
+ import { promises as fs10 } from "fs";
8716
8867
  import { join as join28 } from "path";
8717
8868
  var SCRIPT_REL = ".clinerules/hooks/UserPromptSubmit";
8718
8869
  var OWNERSHIP_MARKER = "managed by RepoWise";
@@ -8746,8 +8897,8 @@ var clineHooksWriter = {
8746
8897
  await ensureExecutable(path);
8747
8898
  return { status: "unchanged", path };
8748
8899
  }
8749
- await fs9.mkdir(join28(ctx.repoRoot, ".clinerules", "hooks"), { recursive: true });
8750
- await fs9.writeFile(path, next, { encoding: "utf-8", mode: 493 });
8900
+ await fs10.mkdir(join28(ctx.repoRoot, ".clinerules", "hooks"), { recursive: true });
8901
+ await fs10.writeFile(path, next, { encoding: "utf-8", mode: 493 });
8751
8902
  await ensureExecutable(path);
8752
8903
  await applyGitignoreChanges(ctx.repoRoot, { add: [SCRIPT_REL] });
8753
8904
  return { status: "written", path };
@@ -8756,23 +8907,23 @@ var clineHooksWriter = {
8756
8907
  const path = join28(ctx.repoRoot, SCRIPT_REL);
8757
8908
  const existing = await readOrNull(path);
8758
8909
  if (existing !== null && existing.includes(OWNERSHIP_MARKER)) {
8759
- await fs9.unlink(path);
8910
+ await fs10.unlink(path);
8760
8911
  }
8761
8912
  await applyGitignoreChanges(ctx.repoRoot, { remove: [SCRIPT_REL] });
8762
8913
  }
8763
8914
  };
8764
8915
  async function ensureExecutable(path) {
8765
8916
  try {
8766
- const stat8 = await fs9.stat(path);
8917
+ const stat8 = await fs10.stat(path);
8767
8918
  if ((stat8.mode & 73) === 0) {
8768
- await fs9.chmod(path, 493);
8919
+ await fs10.chmod(path, 493);
8769
8920
  }
8770
8921
  } catch {
8771
8922
  }
8772
8923
  }
8773
8924
  async function fileExists5(path) {
8774
8925
  try {
8775
- await fs9.access(path);
8926
+ await fs10.access(path);
8776
8927
  return true;
8777
8928
  } catch {
8778
8929
  return false;
@@ -8780,14 +8931,14 @@ async function fileExists5(path) {
8780
8931
  }
8781
8932
  async function readOrNull(path) {
8782
8933
  try {
8783
- return await fs9.readFile(path, "utf-8");
8934
+ return await fs10.readFile(path, "utf-8");
8784
8935
  } catch {
8785
8936
  return null;
8786
8937
  }
8787
8938
  }
8788
8939
 
8789
8940
  // ../listener/dist/mcp/auto-config/writers/codex.js
8790
- import { promises as fs10 } from "fs";
8941
+ import { promises as fs11 } from "fs";
8791
8942
  import { join as join29 } from "path";
8792
8943
  var codexWriter = {
8793
8944
  tool: "codex",
@@ -8812,7 +8963,7 @@ var codexWriter = {
8812
8963
  };
8813
8964
  async function fileExists6(path) {
8814
8965
  try {
8815
- await fs10.access(path);
8966
+ await fs11.access(path);
8816
8967
  return true;
8817
8968
  } catch {
8818
8969
  return false;
@@ -8820,7 +8971,7 @@ async function fileExists6(path) {
8820
8971
  }
8821
8972
 
8822
8973
  // ../listener/dist/mcp/auto-config/writers/codex-hooks.js
8823
- import { promises as fs11 } from "fs";
8974
+ import { promises as fs12 } from "fs";
8824
8975
  import { join as join30 } from "path";
8825
8976
  var HOOKS_REL = ".codex/hooks.json";
8826
8977
  var codexHooksWriter = {
@@ -8851,8 +9002,8 @@ var codexHooksWriter = {
8851
9002
  if (merged === existing) {
8852
9003
  return { status: "unchanged", path };
8853
9004
  }
8854
- await fs11.mkdir(join30(ctx.repoRoot, ".codex"), { recursive: true });
8855
- await fs11.writeFile(path, merged, "utf-8");
9005
+ await fs12.mkdir(join30(ctx.repoRoot, ".codex"), { recursive: true });
9006
+ await fs12.writeFile(path, merged, "utf-8");
8856
9007
  await applyGitignoreChanges(ctx.repoRoot, { add: [HOOKS_REL] });
8857
9008
  return { status: "written", path };
8858
9009
  },
@@ -8862,9 +9013,9 @@ var codexHooksWriter = {
8862
9013
  if (existing !== null) {
8863
9014
  const next = removeCodexHookSettings(existing);
8864
9015
  if (next === null) {
8865
- await fs11.unlink(path);
9016
+ await fs12.unlink(path);
8866
9017
  } else if (next !== existing) {
8867
- await fs11.writeFile(path, next, "utf-8");
9018
+ await fs12.writeFile(path, next, "utf-8");
8868
9019
  }
8869
9020
  }
8870
9021
  await applyGitignoreChanges(ctx.repoRoot, { remove: [HOOKS_REL] });
@@ -8872,7 +9023,7 @@ var codexHooksWriter = {
8872
9023
  };
8873
9024
  async function fileExists7(path) {
8874
9025
  try {
8875
- await fs11.access(path);
9026
+ await fs12.access(path);
8876
9027
  return true;
8877
9028
  } catch {
8878
9029
  return false;
@@ -8880,14 +9031,14 @@ async function fileExists7(path) {
8880
9031
  }
8881
9032
  async function readOrNull2(path) {
8882
9033
  try {
8883
- return await fs11.readFile(path, "utf-8");
9034
+ return await fs12.readFile(path, "utf-8");
8884
9035
  } catch {
8885
9036
  return null;
8886
9037
  }
8887
9038
  }
8888
9039
 
8889
9040
  // ../listener/dist/mcp/auto-config/writers/copilot.js
8890
- import { promises as fs12 } from "fs";
9041
+ import { promises as fs13 } from "fs";
8891
9042
  import { join as join31 } from "path";
8892
9043
  var copilotWriter = {
8893
9044
  tool: "copilot",
@@ -8912,7 +9063,7 @@ var copilotWriter = {
8912
9063
  };
8913
9064
  async function fileExists8(path) {
8914
9065
  try {
8915
- await fs12.access(path);
9066
+ await fs13.access(path);
8916
9067
  return true;
8917
9068
  } catch {
8918
9069
  return false;
@@ -8920,7 +9071,7 @@ async function fileExists8(path) {
8920
9071
  }
8921
9072
 
8922
9073
  // ../listener/dist/mcp/auto-config/writers/copilot-hooks.js
8923
- import { promises as fs13 } from "fs";
9074
+ import { promises as fs14 } from "fs";
8924
9075
  import { join as join32 } from "path";
8925
9076
  var HOOKS_REL2 = ".github/hooks/repowise.json";
8926
9077
  var copilotHooksWriter = {
@@ -8949,8 +9100,8 @@ var copilotHooksWriter = {
8949
9100
  if (existing === next) {
8950
9101
  return { status: "unchanged", path };
8951
9102
  }
8952
- await fs13.mkdir(join32(ctx.repoRoot, ".github", "hooks"), { recursive: true });
8953
- await fs13.writeFile(path, next, "utf-8");
9103
+ await fs14.mkdir(join32(ctx.repoRoot, ".github", "hooks"), { recursive: true });
9104
+ await fs14.writeFile(path, next, "utf-8");
8954
9105
  const userSelected = ctx.selectedTools?.includes("copilot") ?? false;
8955
9106
  await applyGitignoreChanges(ctx.repoRoot, userSelected ? { remove: [HOOKS_REL2] } : { add: [HOOKS_REL2] });
8956
9107
  return { status: "written", path };
@@ -8958,7 +9109,7 @@ var copilotHooksWriter = {
8958
9109
  async remove(ctx) {
8959
9110
  const path = join32(ctx.repoRoot, HOOKS_REL2);
8960
9111
  if (!await isGitTracked(ctx.repoRoot, HOOKS_REL2)) {
8961
- await fs13.unlink(path).catch(() => {
9112
+ await fs14.unlink(path).catch(() => {
8962
9113
  });
8963
9114
  }
8964
9115
  await applyGitignoreChanges(ctx.repoRoot, { remove: [HOOKS_REL2] });
@@ -8966,7 +9117,7 @@ var copilotHooksWriter = {
8966
9117
  };
8967
9118
  async function fileExists9(path) {
8968
9119
  try {
8969
- await fs13.access(path);
9120
+ await fs14.access(path);
8970
9121
  return true;
8971
9122
  } catch {
8972
9123
  return false;
@@ -8974,14 +9125,14 @@ async function fileExists9(path) {
8974
9125
  }
8975
9126
  async function readOrNull3(path) {
8976
9127
  try {
8977
- return await fs13.readFile(path, "utf-8");
9128
+ return await fs14.readFile(path, "utf-8");
8978
9129
  } catch {
8979
9130
  return null;
8980
9131
  }
8981
9132
  }
8982
9133
 
8983
9134
  // ../listener/dist/mcp/auto-config/writers/cursor.js
8984
- import { promises as fs14 } from "fs";
9135
+ import { promises as fs15 } from "fs";
8985
9136
  import { join as join33 } from "path";
8986
9137
  var cursorWriter = {
8987
9138
  tool: "cursor",
@@ -9006,7 +9157,7 @@ var cursorWriter = {
9006
9157
  };
9007
9158
  async function fileExists10(path) {
9008
9159
  try {
9009
- await fs14.access(path);
9160
+ await fs15.access(path);
9010
9161
  return true;
9011
9162
  } catch {
9012
9163
  return false;
@@ -9014,7 +9165,7 @@ async function fileExists10(path) {
9014
9165
  }
9015
9166
 
9016
9167
  // ../listener/dist/mcp/auto-config/writers/gemini-cli.js
9017
- import { promises as fs15 } from "fs";
9168
+ import { promises as fs16 } from "fs";
9018
9169
  import { join as join34 } from "path";
9019
9170
  var geminiCliWriter = {
9020
9171
  tool: "gemini-cli",
@@ -9039,7 +9190,7 @@ var geminiCliWriter = {
9039
9190
  };
9040
9191
  async function fileExists11(path) {
9041
9192
  try {
9042
- await fs15.access(path);
9193
+ await fs16.access(path);
9043
9194
  return true;
9044
9195
  } catch {
9045
9196
  return false;
@@ -9047,7 +9198,7 @@ async function fileExists11(path) {
9047
9198
  }
9048
9199
 
9049
9200
  // ../listener/dist/mcp/auto-config/writers/gemini-hooks.js
9050
- import { promises as fs16 } from "fs";
9201
+ import { promises as fs17 } from "fs";
9051
9202
  import { join as join35 } from "path";
9052
9203
  var SETTINGS_REL = ".gemini/settings.json";
9053
9204
  var geminiHooksWriter = {
@@ -9078,8 +9229,8 @@ var geminiHooksWriter = {
9078
9229
  if (merged === existing) {
9079
9230
  return { status: "unchanged", path };
9080
9231
  }
9081
- await fs16.mkdir(join35(ctx.repoRoot, ".gemini"), { recursive: true });
9082
- await fs16.writeFile(path, merged, "utf-8");
9232
+ await fs17.mkdir(join35(ctx.repoRoot, ".gemini"), { recursive: true });
9233
+ await fs17.writeFile(path, merged, "utf-8");
9083
9234
  await applyGitignoreChanges(ctx.repoRoot, { add: [SETTINGS_REL] });
9084
9235
  return { status: "written", path };
9085
9236
  },
@@ -9089,9 +9240,9 @@ var geminiHooksWriter = {
9089
9240
  if (existing !== null) {
9090
9241
  const next = removeGeminiHookSettings(existing);
9091
9242
  if (next === null) {
9092
- await fs16.unlink(path);
9243
+ await fs17.unlink(path);
9093
9244
  } else if (next !== existing) {
9094
- await fs16.writeFile(path, next, "utf-8");
9245
+ await fs17.writeFile(path, next, "utf-8");
9095
9246
  }
9096
9247
  }
9097
9248
  await applyGitignoreChanges(ctx.repoRoot, { remove: [SETTINGS_REL] });
@@ -9099,7 +9250,7 @@ var geminiHooksWriter = {
9099
9250
  };
9100
9251
  async function fileExists12(path) {
9101
9252
  try {
9102
- await fs16.access(path);
9253
+ await fs17.access(path);
9103
9254
  return true;
9104
9255
  } catch {
9105
9256
  return false;
@@ -9107,14 +9258,14 @@ async function fileExists12(path) {
9107
9258
  }
9108
9259
  async function readOrNull4(path) {
9109
9260
  try {
9110
- return await fs16.readFile(path, "utf-8");
9261
+ return await fs17.readFile(path, "utf-8");
9111
9262
  } catch {
9112
9263
  return null;
9113
9264
  }
9114
9265
  }
9115
9266
 
9116
9267
  // ../listener/dist/mcp/auto-config/writers/roo.js
9117
- import { promises as fs17 } from "fs";
9268
+ import { promises as fs18 } from "fs";
9118
9269
  import { join as join36 } from "path";
9119
9270
  var rooWriter = {
9120
9271
  tool: "roo",
@@ -9145,7 +9296,7 @@ var rooWriter = {
9145
9296
  };
9146
9297
  async function fileExists13(path) {
9147
9298
  try {
9148
- await fs17.access(path);
9299
+ await fs18.access(path);
9149
9300
  return true;
9150
9301
  } catch {
9151
9302
  return false;
@@ -9153,14 +9304,14 @@ async function fileExists13(path) {
9153
9304
  }
9154
9305
  async function readOrNull5(path) {
9155
9306
  try {
9156
- return await fs17.readFile(path, "utf-8");
9307
+ return await fs18.readFile(path, "utf-8");
9157
9308
  } catch {
9158
9309
  return null;
9159
9310
  }
9160
9311
  }
9161
9312
 
9162
9313
  // ../listener/dist/mcp/auto-config/writers/windsurf.js
9163
- import { promises as fs18 } from "fs";
9314
+ import { promises as fs19 } from "fs";
9164
9315
  import { join as join37 } from "path";
9165
9316
  var windsurfWriter = {
9166
9317
  tool: "windsurf",
@@ -9185,7 +9336,7 @@ var windsurfWriter = {
9185
9336
  };
9186
9337
  async function fileExists14(path) {
9187
9338
  try {
9188
- await fs18.access(path);
9339
+ await fs19.access(path);
9189
9340
  return true;
9190
9341
  } catch {
9191
9342
  return false;
@@ -9260,7 +9411,7 @@ init_installer();
9260
9411
  // ../listener/dist/lsp/warm.js
9261
9412
  init_registry();
9262
9413
  init_lsp_tools();
9263
- import { promises as fs19 } from "fs";
9414
+ import { promises as fs20 } from "fs";
9264
9415
  import { join as join38 } from "path";
9265
9416
  async function collectRepresentativeFiles(repoRoot) {
9266
9417
  const reps = /* @__PURE__ */ new Map();
@@ -9271,7 +9422,7 @@ async function collectRepresentativeFiles(repoRoot) {
9271
9422
  return;
9272
9423
  let entries;
9273
9424
  try {
9274
- entries = await fs19.readdir(dir);
9425
+ entries = await fs20.readdir(dir);
9275
9426
  } catch {
9276
9427
  return;
9277
9428
  }
@@ -9293,7 +9444,7 @@ async function collectRepresentativeFiles(repoRoot) {
9293
9444
  await inspect(repoRoot, "");
9294
9445
  let topEntries = [];
9295
9446
  try {
9296
- topEntries = await fs19.readdir(repoRoot);
9447
+ topEntries = await fs20.readdir(repoRoot);
9297
9448
  } catch {
9298
9449
  return reps;
9299
9450
  }
@@ -9304,7 +9455,7 @@ async function collectRepresentativeFiles(repoRoot) {
9304
9455
  continue;
9305
9456
  const sub = join38(repoRoot, name);
9306
9457
  try {
9307
- const stat8 = await fs19.stat(sub);
9458
+ const stat8 = await fs20.stat(sub);
9308
9459
  if (stat8.isDirectory())
9309
9460
  await inspect(sub, name);
9310
9461
  } catch {
@@ -9318,7 +9469,7 @@ async function warmReposLsp(repos, workspaces, lspOverrides, isAvailable) {
9318
9469
  if (!repoRoot)
9319
9470
  continue;
9320
9471
  try {
9321
- const stat8 = await fs19.stat(repoRoot);
9472
+ const stat8 = await fs20.stat(repoRoot);
9322
9473
  if (!stat8.isDirectory())
9323
9474
  continue;
9324
9475
  } catch {
@@ -9347,7 +9498,7 @@ async function warmReposLsp(repos, workspaces, lspOverrides, isAvailable) {
9347
9498
 
9348
9499
  // ../listener/dist/lib/workspace-prep.js
9349
9500
  init_config_dir();
9350
- import { promises as fs20 } from "fs";
9501
+ import { promises as fs21 } from "fs";
9351
9502
  import { spawn as spawn9, execFile as execFile5 } from "child_process";
9352
9503
  import { createWriteStream as createWriteStream2 } from "fs";
9353
9504
  import { join as join39 } from "path";
@@ -9404,7 +9555,7 @@ async function maybeWriteClangdStub(repoRoot, repoId) {
9404
9555
  return;
9405
9556
  let ents;
9406
9557
  try {
9407
- ents = await fs20.readdir(dir, { withFileTypes: true });
9558
+ ents = await fs21.readdir(dir, { withFileTypes: true });
9408
9559
  } catch {
9409
9560
  return;
9410
9561
  }
@@ -9440,9 +9591,9 @@ async function maybeWriteClangdStub(repoRoot, repoId) {
9440
9591
  };
9441
9592
  });
9442
9593
  const outDir = join39(repoRoot, ".repowise");
9443
- await fs20.mkdir(outDir, { recursive: true });
9594
+ await fs21.mkdir(outDir, { recursive: true });
9444
9595
  const outPath = join39(outDir, "compile_commands.json");
9445
- await fs20.writeFile(outPath, JSON.stringify(entries, null, 2));
9596
+ await fs21.writeFile(outPath, JSON.stringify(entries, null, 2));
9446
9597
  const capHit = sources.length >= MAX_STUB_SOURCES;
9447
9598
  console.log(`[workspace-prep] ${repoId}: wrote ${entries.length.toString()}-entry compile_commands stub to .repowise/${capHit ? " (cap reached \u2014 additional sources truncated)" : ""}`);
9448
9599
  return true;
@@ -9450,7 +9601,7 @@ async function maybeWriteClangdStub(repoRoot, repoId) {
9450
9601
  var DEFAULT_TIMEOUT_MS = 10 * 60 * 1e3;
9451
9602
  async function fileExists15(repoRoot, name) {
9452
9603
  try {
9453
- await fs20.access(join39(repoRoot, name));
9604
+ await fs21.access(join39(repoRoot, name));
9454
9605
  return true;
9455
9606
  } catch {
9456
9607
  return false;
@@ -9461,7 +9612,7 @@ async function detectWorkspaceDeps(repoRoot) {
9461
9612
  if (await fileExists15(repoRoot, "package.json")) {
9462
9613
  let pkgRaw = "";
9463
9614
  try {
9464
- pkgRaw = await fs20.readFile(join39(repoRoot, "package.json"), "utf8");
9615
+ pkgRaw = await fs21.readFile(join39(repoRoot, "package.json"), "utf8");
9465
9616
  } catch {
9466
9617
  }
9467
9618
  if (pkgRaw) {
@@ -9565,7 +9716,7 @@ async function runWorkspacePreps(opts) {
9565
9716
  return [];
9566
9717
  const safeRepoId = opts.repoId.replace(/[^a-zA-Z0-9_-]/g, "_");
9567
9718
  const logPath2 = join39(getConfigDir(), `install-log.${safeRepoId}.txt`);
9568
- await fs20.mkdir(getConfigDir(), { recursive: true });
9719
+ await fs21.mkdir(getConfigDir(), { recursive: true });
9569
9720
  const stream = opts.logStream ?? createWriteStream2(logPath2, { flags: "a" });
9570
9721
  stream.on("error", () => {
9571
9722
  });
@@ -9808,7 +9959,7 @@ async function ensureIndexable(indexRoot, language, options = {}) {
9808
9959
  init_src();
9809
9960
  init_registry();
9810
9961
  import { execFile as execFileCb2 } from "child_process";
9811
- import { dirname as dirname16 } from "path";
9962
+ import { dirname as dirname17 } from "path";
9812
9963
  import { promisify as promisify5 } from "util";
9813
9964
  init_daemon_path();
9814
9965
 
@@ -10296,7 +10447,7 @@ async function isCommandOnPath4(command) {
10296
10447
  timeout: 5e3,
10297
10448
  env: {
10298
10449
  ...process.env,
10299
- PATH: buildLspSpawnPath(process.env.PATH, dirname16(process.execPath), managedBinDirs())
10450
+ PATH: buildLspSpawnPath(process.env.PATH, dirname17(process.execPath), managedBinDirs())
10300
10451
  }
10301
10452
  });
10302
10453
  return true;
@@ -10968,11 +11119,11 @@ function resolveAuditRoots() {
10968
11119
  return override.split(":").map((s) => s.trim()).filter(Boolean);
10969
11120
  }
10970
11121
  const out = /* @__PURE__ */ new Set();
10971
- let dir = dirname17(process.execPath);
11122
+ let dir = dirname18(process.execPath);
10972
11123
  for (let i = 0; i < 8; i += 1) {
10973
11124
  out.add(join42(dir, "node_modules"));
10974
11125
  out.add(join42(dir, "lib", "node_modules"));
10975
- const parent = dirname17(dir);
11126
+ const parent = dirname18(dir);
10976
11127
  if (parent === dir)
10977
11128
  break;
10978
11129
  dir = parent;
@@ -11038,8 +11189,8 @@ async function waitForCredentials(isRunning2) {
11038
11189
  let changed = false;
11039
11190
  let watcher = null;
11040
11191
  try {
11041
- const fs31 = await import("fs");
11042
- watcher = fs31.watch(getConfigDir(), (_event, filename) => {
11192
+ const fs32 = await import("fs");
11193
+ watcher = fs32.watch(getConfigDir(), (_event, filename) => {
11043
11194
  if (!filename || filename === "credentials.json")
11044
11195
  changed = true;
11045
11196
  });
@@ -11065,8 +11216,8 @@ async function waitForCredentialsOrTerminal(isRunning2) {
11065
11216
  let changed = false;
11066
11217
  let watcher = null;
11067
11218
  try {
11068
- const fs31 = await import("fs");
11069
- watcher = fs31.watch(getConfigDir(), (_event, filename) => {
11219
+ const fs32 = await import("fs");
11220
+ watcher = fs32.watch(getConfigDir(), (_event, filename) => {
11070
11221
  if (!filename || filename === "credentials.json")
11071
11222
  changed = true;
11072
11223
  });
@@ -11571,7 +11722,7 @@ async function startListener() {
11571
11722
  const packageName = true ? "repowisestage" : "repowise";
11572
11723
  let currentVersion = "";
11573
11724
  try {
11574
- const selfDir = dirname17(fileURLToPath3(import.meta.url));
11725
+ const selfDir = dirname18(fileURLToPath3(import.meta.url));
11575
11726
  const pkgJsonPath = join42(selfDir, "..", "..", "package.json");
11576
11727
  const pkgJson = JSON.parse(await readFile14(pkgJsonPath, "utf-8"));
11577
11728
  currentVersion = pkgJson.version;
@@ -12307,7 +12458,7 @@ async function showWelcome(currentVersion) {
12307
12458
 
12308
12459
  // src/commands/create.ts
12309
12460
  import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync3 } from "fs";
12310
- import { dirname as dirname19, join as join51 } from "path";
12461
+ import { dirname as dirname20, join as join51 } from "path";
12311
12462
  init_src();
12312
12463
  import chalk8 from "chalk";
12313
12464
  import ora from "ora";
@@ -12839,7 +12990,7 @@ async function writeToolConfigsForRepo(opts) {
12839
12990
 
12840
12991
  // src/lib/mcp-resolver.ts
12841
12992
  import { basename as basename4, join as join46 } from "path";
12842
- import { promises as fs21 } from "fs";
12993
+ import { promises as fs22 } from "fs";
12843
12994
  var MCP_WRITER_TOOLS = /* @__PURE__ */ new Set([
12844
12995
  "claude-code",
12845
12996
  "cursor",
@@ -12880,7 +13031,7 @@ function mcpConfigTargetForTool(tool, opts) {
12880
13031
  async function mcpConfigState(target) {
12881
13032
  let raw;
12882
13033
  try {
12883
- raw = await fs21.readFile(target.path, "utf-8");
13034
+ raw = await fs22.readFile(target.path, "utf-8");
12884
13035
  } catch {
12885
13036
  return "absent";
12886
13037
  }
@@ -12933,7 +13084,7 @@ function ensureGitignore(repoRoot, entry) {
12933
13084
  // src/lib/graph-cache.ts
12934
13085
  init_config_dir();
12935
13086
  import { mkdirSync, writeFileSync as writeFileSync2, renameSync, unlinkSync } from "fs";
12936
- import { dirname as dirname18, join as join48 } from "path";
13087
+ import { dirname as dirname19, join as join48 } from "path";
12937
13088
  var SAFE_REPO_ID = /^[A-Za-z0-9_.-]{1,128}$/;
12938
13089
  function assertSafeRepoId2(repoId) {
12939
13090
  if (!repoId || typeof repoId !== "string" || !SAFE_REPO_ID.test(repoId) || repoId === "." || repoId === ".." || repoId.startsWith(".")) {
@@ -13061,7 +13212,7 @@ async function ensureGraphDownloaded(opts) {
13061
13212
  return { status: "not_found", message: "EMPTY_GRAPH" };
13062
13213
  }
13063
13214
  try {
13064
- mkdirSync(dirname18(targetPath), { recursive: true });
13215
+ mkdirSync(dirname19(targetPath), { recursive: true });
13065
13216
  const tmp = `${targetPath}.${String(process.pid)}.${Math.random().toString(36).slice(2)}.tmp`;
13066
13217
  try {
13067
13218
  writeFileSync2(tmp, body, { encoding: "utf-8", mode: 384 });
@@ -13679,7 +13830,7 @@ async function promptDepInstallConsent(missing, opts) {
13679
13830
  import chalk6 from "chalk";
13680
13831
 
13681
13832
  // src/lib/dep-installer.ts
13682
- import { promises as fs22 } from "fs";
13833
+ import { promises as fs23 } from "fs";
13683
13834
  import { join as join49 } from "path";
13684
13835
  var SUPPORTED_DEP_LANGUAGES = /* @__PURE__ */ new Set([
13685
13836
  "typescript",
@@ -13690,7 +13841,7 @@ var SUPPORTED_DEP_LANGUAGES = /* @__PURE__ */ new Set([
13690
13841
  ]);
13691
13842
  var exists = async (p) => {
13692
13843
  try {
13693
- await fs22.access(p);
13844
+ await fs23.access(p);
13694
13845
  return true;
13695
13846
  } catch {
13696
13847
  return false;
@@ -13774,13 +13925,13 @@ async function detectMissingDeps(repoRoot, scopedLanguages) {
13774
13925
  // src/lib/dep-installer-runner.ts
13775
13926
  import { spawn as spawn11 } from "child_process";
13776
13927
  import { createWriteStream as createWriteStream3 } from "fs";
13777
- import { promises as fs23 } from "fs";
13928
+ import { promises as fs24 } from "fs";
13778
13929
  import { join as join50 } from "path";
13779
13930
  var DEFAULT_INSTALL_TIMEOUT_MS = 10 * 60 * 1e3;
13780
13931
  async function runMissingDepInstalls(opts) {
13781
13932
  const safeRepoId = opts.repoId.replace(/[^a-zA-Z0-9_-]/g, "_");
13782
13933
  const logPath2 = join50(getConfigDir2(), `install-log.${safeRepoId}.txt`);
13783
- await fs23.mkdir(getConfigDir2(), { recursive: true });
13934
+ await fs24.mkdir(getConfigDir2(), { recursive: true });
13784
13935
  const stream = opts.logStream ?? createWriteStream3(logPath2, { flags: "a" });
13785
13936
  stream.on("error", () => {
13786
13937
  });
@@ -14464,7 +14615,7 @@ async function create() {
14464
14615
  if (response.ok) {
14465
14616
  const content = await response.text();
14466
14617
  const filePath = join51(contextDir, file.fileName);
14467
- mkdirSync2(dirname19(filePath), { recursive: true });
14618
+ mkdirSync2(dirname20(filePath), { recursive: true });
14468
14619
  writeFileSync3(filePath, content, "utf-8");
14469
14620
  downloadedCount++;
14470
14621
  } else {
@@ -14692,7 +14843,7 @@ Files are stored on our servers (not in git). Retry when online.`
14692
14843
 
14693
14844
  // src/commands/member.ts
14694
14845
  import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync4 } from "fs";
14695
- import { dirname as dirname20, join as join52, resolve, sep } from "path";
14846
+ import { dirname as dirname21, join as join52, resolve, sep } from "path";
14696
14847
  import chalk9 from "chalk";
14697
14848
  import ora2 from "ora";
14698
14849
  var DEFAULT_CONTEXT_FOLDER2 = "repowise-context";
@@ -14867,7 +15018,7 @@ async function member() {
14867
15018
  const response = await fetch(presignedUrl);
14868
15019
  if (response.ok) {
14869
15020
  const content = await response.text();
14870
- mkdirSync3(dirname20(safePath), { recursive: true });
15021
+ mkdirSync3(dirname21(safePath), { recursive: true });
14871
15022
  writeFileSync4(safePath, content, "utf-8");
14872
15023
  downloadedCount++;
14873
15024
  } else {
@@ -15024,7 +15175,7 @@ import chalk10 from "chalk";
15024
15175
  import ora3 from "ora";
15025
15176
 
15026
15177
  // src/lib/tenant-graph-purge.ts
15027
- import { promises as fs24 } from "fs";
15178
+ import { promises as fs25 } from "fs";
15028
15179
  import { homedir as homedir8 } from "os";
15029
15180
  import { join as join53 } from "path";
15030
15181
  async function purgeForeignGraphs(validRepoIds, home = homedir8()) {
@@ -15032,7 +15183,7 @@ async function purgeForeignGraphs(validRepoIds, home = homedir8()) {
15032
15183
  const result = { kept: [], removed: [] };
15033
15184
  let entries;
15034
15185
  try {
15035
- entries = await fs24.readdir(graphsDir);
15186
+ entries = await fs25.readdir(graphsDir);
15036
15187
  } catch (err) {
15037
15188
  if (err.code === "ENOENT") return result;
15038
15189
  throw err;
@@ -15048,13 +15199,13 @@ async function purgeForeignGraphs(validRepoIds, home = homedir8()) {
15048
15199
  }
15049
15200
  const path = join53(graphsDir, entry);
15050
15201
  try {
15051
- const stat8 = await fs24.lstat(path);
15202
+ const stat8 = await fs25.lstat(path);
15052
15203
  if (stat8.isSymbolicLink()) {
15053
- await fs24.unlink(path);
15204
+ await fs25.unlink(path);
15054
15205
  result.removed.push(entry);
15055
15206
  continue;
15056
15207
  }
15057
- await fs24.rm(path, { recursive: true, force: true });
15208
+ await fs25.rm(path, { recursive: true, force: true });
15058
15209
  result.removed.push(entry);
15059
15210
  } catch {
15060
15211
  }
@@ -15254,7 +15405,7 @@ async function status() {
15254
15405
 
15255
15406
  // src/commands/sync.ts
15256
15407
  import { mkdirSync as mkdirSync4, writeFileSync as writeFileSync5 } from "fs";
15257
- import { dirname as dirname21, join as join55 } from "path";
15408
+ import { dirname as dirname22, join as join55 } from "path";
15258
15409
  import chalk12 from "chalk";
15259
15410
  import ora4 from "ora";
15260
15411
  var POLL_INTERVAL_MS2 = 3e3;
@@ -15420,7 +15571,7 @@ async function sync() {
15420
15571
  if (response.ok) {
15421
15572
  const content = await response.text();
15422
15573
  const filePath = join55(contextDir, file.fileName);
15423
- mkdirSync4(dirname21(filePath), { recursive: true });
15574
+ mkdirSync4(dirname22(filePath), { recursive: true });
15424
15575
  writeFileSync5(filePath, content, "utf-8");
15425
15576
  downloadedCount++;
15426
15577
  } else {
@@ -15823,7 +15974,7 @@ async function toolsList() {
15823
15974
  // src/commands/mcp-log.ts
15824
15975
  import { createDecipheriv as createDecipheriv2 } from "crypto";
15825
15976
  import { mkdir as mkdir19, readFile as readFile18, stat as stat7, writeFile as writeFile19 } from "fs/promises";
15826
- import { dirname as dirname22, join as join56 } from "path";
15977
+ import { dirname as dirname23, join as join56 } from "path";
15827
15978
  var FLAG_FILE = "mcp-log.flag";
15828
15979
  var LOG_FILE = "mcp-log.jsonl.enc";
15829
15980
  var KEY_FILE = "mcp-log.key";
@@ -15838,7 +15989,7 @@ function logPath() {
15838
15989
  }
15839
15990
  async function writeFlag(flag) {
15840
15991
  const path = flagPath();
15841
- await mkdir19(dirname22(path), { recursive: true });
15992
+ await mkdir19(dirname23(path), { recursive: true });
15842
15993
  await writeFile19(path, JSON.stringify(flag, null, 2), { encoding: "utf-8", mode: 384 });
15843
15994
  }
15844
15995
  async function mcpLogOn() {
@@ -16103,7 +16254,7 @@ async function mcpLog(subcommand, flags = {}) {
16103
16254
  import chalk15 from "chalk";
16104
16255
 
16105
16256
  // src/lib/graph-loader.ts
16106
- import { promises as fs25 } from "fs";
16257
+ import { promises as fs26 } from "fs";
16107
16258
  import { join as join57, resolve as resolve2 } from "path";
16108
16259
  import { gunzipSync } from "zlib";
16109
16260
  var RELATIVE_GRAPH_PATH = "repowise-context/.meta/dependency-graph.json";
@@ -16130,14 +16281,14 @@ async function loadGraph(repoRoot = process.cwd()) {
16130
16281
  let graphPath = null;
16131
16282
  let raw = null;
16132
16283
  try {
16133
- raw = await fs25.readFile(gzPath);
16284
+ raw = await fs26.readFile(gzPath);
16134
16285
  graphPath = gzPath;
16135
16286
  } catch (err) {
16136
16287
  if (err.code !== "ENOENT") throw err;
16137
16288
  }
16138
16289
  if (!raw) {
16139
16290
  try {
16140
- raw = await fs25.readFile(plainPath);
16291
+ raw = await fs26.readFile(plainPath);
16141
16292
  graphPath = plainPath;
16142
16293
  } catch (err) {
16143
16294
  if (err.code === "ENOENT") {
@@ -16536,13 +16687,13 @@ function registerQueryCommand(program2) {
16536
16687
  }
16537
16688
 
16538
16689
  // src/commands/uninstall.ts
16539
- import { promises as fs29 } from "fs";
16690
+ import { promises as fs30 } from "fs";
16540
16691
  import { homedir as homedir12 } from "os";
16541
16692
  import { join as join61 } from "path";
16542
16693
  import chalk16 from "chalk";
16543
16694
 
16544
16695
  // src/lib/cleanup/marker-blocks.ts
16545
- import { promises as fs26 } from "fs";
16696
+ import { promises as fs27 } from "fs";
16546
16697
  import { join as join58 } from "path";
16547
16698
  var MARKER_START = "<!-- repowise-start -->";
16548
16699
  var MARKER_END = "<!-- repowise-end -->";
@@ -16559,7 +16710,7 @@ var CONTEXT_FILES = [
16559
16710
  async function stripMarkerBlock(filePath) {
16560
16711
  let raw;
16561
16712
  try {
16562
- raw = await fs26.readFile(filePath, "utf-8");
16713
+ raw = await fs27.readFile(filePath, "utf-8");
16563
16714
  } catch (err) {
16564
16715
  if (err.code === "ENOENT")
16565
16716
  return { path: filePath, status: "missing" };
@@ -16574,10 +16725,10 @@ async function stripMarkerBlock(filePath) {
16574
16725
  const after = raw.slice(endIdx + MARKER_END.length).replace(/^\n+/, "");
16575
16726
  const stripped = (before + (before && after ? "\n\n" : "") + after).trim();
16576
16727
  if (stripped.length === 0) {
16577
- await fs26.unlink(filePath);
16728
+ await fs27.unlink(filePath);
16578
16729
  return { path: filePath, status: "deleted" };
16579
16730
  }
16580
- await fs26.writeFile(filePath, stripped + "\n", "utf-8");
16731
+ await fs27.writeFile(filePath, stripped + "\n", "utf-8");
16581
16732
  return { path: filePath, status: "stripped" };
16582
16733
  }
16583
16734
  async function stripAllMarkerBlocks(repoRoot) {
@@ -16595,7 +16746,7 @@ async function stripAllMarkerBlocks(repoRoot) {
16595
16746
  }
16596
16747
 
16597
16748
  // src/lib/cleanup/mcp-configs.ts
16598
- import { promises as fs27 } from "fs";
16749
+ import { promises as fs28 } from "fs";
16599
16750
  import { join as join59 } from "path";
16600
16751
  function mcpConfigPaths(repoRoot, home) {
16601
16752
  return [
@@ -16613,7 +16764,7 @@ function mcpConfigPaths(repoRoot, home) {
16613
16764
  async function removeRepowiseFromConfig(path, serverName) {
16614
16765
  let raw;
16615
16766
  try {
16616
- raw = await fs27.readFile(path, "utf-8");
16767
+ raw = await fs28.readFile(path, "utf-8");
16617
16768
  } catch (err) {
16618
16769
  if (err.code === "ENOENT") return { path, status: "not-found" };
16619
16770
  return { path, status: "error", error: err.message };
@@ -16633,7 +16784,7 @@ async function removeRepowiseFromConfig(path, serverName) {
16633
16784
  } else {
16634
16785
  next.mcpServers = servers;
16635
16786
  }
16636
- await fs27.writeFile(path, JSON.stringify(next, null, 2) + "\n", "utf-8");
16787
+ await fs28.writeFile(path, JSON.stringify(next, null, 2) + "\n", "utf-8");
16637
16788
  return { path, status: "removed" };
16638
16789
  }
16639
16790
  async function removeAllMcpEntries(repoRoot, home, repoId) {
@@ -16646,7 +16797,7 @@ async function removeAllMcpEntries(repoRoot, home, repoId) {
16646
16797
  }
16647
16798
 
16648
16799
  // src/lib/cleanup/local-state.ts
16649
- import { promises as fs28 } from "fs";
16800
+ import { promises as fs29 } from "fs";
16650
16801
  import { homedir as homedir11 } from "os";
16651
16802
  import { join as join60, resolve as resolve3 } from "path";
16652
16803
  async function clearLocalState(homeOverride) {
@@ -16656,7 +16807,7 @@ async function clearLocalState(homeOverride) {
16656
16807
  return { path: target, status: "error", error: "refused: not under home" };
16657
16808
  }
16658
16809
  try {
16659
- await fs28.rm(target, { recursive: true, force: false });
16810
+ await fs29.rm(target, { recursive: true, force: false });
16660
16811
  return { path: target, status: "removed" };
16661
16812
  } catch (err) {
16662
16813
  if (err.code === "ENOENT")
@@ -16695,7 +16846,7 @@ async function uninstall2(opts = {}) {
16695
16846
  else if (svc.error) report.skipped.push({ path: "listener service", reason: svc.error });
16696
16847
  if (tier === "stop") return report;
16697
16848
  try {
16698
- await fs29.unlink(join61(home, ".repowise", "credentials.json"));
16849
+ await fs30.unlink(join61(home, ".repowise", "credentials.json"));
16699
16850
  report.removed.push("credentials");
16700
16851
  } catch (err) {
16701
16852
  if (err.code !== "ENOENT") {
@@ -16722,7 +16873,7 @@ async function uninstall2(opts = {}) {
16722
16873
  const allPaths = mcpConfigPaths(repoRoot, home);
16723
16874
  for (const p of allPaths) {
16724
16875
  try {
16725
- await fs29.access(p);
16876
+ await fs30.access(p);
16726
16877
  } catch {
16727
16878
  }
16728
16879
  }
@@ -16734,7 +16885,7 @@ async function uninstall2(opts = {}) {
16734
16885
  }
16735
16886
  async function defaultLoadRepoIds(home) {
16736
16887
  try {
16737
- const raw = await fs29.readFile(join61(home, ".repowise", "config.json"), "utf-8");
16888
+ const raw = await fs30.readFile(join61(home, ".repowise", "config.json"), "utf-8");
16738
16889
  const parsed = JSON.parse(raw);
16739
16890
  return (parsed.repos ?? []).map((r) => r.repoId);
16740
16891
  } catch {
@@ -16781,7 +16932,7 @@ Done \u2014 ${report.removed.length} removed, ${report.skipped.length} skipped.
16781
16932
 
16782
16933
  // src/commands/mcp-shim.ts
16783
16934
  init_config_dir();
16784
- import { promises as fs30 } from "fs";
16935
+ import { promises as fs31 } from "fs";
16785
16936
  import { createInterface as createInterface2 } from "readline";
16786
16937
  import { join as join62 } from "path";
16787
16938
  var DEFAULT_MAX = 200 * 1024;
@@ -16896,7 +17047,7 @@ function isConnectionError(err) {
16896
17047
  }
16897
17048
  async function readEndpoint(path) {
16898
17049
  try {
16899
- const raw = (await fs30.readFile(path, "utf-8")).trim();
17050
+ const raw = (await fs31.readFile(path, "utf-8")).trim();
16900
17051
  if (!raw) return null;
16901
17052
  if (raw.startsWith("http://") || raw.startsWith("https://")) {
16902
17053
  return { endpoint: raw.split("\n")[0].trim(), secret: null };
@@ -16917,7 +17068,7 @@ async function readEndpoint(path) {
16917
17068
  async function readAuthState(credsPath) {
16918
17069
  let raw;
16919
17070
  try {
16920
- raw = await fs30.readFile(credsPath, "utf-8");
17071
+ raw = await fs31.readFile(credsPath, "utf-8");
16921
17072
  } catch (err) {
16922
17073
  if (err.code === "ENOENT") return "logged-out";
16923
17074
  return "unknown";
@@ -17592,7 +17743,7 @@ async function lspOn() {
17592
17743
 
17593
17744
  // bin/repowise.ts
17594
17745
  var __filename = fileURLToPath4(import.meta.url);
17595
- var __dirname = dirname23(__filename);
17746
+ var __dirname = dirname24(__filename);
17596
17747
  var pkg = JSON.parse(readFileSync3(join63(__dirname, "..", "..", "package.json"), "utf-8"));
17597
17748
  var program = new Command();
17598
17749
  program.name(getPackageName()).description("AI-optimized codebase context generator").version(pkg.version).hook("preAction", async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repowisestage",
3
- "version": "0.0.76",
3
+ "version": "0.0.78",
4
4
  "type": "module",
5
5
  "description": "AI-optimized codebase context generator",
6
6
  "bin": {