repowisestage 0.0.55 → 0.0.57

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.
@@ -2294,7 +2294,7 @@ __export(sidecar_cache_exports, {
2294
2294
  sidecarCachePaths: () => sidecarCachePaths
2295
2295
  });
2296
2296
  import { mkdir as mkdir8, readFile as readFile7, readdir as readdir3, stat as stat2, unlink as unlink7, writeFile as writeFile8 } from "fs/promises";
2297
- import { dirname as dirname7, join as join18 } from "path";
2297
+ import { dirname as dirname8, join as join18 } from "path";
2298
2298
  function repoIdSafe(repoId) {
2299
2299
  return /^[A-Za-z0-9_.-]{1,128}$/.test(repoId) && !repoId.startsWith(".");
2300
2300
  }
@@ -3000,13 +3000,13 @@ var init_telemetry = __esm({
3000
3000
  // bin/repowise.ts
3001
3001
  import { readFileSync as readFileSync3 } from "fs";
3002
3002
  import { fileURLToPath as fileURLToPath4 } from "url";
3003
- import { dirname as dirname19, join as join52 } from "path";
3003
+ import { dirname as dirname20, join as join52 } from "path";
3004
3004
  import { Command } from "commander";
3005
3005
 
3006
3006
  // ../listener/dist/main.js
3007
3007
  init_config_dir();
3008
3008
  import { readFile as readFile12, writeFile as writeFile14, mkdir as mkdir14, stat as fsStat } from "fs/promises";
3009
- import { join as join32, dirname as dirname14 } from "path";
3009
+ import { join as join32, dirname as dirname15 } from "path";
3010
3010
  import { fileURLToPath as fileURLToPath3 } from "url";
3011
3011
  import lockfile4 from "proper-lockfile";
3012
3012
 
@@ -4331,7 +4331,7 @@ import { join as join21 } from "path";
4331
4331
  // ../listener/dist/lsp/workspace-session.js
4332
4332
  import { pathToFileURL } from "url";
4333
4333
  import { readFile as readFile6 } from "fs/promises";
4334
- import { resolve as pathResolve2, sep as pathSep } from "path";
4334
+ import { resolve as pathResolve2, sep as pathSep, dirname as dirname7 } from "path";
4335
4335
 
4336
4336
  // ../listener/dist/lsp/lsp-client.js
4337
4337
  import { spawn as spawn2 } from "child_process";
@@ -4665,12 +4665,13 @@ var WorkspaceManager = class {
4665
4665
  this.rssSampler = opts.rssSampler ?? (() => process.memoryUsage().rss);
4666
4666
  this.clientFactory = opts.clientFactory ?? ((config2, cwd) => {
4667
4667
  const env = { ...process.env };
4668
- const npmBin = getLspBinDir();
4669
- const nativeBin = getNativeLspBinDir();
4670
- const coursierBin = getCoursierBinDir();
4671
- const toolchainBins = getToolchainBinDirs();
4672
- const extraPaths = [npmBin, nativeBin, coursierBin, ...toolchainBins].join(":");
4673
- env.PATH = env.PATH ? `${env.PATH}:${extraPaths}` : extraPaths;
4668
+ const lspBinDirs = [
4669
+ getLspBinDir(),
4670
+ getNativeLspBinDir(),
4671
+ getCoursierBinDir(),
4672
+ ...getToolchainBinDirs()
4673
+ ];
4674
+ env.PATH = buildLspSpawnPath(env.PATH, dirname7(process.execPath), lspBinDirs);
4674
4675
  const client = new LspClient({
4675
4676
  command: config2.command,
4676
4677
  args: config2.args,
@@ -4706,7 +4707,11 @@ var WorkspaceManager = class {
4706
4707
  */
4707
4708
  async getOrOpen(args) {
4708
4709
  const key = keyOf(args);
4709
- const existing = this.sessions.get(key);
4710
+ let existing = this.sessions.get(key);
4711
+ if (existing && !existing.client.isAlive()) {
4712
+ this.sessions.delete(key);
4713
+ existing = void 0;
4714
+ }
4710
4715
  if (existing) {
4711
4716
  existing.lastUsedAt = this.now();
4712
4717
  if (existing.ready)
@@ -4744,8 +4749,8 @@ var WorkspaceManager = class {
4744
4749
  if (!existing) {
4745
4750
  this.sessions.set(key, session);
4746
4751
  session.client.on("close", () => {
4747
- if (session.ready) {
4748
- session.ready = false;
4752
+ session.ready = false;
4753
+ if (this.sessions.get(key) === session) {
4749
4754
  this.sessions.delete(key);
4750
4755
  }
4751
4756
  });
@@ -5034,6 +5039,10 @@ var PathEscapeError = class extends Error {
5034
5039
  this.name = "PathEscapeError";
5035
5040
  }
5036
5041
  };
5042
+ function buildLspSpawnPath(basePath, nodeDir, lspBinDirs) {
5043
+ const extra = lspBinDirs.join(":");
5044
+ return basePath ? `${nodeDir}:${basePath}:${extra}` : `${nodeDir}:${extra}`;
5045
+ }
5037
5046
 
5038
5047
  // ../listener/dist/mcp/graph-cache.js
5039
5048
  init_config_dir();
@@ -5147,7 +5156,7 @@ function defaultRepoWiseHome() {
5147
5156
 
5148
5157
  // ../listener/dist/mcp/graph-downloader.js
5149
5158
  import { mkdir as mkdir9, rename as rename3, writeFile as writeFile9 } from "fs/promises";
5150
- import { dirname as dirname8 } from "path";
5159
+ import { dirname as dirname9 } from "path";
5151
5160
  function createGraphDownloader(options) {
5152
5161
  const fetchFn = options.fetchImpl ?? fetch;
5153
5162
  let lastSha = null;
@@ -5198,7 +5207,7 @@ function createGraphDownloader(options) {
5198
5207
  message: `graph parse: ${err instanceof Error ? err.message : String(err)}`
5199
5208
  };
5200
5209
  }
5201
- await mkdir9(dirname8(options.targetPath), { recursive: true });
5210
+ await mkdir9(dirname9(options.targetPath), { recursive: true });
5202
5211
  const tmpPath = `${options.targetPath}.${Date.now()}.tmp`;
5203
5212
  await writeFile9(tmpPath, body, { encoding: "utf-8", mode: 384 });
5204
5213
  await rename3(tmpPath, options.targetPath);
@@ -5224,7 +5233,7 @@ function createGraphDownloader(options) {
5224
5233
  // ../listener/dist/mcp/log-encryption.js
5225
5234
  import { createCipheriv, createDecipheriv, randomBytes } from "crypto";
5226
5235
  import { mkdir as mkdir10, readFile as readFile9, stat as stat4, writeFile as writeFile10 } from "fs/promises";
5227
- import { dirname as dirname9 } from "path";
5236
+ import { dirname as dirname10 } from "path";
5228
5237
  var KEY_BYTES = 32;
5229
5238
  var IV_BYTES = 12;
5230
5239
  var TAG_BYTES = 16;
@@ -5271,7 +5280,7 @@ function createFileKeyStore(keyPath) {
5271
5280
  return parsed;
5272
5281
  }
5273
5282
  const fresh = randomBytes(KEY_BYTES);
5274
- await mkdir10(dirname9(keyPath), { recursive: true });
5283
+ await mkdir10(dirname10(keyPath), { recursive: true });
5275
5284
  const tmp = `${keyPath}.tmp`;
5276
5285
  await writeFile10(tmp, fresh.toString("base64") + "\n", {
5277
5286
  encoding: "utf-8",
@@ -5313,7 +5322,7 @@ function decryptLine(encoded, key) {
5313
5322
 
5314
5323
  // ../listener/dist/mcp/mcp-logger.js
5315
5324
  import { appendFile, mkdir as mkdir11, stat as stat5, unlink as unlink8, writeFile as writeFile11, readFile as readFile10 } from "fs/promises";
5316
- import { dirname as dirname10 } from "path";
5325
+ import { dirname as dirname11 } from "path";
5317
5326
  var DEFAULT_MAX_BYTES = 100 * 1024 * 1024;
5318
5327
  function createMcpLogger(options) {
5319
5328
  const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
@@ -5336,7 +5345,7 @@ function createMcpLogger(options) {
5336
5345
  await migrateLegacyPlaintext();
5337
5346
  const key = await options.keyStore.getKey();
5338
5347
  const encoded = encryptLine(JSON.stringify(entry), key) + "\n";
5339
- await mkdir11(dirname10(options.filePath), { recursive: true });
5348
+ await mkdir11(dirname11(options.filePath), { recursive: true });
5340
5349
  await appendFile(options.filePath, encoded, { encoding: "utf-8", mode: 384 });
5341
5350
  try {
5342
5351
  const s = await stat5(options.filePath);
@@ -5370,7 +5379,7 @@ async function rotate(path, size) {
5370
5379
  // ../listener/dist/mcp/mcp-log-uploader.js
5371
5380
  import { randomUUID } from "crypto";
5372
5381
  import { readFile as readFile11, writeFile as writeFile12, mkdir as mkdir12 } from "fs/promises";
5373
- import { dirname as dirname11 } from "path";
5382
+ import { dirname as dirname12 } from "path";
5374
5383
  var DEFAULT_MAX_ENTRIES = 5e3;
5375
5384
  var DEFAULT_MAX_BYTES2 = 1 * 1024 * 1024;
5376
5385
  function createMcpLogUploader(options) {
@@ -5520,7 +5529,7 @@ async function readPendingBatch(watermarkPath) {
5520
5529
  }
5521
5530
  }
5522
5531
  async function writePendingBatch(watermarkPath, batchId) {
5523
- await mkdir12(dirname11(watermarkPath), { recursive: true });
5532
+ await mkdir12(dirname12(watermarkPath), { recursive: true });
5524
5533
  await writeFile12(pendingPath(watermarkPath), batchId, { encoding: "utf-8", mode: 384 });
5525
5534
  }
5526
5535
  async function clearPendingBatch(watermarkPath) {
@@ -5542,7 +5551,7 @@ async function readWatermark(path) {
5542
5551
  }
5543
5552
  }
5544
5553
  async function writeWatermark(path, offset) {
5545
- await mkdir12(dirname11(path), { recursive: true });
5554
+ await mkdir12(dirname12(path), { recursive: true });
5546
5555
  const tmp = `${path}.tmp`;
5547
5556
  await writeFile12(tmp, offset.toString() + "\n", { encoding: "utf-8", mode: 384 });
5548
5557
  const { rename: rename5 } = await import("fs/promises");
@@ -5562,7 +5571,7 @@ async function isLocallyConsented(flagPath2) {
5562
5571
  init_config_dir();
5563
5572
  import { createServer } from "http";
5564
5573
  import { mkdir as mkdir13, writeFile as writeFile13 } from "fs/promises";
5565
- import { dirname as dirname12, join as join20 } from "path";
5574
+ import { dirname as dirname13, join as join20 } from "path";
5566
5575
  import { createHash as createHash3, randomUUID as randomUUID2 } from "crypto";
5567
5576
 
5568
5577
  // ../listener/dist/mcp/sanitize.js
@@ -7080,7 +7089,7 @@ async function readJson(req) {
7080
7089
  }
7081
7090
  }
7082
7091
  async function writeEndpointFile(path, endpoint, secret) {
7083
- await mkdir13(dirname12(path), { recursive: true });
7092
+ await mkdir13(dirname13(path), { recursive: true });
7084
7093
  await writeFile13(path, formatEndpointFile({ endpoint, secret }), {
7085
7094
  encoding: "utf-8",
7086
7095
  mode: 384
@@ -7345,7 +7354,7 @@ import { join as join22 } from "path";
7345
7354
 
7346
7355
  // ../listener/dist/mcp/auto-config/markers.js
7347
7356
  import { promises as fs5 } from "fs";
7348
- import { dirname as dirname13 } from "path";
7357
+ import { dirname as dirname14 } from "path";
7349
7358
  async function writeMergedConfig(params) {
7350
7359
  const current = await readConfig(params.path);
7351
7360
  const servers = { ...current.mcpServers ?? {} };
@@ -7355,7 +7364,7 @@ async function writeMergedConfig(params) {
7355
7364
  const existing = safeExistingContent(params.path, current);
7356
7365
  if (existing === canonical)
7357
7366
  return "unchanged";
7358
- await fs5.mkdir(dirname13(params.path), { recursive: true });
7367
+ await fs5.mkdir(dirname14(params.path), { recursive: true });
7359
7368
  await fs5.writeFile(params.path, canonical, "utf-8");
7360
7369
  return "written";
7361
7370
  }
@@ -8999,11 +9008,11 @@ function resolveAuditRoots() {
8999
9008
  return override.split(":").map((s) => s.trim()).filter(Boolean);
9000
9009
  }
9001
9010
  const out = /* @__PURE__ */ new Set();
9002
- let dir = dirname14(process.execPath);
9011
+ let dir = dirname15(process.execPath);
9003
9012
  for (let i = 0; i < 8; i += 1) {
9004
9013
  out.add(join32(dir, "node_modules"));
9005
9014
  out.add(join32(dir, "lib", "node_modules"));
9006
- const parent = dirname14(dir);
9015
+ const parent = dirname15(dir);
9007
9016
  if (parent === dir)
9008
9017
  break;
9009
9018
  dir = parent;
@@ -9452,7 +9461,7 @@ async function startListener() {
9452
9461
  const packageName = true ? "repowisestage" : "repowise";
9453
9462
  let currentVersion = "";
9454
9463
  try {
9455
- const selfDir = dirname14(fileURLToPath3(import.meta.url));
9464
+ const selfDir = dirname15(fileURLToPath3(import.meta.url));
9456
9465
  const pkgJsonPath = join32(selfDir, "..", "..", "package.json");
9457
9466
  const pkgJson = JSON.parse(await readFile12(pkgJsonPath, "utf-8"));
9458
9467
  currentVersion = pkgJson.version;
@@ -9667,6 +9676,8 @@ async function startListener() {
9667
9676
  const freshConfig = await getListenerConfig();
9668
9677
  config2.repos = freshConfig.repos;
9669
9678
  config2.lspOverrides = freshConfig.lspOverrides;
9679
+ config2.lspEnabled = freshConfig.lspEnabled;
9680
+ config2.lspAutoWarm = freshConfig.lspAutoWarm;
9670
9681
  } catch {
9671
9682
  }
9672
9683
  }
@@ -10052,7 +10063,7 @@ async function showWelcome(currentVersion) {
10052
10063
 
10053
10064
  // src/commands/create.ts
10054
10065
  import { mkdirSync, writeFileSync as writeFileSync2 } from "fs";
10055
- import { dirname as dirname15, join as join40 } from "path";
10066
+ import { dirname as dirname16, join as join40 } from "path";
10056
10067
  init_src();
10057
10068
  import chalk8 from "chalk";
10058
10069
  import ora from "ora";
@@ -11685,7 +11696,7 @@ async function create() {
11685
11696
  if (response.ok) {
11686
11697
  const content = await response.text();
11687
11698
  const filePath = join40(contextDir, file.fileName);
11688
- mkdirSync(dirname15(filePath), { recursive: true });
11699
+ mkdirSync(dirname16(filePath), { recursive: true });
11689
11700
  writeFileSync2(filePath, content, "utf-8");
11690
11701
  downloadedCount++;
11691
11702
  } else {
@@ -11887,7 +11898,7 @@ Files are stored on our servers (not in git). Retry when online.`
11887
11898
 
11888
11899
  // src/commands/member.ts
11889
11900
  import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync3 } from "fs";
11890
- import { dirname as dirname16, join as join41, resolve, sep } from "path";
11901
+ import { dirname as dirname17, join as join41, resolve, sep } from "path";
11891
11902
  import chalk9 from "chalk";
11892
11903
  import ora2 from "ora";
11893
11904
  var DEFAULT_CONTEXT_FOLDER2 = "repowise-context";
@@ -12062,7 +12073,7 @@ async function member() {
12062
12073
  const response = await fetch(presignedUrl);
12063
12074
  if (response.ok) {
12064
12075
  const content = await response.text();
12065
- mkdirSync2(dirname16(safePath), { recursive: true });
12076
+ mkdirSync2(dirname17(safePath), { recursive: true });
12066
12077
  writeFileSync3(safePath, content, "utf-8");
12067
12078
  downloadedCount++;
12068
12079
  } else {
@@ -12406,7 +12417,7 @@ async function status() {
12406
12417
 
12407
12418
  // src/commands/sync.ts
12408
12419
  import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync4 } from "fs";
12409
- import { dirname as dirname17, join as join44 } from "path";
12420
+ import { dirname as dirname18, join as join44 } from "path";
12410
12421
  import chalk12 from "chalk";
12411
12422
  import ora4 from "ora";
12412
12423
  var POLL_INTERVAL_MS2 = 3e3;
@@ -12570,7 +12581,7 @@ async function sync() {
12570
12581
  if (response.ok) {
12571
12582
  const content = await response.text();
12572
12583
  const filePath = join44(contextDir, file.fileName);
12573
- mkdirSync3(dirname17(filePath), { recursive: true });
12584
+ mkdirSync3(dirname18(filePath), { recursive: true });
12574
12585
  writeFileSync4(filePath, content, "utf-8");
12575
12586
  downloadedCount++;
12576
12587
  } else {
@@ -12822,7 +12833,7 @@ async function config() {
12822
12833
  // src/commands/mcp-log.ts
12823
12834
  import { createDecipheriv as createDecipheriv2 } from "crypto";
12824
12835
  import { mkdir as mkdir18, readFile as readFile17, stat as stat6, writeFile as writeFile18 } from "fs/promises";
12825
- import { dirname as dirname18, join as join45 } from "path";
12836
+ import { dirname as dirname19, join as join45 } from "path";
12826
12837
  var FLAG_FILE = "mcp-log.flag";
12827
12838
  var LOG_FILE = "mcp-log.jsonl.enc";
12828
12839
  var KEY_FILE = "mcp-log.key";
@@ -12837,7 +12848,7 @@ function logPath() {
12837
12848
  }
12838
12849
  async function writeFlag(flag) {
12839
12850
  const path = flagPath();
12840
- await mkdir18(dirname18(path), { recursive: true });
12851
+ await mkdir18(dirname19(path), { recursive: true });
12841
12852
  await writeFile18(path, JSON.stringify(flag, null, 2), { encoding: "utf-8", mode: 384 });
12842
12853
  }
12843
12854
  async function mcpLogOn() {
@@ -14532,7 +14543,7 @@ async function lspOn() {
14532
14543
 
14533
14544
  // bin/repowise.ts
14534
14545
  var __filename = fileURLToPath4(import.meta.url);
14535
- var __dirname = dirname19(__filename);
14546
+ var __dirname = dirname20(__filename);
14536
14547
  var pkg = JSON.parse(readFileSync3(join52(__dirname, "..", "..", "package.json"), "utf-8"));
14537
14548
  var program = new Command();
14538
14549
  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.55",
3
+ "version": "0.0.57",
4
4
  "type": "module",
5
5
  "description": "AI-optimized codebase context generator",
6
6
  "bin": {