repowisestage 0.0.1-staging.8 → 0.0.16

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.
@@ -2,14 +2,15 @@
2
2
 
3
3
  // bin/repowise.ts
4
4
  import { readFileSync as readFileSync2 } from "fs";
5
- import { fileURLToPath as fileURLToPath2 } from "url";
6
- import { dirname as dirname7, join as join22 } from "path";
5
+ import { fileURLToPath as fileURLToPath3 } from "url";
6
+ import { dirname as dirname9, join as join22 } from "path";
7
7
  import { Command } from "commander";
8
8
 
9
9
  // ../listener/dist/main.js
10
- import { writeFile as writeFile7, mkdir as mkdir7 } from "fs/promises";
10
+ import { readFile as readFile5, writeFile as writeFile7, mkdir as mkdir7 } from "fs/promises";
11
11
  import { execFile as execFile4 } from "child_process";
12
- import { join as join12 } from "path";
12
+ import { join as join12, dirname as dirname4 } from "path";
13
+ import { fileURLToPath as fileURLToPath2 } from "url";
13
14
  import { promisify as promisify3 } from "util";
14
15
  import lockfile2 from "proper-lockfile";
15
16
 
@@ -17,7 +18,7 @@ import lockfile2 from "proper-lockfile";
17
18
  import { homedir } from "os";
18
19
  import { join } from "path";
19
20
  function getConfigDir() {
20
- const isStaging = true ? false : false;
21
+ const isStaging = true ? true : false;
21
22
  return join(homedir(), isStaging ? ".repowise-staging" : ".repowise");
22
23
  }
23
24
 
