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
10 changes: 10 additions & 0 deletions .cursor/mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"mcpServers": {
"codegenome": {
"command": "codegenome",
"args": [
"mcp-start"
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You are operating within a repository analyzed by CodeGenome, an architectural k

## Core Directives

1. **Mandatory MCP Usage**: When `.genome/watcher.db` exists, you MUST use CodeGenome MCP access for all codebase, architecture, dependency, or symbol queries whenever it is available.
1. **Mandatory MCP Usage**: When `.genome/codegenome.db` exists, you MUST use CodeGenome MCP access for all codebase, architecture, dependency, or symbol queries whenever it is available.
2. **Access Order**: First use native CodeGenome MCP tools exposed in your context. If those tools are missing, you MAY try a local MCP HTTP endpoint such as `http://127.0.0.1:7331/mcp` when the user has started it or configured it. Treat this as MCP transport access, not as an arbitrary application HTTP API.
3. **Prefer Graph over Grep**: Use graph-backed MCP tools instead of raw file searching (`grep`) or reading entire files blindly. The graph provides semantic understanding.
4. **Fallback Gracefully**: If native MCP tools are missing and HTTP MCP access is unavailable, incompatible, or returns empty data, tell the user exactly what failed and what to configure. Then, if needed, read `.genome/graph.json` or `.genome/exports/*.md` before resorting to standard text searches.
Expand Down
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ You are operating within a repository analyzed by CodeGenome, an architectural k

## Core Directives

1. **Mandatory MCP Usage**: When `.genome/watcher.db` exists, you MUST use CodeGenome MCP access for all codebase, architecture, dependency, or symbol queries whenever it is available.
1. **Mandatory MCP Usage**: When `.genome/codegenome.db` exists, you MUST use CodeGenome MCP access for all codebase, architecture, dependency, or symbol queries whenever it is available.
2. **Access Order**: First use native CodeGenome MCP tools exposed in your context. If those tools are missing, you MAY try a local MCP HTTP endpoint such as `http://127.0.0.1:7331/mcp` when the user has started it or configured it. Treat this as MCP transport access, not as an arbitrary application HTTP API.
3. **Prefer Graph over Grep**: Use graph-backed MCP tools instead of raw file searching (`grep`) or reading entire files blindly. The graph provides semantic understanding.
4. **Fallback Gracefully**: If native MCP tools are missing and HTTP MCP access is unavailable, incompatible, or returns empty data, tell the user exactly what failed and what to configure. Then, if needed, read `.genome/graph.json` or `.genome/exports/*.md` before resorting to standard text searches.
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ dist/
build/
*.spec

# Watcher runtime artifacts
# CodeGenome runtime artifacts
.genome/
watcher.db
codegenome.db

# OS / IDE
.DS_Store
Expand Down
10 changes: 10 additions & 0 deletions .vscode/cline_mcp_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"mcpServers": {
"codegenome": {
"command": "codegenome",
"args": [
"mcp-start"
]
}
}
}
10 changes: 10 additions & 0 deletions .vscode/mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"mcpServers": {
"codegenome": {
"command": "codegenome",
"args": [
"mcp-start"
]
}
}
}
2 changes: 1 addition & 1 deletion .windsurfrules
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ You are operating within a repository analyzed by CodeGenome, an architectural k

## Core Directives

1. **Mandatory MCP Usage**: When `.genome/watcher.db` exists, you MUST use CodeGenome MCP access for all codebase, architecture, dependency, or symbol queries whenever it is available.
1. **Mandatory MCP Usage**: When `.genome/codegenome.db` exists, you MUST use CodeGenome MCP access for all codebase, architecture, dependency, or symbol queries whenever it is available.
2. **Access Order**: First use native CodeGenome MCP tools exposed in your context. If those tools are missing, you MAY try a local MCP HTTP endpoint such as `http://127.0.0.1:7331/mcp` when the user has started it or configured it. Treat this as MCP transport access, not as an arbitrary application HTTP API.
3. **Prefer Graph over Grep**: Use graph-backed MCP tools instead of raw file searching (`grep`) or reading entire files blindly. The graph provides semantic understanding.
4. **Fallback Gracefully**: If native MCP tools are missing and HTTP MCP access is unavailable, incompatible, or returns empty data, tell the user exactly what failed and what to configure. Then, if needed, read `.genome/graph.json` or `.genome/exports/*.md` before resorting to standard text searches.
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ You are operating within a repository analyzed by CodeGenome, an architectural k

## Core Directives

1. **Mandatory MCP Usage**: When `.genome/watcher.db` exists, you MUST use CodeGenome MCP access for all codebase, architecture, dependency, or symbol queries whenever it is available.
1. **Mandatory MCP Usage**: When `.genome/codegenome.db` exists, you MUST use CodeGenome MCP access for all codebase, architecture, dependency, or symbol queries whenever it is available.
2. **Access Order**: First use native CodeGenome MCP tools exposed in your context. If those tools are missing, you MAY try a local MCP HTTP endpoint such as `http://127.0.0.1:7331/mcp` when the user has started it or configured it. Treat this as MCP transport access, not as an arbitrary application HTTP API.
3. **Prefer Graph over Grep**: Use graph-backed MCP tools instead of raw file searching (`grep`) or reading entire files blindly. The graph provides semantic understanding.
4. **Fallback Gracefully**: If native MCP tools are missing and HTTP MCP access is unavailable, incompatible, or returns empty data, tell the user exactly what failed and what to configure. Then, if needed, read `.genome/graph.json` or `.genome/exports/*.md` before resorting to standard text searches.
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Graph artifacts are written under `.genome/` in the analyzed workspace. See [doc

### Optional: standalone binary

To build a PyInstaller binary (named `watcher` in `dist/`):
To build a PyInstaller binary (named `codegenome` in `dist/`):

```bash
python build_cli.py
Expand Down Expand Up @@ -235,7 +235,7 @@ For MCP or client integration problems, also note which client (Cursor, Claude D

## Documentation

When updating user-facing docs, use **`codegenome`** as the primary CLI name. Document legacy flag-based usage as `python -m codegenome --…`. The on-disk database file remains `.genome/watcher.db`.
When updating user-facing docs, use **`codegenome`** as the primary CLI name. Document legacy flag-based usage as `python -m codegenome --…`. The on-disk database file remains `.genome/codegenome.db`.

| Document | Purpose |
|----------|---------|
Expand Down
33 changes: 33 additions & 0 deletions CURSOR_MCP_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# CodeGenome Cursor MCP Setup

This project uses **CodeGenome** to provide an architectural knowledge graph that helps Cursor understand the codebase deeply.

## Prerequisites

1. Ensure `codegenome` is installed in your environment:
```bash
pip install codegenome
```
2. You must generate the initial knowledge graph so that the `codegenome.db` exists. Run:
```bash
codegenome analyze
```
*Note: This repository is already configured to ignore `.genome/codegenome.db` in `.gitignore`.*

## Cursor MCP Integration

Cursor automatically reads the `.cursor/mcp.json` file in this repository. The configuration points to the `codegenome mcp-start` command.

Once Cursor connects to the MCP server, it will generate the necessary tool configurations under `.cursor/mcps/` automatically at runtime.

### Troubleshooting

- **Server Not Starting?** If Cursor cannot find the `codegenome` command, you may need to update the `command` field in `.cursor/mcp.json` to point to the absolute path of your `codegenome` executable (e.g., inside your virtual environment, like `.venv/bin/codegenome` or `.venv/Scripts/codegenome.exe`), or run Cursor from an activated terminal.
- **Tools Missing?** Ensure that `.genome/codegenome.db` has been created by running `codegenome analyze`.

## Continuous Updates

To keep the CodeGenome knowledge graph updated automatically as you edit files, run the live codegenome in the background:
```bash
codegenome evolve --live
```
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ codegenome evolve --live --lan .
## 🛠️ Troubleshooting

### 1. "No graph found" or Missing Database
**Symptom:** When attempting to run the MCP server (`codegenome mcp-start`) or export the graph (`codegenome export`), you receive an error that no graph was found or `.genome/watcher.db` does not exist.
**Symptom:** When attempting to run the MCP server (`codegenome mcp-start`) or export the graph (`codegenome export`), you receive an error that no graph was found or `.genome/codegenome.db` does not exist.
**Solution:** Codegenome needs to build its initial knowledge graph database before it can be served or exported. Always run `codegenome analyze .` in your workspace first to generate the graph.

### 2. "unrecognized arguments" CLI Error
Expand Down
6 changes: 3 additions & 3 deletions build_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Build a standalone watcher CLI binary with PyInstaller."""
"""Build a standalone codegenome CLI binary with PyInstaller."""

from __future__ import annotations

Expand All @@ -16,7 +16,7 @@
BUILD = ROOT / "build"
SPEC = ROOT / "codegenome.spec"

BINARY_NAME = "watcher"
BINARY_NAME = "codegenome"

HIDDEN_IMPORTS = [
"codegenome",
Expand Down Expand Up @@ -187,7 +187,7 @@ def build(*, clean: bool = True) -> Path:


def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Build watcher standalone binary")
parser = argparse.ArgumentParser(description="Build codegenome standalone binary")
parser.add_argument(
"--no-clean",
action="store_true",
Expand Down
4 changes: 2 additions & 2 deletions docs/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Both operate on a **workspace** (project root). By default that is the current d

| Path | Purpose |
|------|---------|
| `.genome/watcher.db` | Timeline snapshots (SQLite) |
| `.genome/codegenome.db` | Timeline snapshots (SQLite) |
| `.genome/graph.json` | Latest graph |
| `.genome/exports/` | HTML, Markdown, GraphML, etc. |
| `.genome/scan_cache.db` | Incremental scan cache |
Expand Down Expand Up @@ -240,7 +240,7 @@ Terminal 2:

```bash
python -m codegenome.installer \
--db-path "$(pwd)/.genome/watcher.db" \
--db-path "$(pwd)/.genome/codegenome.db" \
--client cursor \
--transport http
codegenome rules --client cursor .
Expand Down
8 changes: 4 additions & 4 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Codegenome writes artifacts under `<workspace>/.genome/`:
| Path | Purpose |
|------|---------|
| `.genome/graph.json` | Latest graph |
| `.genome/watcher.db` | Timeline snapshots (SQLite) |
| `.genome/codegenome.db` | Timeline snapshots (SQLite) |
| `.genome/exports/` | HTML, Markdown, GraphML, etc. |
| `.genome/scan_cache.db` | Incremental scan cache |

Expand All @@ -93,7 +93,7 @@ python -m codegenome --workspace . --build --mcp --watch

```bash
python -m codegenome.installer \
--db-path "$(pwd)/.genome/watcher.db" \
--db-path "$(pwd)/.genome/codegenome.db" \
--client cursor \
--transport http \
--host 127.0.0.1 \
Expand All @@ -119,15 +119,15 @@ Or run the standalone server module:

```bash
python -m codegenome.mcp_server \
--db-path ./.genome/watcher.db \
--db-path ./.genome/codegenome.db \
--transport stdio
```

See [MCP integration](mcp-integration.md) for environment variables, supported clients, and agent rules.

## Optional: standalone binary

To build a PyInstaller binary named `watcher` in `dist/` (requires the `dev` extra):
To build a PyInstaller binary named `codegenome` in `dist/` (requires the `dev` extra):

```bash
python build_cli.py
Expand Down
28 changes: 14 additions & 14 deletions docs/mcp-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ python -m codegenome --workspace . --build --mcp --watch

# Terminal 2: install client config
python -m codegenome.installer \
--db-path "$(pwd)/.genome/watcher.db" \
--db-path "$(pwd)/.genome/codegenome.db" \
--client cursor \
--transport http \
--host 127.0.0.1 \
Expand All @@ -43,7 +43,7 @@ Or configure clients to run the module directly:

```bash
python -m codegenome.mcp_server \
--db-path ./.genome/watcher.db \
--db-path ./.genome/codegenome.db \
--transport stdio
```

Expand All @@ -56,14 +56,14 @@ python -m codegenome.mcp_server --help

# HTTP
python -m codegenome.mcp_server \
--db-path ./.genome/watcher.db \
--db-path ./.genome/codegenome.db \
--host 127.0.0.1 \
--port 7331 \
--transport http

# Stdio
python -m codegenome.mcp_server \
--db-path ./.genome/watcher.db \
--db-path ./.genome/codegenome.db \
--transport stdio
```

Expand All @@ -75,7 +75,7 @@ python -m codegenome.installer --help

| Flag | Description |
|------|-------------|
| `--db-path PATH` | Absolute path to `.genome/watcher.db` |
| `--db-path PATH` | Absolute path to `.genome/codegenome.db` |
| `--python PATH` | Python executable for stdio transport |
| `--transport stdio\|http` | Config transport mode |
| `--host HOST` | HTTP host in config |
Expand All @@ -101,12 +101,12 @@ Always use **absolute paths** for `--db-path`.

| Variable | Default | Purpose |
|----------|---------|---------|
| `WATCHER_MCP_DB_PATH` | `test.db` | Database path |
| `WATCHER_MCP_HOST` | `127.0.0.1` | HTTP bind host |
| `WATCHER_MCP_PORT` | `7331` | HTTP bind port |
| `WATCHER_MCP_TRANSPORT` | `http` | `http` or `stdio` |
| `WATCHER_MCP_TIMEOUT` | `30` | Tool timeout (seconds) |
| `WATCHER_MCP_LOG_LEVEL` | `INFO` | Log level |
| `CODEGENOME_MCP_DB_PATH` | `test.db` | Database path |
| `CODEGENOME_MCP_HOST` | `127.0.0.1` | HTTP bind host |
| `CODEGENOME_MCP_PORT` | `7331` | HTTP bind port |
| `CODEGENOME_MCP_TRANSPORT` | `http` | `http` or `stdio` |
| `CODEGENOME_MCP_TIMEOUT` | `30` | Tool timeout (seconds) |
| `CODEGENOME_MCP_LOG_LEVEL` | `INFO` | Log level |

## Health check

Expand All @@ -129,8 +129,8 @@ Manual Cursor rule install:

```bash
mkdir -p .cursor/rules
sed 's/{{MCP_PORT}}/7331/g' extensions/templates/watcher-knowledge-graph.mdc \
> .cursor/rules/watcher-knowledge-graph.mdc
sed 's/{{MCP_PORT}}/7331/g' extensions/templates/codegenome-knowledge-graph.mdc \
> .cursor/rules/codegenome-knowledge-graph.mdc
```

On Windows PowerShell, copy the template and replace `{{MCP_PORT}}` with `7331` manually or use your editor's find-and-replace.
Expand All @@ -157,7 +157,7 @@ codegenome analyze .
|---------|----------|
| Connection refused | Run HTTP MCP (`python -m codegenome --mcp --build --watch`) or `mcp_server`; ensure the graph was built |
| Port 7331 in use | Stop the other instance or run `mcp_server --port 7332` and update client config |
| Empty tool results | Run `codegenome analyze .` first; confirm `.genome/watcher.db` exists |
| Empty tool results | Run `codegenome analyze .` first; confirm `.genome/codegenome.db` exists |
| Client not using MCP | Restart the client after `installer`; verify the config file path |
| Stdio vs HTTP mismatch | Match `--transport` in `installer` with how the server is started |

Expand Down
8 changes: 4 additions & 4 deletions extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This folder holds **editor and agent integration assets** that ship with the Cod

| Path | Purpose |
|------|---------|
| `templates/watcher-knowledge-graph.mdc` | Cursor rule template — teaches agents to use Codegenome MCP tools |
| `templates/codegenome-knowledge-graph.mdc` | Cursor rule template — teaches agents to use Codegenome MCP tools |
| `templates/copilot-instructions.md` | GitHub Copilot instructions template |
| `templates/claude-instructions.md` | Claude-oriented instructions template |

Expand All @@ -32,7 +32,7 @@ Write MCP server entries into AI client config files:

```bash
python -m codegenome.installer \
--db-path /absolute/path/to/project/.genome/watcher.db \
--db-path /absolute/path/to/project/.genome/codegenome.db \
--client cursor \
--transport http \
--host 127.0.0.1 \
Expand All @@ -47,8 +47,8 @@ See [MCP integration](../docs/mcp-integration.md) for transport modes, health ch

```bash
mkdir -p .cursor/rules
sed 's/{{MCP_PORT}}/7331/g' extensions/templates/watcher-knowledge-graph.mdc \
> .cursor/rules/watcher-knowledge-graph.mdc
sed 's/{{MCP_PORT}}/7331/g' extensions/templates/codegenome-knowledge-graph.mdc \
> .cursor/rules/codegenome-knowledge-graph.mdc
```

Restart Cursor after installing MCP config or rules.
Expand Down
2 changes: 1 addition & 1 deletion extensions/templates/claude-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ You are operating within a repository analyzed by CodeGenome, an architectural k

## Core Directives

1. **Mandatory MCP Usage**: When `.genome/watcher.db` exists, you MUST use CodeGenome MCP access for all codebase, architecture, dependency, or symbol queries whenever it is available.
1. **Mandatory MCP Usage**: When `.genome/codegenome.db` exists, you MUST use CodeGenome MCP access for all codebase, architecture, dependency, or symbol queries whenever it is available.
2. **Access Order**: First use native CodeGenome MCP tools exposed in your context. If those tools are missing, you MAY try a local MCP HTTP endpoint such as `http://127.0.0.1:{{MCP_PORT}}/mcp` when the user has started it or configured it. Treat this as MCP transport access, not as an arbitrary application HTTP API.
3. **Prefer Graph over Grep**: Use graph-backed MCP tools instead of raw file searching (`grep`) or reading entire files blindly. The graph provides semantic understanding.
4. **Fallback Gracefully**: If native MCP tools are missing and HTTP MCP access is unavailable, incompatible, or returns empty data, tell the user exactly what failed and what to configure. Then, if needed, read `.genome/graph.json` or `.genome/exports/*.md` before resorting to standard text searches.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You are operating within a repository analyzed by CodeGenome, an architectural k

## Core Directives

1. **Mandatory MCP Usage**: When `.genome/watcher.db` exists, you MUST use CodeGenome MCP access for all codebase, architecture, dependency, or symbol queries whenever it is available.
1. **Mandatory MCP Usage**: When `.genome/codegenome.db` exists, you MUST use CodeGenome MCP access for all codebase, architecture, dependency, or symbol queries whenever it is available.
2. **Access Order**: First use native CodeGenome MCP tools exposed in your context. If those tools are missing, you MAY try a local MCP HTTP endpoint such as `http://127.0.0.1:{{MCP_PORT}}/mcp` when the user has started it or configured it. Treat this as MCP transport access, not as an arbitrary application HTTP API.
3. **Prefer Graph over Grep**: Use graph-backed MCP tools instead of raw file searching (`grep`) or reading entire files blindly. The graph provides semantic understanding.
4. **Fallback Gracefully**: If native MCP tools are missing and HTTP MCP access is unavailable, incompatible, or returns empty data, tell the user exactly what failed and what to configure. Then, if needed, read `.genome/graph.json` or `.genome/exports/*.md` before resorting to standard text searches.
Expand Down
2 changes: 1 addition & 1 deletion extensions/templates/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ You are operating within a repository analyzed by CodeGenome, an architectural k

## Core Directives

1. **Mandatory MCP Usage**: When `.genome/watcher.db` exists, you MUST use CodeGenome MCP access for all codebase, architecture, dependency, or symbol queries whenever it is available.
1. **Mandatory MCP Usage**: When `.genome/codegenome.db` exists, you MUST use CodeGenome MCP access for all codebase, architecture, dependency, or symbol queries whenever it is available.
2. **Access Order**: First use native CodeGenome MCP tools exposed in your context. If those tools are missing, you MAY try a local MCP HTTP endpoint such as `http://127.0.0.1:{{MCP_PORT}}/mcp` when the user has started it or configured it. Treat this as MCP transport access, not as an arbitrary application HTTP API.
3. **Prefer Graph over Grep**: Use graph-backed MCP tools instead of raw file searching (`grep`) or reading entire files blindly. The graph provides semantic understanding.
4. **Fallback Gracefully**: If native MCP tools are missing and HTTP MCP access is unavailable, incompatible, or returns empty data, tell the user exactly what failed and what to configure. Then, if needed, read `.genome/graph.json` or `.genome/exports/*.md` before resorting to standard text searches.
Expand Down
Loading
Loading