Skip to content
Merged
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
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ Codebase Context gives coding agents a map of your repository through MCP, for d

## Set up your AI client

**These commands use 2.4.0.** If that version is not available on npm yet, use the published 2.2.0 [setup guide](https://github.com/PatrickSys/codebase-context/blob/10ba0a635ff73cd5c5b011ffd5b31e7ed4656c65/docs/client-setup.md).

Use Node.js 22 or newer. Choose your coding tool and run its command once; the examples target the 2.4.0 release:
Use Node.js 22 or newer. These commands use the current npm release of Codebase Context:

```bash
# Claude Code
claude mcp add --scope user --transport stdio codebase-context -- npx -y codebase-context@2.4.0
claude mcp add --scope user --transport stdio codebase-context -- npx -y codebase-context

# Codex CLI
codex mcp add codebase-context -- npx -y codebase-context@2.4.0
codex mcp add codebase-context -- npx -y codebase-context

# OpenCode 1.x (keep the quoted separator on Windows)
opencode mcp add codebase-context '--' npx -y codebase-context@2.4.0
opencode mcp add codebase-context '--' npx -y codebase-context
```

Start a new agent session in your project, then ask:
Expand All @@ -27,7 +25,7 @@ Start a new agent session in your project, then ask:

Replace `[feature]` with something you want to find. The first run downloads a local model and indexes the repository; time depends on repository size, CPU and model.

### New in 2.4.0
### Planned for 2.4.0 (not yet published)

- NestJS support from community contributor Aaron Olin. See the [analyzer details](./docs/capabilities.md#analyzers).
- Better React/Next.js detection and a fix for reranker passage scoring.
Expand All @@ -42,7 +40,7 @@ For Codex Desktop, create or merge `.codex/config.toml` in the project you want
```toml
[mcp_servers.codebase-context]
command = "npx"
args = ["-y", "codebase-context@2.4.0"]
args = ["-y", "codebase-context"]
startup_timeout_sec = 120
```

Expand All @@ -52,10 +50,10 @@ Other clients use their own setup commands:

| Client | Shortest current setup |
| --------------------------- | ---------------------------------------------------------------------------- |
| Gemini CLI | `gemini mcp add --scope user codebase-context npx -y codebase-context@2.4.0` |
| Gemini CLI | `gemini mcp add --scope user codebase-context npx -y codebase-context` |
| Cursor | Add `.cursor/mcp.json` |
| VS Code with GitHub Copilot | Add `.vscode/mcp.json` |
| GitHub Copilot CLI | `copilot mcp add codebase-context -- npx -y codebase-context@2.4.0` |
| GitHub Copilot CLI | `copilot mcp add codebase-context -- npx -y codebase-context` |
| Windsurf | Add `~/.codeium/windsurf/mcp_config.json` |

Check an existing same-name entry before replacing it. To give the server a default folder, append that folder's absolute path to the `npx` arguments. The [client setup guide](./docs/client-setup.md) covers scopes, optional fixed-folder configuration and the interactive setup wizard's limitations.
Expand All @@ -72,7 +70,7 @@ The default connection is `stdio` (standard input/output): your client starts th

### Team patterns and examples

`get_team_patterns` shows the approaches used in the repository and points to representative files. Version `2.4.0` includes dedicated analyzers for Angular, React, Next.js and NestJS, with a generic analyzer for other stacks.
`get_team_patterns` shows the approaches used in the repository and points to representative files. Dedicated analyzers for Angular, React, and Next.js ship in published 2.2.0; NestJS support (along with React and Next.js detection improvements and a reranker fix) is planned for unpublished 2.4.0.

### Project memory

Expand All @@ -92,16 +90,16 @@ The same information is available from the terminal. Run these commands from you

```bash
# Build or refresh the local index
npx -y codebase-context@2.4.0 reindex
npx -y codebase-context reindex

# Repository structure, patterns, and representative files
npx -y codebase-context@2.4.0 map
npx -y codebase-context map

# Ranked code search
npx -y codebase-context@2.4.0 search --query "auth middleware"
npx -y codebase-context search --query "auth middleware"

# Current team patterns
npx -y codebase-context@2.4.0 patterns
npx -y codebase-context patterns
```

One stdio server can route across several repositories. Supply `project` in tool calls to select the intended repository; a successful selection becomes the default for later calls in that process. Some clients also announce workspace roots: one root can auto-select, while an ambiguous selection asks for a project instead of guessing. MCP deprecated Roots in its July 2026 revision, so explicit project selection is the documented default rather than a dependency on client discovery.
Expand Down Expand Up @@ -157,8 +155,8 @@ The method and failures are documented so the measurements can be inspected with
- Retrieval measurements describe expected-file coverage, file precision, and reported `peakPrivateGb`, not patch correctness or end-to-end coding quality.
- The paired token observation covers two frozen investigation tasks and records observed agent behavior; it is not a universal token or time guarantee.
- Setup checks differ by client. The detailed guide distinguishes a written config, a config recognized by the client, a local connection, and instructions checked only against official docs.
- Version `2.4.0` has dedicated Angular, React, Next.js and NestJS analyzers. Other projects use the generic analyzer and the language parsers available for that stack.
- The default searchable-chunk limit is 5,000 per project. In `~/.codebase-context/config.json`, set `projects[].parsing.maxChunks` for a project that needs a higher limit.
- Dedicated Angular, React, and Next.js analyzers ship in published 2.2.0; NestJS support is planned for unpublished 2.4.0. Other projects use the generic analyzer and the language parsers available for that stack.
- The default searchable-chunk limit is 5,000 per project. Customizing this via `projects[].parsing.maxChunks` in `~/.codebase-context/config.json` requires 2.4.0 (not yet published).
- The agent must identify its repository in tool calls when no default or unambiguous client root is available. Concurrent HTTP client isolation is not established by the stdio routing checks.

## Reference
Expand Down
26 changes: 13 additions & 13 deletions docs/capabilities.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Capabilities Reference

Technical reference for Codebase Context 2.4.0. Start with the repository map, then search for relevant code. For an overview, see [README.md](../README.md).
Technical reference for the current Codebase Context npm release and the upcoming 2.4.0 source. Start with the repository map, then search for relevant code. For an overview, see [README.md](../README.md).

**These commands use 2.4.0.** If that version is not available on npm yet, use the published 2.2.0 [setup guide](https://github.com/PatrickSys/codebase-context/blob/10ba0a635ff73cd5c5b011ffd5b31e7ed4656c65/docs/client-setup.md).
Commands use the current npm release. Features marked as planned for 2.4.0 are not yet available from npm; the current published version is 2.2.0.
Comment on lines +3 to +5

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Separate source-only configuration from 2.2.0 capabilities

Labeling this page as a reference for the current npm release leaves projects[].parsing.maxChunks described below as “supported today,” but that setting was introduced after 2.2.0 and the published parser does not recognize it. A user following the new unpinned commands can therefore configure a larger project and silently remain capped at 5,000 chunks; mark that option as 2.4.0-only or retain a version-specific 2.2.0 reference.

AGENTS.md reference: AGENTS.md:L112-L112

Useful? React with 👍 / 👎.


## Transport Modes

The server supports two transport modes:

| Mode | Command | MCP endpoint |
| ------------------- | ------------------------------------------------- | ---------------------------- |
| **stdio** (default) | `npx -y codebase-context@2.4.0` | Spawned process stdin/stdout |
| **HTTP** | `npx -y codebase-context@2.4.0 --http [--port N]` | `http://127.0.0.1:3100/mcp` |
| **stdio** (default) | `npx -y codebase-context` | Spawned process stdin/stdout |
| **HTTP** | `npx -y codebase-context --http [--port N]` | `http://127.0.0.1:3100/mcp` |

HTTP defaults to `127.0.0.1:3100`. Override with `--port`, `CODEBASE_CONTEXT_PORT`, or `server.port` in `~/.codebase-context/config.json`.

Expand All @@ -22,14 +22,14 @@ Per-project config overrides supported today:
- `projects[].excludePatterns`: merged with the built-in exclusion set for that project at index time
- `projects[].analyzerHints.analyzer`: prefers a registered analyzer by name for that project and falls back safely when the name is missing or invalid
- `projects[].analyzerHints.extensions`: adds project-local source extensions for indexing and auto-refresh watching without changing defaults for other projects
- `projects[].parsing.maxChunks`: sets the maximum number of searchable chunks indexed for that project
- `projects[].parsing.maxChunks`: sets the maximum number of searchable chunks indexed for that project (requires 2.4.0, not yet published)

Copy-pasteable client config templates are shipped in the package:

- `templates/mcp/stdio/.mcp.json` — stdio setup for `.mcp.json`-style clients
- `templates/mcp/http/.mcp.json` — HTTP setup for `.mcp.json`-style clients

Use Node.js 22 or newer with the 2.4.0 commands shown here. For setup commands and what was checked, see the [client setup guide](./client-setup.md).
Use Node.js 22 or newer with the commands shown here. For setup commands and what was checked, see the [client setup guide](./client-setup.md).

## CLI Reference

Expand All @@ -56,11 +56,11 @@ Commands that list `--json` above support raw JSON output. Follow the [client se

```bash
# Quick examples
npx -y codebase-context@2.4.0 status
npx -y codebase-context@2.4.0 search --query "auth middleware" --intent edit
npx -y codebase-context@2.4.0 refs --symbol "UserService" --limit 10
npx -y codebase-context@2.4.0 cycles --scope src/features
npx -y codebase-context@2.4.0 reindex --incremental
npx -y codebase-context status
npx -y codebase-context search --query "auth middleware" --intent edit
npx -y codebase-context refs --symbol "UserService" --limit 10
npx -y codebase-context cycles --scope src/features
npx -y codebase-context reindex --incremental
```

## Tool Surface
Expand Down Expand Up @@ -276,7 +276,7 @@ Impact is 2-hop transitive: direct importers (hop 1) and their importers (hop 2)
- **Angular**: signals, standalone components, control flow syntax, lifecycle hooks, DI patterns, component metadata
- **React**: function/class components, custom hooks, context usage, memoization, Suspense, ecosystem signal extraction
- **Next.js**: App Router and Pages Router detection, route/API classification, route paths, `"use client"`, metadata exports
- **NestJS**: modules, controllers, providers and route handlers, contributed by Aaron Olin. Matching NestJS source is detected automatically.
- **NestJS** (planned for 2.4.0, not yet published): modules, controllers, providers and route handlers, contributed by Aaron Olin. Matching NestJS source is detected automatically.
- **Generic**: 30+ have indexing/retrieval coverage including PHP, Ruby, Swift, Scala, Shell, config/markup., 10 languages have full symbol extraction (Tree-sitter: TypeScript, JavaScript, Python, Java, Kotlin, C, C++, C#, Go, Rust).

Notes:
Expand Down Expand Up @@ -305,6 +305,6 @@ Reproducible evaluation is shipped as a CLI entrypoint backed by shared scoring

- **Symbol refs are not a call-graph.** `get_symbol_references` counts identifier-node occurrences in the AST (comments/strings excluded via Tree-sitter). It does not distinguish call sites from type annotations, variable assignments, or imports. Full call-site-specific analysis (`call_expression` nodes only) is a roadmap item.
- **Impact is 2-hop max.** `computeImpactCandidates` walks direct importers then their importers. Full BFS reachability is on the roadmap.
- **Version 2.4.0 has dedicated Angular, React, Next.js and NestJS analyzers.** Other languages use the Generic analyzer (30+ languages, chunking + import graph, no framework-specific signal extraction).
- **Planned for unpublished 2.4.0:** NestJS analyzer support, React and Next.js detection improvements, and reranker fixes. Dedicated Angular, React, and Next.js analyzers already ship in published 2.2.0. Other languages use the Generic analyzer (30+ languages, chunking + import graph, no framework-specific signal extraction).
- **Default embedding model is `bge-small-en-v1.5` (512-token context).** Granite (8192 context) is opt-in via `EMBEDDING_MODEL`. OpenAI is opt-in via `EMBEDDING_PROVIDER=openai` — sends code externally.
- **Patterns are file-level frequency counts.** Not semantic clustering. Rising/Declining trend is derived from git commit recency for files using each pattern, not from usage semantics.
52 changes: 26 additions & 26 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@

> Output depends on the repo you run it against. The examples below are illustrative (paths, counts, and detected frameworks will vary).
>
> **These commands use 2.4.0.** If that version is not available on npm yet, use the published 2.2.0 [setup guide](https://github.com/PatrickSys/codebase-context/blob/10ba0a635ff73cd5c5b011ffd5b31e7ed4656c65/docs/client-setup.md).
> These commands use the current npm release. The examples are illustrative and were not captured from the current npm package.
>
> These output examples come from an earlier CLI run; they were not captured from `2.4.0` and do not verify an MCP connection.
> These output examples come from an earlier CLI run and do not verify the current npm package or an MCP connection.
>
> The commands below use `codebase-context@2.4.0` and require Node.js 22 or newer. The CLI is intentionally single-project per invocation and targets one root via `CODEBASE_ROOT` or the current working directory. MCP registration and project selection are covered in the [client setup guide](./client-setup.md).
> The commands below use `codebase-context` and require Node.js 22 or newer. The CLI is intentionally single-project per invocation and targets one root via `CODEBASE_ROOT` or the current working directory. MCP registration and project selection are covered in the [client setup guide](./client-setup.md).

## How to run

```bash
# CLI only: run from a repo root, or set CODEBASE_ROOT explicitly:
CODEBASE_ROOT=/path/to/repo npx -y codebase-context@2.4.0 status
CODEBASE_ROOT=/path/to/repo npx -y codebase-context status

# Commands that show --json in their help support machine output. Human mode is default.
npx -y codebase-context@2.4.0 patterns --json
npx -y codebase-context patterns --json
```

### ASCII fallback

If your terminal doesn’t render Unicode box-drawing cleanly:

```bash
CODEBASE_CONTEXT_ASCII=1 npx -y codebase-context@2.4.0 patterns
CODEBASE_CONTEXT_ASCII=1 npx -y codebase-context patterns
```

## Commands
Expand All @@ -46,7 +46,7 @@ CODEBASE_CONTEXT_ASCII=1 npx -y codebase-context@2.4.0 patterns
- `reindex` — rebuild index (full or incremental)
- `style-guide` — find style guide sections in docs
- `memory list|add|remove` — manage team memory (stored in `.codebase-context/memory.json`)
- MCP client registration — use the 2.4.0 recipes in the [client setup guide](./client-setup.md); `init` is an interactive HTTP setup wizard with the limitations described there
- MCP client registration — use the recipes in the [client setup guide](./client-setup.md); `init` is an interactive HTTP setup wizard with the limitations described there

---

Expand All @@ -55,18 +55,18 @@ CODEBASE_CONTEXT_ASCII=1 npx -y codebase-context@2.4.0 patterns
Run these CLI commands from the project root. Build or refresh the local index first; the first run downloads a local model and indexes the repository; time depends on repository size, CPU and model. Then inspect the conventions map and search for the code you need:

```bash
npx -y codebase-context@2.4.0 reindex
npx -y codebase-context@2.4.0 map
npx -y codebase-context@2.4.0 search --query "auth middleware"
npx -y codebase-context reindex
npx -y codebase-context map
npx -y codebase-context search --query "auth middleware"
```

This is the CLI preparation flow. It is separate from MCP client registration and does not by itself show that an MCP client connected successfully.

## `map`

```bash
npx -y codebase-context@2.4.0 reindex
npx -y codebase-context@2.4.0 map
npx -y codebase-context reindex
npx -y codebase-context map
```

The conventions map - run this first on an unfamiliar repo. It shows architecture layers, active patterns with adoption rates and trend direction, and the golden files the team treats as the strongest examples. This is also what the MCP server delivers to AI agents via the `codebase://context` resource on first call, before search narrows to a specific local example.
Expand Down Expand Up @@ -101,7 +101,7 @@ Example output (truncated):
## `metadata`

```bash
npx -y codebase-context@2.4.0 metadata
npx -y codebase-context metadata
```

Example output:
Expand All @@ -122,7 +122,7 @@ Example output:
## `patterns`

```bash
npx -y codebase-context@2.4.0 patterns
npx -y codebase-context patterns
```

Example output (truncated):
Expand All @@ -144,8 +144,8 @@ Example output (truncated):
## `search`

```bash
npx -y codebase-context@2.4.0 reindex
npx -y codebase-context@2.4.0 search --query "file watcher" --intent edit --limit 3
npx -y codebase-context reindex
npx -y codebase-context search --query "file watcher" --intent edit --limit 3
```

Example output (truncated):
Expand All @@ -166,7 +166,7 @@ Example output (truncated):
## `refs`

```bash
npx -y codebase-context@2.4.0 refs --symbol "startFileWatcher" --limit 10
npx -y codebase-context refs --symbol "startFileWatcher" --limit 10
```

Example output (truncated):
Expand All @@ -185,7 +185,7 @@ Example output (truncated):
## `cycles`

```bash
npx -y codebase-context@2.4.0 cycles --scope src
npx -y codebase-context cycles --scope src
```

Example output:
Expand All @@ -201,7 +201,7 @@ Example output:
## `status`

```bash
npx -y codebase-context@2.4.0 status
npx -y codebase-context status
```

Example output:
Expand All @@ -220,16 +220,16 @@ Example output:
## `reindex`

```bash
npx -y codebase-context@2.4.0 reindex
npx -y codebase-context@2.4.0 reindex --incremental --reason "changed watcher logic"
npx -y codebase-context reindex
npx -y codebase-context reindex --incremental --reason "changed watcher logic"
```

> **MCP server mode**: if you're running codebase-context as an MCP server (long-running process), the index auto-refreshes via a file watcher — you don't need to call `reindex` between edits. Use `reindex` for one-shot CLI runs or to force a full rebuild.

## `style-guide`

```bash
npx -y codebase-context@2.4.0 style-guide --query "naming"
npx -y codebase-context style-guide --query "naming"
```

Example output:
Expand All @@ -242,14 +242,14 @@ No style guides found.
## `memory`

```bash
npx -y codebase-context@2.4.0 memory list
npx -y codebase-context@2.4.0 memory list --query "watcher"
npx -y codebase-context memory list
npx -y codebase-context memory list --query "watcher"

npx -y codebase-context@2.4.0 memory add \
npx -y codebase-context memory add \
--type gotcha \
--category tooling \
--memory "Use pnpm, not npm" \
--reason "Workspace support and speed"

npx -y codebase-context@2.4.0 memory remove <id>
npx -y codebase-context memory remove <id>
```
Loading
Loading