@@ -112,7 +113,7 @@ var ROLE_PRIORITY = [
112
113
  import { readFile, writeFile, rename, unlink, mkdir, chmod } from "fs/promises";
113
114
  import { join as join2 } from "path";
114
115
  import lockfile from "proper-lockfile";
115
- var DEFAULT_API_URL = false ? "https://staging-api.repowise.ai" : "https://api.repowise.ai";
116
+ var DEFAULT_API_URL = true ? "https://staging-api.repowise.ai" : "https://api.repowise.ai";
116
117
  async function getListenerConfig() {
117
118
  const configDir = getConfigDir();
118
119
  const configPath = join2(configDir, "config.json");
@@ -823,7 +824,7 @@ async function removePidFile() {
823
824
  // ../listener/dist/lib/auto-updater.js
824
825
  import { execFile as execFile2 } from "child_process";
825
826
  import { access as access2, constants } from "fs/promises";
826
- import { join as join9 } from "path";
827
+ import { dirname as dirname3, join as join9 } from "path";
827
828
  import { promisify as promisify2 } from "util";
828
829
  var execFileAsync2 = promisify2(execFile2);
829
830
  async function installUpdate(currentVersion, packageName, targetVersion) {
@@ -831,22 +832,24 @@ async function installUpdate(currentVersion, packageName, targetVersion) {
831
832
  return { updated: false };
832
833
  if (!/^\d+\.\d+\.\d+/.test(targetVersion))
833
834
  return { updated: false };
834
- if (!isNewer(targetVersion, currentVersion))
835
+ if (!isNewer(targetVersion, currentVersion)) {
836
+ console.log(`[auto-update] ${targetVersion} is not newer than ${currentVersion} \u2014 skipping`);
835
837
  return { updated: false };
838
+ }
839
+ const npmBin = join9(dirname3(process.execPath), "npm");
836
840
  try {
837
- const { stdout: prefix } = await execFileAsync2("npm", ["prefix", "-g"], { timeout: 1e4 });
841
+ const { stdout: prefix } = await execFileAsync2(npmBin, ["prefix", "-g"], { timeout: 1e4 });
838
842
  const npmDir = join9(prefix.trim(), "lib", "node_modules");
839
843
  const checkDir = process.platform === "win32" ? prefix.trim() : npmDir;
840
844
  await access2(checkDir, constants.W_OK);
841
- } catch {
842
- console.log("[auto-update] npm global prefix not writable \u2014 skipping update");
845
+ } catch (err) {
846
+ const msg = err instanceof Error ? err.message : String(err);
847
+ console.log(`[auto-update] npm global prefix not writable \u2014 skipping update (${msg})`);
843
848
  return { updated: false };
844
849
  }
845
850
  console.log(`[auto-update] Updating ${packageName} from ${currentVersion} to ${targetVersion}...`);
846
851
  try {
847
- await execFileAsync2("npm", ["install", "-g", `${packageName}@${targetVersion}`], {
848
- timeout: 6e4
849
- });
852
+ await execFileAsync2(npmBin, ["install", "-g", "--ignore-scripts", `${packageName}@${targetVersion}`], { timeout: 6e4 });
850
853
  console.log(`[auto-update] Successfully updated to ${targetVersion}`);
851
854
  return { updated: true, latestVersion: targetVersion };
852
855
  } catch (err) {
@@ -874,9 +877,35 @@ function isNewer(a, b) {
874
877
  if (vb.pre && !va.pre)
875
878
  return true;
876
879
  if (va.pre && vb.pre)
877
- return va.pre > vb.pre;
880
+ return comparePrerelease(va.pre, vb.pre) > 0;
878
881
  return false;
879
882
  }
883
+ function comparePrerelease(a, b) {
884
+ const aParts = a.split(".");
885
+ const bParts = b.split(".");
886
+ for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
887
+ const ap = aParts[i];
888
+ const bp = bParts[i];
889
+ if (ap === void 0)
890
+ return -1;
891
+ if (bp === void 0)
892
+ return 1;
893
+ const aNum = /^\d+$/.test(ap) ? parseInt(ap, 10) : NaN;
894
+ const bNum = /^\d+$/.test(bp) ? parseInt(bp, 10) : NaN;
895
+ if (!isNaN(aNum) && !isNaN(bNum)) {
896
+ if (aNum > bNum)
897
+ return 1;
898
+ if (aNum < bNum)
899
+ return -1;
900
+ } else {
901
+ if (ap > bp)
902
+ return 1;
903
+ if (ap < bp)
904
+ return -1;
905
+ }
906
+ }
907
+ return 0;
908
+ }
880
909
 
881
910
  // ../listener/dist/lifecycle.js
882
911
  import { unlink as unlink5 } from "fs/promises";
@@ -887,7 +916,7 @@ import { execFile as execFile3 } from "child_process";
887
916
  import { writeFile as writeFile6, mkdir as mkdir6, unlink as unlink4 } from "fs/promises";
888
917
  import { homedir as homedir3 } from "os";
889
918
  import { join as join10 } from "path";
890
- var IS_STAGING = true ? false : false;
919
+ var IS_STAGING = true ? true : false;
891
920
  function exec(cmd, args) {
892
921
  return new Promise((resolve, reject) => {
893
922
  execFile3(cmd, args, (err, stdout) => {
@@ -1399,7 +1428,7 @@ async function startListener() {
1399
1428
  try {
1400
1429
  releaseLock = await lockfile2.lock(lockPath, { stale: 3e4, realpath: false });
1401
1430
  } catch {
1402
- console.error(`Listener already running. Stop it first with \`${true ? "repowise" : "repowise"} stop\`.`);
1431
+ console.error(`Listener already running. Stop it first with \`${true ? "repowisestage" : "repowise"} stop\`.`);
1403
1432
  process.exitCode = 1;
1404
1433
  return;
1405
1434
  }
@@ -1485,12 +1514,15 @@ async function startListener() {
1485
1514
  }
1486
1515
  }
1487
1516
  await saveState(state);
1488
- const packageName = true ? "repowise" : "repowise";
1517
+ const packageName = true ? "repowisestage" : "repowise";
1489
1518
  let currentVersion = "";
1490
1519
  try {
1491
- const { stdout } = await execFileAsync3(packageName, ["--version"], { timeout: 1e4 });
1492
- currentVersion = stdout.trim();
1493
- } catch {
1520
+ const selfDir = dirname4(fileURLToPath2(import.meta.url));
1521
+ const pkgJsonPath = join12(selfDir, "..", "..", "package.json");
1522
+ const pkgJson = JSON.parse(await readFile5(pkgJsonPath, "utf-8"));
1523
+ currentVersion = pkgJson.version;
1524
+ } catch (err) {
1525
+ console.log(`[auto-update] Version detection failed: ${err instanceof Error ? err.message : String(err)}`);
1494
1526
  }
1495
1527
  let pollIntervalMs = 5e3;
1496
1528
  let pollCycleCount = 0;
@@ -1744,7 +1776,7 @@ if (isDirectRun) {
1744
1776
  // src/lib/env.ts
1745
1777
  import { homedir as homedir4 } from "os";
1746
1778
  import { join as join13 } from "path";
1747
- var IS_STAGING2 = true ? false : false;
1779
+ var IS_STAGING2 = true ? true : false;
1748
1780
  var PRODUCTION = {
1749
1781
  apiUrl: "https://api.repowise.ai",
1750
1782
  cognitoDomain: "auth.repowise.ai",
@@ -1766,19 +1798,19 @@ function getConfigDir2() {
1766
1798
  return join13(homedir4(), IS_STAGING2 ? ".repowise-staging" : ".repowise");
1767
1799
  }
1768
1800
  function getPackageName() {
1769
- return true ? "repowise" : "repowise";
1801
+ return true ? "repowisestage" : "repowise";
1770
1802
  }
1771
1803
 
1772
1804
  // src/lib/welcome.ts
1773
1805
  import chalk from "chalk";
1774
1806
 
1775
1807
  // src/lib/config.ts
1776
- import { readFile as readFile5, writeFile as writeFile8, mkdir as mkdir8, rename as rename3, unlink as unlink6 } from "fs/promises";
1808
+ import { readFile as readFile6, writeFile as writeFile8, mkdir as mkdir8, rename as rename3, unlink as unlink6 } from "fs/promises";
1777
1809
  import { join as join14 } from "path";
1778
1810
  import lockfile3 from "proper-lockfile";
1779
1811
  async function getConfig() {
1780
1812
  try {
1781
- const data = await readFile5(join14(getConfigDir2(), "config.json"), "utf-8");
1813
+ const data = await readFile6(join14(getConfigDir2(), "config.json"), "utf-8");
1782
1814
  return JSON.parse(data);
1783
1815
  } catch {
1784
1816
  return {};
@@ -1813,7 +1845,7 @@ async function mergeAndSaveConfig(updates) {
1813
1845
  release = await lockfile3.lock(path, { stale: 1e4, retries: 3, realpath: false });
1814
1846
  let raw = {};
1815
1847
  try {
1816
- raw = JSON.parse(await readFile5(path, "utf-8"));
1848
+ raw = JSON.parse(await readFile6(path, "utf-8"));
1817
1849
  } catch {
1818
1850
  }
1819
1851
  const merged = { ...raw, ...updates };
@@ -1873,13 +1905,13 @@ async function showWelcome(currentVersion) {
1873
1905
 
1874
1906
  // src/commands/create.ts
1875
1907
  import { mkdirSync, writeFileSync as writeFileSync2 } from "fs";
1876
- import { dirname as dirname4, join as join18 } from "path";
1908
+ import { dirname as dirname6, join as join18 } from "path";
1877
1909
  import chalk5 from "chalk";
1878
1910
  import ora from "ora";
1879
1911
 
1880
1912
  // src/lib/auth.ts
1881
1913
  import { createHash, randomBytes } from "crypto";
1882
- import { readFile as readFile6, writeFile as writeFile9, mkdir as mkdir9, chmod as chmod4, unlink as unlink7 } from "fs/promises";
1914
+ import { readFile as readFile7, writeFile as writeFile9, mkdir as mkdir9, chmod as chmod4, unlink as unlink7 } from "fs/promises";
1883
1915
  import http from "http";
1884
1916
  import { join as join15 } from "path";
1885
1917
  var CLI_CALLBACK_PORT = 19876;
@@ -2048,7 +2080,7 @@ async function refreshTokens2(refreshToken) {
2048
2080
  async function getStoredCredentials2() {
2049
2081
  try {
2050
2082
  const credPath = join15(getConfigDir2(), "credentials.json");
2051
- const data = await readFile6(credPath, "utf-8");
2083
+ const data = await readFile7(credPath, "utf-8");
2052
2084
  return JSON.parse(data);
2053
2085
  } catch (err) {
2054
2086
  if (err.code === "ENOENT" || err instanceof SyntaxError) {
@@ -2257,8 +2289,8 @@ async function selectAiTools() {
2257
2289
  }
2258
2290
 
2259
2291
  // src/lib/ai-tools.ts
2260
- import { readFile as readFile7, writeFile as writeFile10, mkdir as mkdir10, readdir } from "fs/promises";
2261
- import { join as join16, dirname as dirname3 } from "path";
2292
+ import { readFile as readFile8, writeFile as writeFile10, mkdir as mkdir10, readdir } from "fs/promises";
2293
+ import { join as join16, dirname as dirname5 } from "path";
2262
2294
  var AI_TOOL_CONFIG = {
2263
2295
  cursor: {
2264
2296
  label: "Cursor",
@@ -2388,7 +2420,7 @@ function generateReference(tool, repoName, contextFolder, contextFiles) {
2388
2420
  async function updateToolConfig(repoRoot, tool, repoName, contextFolder, contextFiles) {
2389
2421
  const config2 = AI_TOOL_CONFIG[tool];
2390
2422
  const fullPath = join16(repoRoot, config2.filePath);
2391
- const dir = dirname3(fullPath);
2423
+ const dir = dirname5(fullPath);
2392
2424
  if (dir !== repoRoot) {
2393
2425
  await mkdir10(dir, { recursive: true });
2394
2426
  }
@@ -2396,7 +2428,7 @@ async function updateToolConfig(repoRoot, tool, repoName, contextFolder, context
2396
2428
  let existing = "";
2397
2429
  let created = true;
2398
2430
  try {
2399
- existing = await readFile7(fullPath, "utf-8");
2431
+ existing = await readFile8(fullPath, "utf-8");
2400
2432
  created = false;
2401
2433
  } catch (err) {
2402
2434
  if (err.code !== "ENOENT") throw err;
@@ -3130,7 +3162,7 @@ async function create() {
3130
3162
  if (response.ok) {
3131
3163
  const content = await response.text();
3132
3164
  const filePath = join18(contextDir, file.fileName);
3133
- mkdirSync(dirname4(filePath), { recursive: true });
3165
+ mkdirSync(dirname6(filePath), { recursive: true });
3134
3166
  writeFileSync2(filePath, content, "utf-8");
3135
3167
  downloadedCount++;
3136
3168
  } else {
@@ -3250,7 +3282,7 @@ Files are stored on our servers (not in git). Retry when online.`
3250
3282
 
3251
3283
  // src/commands/member.ts
3252
3284
  import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync3 } from "fs";
3253
- import { dirname as dirname5, join as join19 } from "path";
3285
+ import { dirname as dirname7, join as join19 } from "path";
3254
3286
  import chalk6 from "chalk";
3255
3287
  import ora2 from "ora";
3256
3288
  var DEFAULT_CONTEXT_FOLDER2 = "repowise-context";
@@ -3390,7 +3422,7 @@ async function member() {
3390
3422
  if (response.ok) {
3391
3423
  const content = await response.text();
3392
3424
  const filePath = join19(contextDir, file.fileName);
3393
- mkdirSync2(dirname5(filePath), { recursive: true });
3425
+ mkdirSync2(dirname7(filePath), { recursive: true });
3394
3426
  writeFileSync3(filePath, content, "utf-8");
3395
3427
  downloadedCount++;
3396
3428
  } else {
@@ -3557,7 +3589,7 @@ async function logout() {
3557
3589
  }
3558
3590
 
3559
3591
  // src/commands/status.ts
3560
- import { readFile as readFile8 } from "fs/promises";
3592
+ import { readFile as readFile9 } from "fs/promises";
3561
3593
  import { basename as basename2, join as join20 } from "path";
3562
3594
  async function status() {
3563
3595
  const configDir = getConfigDir2();
@@ -3565,7 +3597,7 @@ async function status() {
3565
3597
  const CONFIG_PATH = join20(configDir, "config.json");
3566
3598
  let state = null;
3567
3599
  try {
3568
- const data = await readFile8(STATE_PATH, "utf-8");
3600
+ const data = await readFile9(STATE_PATH, "utf-8");
3569
3601
  state = JSON.parse(data);
3570
3602
  } catch {
3571
3603
  }
@@ -3591,7 +3623,7 @@ async function status() {
3591
3623
  }
3592
3624
  const repoNames = /* @__PURE__ */ new Map();
3593
3625
  try {
3594
- const configData = await readFile8(CONFIG_PATH, "utf-8");
3626
+ const configData = await readFile9(CONFIG_PATH, "utf-8");
3595
3627
  const config2 = JSON.parse(configData);
3596
3628
  for (const repo of config2.repos ?? []) {
3597
3629
  repoNames.set(repo.repoId, basename2(repo.localPath));
@@ -3610,7 +3642,7 @@ async function status() {
3610
3642
 
3611
3643
  // src/commands/sync.ts
3612
3644
  import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync4 } from "fs";
3613
- import { dirname as dirname6, join as join21 } from "path";
3645
+ import { dirname as dirname8, join as join21 } from "path";
3614
3646
  import chalk9 from "chalk";
3615
3647
  import ora4 from "ora";
3616
3648
  var POLL_INTERVAL_MS2 = 3e3;
@@ -3768,7 +3800,7 @@ async function sync() {
3768
3800
  if (response.ok) {
3769
3801
  const content = await response.text();
3770
3802
  const filePath = join21(contextDir, file.fileName);
3771
- mkdirSync3(dirname6(filePath), { recursive: true });
3803
+ mkdirSync3(dirname8(filePath), { recursive: true });
3772
3804
  writeFileSync4(filePath, content, "utf-8");
3773
3805
  downloadedCount++;
3774
3806
  } else {
@@ -3985,8 +4017,8 @@ async function config() {
3985
4017
  }
3986
4018
 
3987
4019
  // bin/repowise.ts
3988
- var __filename = fileURLToPath2(import.meta.url);
3989
- var __dirname = dirname7(__filename);
4020
+ var __filename = fileURLToPath3(import.meta.url);
4021
+ var __dirname = dirname9(__filename);
3990
4022
  var pkg = JSON.parse(readFileSync2(join22(__dirname, "..", "..", "package.json"), "utf-8"));
3991
4023
  var program = new Command();
3992
4024
  program.name(getPackageName()).description("AI-optimized codebase context generator").version(pkg.version).hook("preAction", async () => {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "repowisestage",
3
- "version": "0.0.1-staging.8",
3
+ "version": "0.0.16",
4
4
  "type": "module",
5
5
  "description": "AI-optimized codebase context generator",
6
6
  "bin": {
7
- "repowise": "dist/bin/repowise.js"
7
+ "repowisestage": "dist/bin/repowise.js"
8
8
  },
9
9
  "files": [
10
10
  "dist/bin"