repowise 0.1.68 → 0.1.70
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 +66 -14
- 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";
|
|
@@ -1787,6 +1787,24 @@ async function scanLocalContextFiles(repoRoot, contextFolder) {
|
|
|
1787
1787
|
}
|
|
1788
1788
|
}
|
|
1789
1789
|
|
|
1790
|
+
// src/lib/gitignore.ts
|
|
1791
|
+
import { readFileSync, writeFileSync, existsSync } from "fs";
|
|
1792
|
+
import { join as join12 } from "path";
|
|
1793
|
+
function ensureGitignore(repoRoot, entry) {
|
|
1794
|
+
const gitignorePath = join12(repoRoot, ".gitignore");
|
|
1795
|
+
if (existsSync(gitignorePath)) {
|
|
1796
|
+
const content = readFileSync(gitignorePath, "utf-8");
|
|
1797
|
+
const lines = content.split("\n").map((l) => l.trim());
|
|
1798
|
+
if (lines.includes(entry) || lines.includes(entry + "/")) {
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
const separator = content.endsWith("\n") ? "" : "\n";
|
|
1802
|
+
writeFileSync(gitignorePath, content + separator + entry + "\n", "utf-8");
|
|
1803
|
+
} else {
|
|
1804
|
+
writeFileSync(gitignorePath, entry + "\n", "utf-8");
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1790
1808
|
// src/lib/interview-handler.ts
|
|
1791
1809
|
import chalk3 from "chalk";
|
|
1792
1810
|
import { input } from "@inquirer/prompts";
|
|
@@ -2450,7 +2468,7 @@ async function create() {
|
|
|
2450
2468
|
const listResult = await apiRequest(`/v1/repos/${repoId}/context`);
|
|
2451
2469
|
const files = listResult.data?.files ?? listResult.files ?? [];
|
|
2452
2470
|
if (files.length > 0) {
|
|
2453
|
-
const contextDir =
|
|
2471
|
+
const contextDir = join13(repoRoot, DEFAULT_CONTEXT_FOLDER);
|
|
2454
2472
|
mkdirSync(contextDir, { recursive: true });
|
|
2455
2473
|
let downloadedCount = 0;
|
|
2456
2474
|
let failedCount = 0;
|
|
@@ -2464,7 +2482,7 @@ async function create() {
|
|
|
2464
2482
|
const response = await fetch(presignedUrl);
|
|
2465
2483
|
if (response.ok) {
|
|
2466
2484
|
const content = await response.text();
|
|
2467
|
-
|
|
2485
|
+
writeFileSync2(join13(contextDir, file.fileName), content, "utf-8");
|
|
2468
2486
|
downloadedCount++;
|
|
2469
2487
|
} else {
|
|
2470
2488
|
failedCount++;
|
|
@@ -2477,6 +2495,10 @@ async function create() {
|
|
|
2477
2495
|
} else {
|
|
2478
2496
|
spinner.succeed(`Context files downloaded to ./${DEFAULT_CONTEXT_FOLDER}/`);
|
|
2479
2497
|
}
|
|
2498
|
+
try {
|
|
2499
|
+
ensureGitignore(repoRoot, DEFAULT_CONTEXT_FOLDER);
|
|
2500
|
+
} catch {
|
|
2501
|
+
}
|
|
2480
2502
|
} else {
|
|
2481
2503
|
spinner.warn("No context files found on server");
|
|
2482
2504
|
}
|
|
@@ -2650,9 +2672,9 @@ async function logout() {
|
|
|
2650
2672
|
// src/commands/status.ts
|
|
2651
2673
|
import { readFile as readFile9 } from "fs/promises";
|
|
2652
2674
|
import { homedir as homedir9 } from "os";
|
|
2653
|
-
import { basename as basename2, join as
|
|
2654
|
-
var STATE_PATH2 =
|
|
2655
|
-
var CONFIG_PATH3 =
|
|
2675
|
+
import { basename as basename2, join as join14 } from "path";
|
|
2676
|
+
var STATE_PATH2 = join14(homedir9(), ".repowise", "listener-state.json");
|
|
2677
|
+
var CONFIG_PATH3 = join14(homedir9(), ".repowise", "config.json");
|
|
2656
2678
|
async function status() {
|
|
2657
2679
|
let state = null;
|
|
2658
2680
|
try {
|
|
@@ -2711,8 +2733,8 @@ async function status() {
|
|
|
2711
2733
|
|
|
2712
2734
|
// src/commands/sync.ts
|
|
2713
2735
|
import { execSync as execSync2 } from "child_process";
|
|
2714
|
-
import { mkdirSync as mkdirSync2, writeFileSync as
|
|
2715
|
-
import { join as
|
|
2736
|
+
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
2737
|
+
import { join as join15 } from "path";
|
|
2716
2738
|
import chalk8 from "chalk";
|
|
2717
2739
|
import ora3 from "ora";
|
|
2718
2740
|
var POLL_INTERVAL_MS2 = 3e3;
|
|
@@ -2768,12 +2790,16 @@ async function sync() {
|
|
|
2768
2790
|
return;
|
|
2769
2791
|
}
|
|
2770
2792
|
let repoId;
|
|
2793
|
+
let repoPlatform;
|
|
2794
|
+
let repoExternalId;
|
|
2771
2795
|
spinner.start("Resolving repository...");
|
|
2772
2796
|
try {
|
|
2773
2797
|
const repos = await apiRequest("/v1/repos");
|
|
2774
2798
|
const match = repos.find((r) => r.name === repoName || r.fullName.endsWith(`/${repoName}`));
|
|
2775
2799
|
if (match) {
|
|
2776
2800
|
repoId = match.repoId;
|
|
2801
|
+
repoPlatform = match.platform;
|
|
2802
|
+
repoExternalId = match.externalId;
|
|
2777
2803
|
}
|
|
2778
2804
|
} catch {
|
|
2779
2805
|
}
|
|
@@ -2858,7 +2884,7 @@ async function sync() {
|
|
|
2858
2884
|
const listResult = await apiRequest(`/v1/repos/${repoId}/context`);
|
|
2859
2885
|
const files = listResult.data?.files ?? listResult.files ?? [];
|
|
2860
2886
|
if (files.length > 0) {
|
|
2861
|
-
const contextDir =
|
|
2887
|
+
const contextDir = join15(repoRoot, DEFAULT_CONTEXT_FOLDER2);
|
|
2862
2888
|
mkdirSync2(contextDir, { recursive: true });
|
|
2863
2889
|
let downloadedCount = 0;
|
|
2864
2890
|
let failedCount = 0;
|
|
@@ -2872,7 +2898,7 @@ async function sync() {
|
|
|
2872
2898
|
const response = await fetch(presignedUrl);
|
|
2873
2899
|
if (response.ok) {
|
|
2874
2900
|
const content = await response.text();
|
|
2875
|
-
|
|
2901
|
+
writeFileSync3(join15(contextDir, file.fileName), content, "utf-8");
|
|
2876
2902
|
downloadedCount++;
|
|
2877
2903
|
} else {
|
|
2878
2904
|
failedCount++;
|
|
@@ -2885,6 +2911,10 @@ async function sync() {
|
|
|
2885
2911
|
} else {
|
|
2886
2912
|
spinner.succeed(`Context files downloaded to ./${DEFAULT_CONTEXT_FOLDER2}/`);
|
|
2887
2913
|
}
|
|
2914
|
+
try {
|
|
2915
|
+
ensureGitignore(repoRoot, DEFAULT_CONTEXT_FOLDER2);
|
|
2916
|
+
} catch {
|
|
2917
|
+
}
|
|
2888
2918
|
} else {
|
|
2889
2919
|
spinner.info("No context files found on server");
|
|
2890
2920
|
}
|
|
@@ -2893,6 +2923,28 @@ async function sync() {
|
|
|
2893
2923
|
spinner.warn(chalk8.yellow(`Could not download context files: ${msg}
|
|
2894
2924
|
Retry when online.`));
|
|
2895
2925
|
}
|
|
2926
|
+
if (repoRoot && repoId) {
|
|
2927
|
+
try {
|
|
2928
|
+
const existingConfig = await getConfig();
|
|
2929
|
+
const existingRepos = existingConfig.repos ?? [];
|
|
2930
|
+
if (!existingRepos.some((r) => r.repoId === repoId)) {
|
|
2931
|
+
const repoEntry = { repoId, localPath: repoRoot };
|
|
2932
|
+
if (isStagingMode()) {
|
|
2933
|
+
repoEntry.apiUrl = getEnvConfig().apiUrl;
|
|
2934
|
+
}
|
|
2935
|
+
if (repoPlatform) repoEntry.platform = repoPlatform;
|
|
2936
|
+
if (repoExternalId) repoEntry.externalId = repoExternalId;
|
|
2937
|
+
existingRepos.push(repoEntry);
|
|
2938
|
+
await saveConfig({ ...existingConfig, repos: existingRepos });
|
|
2939
|
+
}
|
|
2940
|
+
} catch {
|
|
2941
|
+
}
|
|
2942
|
+
try {
|
|
2943
|
+
await install();
|
|
2944
|
+
await startBackground();
|
|
2945
|
+
} catch {
|
|
2946
|
+
}
|
|
2947
|
+
}
|
|
2896
2948
|
const elapsed = formatElapsed2(Date.now() - startTime);
|
|
2897
2949
|
console.log(chalk8.dim(`
|
|
2898
2950
|
Total time: ${elapsed}`));
|
|
@@ -3065,7 +3117,7 @@ async function config() {
|
|
|
3065
3117
|
// bin/repowise.ts
|
|
3066
3118
|
var __filename = fileURLToPath3(import.meta.url);
|
|
3067
3119
|
var __dirname = dirname3(__filename);
|
|
3068
|
-
var pkg = JSON.parse(
|
|
3120
|
+
var pkg = JSON.parse(readFileSync2(join16(__dirname, "..", "..", "package.json"), "utf-8"));
|
|
3069
3121
|
var program = new Command();
|
|
3070
3122
|
program.name("repowise").description("AI-optimized codebase context generator").version(pkg.version).option("--staging", "Use the staging environment").hook("preAction", async () => {
|
|
3071
3123
|
if (program.opts()["staging"]) {
|