jstar-reviewer 2.1.0 → 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 CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  /**
3
3
  * J-Star Reviewer CLI
4
4
  * Global command-line tool for AI-powered code review
@@ -75,9 +75,11 @@ function ensureSetup() {
75
75
  }
76
76
  // Run setup check
77
77
  ensureSetup();
78
- // Load .env.local first, then .env
79
- dotenv_1.default.config({ path: ".env.local" });
80
- dotenv_1.default.config();
78
+ // Load .env.local first, then .env - USE ABSOLUTE PATHS based on CWD
79
+ // This is critical for global CLI usage where the package is installed elsewhere
80
+ const cwd = process.cwd();
81
+ dotenv_1.default.config({ path: path.join(cwd, ".env.local") });
82
+ dotenv_1.default.config({ path: path.join(cwd, ".env") });
81
83
  /**
82
84
  * Default fallback values.
83
85
  */
@@ -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
- const SOURCE_DIR = path.join(process.cwd(), "scripts"); // Changed from src/ to scripts/
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("OpenAI")) {
118
- console.log(chalk_1.default.yellow("👉 Tip: Make sure you have OPENAI_API_KEY in your .env file (or configure a local embedding model)."));
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jstar-reviewer",
3
- "version": "2.1.0",
3
+ "version": "2.1.3",
4
4
  "description": "Local-First, Context-Aware AI Code Reviewer - Works with any language",
5
5
  "bin": {
6
6
  "jstar": "bin/jstar.js"
package/scripts/config.ts CHANGED
@@ -42,9 +42,11 @@ function ensureSetup() {
42
42
  // Run setup check
43
43
  ensureSetup();
44
44
 
45
- // Load .env.local first, then .env
46
- dotenv.config({ path: ".env.local" });
47
- dotenv.config();
45
+ // Load .env.local first, then .env - USE ABSOLUTE PATHS based on CWD
46
+ // This is critical for global CLI usage where the package is installed elsewhere
47
+ const cwd = process.cwd();
48
+ dotenv.config({ path: path.join(cwd, ".env.local") });
49
+ dotenv.config({ path: path.join(cwd, ".env") });
48
50
 
49
51
  /**
50
52
  * Default fallback values.
@@ -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
- import { Config } from "./config";
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
- const SOURCE_DIR = path.join(process.cwd(), "scripts"); // Changed from src/ to scripts/
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("OpenAI")) {
95
- console.log(chalk.yellow("👉 Tip: Make sure you have OPENAI_API_KEY in your .env file (or configure a local embedding model)."));
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.0';
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) {