diff --git a/CLAUDE.md b/CLAUDE.md index 9e429d8..23cf432 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -92,7 +92,7 @@ qmd context rm / # Remove global context ## Development ```sh -bun qmd.ts # Run from source +bun src/qmd.ts # Run from source bun link # Install globally as 'qmd' ``` @@ -113,4 +113,4 @@ bun link # Install globally as 'qmd' ## Do NOT compile - Never run `bun build --compile` - it overwrites the shell wrapper and breaks sqlite-vec -- The `qmd` file is a shell script that runs `bun qmd.ts` - do not replace it \ No newline at end of file +- The `qmd` file is a shell script that runs `bun src/qmd.ts` - do not replace it \ No newline at end of file diff --git a/README.md b/README.md index 2424265..8bea647 100644 --- a/README.md +++ b/README.md @@ -466,7 +466,7 @@ Query ──► LLM Expansion ──► [Original, Variant 1, Variant 2] ## Model Configuration -Models are configured as constants in `qmd.ts`: +Models are configured as constants in `src/qmd.ts`: ```typescript const DEFAULT_EMBED_MODEL = "embeddinggemma"; diff --git a/package.json b/package.json index 18c52de..d3dd836 100644 --- a/package.json +++ b/package.json @@ -8,14 +8,14 @@ }, "scripts": { "test": "bun test", - "qmd": "bun qmd.ts", - "index": "bun qmd.ts index", - "vector": "bun qmd.ts vector", - "search": "bun qmd.ts search", - "vsearch": "bun qmd.ts vsearch", - "rerank": "bun qmd.ts rerank", + "qmd": "bun src/qmd.ts", + "index": "bun src/qmd.ts index", + "vector": "bun src/qmd.ts vector", + "search": "bun src/qmd.ts search", + "vsearch": "bun src/qmd.ts vsearch", + "rerank": "bun src/qmd.ts rerank", "link": "bun link", - "inspector": "npx @modelcontextprotocol/inspector bun qmd.ts mcp" + "inspector": "npx @modelcontextprotocol/inspector bun src/qmd.ts mcp" }, "dependencies": { "@modelcontextprotocol/sdk": "^1.24.3", diff --git a/qmd b/qmd index 7db8a3c..3281acb 100755 --- a/qmd +++ b/qmd @@ -11,4 +11,4 @@ while [ -L "$SOURCE" ]; do done SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)" -exec bun "$SCRIPT_DIR/qmd.ts" "$@" +exec bun "$SCRIPT_DIR/src/qmd.ts" "$@" diff --git a/cli.test.ts b/src/cli.test.ts similarity index 100% rename from cli.test.ts rename to src/cli.test.ts diff --git a/context-ops.ts b/src/context-ops.ts similarity index 100% rename from context-ops.ts rename to src/context-ops.ts diff --git a/formatter.ts b/src/formatter.ts similarity index 100% rename from formatter.ts rename to src/formatter.ts diff --git a/llm.test.ts b/src/llm.test.ts similarity index 100% rename from llm.test.ts rename to src/llm.test.ts diff --git a/llm.ts b/src/llm.ts similarity index 100% rename from llm.ts rename to src/llm.ts diff --git a/mcp.test.ts b/src/mcp.test.ts similarity index 100% rename from mcp.test.ts rename to src/mcp.test.ts diff --git a/mcp.ts b/src/mcp.ts similarity index 100% rename from mcp.ts rename to src/mcp.ts diff --git a/qmd.ts b/src/qmd.ts similarity index 97% rename from qmd.ts rename to src/qmd.ts index 46976b7..a24cbbc 100755 --- a/qmd.ts +++ b/src/qmd.ts @@ -512,7 +512,7 @@ function showStatus(): void { closeDb(); } -async function updateCollections(): Promise { +async function updateCollections(pullFirst: boolean = false): Promise { const db = getDb(); cleanupDuplicateCollections(db); @@ -534,6 +534,59 @@ async function updateCollections(): Promise { const col = collections[i]; console.log(`${c.cyan}[${i + 1}/${collections.length}]${c.reset} ${c.bold}${col.pwd}${c.reset}`); console.log(`${c.dim} Pattern: ${col.glob_pattern}${c.reset}`); + + // Check if this is a git repository + const gitDir = `${col.pwd}/.git`; + let isGitRepo = false; + + try { + const stat = await Bun.file(gitDir).exists(); + isGitRepo = stat; + } catch { + // Not a git repo or can't access + isGitRepo = false; + } + + if (isGitRepo) { + console.log(`${c.dim} Git repository detected${c.reset}`); + + // Execute git pull if requested + if (pullFirst) { + console.log(`${c.dim} Running git pull...${c.reset}`); + try { + const result = await $`cd ${col.pwd} && git pull`.quiet(); + if (result.exitCode === 0) { + const output = result.stdout.toString().trim(); + if (output) { + // Show output but dimmed + console.log(`${c.dim} ${output.split('\n').join('\n ')}${c.reset}`); + } + } else { + const stderr = result.stderr.toString().trim(); + console.log(`${c.yellow} Warning: git pull failed: ${stderr}${c.reset}`); + } + } catch (err) { + console.log(`${c.yellow} Warning: git pull failed: ${err}${c.reset}`); + } + } + + // Show git status + try { + const statusResult = await $`cd ${col.pwd} && git status --short`.quiet(); + if (statusResult.exitCode === 0) { + const statusOutput = statusResult.stdout.toString().trim(); + if (statusOutput) { + console.log(`${c.dim} Git status:${c.reset}`); + console.log(`${c.dim} ${statusOutput.split('\n').join('\n ')}${c.reset}`); + } else { + console.log(`${c.dim} Git status: clean${c.reset}`); + } + } + } catch (err) { + // Silently ignore git status errors + } + } + await indexFiles(col.pwd, col.glob_pattern); console.log(""); } diff --git a/store.test.ts b/src/store.test.ts similarity index 100% rename from store.test.ts rename to src/store.test.ts diff --git a/store.ts b/src/store.ts similarity index 100% rename from store.ts rename to src/store.ts