Skip to content

Commit caa5451

Browse files
authored
Merge pull request #27 from mars167/feat/code-context-engine-runtime
feat: introduce code context runtime foundation
2 parents 0816ea5 + b558815 commit caa5451

42 files changed

Lines changed: 2216 additions & 1607 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 56 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,68 @@
1-
# PROJECT KNOWLEDGE BASE
1+
# Code Context Engine Knowledge Base
22

3-
**Generated:** 2026-02-02 01:45
4-
**Commit:** bd3baf8
5-
**Branch:** refactor/cli-commands-architecture
3+
## Overview
64

7-
## OVERVIEW
8-
git-ai CLI + MCP server. TypeScript implementation for AI-powered Git operations with semantic search and graph-based code analysis. Indices stored in `.git-ai/`.
5+
Code Context Engine is a TypeScript local runtime for agent-oriented code retrieval and context construction. The runtime is the product core. CLI and MCP are thin adapters retained only where they help local debugging or agent integration.
96

10-
## STRUCTURE
11-
```
12-
git-ai-cli-v2/
13-
├── src/
14-
│ ├── cli/ # CLI command architecture (NEW: registry + handlers + schemas)
15-
│ │ ├── types.ts # Core types, executeHandler
16-
│ │ ├── registry.ts # Handler registry (20 commands)
17-
│ │ ├── helpers.ts # Shared utilities
18-
│ │ ├── schemas/ # Zod validation schemas
19-
│ │ ├── handlers/ # Business logic handlers
20-
│ │ └── commands/ # Commander.js wrappers
21-
│ ├── commands/ # Command aggregator (ai.ts only)
22-
│ ├── core/ # Indexing, graph, storage, parsers
23-
│ └── mcp/ # MCP server implementation
24-
├── test/ # Node test runner tests
25-
├── dist/ # Build output
26-
└── .git-ai/ # Indices (LanceDB)
7+
## Structure
8+
9+
```text
10+
src/
11+
index.ts public runtime entry
12+
domain/ stable agent-facing contracts
13+
retrieval/
14+
runtime.ts createCodeContextEngine()
15+
lexical/ lexical-first retrieval
16+
symbol/ higher-level navigation capabilities
17+
tasks/
18+
review/ review context builders
19+
impact/ impact analysis
20+
tests/ test discovery and mapping
21+
implementation/ implementation context
22+
extensions/ extension point discovery
23+
diff/ diff parsing and analysis
24+
core/ parsers, indexers, LanceDB, CozoDB, repo-map
25+
cli/ thin local adapter
26+
commands/ ai command aggregation
27+
mcp/ thin MCP adapter
28+
bin/
29+
code-context-engine.ts package CLI entry
2730
```
2831

29-
## WHERE TO LOOK
30-
| Task | Location |
32+
## Where To Look
33+
34+
| Need | Location |
3135
|------|----------|
32-
| CLI commands | `src/cli/commands/*.ts` (new architecture) |
33-
| CLI handlers | `src/cli/handlers/*.ts` (business logic) |
34-
| CLI schemas | `src/cli/schemas/*.ts` (Zod validation) |
35-
| Handler registry | `src/cli/registry.ts` (all 20 commands) |
36-
| Command aggregator | `src/commands/ai.ts` (entry point) |
37-
| Indexing logic | `src/core/indexer.ts`, `src/core/indexerIncremental.ts` |
38-
| Graph queries | `src/core/cozo.ts`, `src/core/astGraph.ts` |
39-
| Semantic search | `src/core/semantic.ts`, `src/core/sq8.ts` |
40-
| Repo map | `src/core/repoMap.ts` |
41-
| MCP tools | `src/mcp/`, `src/core/graph.ts` |
42-
| Language parsers | `src/core/parser/*.ts` |
36+
| Runtime API | `src/index.ts`, `src/retrieval/runtime.ts` |
37+
| Stable contracts | `src/domain/*.ts` |
38+
| Lexical retrieval | `src/retrieval/lexical/*.ts` |
39+
| Symbol navigation | `src/retrieval/symbol/*.ts` |
40+
| Task builders | `src/tasks/**/*` |
41+
| MCP thin adapter | `src/mcp/server.ts`, `src/mcp/tools/taskTools.ts`, `src/mcp/handlers/taskHandlers.ts` |
42+
| CLI thin adapter | `src/commands/ai.ts`, `src/cli/commands/*` |
43+
| Core indexing and graph | `src/core/*` |
4344

44-
## CODE MAP
45-
| Symbol | Type | Location | Role |
46-
|--------|------|----------|------|
47-
| `indexer` | fn | `core/indexer.ts` | Full repository indexing |
48-
| `incrementalIndexer` | fn | `core/indexerIncremental.ts` | Incremental updates |
49-
| `GitAiService` | class | `mcp/index.ts` | MCP entry point |
50-
| `cozoQuery` | fn | `core/cozo.ts` | Graph DB queries |
51-
| `semanticSearch` | fn | `core/semantic.ts` | Vector similarity |
52-
| `repoMap` | fn | `core/repoMap.ts` | PageRank-based repo overview |
53-
| `resolveGitRoot` | fn | `core/git.ts` | Repo boundary detection |
45+
## Primary Entry Points
5446

55-
## CONVENTIONS
56-
- **strict: true** TypeScript - no implicit any
57-
- **Imports**: Node built-ins → external deps → internal modules
58-
- **Formatting**: 2 spaces, single quotes, trailing commas
59-
- **Errors**: Structured JSON logging via `createLogger`
60-
- **CLI output**: JSON on stdout, logs on stderr
61-
- **External inputs**: Use `unknown`, narrow early
47+
- `createCodeContextEngine()` is the main product entry point.
48+
- `code-context-engine ai serve` starts the thin MCP adapter.
49+
- `code-context-engine ai index --overwrite` rebuilds local index state.
6250

63-
## ANTI-PATTERNS (THIS PROJECT)
64-
- Never suppress type errors (`as any`, `@ts-ignore`)
65-
- Never throw raw strings - throw `Error` objects
66-
- Never commit without explicit request
67-
- No empty catch blocks
51+
## Thin MCP Surface
6852

69-
## UNIQUE STYLES
70-
- `.git-ai/` directory for all index data (not config files)
71-
- MCP tools require explicit `path` argument
72-
- Multi-language parser architecture (TS, Go, Rust, Python, C, Markdown, YAML)
73-
- PageRank-based repo-map for code importance scoring
53+
- `check_index`
54+
- `rebuild_index`
55+
- `read_file`
56+
- `repo_map`
57+
- `lexical_search`
58+
- `implementation_context`
59+
- `find_tests`
60+
- `find_impact`
61+
- `find_extension_points`
62+
- `review_context_for_diff`
7463

75-
## COMMANDS
76-
```bash
77-
npm i # Install dependencies
78-
npm run build # Build to dist/
79-
npm run start # Dev run (e.g., --help)
80-
npm test # Build + node --test
81-
node dist/bin/git-ai.js --help # Validate packaged output
82-
```
64+
## Retrieval Policy
8365

84-
## NOTES
85-
- Indices auto-update on git operations
86-
- `checkIndex` gates symbol/semantic/graph queries
87-
- MCP server exposes git-ai tools for external IDEs
66+
- lexical / symbol first
67+
- graph expand second
68+
- semantic rerank last

0 commit comments

Comments
 (0)