repowise 0.1.69 → 0.1.71
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/bin/repowise.js +63 -20
- package/package.json +1 -1
package/dist/bin/repowise.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// bin/repowise.ts
|
|
4
|
-
import { readFileSync } from "fs";
|
|
4
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
5
5
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
6
|
-
import { dirname as dirname3, join as
|
|
6
|
+
import { dirname as dirname3, join as join16 } from "path";
|
|
7
7
|
import { Command } from "commander";
|
|
8
8
|
|
|
9
9
|
// ../listener/dist/main.js
|
|
@@ -916,8 +916,8 @@ async function showWelcome(currentVersion) {
|
|
|
916
916
|
|
|
917
917
|
// src/commands/create.ts
|
|
918
918
|
import { execSync } from "child_process";
|
|
919
|
-
import { mkdirSync, writeFileSync } from "fs";
|
|
920
|
-
import { join as
|
|
919
|
+
import { mkdirSync, writeFileSync as writeFileSync2 } from "fs";
|
|
920
|
+
import { join as join13 } from "path";
|
|
921
921
|
|
|
922
922
|
// ../listener/dist/process-manager.js
|
|
923
923
|
import { spawn } from "child_process";
|
|
@@ -1450,16 +1450,20 @@ async function clearCredentials() {
|
|
|
1450
1450
|
if (err.code !== "ENOENT") throw err;
|
|
1451
1451
|
}
|
|
1452
1452
|
}
|
|
1453
|
-
async function getValidCredentials2() {
|
|
1453
|
+
async function getValidCredentials2(opts) {
|
|
1454
1454
|
const creds = await getStoredCredentials2();
|
|
1455
1455
|
if (!creds) return null;
|
|
1456
|
-
|
|
1456
|
+
const needsRefresh = opts?.forceRefresh || Date.now() > creds.expiresAt - 5 * 60 * 1e3;
|
|
1457
|
+
if (needsRefresh) {
|
|
1457
1458
|
try {
|
|
1458
1459
|
const refreshed = await refreshTokens2(creds.refreshToken);
|
|
1459
1460
|
refreshed.cognito = creds.cognito;
|
|
1460
1461
|
await storeCredentials2(refreshed);
|
|
1461
1462
|
return refreshed;
|
|
1462
1463
|
} catch {
|
|
1464
|
+
if (Date.now() < creds.expiresAt) {
|
|
1465
|
+
return creds;
|
|
1466
|
+
}
|
|
1463
1467
|
await clearCredentials();
|
|
1464
1468
|
return null;
|
|
1465
1469
|
}
|
|
@@ -1547,7 +1551,7 @@ async function apiRequest(path, options) {
|
|
|
1547
1551
|
if (!credentials) {
|
|
1548
1552
|
throw new Error("Not logged in. Run `repowise login` first.");
|
|
1549
1553
|
}
|
|
1550
|
-
|
|
1554
|
+
let response = await fetch(`${getApiUrl()}${path}`, {
|
|
1551
1555
|
...options,
|
|
1552
1556
|
headers: {
|
|
1553
1557
|
"Content-Type": "application/json",
|
|
@@ -1556,8 +1560,21 @@ async function apiRequest(path, options) {
|
|
|
1556
1560
|
}
|
|
1557
1561
|
});
|
|
1558
1562
|
if (response.status === 401) {
|
|
1559
|
-
await
|
|
1560
|
-
|
|
1563
|
+
const refreshed = await getValidCredentials2({ forceRefresh: true });
|
|
1564
|
+
if (refreshed) {
|
|
1565
|
+
response = await fetch(`${getApiUrl()}${path}`, {
|
|
1566
|
+
...options,
|
|
1567
|
+
headers: {
|
|
1568
|
+
"Content-Type": "application/json",
|
|
1569
|
+
Authorization: `Bearer ${refreshed.accessToken}`,
|
|
1570
|
+
...options?.headers
|
|
1571
|
+
}
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
if (!refreshed || response.status === 401) {
|
|
1575
|
+
await clearCredentials();
|
|
1576
|
+
throw new Error("Session expired. Run `repowise login` again.");
|
|
1577
|
+
}
|
|
1561
1578
|
}
|
|
1562
1579
|
if (response.status === 402) {
|
|
1563
1580
|
let message = "Your subscription is inactive.";
|
|
@@ -1787,6 +1804,24 @@ async function scanLocalContextFiles(repoRoot, contextFolder) {
|
|
|
1787
1804
|
}
|
|
1788
1805
|
}
|
|
1789
1806
|
|
|
1807
|
+
// src/lib/gitignore.ts
|
|
1808
|
+
import { readFileSync, writeFileSync, existsSync } from "fs";
|
|
1809
|
+
import { join as join12 } from "path";
|
|
1810
|
+
function ensureGitignore(repoRoot, entry) {
|
|
1811
|
+
const gitignorePath = join12(repoRoot, ".gitignore");
|
|
1812
|
+
if (existsSync(gitignorePath)) {
|
|
1813
|
+
const content = readFileSync(gitignorePath, "utf-8");
|
|
1814
|
+
const lines = content.split("\n").map((l) => l.trim());
|
|
1815
|
+
if (lines.includes(entry) || lines.includes(entry + "/")) {
|
|
1816
|
+
return;
|
|
1817
|
+
}
|
|
1818
|
+
const separator = content.endsWith("\n") ? "" : "\n";
|
|
1819
|
+
writeFileSync(gitignorePath, content + separator + entry + "\n", "utf-8");
|
|
1820
|
+
} else {
|
|
1821
|
+
writeFileSync(gitignorePath, entry + "\n", "utf-8");
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1790
1825
|
// src/lib/interview-handler.ts
|
|
1791
1826
|
import chalk3 from "chalk";
|
|
1792
1827
|
import { input } from "@inquirer/prompts";
|
|
@@ -1926,7 +1961,7 @@ var PERSONA_LABELS = {
|
|
|
1926
1961
|
};
|
|
1927
1962
|
function computeOverallProgress(syncResult) {
|
|
1928
1963
|
const stepNumber = syncResult.stepNumber ?? 1;
|
|
1929
|
-
const totalSteps = syncResult.totalSteps ??
|
|
1964
|
+
const totalSteps = syncResult.totalSteps ?? 7;
|
|
1930
1965
|
const stepPct = syncResult.progressPercentage ?? 0;
|
|
1931
1966
|
return Math.min(100, Math.round(((stepNumber - 1) * 100 + stepPct) / totalSteps));
|
|
1932
1967
|
}
|
|
@@ -2450,7 +2485,7 @@ async function create() {
|
|
|
2450
2485
|
const listResult = await apiRequest(`/v1/repos/${repoId}/context`);
|
|
2451
2486
|
const files = listResult.data?.files ?? listResult.files ?? [];
|
|
2452
2487
|
if (files.length > 0) {
|
|
2453
|
-
const contextDir =
|
|
2488
|
+
const contextDir = join13(repoRoot, DEFAULT_CONTEXT_FOLDER);
|
|
2454
2489
|
mkdirSync(contextDir, { recursive: true });
|
|
2455
2490
|
let downloadedCount = 0;
|
|
2456
2491
|
let failedCount = 0;
|
|
@@ -2464,7 +2499,7 @@ async function create() {
|
|
|
2464
2499
|
const response = await fetch(presignedUrl);
|
|
2465
2500
|
if (response.ok) {
|
|
2466
2501
|
const content = await response.text();
|
|
2467
|
-
|
|
2502
|
+
writeFileSync2(join13(contextDir, file.fileName), content, "utf-8");
|
|
2468
2503
|
downloadedCount++;
|
|
2469
2504
|
} else {
|
|
2470
2505
|
failedCount++;
|
|
@@ -2477,6 +2512,10 @@ async function create() {
|
|
|
2477
2512
|
} else {
|
|
2478
2513
|
spinner.succeed(`Context files downloaded to ./${DEFAULT_CONTEXT_FOLDER}/`);
|
|
2479
2514
|
}
|
|
2515
|
+
try {
|
|
2516
|
+
ensureGitignore(repoRoot, DEFAULT_CONTEXT_FOLDER);
|
|
2517
|
+
} catch {
|
|
2518
|
+
}
|
|
2480
2519
|
} else {
|
|
2481
2520
|
spinner.warn("No context files found on server");
|
|
2482
2521
|
}
|
|
@@ -2650,9 +2689,9 @@ async function logout() {
|
|
|
2650
2689
|
// src/commands/status.ts
|
|
2651
2690
|
import { readFile as readFile9 } from "fs/promises";
|
|
2652
2691
|
import { homedir as homedir9 } from "os";
|
|
2653
|
-
import { basename as basename2, join as
|
|
2654
|
-
var STATE_PATH2 =
|
|
2655
|
-
var CONFIG_PATH3 =
|
|
2692
|
+
import { basename as basename2, join as join14 } from "path";
|
|
2693
|
+
var STATE_PATH2 = join14(homedir9(), ".repowise", "listener-state.json");
|
|
2694
|
+
var CONFIG_PATH3 = join14(homedir9(), ".repowise", "config.json");
|
|
2656
2695
|
async function status() {
|
|
2657
2696
|
let state = null;
|
|
2658
2697
|
try {
|
|
@@ -2711,8 +2750,8 @@ async function status() {
|
|
|
2711
2750
|
|
|
2712
2751
|
// src/commands/sync.ts
|
|
2713
2752
|
import { execSync as execSync2 } from "child_process";
|
|
2714
|
-
import { mkdirSync as mkdirSync2, writeFileSync as
|
|
2715
|
-
import { join as
|
|
2753
|
+
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
2754
|
+
import { join as join15 } from "path";
|
|
2716
2755
|
import chalk8 from "chalk";
|
|
2717
2756
|
import ora3 from "ora";
|
|
2718
2757
|
var POLL_INTERVAL_MS2 = 3e3;
|
|
@@ -2862,7 +2901,7 @@ async function sync() {
|
|
|
2862
2901
|
const listResult = await apiRequest(`/v1/repos/${repoId}/context`);
|
|
2863
2902
|
const files = listResult.data?.files ?? listResult.files ?? [];
|
|
2864
2903
|
if (files.length > 0) {
|
|
2865
|
-
const contextDir =
|
|
2904
|
+
const contextDir = join15(repoRoot, DEFAULT_CONTEXT_FOLDER2);
|
|
2866
2905
|
mkdirSync2(contextDir, { recursive: true });
|
|
2867
2906
|
let downloadedCount = 0;
|
|
2868
2907
|
let failedCount = 0;
|
|
@@ -2876,7 +2915,7 @@ async function sync() {
|
|
|
2876
2915
|
const response = await fetch(presignedUrl);
|
|
2877
2916
|
if (response.ok) {
|
|
2878
2917
|
const content = await response.text();
|
|
2879
|
-
|
|
2918
|
+
writeFileSync3(join15(contextDir, file.fileName), content, "utf-8");
|
|
2880
2919
|
downloadedCount++;
|
|
2881
2920
|
} else {
|
|
2882
2921
|
failedCount++;
|
|
@@ -2889,6 +2928,10 @@ async function sync() {
|
|
|
2889
2928
|
} else {
|
|
2890
2929
|
spinner.succeed(`Context files downloaded to ./${DEFAULT_CONTEXT_FOLDER2}/`);
|
|
2891
2930
|
}
|
|
2931
|
+
try {
|
|
2932
|
+
ensureGitignore(repoRoot, DEFAULT_CONTEXT_FOLDER2);
|
|
2933
|
+
} catch {
|
|
2934
|
+
}
|
|
2892
2935
|
} else {
|
|
2893
2936
|
spinner.info("No context files found on server");
|
|
2894
2937
|
}
|
|
@@ -3091,7 +3134,7 @@ async function config() {
|
|
|
3091
3134
|
// bin/repowise.ts
|
|
3092
3135
|
var __filename = fileURLToPath3(import.meta.url);
|
|
3093
3136
|
var __dirname = dirname3(__filename);
|
|
3094
|
-
var pkg = JSON.parse(
|
|
3137
|
+
var pkg = JSON.parse(readFileSync2(join16(__dirname, "..", "..", "package.json"), "utf-8"));
|
|
3095
3138
|
var program = new Command();
|
|
3096
3139
|
program.name("repowise").description("AI-optimized codebase context generator").version(pkg.version).option("--staging", "Use the staging environment").hook("preAction", async () => {
|
|
3097
3140
|
if (program.opts()["staging"]) {
|