scai 0.1.40 → 0.1.41
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/daemon/daemonBatch.js +34 -24
- package/dist/db/schema.js +2 -1
- package/package.json +1 -1
|
@@ -21,9 +21,9 @@ async function lockDb() {
|
|
|
21
21
|
export async function runDaemonBatch() {
|
|
22
22
|
log('🟡 Starting daemon batch...');
|
|
23
23
|
const rows = db.prepare(`
|
|
24
|
-
SELECT path, type,
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
SELECT id, path, type, summary, indexed_at, last_modified, processing_status
|
|
25
|
+
FROM files
|
|
26
|
+
WHERE processing_status = 'unprocessed' OR summary IS NULL OR summary = ''
|
|
27
27
|
ORDER BY last_modified DESC
|
|
28
28
|
LIMIT ?
|
|
29
29
|
`).all(MAX_FILES_PER_BATCH);
|
|
@@ -47,32 +47,42 @@ export async function runDaemonBatch() {
|
|
|
47
47
|
}
|
|
48
48
|
try {
|
|
49
49
|
const content = await fs.readFile(row.path, 'utf-8');
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
// 🧠 Only re-generate summary if it's missing or outdated
|
|
51
|
+
const needsResummary = !row.summary ||
|
|
52
|
+
!row.indexed_at ||
|
|
53
|
+
(row.last_modified && new Date(row.last_modified) > new Date(row.indexed_at));
|
|
54
|
+
if (needsResummary) {
|
|
55
|
+
log(`📝 Generating summary for ${row.path}...`);
|
|
56
|
+
const summaryResult = await summaryModule.run({ content, filepath: row.path });
|
|
57
|
+
const summary = summaryResult?.summary?.trim() || null;
|
|
58
|
+
let embedding = null;
|
|
59
|
+
if (summary) {
|
|
60
|
+
const vector = await generateEmbedding(summary);
|
|
61
|
+
if (vector) {
|
|
62
|
+
embedding = JSON.stringify(vector);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
db.prepare(`
|
|
66
|
+
UPDATE files
|
|
67
|
+
SET summary = @summary,
|
|
68
|
+
embedding = @embedding,
|
|
69
|
+
indexed_at = datetime('now')
|
|
70
|
+
WHERE path = @path
|
|
71
|
+
`).run({ summary, embedding, path: row.path });
|
|
72
|
+
log(`✅ Updated summary & embedding for ${row.path}`);
|
|
56
73
|
}
|
|
57
74
|
else {
|
|
58
|
-
log(
|
|
59
|
-
}
|
|
60
|
-
log(`📝 Generating summary for ${row.path}...`);
|
|
61
|
-
const summaryResult = await summaryModule.run({ content, filepath: row.path });
|
|
62
|
-
const summary = summaryResult?.summary?.trim() || null;
|
|
63
|
-
let embedding = null;
|
|
64
|
-
if (summary) {
|
|
65
|
-
const vector = await generateEmbedding(summary);
|
|
66
|
-
if (vector) {
|
|
67
|
-
embedding = JSON.stringify(vector);
|
|
68
|
-
}
|
|
75
|
+
log(`⚡ Skipped summary (up-to-date) for ${row.path}`);
|
|
69
76
|
}
|
|
77
|
+
// 🧩 Extract functions and update processing status
|
|
78
|
+
await indexFunctionsForFile(row.path, row.id);
|
|
70
79
|
db.prepare(`
|
|
71
80
|
UPDATE files
|
|
72
|
-
SET
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
81
|
+
SET processing_status = 'extracted',
|
|
82
|
+
functions_extracted_at = datetime('now')
|
|
83
|
+
WHERE id = @id
|
|
84
|
+
`).run({ id: row.id });
|
|
85
|
+
log(`✅ Function extraction complete for ${row.path}\n`);
|
|
76
86
|
}
|
|
77
87
|
catch (err) {
|
|
78
88
|
log(`❌ Failed: ${row.path}: ${err instanceof Error ? err.message : String(err)}\n`);
|
package/dist/db/schema.js
CHANGED