jstar-reviewer 2.1.1 → 2.1.3
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/bin/jstar.js +1 -1
- package/dist/scripts/indexer.js +35 -3
- package/package.json +1 -1
- package/scripts/indexer.ts +39 -5
- package/setup.js +1 -1
package/bin/jstar.js
CHANGED
package/dist/scripts/indexer.js
CHANGED
|
@@ -42,9 +42,39 @@ const mock_llm_1 = require("./mock-llm");
|
|
|
42
42
|
const path = __importStar(require("path"));
|
|
43
43
|
const fs = __importStar(require("fs"));
|
|
44
44
|
const chalk_1 = __importDefault(require("chalk"));
|
|
45
|
+
// IMPORTANT: Import config for side effects (loads dotenv from cwd)
|
|
46
|
+
require("./config");
|
|
45
47
|
// Configuration
|
|
46
48
|
const STORAGE_DIR = path.join(process.cwd(), ".jstar", "storage");
|
|
47
|
-
|
|
49
|
+
// Smart source directory detection
|
|
50
|
+
function getSourceDir() {
|
|
51
|
+
const cwd = process.cwd();
|
|
52
|
+
// 1. Check for --path argument
|
|
53
|
+
const args = process.argv.slice(2);
|
|
54
|
+
const pathArgIndex = args.indexOf('--path');
|
|
55
|
+
if (pathArgIndex !== -1 && args[pathArgIndex + 1]) {
|
|
56
|
+
const customPath = path.resolve(cwd, args[pathArgIndex + 1]);
|
|
57
|
+
if (fs.existsSync(customPath)) {
|
|
58
|
+
return customPath;
|
|
59
|
+
}
|
|
60
|
+
console.error(chalk_1.default.red(`❌ Custom path not found: ${customPath}`));
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
// 2. Try common source directories
|
|
64
|
+
const candidates = ['src', 'lib', 'app', 'scripts', '.'];
|
|
65
|
+
for (const dir of candidates) {
|
|
66
|
+
const fullPath = path.join(cwd, dir);
|
|
67
|
+
if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) {
|
|
68
|
+
// Skip '.' if there's a more specific match
|
|
69
|
+
if (dir === '.' && candidates.slice(0, -1).some(d => fs.existsSync(path.join(cwd, d)))) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
return fullPath;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Default to cwd
|
|
76
|
+
return cwd;
|
|
77
|
+
}
|
|
48
78
|
async function main() {
|
|
49
79
|
// 0. Environment Validation
|
|
50
80
|
if (!process.env.GOOGLE_API_KEY) {
|
|
@@ -54,7 +84,9 @@ async function main() {
|
|
|
54
84
|
}
|
|
55
85
|
const args = process.argv.slice(2);
|
|
56
86
|
const isWatch = args.includes("--watch");
|
|
87
|
+
const SOURCE_DIR = getSourceDir();
|
|
57
88
|
console.log(chalk_1.default.blue("🧠 J-Star Indexer: Scanning codebase..."));
|
|
89
|
+
console.log(chalk_1.default.dim(` Source: ${SOURCE_DIR}`));
|
|
58
90
|
// 1. Load documents (Your Code)
|
|
59
91
|
if (!fs.existsSync(SOURCE_DIR)) {
|
|
60
92
|
console.error(chalk_1.default.red(`❌ Source directory not found: ${SOURCE_DIR}`));
|
|
@@ -114,8 +146,8 @@ async function main() {
|
|
|
114
146
|
}
|
|
115
147
|
catch (e) {
|
|
116
148
|
console.error(chalk_1.default.red("❌ Indexing Failed:"), e.message);
|
|
117
|
-
if (e.message.includes("
|
|
118
|
-
console.log(chalk_1.default.yellow("👉 Tip: Make sure you have
|
|
149
|
+
if (e.message.includes("API") || e.message.includes("key")) {
|
|
150
|
+
console.log(chalk_1.default.yellow("👉 Tip: Make sure you have GOOGLE_API_KEY in your .env.local file."));
|
|
119
151
|
}
|
|
120
152
|
process.exit(1);
|
|
121
153
|
}
|
package/package.json
CHANGED
package/scripts/indexer.ts
CHANGED
|
@@ -9,11 +9,44 @@ import { MockLLM } from "./mock-llm";
|
|
|
9
9
|
import * as path from "path";
|
|
10
10
|
import * as fs from "fs";
|
|
11
11
|
import chalk from "chalk";
|
|
12
|
-
|
|
12
|
+
// IMPORTANT: Import config for side effects (loads dotenv from cwd)
|
|
13
|
+
import "./config";
|
|
13
14
|
|
|
14
15
|
// Configuration
|
|
15
16
|
const STORAGE_DIR = path.join(process.cwd(), ".jstar", "storage");
|
|
16
|
-
|
|
17
|
+
|
|
18
|
+
// Smart source directory detection
|
|
19
|
+
function getSourceDir(): string {
|
|
20
|
+
const cwd = process.cwd();
|
|
21
|
+
|
|
22
|
+
// 1. Check for --path argument
|
|
23
|
+
const args = process.argv.slice(2);
|
|
24
|
+
const pathArgIndex = args.indexOf('--path');
|
|
25
|
+
if (pathArgIndex !== -1 && args[pathArgIndex + 1]) {
|
|
26
|
+
const customPath = path.resolve(cwd, args[pathArgIndex + 1]);
|
|
27
|
+
if (fs.existsSync(customPath)) {
|
|
28
|
+
return customPath;
|
|
29
|
+
}
|
|
30
|
+
console.error(chalk.red(`❌ Custom path not found: ${customPath}`));
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 2. Try common source directories
|
|
35
|
+
const candidates = ['src', 'lib', 'app', 'scripts', '.'];
|
|
36
|
+
for (const dir of candidates) {
|
|
37
|
+
const fullPath = path.join(cwd, dir);
|
|
38
|
+
if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) {
|
|
39
|
+
// Skip '.' if there's a more specific match
|
|
40
|
+
if (dir === '.' && candidates.slice(0, -1).some(d => fs.existsSync(path.join(cwd, d)))) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
return fullPath;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Default to cwd
|
|
48
|
+
return cwd;
|
|
49
|
+
}
|
|
17
50
|
|
|
18
51
|
async function main() {
|
|
19
52
|
// 0. Environment Validation
|
|
@@ -25,9 +58,10 @@ async function main() {
|
|
|
25
58
|
|
|
26
59
|
const args = process.argv.slice(2);
|
|
27
60
|
const isWatch = args.includes("--watch");
|
|
61
|
+
const SOURCE_DIR = getSourceDir();
|
|
28
62
|
|
|
29
63
|
console.log(chalk.blue("🧠 J-Star Indexer: Scanning codebase..."));
|
|
30
|
-
|
|
64
|
+
console.log(chalk.dim(` Source: ${SOURCE_DIR}`));
|
|
31
65
|
|
|
32
66
|
// 1. Load documents (Your Code)
|
|
33
67
|
if (!fs.existsSync(SOURCE_DIR)) {
|
|
@@ -91,8 +125,8 @@ async function main() {
|
|
|
91
125
|
|
|
92
126
|
} catch (e: any) {
|
|
93
127
|
console.error(chalk.red("❌ Indexing Failed:"), e.message);
|
|
94
|
-
if (e.message.includes("
|
|
95
|
-
console.log(chalk.yellow("👉 Tip: Make sure you have
|
|
128
|
+
if (e.message.includes("API") || e.message.includes("key")) {
|
|
129
|
+
console.log(chalk.yellow("👉 Tip: Make sure you have GOOGLE_API_KEY in your .env.local file."));
|
|
96
130
|
}
|
|
97
131
|
process.exit(1);
|
|
98
132
|
}
|
package/setup.js
CHANGED
|
@@ -115,7 +115,7 @@ async function main() {
|
|
|
115
115
|
|
|
116
116
|
// HARDCODED: Tagged release URL - NOT configurable for security
|
|
117
117
|
// To update, modify this constant and publish a new version of setup.js
|
|
118
|
-
const BASE_URL = 'https://raw.githubusercontent.com/JStaRFilms/jstar-code-review/v2.1.
|
|
118
|
+
const BASE_URL = 'https://raw.githubusercontent.com/JStaRFilms/jstar-code-review/v2.1.3';
|
|
119
119
|
|
|
120
120
|
// Validate URL matches our exact expected pattern (defense in depth)
|
|
121
121
|
function isValidUrl(url) {
|