Skip to content
Open
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
4 changes: 2 additions & 2 deletions .mcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"mcpServers": {
"codemogger": {
"type": "stdio",
"command": "bun",
"args": ["run", "/Users/glaubercosta/recall/bin/codemogger.ts", "mcp"]
"command": "codemogger",
"args": ["mcp"]
}
}
}
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ The real advantage isn't speed - it's **finding the right code when you don't kn

ripgrep matches thousands of files on common keywords. codemogger returns the 5 most relevant definitions.

## Dependencies note

`@tursodatabase/database` is currently pinned to a pre-release version (`0.5.0-pre.14`). There is no stable `0.5.x` release yet; once one is published this should be updated. The pre-release is stable enough for development use but may have breaking changes before it reaches a final release.

## Architecture

- **Bun/TypeScript** runtime
Expand Down
40 changes: 14 additions & 26 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 1 addition & 59 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,59 +1 @@
{
"name": "codemogger",
"version": "0.1.4",
"description": "Code indexing library with tree-sitter chunking and vector+FTS search for AI coding agents",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
},
"bin": {
"codemogger": "dist/cli.mjs"
},
"repository": {
"type": "git",
"url": "https://github.com/glommer/codemogger"
},
"files": [
"dist",
"codemogger.png",
"README.md",
"LICENSE"
],
"scripts": {
"build": "tsc -p tsconfig.build.json && bun build bin/codemogger.ts --target node --external @tursodatabase/database --external @modelcontextprotocol/sdk --external @huggingface/transformers --external zod --external commander --external web-tree-sitter --external tree-sitter-rust --external tree-sitter-javascript --external tree-sitter-typescript --external tree-sitter-c --external tree-sitter-cpp --external tree-sitter-python --external tree-sitter-go --external tree-sitter-java --external tree-sitter-scala --external tree-sitter-php --external tree-sitter-ruby --external @tree-sitter-grammars/tree-sitter-zig --outfile dist/cli.mjs && node -e \"let f=require('fs');let c=f.readFileSync('dist/cli.mjs','utf8');f.writeFileSync('dist/cli.mjs',c.replace('#!/usr/bin/env bun','#!/usr/bin/env node'))\"",
"prepublishOnly": "bun run build",
"test": "bun test"
},
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5"
},
"dependencies": {
"@huggingface/transformers": "^3.8.1",
"@modelcontextprotocol/sdk": "^1.26.0",
"@tree-sitter-grammars/tree-sitter-zig": "^1.1.2",
"@tursodatabase/database": "0.5.0-pre.14",
"commander": "^14.0.3",
"tree-sitter-c": "^0.24.1",
"tree-sitter-c-sharp": "^0.23.1",
"tree-sitter-cpp": "^0.23.4",
"tree-sitter-go": "^0.25.0",
"tree-sitter-java": "^0.23.5",
"tree-sitter-javascript": "^0.25.0",
"tree-sitter-php": "^0.24.2",
"tree-sitter-python": "^0.25.0",
"tree-sitter-ruby": "^0.23.1",
"tree-sitter-rust": "^0.24.0",
"tree-sitter-scala": "^0.24.0",
"tree-sitter-typescript": "^0.23.2",
"web-tree-sitter": "^0.26.5",
"zod": "^4.3.6"
}
}
{"name":"codemogger","version":"0.1.4","description":"Code indexing library with tree-sitter chunking and vector+FTS search for AI coding agents","type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"bin":{"codemogger":"dist/cli.mjs"},"repository":{"type":"git","url":"https://github.com/glommer/codemogger"},"files":["dist","codemogger.png","README.md","LICENSE"],"scripts":{"build":"tsc -p tsconfig.build.json && bun build bin/codemogger.ts --target node --external @tursodatabase/database --external @modelcontextprotocol/sdk --external @huggingface/transformers --external zod --external commander --external web-tree-sitter --external tree-sitter-rust --external tree-sitter-javascript --external tree-sitter-typescript --external tree-sitter-c --external tree-sitter-cpp --external tree-sitter-python --external tree-sitter-go --external tree-sitter-java --external tree-sitter-scala --external tree-sitter-php --external tree-sitter-ruby --external @tree-sitter-grammars/tree-sitter-zig --outfile dist/cli.mjs && node -e \"let f=require('fs');let c=f.readFileSync('dist/cli.mjs','utf8');f.writeFileSync('dist/cli.mjs',c.replace('#!/usr/bin/env bun','#!/usr/bin/env node'))\"","prepublishOnly":"bun run build","test":"bun test"},"devDependencies":{"@types/bun":"latest"},"peerDependencies":{"typescript":"^5"},"dependencies":{"@huggingface/transformers":"^3.8.1","@modelcontextprotocol/sdk":"^1.26.0","@tree-sitter-grammars/tree-sitter-zig":"^1.1.2","@tursodatabase/database":"0.5.1","commander":"^14.0.3","tree-sitter-c":"^0.24.1","tree-sitter-c-sharp":"^0.23.1","tree-sitter-cpp":"^0.23.4","tree-sitter-go":"^0.25.0","tree-sitter-java":"^0.23.5","tree-sitter-javascript":"^0.25.0","tree-sitter-php":"^0.24.2","tree-sitter-python":"^0.25.0","tree-sitter-ruby":"^0.23.1","tree-sitter-rust":"^0.24.0","tree-sitter-scala":"^0.24.0","tree-sitter-typescript":"^0.23.2","web-tree-sitter":"^0.26.5","zod":"^4.3.6"},"overrides":{"global-agent":"^4.1.3"}}
3 changes: 3 additions & 0 deletions src/chunk/treesitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import type { Node as SyntaxNode } from "web-tree-sitter"
import type { CodeChunk } from "./types.ts"
import type { LanguageConfig } from "./languages.ts"

// Chunks longer than this are split at nested top-level nodes rather than kept as one unit.
// 150 lines is roughly the context window a model can attend to without losing detail;
// going much larger hurts retrieval precision.
const MAX_CHUNK_LINES = 150

let parserReady: Promise<void> | null = null
Expand Down
9 changes: 9 additions & 0 deletions src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,14 @@ SELECT id, name, signature FROM chunks WHERE codebase_id = ?
`
}

/** Insert FTS entries for chunks of a single file (used by incremental update) */
export function populateFtsForFileSQL(codebaseId: number): string {
const table = ftsTableName(codebaseId)
return `
INSERT INTO ${table} (chunk_id, name, signature)
SELECT id, name, signature FROM chunks WHERE codebase_id = ? AND file_path = ?
`
}

// Core tables (FTS is per-codebase, created dynamically)
export const ALL_SCHEMA = [CREATE_CODEBASES_TABLE, CREATE_CHUNKS_TABLE, CREATE_FILES_TABLE]
Loading