Skip to content

About

TypeScript CLI that indexes a local repository and searches code by meaning and by token overlap.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Semantic Code Search

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.

Installation

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 build

Environment variables: OPENAI_API_KEY, OPENAI_EMBEDDING_MODEL, OPENAI_EXPLAIN_MODEL. See docs/configuration.md.

Usage

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.json

The 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.

Project structure

├── 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.

Coding style

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 typecheck

Test

npm test
npm run deps:audit
npm run deps:outdated

Vitest 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.

Documentation

License

MIT. See LICENSE.

About

TypeScript CLI that indexes a local repository and searches code by meaning and by token overlap.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages