Skip to content

Commit f026c6a

Browse files
fix: add win32 native binary to optionalDependencies, fix embedder crashes
- Add @optave/codegraph-win32-x64-msvc to optionalDependencies (was missing, causing fallback to WASM on Windows) - Pin all native binary packages to 2.4.0 - Add bounds check in extractLeadingComment to prevent crash on stale graph data where node line numbers exceed file length - Route model loading messages through logger (stderr) instead of console.log (stdout) to fix pipe-clean JSON output for search --json Closes #113 Closes #114 Closes #115 Impact: 2 functions changed, 9 affected
1 parent 7a4dfc9 commit f026c6a

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@
6969
},
7070
"optionalDependencies": {
7171
"@modelcontextprotocol/sdk": "^1.0.0",
72-
"@optave/codegraph-darwin-arm64": "2.3.0",
73-
"@optave/codegraph-darwin-x64": "2.3.0",
74-
"@optave/codegraph-linux-x64-gnu": "2.3.0"
72+
"@optave/codegraph-darwin-arm64": "2.4.0",
73+
"@optave/codegraph-darwin-x64": "2.4.0",
74+
"@optave/codegraph-linux-x64-gnu": "2.4.0",
75+
"@optave/codegraph-win32-x64-msvc": "2.4.0"
7576
},
7677
"devDependencies": {
7778
"@biomejs/biome": "^2.4.4",

src/embedder.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import path from 'node:path';
44
import { createInterface } from 'node:readline';
55
import Database from 'better-sqlite3';
66
import { findDbPath, openReadonlyOrFail } from './db.js';
7-
import { warn } from './logger.js';
7+
import { info, warn } from './logger.js';
88

99
/**
1010
* Split an identifier into readable words.
@@ -135,8 +135,10 @@ export function estimateTokens(text) {
135135
* Returns the cleaned comment text or null if none found.
136136
*/
137137
function extractLeadingComment(lines, fnLineIndex) {
138+
if (fnLineIndex > lines.length) return null;
138139
const raw = [];
139140
for (let i = fnLineIndex - 1; i >= Math.max(0, fnLineIndex - 15); i--) {
141+
if (i >= lines.length) continue;
140142
const trimmed = lines[i].trim();
141143
if (/^(\/\/|\/\*|\*\/|\*|#|\/\/\/)/.test(trimmed)) {
142144
raw.unshift(trimmed);
@@ -298,7 +300,7 @@ async function loadModel(modelKey) {
298300
pipeline = transformers.pipeline;
299301
_cos_sim = transformers.cos_sim;
300302

301-
console.log(`Loading embedding model: ${config.name} (${config.dim}d)...`);
303+
info(`Loading embedding model: ${config.name} (${config.dim}d)...`);
302304
const pipelineOpts = config.quantized ? { quantized: true } : {};
303305
try {
304306
extractor = await pipeline('feature-extraction', config.name, pipelineOpts);
@@ -321,7 +323,7 @@ async function loadModel(modelKey) {
321323
process.exit(1);
322324
}
323325
activeModel = config.name;
324-
console.log('Model loaded.');
326+
info('Model loaded.');
325327
return { extractor, config };
326328
}
327329

0 commit comments

Comments
 (0)