Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { spawnSync } from 'node:child_process';
import { existsSync, readFileSync, writeFileSync,
unlinkSync, linkSync, copyFileSync,
readSync } from 'node:fs';
readSync, readdirSync, rmSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { randomBytes } from 'node:crypto';
Expand Down Expand Up @@ -59,6 +59,17 @@ function commandExists(cmd) {
return capture(checker, [cmd]) !== null;
}

function removeIncompletePackageMetadata(sitePackages) {
if (!existsSync(sitePackages)) return;
for (const entry of readdirSync(sitePackages, { withFileTypes: true })) {
if (!entry.isDirectory() || !entry.name.endsWith('.dist-info')) continue;
const metadataDir = join(sitePackages, entry.name);
if (existsSync(join(metadataDir, 'RECORD'))) continue;
console.log(` Removing incomplete package metadata: ${entry.name}`);
rmSync(metadataDir, { recursive: true, force: true });
}
}

function prompt(question) {
process.stdout.write(question);
const buf = Buffer.alloc(4096);
Expand Down Expand Up @@ -116,6 +127,14 @@ if (uninstall) {

// -- Main setup ----------------------------------------------------------------

// Stop the daemon before changing its Python environment. The stop command
// waits for the process lock to be released, not just for the HTTP port to close.
step(0, 'Stopping running daemon');
if (existsSync(join(REPO, 'config.json')))
runOrDie('node', [join(REPO, 'ts.mjs'), 'stop'], 'ts stop');
else
console.log(' No config.json yet; nothing to stop.');

// [1] Register MCP
step(1, 'Registering MCP server (Claude Code + GitHub Copilot)');
run('claude', ['mcp', 'remove', '--scope', 'user', 'tscodesearch'], { stdio: 'pipe' });
Expand Down Expand Up @@ -181,9 +200,12 @@ step(2, 'Creating client venv (.client-venv)');

runOrDie('uv', ['python', 'install', PYTHON_VER], `uv python install ${PYTHON_VER}`);

removeIncompletePackageMetadata(join(clientVenv, 'Lib', 'site-packages'));

const needsCreate = !existsSync(pyExe);
console.log(needsCreate ? ' Installing packages...' : ' Synchronizing packages...');
runOrDie('uv', ['sync', '--locked', '--no-dev', '--python', PYTHON_VER, '--project', REPO],
runOrDie('uv', ['sync', '--locked', '--no-dev', '--link-mode', 'copy',
'--python', PYTHON_VER, '--project', REPO],
'uv sync', {
env: {
...process.env,
Expand Down
3 changes: 3 additions & 0 deletions vscode-codesearch/.vscodeignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode/**
.claude/**
src/**
out/test/**
node_modules/**
Expand All @@ -8,3 +9,5 @@ node_modules/**
tsconfig.json
AGENTS.md
setup-vscode-ext.cmd
setup-out.txt
test-virtual-scroll.js
3 changes: 2 additions & 1 deletion vscode-codesearch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@
}
},
"scripts": {
"clean": "node -e \"require('fs').rmSync('out',{recursive:true,force:true})\"",
"prebuild": "node -e \"var d=new Date();require('fs').writeFileSync('src/buildInfo.ts','export const BUILD_DATE = \\\"'+d.toISOString().slice(0,16).replace('T',' ')+' UTC\\\";\\n')\"",
"precompile": "npm run prebuild",
"precompile": "npm run clean && npm run prebuild",
"prewatch": "npm run prebuild",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
Expand Down
Loading