diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 736fb7cb..940a03b9 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -94,7 +94,7 @@ jobs: if [ "${{ steps.mode.outputs.source }}" = "npm" ]; then ARGS="$ARGS --npm" fi - node $STRIP_FLAG --import ./scripts/ts-resolve-loader.js scripts/benchmark.ts $ARGS 2>/dev/null > benchmark-result.json + node $STRIP_FLAG --import ./scripts/ts-resolve-loader.js scripts/benchmark.ts $ARGS > benchmark-result.json - name: Update build report if: steps.existing.outputs.skip != 'true' @@ -231,12 +231,14 @@ jobs: uses: actions/cache@v5 with: path: ~/.cache/huggingface - key: hf-models-${{ runner.os }}-${{ hashFiles('src/embeddings/**') }} + key: hf-models-${{ runner.os }}-${{ hashFiles('src/domain/search/**') }} restore-keys: hf-models-${{ runner.os }}- - name: Build graph if: steps.existing.outputs.skip != 'true' - run: node src/cli.js build . + run: | + STRIP_FLAG=$(node -e "const [M]=process.versions.node.split('.').map(Number); console.log(M>=23?'--strip-types':'--experimental-strip-types')") + node $STRIP_FLAG --import ./scripts/ts-resolve-loader.js src/cli.ts build . - name: Run embedding benchmark if: steps.existing.outputs.skip != 'true' @@ -248,7 +250,7 @@ jobs: if [ "${{ steps.mode.outputs.source }}" = "npm" ]; then ARGS="$ARGS --npm" fi - node $STRIP_FLAG --import ./scripts/ts-resolve-loader.js scripts/embedding-benchmark.ts $ARGS 2>/dev/null > embedding-benchmark-result.json + node $STRIP_FLAG --import ./scripts/ts-resolve-loader.js scripts/embedding-benchmark.ts $ARGS > embedding-benchmark-result.json - name: Update embedding report if: steps.existing.outputs.skip != 'true' @@ -388,7 +390,7 @@ jobs: if [ "${{ steps.mode.outputs.source }}" = "npm" ]; then ARGS="$ARGS --npm" fi - node $STRIP_FLAG --import ./scripts/ts-resolve-loader.js scripts/query-benchmark.ts $ARGS 2>/dev/null > query-benchmark-result.json + node $STRIP_FLAG --import ./scripts/ts-resolve-loader.js scripts/query-benchmark.ts $ARGS > query-benchmark-result.json - name: Update query report if: steps.existing.outputs.skip != 'true' @@ -528,7 +530,7 @@ jobs: if [ "${{ steps.mode.outputs.source }}" = "npm" ]; then ARGS="$ARGS --npm" fi - node $STRIP_FLAG --import ./scripts/ts-resolve-loader.js scripts/incremental-benchmark.ts $ARGS 2>/dev/null > incremental-benchmark-result.json + node $STRIP_FLAG --import ./scripts/ts-resolve-loader.js scripts/incremental-benchmark.ts $ARGS > incremental-benchmark-result.json - name: Update incremental report if: steps.existing.outputs.skip != 'true' diff --git a/scripts/lib/bench-config.ts b/scripts/lib/bench-config.ts index 55306e70..613224b2 100644 --- a/scripts/lib/bench-config.ts +++ b/scripts/lib/bench-config.ts @@ -183,10 +183,20 @@ export async function resolveBenchmarkSource() { /** * Build a file:// URL suitable for dynamic import. * + * After the TypeScript migration, src/ contains .ts files while the .js + * extension is still used in import specifiers. This helper checks for the + * .ts variant first (matching the actual source) and falls back to .js so it + * works in both local-dev and npm-published layouts. + * * @param {string} srcDir Absolute path to the codegraph src/ directory - * @param {string} file Relative filename within src/ (e.g. 'builder.js') + * @param {string} file Relative filename within src/ (e.g. 'domain/queries.js') * @returns {string} file:// URL string */ -export function srcImport(srcDir, file) { - return pathToFileURL(path.join(srcDir, file)).href; +export function srcImport(srcDir: string, file: string): string { + const full = path.join(srcDir, file); + if (file.endsWith('.js')) { + const tsVariant = full.replace(/\.js$/, '.ts'); + if (fs.existsSync(tsVariant)) return pathToFileURL(tsVariant).href; + } + return pathToFileURL(full).href; }