Semantic Code Search is a TypeScript CLI for indexing a local repository and finding code by meaning as well as by exact text. It combines OpenAI embeddings with code-token overlap, writes a local JSON index, and can serve a local web UI. A deterministic hash provider runs fully offline for demos and tests. Version 0.1.0.
Requirements: Node.js 20 or newer and npm. Development (tests and npm run dev) needs
Node.js 20.19+ or 22.12+; CI runs Node.js 24. An OpenAI API key is needed only for
OpenAI embeddings and explain --ai.
npm install
cp .env.example .env.local
npm run buildEnvironment variables: OPENAI_API_KEY, OPENAI_EMBEDDING_MODEL,
OPENAI_EXPLAIN_MODEL. See docs/configuration.md.
npx semantic-code-search index . --out .semantic-code-search/index.json
npx semantic-code-search index . --provider hash --out .semantic-code-search/index.json
npx semantic-code-search search "where invoices are deduplicated" --index .semantic-code-search/index.json
npx semantic-code-search search "retry failed webhooks" --json
npx semantic-code-search explain "where invoices are deduplicated" --rank 1
npx semantic-code-search explain "where invoices are deduplicated" --rank 1 --ai
npx semantic-code-search serve --index .semantic-code-search/index.jsonThe first index line uses OpenAI embeddings; run either it or the --provider hash
line, which makes no network calls. search, explain and serve embed queries with
the provider that built the index. explain --ai sends the query and the selected chunk
to OpenAI. serve starts the local web UI at http://127.0.0.1:4317. npm run dev runs
the CLI from source with tsx. There is no deployment setup in this repository.
├── src
│ ├── cli.ts
│ ├── walker.ts
│ ├── ignore-rules.ts
│ ├── chunker.ts
│ ├── embeddings.ts
│ ├── indexer.ts
│ ├── ranking.ts
│ ├── index-store.ts
│ ├── explain.ts
│ ├── server.ts
│ ├── env.ts
│ ├── hash-embedding.ts
│ ├── text-utils.ts
│ └── types.ts
├── tests
├── docs
├── .env.example
├── package.json
├── tsconfig.json
└── tsconfig.build.json
How the pieces fit together: docs/architecture.md.
TypeScript runs in strict mode and CI typechecks on pushes to main and on pull
requests. No linter, formatter or commit convention is configured.
npm run typechecknpm test
npm run deps:audit
npm run deps:outdatedVitest covers chunking, ignore rules, ranking, index storage and CLI behavior.
deps:audit fails on moderate or higher advisories and deps:outdated exits non-zero
when direct dependencies are behind. CI runs both; only the audit can fail the run.
- docs/README.md: index of all docs
- docs/architecture.md: indexing, chunking, ranking and modules
- docs/overview.md: audience and use cases
- docs/configuration.md: environment variables and flags
- docs/operations.md: privacy, security and dependency maintenance
MIT. See LICENSE.