scai 0.1.59 ā 0.1.61
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/config.js
CHANGED
|
@@ -91,9 +91,7 @@ export const Config = {
|
|
|
91
91
|
// Ensure repoKey doesn't contain an absolute path, only the repo name or a relative path
|
|
92
92
|
const scaiRepoRoot = path.join(SCAI_REPOS, path.basename(repoKey)); // Use repo name as key to avoid double paths
|
|
93
93
|
// Set the active repo to the provided indexDir
|
|
94
|
-
|
|
95
|
-
cfg.activeRepo = repoKey;
|
|
96
|
-
await writeConfig(cfg); // Persist the change in activeRepo
|
|
94
|
+
this.setActiveRepo(scaiRepoRoot);
|
|
97
95
|
// Call setRepoIndexDir to update the repo's indexDir and other settings
|
|
98
96
|
await this.setRepoIndexDir(scaiRepoRoot, absPath); // Set the indexDir for the repo
|
|
99
97
|
// Ensure base folders exist
|
|
@@ -103,7 +101,7 @@ export const Config = {
|
|
|
103
101
|
// Init DB if not exists
|
|
104
102
|
const dbPath = path.join(scaiRepoRoot, 'db.sqlite');
|
|
105
103
|
if (!fs.existsSync(dbPath)) {
|
|
106
|
-
console.log(
|
|
104
|
+
console.log(`š¦ Database not found. ${chalk.green('Initializing DB')} at ${normalizePath(dbPath)}`);
|
|
107
105
|
getDbForRepo(); // Now DB creation works after config update
|
|
108
106
|
}
|
|
109
107
|
console.log(`ā
Index directory set to: ${normalizePath(absPath)}`);
|
|
@@ -129,7 +127,7 @@ export const Config = {
|
|
|
129
127
|
},
|
|
130
128
|
setActiveRepo(repoKey) {
|
|
131
129
|
const cfg = readConfig();
|
|
132
|
-
cfg.activeRepo = repoKey;
|
|
130
|
+
cfg.activeRepo = normalizePath(repoKey);
|
|
133
131
|
writeConfig(cfg);
|
|
134
132
|
console.log(`ā
Active repo switched to: ${repoKey}`);
|
|
135
133
|
},
|
|
@@ -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);
|
package/dist/scripts/dbcheck.js
CHANGED
|
@@ -207,20 +207,20 @@ randomFunctions.forEach(row => {
|
|
|
207
207
|
console.log(` ${row.preview}\n`);
|
|
208
208
|
});
|
|
209
209
|
// === Column View of 100 Files ===
|
|
210
|
-
console.log('\nš Table View: First
|
|
210
|
+
console.log('\nš Table View: First 500 Files');
|
|
211
211
|
console.log('-------------------------------------------');
|
|
212
212
|
const fileRows = db.prepare(`
|
|
213
213
|
SELECT id, filename, type, processing_status, functions_extracted_at, length(summary) AS summary_len
|
|
214
214
|
FROM files
|
|
215
|
-
LIMIT
|
|
215
|
+
LIMIT 500
|
|
216
216
|
`).all();
|
|
217
217
|
console.table(fileRows);
|
|
218
218
|
// === Column View of 100 Functions ===
|
|
219
|
-
console.log('\nš Table View: First
|
|
219
|
+
console.log('\nš Table View: First 500 Functions');
|
|
220
220
|
console.log('-------------------------------------------');
|
|
221
221
|
const functionRows = db.prepare(`
|
|
222
222
|
SELECT id, file_id, name, start_line, end_line, length(content) AS length
|
|
223
223
|
FROM functions
|
|
224
|
-
LIMIT
|
|
224
|
+
LIMIT 500
|
|
225
225
|
`).all();
|
|
226
226
|
console.table(functionRows);
|