-
Notifications
You must be signed in to change notification settings - Fork 0
feat: introduce code context runtime foundation #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,87 +1,68 @@ | ||
| # PROJECT KNOWLEDGE BASE | ||
| # Code Context Engine Knowledge Base | ||
|
|
||
| **Generated:** 2026-02-02 01:45 | ||
| **Commit:** bd3baf8 | ||
| **Branch:** refactor/cli-commands-architecture | ||
| ## Overview | ||
|
|
||
| ## OVERVIEW | ||
| 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/`. | ||
| 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. | ||
|
|
||
| ## STRUCTURE | ||
| ``` | ||
| git-ai-cli-v2/ | ||
| ├── src/ | ||
| │ ├── cli/ # CLI command architecture (NEW: registry + handlers + schemas) | ||
| │ │ ├── types.ts # Core types, executeHandler | ||
| │ │ ├── registry.ts # Handler registry (20 commands) | ||
| │ │ ├── helpers.ts # Shared utilities | ||
| │ │ ├── schemas/ # Zod validation schemas | ||
| │ │ ├── handlers/ # Business logic handlers | ||
| │ │ └── commands/ # Commander.js wrappers | ||
| │ ├── commands/ # Command aggregator (ai.ts only) | ||
| │ ├── core/ # Indexing, graph, storage, parsers | ||
| │ └── mcp/ # MCP server implementation | ||
| ├── test/ # Node test runner tests | ||
| ├── dist/ # Build output | ||
| └── .git-ai/ # Indices (LanceDB) | ||
| ## Structure | ||
|
|
||
| ```text | ||
| src/ | ||
| index.ts public runtime entry | ||
| domain/ stable agent-facing contracts | ||
| retrieval/ | ||
| runtime.ts createCodeContextEngine() | ||
| lexical/ lexical-first retrieval | ||
| symbol/ higher-level navigation capabilities | ||
| tasks/ | ||
| review/ review context builders | ||
| impact/ impact analysis | ||
| tests/ test discovery and mapping | ||
| implementation/ implementation context | ||
| extensions/ extension point discovery | ||
| diff/ diff parsing and analysis | ||
| core/ parsers, indexers, LanceDB, CozoDB, repo-map | ||
| cli/ thin local adapter | ||
| commands/ ai command aggregation | ||
| mcp/ thin MCP adapter | ||
| bin/ | ||
| code-context-engine.ts package CLI entry | ||
| ``` | ||
|
|
||
| ## WHERE TO LOOK | ||
| | Task | Location | | ||
| ## Where To Look | ||
|
|
||
| | Need | Location | | ||
| |------|----------| | ||
| | CLI commands | `src/cli/commands/*.ts` (new architecture) | | ||
| | CLI handlers | `src/cli/handlers/*.ts` (business logic) | | ||
| | CLI schemas | `src/cli/schemas/*.ts` (Zod validation) | | ||
| | Handler registry | `src/cli/registry.ts` (all 20 commands) | | ||
| | Command aggregator | `src/commands/ai.ts` (entry point) | | ||
| | Indexing logic | `src/core/indexer.ts`, `src/core/indexerIncremental.ts` | | ||
| | Graph queries | `src/core/cozo.ts`, `src/core/astGraph.ts` | | ||
| | Semantic search | `src/core/semantic.ts`, `src/core/sq8.ts` | | ||
| | Repo map | `src/core/repoMap.ts` | | ||
| | MCP tools | `src/mcp/`, `src/core/graph.ts` | | ||
| | Language parsers | `src/core/parser/*.ts` | | ||
| | Runtime API | `src/index.ts`, `src/retrieval/runtime.ts` | | ||
| | Stable contracts | `src/domain/*.ts` | | ||
| | Lexical retrieval | `src/retrieval/lexical/*.ts` | | ||
| | Symbol navigation | `src/retrieval/symbol/*.ts` | | ||
| | Task builders | `src/tasks/**/*` | | ||
| | MCP thin adapter | `src/mcp/server.ts`, `src/mcp/tools/taskTools.ts`, `src/mcp/handlers/taskHandlers.ts` | | ||
| | CLI thin adapter | `src/commands/ai.ts`, `src/cli/commands/*` | | ||
| | Core indexing and graph | `src/core/*` | | ||
|
|
||
| ## CODE MAP | ||
| | Symbol | Type | Location | Role | | ||
| |--------|------|----------|------| | ||
| | `indexer` | fn | `core/indexer.ts` | Full repository indexing | | ||
| | `incrementalIndexer` | fn | `core/indexerIncremental.ts` | Incremental updates | | ||
| | `GitAiService` | class | `mcp/index.ts` | MCP entry point | | ||
| | `cozoQuery` | fn | `core/cozo.ts` | Graph DB queries | | ||
| | `semanticSearch` | fn | `core/semantic.ts` | Vector similarity | | ||
| | `repoMap` | fn | `core/repoMap.ts` | PageRank-based repo overview | | ||
| | `resolveGitRoot` | fn | `core/git.ts` | Repo boundary detection | | ||
| ## Primary Entry Points | ||
|
|
||
| ## CONVENTIONS | ||
| - **strict: true** TypeScript - no implicit any | ||
| - **Imports**: Node built-ins → external deps → internal modules | ||
| - **Formatting**: 2 spaces, single quotes, trailing commas | ||
| - **Errors**: Structured JSON logging via `createLogger` | ||
| - **CLI output**: JSON on stdout, logs on stderr | ||
| - **External inputs**: Use `unknown`, narrow early | ||
| - `createCodeContextEngine()` is the main product entry point. | ||
| - `code-context-engine ai serve` starts the thin MCP adapter. | ||
| - `code-context-engine ai index --overwrite` rebuilds local index state. | ||
|
|
||
| ## ANTI-PATTERNS (THIS PROJECT) | ||
| - Never suppress type errors (`as any`, `@ts-ignore`) | ||
| - Never throw raw strings - throw `Error` objects | ||
| - Never commit without explicit request | ||
| - No empty catch blocks | ||
| ## Thin MCP Surface | ||
|
|
||
| ## UNIQUE STYLES | ||
| - `.git-ai/` directory for all index data (not config files) | ||
| - MCP tools require explicit `path` argument | ||
| - Multi-language parser architecture (TS, Go, Rust, Python, C, Markdown, YAML) | ||
| - PageRank-based repo-map for code importance scoring | ||
| - `check_index` | ||
| - `rebuild_index` | ||
| - `read_file` | ||
| - `repo_map` | ||
| - `lexical_search` | ||
| - `implementation_context` | ||
| - `find_tests` | ||
| - `find_impact` | ||
| - `find_extension_points` | ||
| - `review_context_for_diff` | ||
|
|
||
| ## COMMANDS | ||
| ```bash | ||
| npm i # Install dependencies | ||
| npm run build # Build to dist/ | ||
| npm run start # Dev run (e.g., --help) | ||
| npm test # Build + node --test | ||
| node dist/bin/git-ai.js --help # Validate packaged output | ||
| ``` | ||
| ## Retrieval Policy | ||
|
|
||
| ## NOTES | ||
| - Indices auto-update on git operations | ||
| - `checkIndex` gates symbol/semantic/graph queries | ||
| - MCP server exposes git-ai tools for external IDEs | ||
| - lexical / symbol first | ||
| - graph expand second | ||
| - semantic rerank last | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HIGH · 移除了重要的编码规范和反模式文档
原文件包含 CONVENTIONS 和 ANTI-PATTERNS 章节,定义了 TypeScript strict 模式、错误处理规范、禁止 as any 等关键编码标准。这些规范对维护代码质量至关重要,移除后可能导致新贡献者不了解项目约定,引入不一致的代码风格或潜在缺陷。
建议:确认这些规范是否已迁移至其他文档(如 CONTRIBUTING.md 或 src/cli/AGENTS.md)。如未迁移,建议保留或在新架构文档中引用,确保编码标准不丢失。