scai 0.1.59 → 0.1.60
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.
|
@@ -3,7 +3,6 @@ import { ancestor as walkAncestor } from 'acorn-walk';
|
|
|
3
3
|
import { generateEmbedding } from '../../lib/generateEmbedding.js';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import { log } from '../../utils/log.js';
|
|
6
|
-
import fs from 'fs';
|
|
7
6
|
import { markFileAsSkippedTemplate, markFileAsExtractedTemplate, markFileAsFailedTemplate } from '../sqlTemplates.js';
|
|
8
7
|
import { getDbForRepo } from '../client.js';
|
|
9
8
|
function getFunctionName(node, parent, fileName) {
|
|
@@ -22,9 +21,8 @@ function getFunctionName(node, parent, fileName) {
|
|
|
22
21
|
export async function extractFromJS(filePath, content, fileId) {
|
|
23
22
|
const db = getDbForRepo();
|
|
24
23
|
try {
|
|
25
|
-
const code = fs.readFileSync(filePath, 'utf-8');
|
|
26
24
|
console.log(`[Debug] Attempting to parse: ${filePath}`);
|
|
27
|
-
console.log(`[Debug] First 3 lines:\n${
|
|
25
|
+
console.log(`[Debug] First 3 lines:\n${content.split('\n').slice(0, 3).join('\n')}`);
|
|
28
26
|
const ast = parse(content, {
|
|
29
27
|
ecmaVersion: 'latest',
|
|
30
28
|
sourceType: 'module',
|
package/dist/index.js
CHANGED
|
@@ -27,8 +27,8 @@ import { validateGitHubTokenAgainstRepo } from "./github/githubAuthCheck.js";
|
|
|
27
27
|
import { checkGit } from "./commands/GitCmd.js";
|
|
28
28
|
import { runSwitchCommand, runInteractiveSwitch } from "./commands/SwitchCmd.js";
|
|
29
29
|
import { execSync } from "child_process";
|
|
30
|
-
import
|
|
31
|
-
import
|
|
30
|
+
import { dirname, resolve } from "path";
|
|
31
|
+
import { fileURLToPath } from "url";
|
|
32
32
|
// 🎛️ CLI Setup
|
|
33
33
|
const cmd = new Command('scai')
|
|
34
34
|
.version(version)
|
|
@@ -182,22 +182,13 @@ cmd
|
|
|
182
182
|
.command('check-db')
|
|
183
183
|
.description('Run the dbcheck script to check the database status')
|
|
184
184
|
.action(() => {
|
|
185
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
186
|
+
const __dirname = dirname(__filename);
|
|
187
|
+
// Go up two levels from dist/commands → dist → then into dist/scripts/dbcheck.js
|
|
188
|
+
const scriptPath = resolve(__dirname, '..', 'dist/scripts', 'dbcheck.js');
|
|
189
|
+
console.log(`🚀 Running database check script: ${scriptPath}`);
|
|
185
190
|
try {
|
|
186
|
-
|
|
187
|
-
const indexDir = cfg.activeRepo;
|
|
188
|
-
console.log('RepoKey: ', indexDir);
|
|
189
|
-
if (!indexDir) {
|
|
190
|
-
console.error('❌ No indexDir found for the active repo.');
|
|
191
|
-
process.exit(1);
|
|
192
|
-
}
|
|
193
|
-
// Prefer dist version if it exists (built), otherwise use src
|
|
194
|
-
let scriptPath = path.resolve(indexDir, 'dist/scripts/dbcheck.js');
|
|
195
|
-
if (!fs.existsSync(scriptPath)) {
|
|
196
|
-
scriptPath = path.resolve(indexDir, 'src/scripts/dbcheck.ts');
|
|
197
|
-
}
|
|
198
|
-
console.log(`🚀 Running database check script: ${scriptPath}`);
|
|
199
|
-
execSync(`node ${scriptPath}`, { stdio: 'inherit' });
|
|
200
|
-
console.log('✅ Database check completed!');
|
|
191
|
+
execSync(`node "${scriptPath}"`, { stdio: 'inherit' });
|
|
201
192
|
}
|
|
202
193
|
catch (err) {
|
|
203
194
|
console.error('❌ Error running dbcheck script:', err instanceof Error ? err.message : err);
|