scai 0.1.47 β†’ 0.1.49

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/README.md CHANGED
@@ -204,6 +204,18 @@ You won't gain much value from the index unless you scope it to one repository.
204
204
 
205
205
  `find` and `ask` rely on that indexβ€”without it they will return no useful results.
206
206
 
207
+ ## πŸ”„ Breaking Change in v0.1.47
208
+
209
+ > πŸ› οΈ As of `v0.1.47`, the internal database schema has changed.
210
+
211
+ 🚨 **OBS**: The **Migrate** command is for **internal use only**. Do **not** run it unless explicitly instructed, as it may delete existing data or corrupt your local database.
212
+
213
+ If you're upgrading from an earlier version, please run the following commands to avoid indexing issues:
214
+
215
+ ```bash
216
+ scai reset-db
217
+ scai index
218
+ ```
207
219
 
208
220
  ---
209
221
 
@@ -86,6 +86,13 @@ export async function runDaemonBatch() {
86
86
  log(`βœ… Function extraction complete for ${row.path}\n`);
87
87
  }
88
88
  else {
89
+ // If no functions were found, set processing status to 'skipped' or 'failed'
90
+ db.prepare(`
91
+ UPDATE files
92
+ SET processing_status = 'failed',
93
+ functions_extracted_at = datetime('now')
94
+ WHERE id = @id
95
+ `).run({ id: row.id });
89
96
  log(`ℹ️ No functions extracted for ${row.path}\n`);
90
97
  }
91
98
  }
@@ -11,7 +11,7 @@ export async function extractFunctionsFromFile(filePath, content, fileId) {
11
11
  const type = detectFileType(filePath).trim().toLowerCase();
12
12
  try {
13
13
  if (type === 'js' || type === 'ts' || type === 'javascript' || type === 'typescript') {
14
- log(`βœ… Attempting to extract JS functions from ${filePath}\n`);
14
+ log(`βœ… Attempting to extract JS functions from ${filePath}`);
15
15
  return await extractFromJS(filePath, content, fileId);
16
16
  }
17
17
  if (type === 'java') {
package/dist/db/schema.js CHANGED
@@ -5,13 +5,13 @@ export function initSchema() {
5
5
  CREATE TABLE IF NOT EXISTS files (
6
6
  id INTEGER PRIMARY KEY AUTOINCREMENT,
7
7
  path TEXT UNIQUE,
8
- filename TEXT, -- βœ… Store extracted filename here
8
+ filename TEXT,
9
9
  summary TEXT,
10
10
  type TEXT,
11
11
  indexed_at TEXT,
12
12
  last_modified TEXT,
13
13
  embedding TEXT,
14
- processing_status TEXT,
14
+ processing_status TEXT NOT NULL DEFAULT 'unprocessed',
15
15
  functions_extracted_at TEXT
16
16
  );
17
17
 
@@ -4,6 +4,6 @@ export function isGeneratedOrBundledFile(filePath) {
4
4
  const base = path.basename(filePath);
5
5
  const isMinified = /\.min\.(js|ts)$/.test(base); // βœ… New check
6
6
  const isHashNamed = /[-_.](worker|bundle|chunk|[a-f0-9]{6,})\.(js|ts)$/.test(base);
7
- const isInOutputFolder = /[\\/]dist[\\/]|[\\/]build[\\/]|[\\/]assets[\\/]|[\\/]node_modules[\\/]/i.test(filePath);
7
+ const isInOutputFolder = /[\\/]dist[\\/]|[\\/]build[\\/]|[\\/]assets[\\/]|[\\/]node_modules[\\/]|[\\/]lib[\\/]|[\\/]plugin[s]?[\\/]/i.test(filePath);
8
8
  return isMinified || isHashNamed || isInOutputFolder;
9
9
  }
@@ -1,34 +1,46 @@
1
1
  // scripts/migrateDb.ts
2
2
  import { db } from "../db/client.js";
3
3
  import { log } from "../utils/log.js";
4
+ // scripts/resetFunctionExtraction.ts
4
5
  try {
5
- // Add `processing_status` column if it doesn't exist
6
+ db.prepare(`DELETE FROM function_calls`).run();
7
+ log("βœ… Deleted all rows from function_calls.");
8
+ db.prepare(`DELETE FROM functions`).run();
9
+ log("βœ… Deleted all rows from functions.");
6
10
  db.prepare(`
7
- ALTER TABLE files ADD COLUMN processing_status TEXT DEFAULT 'unprocessed'
11
+ UPDATE files
12
+ SET processing_status = 'unprocessed',
13
+ functions_extracted_at = NULL
8
14
  `).run();
9
- log('βœ… Added processing_status column.');
15
+ log("βœ… Reset processing_status and functions_extracted_at in files table.");
10
16
  }
11
17
  catch (e) {
12
- if (e instanceof Error && e.message.includes('duplicate column name')) {
13
- log('ℹ️ Column processing_status already exists. Skipping.');
14
- }
15
- else {
16
- log(`❌ Migration failed: ${e instanceof Error ? e.message : e}`);
17
- }
18
- }
19
- try {
20
- // Add `functions_extracted_at` column if it doesn't exist
21
- db.prepare(`
22
- ALTER TABLE files ADD COLUMN functions_extracted_at TEXT
23
- `).run();
24
- log('βœ… Added functions_extracted_at column.');
25
- }
26
- catch (e) {
27
- if (e instanceof Error && e.message.includes('duplicate column name')) {
28
- log('ℹ️ Column functions_extracted_at already exists. Skipping.');
29
- }
30
- else {
31
- log(`❌ Migration failed: ${e instanceof Error ? e.message : e}`);
32
- }
18
+ log(`❌ Reset failed: ${e instanceof Error ? e.message : e}`);
33
19
  }
20
+ // try {
21
+ // // Add `processing_status` column if it doesn't exist
22
+ // db.prepare(`
23
+ // ALTER TABLE files ADD COLUMN processing_status TEXT DEFAULT 'unprocessed'
24
+ // `).run();
25
+ // log('βœ… Added processing_status column.');
26
+ // } catch (e: unknown) {
27
+ // if (e instanceof Error && e.message.includes('duplicate column name')) {
28
+ // log('ℹ️ Column processing_status already exists. Skipping.');
29
+ // } else {
30
+ // log(`❌ Migration failed: ${e instanceof Error ? e.message : e}`);
31
+ // }
32
+ // }
33
+ // try {
34
+ // // Add `functions_extracted_at` column if it doesn't exist
35
+ // db.prepare(`
36
+ // ALTER TABLE files ADD COLUMN functions_extracted_at TEXT
37
+ // `).run();
38
+ // log('βœ… Added functions_extracted_at column.');
39
+ // } catch (e: unknown) {
40
+ // if (e instanceof Error && e.message.includes('duplicate column name')) {
41
+ // log('ℹ️ Column functions_extracted_at already exists. Skipping.');
42
+ // } else {
43
+ // log(`❌ Migration failed: ${e instanceof Error ? e.message : e}`);
44
+ // }
45
+ // }
34
46
  // Add more migration steps here as needed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scai",
3
- "version": "0.1.47",
3
+ "version": "0.1.49",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "scai": "./dist/index.js"