scai 0.1.47 → 0.1.48
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 +12 -0
- package/dist/daemon/daemonBatch.js +7 -0
- package/dist/db/schema.js +2 -2
- package/dist/scripts/migrateDb.js +36 -24
- package/package.json +1 -1
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
|
}
|
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,
|
|
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
|
|
|
@@ -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
|
-
|
|
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
|
-
|
|
11
|
+
UPDATE files
|
|
12
|
+
SET processing_status = 'unprocessed',
|
|
13
|
+
functions_extracted_at = NULL
|
|
8
14
|
`).run();
|
|
9
|
-
log(
|
|
15
|
+
log("✅ Reset processing_status and functions_extracted_at in files table.");
|
|
10
16
|
}
|
|
11
17
|
catch (e) {
|
|
12
|
-
|
|
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.
|