refactor(schema): consolidate schema definition to single source of truth

This commit is contained in:
2026-04-15 08:10:39 -04:00
parent dfd61f899a
commit ac343a5477
5 changed files with 57 additions and 58 deletions

View File

@@ -15,27 +15,10 @@ import { existsSync } from "node:fs";
import { join } from "node:path";
import Database from "better-sqlite3";
const SCHEMA = `-- .codexis/index.db schema:
--
-- files: indexed source files
-- id INTEGER PRIMARY KEY
-- path TEXT NOT NULL UNIQUE -- relative to repo root
-- language TEXT NOT NULL -- e.g. 'go', 'typescript', 'python', 'tsx', 'proto'
-- package TEXT -- package/module name (from AST or directory)
-- hash TEXT NOT NULL -- sha256, for incremental indexing
-- indexed_at DATETIME
--
-- symbols: definitions extracted via tree-sitter
-- id INTEGER PRIMARY KEY
-- file_id INTEGER NOT NULL REFERENCES files(id)
-- name TEXT NOT NULL
-- kind TEXT NOT NULL -- one of: 'function','method','class','type','interface','constant','variable','constructor'
-- line INTEGER NOT NULL -- 1-indexed
-- line_end INTEGER -- end of definition body
-- col INTEGER
-- col_end INTEGER
-- exported BOOLEAN -- language-specific visibility
-- parent_id INTEGER REFERENCES symbols(id) -- e.g. method→class, field→struct`;
// @ts-expect-error - generated file
import schema from "./schema.sql?raw";
const SCHEMA = schema;
const DESCRIPTION = `Query the code index database (.codexis/index.db). Run read-only SQL to find symbols, files, and line numbers across the codebase.