Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
refactor(parser): Refactor code summaries to fixed skeleton-first routing (#3568)
zgy49b182045b42
diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.tsindex d0f8582ed..5f491e81b 100644--- a/docs/.vitepress/config.ts+++ b/docs/.vitepress/config.ts@@ -188,8 +188,7 @@ const apiReferenceSidebar = {text: 'Retrieval & Relations',items: [['06-retrieval.md', 'Retrieval'],- ['13-relations.md', 'Relations'],- ['21-code.md', 'Code Navigation']+ ['13-relations.md', 'Relations']]},{@@ -248,8 +247,7 @@ const apiReferenceSidebar = {text: '检索与关系',items: [['06-retrieval.md', '检索'],- ['13-relations.md', '关系'],- ['21-code.md', '代码导航']+ ['13-relations.md', '关系']]},{diff --git a/docs/design/2026-05-20-code-tools-design.md b/docs/design/2026-05-20-code-tools-design.mddeleted file mode 100644index 27e5f1ade..000000000--- a/docs/design/2026-05-20-code-tools-design.md+++ /dev/null@@ -1,293 +0,0 @@-# Code Tools MCP 集成设计文档--**日期**:2026-05-20-**范围**:向 OpenViking 新增 `code_outline`、`code_search`、`code_expand` 三个 MCP 工具-------## 概述--三个新 MCP 工具通过 OpenViking 现有的 `@mcp.tool()` 端点向 AI Agent 暴露代码结构导航能力。典型使用顺序:--```-code_outline → 查看文件符号结构-code_search → 跨目录查找符号位置-code_expand → 展开完整实现代码-```--**仅支持 `viking://` URI**(不支持直接本地路径),与现有 `read`、`grep`、`list` 等工具保持一致,符合服务端既有安全边界(参见 `local_input_guard.py`:HTTP MCP 端拒绝直接的本地文件系统路径)。需要分析本地代码时,先用 `add_resource` 入库为 `viking://` 资源即可。-------## 架构--```-mcp_endpoint.py- ├── code_outline(uri) → openviking.parse.parsers.code.ast- ├── code_search(query, uri) → openviking.parse.parsers.code.ast- └── code_expand(uri, symbol) → openviking.parse.parsers.code.ast--openviking/parse/parsers/code/ast/- ├── skeleton.py (修改:给 FunctionSig、ClassSkeleton 加行号字段)- ├── extractor.py (修改:新增 extract() 返回 CodeSkeleton,extract_skeleton 复用之)- ├── code_tools.py (新增:outline_file、search_symbols、expand_symbol)- └── languages/- ├── python.py (修改:读取 node.start_point / end_point)- ├── js_ts.py (修改)- ├── go.py (修改)- ├── rust.py (修改)- ├── java.py (修改)- ├── cpp.py (修改:3 处函数提取路径都要改)- └── ...-```--无新增依赖,使用已安装的 `tree-sitter` Python 绑定。-------## 各组件改动说明--### 1. `skeleton.py` — 新增行号字段--给 `FunctionSig` 和 `ClassSkeleton` 加 `line_start`、`line_end`:--```python-@dataclass-class FunctionSig:- name: str- params: str- return_type: str- docstring: str- line_start: int = 0 # 1-indexed,起始行(含)- line_end: int = 0 # 1-indexed,结束行(含)--@dataclass-class ClassSkeleton:- name: str- bases: List[str]- docstring: str- methods: List[FunctionSig] = field(default_factory=list)- line_start: int = 0- line_end: int = 0-```--默认值 `0` 保持向后兼容,现有调用方(`extract_skeleton`、嵌入流水线)无需改动。--`to_text()` **不改**——它服务于 embedding/LLM 输入场景,行号会污染那条路径。outline 的展示由 `code_tools.outline_file()` 独立实现。--### 2. `extractor.py` — 新增 `extract()` 返回 `CodeSkeleton`--现有 `ASTExtractor.extract_skeleton()` 返回的是格式化文本字符串,不是 `CodeSkeleton` 对象。代码工具需要原始结构,因此在 `ASTExtractor` 上新增公开方法:--```python-def extract(self, file_name: str, content: str) -> Optional[CodeSkeleton]:- """Return raw CodeSkeleton or None for unsupported/failed extraction."""- lang = self._detect_language(file_name)- extractor = self._get_extractor(lang)- if extractor is None:- return None- try:- return extractor.extract(file_name, content)- except Exception as e:- logger.warning(- "AST extraction failed for '%s' (language: %s): %s", file_name, lang, e- )- return None-```--`extract_skeleton()` 重构为先调 `extract()`、再 `.to_text(verbose)`,逻辑完全等价。--### 3. 各语言提取器 — 读取节点行号--每个 `_extract_function` / `_extract_class` / `_extract_struct` 在构造 `FunctionSig` / `ClassSkeleton` 时多传两个参数:--```python-# tree-sitter node.start_point = (row, col),0-indexed-line_start = node.start_point[0] + 1-line_end = node.end_point[0] + 1-```--**特别注意 `cpp.py`**:该文件有三处函数构造路径——`_extract_function_declarator`、`_extract_function`、`_extract_function_proto`——三处都要传行号。其他语言每个文件改 2 处(函数 + 类/struct)即可。--### 4. `code_tools.py` — 新增模块--新建 `openviking/parse/parsers/code/ast/code_tools.py`,三个纯函数,无 I/O 无异步,输入字符串、返回格式化字符串。I/O 与逻辑分离便于独立测试。--```python-def outline_file(content: str, file_name: str) -> str:- """返回源文件的符号结构(含行号、总行数)。- 内部:ASTExtractor.extract() -> CodeSkeleton -> 专用 outline 格式器。"""--def search_symbols(query: str, files: list[tuple[str, str]]) -> str:- """在多个 (content, file_name) 中搜索符号名包含 query 的符号- (大小写不敏感子串匹配)。"""--def expand_symbol(content: str, file_name: str, symbol: str) -> str:- """返回符号完整源码。symbol 支持两种形式:- - 'foo' 匹配任意位置同名函数/类/方法- - 'Foo.bar' 精确匹配 Foo 类下的 bar 方法- 同名多个返回第一个;区分大小写。"""-```--### 5. `mcp_endpoint.py` — 新增三个工具--```python-async def code_outline(uri: str) -> str:- """展示源文件的符号结构——类、函数、方法及其行号范围。- uri 必须是 viking:// URI。"""--async def code_search(query: str, uri: str) -> str:- """在 viking:// 目录下按名称搜索符号。query 对符号名做大小写不敏感- 子串匹配,返回匹配符号及其文件位置和行号。最多扫描 200 个文件。- uri 必填——不提供默认值以避免误扫整个 VikingFS。"""--async def code_expand(uri: str, symbol: str) -> str:- """返回源文件中指定符号(函数、类或方法)的完整源码。- symbol 支持 'bar' 和 'Foo.bar' 两种形式。"""-```-------## URI 解析--仅处理 `viking://` URI,通过 `service.fs` 调用:--```-viking://resources/owner/repo/src/auth.py- → service.fs.read(uri, ctx=ctx) # 文件内容--viking://resources/owner/repo/src/- → service.fs.ls(uri, ctx=ctx, recursive=True, output="original")- 返回 dict 列表,字段:name、isDir、uri(camelCase)-```--辅助函数 `_resolve_code_dir(uri, service, ctx)` 完成 ls + 按扩展名过滤 + 并发读取。--支持的扩展名(与 `extractor._EXT_MAP` 对齐):-`.py .js .jsx .ts .tsx .java .c .cpp .cc .h .hpp .rs .go .cs .php .lua`-------## 数据流--### `code_outline(uri)`--```-uri- → service.fs.read() → content- → ASTExtractor.extract() → CodeSkeleton(或 None)- → outline_file() → 格式化字符串-```--None 时直接返回 `"不支持的语言:{file_name}"` 或 `"解析 {file_name} 失败"`。--### `code_search(query, uri)`--```-uri(目录)- → service.fs.ls(recursive=True, output="original")- → 按扩展名过滤,截断到 200 个 → list[uri]- → asyncio.gather + Semaphore(10) 并发 service.fs.read()- → list[(content, file_name)]- → 逐文件 ASTExtractor.extract() → list[CodeSkeleton]- → search_symbols(query, ...) → 格式化字符串-```--并发模式参考已有 `read` 工具(`mcp_endpoint.py:290`)。解析失败的文件跳过、记录 warning,不中断整体搜索。--### `code_expand(uri, symbol)`--```-uri- → service.fs.read() → content- → ASTExtractor.extract() → CodeSkeleton- → expand_symbol() → content 的 [line_start-1 : line_end] 行 + 位置标注-```-------## 输出格式--### `code_outline`--`outline_file()` 不复用 `CodeSkeleton.to_text()`(那是嵌入流水线格式),自带格式器:--```-auth.py [Python, 120 lines]--imports: os, typing.Optional, fastapi.HTTPException--class AuthHandler L18-62- + __init__(self, secret: str) L20-25- + authenticate(self, token: str) -> Optional[User] L27-45- + verify_scope(self, user: User, scope: str) -> bool L47-60--def get_handler() -> AuthHandler L65-70-```--- 头部行的语言名直接用 `CodeSkeleton.language`(Python/JavaScript/TypeScript 等,保留 `extractor` 已有 casing)-- 总行数由 `outline_file()` 内 `content.count("\n") + 1` 计算-- 不输出 docstring,行号是导航主信息--### `code_search`--```-2 matches for "authenticate" (scanned 47 files)--src/auth.py- AuthHandler.authenticate L27-45- authenticate_request L75-88-```--如果到达 200 文件上限,输出末尾追加 `(scanning stopped at 200-file cap; narrow uri to search more)`。--### `code_expand`--```-# src/auth.py L27-45--def authenticate(self, token: str) -> Optional[User]:- payload = jwt.decode(token, self.secret)- user_id = payload.get("sub")- if not user_id:- raise HTTPException(status_code=401)- return db.get(User, user_id)-```-------## 错误处理--| 场景 | 工具 | 返回内容 |-|------|------|---------|-| 不支持的语言(扩展名不在 `_EXT_MAP`) | outline / expand | `"不支持的语言:{file_name}"` |-| 不支持的语言 | search | 静默跳过该文件 |-| 解析失败 | outline / expand | `"解析 {file_name} 失败:{reason}"`(明确错误,**不** "继续") |-| 解析失败 | search | 记录 warning,跳过该文件,继续 |-| 符号未找到 | expand | `"在 {file_name} 中未找到符号 '{symbol}'"` |-| URI 不存在 | 全部 | 透传 `AGFSNotFoundError` 或 `FileNotFoundError` |-| 目录为空 / 无可解析文件 | search | `"在 {uri} 中未找到支持的源文件"` |-| 传入非 viking:// URI | 全部 | `"仅支持 viking:// URI;本地路径请先 add_resource"` |-------## 涉及文件清单--| 文件 | 改动类型 |-|------|---------|-| `openviking/parse/parsers/code/ast/skeleton.py` | 新增 `line_start`、`line_end` 字段(默认 0) |-| `openviking/parse/parsers/code/ast/extractor.py` | 新增 `extract()` 返回 `CodeSkeleton`;`extract_skeleton` 重构复用之 |-| `openviking/parse/parsers/code/ast/languages/python.py` | 读取节点行号(2 处) |-| `openviking/parse/parsers/code/ast/languages/js_ts.py` | 读取节点行号(2 处) |-| `openviking/parse/parsers/code/ast/languages/go.py` | 读取节点行号(2 处:function、struct) |-| `openviking/parse/parsers/code/ast/languages/rust.py` | 读取节点行号(2 处) |-| `openviking/parse/parsers/code/ast/languages/java.py` | 读取节点行号(2 处) |-| `openviking/parse/parsers/code/ast/languages/cpp.py` | 读取节点行号(**3 处**:declarator、function、proto) |-| `openviking/parse/parsers/code/ast/languages/csharp.py` | 读取节点行号(2 处) |-| `openviking/parse/parsers/code/ast/languages/php.py` | 读取节点行号(2 处) |-| `openviking/parse/parsers/code/ast/languages/lua.py` | 读取节点行号(2 处) |-| `openviking/parse/parsers/code/ast/code_tools.py` | **新增文件** |-| `openviking/server/mcp_endpoint.py` | 新增 3 个工具 + viking:// 校验辅助 |diff --git a/docs/en/agent-integrations/10-opencode.md b/docs/en/agent-integrations/10-opencode.mdindex b1171abcd..7a91a912c 100644--- a/docs/en/agent-integrations/10-opencode.md+++ b/docs/en/agent-integrations/10-opencode.md@@ -136,7 +136,6 @@ Restart OpenCode after installation. In an OpenCode session, the plugin should e- `openviking_recall`, `openviking_search`, `openviking_find`- `openviking_read`, `openviking_list`, `openviking_grep`, `openviking_glob`- `openviking_remember`, `openviking_add_resource`, `openviking_forget`, `openviking_health`-- `openviking_code_search`, `openviking_code_outline`, `openviking_code_expand`Ask OpenCode to search or browse OpenViking memory. Runtime state and errors are written to:diff --git a/docs/en/api/01-overview.md b/docs/en/api/01-overview.mdindex abef9d5ce..5a393b6e0 100644--- a/docs/en/api/01-overview.md+++ b/docs/en/api/01-overview.md@@ -472,7 +472,7 @@ This catalog follows the routes actually mounted by the server. Each group headi| POST | `/api/v1/sessions/{session_id}/used` | Record context or skills actually used || POST | `/api/v1/search/recall` | Recall memory as injection-ready context |-### [Retrieval](06-retrieval.md), [Code Retrieval](21-code.md), and [Relations](13-relations.md)+### [Retrieval](06-retrieval.md) and [Relations](13-relations.md)| Method | Path | Description ||--------|------|-------------|@@ -480,9 +480,6 @@ This catalog follows the routes actually mounted by the server. Each group headi| POST | `/api/v1/search/search` | Context-aware search || POST | `/api/v1/search/grep` | Content pattern search || POST | `/api/v1/search/glob` | File pattern matching |-| POST | `/api/v1/code/outline` | Extract code structure |-| POST | `/api/v1/code/search` | Search code |-| POST | `/api/v1/code/expand` | Expand code context || GET | `/api/v1/relations` | Get resource relations || POST | `/api/v1/relations/link` | Create a resource link || DELETE | `/api/v1/relations/link` | Delete a resource link |diff --git a/docs/en/api/21-code.md b/docs/en/api/21-code.mddeleted file mode 100644index 64be6075a..000000000--- a/docs/en/api/21-code.md+++ /dev/null@@ -1,119 +0,0 @@-# Code Navigation--The Code Navigation API extracts structure, searches symbols, and expands symbols in source code already imported into OpenViking. Every `uri` must be a `viking://` URI; import local code through the Resources API first.--**Code entry points**:--- `openviking/server/routers/code.py` - HTTP routes and request models-- `openviking/parse/parsers/code/ast/code_tools.py` - outline, search, and symbol expansion--## API Reference--### outline()--Extract the symbol outline of one source file.--| Parameter | Type | Required | Description |-|-----------|------|----------|-------------|-| `uri` | string | Yes | `viking://` URI of an imported source file |--**HTTP API**--```http-POST /api/v1/code/outline-Content-Type: application/json-```--```bash-curl -X POST http://localhost:1933/api/v1/code/outline \- -H "Content-Type: application/json" \- -H "X-API-Key: your-key" \- -d '{"uri":"viking://resources/project/src/main.py"}'-```--**Response Example**--`result` is a text outline suitable for display or direct Agent context.--```json-{- "status": "ok",- "result": "viking://resources/project/src/main.py [python, 24 lines]\n\nclass SessionService L16-24\n\ndef main() L8-12"-}-```--### search()--Search symbols in supported source files below a URI. One request scans at most 200 files; when capped, `result` ends with a prompt to narrow the URI.--| Parameter | Type | Required | Description |-|-----------|------|----------|-------------|-| `uri` | string | Yes | File or directory URI to search recursively |-| `query` | string | Yes | Non-empty symbol name or search term |--**HTTP API**--```http-POST /api/v1/code/search-Content-Type: application/json-```--```bash-curl -X POST http://localhost:1933/api/v1/code/search \- -H "Content-Type: application/json" \- -H "X-API-Key: your-key" \- -d '{"uri":"viking://resources/project/src","query":"SessionService"}'-```--**Response Example**--```json-{- "status": "ok",- "result": "1 matches for \"SessionService\" (scanned 8 files)\n\nviking://resources/project/src/session.py\n SessionService L16-24"-}-```--### expand()--Return the complete code block for one symbol in a source file.--| Parameter | Type | Required | Description |-|-----------|------|----------|-------------|-| `uri` | string | Yes | Source file URI containing the symbol |-| `symbol` | string | Yes | Non-empty symbol name to expand |--**HTTP API**--```http-POST /api/v1/code/expand-Content-Type: application/json-```--```bash-curl -X POST http://localhost:1933/api/v1/code/expand \- -H "Content-Type: application/json" \- -H "X-API-Key: your-key" \- -d '{"uri":"viking://resources/project/src/main.py","symbol":"main"}'-```--**Response Example**--```json-{- "status": "ok",- "result": "# viking://resources/project/src/main.py L8-10 (main)\n\ndef main():\n service = SessionService()\n service.run()"-}-```--The current implementation returns business failures such as a non-`viking://` URI, an empty query or symbol, or a non-text file with `status="ok"` and an `Error:` message in `result`. A request body missing required fields returns HTTP `400` with `INVALID_ARGUMENT`.--## Current Client Support--These endpoints are currently server-only HTTP capabilities. They are not wrapped by the public Python, TypeScript, or Go SDKs or by the `ov` CLI, so this page shows only the HTTP tab.--## Related Documentation--- [Resources](02-resources.md) - import source code-- [Retrieval](06-retrieval.md) - general semantic and pattern retrieval-- [Content](12-content.md) - read source file contentdiff --git a/docs/en/concepts/06-extraction.md b/docs/en/concepts/06-extraction.mdindex 08c24be40..ccb4a9513 100644--- a/docs/en/concepts/06-extraction.md+++ b/docs/en/concepts/06-extraction.md@@ -122,7 +122,7 @@ Leaf directories → Parent directories → Root5. **Write files**: Save to AGFS6. **Vectorize**: Create Context and queue to EmbeddingQueue-### Configuration Parameters+### Processing Limits| Parameter | Default | Description ||-----------|---------|-------------|@@ -130,64 +130,23 @@ Leaf directories → Parent directories → Root| `max_images_per_call` | 10 | Max images per VLM call || `max_sections_per_call` | 20 | Max sections per VLM call |-## Code Skeleton Extraction (AST Mode)+## Code Skeleton Extraction-For code files, OpenViking supports AST-based skeleton extraction via tree-sitter as a lightweight alternative to LLM summarization, significantly reducing processing cost.+For code files, OpenViking uses a fixed skeleton extraction route. This route is built into the code summary pipeline and is not selected or tuned by per-language parser settings.-### Modes+### What Skeleton Extraction Includes-Controlled by `code_summary_mode` in `ov.conf` (see [Configuration](../guides/01-configuration.md#code)):+The skeleton can include imports, classes, methods, functions, and other language-level symbols. Exact output depends on the maintained query or generic parser result for that language, but the route itself is fixed.-| Mode | Description |-|------|-------------|-| `"ast"` | Extract structural skeleton for files ≥100 lines, skip LLM calls (**default**) |-| `"llm"` | Always use LLM for summarization (original behavior) |-| `"ast_llm"` | Extract AST skeleton first, then pass it as context to LLM for summarization |+### Extraction Route-### What AST Extracts+Code skeleton extraction follows this fixed order:-The skeleton includes:+1. Use a maintained `tags.scm` query when one exists for the language.+2. If no corresponding `tags.scm` exists, use `tree-sitter-language-pack.process()`.+3. Invoke `semantic.code_summary` only as fallback when the extraction route produces no useful skeleton.-- Module-level docstring (first line)-- Import statement list-- Class names, base classes, and method signatures (`ast` mode: first-line docstrings only; `ast_llm` mode: full docstrings)-- Top-level function signatures--### Supported Languages--The following languages have dedicated extractors built on tree-sitter:--| Language | Status |-|----------|--------|-| Python | Supported |-| JavaScript / TypeScript | Supported |-| Java | Supported |-| C / C++ | Supported |-| Rust | Supported |-| Go | Supported |-| C# | Supported |-| PHP | Supported |-| Lua | Supported |--Other languages automatically fall back to LLM.--### Fallback Behavior--The following conditions trigger automatic fallback to LLM, with the reason logged. The overall pipeline is unaffected:--- Language not in the supported list-- File has fewer than 100 lines-- AST parse error-- Extraction produces an empty skeleton--### File Structure--```-openviking/parse/parsers/code/ast/-├── extractor.py # Language detection and dispatch-├── skeleton.py # CodeSkeleton / FunctionSig / ClassSkeleton data structures-└── languages/ # Per-language extractors-```+This routing applies to short and long code files alike.## Three Context Types Extractiondiff --git a/docs/en/guides/01-configuration.md b/docs/en/guides/01-configuration.mdindex 97fb549ea..edb1cec85 100644--- a/docs/en/guides/01-configuration.md+++ b/docs/en/guides/01-configuration.md@@ -793,39 +793,9 @@ Configuration for Feishu/Lark cloud document parsing. See [Resources](../api/02-### code-Controls how code files are summarized via `code_summary_mode`. Both config formats are equivalent:+Code skeleton extraction is built into the code summary pipeline and has no parser-level configuration. OpenViking first uses maintained `tags.scm` queries when one exists for the language; if no corresponding `tags.scm` exists, it uses `tree-sitter-language-pack.process()`; when the current extraction route produces no useful skeleton, it invokes `semantic.code_summary` as fallback.-```json-{- "code": {- "code_summary_mode": "ast"- }-}-```--```json-{- "parsers": {- "code": {- "code_summary_mode": "ast"- }- }-}-```--Set `code_summary_mode` to one of:--| Value | Description | Default |-|-------|-------------|---------|-| `"ast"` | Extract AST skeleton (class names, method signatures, first-line docstrings, imports) for files ≥100 lines, skip LLM calls. **Recommended for large-scale code indexing** | ✓ |-| `"llm"` | Always use LLM for summarization (higher cost) | |-| `"ast_llm"` | Extract AST skeleton (with full docstrings) first, then pass it as context to LLM (highest quality, moderate cost) | |--AST extraction supports: Python, JavaScript/TypeScript, Java, C/C++, Rust, Go, C#, PHP,-and Lua. Other languages, extraction failures, or empty skeletons automatically fall back-to LLM.--See [Code Skeleton Extraction](../concepts/06-extraction.md#code-skeleton-extraction-ast-mode) for details.+The remaining `code` configuration fields are for remote code resource network guards and code-hosting allowlists. See [Code Skeleton Extraction](../concepts/06-extraction.md#code-skeleton-extraction) for the extraction route.#### Remote resource network guard@@ -1775,9 +1745,6 @@ For detailed encryption explanations, see [Data Encryption](../concepts/10-encry"project": "string"}},- "code": {- "code_summary_mode": "ast"- },"server": {"host": "127.0.0.1","port": 1933,diff --git a/docs/en/guides/06-mcp-integration.md b/docs/en/guides/06-mcp-integration.mdindex 929d69b52..88bffcea3 100644--- a/docs/en/guides/06-mcp-integration.md+++ b/docs/en/guides/06-mcp-integration.md@@ -129,7 +129,7 @@ If you already have HTTPS configured, just connect to `https://your-server.com/m## Available MCP Tools-Once connected, OpenViking exposes 16 tools:+Once connected, OpenViking exposes 13 tools:| Tool | Description | Key Parameters ||------|-------------|----------------|@@ -145,9 +145,6 @@ Once connected, OpenViking exposes 16 tools:| `grep` | Regex content search across `viking://` files | `uri`, `pattern` (string or array), `case_insensitive`, `node_limit` || `glob` | Find files matching a glob pattern | `pattern`, `uri` (optional scope), `node_limit` || `forget` | Delete any `viking://` URI (use `search` to find it first; pass `recursive=true` to delete a directory) | `uri`, `recursive` (optional) |-| `code_outline` | Show a file's symbol structure (classes, functions, methods, line ranges) without reading bodies. Survey a file before deciding what to `read`. | `uri` (must be a `viking://` **file** URI) |-| `code_search` | Search symbol names (class / function / method) by substring across a `viking://` directory. Returns symbol type, class context, file URI, line range. Scans up to 200 source files. | `query`, `uri` (must be a `viking://` directory; narrow to subdir for deeper coverage) |-| `code_expand` | Return the full source of a single named symbol, avoiding reading the entire file. | `uri` (file), `symbol` (`bar` for top-level or `Foo.bar` for a method) || `health` | Check OpenViking service health | none |> **Note**: MCP exposes the minimum closure for watch management (`list_watches` + `cancel_watch`). Pause / resume / trigger and the unified `update` verb are intentionally not exposed here — use the REST `/api/v1/watches/*` endpoints or the `ov task watch` CLI for those operations.diff --git a/docs/en/guides/10-prompt-guide.md b/docs/en/guides/10-prompt-guide.mdindex cddc9a0c1..6c131b063 100644--- a/docs/en/guides/10-prompt-guide.md+++ b/docs/en/guides/10-prompt-guide.md@@ -324,12 +324,6 @@ These prompts are mainly used to understand user intent before retrieval and decThese prompts are mainly used to generate file-level and directory-level summaries and are an important part of semantic indexing.-- `semantic.code_ast_summary`- - Effective stage: AST skeleton summarization for large code files- - Affects: code file summaries, code retrieval, and structural understanding- - Purpose: generates code summaries from an AST skeleton instead of the full source- - Key inputs: `file_name`, `skeleton`, `output_language`-- `semantic.code_summary`- Effective stage: code file summarization stage- Affects: semantic indexing for code files, code retrieval, and understanding resultsdiff --git a/docs/zh/agent-integrations/06-mcp-clients.md b/docs/zh/agent-integrations/06-mcp-clients.mdindex f7a700f57..f022439f7 100644--- a/docs/zh/agent-integrations/06-mcp-clients.md+++ b/docs/zh/agent-integrations/06-mcp-clients.md@@ -75,7 +75,7 @@ HTTPS 配置、部署模板和完整授权流程详见 [OAuth 2.1 指南](../gui## 可用工具-连接后,OpenViking 会提供检索、记忆、资源、watch、文件系统和代码导航工具。完整工具清单、参数、渐进式文件上传和高级配置见 [MCP 集成指南](../guides/06-mcp-integration.md#可用的-mcp-工具)。+连接后,OpenViking 会提供检索、记忆、资源、watch 和文件系统工具。完整工具清单、参数、渐进式文件上传和高级配置见 [MCP 集成指南](../guides/06-mcp-integration.md#可用的-mcp-工具)。## 故障排查diff --git a/docs/zh/agent-integrations/10-opencode.md b/docs/zh/agent-integrations/10-opencode.mdindex 46f39a1d6..a56da1732 100644--- a/docs/zh/agent-integrations/10-opencode.md+++ b/docs/zh/agent-integrations/10-opencode.md@@ -136,7 +136,6 @@ API key 会由 hooks 和 MCP proxy 作为 `Authorization: Bearer ...` 发送;`- `openviking_recall`、`openviking_search`、`openviking_find`- `openviking_read`、`openviking_list`、`openviking_grep`、`openviking_glob`- `openviking_remember`、`openviking_add_resource`、`openviking_forget`、`openviking_health`-- `openviking_code_search`、`openviking_code_outline`、`openviking_code_expand`可以让 OpenCode 搜索或浏览 OpenViking memory。运行时状态和错误日志会写入:diff --git a/docs/zh/api/01-overview.md b/docs/zh/api/01-overview.mdindex 7bd68e349..e775110cb 100644--- a/docs/zh/api/01-overview.md+++ b/docs/zh/api/01-overview.md@@ -467,7 +467,7 @@ JSON 输出 - 错误:| POST | `/api/v1/sessions/{session_id}/used` | 记录实际使用的上下文或技能 || POST | `/api/v1/search/recall` | 召回记忆并返回可直接注入的上下文 |-### [检索](06-retrieval.md)、[代码检索](21-code.md)与[关系](13-relations.md)+### [检索](06-retrieval.md)与[关系](13-relations.md)| 方法 | 路径 | 说明 ||------|------|------|@@ -475,9 +475,6 @@ JSON 输出 - 错误:| POST | `/api/v1/search/search` | 上下文感知搜索 || POST | `/api/v1/search/grep` | 内容模式搜索 || POST | `/api/v1/search/glob` | 文件模式匹配 |-| POST | `/api/v1/code/outline` | 提取代码结构 |-| POST | `/api/v1/code/search` | 代码搜索 |-| POST | `/api/v1/code/expand` | 展开代码上下文 || GET | `/api/v1/relations` | 获取资源关系 || POST | `/api/v1/relations/link` | 创建资源链接 || DELETE | `/api/v1/relations/link` | 删除资源链接 |diff --git a/docs/zh/api/21-code.md b/docs/zh/api/21-code.mddeleted file mode 100644index d58ef90a5..000000000--- a/docs/zh/api/21-code.md+++ /dev/null@@ -1,119 +0,0 @@-# 代码导航--代码导航 API 对已经导入 OpenViking 的源代码执行结构提取、符号搜索和符号展开。所有 `uri` 必须是 `viking://` URI;本地代码需要先通过资源 API 导入。--**代码入口**:--- `openviking/server/routers/code.py` - HTTP 路由与请求模型-- `openviking/parse/parsers/code/ast/code_tools.py` - 大纲、搜索和符号展开实现--## API 参考--### outline()--提取单个源文件的符号大纲。--| 参数 | 类型 | 必填 | 说明 |-|------|------|------|------|-| `uri` | string | 是 | 已导入源文件的 `viking://` URI |--**HTTP API**--```http-POST /api/v1/code/outline-Content-Type: application/json-```--```bash-curl -X POST http://localhost:1933/api/v1/code/outline \- -H "Content-Type: application/json" \- -H "X-API-Key: your-key" \- -d '{"uri":"viking://resources/project/src/main.py"}'-```--**响应示例**--`result` 是适合直接展示或注入 Agent 上下文的文本大纲。--```json-{- "status": "ok",- "result": "viking://resources/project/src/main.py [python, 24 lines]\n\nclass SessionService L16-24\n\ndef main() L8-12"-}-```--### search()--在指定目录下的受支持源文件中搜索符号。一次请求最多扫描 200 个文件;达到上限时,`result` 末尾会提示缩小 URI 范围。--| 参数 | 类型 | 必填 | 说明 |-|------|------|------|------|-| `uri` | string | 是 | 要递归搜索的文件或目录 URI |-| `query` | string | 是 | 非空的符号名称或搜索词 |--**HTTP API**--```http-POST /api/v1/code/search-Content-Type: application/json-```--```bash-curl -X POST http://localhost:1933/api/v1/code/search \- -H "Content-Type: application/json" \- -H "X-API-Key: your-key" \- -d '{"uri":"viking://resources/project/src","query":"SessionService"}'-```--**响应示例**--```json-{- "status": "ok",- "result": "1 matches for \"SessionService\" (scanned 8 files)\n\nviking://resources/project/src/session.py\n SessionService L16-24"-}-```--### expand()--读取单个文件中指定符号的完整代码片段。--| 参数 | 类型 | 必填 | 说明 |-|------|------|------|------|-| `uri` | string | 是 | 包含目标符号的源文件 URI |-| `symbol` | string | 是 | 要展开的非空符号名称 |--**HTTP API**--```http-POST /api/v1/code/expand-Content-Type: application/json-```--```bash-curl -X POST http://localhost:1933/api/v1/code/expand \- -H "Content-Type: application/json" \- -H "X-API-Key: your-key" \- -d '{"uri":"viking://resources/project/src/main.py","symbol":"main"}'-```--**响应示例**--```json-{- "status": "ok",- "result": "# viking://resources/project/src/main.py L8-10 (main)\n\ndef main():\n service = SessionService()\n service.run()"-}-```--当前实现把“非 `viking://` URI”“空查询或空符号”“非文本文件”等业务失败作为 `status="ok"` 返回,错误说明位于以 `Error:` 开头的 `result` 字符串中。请求体缺少必填字段时返回 HTTP `400` 和 `INVALID_ARGUMENT`。--## 当前客户端支持--这些端点当前是 Server HTTP 能力,尚未进入 Python、TypeScript、Go 公共 SDK 或 `ov` CLI,因此本页只展示 HTTP Tab。--## 相关文档--- [资源](02-resources.md) - 导入源代码-- [检索](06-retrieval.md) - 通用语义与模式检索-- [内容](12-content.md) - 读取源文件内容diff --git a/docs/zh/concepts/06-extraction.md b/docs/zh/concepts/06-extraction.mdindex 574a58b27..e501470b6 100644--- a/docs/zh/concepts/06-extraction.md+++ b/docs/zh/concepts/06-extraction.md@@ -121,7 +121,7 @@ SemanticMsg(5. **写入文件**:保存到 AGFS6. **向量化**:创建 Context 并入队 EmbeddingQueue-### 配置参数+### 处理限制| 参数 | 默认值 | 说明 ||------|--------|------|@@ -129,64 +129,23 @@ SemanticMsg(| `max_images_per_call` | 10 | 单次 VLM 最大图片数 || `max_sections_per_call` | 20 | 单次 VLM 最大章节数 |-## 代码骨架提取(AST 模式)+## 代码骨架提取-对于代码文件,OpenViking 支持基于 tree-sitter 的 AST 骨架提取,作为 LLM 摘要的轻量替代方案,可显著降低处理成本。+对于代码文件,OpenViking 使用固定的代码骨架提取路线。该路线内置在代码摘要流程中,不再通过逐语言解析参数选择或调节。-### 工作模式+### 代码骨架内容-在 `ov.conf` 中通过 `code_summary_mode` 字段控制(参见[配置文档](../guides/01-configuration.md#code)),支持三种模式:+骨架可包含 import、类、方法、函数及其他语言级符号。具体输出取决于该语言维护中的 query 或通用解析结果,但提取路线本身是固定的。-| 模式 | 说明 |-|------|------|-| `"ast"` | 对 ≥100 行的代码文件提取结构骨架,跳过 LLM 调用(**默认**) |-| `"llm"` | 全部走 LLM 生成摘要(原有行为) |-| `"ast_llm"` | 先提取 AST 骨架,再将骨架作为上下文辅助 LLM 生成摘要 |+### 提取路线-### AST 提取内容+代码骨架提取按以下固定顺序执行:-提取的骨架包含:+1. 语言存在维护中的 `tags.scm` 时,优先使用 tags query。+2. 不存在对应的 `tags.scm` 时,使用 `tree-sitter-language-pack.process()`。+3. 两种提取方式都无可用结果时,才将 `semantic.code_summary` 作为兜底处理。-- 模块级 docstring(首行)-- import 语句列表-- 类名、继承关系及方法签名(`ast` 模式仅保留 docstring 首行,`ast_llm` 模式保留完整 docstring)-- 顶层函数签名--### 支持语言--以下语言有专属 extractor,基于 tree-sitter 实现精确提取:--| 语言 | 说明 |-|------|------|-| Python | 完整支持 |-| JavaScript / TypeScript | 完整支持 |-| Java | 完整支持 |-| C / C++ | 完整支持 |-| Rust | 完整支持 |-| Go | 完整支持 |-| C# | 完整支持 |-| PHP | 完整支持 |-| Lua | 完整支持 |--其他语言不在支持列表内,自动 fallback 到 LLM。--### Fallback 机制--以下情况自动回退到 LLM,并在日志中记录原因,整体流程不受影响:--- 语言不在支持列表中-- 文件行数 < 100-- AST 解析报错-- 提取结果为空骨架--### 文件结构--```-openviking/parse/parsers/code/ast/-├── extractor.py # 语言检测 + 分发入口-├── skeleton.py # CodeSkeleton / FunctionSig / ClassSkeleton 数据结构-└── languages/ # 各语言专属 extractor-```+长短代码文件都遵循同一路由。## 三种上下文提取diff --git a/docs/zh/guides/01-configuration.md b/docs/zh/guides/01-configuration.mdindex 2a0aaab93..05dda0ca8 100644--- a/docs/zh/guides/01-configuration.md+++ b/docs/zh/guides/01-configuration.md@@ -762,38 +762,9 @@ ollama pull guoxuter/ov_intent_analysis_sft:v7_q8### code-通过 `code_summary_mode` 控制代码文件的摘要生成方式。以下两种写法等价:+代码骨架提取内置在代码摘要流程中,不再提供解析器级配置。OpenViking 会在语言存在维护中的 `tags.scm` 时优先使用 tags query;不存在对应的 `tags.scm` 时,使用 `tree-sitter-language-pack.process()`;当前提取路线无可用结果时,才将 `semantic.code_summary` 作为兜底处理。-```json-{- "code": {- "code_summary_mode": "ast"- }-}-```--```json-{- "parsers": {- "code": {- "code_summary_mode": "ast"- }- }-}-```--将 `code_summary_mode` 设置为以下三个值之一:--| 值 | 说明 | 默认 |-|----|------|------|-| `"ast"` | 对 ≥100 行的代码文件提取 AST 骨架(类名、方法签名、首行注释、import),跳过 LLM 调用。**推荐用于大规模代码索引** | ✓ |-| `"llm"` | 全部走 LLM 生成摘要(成本较高) | |-| `"ast_llm"` | 先提取 AST 骨架(含完整注释),再将骨架作为上下文辅助 LLM 生成摘要(质量最高,成本居中) | |--AST 提取支持:Python、JavaScript/TypeScript、Java、C/C++、Rust、Go、C#、PHP 和 Lua。-其他语言、提取失败或骨架为空时自动 fallback 到 LLM。--详见 [代码骨架提取](../concepts/06-extraction.md#代码骨架提取ast-模式)。+当前保留的 `code` 配置字段用于远程代码资源的网络防护和代码托管白名单。提取路线详见 [代码骨架提取](../concepts/06-extraction.md#代码骨架提取)。#### 远程资源网络防护@@ -1739,9 +1710,6 @@ Task 记录文件位于所属账号的系统目录:"project": "string"}},- "code": {- "code_summary_mode": "ast"- },"server": {"host": "string","port": 1933,diff --git a/docs/zh/guides/06-mcp-integration.md b/docs/zh/guides/06-mcp-integration.mdindex 0cf549f44..e51909290 100644--- a/docs/zh/guides/06-mcp-integration.md+++ b/docs/zh/guides/06-mcp-integration.md@@ -121,7 +121,7 @@ claude mcp add --transport http openviking \## 可用的 MCP 工具-连接后,OpenViking MCP 端点暴露 16 个工具:+连接后,OpenViking MCP 端点暴露 13 个工具:| 工具 | 说明 | 主要参数 ||------|------|----------|@@ -137,9 +137,6 @@ claude mcp add --transport http openviking \| `grep` | 在 `viking://` 文件中进行正则内容搜索 | `uri`, `pattern`(字符串或数组), `case_insensitive`, `node_limit` || `glob` | 按 glob 模式匹配文件 | `pattern`, `uri`(可选范围), `node_limit` || `forget` | 删除任意 `viking://` URI(先用 `search` 查找;删除目录需 `recursive=true`) | `uri`, `recursive`(可选) |-| `code_outline` | 显示文件的符号结构(类、函数、方法及其行号范围),不读取实现体。在决定 `read` 之前用于快速浏览文件。 | `uri`(必须是 `viking://` **文件** URI) |-| `code_search` | 在 `viking://` 目录下按子串搜索符号名(类 / 函数 / 方法),返回符号类型、所属类、文件 URI、行号范围。最多扫描 200 个源文件。 | `query`, `uri`(必须是 `viking://` 目录;缩小到子目录可获得更深覆盖) |-| `code_expand` | 返回单个命名符号的完整源码,避免读取整个文件。 | `uri`(文件), `symbol`(`bar` 表示顶层,`Foo.bar` 表示方法) || `health` | 检查 OpenViking 服务健康状态 | 无 |> **注**:MCP 仅暴露 watch 管理的最小闭包(`list_watches` + `cancel_watch`)。pause / resume / trigger 和统一的 `update` 动作刻意不在此处暴露,请通过 REST `/api/v1/watches/*` 接口或 `ov task watch` CLI 使用上述操作。diff --git a/docs/zh/guides/10-prompt-guide.md b/docs/zh/guides/10-prompt-guide.mdindex a23c31e61..574a978b5 100644--- a/docs/zh/guides/10-prompt-guide.md+++ b/docs/zh/guides/10-prompt-guide.md@@ -324,12 +324,6 @@ peer_enabled: true这一类 prompt 主要用于文件级和目录级摘要生成,是语义索引构建的重要部分。-- `semantic.code_ast_summary`- - 生效环节:大型代码文件 AST 骨架总结阶段- - 影响能力:代码文件摘要、代码检索和结构理解效果- - 作用:基于 AST 骨架而不是完整源码生成代码摘要- - 关键输入:`file_name`、`skeleton`、`output_language`-- `semantic.code_summary`- 生效环节:代码文件摘要阶段- 影响能力:代码文件语义索引、代码检索与理解结果diff --git a/examples/claude-code-memory-plugin/README_CN.md b/examples/claude-code-memory-plugin/README_CN.mdindex 93f0cc7f8..f48013d09 100644--- a/examples/claude-code-memory-plugin/README_CN.md+++ b/examples/claude-code-memory-plugin/README_CN.md@@ -348,7 +348,7 @@ Claude Code 自带 `MEMORY.md` 文件系统,本插件**与之互补**:### 服务器暴露的 MCP 工具-插件的 `.mcp.json` 启动本地 stdio 代理,代理再连到 OpenViking 服务器原生 HTTP MCP endpoint `/mcp`。Claude 可按需调用服务器提供的检索、记忆、资源、watch、文件系统和代码导航工具。+插件的 `.mcp.json` 启动本地 stdio 代理,代理再连到 OpenViking 服务器原生 HTTP MCP endpoint `/mcp`。Claude 可按需调用服务器提供的检索、记忆、资源、watch 和文件系统工具。完整工具清单和参数详见 [MCP 集成指南](../../docs/zh/guides/06-mcp-integration.md)。diff --git a/examples/codex-memory-plugin/README.md b/examples/codex-memory-plugin/README.mdindex da2cb6943..14ed6ee26 100644--- a/examples/codex-memory-plugin/README.md+++ b/examples/codex-memory-plugin/README.md@@ -161,7 +161,7 @@ Earlier plugin versions configured tuning fields under a `codex` block in `~/.op│Codex ◄── stdio MCP proxy ──► /mcp (find, search, recall,(env/ovcli.conf) remember, resources, watches,- filesystem, code navigation)+ filesystem)```The checked-in `.mcp.json` starts `servers/mcp-proxy.mjs` with `node`. The proxy keeps stdout protocol-clean, reads the same credential sources as the hooks, sends auth and identity headers to `/mcp`, caches the server `mcp-session-id`, and transparently reinitializes once if the server restarts.diff --git a/examples/codex-memory-plugin/scripts/marketplace.test.mjs b/examples/codex-memory-plugin/scripts/marketplace.test.mjsindex f851fa6c4..63887836b 100644--- a/examples/codex-memory-plugin/scripts/marketplace.test.mjs+++ b/examples/codex-memory-plugin/scripts/marketplace.test.mjs@@ -26,8 +26,7 @@ const mcpEndpointPath = join(repoRoot, "openviking", "server", "mcp_endpoint.py"const PLUGIN_NAME = "openviking-memory";const REAL_MCP_TOOLS = ["find", "search", "recall", "read", "list", "remember", "add_resource",- "list_watches", "cancel_watch", "grep", "glob", "forget", "code_outline",- "code_search", "code_expand", "health",+ "list_watches", "cancel_watch", "grep", "glob", "forget", "health",];const LEGACY_TOOL_NAMES = ["openviking_recall", "openviking_store", "openviking_forget", "openviking_health"];diff --git a/examples/opencode-plugin/INSTALL-ZH.md b/examples/opencode-plugin/INSTALL-ZH.mdindex 761616b92..3398fb797 100644--- a/examples/opencode-plugin/INSTALL-ZH.md+++ b/examples/opencode-plugin/INSTALL-ZH.md@@ -137,7 +137,6 @@ user/admin API key 的 API_KEY mode 时应留空。- `openviking_read`、`openviking_list`、`openviking_grep`、`openviking_glob`- `openviking_remember`、`openviking_add_resource`、`openviking_forget`、`openviking_health`- `openviking_list_watches`、`openviking_cancel_watch`-- `openviking_code_search`、`openviking_code_outline`、`openviking_code_expand`如果行为异常,先查看运行时文件:@@ -167,7 +166,6 @@ curl http://localhost:1933/health- `openviking_add_resource`:添加 URL、本地文件、sitemap 或 feed- `openviking_forget`:在用户明确确认后删除 `viking://` URI- `openviking_list_watches` / `openviking_cancel_watch`:查看或取消资源 watch-- `openviking_code_search`、`openviking_code_outline`、`openviking_code_expand`:查看已索引代码符号- `openviking_health`:检查 OpenViking server 健康状态使用建议:diff --git a/examples/opencode-plugin/INSTALL.md b/examples/opencode-plugin/INSTALL.mdindex 08f412f48..d3d058c1f 100644--- a/examples/opencode-plugin/INSTALL.md+++ b/examples/opencode-plugin/INSTALL.md@@ -132,7 +132,6 @@ In a new OpenCode session, ask the agent to browse OpenViking memory or search f- `openviking_read`, `openviking_list`, `openviking_grep`, `openviking_glob`- `openviking_remember`, `openviking_add_resource`, `openviking_forget`, `openviking_health`- `openviking_list_watches`, `openviking_cancel_watch`-- `openviking_code_search`, `openviking_code_outline`, `openviking_code_expand`If anything looks wrong, check the runtime files:@@ -162,7 +161,6 @@ The plugin registers OpenViking's stdio MCP proxy through OpenCode config. The s- `openviking_add_resource`: add a URL, local file, sitemap, or feed.- `openviking_forget`: delete a `viking://` URI after explicit user confirmation.- `openviking_list_watches` / `openviking_cancel_watch`: inspect or cancel resource watches.-- `openviking_code_search`, `openviking_code_outline`, `openviking_code_expand`: inspect indexed code symbols.- `openviking_health`: check OpenViking server health.Usage guidance:diff --git a/examples/opencode-plugin/README.md b/examples/opencode-plugin/README.mdindex ae40ca426..7dd8df7cb 100644--- a/examples/opencode-plugin/README.md+++ b/examples/opencode-plugin/README.md@@ -177,7 +177,6 @@ OpenCode sees the OpenViking MCP server as `openviking`, so tool names are names- `openviking_add_resource`: add a URL, local file, sitemap, or feed.- `openviking_forget`: delete a `viking://` URI after explicit user confirmation.- `openviking_list_watches` / `openviking_cancel_watch`: inspect or cancel resource watches.-- `openviking_code_search`, `openviking_code_outline`, `openviking_code_expand`: inspect indexed code symbols.- `openviking_health`: check OpenViking server health.The proxy forwards the server's real `tools/list` response; the plugin does not maintain a separate native tool list.diff --git a/examples/ov.conf.example b/examples/ov.conf.exampleindex 0c3f6bb53..efe65caae 100644--- a/examples/ov.conf.example+++ b/examples/ov.conf.example@@ -216,15 +216,6 @@"mineru_timeout": 300.0,},"code": {- "code_summary_mode": "ast",- "extract_functions": true,- "extract_classes": true,- "extract_imports": true,- "include_comments": true,- "max_line_length": 1000,- "max_token_limit": 50000,- "truncation_strategy": "head",- "warn_on_truncation": true,"github_raw_domain": "raw.githubusercontent.com","code_hosting_domains": ["github.com",diff --git a/openviking/parse/accessors/http_accessor.py b/openviking/parse/accessors/http_accessor.pyindex 7fe50ed58..315872a72 100644--- a/openviking/parse/accessors/http_accessor.py+++ b/openviking/parse/accessors/http_accessor.py@@ -98,7 +98,6 @@ class URLTypeDetector:**dict.fromkeys(VIDEO_EXTENSIONS, URLType.DOWNLOAD_VIDEO),**dict.fromkeys(DOCUMENT_EXTENSIONS, URLType.DOWNLOAD_DOCUMENT),}-# === IANA Media Type to URL type mapping ===# Maps IANA registered media types to our internal URLType# Patterns can be:@@ -646,7 +645,10 @@ class HTTPAccessor(DataAccessor):get_meta,detected_by_prefix="get_",)- if get_url_type != URLType.UNKNOWN and self._should_refine_url_type(url_type, get_url_type):+ if get_url_type != URLType.UNKNOWN and self._should_refine_url_type(+ url_type,+ get_url_type,+ ):url_type = get_url_typemeta.update(get_meta)meta["refined_by_get_headers"] = True@@ -687,7 +689,10 @@ class HTTPAccessor(DataAccessor):return meta@staticmethod- def _should_refine_url_type(current: URLType, candidate: URLType) -> bool:+ def _should_refine_url_type(+ current: URLType,+ candidate: URLType,+ ) -> bool:"""Only replace ambiguous/default webpage guesses with file types."""if candidate in (URLType.UNKNOWN, URLType.WEBPAGE):return Falsediff --git a/openviking/parse/parsers/code/ast/__init__.py b/openviking/parse/parsers/code/ast/__init__.pyindex 3bd2ca40b..a430f0b3b 100644--- a/openviking/parse/parsers/code/ast/__init__.py+++ b/openviking/parse/parsers/code/ast/__init__.py@@ -1,29 +1,13 @@# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.# SPDX-License-Identifier: AGPL-3.0-"""Public API for AST-based code skeleton extraction."""+"""Public code skeleton extraction API."""-from typing import Optional+from openviking.parse.parsers.code.ast.providers import (+ SkeletonExtractionResult,+ extract_skeleton_result,+)-from openviking.parse.parsers.code.ast.extractor import get_extractor---def extract_skeleton(file_name: str, content: str, verbose: bool = False) -> Optional[str]:- """Extract a skeleton from source code.-- Supports Python, JS/TS, Java, C/C++, Rust, Go via tree-sitter.- Returns None for unsupported languages or on extraction failure,- signalling the caller to fall back to LLM.-- Args:- file_name: File name with extension (used for language detection).- content: Source code content.- verbose: If True, include full docstrings (for ast_llm / LLM input).- If False, only first line of each docstring (for ast / embedding).-- Returns:- Plain-text skeleton string, or None if unsupported / failed.- """- return get_extractor().extract_skeleton(file_name, content, verbose=verbose)---__all__ = ["extract_skeleton"]+__all__ = [+ "SkeletonExtractionResult",+ "extract_skeleton_result",+]diff --git a/openviking/parse/parsers/code/ast/aider_repomap.py b/openviking/parse/parsers/code/ast/aider_repomap.pynew file mode 100644index 000000000..ade3b1727--- /dev/null+++ b/openviking/parse/parsers/code/ast/aider_repomap.py@@ -0,0 +1,154 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: AGPL-3.0+"""Aider RepoMap-style skeleton extraction using vendored tags queries."""++import logging+from functools import lru_cache+from pathlib import Path+from typing import Optional++logger = logging.getLogger(__name__)++_QUERY_DIR = Path(__file__).with_name("queries") / "tree-sitter-language-pack"+_TREE_CONTEXT_OMISSION = "⋮"+_TREE_CONTEXT_CODE_PREFIX = "│"++_LANG_ALIASES = {+ "common_lisp": "commonlisp",+ "emacs_lisp": "elisp",+ "objective_caml": "ocaml",+}+++def _query_language_name(lang: str) -> str:+ return _LANG_ALIASES.get(lang, lang)+++@lru_cache(maxsize=None)+def _load_tag_query(lang: str) -> Optional[str]:+ """Load a maintained tree-sitter tags query for a grep-ast language."""++ query_file = f"{_query_language_name(lang)}-tags.scm"+ query_path = _QUERY_DIR / query_file+ try:+ query_scm = query_path.read_text(encoding="utf-8")+ except FileNotFoundError:+ logger.debug("No maintained tags query for language '%s'", lang)+ return None+ except OSError as exc:+ logger.warning(+ "Failed to load tags query '%s' for language '%s': %s",+ query_file,+ lang,+ exc,+ )+ return None+ return query_scm.strip() or None+++def has_tag_query(file_name: str) -> bool:+ """Return whether a maintained tags query exists for this file."""++ try:+ from grep_ast import filename_to_lang++ lang = filename_to_lang(Path(file_name).name or "source.txt")+ except Exception as exc:+ logger.debug("Unable to detect tags-query language for '%s': %s", file_name, exc)+ return False+ return bool(lang and _load_tag_query(lang))+++def _extract_with_grep_ast(+ file_name: str,+ rel_name: str,+ content: str,+ verbose: bool,+) -> Optional[str]:+ try:+ from grep_ast import TreeContext+ except Exception as exc:+ logger.warning("grep-ast RepoMap extractor unavailable: %s", exc)+ return None++ try:+ _, captures = _query_captures(rel_name, content)+ def_lines = _definition_lines(captures)+ if not def_lines:+ return None++ context = TreeContext(+ rel_name,+ content if content.endswith("\n") else content + "\n",+ color=False,+ line_number=False,+ child_context=False,+ last_line=False,+ margin=0,+ mark_lois=False,+ loi_pad=0,+ show_top_of_file_parent_scope=False,+ )+ context.add_lines_of_interest(def_lines)+ context.add_context()+ rendered = _clean_repromap_rendered(context.format()).strip()+ if not rendered:+ return None++ mode = "verbose" if verbose else "compact"+ return f"# {file_name} [aider-repomap-lite, {mode}]\n\n{rendered}"+ except Exception as exc:+ logger.warning("grep-ast RepoMap extraction failed for '%s': %s", file_name, exc)+ return None+++def _clean_repromap_rendered(rendered: str) -> str:+ """Remove TreeContext visual gutter before skeleton usefulness checks."""++ lines: list[str] = []+ for line in rendered.splitlines():+ if line.strip() == _TREE_CONTEXT_OMISSION:+ continue+ if line.startswith(_TREE_CONTEXT_CODE_PREFIX):+ line = line[len(_TREE_CONTEXT_CODE_PREFIX) :]+ lines.append(line.rstrip())+ return "\n".join(lines)+++def _query_captures(rel_name: str, content: str):+ from grep_ast import filename_to_lang+ from grep_ast.tsl import get_language, get_parser++ lang = filename_to_lang(rel_name)+ if not lang:+ raise ValueError(f"unsupported file language: {rel_name}")+ query_scm = _load_tag_query(lang)+ if not query_scm:+ raise ValueError(f"missing tags query for language: {lang}")++ query_lang = _query_language_name(lang)+ parser = get_parser(query_lang)+ language = get_language(query_lang)+ tree = parser.parse(content.encode("utf-8"))+ query = language.query(query_scm)+ if hasattr(query, "captures"):+ captures = query.captures(tree.root_node)+ else:+ from tree_sitter import QueryCursor++ captures = QueryCursor(query).captures(tree.root_node)+ return lang, captures+++def _definition_lines(captures) -> list[int]:+ lines: set[int] = set()+ if isinstance(captures, dict):+ for tag, nodes in captures.items():+ if str(tag).startswith("name.definition."):+ lines.update(node.start_point[0] for node in nodes)+ return sorted(lines)++ for node, tag in captures:+ if str(tag).startswith("name.definition."):+ lines.add(node.start_point[0])+ return sorted(lines)diff --git a/openviking/parse/parsers/code/ast/code_tools.py b/openviking/parse/parsers/code/ast/code_tools.pydeleted file mode 100644index 963ec81af..000000000--- a/openviking/parse/parsers/code/ast/code_tools.py+++ /dev/null@@ -1,213 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""Pure I/O-free formatters powering the code_outline / code_search / code_expand-MCP tools. Inputs are source strings; outputs are agent-facing text.--The MCP layer handles all URI resolution and I/O; this module deals only with-content -> CodeSkeleton -> formatted text.-"""--from __future__ import annotations--from typing import Iterable, List, Optional, Tuple--from openviking.parse.parsers.code.ast.extractor import get_extractor-from openviking.parse.parsers.code.ast.skeleton import (- CodeSkeleton,- FunctionSig,- _compact_params,-)--CODE_SEARCH_FILE_CAP = 200-CODE_SEARCH_CONCURRENCY = 10---def _entry_field(entry, key: str, fallback_key: str, default):- """Read a field from ls entries that may be dicts (camelCase) or objects (snake_case)."""- if isinstance(entry, dict):- return entry.get(key, default)- return getattr(entry, fallback_key, default)---def filter_code_uris(entries) -> tuple[list[str], bool]:- """Pick file entries whose extension is supported by the AST extractor, capped at 200.-- Returns (uris, capped) where capped is True when the 200-file limit was hit- and there may be more matching files beyond the cap.- """- extractor = get_extractor()- uris: list[str] = []- for e in entries:- is_dir = _entry_field(e, "isDir", "is_dir", False)- if is_dir:- continue- entry_uri = _entry_field(e, "uri", "uri", "")- if not entry_uri:- continue- if extractor.supports(entry_uri):- uris.append(entry_uri)- if len(uris) > CODE_SEARCH_FILE_CAP:- return uris[:CODE_SEARCH_FILE_CAP], True- return uris, False---def _line_span(item) -> str:- if item.line_start and item.line_end:- return f" L{item.line_start}-{item.line_end}"- return ""---def _format_function(fn: FunctionSig, indent: str, prefix: str) -> str:- ret = f" -> {fn.return_type}" if fn.return_type else ""- params = _compact_params(fn.params)- return f"{indent}{prefix}{fn.name}({params}){ret}{_line_span(fn)}"---def _outline_text(skeleton: CodeSkeleton, total_lines: int) -> str:- lines: List[str] = [f"{skeleton.file_name} [{skeleton.language}, {total_lines} lines]"]- if skeleton.module_doc:- first = skeleton.module_doc.split("\n", 1)[0].strip()- if first:- lines.append(f'module: "{first}"')- if skeleton.imports:- lines.append(f"imports: {', '.join(skeleton.imports)}")- lines.append("")-- for cls in skeleton.classes:- bases = f"({', '.join(cls.bases)})" if cls.bases else ""- lines.append(f"class {cls.name}{bases}{_line_span(cls)}")- for method in cls.methods:- lines.append(_format_function(method, " ", "+ "))- lines.append("")-- for fn in skeleton.functions:- lines.append(_format_function(fn, "", "def "))-- return "\n".join(lines).rstrip()---def outline_file(content: str, file_name: str) -> str:- """Return outline view of one source file (header + symbols + line spans).-- Returns an "Error: ..." sentinel string when the language is unsupported or- parsing fails — callers can detect by the "Error:" prefix.- """- skeleton = get_extractor().extract(file_name, content)- if skeleton is None:- return _failure_message(file_name)- total_lines = content.count("\n") + 1 if content else 0- return _outline_text(skeleton, total_lines)---def _failure_message(file_name: str) -> str:- if not get_extractor().supports(file_name):- return f"Error: unsupported language for {file_name}"- return f"Error: failed to parse {file_name}"---def _iter_symbols(skeleton: CodeSkeleton) -> Iterable[Tuple[str, int, int]]:- """Yield (display_name, line_start, line_end) for every symbol."""- for cls in skeleton.classes:- yield cls.name, cls.line_start, cls.line_end- for method in cls.methods:- yield f"{cls.name}.{method.name}", method.line_start, method.line_end- for fn in skeleton.functions:- yield fn.name, fn.line_start, fn.line_end---def search_symbols(query: str, files: List[Tuple[str, str]]) -> str:- """Case-insensitive substring search across symbol names in many files.-- files: list of (content, file_name) tuples. Files whose language is- unsupported or fails to parse are silently skipped (the caller already- filtered by extension).- """- if not query:- return "Error: empty query"-- needle = query.lower()- extractor = get_extractor()- scanned = 0- hits_by_file: List[Tuple[str, List[Tuple[str, int, int]]]] = []- total = 0-- for content, file_name in files:- scanned += 1- skeleton = extractor.extract(file_name, content)- if skeleton is None:- continue- file_hits: List[Tuple[str, int, int]] = []- for name, start, end in _iter_symbols(skeleton):- tail = name.rsplit(".", 1)[-1]- haystack = name.lower() if "." in needle else tail.lower()- if needle in haystack:- file_hits.append((name, start, end))- if file_hits:- hits_by_file.append((file_name, file_hits))- total += len(file_hits)-- if total == 0:- return f'No matches for "{query}" (scanned {scanned} files)'-- out: List[str] = [f'{total} matches for "{query}" (scanned {scanned} files)']- for file_name, file_hits in hits_by_file:- out.append("")- out.append(file_name)- for name, start, end in file_hits:- span = f" L{start}-{end}" if start and end else ""- out.append(f" {name}{span}")- return "\n".join(out)---def _resolve_symbol(skeleton: CodeSkeleton, symbol: str) -> Optional[Tuple[str, int, int]]:- """Find a symbol by 'foo' (bare) or 'Foo.bar' (qualified). Case sensitive.-- Search priority for bare names (no dot):- 1. Top-level functions — exact name match- 2. Classes — exact name match- 3. Methods in any class — bare method name, first class that contains it wins- (returns qualified display name "ClassName.method" so the caller knows- where the method lives; use 'Foo.bar' to target a specific class)- """- if "." in symbol:- cls_name, method_name = symbol.split(".", 1)- for cls in skeleton.classes:- if cls.name == cls_name:- for method in cls.methods:- if method.name == method_name:- return f"{cls.name}.{method.name}", method.line_start, method.line_end- return None-- for fn in skeleton.functions:- if fn.name == symbol:- return fn.name, fn.line_start, fn.line_end- for cls in skeleton.classes:- if cls.name == symbol:- return cls.name, cls.line_start, cls.line_end- for method in cls.methods:- if method.name == symbol:- return f"{cls.name}.{method.name}", method.line_start, method.line_end- return None---def expand_symbol(content: str, file_name: str, symbol: str) -> str:- """Return the source for `symbol` from `content`, with a location header.-- Accepts 'foo' (any function/class/method named foo, first match wins) or- 'Foo.bar' (method bar inside class Foo).- """- skeleton = get_extractor().extract(file_name, content)- if skeleton is None:- return _failure_message(file_name)-- match = _resolve_symbol(skeleton, symbol)- if match is None:- return f"Error: symbol '{symbol}' not found in {file_name}"-- display_name, start, end = match- if not start or not end:- return f"Error: symbol '{symbol}' found but line numbers unavailable in {file_name}"-- lines = content.splitlines()- body = "\n".join(lines[start - 1 : end])- return f"# {file_name} L{start}-{end} ({display_name})\n\n{body}"diff --git a/openviking/parse/parsers/code/ast/extractor.py b/openviking/parse/parsers/code/ast/extractor.pydeleted file mode 100644index 323302bea..000000000--- a/openviking/parse/parsers/code/ast/extractor.py+++ /dev/null@@ -1,148 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""ASTExtractor: language detection + dispatch to per-language extractors."""--import importlib-from pathlib import Path-from typing import Dict, Optional--from openviking.parse.parsers.code.ast.languages.base import LanguageExtractor-from openviking.parse.parsers.code.ast.skeleton import CodeSkeleton-from openviking_cli.utils import get_logger--logger = get_logger(__name__)--# File extension → internal language key-_EXT_MAP: Dict[str, str] = {- ".py": "python",- ".js": "javascript",- ".jsx": "javascript",- ".ts": "typescript",- ".tsx": "typescript",- ".java": "java",- ".c": "cpp",- ".cpp": "cpp",- ".cc": "cpp",- ".h": "cpp",- ".hpp": "cpp",- ".rs": "rust",- ".go": "go",- ".cs": "csharp",- ".php": "php",- ".lua": "lua",-}--# Language key → (module path, class name, constructor kwargs)-_EXTRACTOR_REGISTRY: Dict[str, tuple] = {- "python": ("openviking.parse.parsers.code.ast.languages.python", "PythonExtractor", {}),- "javascript": (- "openviking.parse.parsers.code.ast.languages.js_ts",- "JsTsExtractor",- {"lang": "javascript"},- ),- "typescript": (- "openviking.parse.parsers.code.ast.languages.js_ts",- "JsTsExtractor",- {"lang": "typescript"},- ),- "java": ("openviking.parse.parsers.code.ast.languages.java", "JavaExtractor", {}),- "cpp": ("openviking.parse.parsers.code.ast.languages.cpp", "CppExtractor", {}),- "rust": ("openviking.parse.parsers.code.ast.languages.rust", "RustExtractor", {}),- "go": ("openviking.parse.parsers.code.ast.languages.go", "GoExtractor", {}),- "csharp": ("openviking.parse.parsers.code.ast.languages.csharp", "CSharpExtractor", {}),- "php": ("openviking.parse.parsers.code.ast.languages.php", "PhpExtractor", {}),- "lua": ("openviking.parse.parsers.code.ast.languages.lua", "LuaExtractor", {}),-}---class ASTExtractor:- """Dispatches to per-language tree-sitter extractors for supported languages.-- Unsupported languages return None, signalling the caller to fall back to LLM.- """-- def __init__(self):- self._cache: Dict[str, Optional[LanguageExtractor]] = {}-- def _detect_language(self, file_name: str) -> Optional[str]:- path = Path(file_name)- lang = _EXT_MAP.get(path.suffix.lower())- if lang is not None:- return lang- # Viking resource convention: a file uploaded as <NAME.ext> is stored as a- # directory <NAME.ext>/ containing the content under a "<NAME>.md" body- # (e.g. foo.py/foo.md). When the file's own suffix is unsupported (.md),- # fall back to the parent directory's suffix to recover the language.- if path.suffix.lower() == ".md" and path.parent.name:- return _EXT_MAP.get(Path(path.parent.name).suffix.lower())- return None-- def _get_extractor(self, lang: Optional[str]) -> Optional[LanguageExtractor]:- if lang is None or lang not in _EXTRACTOR_REGISTRY:- return None-- if lang in self._cache:- return self._cache[lang]-- module_path, class_name, kwargs = _EXTRACTOR_REGISTRY[lang]- try:- mod = importlib.import_module(module_path)- cls = getattr(mod, class_name)- extractor = cls(**kwargs)- self._cache[lang] = extractor- return extractor- except Exception as e:- logger.warning(- "AST extractor unavailable for language '%s', falling back to LLM: %s", lang, e- )- self._cache[lang] = None- return None-- def supports(self, file_name: str) -> bool:- """True if the file extension maps to a known language (parsing may still fail)."""- return self._detect_language(file_name) is not None-- def extract(self, file_name: str, content: str) -> Optional[CodeSkeleton]:- """Return raw CodeSkeleton, or None for unsupported language / parse failure.-- Consumers that need the structured object (line numbers, traversal) call- this; consumers that want the legacy formatted text use extract_skeleton.- """- lang = self._detect_language(file_name)- extractor = self._get_extractor(lang)- if extractor is None:- return None-- try:- return extractor.extract(file_name, content)- except Exception as e:- logger.warning("AST extraction failed for '%s' (language: %s): %s", file_name, lang, e)- return None-- def extract_skeleton(- self, file_name: str, content: str, verbose: bool = False- ) -> Optional[str]:- """Extract skeleton text from source code.-- Returns None for unsupported languages or on extraction failure,- signalling the caller to fall back to LLM.-- Args:- verbose: If True, include full docstrings (for ast_llm / LLM input).- If False, only first line of each docstring (for ast / embedding).- """- skeleton = self.extract(file_name, content)- if skeleton is None:- return None- return skeleton.to_text(verbose=verbose)---# Module-level singleton-_extractor: Optional[ASTExtractor] = None---def get_extractor() -> ASTExtractor:- global _extractor- if _extractor is None:- _extractor = ASTExtractor()- return _extractordiff --git a/openviking/parse/parsers/code/ast/languages/__init__.py b/openviking/parse/parsers/code/ast/languages/__init__.pydeleted file mode 100644index 236633478..000000000--- a/openviking/parse/parsers/code/ast/languages/__init__.py+++ /dev/null@@ -1,2 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0diff --git a/openviking/parse/parsers/code/ast/languages/base.py b/openviking/parse/parsers/code/ast/languages/base.pydeleted file mode 100644index e474d941d..000000000--- a/openviking/parse/parsers/code/ast/languages/base.py+++ /dev/null@@ -1,13 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""Abstract base class for language-specific AST extractors."""--from abc import ABC, abstractmethod--from openviking.parse.parsers.code.ast.skeleton import CodeSkeleton---class LanguageExtractor(ABC):- @abstractmethod- def extract(self, file_name: str, content: str) -> CodeSkeleton:- """Extract code skeleton from source. Raises on unrecoverable error."""diff --git a/openviking/parse/parsers/code/ast/languages/cpp.py b/openviking/parse/parsers/code/ast/languages/cpp.pydeleted file mode 100644index f548df9d6..000000000--- a/openviking/parse/parsers/code/ast/languages/cpp.py+++ /dev/null@@ -1,256 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""C/C++ AST extractor using tree-sitter-cpp."""--from typing import List, Optional--from openviking.parse.parsers.code.ast.languages.base import LanguageExtractor-from openviking.parse.parsers.code.ast.skeleton import ClassSkeleton, CodeSkeleton, FunctionSig---def _node_text(node, content_bytes: bytes) -> str:- return content_bytes[node.start_byte : node.end_byte].decode("utf-8", errors="replace")---def _parse_block_comment(raw: str) -> str:- """Strip /** ... */ markers and leading * from each line."""- raw = raw.strip()- if raw.startswith("/**"):- raw = raw[3:]- elif raw.startswith("/*"):- raw = raw[2:]- if raw.endswith("*/"):- raw = raw[:-2]- lines = [l.strip().lstrip("*").strip() for l in raw.split("\n")]- return "\n".join(l for l in lines if l).strip()---def _preceding_doc(siblings: list, idx: int, content_bytes: bytes) -> str:- """Return Doxygen block comment immediately before siblings[idx], or ''."""- if idx == 0:- return ""- prev = siblings[idx - 1]- if prev.type == "comment":- return _parse_block_comment(_node_text(prev, content_bytes))- return ""---def _extract_function_declarator(node, content_bytes: bytes):- name = ""- params = ""- for child in node.children:- if child.type in ("identifier", "field_identifier") and not name:- name = _node_text(child, content_bytes)- elif child.type == "qualified_identifier" and not name:- name = _node_text(child, content_bytes)- elif child.type == "function_declarator":- n, p = _extract_function_declarator(child, content_bytes)- if n:- name = n- if p:- params = p- elif child.type == "parameter_list":- raw = _node_text(child, content_bytes).strip()- if raw.startswith("(") and raw.endswith(")"):- raw = raw[1:-1]- params = raw.strip()- return name, params---def _extract_function(node, content_bytes: bytes, docstring: str = "") -> FunctionSig:- name = ""- params = ""- return_type = ""-- for child in node.children:- if child.type == "function_declarator":- name, params = _extract_function_declarator(child, content_bytes)- elif child.type in (- "type_specifier",- "primitive_type",- "type_identifier",- "qualified_identifier",- "auto",- ):- if not return_type:- return_type = _node_text(child, content_bytes)- elif child.type == "pointer_declarator":- for sub in child.children:- if sub.type == "function_declarator":- name, params = _extract_function_declarator(sub, content_bytes)-- return FunctionSig(- name=name,- params=params,- return_type=return_type,- docstring=docstring,- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---def _extract_class(node, content_bytes: bytes, docstring: str = "") -> ClassSkeleton:- name = ""- bases: List[str] = []- body_node = None-- for child in node.children:- if child.type == "type_identifier" and not name:- name = _node_text(child, content_bytes)- elif child.type == "base_class_clause":- for sub in child.children:- if sub.type == "type_identifier":- bases.append(_node_text(sub, content_bytes))- elif child.type == "field_declaration_list":- body_node = child-- methods: List[FunctionSig] = []- if body_node:- siblings = list(body_node.children)- for idx, child in enumerate(siblings):- if child.type == "function_definition":- doc = _preceding_doc(siblings, idx, content_bytes)- methods.append(_extract_function(child, content_bytes, docstring=doc))- elif child.type in ("declaration", "field_declaration"):- ret_type = ""- fn_name = ""- fn_params = ""- for sub in child.children:- if (- sub.type- in (- "type_specifier",- "primitive_type",- "type_identifier",- "qualified_identifier",- )- and not ret_type- ):- ret_type = _node_text(sub, content_bytes)- elif sub.type == "function_declarator":- fn_name, fn_params = _extract_function_declarator(sub, content_bytes)- break- if fn_name:- doc = _preceding_doc(siblings, idx, content_bytes)- methods.append(- FunctionSig(- name=fn_name,- params=fn_params,- return_type=ret_type,- docstring=doc,- line_start=child.start_point[0] + 1,- line_end=child.end_point[0] + 1,- )- )-- return ClassSkeleton(- name=name,- bases=bases,- docstring=docstring,- methods=methods,- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---def _extract_typedef_struct(- node, content_bytes: bytes, docstring: str = ""-) -> Optional[ClassSkeleton]:- """Handle typedef struct { ... } Name; and typedef struct Tag { ... } Name;-- tree-sitter-cpp emits this as a 'type_definition' node with children:- 'typedef', struct_specifier, type_identifier (the alias), ';'- """- struct_node = None- typedef_name = ""-- for child in node.children:- if child.type in ("struct_specifier", "class_specifier"):- struct_node = child- elif child.type == "type_identifier" and struct_node is not None:- typedef_name = _node_text(child, content_bytes)-- if struct_node is None:- return None-- skeleton = _extract_class(struct_node, content_bytes, docstring=docstring)- # Prefer the typedef alias as the canonical name; span the outer typedef.- if typedef_name:- skeleton.name = typedef_name- skeleton.line_start = node.start_point[0] + 1- skeleton.line_end = node.end_point[0] + 1- return skeleton if skeleton.name else None---def _extract_function_proto(- node, content_bytes: bytes, docstring: str = ""-) -> Optional[FunctionSig]:- """Extract a function prototype from a top-level declaration node."""- fn = _extract_function(node, content_bytes, docstring=docstring)- return fn if fn.name else None---def _process_siblings(- siblings: list,- content_bytes: bytes,- classes: List[ClassSkeleton],- functions: List[FunctionSig],-) -> None:- """Extract classes and functions from a list of sibling nodes (shared by top-level and namespace)."""- for idx, child in enumerate(siblings):- doc = _preceding_doc(siblings, idx, content_bytes)- if child.type in ("class_specifier", "struct_specifier"):- classes.append(_extract_class(child, content_bytes, docstring=doc))- elif child.type == "function_definition":- functions.append(_extract_function(child, content_bytes, docstring=doc))- elif child.type == "type_definition":- cls = _extract_typedef_struct(child, content_bytes, docstring=doc)- if cls:- classes.append(cls)- elif child.type == "declaration":- fn = _extract_function_proto(child, content_bytes, docstring=doc)- if fn:- functions.append(fn)---class CppExtractor(LanguageExtractor):- def __init__(self):- import tree_sitter_cpp as tscpp- from tree_sitter import Language, Parser-- self._language = Language(tscpp.language())- self._parser = Parser(self._language)-- def extract(self, file_name: str, content: str) -> CodeSkeleton:- content_bytes = content.encode("utf-8")- tree = self._parser.parse(content_bytes)- root = tree.root_node-- imports: List[str] = []- classes: List[ClassSkeleton] = []- functions: List[FunctionSig] = []-- siblings = list(root.children)- top_level = []- for _idx, child in enumerate(siblings):- if child.type == "preproc_include":- for sub in child.children:- if sub.type in ("string_literal", "system_lib_string"):- raw = _node_text(sub, content_bytes).strip().strip('"<>')- imports.append(raw)- elif child.type == "namespace_definition":- for sub in child.children:- if sub.type == "declaration_list":- _process_siblings(list(sub.children), content_bytes, classes, functions)- else:- top_level.append(child)- _process_siblings(top_level, content_bytes, classes, functions)-- return CodeSkeleton(- file_name=file_name,- language="C/C++",- module_doc="",- imports=imports,- classes=classes,- functions=functions,- )diff --git a/openviking/parse/parsers/code/ast/languages/csharp.py b/openviking/parse/parsers/code/ast/languages/csharp.pydeleted file mode 100644index 7c626a778..000000000--- a/openviking/parse/parsers/code/ast/languages/csharp.py+++ /dev/null@@ -1,203 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""C# AST extractor using tree-sitter-c-sharp."""--import re-from typing import List--from openviking.parse.parsers.code.ast.languages.base import LanguageExtractor-from openviking.parse.parsers.code.ast.skeleton import ClassSkeleton, CodeSkeleton, FunctionSig---def _node_text(node, content_bytes: bytes) -> str:- return content_bytes[node.start_byte : node.end_byte].decode("utf-8", errors="replace")---def _parse_doc_comment(raw: str) -> str:- """Strip XML doc comment markers (/// or /** */) and extract text from XML tags."""- raw = raw.strip()- if raw.startswith("///"):- lines = raw.split("\n")- cleaned = []- for line in lines:- stripped = line.strip()- if stripped.startswith("///"):- stripped = stripped[3:].strip()- if stripped:- cleaned.append(stripped)- raw = " ".join(cleaned)- elif raw.startswith("/**"):- raw = raw[3:]- if raw.endswith("*/"):- raw = raw[:-2]- lines = [l.strip().lstrip("*").strip() for l in raw.split("\n")]- raw = "\n".join(l for l in lines if l).strip()- # Remove XML tags- raw = re.sub(r"</?[a-zA-Z][a-zA-Z0-9]*(?:\s+[^>]*)?/?>", "", raw)- # Normalize whitespace- raw = re.sub(r"\s+", " ", raw).strip()- return raw---def _preceding_doc(siblings: list, idx: int, content_bytes: bytes) -> str:- """Return XML doc comment immediately before siblings[idx], or ''."""- if idx == 0:- return ""- comments = []- for i in range(idx - 1, -1, -1):- prev = siblings[i]- if prev.type == "comment":- text = _node_text(prev, content_bytes)- if text.strip().startswith("///") or text.strip().startswith("/**"):- comments.insert(0, _parse_doc_comment(text))- else:- break- elif prev.type in ("preprocessor_directive", "nullable_directive"):- continue- else:- break- return "\n".join(comments) if comments else ""---def _extract_method(node, content_bytes: bytes, docstring: str = "") -> FunctionSig:- name = ""- params = ""- return_type = ""-- for child in node.children:- if child.type == "identifier" and not name:- name = _node_text(child, content_bytes)- elif child.type == "void_keyword":- return_type = "void"- elif child.type in ("predefined_type", "type_identifier", "generic_name"):- if not return_type:- return_type = _node_text(child, content_bytes)- elif child.type == "parameter_list":- raw = _node_text(child, content_bytes).strip()- if raw.startswith("(") and raw.endswith(")"):- raw = raw[1:-1]- params = raw.strip()-- if node.type == "property_declaration":- for child in node.children:- if child.type == "accessor_list":- accessors = []- for acc in child.children:- if acc.type == "accessor_declaration":- accessor_name = ""- name_node = acc.child_by_field_name("name")- if name_node is not None:- accessor_name = _node_text(name_node, content_bytes).strip()- else:- for sub in acc.children:- if sub.type in ("get", "set", "init"):- accessor_name = sub.type- break- if accessor_name in ("get", "set", "init"):- accessors.append(accessor_name)- if accessors:- params = f"{{ {' '.join(accessors)} }}"-- return FunctionSig(- name=name,- params=params,- return_type=return_type,- docstring=docstring,- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---def _extract_class(node, content_bytes: bytes, docstring: str = "") -> ClassSkeleton:- name = ""- bases: List[str] = []- body_node = None-- for child in node.children:- if child.type == "identifier" and not name:- name = _node_text(child, content_bytes)- elif child.type == "base_list":- for sub in child.children:- if sub.type in ("type_identifier", "identifier"):- bases.append(_node_text(sub, content_bytes))- elif child.type == "declaration_list":- body_node = child-- methods: List[FunctionSig] = []- if body_node:- siblings = list(body_node.children)- for idx, child in enumerate(siblings):- if child.type in ("method_declaration", "constructor_declaration"):- doc = _preceding_doc(siblings, idx, content_bytes)- methods.append(_extract_method(child, content_bytes, docstring=doc))- elif child.type == "property_declaration":- doc = _preceding_doc(siblings, idx, content_bytes)- methods.append(_extract_method(child, content_bytes, docstring=doc))-- return ClassSkeleton(- name=name,- bases=bases,- docstring=docstring,- methods=methods,- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---class CSharpExtractor(LanguageExtractor):- def __init__(self):- import tree_sitter_c_sharp as tscsharp- from tree_sitter import Language, Parser-- self._language = Language(tscsharp.language())- self._parser = Parser(self._language)-- def extract(self, file_name: str, content: str) -> CodeSkeleton:- content_bytes = content.encode("utf-8")- tree = self._parser.parse(content_bytes)- root = tree.root_node-- imports: List[str] = []- classes: List[ClassSkeleton] = []- functions: List[FunctionSig] = []-- siblings = list(root.children)- for idx, child in enumerate(siblings):- if child.type == "using_directive":- for sub in child.children:- if sub.type == "identifier":- imports.append(_node_text(sub, content_bytes))- elif sub.type == "qualified_name":- imports.append(_node_text(sub, content_bytes))- elif child.type in ("namespace_declaration", "file_scoped_namespace_declaration"):- for sub in child.children:- if sub.type == "declaration_list":- ns_siblings = list(sub.children)- for ns_idx, ns_child in enumerate(ns_siblings):- if ns_child.type in (- "class_declaration",- "interface_declaration",- "struct_declaration",- "record_declaration",- ):- doc = _preceding_doc(ns_siblings, ns_idx, content_bytes)- classes.append(- _extract_class(ns_child, content_bytes, docstring=doc)- )- elif child.type in (- "class_declaration",- "interface_declaration",- "struct_declaration",- "record_declaration",- ):- doc = _preceding_doc(siblings, idx, content_bytes)- classes.append(_extract_class(child, content_bytes, docstring=doc))-- return CodeSkeleton(- file_name=file_name,- language="C#",- module_doc="",- imports=imports,- classes=classes,- functions=functions,- )diff --git a/openviking/parse/parsers/code/ast/languages/go.py b/openviking/parse/parsers/code/ast/languages/go.pydeleted file mode 100644index 1f793d0fc..000000000--- a/openviking/parse/parsers/code/ast/languages/go.py+++ /dev/null@@ -1,131 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""Go AST extractor using tree-sitter-go."""--from typing import List--from openviking.parse.parsers.code.ast.languages.base import LanguageExtractor-from openviking.parse.parsers.code.ast.skeleton import ClassSkeleton, CodeSkeleton, FunctionSig---def _node_text(node, content_bytes: bytes) -> str:- return content_bytes[node.start_byte : node.end_byte].decode("utf-8", errors="replace")---def _preceding_doc(siblings: list, idx: int, content_bytes: bytes) -> str:- """Collect consecutive // comment lines immediately before siblings[idx]."""- lines = []- i = idx - 1- while i >= 0 and siblings[i].type == "comment":- raw = _node_text(siblings[i], content_bytes).strip()- # strip leading //- if raw.startswith("//"):- raw = raw[2:].strip()- lines.insert(0, raw)- i -= 1- return "\n".join(lines).strip()---def _extract_function(node, content_bytes: bytes, docstring: str = "") -> FunctionSig:- name = ""- params = ""- return_type = ""- is_method = node.type == "method_declaration"- param_list_count = 0-- for child in node.children:- if child.type == "identifier" and not name:- name = _node_text(child, content_bytes)- elif child.type == "field_identifier" and not name:- name = _node_text(child, content_bytes)- elif child.type == "parameter_list":- param_list_count += 1- if is_method and param_list_count == 1:- continue # first parameter_list is receiver (s *Server), not params- if not params:- raw = _node_text(child, content_bytes).strip()- if raw.startswith("(") and raw.endswith(")"):- raw = raw[1:-1]- params = raw.strip()- elif child.type == "type_identifier":- return_type = _node_text(child, content_bytes)-- return FunctionSig(- name=name,- params=params,- return_type=return_type,- docstring=docstring,- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---def _extract_struct(node, content_bytes: bytes, docstring: str = "") -> ClassSkeleton:- name = ""- for child in node.children:- if child.type == "type_identifier":- name = _node_text(child, content_bytes)- break- return ClassSkeleton(- name=name,- bases=[],- docstring=docstring,- methods=[],- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---class GoExtractor(LanguageExtractor):- def __init__(self):- import tree_sitter_go as tsgo- from tree_sitter import Language, Parser-- self._language = Language(tsgo.language())- self._parser = Parser(self._language)-- def extract(self, file_name: str, content: str) -> CodeSkeleton:- content_bytes = content.encode("utf-8")- tree = self._parser.parse(content_bytes)- root = tree.root_node-- imports: List[str] = []- classes: List[ClassSkeleton] = []- functions: List[FunctionSig] = []-- siblings = list(root.children)- for idx, child in enumerate(siblings):- if child.type == "import_declaration":- for sub in child.children:- if sub.type == "import_spec":- for s2 in sub.children:- if s2.type == "interpreted_string_literal":- imports.append(_node_text(s2, content_bytes).strip().strip('"'))- elif sub.type == "import_spec_list":- for s2 in sub.children:- if s2.type == "import_spec":- for s3 in s2.children:- if s3.type == "interpreted_string_literal":- imports.append(- _node_text(s3, content_bytes).strip().strip('"')- )- elif child.type in ("function_declaration", "method_declaration"):- doc = _preceding_doc(siblings, idx, content_bytes)- functions.append(_extract_function(child, content_bytes, docstring=doc))- elif child.type == "type_declaration":- for sub in child.children:- if sub.type == "type_spec":- for s2 in sub.children:- if s2.type in ("struct_type", "interface_type"):- doc = _preceding_doc(siblings, idx, content_bytes)- classes.append(_extract_struct(sub, content_bytes, docstring=doc))- break-- return CodeSkeleton(- file_name=file_name,- language="Go",- module_doc="",- imports=imports,- classes=classes,- functions=functions,- )diff --git a/openviking/parse/parsers/code/ast/languages/java.py b/openviking/parse/parsers/code/ast/languages/java.pydeleted file mode 100644index 91a1e93ab..000000000--- a/openviking/parse/parsers/code/ast/languages/java.py+++ /dev/null@@ -1,148 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""Java AST extractor using tree-sitter-java."""--from typing import List--from openviking.parse.parsers.code.ast.languages.base import LanguageExtractor-from openviking.parse.parsers.code.ast.skeleton import ClassSkeleton, CodeSkeleton, FunctionSig---def _node_text(node, content_bytes: bytes) -> str:- return content_bytes[node.start_byte : node.end_byte].decode("utf-8", errors="replace")---def _parse_block_comment(raw: str) -> str:- """Strip /** ... */ markers and leading * from each line."""- raw = raw.strip()- if raw.startswith("/**"):- raw = raw[3:]- elif raw.startswith("/*"):- raw = raw[2:]- if raw.endswith("*/"):- raw = raw[:-2]- lines = [l.strip().lstrip("*").strip() for l in raw.split("\n")]- return "\n".join(l for l in lines if l).strip()---def _preceding_doc(siblings: list, idx: int, content_bytes: bytes) -> str:- """Return Javadoc block comment immediately before siblings[idx], or ''."""- if idx == 0:- return ""- prev = siblings[idx - 1]- if prev.type == "block_comment":- return _parse_block_comment(_node_text(prev, content_bytes))- return ""---def _extract_method(node, content_bytes: bytes, docstring: str = "") -> FunctionSig:- name = ""- params = ""- return_type = ""-- for child in node.children:- if child.type == "identifier" and not name:- if return_type:- name = _node_text(child, content_bytes)- elif child.type in (- "type_identifier",- "void_type",- "integral_type",- "floating_point_type",- "boolean_type",- "array_type",- "generic_type",- ):- if not return_type:- return_type = _node_text(child, content_bytes)- elif child.type == "formal_parameters":- raw = _node_text(child, content_bytes).strip()- if raw.startswith("(") and raw.endswith(")"):- raw = raw[1:-1]- params = raw.strip()-- return FunctionSig(- name=name,- params=params,- return_type=return_type,- docstring=docstring,- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---def _extract_class(node, content_bytes: bytes, docstring: str = "") -> ClassSkeleton:- name = ""- bases: List[str] = []- body_node = None-- for child in node.children:- if child.type in ("type_identifier", "identifier") and not name:- name = _node_text(child, content_bytes)- elif child.type == "superclass":- for sub in child.children:- if sub.type == "type_identifier":- bases.append(_node_text(sub, content_bytes))- elif child.type == "super_interfaces":- for sub in child.children:- if sub.type == "type_list":- for s2 in sub.children:- if s2.type == "type_identifier":- bases.append(_node_text(s2, content_bytes))- elif child.type == "class_body":- body_node = child-- methods: List[FunctionSig] = []- if body_node:- siblings = list(body_node.children)- for idx, child in enumerate(siblings):- if child.type in ("method_declaration", "constructor_declaration"):- doc = _preceding_doc(siblings, idx, content_bytes)- methods.append(_extract_method(child, content_bytes, docstring=doc))-- return ClassSkeleton(- name=name,- bases=bases,- docstring=docstring,- methods=methods,- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---class JavaExtractor(LanguageExtractor):- def __init__(self):- import tree_sitter_java as tsjava- from tree_sitter import Language, Parser-- self._language = Language(tsjava.language())- self._parser = Parser(self._language)-- def extract(self, file_name: str, content: str) -> CodeSkeleton:- content_bytes = content.encode("utf-8")- tree = self._parser.parse(content_bytes)- root = tree.root_node-- imports: List[str] = []- classes: List[ClassSkeleton] = []-- siblings = list(root.children)- for idx, child in enumerate(siblings):- if child.type == "import_declaration":- for sub in child.children:- if sub.type == "scoped_identifier":- imports.append(_node_text(sub, content_bytes))- elif sub.type == "identifier":- imports.append(_node_text(sub, content_bytes))- elif child.type in ("class_declaration", "interface_declaration", "enum_declaration"):- doc = _preceding_doc(siblings, idx, content_bytes)- classes.append(_extract_class(child, content_bytes, docstring=doc))-- return CodeSkeleton(- file_name=file_name,- language="Java",- module_doc="",- imports=imports,- classes=classes,- functions=[],- )diff --git a/openviking/parse/parsers/code/ast/languages/js_ts.py b/openviking/parse/parsers/code/ast/languages/js_ts.pydeleted file mode 100644index 375ca7449..000000000--- a/openviking/parse/parsers/code/ast/languages/js_ts.py+++ /dev/null@@ -1,243 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""JavaScript/TypeScript AST extractor using tree-sitter."""--from typing import List--from openviking.parse.parsers.code.ast.languages.base import LanguageExtractor-from openviking.parse.parsers.code.ast.skeleton import ClassSkeleton, CodeSkeleton, FunctionSig---def _node_text(node, content_bytes: bytes) -> str:- return content_bytes[node.start_byte : node.end_byte].decode("utf-8", errors="replace")---def _parse_jsdoc(raw: str) -> str:- """Strip /** ... */ markers and leading * from each line."""- raw = raw.strip()- if raw.startswith("/**"):- raw = raw[3:]- elif raw.startswith("/*"):- raw = raw[2:]- if raw.endswith("*/"):- raw = raw[:-2]- lines = [l.strip().lstrip("*").strip() for l in raw.split("\n")]- return "\n".join(l for l in lines if l).strip()---def _preceding_doc(siblings: list, idx: int, content_bytes: bytes) -> str:- """Return JSDoc block comment immediately before siblings[idx], or ''."""- if idx == 0:- return ""- prev = siblings[idx - 1]- if prev.type == "comment":- raw = _node_text(prev, content_bytes).strip()- if raw.startswith("/*"):- return _parse_jsdoc(raw)- if raw.startswith("//"):- return raw[2:].strip()- return ""---def _first_string_in_body(body_node, content_bytes: bytes) -> str:- if body_node is None:- return ""- for child in body_node.children:- if child.type == "expression_statement":- for sub in child.children:- if sub.type == "string":- raw = _node_text(sub, content_bytes).strip()- for q in ('"""', "'''", '"', "'", "`"):- if raw.startswith(q) and raw.endswith(q) and len(raw) >= 2 * len(q):- return raw[len(q) : -len(q)].strip()- return raw- break- return ""---def _extract_params(params_node, content_bytes: bytes) -> str:- if params_node is None:- return ""- raw = _node_text(params_node, content_bytes).strip()- if raw.startswith("(") and raw.endswith(")"):- raw = raw[1:-1]- return raw.strip()---def _extract_function(- node, content_bytes: bytes, lang_name: str, docstring: str = ""-) -> FunctionSig:- name = ""- params = ""- return_type = ""- body_node = None-- for child in node.children:- if child.type == "identifier" and not name:- name = _node_text(child, content_bytes)- elif child.type == "property_identifier" and not name:- name = _node_text(child, content_bytes)- elif child.type in ("formal_parameters", "call_signature"):- params = _extract_params(child, content_bytes)- elif child.type == "type_annotation":- # TypeScript return type annotation- for sub in child.children:- if sub.type not in (":",):- return_type = _node_text(sub, content_bytes).strip()- break- elif child.type == "statement_block":- body_node = child-- if not docstring:- docstring = _first_string_in_body(body_node, content_bytes)- return FunctionSig(- name=name,- params=params,- return_type=return_type,- docstring=docstring,- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---def _extract_class(- node, content_bytes: bytes, lang_name: str, docstring: str = ""-) -> ClassSkeleton:- name = ""- bases: List[str] = []- body_node = None-- for child in node.children:- if child.type == "identifier" and not name:- name = _node_text(child, content_bytes)- elif child.type == "type_identifier" and not name:- name = _node_text(child, content_bytes)- elif child.type == "class_heritage":- for sub in child.children:- if sub.type == "extends_clause":- for s2 in sub.children:- if s2.type in ("identifier", "type_identifier", "member_expression"):- bases.append(_node_text(s2, content_bytes))- elif child.type == "class_body":- body_node = child-- if not docstring:- docstring = _first_string_in_body(body_node, content_bytes)- methods: List[FunctionSig] = []-- if body_node:- siblings = list(body_node.children)- for idx, child in enumerate(siblings):- if child.type == "method_definition":- doc = _preceding_doc(siblings, idx, content_bytes)- methods.append(_extract_function(child, content_bytes, lang_name, docstring=doc))- elif child.type == "public_field_definition":- # arrow function fields- for sub in child.children:- if sub.type == "arrow_function":- doc = _preceding_doc(siblings, idx, content_bytes)- fn = _extract_function(sub, content_bytes, lang_name, docstring=doc)- # get field name- for s2 in child.children:- if s2.type in ("property_identifier", "identifier"):- fn.name = _node_text(s2, content_bytes)- break- methods.append(fn)- break-- return ClassSkeleton(- name=name,- bases=bases,- docstring=docstring,- methods=methods,- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---class JsTsExtractor(LanguageExtractor):- def __init__(self, lang: str):- """lang: 'javascript' or 'typescript'"""- self._lang_name = "JavaScript" if lang == "javascript" else "TypeScript"- if lang == "javascript":- import tree_sitter_javascript as tsjs- from tree_sitter import Language, Parser-- self._language = Language(tsjs.language())- else:- import tree_sitter_typescript as tsts- from tree_sitter import Language, Parser-- self._language = Language(tsts.language_typescript())- from tree_sitter import Parser-- self._parser = Parser(self._language)-- def extract(self, file_name: str, content: str) -> CodeSkeleton:- content_bytes = content.encode("utf-8")- tree = self._parser.parse(content_bytes)- root = tree.root_node-- imports: List[str] = []- _seen_imports: set = set()- classes: List[ClassSkeleton] = []- functions: List[FunctionSig] = []-- siblings = list(root.children)- for idx, child in enumerate(siblings):- if child.type == "import_statement":- # from "module"- for sub in child.children:- if sub.type == "string":- raw = _node_text(sub, content_bytes).strip().strip("\"'")- if raw not in _seen_imports:- imports.append(raw)- _seen_imports.add(raw)- break- elif child.type == "class_declaration":- doc = _preceding_doc(siblings, idx, content_bytes)- classes.append(_extract_class(child, content_bytes, self._lang_name, docstring=doc))- elif child.type in ("function_declaration", "generator_function_declaration"):- doc = _preceding_doc(siblings, idx, content_bytes)- functions.append(- _extract_function(child, content_bytes, self._lang_name, docstring=doc)- )- elif child.type == "export_statement":- # export default class / export function- for sub in child.children:- if sub.type == "class_declaration":- doc = _preceding_doc(siblings, idx, content_bytes)- classes.append(- _extract_class(sub, content_bytes, self._lang_name, docstring=doc)- )- break- elif sub.type in ("function_declaration", "generator_function_declaration"):- doc = _preceding_doc(siblings, idx, content_bytes)- functions.append(- _extract_function(sub, content_bytes, self._lang_name, docstring=doc)- )- break- elif child.type == "lexical_declaration":- # const foo = () => ...- for sub in child.children:- if sub.type == "variable_declarator":- fn_name = ""- for s2 in sub.children:- if s2.type == "identifier":- fn_name = _node_text(s2, content_bytes)- elif s2.type == "arrow_function":- doc = _preceding_doc(siblings, idx, content_bytes)- fn = _extract_function(- s2, content_bytes, self._lang_name, docstring=doc- )- fn.name = fn_name- functions.append(fn)-- return CodeSkeleton(- file_name=file_name,- language=self._lang_name,- module_doc="",- imports=imports,- classes=classes,- functions=functions,- )diff --git a/openviking/parse/parsers/code/ast/languages/lua.py b/openviking/parse/parsers/code/ast/languages/lua.pydeleted file mode 100644index 8af37e745..000000000--- a/openviking/parse/parsers/code/ast/languages/lua.py+++ /dev/null@@ -1,178 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""Lua AST extractor using tree-sitter-lua."""--from typing import Dict, List, Optional--from openviking.parse.parsers.code.ast.languages.base import LanguageExtractor-from openviking.parse.parsers.code.ast.skeleton import ClassSkeleton, CodeSkeleton, FunctionSig---def _node_text(node, content_bytes: bytes) -> str:- return content_bytes[node.start_byte : node.end_byte].decode("utf-8", errors="replace")---def _comment_text(node, content_bytes: bytes) -> str:- """Extract readable text from a comment node (-- or --[[ ... ]])."""- raw = _node_text(node, content_bytes).strip()- if raw.startswith("--[["):- inner = raw[4:]- if inner.endswith("]]"):- inner = inner[:-2]- lines = [line.strip() for line in inner.split("\n")]- return "\n".join(line for line in lines if line).strip()- if raw.startswith("--"):- return raw[2:].strip()- return raw---def _preceding_doc(siblings: list, idx: int, content_bytes: bytes) -> str:- """Collect consecutive comment nodes immediately before siblings[idx]."""- lines: List[str] = []- i = idx - 1- while i >= 0 and siblings[i].type == "comment":- lines.insert(0, _comment_text(siblings[i], content_bytes))- i -= 1- return "\n".join(lines).strip()---def _extract_params(params_node, content_bytes: bytes) -> str:- if params_node is None:- return ""- raw = _node_text(params_node, content_bytes).strip()- if raw.startswith("(") and raw.endswith(")"):- raw = raw[1:-1]- return raw.strip()---def _find_require_in_call(call_node, content_bytes: bytes) -> Optional[str]:- """Return module name if call_node is require('mod') / require 'mod', else None."""- children = list(call_node.children)- if not children:- return None- if children[0].type != "identifier":- return None- if _node_text(children[0], content_bytes) != "require":- return None- for child in children[1:]:- if child.type == "arguments":- for arg in child.children:- if arg.type == "string":- return _node_text(arg, content_bytes).strip().strip("'\"")- elif child.type == "string":- return _node_text(child, content_bytes).strip().strip("'\"")- return None---def _collect_requires(node, content_bytes: bytes) -> List[str]:- """Find require() calls in node, not recursing into function bodies."""- if node.type == "function_call":- mod = _find_require_in_call(node, content_bytes)- if mod:- return [mod]- results: List[str] = []- for child in node.children:- if child.type in ("block", "function_declaration"):- continue- results.extend(_collect_requires(child, content_bytes))- return results---class LuaExtractor(LanguageExtractor):- def __init__(self):- import tree_sitter_lua as tslua- from tree_sitter import Language, Parser-- self._language = Language(tslua.language())- self._parser = Parser(self._language)-- def extract(self, file_name: str, content: str) -> CodeSkeleton:- content_bytes = content.encode("utf-8")- tree = self._parser.parse(content_bytes)- root = tree.root_node-- imports: List[str] = []- _seen_imports: set = set()- _classes: Dict[str, ClassSkeleton] = {}- functions: List[FunctionSig] = []-- siblings = list(root.children)- for idx, child in enumerate(siblings):- # --- require imports (from variable_declaration or bare function_call) ---- if child.type in ("variable_declaration", "function_call"):- for mod in _collect_requires(child, content_bytes):- if mod not in _seen_imports:- imports.append(mod)- _seen_imports.add(mod)-- # --- function declarations (including local function ...) ---- if child.type == "function_declaration":- doc = _preceding_doc(siblings, idx, content_bytes)- name_node = None- params_node = None- for c in child.children:- if c.type in (- "identifier",- "dot_index_expression",- "method_index_expression",- ):- name_node = c- elif c.type == "parameters":- params_node = c-- if name_node is None:- continue-- params = _extract_params(params_node, content_bytes)-- fn_start = child.start_point[0] + 1- fn_end = child.end_point[0] + 1- if name_node.type == "identifier":- name = _node_text(name_node, content_bytes)- functions.append(- FunctionSig(- name=name,- params=params,- return_type="",- docstring=doc,- line_start=fn_start,- line_end=fn_end,- )- )- elif name_node.type in ("dot_index_expression", "method_index_expression"):- # M.foo or M:foo — map to class method- id_children = [c for c in name_node.children if c.type == "identifier"]- if len(id_children) >= 2:- table_name = _node_text(id_children[0], content_bytes)- method_name = _node_text(id_children[1], content_bytes)- fn = FunctionSig(- name=method_name,- params=params,- return_type="",- docstring=doc,- line_start=fn_start,- line_end=fn_end,- )- if table_name not in _classes:- _classes[table_name] = ClassSkeleton(- name=table_name,- bases=[],- docstring="",- methods=[],- line_start=fn_start,- line_end=fn_end,- )- else:- _classes[table_name].line_end = max(- _classes[table_name].line_end, fn_end- )- _classes[table_name].methods.append(fn)-- return CodeSkeleton(- file_name=file_name,- language="Lua",- module_doc="",- imports=imports,- classes=list(_classes.values()),- functions=functions,- )diff --git a/openviking/parse/parsers/code/ast/languages/php.py b/openviking/parse/parsers/code/ast/languages/php.pydeleted file mode 100644index 8b9df46d6..000000000--- a/openviking/parse/parsers/code/ast/languages/php.py+++ /dev/null@@ -1,361 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""PHP AST extractor using tree-sitter-php."""--from __future__ import annotations--from typing import List--from openviking.parse.parsers.code.ast.languages.base import LanguageExtractor-from openviking.parse.parsers.code.ast.skeleton import ClassSkeleton, CodeSkeleton, FunctionSig---def _node_text(node, content_bytes: bytes) -> str:- return content_bytes[node.start_byte : node.end_byte].decode("utf-8", errors="replace")---def _parse_comment(raw: str) -> str:- raw = raw.strip()- if raw.startswith("/**") or raw.startswith("/*"):- raw = raw[3:] if raw.startswith("/**") else raw[2:]- if raw.endswith("*/"):- raw = raw[:-2]- lines = [l.strip().lstrip("*").strip() for l in raw.split("\n")]- return "\n".join(l for l in lines if l).strip()- if raw.startswith("//"):- return raw[2:].strip()- if raw.startswith("#"):- return raw[1:].strip()- return raw---def _preceding_doc(siblings: list, idx: int, content_bytes: bytes) -> str:- if idx <= 0:- return ""-- adjacent: List[str] = []- current_start_row = siblings[idx].start_point[0]- i = idx - 1- while i >= 0 and siblings[i].type == "comment":- if current_start_row - siblings[i].end_point[0] > 1:- break- adjacent.insert(0, _node_text(siblings[i], content_bytes).strip())- current_start_row = siblings[i].start_point[0]- i -= 1-- if not adjacent:- return ""-- phpdocs = [c for c in adjacent if c.lstrip().startswith("/**")]- chosen = phpdocs if phpdocs else adjacent- parsed = [_parse_comment(c) for c in chosen]- return "\n".join(p for p in parsed if p).strip()---def _strip_parens(raw: str) -> str:- raw = raw.strip()- if raw.startswith("(") and raw.endswith(")"):- raw = raw[1:-1]- return raw.strip()---def _first_named_child_text(node, types: set, content_bytes: bytes) -> str:- for child in node.children:- if child.type in types:- return _node_text(child, content_bytes).strip()- return ""---def _collect_typeish_tokens(node, content_bytes: bytes) -> List[str]:- out: List[str] = []-- def _walk(n) -> None:- if n.type in (- "qualified_name",- "namespace_name",- "name",- "identifier",- ):- txt = _node_text(n, content_bytes).strip()- if txt and txt not in out:- out.append(txt)- for c in n.children:- _walk(c)-- _walk(node)- return out---def _normalize_name(raw: str) -> str:- raw = raw.strip()- while raw.startswith("\\"):- raw = raw[1:]- return raw---def _extract_use_declaration(node, content_bytes: bytes) -> List[str]:- base_prefix = ""- group_node = None- for child in node.children:- if child.type == "namespace_use_group":- group_node = child- break- if group_node is not None:- base_node = None- for child in node.children:- if child.type == "namespace_name":- base_node = child- break- if base_node is not None:- base = _normalize_name(_node_text(base_node, content_bytes)).rstrip("\\")- base_prefix = f"{base}\\" if base else ""-- def _clause_name(clause) -> str:- name_node = None- for sub in clause.children:- if sub.type == "qualified_name":- name_node = sub- break- if name_node is None:- for sub in clause.children:- if sub.type == "name":- name_node = sub- break- return (- _normalize_name(_node_text(name_node, content_bytes)) if name_node is not None else ""- )-- clauses = []- if group_node is not None:- for sub in group_node.children:- if sub.type == "namespace_use_clause":- clauses.append(sub)- else:- for sub in node.children:- if sub.type == "namespace_use_clause":- clauses.append(sub)-- out: List[str] = []- for clause in clauses:- name = _clause_name(clause)- if not name:- continue- out.append(f"{base_prefix}{name}" if base_prefix else name)-- return out---def _extract_function_like(node, content_bytes: bytes, docstring: str = "") -> FunctionSig:- name = ""- params = ""- return_type = ""-- name_node = node.child_by_field_name("name")- if name_node is not None:- name = _node_text(name_node, content_bytes).strip()- if not name:- name = _first_named_child_text(node, {"name", "identifier"}, content_bytes)-- params_node = node.child_by_field_name("parameters")- if params_node is None:- params_node = node.child_by_field_name("parameters_list")- if params_node is None:- for child in node.children:- if child.type in ("formal_parameters", "parameters", "parameter_list"):- params_node = child- break- if params_node is not None:- params = _strip_parens(_node_text(params_node, content_bytes))-- ret_node = node.child_by_field_name("return_type")- if ret_node is None:- ret_node = node.child_by_field_name("type")- if ret_node is not None:- return_type = _node_text(ret_node, content_bytes).strip().lstrip(":").strip()- else:- for child in node.children:- if child.type in (- "nullable_type",- "union_type",- "intersection_type",- "primitive_type",- "qualified_name",- "namespace_name",- "named_type",- ):- return_type = _node_text(child, content_bytes).strip().lstrip(":").strip()- if return_type:- break-- return FunctionSig(- name=name,- params=params,- return_type=return_type,- docstring=docstring,- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---def _extract_class(- node, content_bytes: bytes, docstring: str = "", name_prefix: str = ""-) -> ClassSkeleton:- name = ""- bases: List[str] = []- body_node = None-- name_node = node.child_by_field_name("name")- if name_node is not None:- name = _node_text(name_node, content_bytes).strip()- if not name:- name = _first_named_child_text(node, {"name", "identifier"}, content_bytes)- if name_prefix:- name = f"{name_prefix}{name}" if name else name_prefix.strip()-- for child in node.children:- if child.type in (- "base_clause",- "extends_clause",- "implements_clause",- "class_interface_clause",- ):- for b in _collect_typeish_tokens(child, content_bytes):- if b not in bases:- bases.append(b)- elif child.type in ("declaration_list", "class_body", "interface_body", "trait_body"):- body_node = child- elif body_node is None and child.type.endswith("_body"):- body_node = child-- methods: List[FunctionSig] = []- if body_node is not None:- siblings = list(body_node.children)- for idx, child in enumerate(siblings):- if child.type == "use_declaration":- for sub in child.children:- if sub.type in ("name", "qualified_name"):- t = _normalize_name(_node_text(sub, content_bytes))- if t and t not in bases:- bases.append(t)- elif child.type in ("method_declaration", "method_definition"):- doc = _preceding_doc(siblings, idx, content_bytes)- methods.append(_extract_function_like(child, content_bytes, docstring=doc))-- return ClassSkeleton(- name=name,- bases=bases,- docstring=docstring,- methods=methods,- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---def _dedup_keep_order(items: List[str]) -> List[str]:- seen = set()- out = []- for i in items:- if i and i not in seen:- seen.add(i)- out.append(i)- return out---def _leading_module_doc(siblings: list, content_bytes: bytes) -> str:- for child in siblings:- if child.type in ("php_tag", "text"):- continue- if child.type == "comment":- raw = _node_text(child, content_bytes).strip()- if raw.startswith("/**"):- return _parse_comment(raw)- continue- break- return ""---def _process_siblings(- siblings: list,- content_bytes: bytes,- imports: List[str],- classes: List[ClassSkeleton],- functions: List[FunctionSig],-) -> None:- for idx, child in enumerate(siblings):- if child.type == "namespace_use_declaration":- imports.extend(_extract_use_declaration(child, content_bytes))- elif child.type == "class_declaration":- doc = _preceding_doc(siblings, idx, content_bytes)- classes.append(_extract_class(child, content_bytes, docstring=doc, name_prefix=""))- elif child.type == "interface_declaration":- doc = _preceding_doc(siblings, idx, content_bytes)- classes.append(- _extract_class(child, content_bytes, docstring=doc, name_prefix="interface ")- )- elif child.type == "trait_declaration":- doc = _preceding_doc(siblings, idx, content_bytes)- classes.append(- _extract_class(child, content_bytes, docstring=doc, name_prefix="trait ")- )- elif child.type == "enum_declaration":- doc = _preceding_doc(siblings, idx, content_bytes)- classes.append(_extract_class(child, content_bytes, docstring=doc, name_prefix="enum "))- elif child.type in ("function_definition", "function_declaration"):- doc = _preceding_doc(siblings, idx, content_bytes)- functions.append(_extract_function_like(child, content_bytes, docstring=doc))- elif child.type == "expression_statement":- assign = None- for sub in child.children:- if sub.type == "assignment_expression":- assign = sub- break- if assign is not None:- left = None- right = None- for sub in assign.children:- if left is None and sub.type == "variable_name":- left = sub- elif right is None and sub.type in ("anonymous_function", "arrow_function"):- right = sub- if left is not None and right is not None:- doc = _preceding_doc(siblings, idx, content_bytes)- sig = _extract_function_like(right, content_bytes, docstring=doc)- sig.name = _node_text(left, content_bytes).strip()- functions.append(sig)- elif child.type == "namespace_definition":- for sub in child.children:- if sub.type in ("declaration_list", "compound_statement"):- _process_siblings(- list(sub.children), content_bytes, imports, classes, functions- )---class PhpExtractor(LanguageExtractor):- def __init__(self):- import tree_sitter_php as tsphp- from tree_sitter import Language, Parser-- self._language = Language(tsphp.language_php())- self._parser = Parser(self._language)-- def extract(self, file_name: str, content: str) -> CodeSkeleton:- content_bytes = content.encode("utf-8")- tree = self._parser.parse(content_bytes)- root = tree.root_node-- imports: List[str] = []- classes: List[ClassSkeleton] = []- functions: List[FunctionSig] = []-- siblings = list(root.children)- module_doc = _leading_module_doc(siblings, content_bytes)- _process_siblings(siblings, content_bytes, imports, classes, functions)-- return CodeSkeleton(- file_name=file_name,- language="PHP",- module_doc=module_doc,- imports=_dedup_keep_order(imports),- classes=classes,- functions=functions,- )diff --git a/openviking/parse/parsers/code/ast/languages/python.py b/openviking/parse/parsers/code/ast/languages/python.pydeleted file mode 100644index 735e0f4ca..000000000--- a/openviking/parse/parsers/code/ast/languages/python.py+++ /dev/null@@ -1,201 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""Python AST extractor using tree-sitter-python."""--from typing import List--from openviking.parse.parsers.code.ast.languages.base import LanguageExtractor-from openviking.parse.parsers.code.ast.skeleton import ClassSkeleton, CodeSkeleton, FunctionSig---def _node_text(node, content_bytes: bytes) -> str:- return content_bytes[node.start_byte : node.end_byte].decode("utf-8", errors="replace")---def _first_string_child(body_node, content_bytes: bytes) -> str:- """Extract docstring from the first expression_statement in a body."""- if body_node is None:- return ""- for child in body_node.children:- if child.type == "expression_statement":- for sub in child.children:- if sub.type in ("string", "concatenated_string"):- raw = _node_text(sub, content_bytes).strip()- # Strip quotes- for q in ('"""', "'''", '"', "'"):- if raw.startswith(q) and raw.endswith(q) and len(raw) >= 2 * len(q):- return raw[len(q) : -len(q)].strip()- return raw- break # only check first expression_statement- return ""---def _extract_function(node, content_bytes: bytes) -> FunctionSig:- name = ""- params = ""- return_type = ""- body_node = None-- for child in node.children:- if child.type == "identifier":- name = _node_text(child, content_bytes)- elif child.type == "parameters":- raw = _node_text(child, content_bytes).strip()- # Remove surrounding parens- if raw.startswith("(") and raw.endswith(")"):- raw = raw[1:-1]- params = raw.strip()- elif child.type == "type":- return_type = _node_text(child, content_bytes).strip()- elif child.type == "block":- body_node = child-- docstring = _first_string_child(body_node, content_bytes)- return FunctionSig(- name=name,- params=params,- return_type=return_type,- docstring=docstring,- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---def _extract_class(node, content_bytes: bytes) -> ClassSkeleton:- name = ""- bases: List[str] = []- body_node = None-- for child in node.children:- if child.type == "identifier":- name = _node_text(child, content_bytes)- elif child.type == "argument_list":- # base classes- for arg in child.children:- if arg.type not in (",", "(", ")"):- bases.append(_node_text(arg, content_bytes).strip())- elif child.type == "block":- body_node = child-- docstring = _first_string_child(body_node, content_bytes)- methods: List[FunctionSig] = []- if body_node:- for child in body_node.children:- if child.type == "function_definition":- methods.append(_extract_function(child, content_bytes))- elif child.type == "decorated_definition":- # decorated method- for sub in child.children:- if sub.type == "function_definition":- methods.append(_extract_function(sub, content_bytes))-- return ClassSkeleton(- name=name,- bases=bases,- docstring=docstring,- methods=methods,- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---def _extract_imports(node, content_bytes: bytes) -> List[str]:- """Flatten import node into module name strings."""- results: List[str] = []- if node.type == "import_statement":- # import foo, bar- for child in node.children:- if child.type == "dotted_name":- results.append(_node_text(child, content_bytes))- elif child.type == "aliased_import":- for sub in child.children:- if sub.type == "dotted_name":- results.append(_node_text(sub, content_bytes))- break- elif node.type == "import_from_statement":- # from foo import bar, baz- module = ""- names: List[str] = []- for child in node.children:- if child.type == "dotted_name" and not module:- module = _node_text(child, content_bytes)- elif child.type == "import_prefix":- # relative imports like "from . import foo"- module = _node_text(child, content_bytes)- elif child.type == "wildcard_import":- results.append(f"{module}.*")- return results- elif child.type == "dotted_name" and module:- names.append(_node_text(child, content_bytes))- elif child.type == "aliased_import":- for sub in child.children:- if sub.type == "dotted_name":- names.append(_node_text(sub, content_bytes))- break-- if names:- for n in names:- results.append(f"{module}.{n}" if module else n)- elif module:- results.append(module)- return results---class PythonExtractor(LanguageExtractor):- def __init__(self):- import tree_sitter_python as tspython- from tree_sitter import Language, Parser-- self._language = Language(tspython.language())- self._parser = Parser(self._language)-- def extract(self, file_name: str, content: str) -> CodeSkeleton:- content_bytes = content.encode("utf-8")- tree = self._parser.parse(content_bytes)- root = tree.root_node-- module_doc = ""- imports: List[str] = []- classes: List[ClassSkeleton] = []- functions: List[FunctionSig] = []-- # Module docstring: first expression_statement at top level- for child in root.children:- if child.type == "expression_statement":- for sub in child.children:- if sub.type in ("string", "concatenated_string"):- raw = _node_text(sub, content_bytes).strip()- for q in ('"""', "'''", '"', "'"):- if raw.startswith(q) and raw.endswith(q) and len(raw) >= 2 * len(q):- module_doc = raw[len(q) : -len(q)].strip()- break- else:- module_doc = raw- break # only first statement- elif child.type not in ("comment", "newline"):- break-- for child in root.children:- if child.type in ("import_statement", "import_from_statement"):- imports.extend(_extract_imports(child, content_bytes))- elif child.type == "class_definition":- classes.append(_extract_class(child, content_bytes))- elif child.type == "function_definition":- functions.append(_extract_function(child, content_bytes))- elif child.type == "decorated_definition":- for sub in child.children:- if sub.type == "class_definition":- classes.append(_extract_class(sub, content_bytes))- break- elif sub.type == "function_definition":- functions.append(_extract_function(sub, content_bytes))- break-- return CodeSkeleton(- file_name=file_name,- language="Python",- module_doc=module_doc,- imports=imports,- classes=classes,- functions=functions,- )diff --git a/openviking/parse/parsers/code/ast/languages/rust.py b/openviking/parse/parsers/code/ast/languages/rust.pydeleted file mode 100644index 5b6eb6a69..000000000--- a/openviking/parse/parsers/code/ast/languages/rust.py+++ /dev/null@@ -1,146 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""Rust AST extractor using tree-sitter-rust."""--from typing import List--from openviking.parse.parsers.code.ast.languages.base import LanguageExtractor-from openviking.parse.parsers.code.ast.skeleton import ClassSkeleton, CodeSkeleton, FunctionSig---def _node_text(node, content_bytes: bytes) -> str:- return content_bytes[node.start_byte : node.end_byte].decode("utf-8", errors="replace")---def _preceding_doc(siblings: list, idx: int, content_bytes: bytes) -> str:- """Collect consecutive /// doc comment lines before siblings[idx]."""- lines = []- i = idx - 1- while i >= 0 and siblings[i].type == "line_comment":- node = siblings[i]- # Only /// doc comments have a doc_comment child- doc_child = next((c for c in node.children if c.type == "doc_comment"), None)- if doc_child is None:- break- lines.insert(0, _node_text(doc_child, content_bytes).strip())- i -= 1- return "\n".join(lines).strip()---def _extract_function(node, content_bytes: bytes, docstring: str = "") -> FunctionSig:- name = ""- params = ""- return_type = ""-- for child in node.children:- if child.type == "identifier" and not name:- name = _node_text(child, content_bytes)- elif child.type == "parameters":- raw = _node_text(child, content_bytes).strip()- if raw.startswith("(") and raw.endswith(")"):- raw = raw[1:-1]- params = raw.strip()- elif child.type == "type_identifier":- return_type = _node_text(child, content_bytes)- elif child.type == "scoped_type_identifier":- return_type = _node_text(child, content_bytes)- elif child.type == "generic_type":- return_type = _node_text(child, content_bytes)-- return FunctionSig(- name=name,- params=params,- return_type=return_type,- docstring=docstring,- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---def _extract_struct_or_trait(node, content_bytes: bytes, docstring: str = "") -> ClassSkeleton:- name = ""- bases: List[str] = []-- for child in node.children:- if child.type in ("type_identifier", "identifier") and not name:- name = _node_text(child, content_bytes)- elif child.type == "trait_bounds":- for sub in child.children:- if sub.type == "type_identifier":- bases.append(_node_text(sub, content_bytes))-- return ClassSkeleton(- name=name,- bases=bases,- docstring=docstring,- methods=[],- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---def _extract_impl(node, content_bytes: bytes) -> ClassSkeleton:- """impl Foo { ... } → treat as class with methods."""- name = ""- methods: List[FunctionSig] = []-- for child in node.children:- if child.type == "type_identifier" and not name:- name = _node_text(child, content_bytes)- elif child.type == "declaration_list":- siblings = list(child.children)- for idx, sub in enumerate(siblings):- if sub.type == "function_item":- doc = _preceding_doc(siblings, idx, content_bytes)- methods.append(_extract_function(sub, content_bytes, docstring=doc))-- return ClassSkeleton(- name=f"impl {name}",- bases=[],- docstring="",- methods=methods,- line_start=node.start_point[0] + 1,- line_end=node.end_point[0] + 1,- )---class RustExtractor(LanguageExtractor):- def __init__(self):- import tree_sitter_rust as tsrust- from tree_sitter import Language, Parser-- self._language = Language(tsrust.language())- self._parser = Parser(self._language)-- def extract(self, file_name: str, content: str) -> CodeSkeleton:- content_bytes = content.encode("utf-8")- tree = self._parser.parse(content_bytes)- root = tree.root_node-- imports: List[str] = []- classes: List[ClassSkeleton] = []- functions: List[FunctionSig] = []-- siblings = list(root.children)- for idx, child in enumerate(siblings):- if child.type == "use_declaration":- imports.append(- _node_text(child, content_bytes).strip().rstrip(";").replace("use ", "")- )- elif child.type in ("struct_item", "trait_item", "enum_item"):- doc = _preceding_doc(siblings, idx, content_bytes)- classes.append(_extract_struct_or_trait(child, content_bytes, docstring=doc))- elif child.type == "impl_item":- classes.append(_extract_impl(child, content_bytes))- elif child.type == "function_item":- doc = _preceding_doc(siblings, idx, content_bytes)- functions.append(_extract_function(child, content_bytes, docstring=doc))-- return CodeSkeleton(- file_name=file_name,- language="Rust",- module_doc="",- imports=imports,- classes=classes,- functions=functions,- )diff --git a/openviking/parse/parsers/code/ast/process_engine.py b/openviking/parse/parsers/code/ast/process_engine.pynew file mode 100644index 000000000..a6ff9541f--- /dev/null+++ b/openviking/parse/parsers/code/ast/process_engine.py@@ -0,0 +1,190 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: AGPL-3.0+"""Code skeleton extraction via tree-sitter-language-pack.process()."""++from pathlib import Path+from typing import Optional++from tree_sitter_language_pack import (+ ProcessConfig,+ SupportedLanguage,+ detect_language_from_path,+ process,+)++from openviking_cli.utils import get_logger++logger = get_logger(__name__)++_CLASS_KINDS = {"class", "struct", "interface", "enum", "trait", "impl", "namespace"}+_FUNC_KINDS = {"function", "method"}++_DISPLAY = {+ "python": "Python",+ "javascript": "JavaScript",+ "typescript": "TypeScript",+ "java": "Java",+ "c": "C",+ "cpp": "C/C++",+ "rust": "Rust",+ "go": "Go",+ "csharp": "C#",+ "php": "PHP",+ "lua": "Lua",+ "ruby": "Ruby",+ "kotlin": "Kotlin",+ "swift": "Swift",+ "scala": "Scala",+ "terraform": "Terraform",+ "proto": "Protocol Buffers",+ "protobuf": "Protocol Buffers",+ "graphql": "GraphQL",+ "prisma": "Prisma",+ "sql": "SQL",+}++_SUPPORTED_PROCESS_LANGUAGES = set(getattr(SupportedLanguage, "__args__", ()) or ())++_PROCESS_LANGUAGE_DENYLIST = {+ "markdown",+ "asciidoc",+ "html",+ "xml",+ "json",+ "json5",+ "jsonnet",+ "yaml",+ "toml",+ "ini",+ "csv",+ "tsv",+ "properties",+ "gitignore",+ "dockerfile",+ "make",+ "latex",+ "mermaid",+ "dot",+ "http",+ "hurl",+ "css",+ "scss",+ "less",+ "sass",+}++_PROCESS_SUFFIX_DENYLIST = {+ ".md",+ ".markdown",+ ".mdown",+ ".mkd",+ ".txt",+ ".rst",+ ".adoc",+ ".asciidoc",+ ".org",+ ".tex",+ ".latex",+ ".mmd",+ ".mermaid",+ ".dot",+ ".http",+ ".hurl",+ ".json",+ ".jsonl",+ ".yaml",+ ".yml",+ ".toml",+ ".ini",+ ".cfg",+ ".conf",+ ".properties",+ ".xml",+ ".html",+ ".htm",+ ".csv",+ ".tsv",+ ".log",+ ".lock",+ ".env",+ ".css",+ ".scss",+ ".less",+ ".sass",+}+++def _display_language(lang: str) -> str:+ return _DISPLAY.get(lang, lang.replace("_", " ").title())+++def _detect_process_language(file_name: str) -> Optional[str]:+ path = Path(file_name)+ if path.suffix.lower() in _PROCESS_SUFFIX_DENYLIST:+ return None++ try:+ lang = detect_language_from_path(str(path))+ except Exception as exc:+ logger.warning("process language detection failed for '%s': %s", file_name, exc)+ return None++ if (+ lang is None+ or lang not in _SUPPORTED_PROCESS_LANGUAGES+ or lang in _PROCESS_LANGUAGE_DENYLIST+ ):+ return None+ return lang+++def _extract_process_skeleton(file_name: str, content: str, lang: str) -> str:+ result = process(+ content,+ ProcessConfig(language=lang, structure=True, imports=True),+ )++ lines: list[str] = [f"# {file_name} [{_display_language(lang)}]"]++ imports = [item.source.strip() for item in result.imports if item.source]+ if imports:+ lines.append(f"imports: {', '.join(imports)}")+ lines.append("")++ for node in result.structure:+ kind = str(node.kind).lower()+ if kind in _CLASS_KINDS:+ lines.append(f"class {node.name or ''}")+ for child in node.children:+ if str(child.kind).lower() in _FUNC_KINDS and child.name:+ lines.append(f" + {child.name}()")+ lines.append("")+ elif kind in _FUNC_KINDS and node.name:+ lines.append(f"def {node.name}()")++ return "\n".join(lines).strip()+++def supports_process_skeleton(file_name: str) -> bool:+ return _detect_process_language(file_name) is not None+++def extract_process_skeleton(+ file_name: str,+ content: str,+ verbose: bool = False,+) -> Optional[str]:+ del verbose+ lang = _detect_process_language(file_name)+ if lang is None:+ return None+ try:+ return _extract_process_skeleton(file_name, content, lang)+ except Exception as exc:+ logger.warning(+ "process extraction failed for '%s' (language: %s): %s",+ file_name,+ lang,+ exc,+ )+ return Nonediff --git a/openviking/parse/parsers/code/ast/providers.py b/openviking/parse/parsers/code/ast/providers.pynew file mode 100644index 000000000..46a36e748--- /dev/null+++ b/openviking/parse/parsers/code/ast/providers.py@@ -0,0 +1,77 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: AGPL-3.0+"""Routing for tags-query, process, and LLM-fallback code summaries."""++from dataclasses import dataclass+from pathlib import Path+from typing import Optional++from openviking.parse.parsers.code.ast.aider_repomap import (+ _extract_with_grep_ast,+ has_tag_query,+)+from openviking.parse.parsers.code.ast.process_engine import (+ extract_process_skeleton,+ supports_process_skeleton,+)+from openviking_cli.utils import get_logger++logger = get_logger(__name__)++_IMPORT_ONLY_PREFIXES = ("#", "imports:", "module:", "language:")+++def supports_code_skeleton(file_name: str) -> bool:+ """Return whether tags or process extraction recognizes the file."""++ return has_tag_query(file_name) or supports_process_skeleton(file_name)+++@dataclass(frozen=True)+class SkeletonExtractionResult:+ text: Optional[str]+ provider: str+ should_fallback_to_llm: bool+ reason: str+++def is_skeleton_useful(text: Optional[str]) -> bool:+ """Return whether a skeleton contains extractor-produced structure."""++ if not text or not text.strip():+ return False+ return any(+ line.strip() and not line.strip().startswith(_IMPORT_ONLY_PREFIXES)+ for line in text.splitlines()+ )+++def extract_skeleton_result(+ file_name: str,+ content: str,+ verbose: bool = False,+) -> SkeletonExtractionResult:+ """Extract a skeleton, signalling when the caller must use LLM fallback."""++ reasons: list[str] = []+ if has_tag_query(file_name):+ text = None+ if content:+ rel_name = Path(file_name).name or "source.txt"+ text = _extract_with_grep_ast(file_name, rel_name, content, verbose)+ if is_skeleton_useful(text):+ return SkeletonExtractionResult(text, "aider_repomap", False, "maintained tags query")+ reason = "tags query produced no useful skeleton"+ logger.debug("Code skeleton requires LLM fallback for '%s': %s", file_name, reason)+ return SkeletonExtractionResult(None, "llm", True, reason)+ else:+ reasons.append("no maintained tags query")++ text = extract_process_skeleton(file_name, content, verbose=verbose)+ if is_skeleton_useful(text):+ return SkeletonExtractionResult(text, "process", False, "process extraction succeeded")+ reasons.append("process produced no useful skeleton")++ reason = "; ".join(reasons)+ logger.debug("Code skeleton requires LLM fallback for '%s': %s", file_name, reason)+ return SkeletonExtractionResult(None, "llm", True, reason)diff --git a/openviking/parse/parsers/code/ast/queries/AIDER_LICENSE.txt b/openviking/parse/parsers/code/ast/queries/AIDER_LICENSE.txtnew file mode 100644index 000000000..d64569567--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/AIDER_LICENSE.txt@@ -0,0 +1,202 @@++ Apache License+ Version 2.0, January 2004+ http://www.apache.org/licenses/++ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION++ 1. Definitions.++ "License" shall mean the terms and conditions for use, reproduction,+ and distribution as defined by Sections 1 through 9 of this document.++ "Licensor" shall mean the copyright owner or entity authorized by+ the copyright owner that is granting the License.++ "Legal Entity" shall mean the union of the acting entity and all+ other entities that control, are controlled by, or are under common+ control with that entity. For the purposes of this definition,+ "control" means (i) the power, direct or indirect, to cause the+ direction or management of such entity, whether by contract or+ otherwise, or (ii) ownership of fifty percent (50%) or more of the+ outstanding shares, or (iii) beneficial ownership of such entity.++ "You" (or "Your") shall mean an individual or Legal Entity+ exercising permissions granted by this License.++ "Source" form shall mean the preferred form for making modifications,+ including but not limited to software source code, documentation+ source, and configuration files.++ "Object" form shall mean any form resulting from mechanical+ transformation or translation of a Source form, including but+ not limited to compiled object code, generated documentation,+ and conversions to other media types.++ "Work" shall mean the work of authorship, whether in Source or+ Object form, made available under the License, as indicated by a+ copyright notice that is included in or attached to the work+ (an example is provided in the Appendix below).++ "Derivative Works" shall mean any work, whether in Source or Object+ form, that is based on (or derived from) the Work and for which the+ editorial revisions, annotations, elaborations, or other modifications+ represent, as a whole, an original work of authorship. For the purposes+ of this License, Derivative Works shall not include works that remain+ separable from, or merely link (or bind by name) to the interfaces of,+ the Work and Derivative Works thereof.++ "Contribution" shall mean any work of authorship, including+ the original version of the Work and any modifications or additions+ to that Work or Derivative Works thereof, that is intentionally+ submitted to Licensor for inclusion in the Work by the copyright owner+ or by an individual or Legal Entity authorized to submit on behalf of+ the copyright owner. For the purposes of this definition, "submitted"+ means any form of electronic, verbal, or written communication sent+ to the Licensor or its representatives, including but not limited to+ communication on electronic mailing lists, source code control systems,+ and issue tracking systems that are managed by, or on behalf of, the+ Licensor for the purpose of discussing and improving the Work, but+ excluding communication that is conspicuously marked or otherwise+ designated in writing by the copyright owner as "Not a Contribution."++ "Contributor" shall mean Licensor and any individual or Legal Entity+ on behalf of whom a Contribution has been received by Licensor and+ subsequently incorporated within the Work.++ 2. Grant of Copyright License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ copyright license to reproduce, prepare Derivative Works of,+ publicly display, publicly perform, sublicense, and distribute the+ Work and such Derivative Works in Source or Object form.++ 3. Grant of Patent License. Subject to the terms and conditions of+ this License, each Contributor hereby grants to You a perpetual,+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable+ (except as stated in this section) patent license to make, have made,+ use, offer to sell, sell, import, and otherwise transfer the Work,+ where such license applies only to those patent claims licensable+ by such Contributor that are necessarily infringed by their+ Contribution(s) alone or by combination of their Contribution(s)+ with the Work to which such Contribution(s) was submitted. If You+ institute patent litigation against any entity (including a+ cross-claim or counterclaim in a lawsuit) alleging that the Work+ or a Contribution incorporated within the Work constitutes direct+ or contributory patent infringement, then any patent licenses+ granted to You under this License for that Work shall terminate+ as of the date such litigation is filed.++ 4. Redistribution. You may reproduce and distribute copies of the+ Work or Derivative Works thereof in any medium, with or without+ modifications, and in Source or Object form, provided that You+ meet the following conditions:++ (a) You must give any other recipients of the Work or+ Derivative Works a copy of this License; and++ (b) You must cause any modified files to carry prominent notices+ stating that You changed the files; and++ (c) You must retain, in the Source form of any Derivative Works+ that You distribute, all copyright, patent, trademark, and+ attribution notices from the Source form of the Work,+ excluding those notices that do not pertain to any part of+ the Derivative Works; and++ (d) If the Work includes a "NOTICE" text file as part of its+ distribution, then any Derivative Works that You distribute must+ include a readable copy of the attribution notices contained+ within such NOTICE file, excluding those notices that do not+ pertain to any part of the Derivative Works, in at least one+ of the following places: within a NOTICE text file distributed+ as part of the Derivative Works; within the Source form or+ documentation, if provided along with the Derivative Works; or,+ within a display generated by the Derivative Works, if and+ wherever such third-party notices normally appear. The contents+ of the NOTICE file are for informational purposes only and+ do not modify the License. You may add Your own attribution+ notices within Derivative Works that You distribute, alongside+ or as an addendum to the NOTICE text from the Work, provided+ that such additional attribution notices cannot be construed+ as modifying the License.++ You may add Your own copyright statement to Your modifications and+ may provide additional or different license terms and conditions+ for use, reproduction, or distribution of Your modifications, or+ for any such Derivative Works as a whole, provided Your use,+ reproduction, and distribution of the Work otherwise complies with+ the conditions stated in this License.++ 5. Submission of Contributions. Unless You explicitly state otherwise,+ any Contribution intentionally submitted for inclusion in the Work+ by You to the Licensor shall be under the terms and conditions of+ this License, without any additional terms or conditions.+ Notwithstanding the above, nothing herein shall supersede or modify+ the terms of any separate license agreement you may have executed+ with Licensor regarding such Contributions.++ 6. Trademarks. This License does not grant permission to use the trade+ names, trademarks, service marks, or product names of the Licensor,+ except as required for reasonable and customary use in describing the+ origin of the Work and reproducing the content of the NOTICE file.++ 7. Disclaimer of Warranty. Unless required by applicable law or+ agreed to in writing, Licensor provides the Work (and each+ Contributor provides its Contributions) on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or+ implied, including, without limitation, any warranties or conditions+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A+ PARTICULAR PURPOSE. You are solely responsible for determining the+ appropriateness of using or redistributing the Work and assume any+ risks associated with Your exercise of permissions under this License.++ 8. Limitation of Liability. In no event and under no legal theory,+ whether in tort (including negligence), contract, or otherwise,+ unless required by applicable law (such as deliberate and grossly+ negligent acts) or agreed to in writing, shall any Contributor be+ liable to You for damages, including any direct, indirect, special,+ incidental, or consequential damages of any character arising as a+ result of this License or out of the use or inability to use the+ Work (including but not limited to damages for loss of goodwill,+ work stoppage, computer failure or malfunction, or any and all+ other commercial damages or losses), even if such Contributor+ has been advised of the possibility of such damages.++ 9. Accepting Warranty or Additional Liability. While redistributing+ the Work or Derivative Works thereof, You may choose to offer,+ and charge a fee for, acceptance of support, warranty, indemnity,+ or other liability obligations and/or rights consistent with this+ License. However, in accepting such obligations, You may act only+ on Your own behalf and on Your sole responsibility, not on behalf+ of any other Contributor, and only if You agree to indemnify,+ defend, and hold each Contributor harmless for any liability+ incurred by, or claims asserted against, such Contributor by reason+ of your accepting any such warranty or additional liability.++ END OF TERMS AND CONDITIONS++ APPENDIX: How to apply the Apache License to your work.++ To apply the Apache License to your work, attach the following+ boilerplate notice, with the fields enclosed by brackets "[]"+ replaced with your own identifying information. (Don't include+ the brackets!) The text should be enclosed in the appropriate+ comment syntax for the file format. We also recommend that a+ file or class name and description of purpose be included on the+ same "printed page" as the copyright notice for easier+ identification within third-party archives.++ Copyright [yyyy] [name of copyright owner]++ Licensed under the Apache License, Version 2.0 (the "License");+ you may not use this file except in compliance with the License.+ You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++ Unless required by applicable law or agreed to in writing, software+ distributed under the License is distributed on an "AS IS" BASIS,+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ See the License for the specific language governing permissions and+ limitations under the License.diff --git a/openviking/parse/parsers/code/ast/queries/THIRD_PARTY_NOTICES.md b/openviking/parse/parsers/code/ast/queries/THIRD_PARTY_NOTICES.mdnew file mode 100644index 000000000..deb752e6b--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/THIRD_PARTY_NOTICES.md@@ -0,0 +1,50 @@+Third-Party Notices for Code Skeleton Queries+=============================================++This directory contains OpenViking-maintained tree-sitter tag queries used for+code skeleton extraction. The query set has mixed provenance:++- Some `.scm` files were initially adapted from Aider's RepoMap query set.+- Some `.scm` files were authored or substantially rewritten by OpenViking.+- All files in this directory are maintained by OpenViking going forward.++Do not assume that every file in this directory is vendored from Aider.++Aider Source+------------++The Aider-derived query files were adapted from:++https://github.com/Aider-AI/aider/tree/main/aider/queries/tree-sitter-language-pack++Reference revision:++5dc9490bb35f9729ef2c95d00a19ccd30c26339c++Aider is licensed under the Apache License, Version 2.0. A copy of that license+is included in this directory as `AIDER_LICENSE.txt` because this query set+contains Aider-derived material.++Aider's query directory states that its `.scm` files are adapted from the+language repositories listed by tree-sitter-language-pack:++https://github.com/Goldziher/tree-sitter-language-pack/blob/main/sources/language_definitions.json++See the tree-sitter-language-pack project for information about those language+repositories:++https://github.com/Goldziher/tree-sitter-language-pack/++OpenViking Maintenance Policy+-----------------------------++OpenViking may modify, replace, or add tag query files in this directory to+improve code skeleton extraction quality. For future changes:++- Keep `AIDER_LICENSE.txt` while any Aider-derived query remains.+- Add a short file header or update this notice when adding a query with a+ third-party source.+- For OpenViking-authored queries, no third-party attribution is required unless+ they are based on another project.+- If a previously Aider-derived query is replaced with a fully original+ OpenViking implementation, record that change in the file or this notice.diff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/arduino-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/arduino-tags.scmnew file mode 100644index 000000000..71cc3849f--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/arduino-tags.scm@@ -0,0 +1,5 @@+(function_declarator+ declarator: (identifier) @name.definition.function) @definition.function++(call_expression+ function: (identifier) @name.reference.call) @reference.calldiff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/c-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/c-tags.scmnew file mode 100644index 000000000..1035aa224--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/c-tags.scm@@ -0,0 +1,9 @@+(struct_specifier name: (type_identifier) @name.definition.class body:(_)) @definition.class++(declaration type: (union_specifier name: (type_identifier) @name.definition.class)) @definition.class++(function_declarator declarator: (identifier) @name.definition.function) @definition.function++(type_definition declarator: (type_identifier) @name.definition.type) @definition.type++(enum_specifier name: (type_identifier) @name.definition.type) @definition.typediff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/chatito-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/chatito-tags.scmnew file mode 100644index 000000000..6fbac9420--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/chatito-tags.scm@@ -0,0 +1,16 @@+; Definitions+(intent_def+ (intent) @name.definition.intent) @definition.intent++(slot_def+ (slot) @name.definition.slot) @definition.slot++(alias_def+ (alias) @name.definition.alias) @definition.alias++; References+(slot_ref+ (slot) @name.reference.slot) @reference.slot++(alias_ref+ (alias) @name.reference.alias) @reference.aliasdiff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/clojure-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/clojure-tags.scmnew file mode 100644index 000000000..4b2bfa172--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/clojure-tags.scm@@ -0,0 +1,7 @@+(list_lit+ meta: _*+ . (sym_lit name: (sym_name) @ignore)+ . (sym_lit name: (sym_name) @name.definition.method)+ (#match? @ignore "^def.*"))++(sym_lit name: (sym_name) @name.reference.call)diff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/commonlisp-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/commonlisp-tags.scmnew file mode 100644index 000000000..a47dfeeda--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/commonlisp-tags.scm@@ -0,0 +1,122 @@+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+;;; Function Definitions ;;;;;;;;;;;;;;;;;;;;;;;++(defun_header+ function_name: (sym_lit) @name.definition.function) @definition.function++;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+;;; Function Calls ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+;;;+;;; Basically, we consider every list literal with symbol as the+;;; first element to be a call to a function named by that element.+;;; But we must exclude some cases. Note, tree-sitter @ignore+;;; cases only work if they are declared before the cases+;;; we want to include.++;; Exclude lambda lists for function definitions+;; For example:+;;+;; (defun my-func (arg1 arg2) ...)+;;+;; do not treat (arg1 arg2) as a call of function arg1+;;+(defun_header+ lambda_list: (list_lit . [(sym_lit) (package_lit)] @ignore))++;; Similar to the above, but for+;;+;; (defmethod m ((type1 param1) (type2 param2)) ...)+;;+;; where list literals having symbol as their first element+;; are nested inside the lambda list.+(defun_header+ lambda_list: (list_lit (list_lit . [(sym_lit) (package_lit)] @ignore)))++;;+;; (let ((var ...) (var2 ...)) ...)+;;+;; - exclude var, var2+;; - the same for let*, flet, labels, macrolet, symbol-macrolet+(list_lit . [(sym_lit) (package_lit)] @name.reference.call+ . (list_lit (list_lit . [(sym_lit) (package_lit)] @ignore))+ (#match? @name.reference.call+ "(?i)^(cl:)?(let|let\\*|flet|labels|macrolet|symbol-macrolet)$")+ )++;; TODO:+;; - exclude also:+;; - (defclass name (parent parent2)+;; ((slot1 ...)+;; (slot2 ...))+;; exclude the parent, slot1, slot2+;; - (flet ((func-1 (param1 param2))) ...)+;; - we already exclude func-1, but param1 is still recognized+;; as a function call - exclude it too+;; - the same for labels+;; - the same macrolet+;; - what else?+;; (that's a non-goal to completely support all macros+;; and special operators, but every one we support+;; makes the solution a little bit better)+;; - (flet ((func-1 (param1 param2))) ...)+;; - instead of simply excluding it, as we do today,+;; tag func-1 as @local.definition.function (I suppose)+;; - the same for labels, macrolet+;; - @local.scope for let, let*, flet, labels, macrolet+;; - I guess the whole span of the scope text,+;; till the closing paren, should be tagged as @local.scope;+;; Hopefully, combined with @local.definition.function+;; within the scope, the usual @reference.call within+;; that scope will refer to the local definition,+;; and there will be no need to use @local.reference.call+;; (which is more difficult to implement).+;; - When implementing, remember the scope rules differences+;; of let vs let*, flet vs labels.+++;; Include all other cases - list literal with symbol as the+;; first element+(list_lit . [(sym_lit) (package_lit)] @name.reference.call) @reference.call++;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+;;; classes++(list_lit . [(sym_lit) (package_lit)] @ignore+ . [(sym_lit) (package_lit)] @name.definition.class+ (#match? @ignore "(?i)^(cl:)?defclass$")+ ) @definition.class++(list_lit . [(sym_lit) (package_lit)] @ignore+ . (quoting_lit [(sym_lit) (package_lit)] @name.reference.class)+ (#match? @ignore "(?i)^(cl:)?make-instance$")+ ) @reference.class++;;; TODO:+;; - @reference.class for base classes++;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+;;; TODO:+;; - Symbols referenced in defpackage+;;+;; (defpackage ...+;; (:export (symbol-a :symbol-b #:symbol-c "SYMBOL-D")))+;;+;; The goal is to allow quick navigation from the API+;; overview in the form of defpackage, to the definition+;; where user can read parameters, docstring, etc.+;; - The @name must not include the colon, or sharpsign colon, quotes,+;; just symbol-a, symbol-b, symbol-c, sybmol-d+;; - Downcase the names specified as string literals?+;; ("SYMBOL-D" -> symbol-d)+;; - We don't know if the exported symbol is a function, variable,+;; class or something else. The official doc+;; (https://tree-sitter.github.io/tree-sitter/code-navigation-systems)+;; does not even suggest a tag for variable reference.+;; (Although in practice, the `tree-sitter tags` command+;; allows any @reference.* and @definition.* tags)+;; Probably it's better to just use @reference.call for all+;; the symbols in the :export clause.+;;+;; - The same for the export function call:+;;+;; (export '(symbol-a :symbol-b #:symbol-c "SYMBOL-D"))diff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/cpp-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/cpp-tags.scmnew file mode 100644index 000000000..bf864dbff--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/cpp-tags.scm@@ -0,0 +1,91 @@+; C++ declarations used by RepoMap-style summary extraction.+; Keep function captures scoped to real declarations/definitions so local+; object construction such as `std::vector<T> buf(n)` is not tagged as a+; function definition.++(struct_specifier+ name: (type_identifier) @name.definition.class+ body: (_)) @definition.class++(class_specifier+ name: (type_identifier) @name.definition.class) @definition.class++(declaration+ type: (union_specifier+ name: (type_identifier) @name.definition.class)) @definition.class++(enum_specifier+ name: (type_identifier) @name.definition.type) @definition.type++(type_definition+ declarator: (type_identifier) @name.definition.type) @definition.type++(declaration_list+ (alias_declaration+ name: (type_identifier) @name.definition.type)) @definition.type++(field_declaration_list+ (alias_declaration+ name: (type_identifier) @name.definition.type)) @definition.type++(function_definition+ declarator: (function_declarator+ declarator: (identifier) @name.definition.function)) @definition.function++(function_definition+ declarator: (function_declarator+ declarator: (field_identifier) @name.definition.method)) @definition.method++(function_definition+ declarator: (function_declarator+ declarator: (qualified_identifier+ scope: (_) @local.scope+ name: (identifier) @name.definition.method))) @definition.method++(function_definition+ declarator: (function_declarator+ declarator: (operator_name) @name.definition.method)) @definition.method++(function_definition+ declarator: (function_declarator+ declarator: (destructor_name) @name.definition.method)) @definition.method++(template_declaration+ (declaration+ declarator: (function_declarator+ declarator: (identifier) @name.definition.function))) @definition.function++(template_declaration+ (declaration+ declarator: (function_declarator+ declarator: (qualified_identifier+ scope: (_) @local.scope+ name: (identifier) @name.definition.method)))) @definition.method++(declaration_list+ (declaration+ declarator: (function_declarator+ declarator: (identifier) @name.definition.function))) @definition.function++(declaration_list+ (declaration+ declarator: (function_declarator+ declarator: (qualified_identifier+ scope: (_) @local.scope+ name: (identifier) @name.definition.method)))) @definition.method++(field_declaration+ declarator: (function_declarator+ declarator: (field_identifier) @name.definition.method)) @definition.method++(field_declaration+ declarator: (function_declarator+ declarator: (identifier) @name.definition.method)) @definition.method++(field_declaration+ declarator: (function_declarator+ declarator: (operator_name) @name.definition.method)) @definition.method++(field_declaration+ declarator: (function_declarator+ declarator: (destructor_name) @name.definition.method)) @definition.methoddiff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/cuda-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/cuda-tags.scmnew file mode 100644index 000000000..be5a80c00--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/cuda-tags.scm@@ -0,0 +1,91 @@+; CUDA/C++ declarations used by RepoMap-style summary extraction.+; Keep function captures scoped to real declarations/definitions so local+; object construction such as `std::vector<T> buf(n)` is not tagged as a+; function definition.++(struct_specifier+ name: (type_identifier) @name.definition.class+ body: (_)) @definition.class++(class_specifier+ name: (type_identifier) @name.definition.class) @definition.class++(declaration+ type: (union_specifier+ name: (type_identifier) @name.definition.class)) @definition.class++(enum_specifier+ name: (type_identifier) @name.definition.type) @definition.type++(type_definition+ declarator: (type_identifier) @name.definition.type) @definition.type++(declaration_list+ (alias_declaration+ name: (type_identifier) @name.definition.type)) @definition.type++(field_declaration_list+ (alias_declaration+ name: (type_identifier) @name.definition.type)) @definition.type++(function_definition+ declarator: (function_declarator+ declarator: (identifier) @name.definition.function)) @definition.function++(function_definition+ declarator: (function_declarator+ declarator: (field_identifier) @name.definition.method)) @definition.method++(function_definition+ declarator: (function_declarator+ declarator: (qualified_identifier+ scope: (_) @local.scope+ name: (identifier) @name.definition.method))) @definition.method++(function_definition+ declarator: (function_declarator+ declarator: (operator_name) @name.definition.method)) @definition.method++(function_definition+ declarator: (function_declarator+ declarator: (destructor_name) @name.definition.method)) @definition.method++(template_declaration+ (declaration+ declarator: (function_declarator+ declarator: (identifier) @name.definition.function))) @definition.function++(template_declaration+ (declaration+ declarator: (function_declarator+ declarator: (qualified_identifier+ scope: (_) @local.scope+ name: (identifier) @name.definition.method)))) @definition.method++(declaration_list+ (declaration+ declarator: (function_declarator+ declarator: (identifier) @name.definition.function))) @definition.function++(declaration_list+ (declaration+ declarator: (function_declarator+ declarator: (qualified_identifier+ scope: (_) @local.scope+ name: (identifier) @name.definition.method)))) @definition.method++(field_declaration+ declarator: (function_declarator+ declarator: (field_identifier) @name.definition.method)) @definition.method++(field_declaration+ declarator: (function_declarator+ declarator: (identifier) @name.definition.method)) @definition.method++(field_declaration+ declarator: (function_declarator+ declarator: (operator_name) @name.definition.method)) @definition.method++(field_declaration+ declarator: (function_declarator+ declarator: (destructor_name) @name.definition.method)) @definition.methoddiff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/d-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/d-tags.scmnew file mode 100644index 000000000..d153a81a2--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/d-tags.scm@@ -0,0 +1,20 @@+(module_def (module_declaration (module_fqn) @name.definition.module)) @definition.module++(struct_declaration (struct) . (identifier) @name.definition.class) @definition.class+(interface_declaration (interface) . (identifier) @name.definition.interface) @definition.interface+(enum_declaration (enum) . (identifier) @name.definition.type) @definition.type++(class_declaration (class) . (identifier) @name.definition.class) @definition.class+(constructor (this) @name.definition.method) @definition.method+(destructor (this) @name.definition.method) @definition.method+(postblit (this) @name.definition.method) @definition.method++(function_declaration (identifier) @name.definition.function) @definition.function++(union_declaration (union) . (identifier) @name.definition.type) @definition.type++(call_expression (identifier) @name.reference.call) @reference.call+(call_expression (type (template_instance (identifier) @name.reference.call))) @reference.call+(parameter (type (identifier) @name.reference.class) @reference.class (identifier))++(variable_declaration (type (identifier) @name.reference.class) @reference.class (declarator))diff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/dart-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/dart-tags.scmnew file mode 100644index 000000000..a11fafcb1--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/dart-tags.scm@@ -0,0 +1,92 @@++(class_definition+ name: (identifier) @name.definition.class) @definition.class++(method_signature+ (function_signature)) @definition.method++(type_alias+ (type_identifier) @name.definition.type) @definition.type++(method_signature+(getter_signature+ name: (identifier) @name.definition.method)) @definition.method++(method_signature+(setter_signature+ name: (identifier) @name.definition.method)) @definition.method++(method_signature+ (function_signature+ name: (identifier) @name.definition.method)) @definition.method++(method_signature+ (factory_constructor_signature+ (identifier) @name.definition.method)) @definition.method++(method_signature+ (constructor_signature+ name: (identifier) @name.definition.method)) @definition.method++(method_signature+ (operator_signature)) @definition.method++(method_signature) @definition.method++(mixin_declaration+ (mixin)+ (identifier) @name.definition.mixin) @definition.mixin++(extension_declaration+ name: (identifier) @name.definition.extension) @definition.extension+++(new_expression+ (type_identifier) @name.reference.class) @reference.class++(enum_declaration+ name: (identifier) @name.definition.enum) @definition.enum++(function_signature+ name: (identifier) @name.definition.function) @definition.function++(initialized_variable_definition+ name: (identifier)+ value: (identifier) @name.reference.class+ value: (selector+ "!"?+ (argument_part+ (arguments+ (argument)*))?)?) @reference.class++(assignment_expression+ left: (assignable_expression+ (identifier)+ (unconditional_assignable_selector+ "."+ (identifier) @name.reference.send))) @reference.call++(assignment_expression+ left: (assignable_expression+ (identifier)+ (conditional_assignable_selector+ "?."+ (identifier) @name.reference.send))) @reference.call++((identifier) @name.reference.send+ (selector+ "!"?+ (conditional_assignable_selector+ "?." (identifier) @name.reference.send)?+ (unconditional_assignable_selector+ "."? (identifier) @name.reference.send)?+ (argument_part+ (arguments+ (argument)*))?)*+ (cascade_section+ (cascade_selector+ (identifier)) @name.reference.send+ (argument_part+ (arguments+ (argument)*))?)?) @reference.call+diff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/elisp-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/elisp-tags.scmnew file mode 100644index 000000000..81e50d8e0--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/elisp-tags.scm@@ -0,0 +1,5 @@+;; defun/defsubst+(function_definition name: (symbol) @name.definition.function) @definition.function++;; Treat macros as function definitions for the sake of TAGS.+(macro_definition name: (symbol) @name.definition.function) @definition.functiondiff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/elixir-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/elixir-tags.scmnew file mode 100644index 000000000..e0a351e32--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/elixir-tags.scm@@ -0,0 +1,54 @@+; Definitions++; * modules and protocols+(call+ target: (identifier) @ignore+ (arguments (alias) @name.definition.module)+ (#any-of? @ignore "defmodule" "defprotocol")) @definition.module++; * functions/macros+(call+ target: (identifier) @ignore+ (arguments+ [+ ; zero-arity functions with no parentheses+ (identifier) @name.definition.function+ ; regular function clause+ (call target: (identifier) @name.definition.function)+ ; function clause with a guard clause+ (binary_operator+ left: (call target: (identifier) @name.definition.function)+ operator: "when")+ ])+ (#any-of? @ignore "def" "defp" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp")) @definition.function++; References++; ignore calls to kernel/special-forms keywords+(call+ target: (identifier) @ignore+ (#any-of? @ignore "def" "defp" "defdelegate" "defguard" "defguardp" "defmacro" "defmacrop" "defn" "defnp" "defmodule" "defprotocol" "defimpl" "defstruct" "defexception" "defoverridable" "alias" "case" "cond" "else" "for" "if" "import" "quote" "raise" "receive" "require" "reraise" "super" "throw" "try" "unless" "unquote" "unquote_splicing" "use" "with"))++; ignore module attributes+(unary_operator+ operator: "@"+ operand: (call+ target: (identifier) @ignore))++; * function call+(call+ target: [+ ; local+ (identifier) @name.reference.call+ ; remote+ (dot+ right: (identifier) @name.reference.call)+ ]) @reference.call++; * pipe into function call+(binary_operator+ operator: "|>"+ right: (identifier) @name.reference.call) @reference.call++; * modules+(alias) @name.reference.module @reference.modulediff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/elm-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/elm-tags.scmnew file mode 100644index 000000000..c2e042763--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/elm-tags.scm@@ -0,0 +1,19 @@+(value_declaration (function_declaration_left (lower_case_identifier) @name.definition.function)) @definition.function++(function_call_expr (value_expr (value_qid) @name.reference.function)) @reference.function+(exposed_value (lower_case_identifier) @name.reference.function) @reference.function+(type_annotation ((lower_case_identifier) @name.reference.function) (colon)) @reference.function++(type_declaration ((upper_case_identifier) @name.definition.type) ) @definition.type++(type_ref (upper_case_qid (upper_case_identifier) @name.reference.type)) @reference.type+(exposed_type (upper_case_identifier) @name.reference.type) @reference.type++(type_declaration (union_variant (upper_case_identifier) @name.definition.union)) @definition.union++(value_expr (upper_case_qid (upper_case_identifier) @name.reference.union)) @reference.union+++(module_declaration+ (upper_case_qid (upper_case_identifier)) @name.definition.module+) @definition.modulediff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/gleam-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/gleam-tags.scmnew file mode 100644index 000000000..b1b934c20--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/gleam-tags.scm@@ -0,0 +1,41 @@+; Modules+(module) @name.reference.module @reference.module+(import alias: (identifier) @name.reference.module) @reference.module+(remote_type_identifier+ module: (identifier) @name.reference.module) @reference.module+((field_access+ record: (identifier) @name.reference.module)+ (#is-not? local)) @reference.module++; Functions+(function+ name: (identifier) @name.definition.function) @definition.function+(external_function+ name: (identifier) @name.definition.function) @definition.function+(unqualified_import (identifier) @name.reference.function) @reference.function+((function_call+ function: (identifier) @name.reference.function) @reference.function+ (#is-not? local))+((field_access+ record: (identifier) @ignore+ field: (label) @name.reference.function)+ (#is-not? local)) @reference.function+((binary_expression+ operator: "|>"+ right: (identifier) @name.reference.function)+ (#is-not? local)) @reference.function++; Types+(type_definition+ (type_name+ name: (type_identifier) @name.definition.type)) @definition.type+(type_definition+ (data_constructors+ (data_constructor+ name: (constructor_name) @name.definition.constructor))) @definition.constructor+(external_type+ (type_name+ name: (type_identifier) @name.definition.type)) @definition.type++(type_identifier) @name.reference.type @reference.type+(constructor_name) @name.reference.constructor @reference.constructordiff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/matlab-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/matlab-tags.scmnew file mode 100644index 000000000..66f12527f--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/matlab-tags.scm@@ -0,0 +1,10 @@+(class_definition+ name: (identifier) @name.definition.class) @definition.class++(function_definition+ name: (identifier) @name.definition.function) @definition.function++(function_call+ name: (identifier) @name.reference.call) @reference.call++(command (command_name) @name.reference.call) @reference.call\ No newline at end of filediff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/ocaml-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/ocaml-tags.scmnew file mode 100644index 000000000..52d5a857e--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/ocaml-tags.scm@@ -0,0 +1,115 @@+; Modules+;--------++(+ (comment)? @doc .+ (module_definition (module_binding (module_name) @name.definition.module) @definition.module)+ (#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")+)++(module_path (module_name) @name.reference.module) @reference.module++; Module types+;--------------++(+ (comment)? @doc .+ (module_type_definition (module_type_name) @name.definition.interface) @definition.interface+ (#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")+)++(module_type_path (module_type_name) @name.reference.implementation) @reference.implementation++; Functions+;----------++(+ (comment)? @doc .+ (value_definition+ [+ (let_binding+ pattern: (value_name) @name.definition.function+ (parameter))+ (let_binding+ pattern: (value_name) @name.definition.function+ body: [(fun_expression) (function_expression)])+ ] @definition.function+ )+ (#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")+)++(+ (comment)? @doc .+ (external (value_name) @name.definition.function) @definition.function+ (#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")+)++(application_expression+ function: (value_path (value_name) @name.reference.call)) @reference.call++(infix_expression+ left: (value_path (value_name) @name.reference.call)+ operator: (concat_operator) @reference.call+ (#eq? @reference.call "@@"))++(infix_expression+ operator: (rel_operator) @reference.call+ right: (value_path (value_name) @name.reference.call)+ (#eq? @reference.call "|>"))++; Operator+;---------++(+ (comment)? @doc .+ (value_definition+ (let_binding+ pattern: (parenthesized_operator (_) @name.definition.function)) @definition.function)+ (#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")+)++[+ (prefix_operator)+ (sign_operator)+ (pow_operator)+ (mult_operator)+ (add_operator)+ (concat_operator)+ (rel_operator)+ (and_operator)+ (or_operator)+ (assign_operator)+ (hash_operator)+ (indexing_operator)+ (let_operator)+ (let_and_operator)+ (match_operator)+] @name.reference.call @reference.call++; Classes+;--------++(+ (comment)? @doc .+ [+ (class_definition (class_binding (class_name) @name.definition.class) @definition.class)+ (class_type_definition (class_type_binding (class_type_name) @name.definition.class) @definition.class)+ ]+ (#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")+)++[+ (class_path (class_name) @name.reference.class)+ (class_type_path (class_type_name) @name.reference.class)+] @reference.class++; Methods+;--------++(+ (comment)? @doc .+ (method_definition (method_name) @name.definition.method) @definition.method+ (#strip! @doc "^\\(\\*\\*?\\s*|\\s\\*\\)$")+)++(method_invocation (method_name) @name.reference.call) @reference.calldiff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/ocaml_interface-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/ocaml_interface-tags.scmnew file mode 100644index 000000000..4e1d1fb24--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/ocaml_interface-tags.scm@@ -0,0 +1,98 @@+; Modules+;--------++(+ (comment)? @doc .+ (module_definition+ (module_binding (module_name) @name.definition.module) @definition.module+ )+ (#strip! @doc "^\\(\\*+\\s*|\\s*\\*+\\)$")+)++(module_path (module_name) @name) @reference.module+(extended_module_path (module_name) @name) @reference.module++(+ (comment)? @doc .+ (module_type_definition (module_type_name) @name.definition.interface) @definition.interface+ (#strip! @doc "^\\(\\*+\\s*|\\s*\\*+\\)$")+)++(module_type_path (module_type_name) @name) @reference.implementation+++; Classes+;--------++(+ (comment)? @doc .+ [+ (class_definition+ (class_binding (class_name) @name.definition.class) @definition.class+ )+ (class_type_definition+ (class_type_binding (class_type_name) @name.definition.class) @definition.class+ )+ ]+ (#strip! @doc "^\\(\\*+\\s*|\\s*\\*+\\)$")+)++[+ (class_path (class_name) @name)+ (class_type_path (class_type_name) @name)+] @reference.class++(+ (comment)? @doc .+ (method_definition (method_name) @name.definition.method) @definition.method+ (#strip! @doc "^\\(\\*+\\s*|\\s*\\*+\\)$")+)++(method_invocation (method_name) @name) @reference.call+++; Types+;------++(+ (comment)? @doc .+ (type_definition+ (type_binding+ name: [+ (type_constructor) @name.definition.type+ (type_constructor_path (type_constructor) @name.definition.type)+ ]+ ) @definition.type+ )+ (#strip! @doc "^\\(\\*+\\s*|\\s*\\*+\\)$")+)++(type_constructor_path (type_constructor) @name) @reference.type++[+ (constructor_declaration (constructor_name) @name)+ (tag_specification (tag) @name)+] @definition.enum_variant++[+ (constructor_path (constructor_name) @name)+ (tag) @name+] @reference.enum_variant++(field_declaration (field_name) @name) @definition.field++(field_path (field_name) @name) @reference.field++(+ (comment)? @doc .+ (external (value_name) @name.definition.function) @definition.function+ (#strip! @doc "^\\(\\*+\\s*|\\s*\\*+\\)$")+)++(+ (comment)? @doc .+ (value_specification+ (value_name) @name.definition.function+ ) @definition.function+ (#strip! @doc "^\\(\\*+\\s*|\\s*\\*+\\)$")+)diff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/pony-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/pony-tags.scmnew file mode 100644index 000000000..695f628ea--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/pony-tags.scm@@ -0,0 +1,39 @@+;Class definitions @definition.class+;Function definitions @definition.function+;Interface definitions @definition.interface+;Method definitions @definition.method+;Module definitions @definition.module+;Function/method calls @reference.call+;Class reference @reference.class+;Interface implementation @reference.implementation+(+ (identifier) @reference.class+ (#match? @reference.class "^_*[A-Z][a-zA-Z0-9_]*$")+)++(class_definition (identifier) @name.definition.class) @definition.class+(actor_definition (identifier) @name.definition.class) @definition.class+(primitive_definition (identifier) @name.definition.class) @definition.class+(struct_definition (identifier) @name.definition.class) @definition.class+(type_alias (identifier) @name.definition.class) @definition.class++(trait_definition (identifier) @name.definition.interface) @definition.interface+(interface_definition (identifier) @name.definition.interface) @definition.interface++(constructor (identifier) @name.definition.method) @definition.method+(method (identifier) @name.definition.method) @definition.method+(behavior (identifier) @name.definition.method) @definition.method++(class_definition (type) @name.reference.implementation) @reference.implementation+(actor_definition (type) @name.reference.implementation) @reference.implementation+(primitive_definition (type) @name.reference.implementation) @reference.implementation+(struct_definition (type) @name.reference.implementation) @reference.implementation+(type_alias (type) @name.reference.implementation) @reference.implementation++; calls - not catching all possible call cases of callees for capturing the method name+(call_expression callee: [(identifier) (ffi_identifier)] @name.reference.call) @reference.call+(call_expression callee: (generic_expression [(identifier) (ffi_identifier)] @name.reference.call)) @reference.call+(call_expression callee: (member_expression (identifier) @name.reference.call .)) @reference.call+(call_expression callee: (member_expression (generic_expression [(identifier) (ffi_identifier)] @name.reference.call) .)) @reference.call+; TODO: add more possible callee expressions+(call_expression) @reference.calldiff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/properties-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/properties-tags.scmnew file mode 100644index 000000000..1d70c6a7f--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/properties-tags.scm@@ -0,0 +1,5 @@+(property+ (key) @name.definition.property) @definition.property++(substitution+ (key) @name.reference.property) @reference.propertydiff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/r-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/r-tags.scmnew file mode 100644index 000000000..5ffc72332--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/r-tags.scm@@ -0,0 +1,21 @@+(binary_operator+ lhs: (identifier) @name.definition.function+ operator: "<-"+ rhs: (function_definition)+) @definition.function++(binary_operator+ lhs: (identifier) @name.definition.function+ operator: "="+ rhs: (function_definition)+) @definition.function++(call+ function: (identifier) @name.reference.call+) @reference.call++(call+ function: (namespace_operator+ rhs: (identifier) @name.reference.call+ )+) @reference.calldiff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/racket-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/racket-tags.scmnew file mode 100644index 000000000..b3034026c--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/racket-tags.scm@@ -0,0 +1,12 @@+(list+ .+ (symbol) @reference._define+ (#match? @reference._define "^(define|define/contract)$")+ .+ (list+ .+ (symbol) @name.definition.function) @definition.function)++(list+ .+ (symbol) @name.reference.call)diff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/ruby-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/ruby-tags.scmnew file mode 100644index 000000000..79e71d2d6--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/ruby-tags.scm@@ -0,0 +1,64 @@+; Method definitions++(+ (comment)* @doc+ .+ [+ (method+ name: (_) @name.definition.method) @definition.method+ (singleton_method+ name: (_) @name.definition.method) @definition.method+ ]+ (#strip! @doc "^#\\s*")+ (#select-adjacent! @doc @definition.method)+)++(alias+ name: (_) @name.definition.method) @definition.method++(setter+ (identifier) @ignore)++; Class definitions++(+ (comment)* @doc+ .+ [+ (class+ name: [+ (constant) @name.definition.class+ (scope_resolution+ name: (_) @name.definition.class)+ ]) @definition.class+ (singleton_class+ value: [+ (constant) @name.definition.class+ (scope_resolution+ name: (_) @name.definition.class)+ ]) @definition.class+ ]+ (#strip! @doc "^#\\s*")+ (#select-adjacent! @doc @definition.class)+)++; Module definitions++(+ (module+ name: [+ (constant) @name.definition.module+ (scope_resolution+ name: (_) @name.definition.module)+ ]) @definition.module+)++; Calls++(call method: (identifier) @name.reference.call) @reference.call++(+ [(identifier) (constant)] @name.reference.call @reference.call+ (#is-not? local)+ (#not-match? @name.reference.call "^(lambda|load|require|require_relative|__FILE__|__LINE__)$")+)diff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/solidity-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/solidity-tags.scmnew file mode 100644index 000000000..d56bc19a0--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/solidity-tags.scm@@ -0,0 +1,43 @@+;; Method and Function declarations+(contract_declaration (_+ (function_definition+ name: (identifier) @name.definition.function) @definition.method))++(source_file+ (function_definition+ name: (identifier) @name.definition.function) @definition.function)++;; Contract, struct, enum and interface declarations+(contract_declaration+ name: (identifier) @name.definition.class) @definition.class++(interface_declaration+ name: (identifier) @name.definition.interface) @definition.interface++(library_declaration+ name: (identifier) @name.definition.class) @definition.interface++(struct_declaration name: (identifier) @name.definition.class) @definition.class+(enum_declaration name: (identifier) @name.definition.class) @definition.class+(event_definition name: (identifier) @name.definition.class) @definition.class++;; Function calls+(call_expression (expression (identifier)) @name.reference.call ) @reference.call++(call_expression+ (expression (member_expression+ property: (_) @name.reference.method ))) @reference.call++;; Log emit+(emit_statement name: (_) @name.reference.class) @reference.class+++;; Inheritance++(inheritance_specifier+ ancestor: (user_defined_type (_) @name.reference.class . )) @reference.class+++;; Imports ( note that unknown is not standardised )+(import_directive+ import_name: (_) @name.reference.module ) @reference.unknowndiff --git a/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/udev-tags.scm b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/udev-tags.scmnew file mode 100644index 000000000..a33e6924b--- /dev/null+++ b/openviking/parse/parsers/code/ast/queries/tree-sitter-language-pack/udev-tags.scm@@ -0,0 +1,16 @@+(assignment+ key: "LABEL"+ (value+ (content) @name.definition.label)) @definition.label++(assignment+ key: "GOTO"+ (value+ (content) @name.reference.label)) @reference.label++(match+ key: "ENV"+ (env_var) @name.reference.variable) @reference.variable++(var_sub+ (env_var) @name.reference.variable) @reference.variablediff --git a/openviking/parse/parsers/code/ast/skeleton.py b/openviking/parse/parsers/code/ast/skeleton.pydeleted file mode 100644index 260712482..000000000--- a/openviking/parse/parsers/code/ast/skeleton.py+++ /dev/null@@ -1,103 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""CodeSkeleton dataclasses and to_text() serialization."""--import re-from dataclasses import dataclass, field-from typing import List---def _compact_params(params: str) -> str:- """Collapse multi-line params into a single line."""- return re.sub(r"\s+", " ", params).strip().strip(",")---@dataclass-class FunctionSig:- name: str- params: str # raw parameter string, e.g. "source, instruction, **kwargs"- return_type: str # e.g. "ParseResult" or ""- docstring: str # first line only- line_start: int = 0 # 1-indexed, inclusive; 0 = unknown (back-compat)- line_end: int = 0 # 1-indexed, inclusive; 0 = unknown---@dataclass-class ClassSkeleton:- name: str- bases: List[str]- docstring: str- methods: List[FunctionSig] = field(default_factory=list)- line_start: int = 0- line_end: int = 0---@dataclass-class CodeSkeleton:- file_name: str- language: str- module_doc: str- imports: List[str] # flattened, e.g. ["asyncio", "os", "typing.Optional"]- classes: List[ClassSkeleton]- functions: List[FunctionSig] # top-level functions only-- def to_text(self, verbose: bool = False) -> str:- """Generate skeleton text.-- Args:- verbose: If True, include full docstrings (for ast_llm mode / LLM input).- If False, only keep the first line (for ast mode / direct embedding).- """-- def _doc(raw: str, indent: str) -> List[str]:- if not raw:- return []- first = raw.split("\n")[0].strip()- if not verbose:- return [f'{indent}"""{first}"""']- # verbose: keep full docstring, re-indent each line- doc_lines = raw.strip().split("\n")- if len(doc_lines) == 1:- return [f'{indent}"""{first}"""']- return (- [f'{indent}"""{doc_lines[0]}']- + [f"{indent}{l.strip()}" for l in doc_lines[1:]]- + [f'{indent}"""']- )-- lines: List[str] = []-- # Header- lines.append(f"# {self.file_name} [{self.language}]")-- # Module docstring — always single-line with "module:" label- if self.module_doc:- first = self.module_doc.split("\n")[0].strip()- lines.append(f'module: "{first}"')-- # Imports (compact)- if self.imports:- lines.append(f"imports: {', '.join(self.imports)}")-- lines.append("")-- # Classes- for cls in self.classes:- bases_str = f"({', '.join(cls.bases)})" if cls.bases else ""- lines.append(f"class {cls.name}{bases_str}")- lines.extend(_doc(cls.docstring, " "))- for method in cls.methods:- ret = f" -> {method.return_type}" if method.return_type else ""- params = _compact_params(method.params)- lines.append(f" + {method.name}({params}){ret}")- lines.extend(_doc(method.docstring, " "))- lines.append("")-- # Top-level functions- for fn in self.functions:- ret = f" -> {fn.return_type}" if fn.return_type else ""- params = _compact_params(fn.params)- lines.append(f"def {fn.name}({params}){ret}")- lines.extend(_doc(fn.docstring, " "))-- return "\n".join(lines).strip()diff --git a/openviking/parse/parsers/constants.py b/openviking/parse/parsers/constants.pyindex 603dee09e..16d34d53d 100644--- a/openviking/parse/parsers/constants.py+++ b/openviking/parse/parsers/constants.py@@ -104,6 +104,8 @@ CODE_EXTENSIONS = {".cpp",".cc",".c",+ ".cu",+ ".cuh",".h",".hpp",".inl",diff --git a/openviking/parse/parsers/markdown.py b/openviking/parse/parsers/markdown.pyindex 0fd486f19..e5cd615f8 100644--- a/openviking/parse/parsers/markdown.py+++ b/openviking/parse/parsers/markdown.py@@ -30,7 +30,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Unionfrom openviking.parse.accessors.mime_types import IANA_MEDIA_TYPE_TO_EXTENSIONfrom openviking.parse.base import NodeType, ParseResult, ResourceNode, create_parse_resultfrom openviking.parse.parsers.base_parser import BaseParser-from openviking.parse.parsers.code.ast.extractor import get_extractor+from openviking.parse.parsers.code.ast.providers import supports_code_skeletonfrom openviking.parse.parsers.constants import (CODE_EXTENSIONS,DOCUMENTATION_EXTENSIONS,@@ -368,11 +368,9 @@ class MarkdownParser(BaseParser):)doc_name = self._sanitize_for_path(doc_title)# Preserve code source filenames as the temp document directory.- # This yields foo.py/foo.md, allowing AST language detection to recover- # ".py" from the parent directory while keeping the markdown body name tidy.source_name = kwargs.get("source_name")root_name = (- source_name if source_name and get_extractor().supports(source_name) else doc_name+ source_name if source_name and supports_code_skeleton(source_name) else doc_name)root_dir = f"{temp_uri}/{self._sanitize_for_path(root_name)}"diff --git a/openviking/parse/parsers/upload_utils.py b/openviking/parse/parsers/upload_utils.pyindex 8211d3a3f..2f3f7080f 100644--- a/openviking/parse/parsers/upload_utils.py+++ b/openviking/parse/parsers/upload_utils.py@@ -49,11 +49,16 @@ def is_text_file(file_path: Union[str, Path]) -> bool:p = Path(file_path)extension = p.suffix.lower()if extension:- return (+ if (extension in CODE_EXTENSIONSor extension in DOCUMENTATION_EXTENSIONSor extension in ADDITIONAL_TEXT_EXTENSIONS- )+ ):+ return True++ from openviking.parse.parsers.code.ast.providers import supports_code_skeleton++ return supports_code_skeleton(str(p))# Extensionless files: check against known text file names (case-insensitive).return p.name.upper() in _EXTENSIONLESS_TEXT_NAMESdiff --git a/openviking/prompts/templates/semantic/code_ast_summary.yaml b/openviking/prompts/templates/semantic/code_ast_summary.yamldeleted file mode 100644index c84757136..000000000--- a/openviking/prompts/templates/semantic/code_ast_summary.yaml+++ /dev/null@@ -1,45 +0,0 @@-metadata:- id: "semantic.code_ast_summary"- name: "Code AST Skeleton Summary Generation"- description: "Generate summary for code files from AST-extracted skeleton (ast_llm mode). Input is compact structural skeleton rather than full source."- version: "1.0.0"- language: "en"- category: "semantic"--variables:- - name: "file_name"- type: "string"- description: "File name with extension"- required: true-- - name: "skeleton"- type: "string"- description: "AST-extracted code skeleton (classes, functions, imports)"- required: true-- - name: "output_language"- type: "string"- description: "Language code for output (e.g., 'en', 'zh-CN', 'ja', 'ko', 'ru', 'ar')"- required: true--template: |- Output Language: {{ output_language }}-- You are a code analysis expert. Based on the structural skeleton below,- generate a concise summary (80-200 words) focusing on purpose, key components,- and relationships. The skeleton was extracted via AST parsing.-- 【File Name】{{ file_name }}- 【Code Structure】- {{ skeleton }}-- Output requirements:- - Length: 80-200 words- - Focus on the main purpose and functionality inferred from the structure- - Highlight key classes, functions, and their relationships- - Note important dependencies shown in imports- - Include relevant technical keywords for semantic search- - Output plain text directly, no markdown format--llm_config:- temperature: 0.0diff --git a/openviking/server/app.py b/openviking/server/app.pyindex 08fbb64be..6310aacb3 100644--- a/openviking/server/app.py+++ b/openviking/server/app.py@@ -32,7 +32,6 @@ from openviking.server.request_id import REQUEST_ID_HEADER, RequestIdMiddlewarefrom openviking.server.routers import (admin_router,bot_router,- code_router,console_router,content_router,debug_router,@@ -578,7 +577,6 @@ def create_app(app.include_router(content_router)app.include_router(console_router)app.include_router(search_router)- app.include_router(code_router)app.include_router(relations_router)app.include_router(privacy_configs_router)app.include_router(skills_router)diff --git a/openviking/server/mcp_endpoint.py b/openviking/server/mcp_endpoint.pyindex ac59ea596..352f39e8c 100644--- a/openviking/server/mcp_endpoint.py+++ b/openviking/server/mcp_endpoint.py@@ -3,8 +3,7 @@"""MCP (Model Context Protocol) endpoint for OpenViking server.Exposes tools to Claude Code (or any MCP client) via streamable HTTP:- find, search, read, list, remember, add_resource, grep, glob,- code_outline, code_search, code_expand, forget, health+ find, search, read, list, remember, add_resource, grep, glob, forget, healthMounted on the FastAPI app at /mcp. The MCP session manager lifecycle istied to the FastAPI app lifespan (not a sub-app lifespan) so the task group@@ -31,13 +30,6 @@ from starlette.requests import Requestfrom starlette.responses import JSONResponsefrom starlette.types import ASGIApp, Receive, Scope, Send-from openviking.parse.parsers.code.ast.code_tools import (- CODE_SEARCH_CONCURRENCY,- expand_symbol,- filter_code_uris,- outline_file,- search_symbols,-)from openviking.resource.processing_mode import DEFAULT_PROCESSING_MODE, ProcessingModefrom openviking.retrieve.type_quota_recall import (DEFAULT_MAX_CHARS,@@ -65,9 +57,6 @@ from openviking_cli.exceptions import (from openviking_cli.session.user_id import UserIdentifierfrom openviking_cli.utils import get_logger-# Backwards-compatible alias for existing tests that import this private name.-_filter_code_uris = filter_code_uris-logger = get_logger(__name__)# ---------------------------------------------------------------------------@@ -931,97 +920,6 @@ async def forget(uri: str, recursive: bool = False) -> str:return f"Deleted: {uri}"-# -- code navigation ----------------------------------------------------------def _require_viking_uri(uri: str) -> Optional[str]:- """Return error message if uri is not a viking:// URI, else None."""- if not isinstance(uri, str) or not uri.startswith("viking://"):- return (- "Error: only viking:// URIs are supported; "- "use add_resource to ingest local code as a viking:// resource first."- )- return None---async def code_outline(uri: str) -> str:- """Show symbol structure (classes, functions, methods, line ranges) of a viking:// source file without reading full content."""- err = _require_viking_uri(uri)- if err:- return err- service = get_service()- ctx = _get_ctx()- try:- content = await service.fs.read(uri, ctx=ctx)- except Exception as exc:- return f"Error: failed to read {uri}: {exc}"- if not isinstance(content, str):- return f"Error: {uri} is not text"- return outline_file(content, uri)---async def code_search(query: str, uri: str) -> str:- """Search symbol names (class/function/method) by substring across a viking:// code repository. Returns symbol type, class context, file URI, and line range. Scans up to 200 source files — narrow uri for deeper coverage."""- err = _require_viking_uri(uri)- if err:- return err- if not query:- return "Error: empty query"-- service = get_service()- ctx = _get_ctx()- try:- entries = await service.fs.ls(uri, ctx=ctx, recursive=True, output="original")- except Exception as exc:- return f"Error: failed to list {uri}: {exc}"-- code_uris, capped = filter_code_uris(entries or [])- if not code_uris:- return f"No supported source files found under {uri}"-- semaphore = asyncio.Semaphore(CODE_SEARCH_CONCURRENCY)-- async def _read(u: str) -> Optional[tuple[str, str]]:- async with semaphore:- try:- body = await service.fs.read(u, ctx=ctx)- except Exception as exc:- logger.warning("code_search: read failed for %s: %s", u, exc)- return None- if isinstance(body, str):- return body, u- return None-- fetched = await asyncio.gather(*[_read(u) for u in code_uris])- files = [pair for pair in fetched if pair is not None]- result = search_symbols(query, files)- if capped:- result += "\n\n(scanning stopped at 200-file cap; narrow uri to search more)"- return result---async def code_expand(uri: str, symbol: str) -> str:- """Return the full source of a single named symbol from a viking:// source file. symbol accepts 'bar' (top-level) or 'Foo.bar' (method)."""- err = _require_viking_uri(uri)- if err:- return err- if not symbol:- return "Error: empty symbol"-- service = get_service()- ctx = _get_ctx()- try:- content = await service.fs.read(uri, ctx=ctx)- except Exception as exc:- return f"Error: failed to read {uri}: {exc}"- if not isinstance(content, str):- return f"Error: {uri} is not text"- return expand_symbol(content, uri, symbol)--# -- health ----------------------------------------------------------------@@ -1133,9 +1031,8 @@ async def mcp_lifespan():"""Run the MCP session manager. Call this inside the FastAPI lifespan."""async with mcp.session_manager.run():logger.info(- "MCP endpoint ready (16 tools: find, search, recall, read, list, remember, "- "add_resource, list_watches, cancel_watch, grep, glob, forget, code_outline, "- "code_search, code_expand, health)"+ "MCP endpoint ready (13 tools: find, search, recall, read, list, remember, "+ "add_resource, list_watches, cancel_watch, grep, glob, forget, health)")yielddiff --git a/openviking/server/routers/__init__.py b/openviking/server/routers/__init__.pyindex cd307fe3e..3c0a519e3 100644--- a/openviking/server/routers/__init__.py+++ b/openviking/server/routers/__init__.py@@ -4,7 +4,6 @@from openviking.server.routers.admin import router as admin_routerfrom openviking.server.routers.bot import router as bot_router-from openviking.server.routers.code import router as code_routerfrom openviking.server.routers.console import router as console_routerfrom openviking.server.routers.content import router as content_routerfrom openviking.server.routers.debug import router as debug_router@@ -30,7 +29,6 @@ from openviking.server.routers.webdav import router as webdav_router__all__ = ["admin_router","bot_router",- "code_router","system_router","resources_router","filesystem_router",diff --git a/openviking/server/routers/code.py b/openviking/server/routers/code.pydeleted file mode 100644index a0e228d03..000000000--- a/openviking/server/routers/code.py+++ /dev/null@@ -1,127 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""Code navigation endpoints for OpenViking HTTP Server."""--import asyncio--from fastapi import APIRouter, Depends-from pydantic import BaseModel--from openviking.parse.parsers.code.ast.code_tools import (- CODE_SEARCH_CONCURRENCY,- expand_symbol,- filter_code_uris,- outline_file,- search_symbols,-)-from openviking.server.auth import get_request_context-from openviking.server.dependencies import get_service-from openviking.server.identity import RequestContext-from openviking.server.models import Response-from openviking_cli.utils import get_logger--logger = get_logger(__name__)--router = APIRouter(prefix="/api/v1/code", tags=["code"])--_ERROR_NOT_VIKING = (- "Error: only viking:// URIs are supported; "- "use add_resource to ingest local code as a viking:// resource first."-)---class CodeOutlineRequest(BaseModel):- uri: str---class CodeSearchRequest(BaseModel):- uri: str- query: str---class CodeExpandRequest(BaseModel):- uri: str- symbol: str--[email protected]("/outline")-async def code_outline_endpoint(- request: CodeOutlineRequest,- _ctx: RequestContext = Depends(get_request_context),-):- if not request.uri.startswith("viking://"):- return Response(status="ok", result=_ERROR_NOT_VIKING).model_dump(exclude_none=True)- service = get_service()- content = await service.fs.read(request.uri, ctx=_ctx)- if not isinstance(content, str):- return Response(status="ok", result=f"Error: {request.uri} is not text").model_dump(- exclude_none=True- )- return Response(status="ok", result=outline_file(content, request.uri)).model_dump(- exclude_none=True- )--[email protected]("/search")-async def code_search_endpoint(- request: CodeSearchRequest,- _ctx: RequestContext = Depends(get_request_context),-):- if not request.uri.startswith("viking://"):- return Response(status="ok", result=_ERROR_NOT_VIKING).model_dump(exclude_none=True)- if not request.query:- return Response(status="ok", result="Error: empty query").model_dump(exclude_none=True)- service = get_service()- entries = await service.fs.ls(request.uri, ctx=_ctx, recursive=True, output="original")- code_uris, capped = filter_code_uris(entries or [])- if not code_uris:- return Response(- status="ok",- result=f"No supported source files found under {request.uri}",- ).model_dump(exclude_none=True)-- semaphore = asyncio.Semaphore(CODE_SEARCH_CONCURRENCY)-- async def _read_one(uri: str):- async with semaphore:- try:- body = await service.fs.read(uri, ctx=_ctx)- except Exception as exc:- logger.warning("code_search: read failed for %s: %s", uri, exc)- return None, uri- return ((body, uri) if isinstance(body, str) else None), uri-- fetched = await asyncio.gather(*[_read_one(u) for u in code_uris])- files = [pair for pair, _uri in fetched if pair is not None]- failed_reads = len(fetched) - len(files)- if failed_reads == len(code_uris):- return Response(- status="ok",- result=f"Error: failed to read all {len(code_uris)} source files under {request.uri}",- ).model_dump(exclude_none=True)- result = search_symbols(request.query, files)- if failed_reads:- result += f"\n\n(warning: skipped {failed_reads} unreadable source file(s))"- if capped:- result += "\n\n(scanning stopped at 200-file cap; narrow uri to search more)"- return Response(status="ok", result=result).model_dump(exclude_none=True)--[email protected]("/expand")-async def code_expand_endpoint(- request: CodeExpandRequest,- _ctx: RequestContext = Depends(get_request_context),-):- if not request.uri.startswith("viking://"):- return Response(status="ok", result=_ERROR_NOT_VIKING).model_dump(exclude_none=True)- if not request.symbol:- return Response(status="ok", result="Error: empty symbol").model_dump(exclude_none=True)- service = get_service()- content = await service.fs.read(request.uri, ctx=_ctx)- if not isinstance(content, str):- return Response(status="ok", result=f"Error: {request.uri} is not text").model_dump(- exclude_none=True- )- return Response(- status="ok", result=expand_symbol(content, request.uri, request.symbol)- ).model_dump(exclude_none=True)diff --git a/openviking/storage/queuefs/semantic_processor.py b/openviking/storage/queuefs/semantic_processor.pyindex 467c1407d..7f0a03de3 100644--- a/openviking/storage/queuefs/semantic_processor.py+++ b/openviking/storage/queuefs/semantic_processor.py@@ -179,7 +179,7 @@ class SemanticProcessor(DequeueHandlerBase):def _detect_file_type(self, file_name: str) -> str:"""- Detect file type based on extension using constants from code parser.+ Detect file type for summary prompt selection.Args:file_name: File name with extension@@ -189,16 +189,22 @@ class SemanticProcessor(DequeueHandlerBase):"""file_name_lower = file_name.lower()- # Check if file is a code file- for ext in CODE_EXTENSIONS:- if file_name_lower.endswith(ext):- return FILE_TYPE_CODE-- # Check if file is a documentation file+ # Documentation prompts should win over broad code skeleton recognition.for ext in DOCUMENTATION_EXTENSIONS:if file_name_lower.endswith(ext):return FILE_TYPE_DOCUMENTATION+ from openviking.parse.parsers.code.ast.providers import supports_code_skeleton++ if supports_code_skeleton(file_name):+ return FILE_TYPE_CODE++ # Keep legacy extension-based routing for code-like text formats not+ # covered by tags queries or tree-sitter-language-pack.+ for ext in CODE_EXTENSIONS:+ if file_name_lower.endswith(ext):+ return FILE_TYPE_CODE+# Default to otherreturn FILE_TYPE_OTHER@@ -1076,56 +1082,39 @@ class SemanticProcessor(DequeueHandlerBase):def result(summary: str) -> Dict[str, Any]:return {"name": file_name, "summary": summary, "content": full_content}+ config = get_openviking_config()+# Limit content length- max_chars = get_openviking_config().semantic.max_file_content_chars+ max_chars = config.semantic.max_file_content_charsif len(content) > max_chars:content = content[:max_chars] + "\n...(truncated)"- # Generate summary- if not vlm.is_available():- logger.warning("VLM not available, using empty summary")- return result("")-- from openviking.session.memory.utils.language import resolve_output_language-- output_language = resolve_output_language(content)-# Detect file type and select appropriate promptfile_type = self._detect_file_type(file_name)if file_type == FILE_TYPE_CODE:- code_mode = get_openviking_config().code.code_summary_mode-- if code_mode in ("ast", "ast_llm") and len(content.splitlines()) >= 100:- from openviking.parse.parsers.code.ast import extract_skeleton-- verbose = code_mode == "ast_llm"- skeleton_text = extract_skeleton(file_name, content, verbose=verbose)- if skeleton_text:- max_skeleton_chars = get_openviking_config().semantic.max_skeleton_chars- if len(skeleton_text) > max_skeleton_chars:- skeleton_text = skeleton_text[:max_skeleton_chars]- if code_mode == "ast":- return result(skeleton_text)- else: # ast_llm- prompt = render_prompt(- "semantic.code_ast_summary",- {- "file_name": file_name,- "skeleton": skeleton_text,- "output_language": output_language,- },- )- async with llm_sem:- with bind_telemetry_stage("resource_summarize"):- summary = await vlm.get_completion_async(prompt)- return result(summary.strip())- if skeleton_text is None:- logger.info("AST unsupported language, fallback to LLM: %s", file_path)- else:- logger.info("AST empty skeleton, fallback to LLM: %s", file_path)+ from openviking.parse.parsers.code.ast import extract_skeleton_result++ extraction = extract_skeleton_result(file_name, content)+ if extraction.text:+ skeleton_text = extraction.text+ max_skeleton_chars = config.semantic.max_skeleton_chars+ if len(skeleton_text) > max_skeleton_chars:+ skeleton_text = skeleton_text[:max_skeleton_chars]+ return result(skeleton_text)+ logger.info(+ "Code skeleton fallback to LLM for '%s': %s",+ file_path,+ extraction.reason,+ )++ if not vlm.is_available():+ logger.warning("VLM not available for code summary fallback: %s", file_path)+ return result("")- # "llm" mode or fallback when skeleton is None/empty+ from openviking.session.memory.utils.language import resolve_output_language++ output_language = resolve_output_language(content, config=config)prompt = render_prompt("semantic.code_summary",{"file_name": file_name, "content": content, "output_language": output_language},@@ -1135,7 +1124,14 @@ class SemanticProcessor(DequeueHandlerBase):summary = await vlm.get_completion_async(prompt)return result(summary.strip())- elif file_type == FILE_TYPE_DOCUMENTATION:+ if not vlm.is_available():+ logger.warning("VLM not available, using empty summary")+ return result("")++ from openviking.session.memory.utils.language import resolve_output_language++ output_language = resolve_output_language(content, config=config)+ if file_type == FILE_TYPE_DOCUMENTATION:prompt_id = "semantic.document_summary"else:prompt_id = "semantic.file_summary"diff --git a/openviking/utils/embedding_utils.py b/openviking/utils/embedding_utils.pyindex 9618d195c..4d3beb1c4 100644--- a/openviking/utils/embedding_utils.py+++ b/openviking/utils/embedding_utils.py@@ -175,6 +175,8 @@ def get_resource_content_type(file_name: str) -> Optional[ResourceContentType]:".java",".cpp",".c",+ ".cu",+ ".cuh",".h",".go",".rs",diff --git a/openviking_cli/utils/config/parser_config.py b/openviking_cli/utils/config/parser_config.pyindex 597144f3d..e7dfe3e10 100644--- a/openviking_cli/utils/config/parser_config.py+++ b/openviking_cli/utils/config/parser_config.py@@ -12,8 +12,12 @@ from dataclasses import dataclass, replacefrom pathlib import Pathfrom typing import Any, Dict, Iterable, Optional, Union+from openviking_cli.utils.logger import get_logger+from .config_utils import raise_unknown_config_fields+logger = get_logger(__name__)+@dataclassclass ParserConfig:@@ -245,20 +249,18 @@ class CodeConfig(CodeHostingConfig):Configuration for code parsing.Attributes:- code_summary_mode: Summary generation mode ("llm" | "ast" | "ast_llm")- extract_functions: Whether to extract function definitions- extract_classes: Whether to extract class definitions- extract_imports: Whether to extract import statements- include_comments: Whether to include comments in L1/L2- max_line_length: Maximum line length before splitting- language_hint: Optional language hint (auto-detected if None)- max_token_limit: Maximum tokens to process per file- truncation_strategy: "head", "tail", or "balanced"- warn_on_truncation: Whether to warn when truncation occurs+ extract_functions: Legacy compatibility field; ignored by the fixed skeleton route+ extract_classes: Legacy compatibility field; ignored by the fixed skeleton route+ extract_imports: Legacy compatibility field; ignored by the fixed skeleton route+ include_comments: Legacy compatibility field; ignored by the fixed skeleton route+ max_line_length: Legacy compatibility field; ignored by the fixed skeleton route+ language_hint: Legacy compatibility field; ignored by the fixed skeleton route+ max_token_limit: Legacy compatibility field; ignored by the fixed skeleton route+ truncation_strategy: Legacy compatibility field; ignored by the fixed skeleton route+ warn_on_truncation: Legacy compatibility field; ignored by the fixed skeleton routegithub_raw_domain: Domain for GitHub raw content (raw.githubusercontent.com)"""- code_summary_mode: str = "ast" # "llm" | "ast" | "ast_llm"extract_functions: bool = Trueextract_classes: bool = Trueextract_imports: bool = True@@ -270,6 +272,22 @@ class CodeConfig(CodeHostingConfig):warn_on_truncation: bool = Truegithub_raw_domain: str = "raw.githubusercontent.com"+ @classmethod+ def from_dict(cls, data: Dict[str, Any]) -> "CodeConfig":+ """Create code configuration, accepting removed fields for upgrade compatibility."""++ data = dict(data)+ if "code_summary_mode" in data:+ data.pop("code_summary_mode", None)+ logger.warning(+ "code.code_summary_mode is deprecated and ignored; "+ "code summaries now always use the fixed skeleton route with LLM fallback"+ )++ valid_fields = {f.name for f in cls.__dataclass_fields__.values()}+ raise_unknown_config_fields(data=data, valid_fields=valid_fields, context_name=cls.__name__)+ return cls(**data)+def validate(self) -> None:"""Validate configuration.@@ -281,12 +299,6 @@ class CodeConfig(CodeHostingConfig):super().validate()# Validate code-specific fields- if self.code_summary_mode not in ("llm", "ast", "ast_llm"):- raise ValueError(- f"Invalid code_summary_mode '{self.code_summary_mode}'. "- "Must be 'llm', 'ast', or 'ast_llm'"- )-if self.max_line_length <= 0:raise ValueError("max_line_length must be positive")@@ -728,7 +740,7 @@ class SemanticConfig:"""Maximum characters of file content sent to LLM for summary generation."""max_skeleton_chars: int = 12000- """Maximum characters of AST skeleton used for embedding (~3000 tokens)."""+ """Maximum characters of code skeleton used for embedding (~3000 tokens)."""max_overview_prompt_chars: int = 60000"""Maximum characters allowed in the overview generation prompt.@@ -798,8 +810,7 @@ def get_parser_config(>>> # Get custom code configuration>>> code_config = get_parser_config("code", {- ... "enable_ast": False,- ... "max_token_limit": 10000+ ... "github_raw_domain": "raw.githubusercontent.com"... })"""if parser_type not in PARSER_CONFIG_REGISTRY:@@ -827,7 +838,7 @@ def load_parser_configs_from_dict(config_dict: Dict[str, Any]) -> Dict[str, ParsExamples:>>> configs = load_parser_configs_from_dict({... "pdf": {"strategy": "auto"},- ... "code": {"enable_ast": false}+ ... "code": {"github_raw_domain": "raw.githubusercontent.com"}... })>>> pdf_config = configs["pdf"]>>> code_config = configs["code"]diff --git a/pyproject.toml b/pyproject.tomlindex 680410e26..b6645691f 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -87,6 +87,8 @@ dependencies = ["lark-oapi>=1.5.3","mcp>=1.27,<2","pathspec>=1.1.1",+ "grep-ast>=0.9.0",+ "tree-sitter-language-pack>=1.12,<2.0",]diff --git a/tests/api_test/tools/tests/test_logger_usage_regression.py b/tests/api_test/tools/tests/test_logger_usage_regression.pyindex 332f5493c..90c31cece 100644--- a/tests/api_test/tools/tests/test_logger_usage_regression.py+++ b/tests/api_test/tools/tests/test_logger_usage_regression.py@@ -22,7 +22,7 @@ def test_runtime_modules_use_unified_get_logger():"openviking/parse/tree_builder.py","openviking/parse/accessors/registry.py","openviking/parse/parsers/pdf.py",- "openviking/parse/parsers/code/ast/extractor.py",+ "openviking/parse/parsers/code/ast/providers.py","openviking/models/rerank/base.py","openviking/models/rerank/volcengine_rerank.py","openviking/models/rerank/openai_rerank.py",diff --git a/tests/mcp_benchmark/server.py b/tests/mcp_benchmark/server.pydeleted file mode 100644index 1eee86883..000000000--- a/tests/mcp_benchmark/server.py+++ /dev/null@@ -1,228 +0,0 @@-"""Minimal stdio MCP server that exposes the 3 new code-navigation tools-backed by the *actual* code_tools / extractor modules from the OpenViking-repo. Stubs the heavy openviking dependencies (pyagfs, etc.) and maps-viking:// URIs to local disk so we can drive an end-to-end MCP test-without building the full openviking stack.--URI scheme:- viking://local/<ABSOLUTE-PATH> -> /<ABSOLUTE-PATH> on local disk--This is *only* for the end-to-end MCP verification. Production runs through-openviking.server.mcp_endpoint with the real VikingFS.-"""-from __future__ import annotations--import asyncio-import importlib.util-import logging-import os-import sys-import types-from pathlib import Path-from typing import Optional--ROOT = Path(__file__).parent.parent.parent--# Stub openviking_cli.utils.get_logger so extractor.py imports cleanly.-ovc = types.ModuleType("openviking_cli")-ovc_utils = types.ModuleType("openviking_cli.utils")-ovc_utils.get_logger = lambda name: logging.getLogger(name)-sys.modules["openviking_cli"] = ovc-sys.modules["openviking_cli.utils"] = ovc_utils--for pkg in (- "openviking",- "openviking.parse",- "openviking.parse.parsers",- "openviking.parse.parsers.code",- "openviking.parse.parsers.code.ast",- "openviking.parse.parsers.code.ast.languages",-):- m = types.ModuleType(pkg)- m.__path__ = []- sys.modules[pkg] = m---def _load(name: str, rel: str):- spec = importlib.util.spec_from_file_location(name, ROOT / rel)- mod = importlib.util.module_from_spec(spec)- sys.modules[name] = mod- spec.loader.exec_module(mod)- return mod---_load("openviking.parse.parsers.code.ast.skeleton",- "openviking/parse/parsers/code/ast/skeleton.py")-_load("openviking.parse.parsers.code.ast.languages.base",- "openviking/parse/parsers/code/ast/languages/base.py")-_load("openviking.parse.parsers.code.ast.languages.python",- "openviking/parse/parsers/code/ast/languages/python.py")-_load("openviking.parse.parsers.code.ast.extractor",- "openviking/parse/parsers/code/ast/extractor.py")-_load("openviking.parse.parsers.code.ast.code_tools",- "openviking/parse/parsers/code/ast/code_tools.py")--from openviking.parse.parsers.code.ast.code_tools import ( # noqa: E402- expand_symbol,- outline_file,- search_symbols,-)-from openviking.parse.parsers.code.ast.extractor import get_extractor # noqa: E402--from mcp.server.fastmcp import FastMCP # noqa: E402--logger = logging.getLogger("openviking_mcp_test")--mcp = FastMCP("openviking-code-tools-test")--_VIKING_PREFIX = "viking://local"-_CODE_SEARCH_FILE_CAP = 200-_CODE_SEARCH_CONCURRENCY = 10---def _uri_to_path(uri: str) -> Optional[Path]:- """Map viking://local/<abs-path> -> Path('<abs-path>'). None on bad URI."""- if not isinstance(uri, str) or not uri.startswith(_VIKING_PREFIX):- return None- rest = uri[len(_VIKING_PREFIX):]- if not rest.startswith("/"):- return None- return Path(rest)---def _require_viking_uri(uri: str) -> Optional[str]:- if not isinstance(uri, str) or not uri.startswith("viking://"):- return (- "Error: only viking:// URIs are supported; "- "use add_resource to ingest local code as a viking:// resource first."- )- return None---async def _read_text(uri: str) -> tuple[Optional[str], Optional[str]]:- """Returns (content, error_msg). Content is None iff error_msg is set."""- path = _uri_to_path(uri)- if path is None:- return None, f"Error: {uri} is not a viking://local URI in this test server"- try:- return await asyncio.to_thread(path.read_text, encoding="utf-8"), None- except FileNotFoundError as exc:- return None, f"Error: failed to read {uri}: {exc}"- except UnicodeDecodeError:- return None, f"Error: {uri} is not text"- except Exception as exc:- return None, f"Error: failed to read {uri}: {exc}"---async def _walk(uri: str) -> tuple[Optional[list[str]], Optional[str]]:- """Recursively list viking:// URIs under a directory. Returns (uris, error)."""- root = _uri_to_path(uri)- if root is None or not root.is_dir():- return None, f"Error: failed to list {uri}: not a directory"- found: list[str] = []- try:- def _scan() -> list[str]:- out: list[str] = []- for p in root.rglob("*"):- if p.is_file():- out.append(f"{_VIKING_PREFIX}{p}")- return out- found = await asyncio.to_thread(_scan)- return found, None- except Exception as exc:- return None, f"Error: failed to list {uri}: {exc}"---async def code_outline(uri: str) -> str:- """Show a file's symbol structure — classes, functions, methods, and their line ranges.- Returns a structural map without reading implementation bodies.-- Use to survey a file before deciding what to read. More efficient than reading the whole- file when you only need to locate a method or understand a file's API surface.- Typical workflow: code_search → code_outline → code_expand.-- uri must be a viking://local file URI in this test server."""- err = _require_viking_uri(uri)- if err:- return err- content, err = await _read_text(uri)- if err:- return err- return outline_file(content, uri)---async def code_search(query: str, uri: str) -> str:- """Search symbol names (class / function / method) by substring across a viking://local directory.- Returns structured results: symbol type, class context, file URI, and line range.-- Use when you don't know which file contains the symbol you're looking for. Returns- structural context (class ownership, location) that raw text search does not provide.-- Skip if you already know the exact file; use code_outline or Read directly.-- Scans up to 200 source files. Narrow uri to a subdirectory for deeper coverage."""- err = _require_viking_uri(uri)- if err:- return err- if not query:- return "Error: empty query"-- all_uris, err = await _walk(uri)- if err:- return err-- extractor = get_extractor()- code_uris: list[str] = []- for u in all_uris or []:- if extractor.supports(u):- code_uris.append(u)- if len(code_uris) >= _CODE_SEARCH_FILE_CAP:- break-- if not code_uris:- return f"No supported source files found under {uri}"-- capped = len(code_uris) >= _CODE_SEARCH_FILE_CAP- sem = asyncio.Semaphore(_CODE_SEARCH_CONCURRENCY)-- async def _fetch(u: str):- async with sem:- body, ferr = await _read_text(u)- if ferr:- logger.warning("code_search: %s", ferr)- return None- return body, u-- fetched = await asyncio.gather(*[_fetch(u) for u in code_uris])- files = [pair for pair in fetched if pair is not None]- result = search_symbols(query, files)- if capped:- result += "\n\n(scanning stopped at 200-file cap; narrow uri to search more)"- return result---async def code_expand(uri: str, symbol: str) -> str:- """Return the full source of a single named symbol (function, class, or method).- Reads only that symbol's body, avoiding the overhead of reading an entire file.-- Use when you need the implementation of one specific symbol. For reading multiple- symbols from the same file, Read is often more efficient.-- `symbol` accepts 'bar' (top-level) or 'Foo.bar' (method).- uri must be a viking://local file URI in this test server."""- err = _require_viking_uri(uri)- if err:- return err- if not symbol:- return "Error: empty symbol"- content, err = await _read_text(uri)- if err:- return err- return expand_symbol(content, uri, symbol)---if __name__ == "__main__":- mcp.run()diff --git a/tests/parse/run_code_tests.py b/tests/parse/run_code_tests.pydeleted file mode 100644index 091ef69a8..000000000--- a/tests/parse/run_code_tests.py+++ /dev/null@@ -1,62 +0,0 @@-#!/usr/bin/env python3-"""Run tests/parse/test_code_tools.py without the full openviking dependency stack.--Uses the same stub-then-load pattern as tests/mcp_benchmark/server.py.-"""-import importlib.util-import logging-import sys-import types-from pathlib import Path--ROOT = Path(__file__).parent.parent.parent--# Stub openviking_cli so extractor.py imports cleanly.-ovc = types.ModuleType("openviking_cli")-ovc_utils = types.ModuleType("openviking_cli.utils")-ovc_utils.get_logger = lambda name: logging.getLogger(name)-sys.modules["openviking_cli"] = ovc-sys.modules["openviking_cli.utils"] = ovc_utils--# Stub the openviking package hierarchy so __init__.py files are skipped.-for pkg in (- "openviking",- "openviking.parse",- "openviking.parse.parsers",- "openviking.parse.parsers.code",- "openviking.parse.parsers.code.ast",- "openviking.parse.parsers.code.ast.languages",-):- m = types.ModuleType(pkg)- m.__path__ = [str(ROOT / pkg.replace(".", "/"))]- sys.modules[pkg] = m---def _load(name: str, rel: str):- spec = importlib.util.spec_from_file_location(name, ROOT / rel)- mod = importlib.util.module_from_spec(spec)- sys.modules[name] = mod- spec.loader.exec_module(mod)- return mod---_load("openviking.parse.parsers.code.ast.skeleton",- "openviking/parse/parsers/code/ast/skeleton.py")-_load("openviking.parse.parsers.code.ast.languages.base",- "openviking/parse/parsers/code/ast/languages/base.py")-for lang in ("python", "js_ts", "go", "rust", "java", "cpp", "csharp", "php", "lua"):- _load(f"openviking.parse.parsers.code.ast.languages.{lang}",- f"openviking/parse/parsers/code/ast/languages/{lang}.py")-_load("openviking.parse.parsers.code.ast.extractor",- "openviking/parse/parsers/code/ast/extractor.py")-_load("openviking.parse.parsers.code.ast.code_tools",- "openviking/parse/parsers/code/ast/code_tools.py")--if __name__ == "__main__":- import pytest- sys.exit(pytest.main([- str(Path(__file__).parent / "test_code_tools.py"),- "--noconftest",- "-o", "addopts=",- "-v",- ] + sys.argv[1:]))diff --git a/tests/parse/test_ast_extractor.py b/tests/parse/test_ast_extractor.pyindex 5c2f132d2..0a9465ffd 100644--- a/tests/parse/test_ast_extractor.py+++ b/tests/parse/test_ast_extractor.py@@ -1,1454 +1,288 @@# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""Tests for AST-based code skeleton extraction."""+# SPDX-License-Identifier: Apache-2.0-from openviking.parse.parsers.code.ast.skeleton import ClassSkeleton, CodeSkeleton, FunctionSig+from unittest.mock import Mock-# ----------------------------------------------------------------------------# Helpers-# ---------------------------------------------------------------------------+import pytest--def _python_extractor():- from openviking.parse.parsers.code.ast.languages.python import PythonExtractor-- return PythonExtractor()---def _js_extractor():- from openviking.parse.parsers.code.ast.languages.js_ts import JsTsExtractor-- return JsTsExtractor(lang="javascript")---def _go_extractor():- from openviking.parse.parsers.code.ast.languages.go import GoExtractor-- return GoExtractor()---def _ts_extractor():- from openviking.parse.parsers.code.ast.languages.js_ts import JsTsExtractor-- return JsTsExtractor(lang="typescript")---def _csharp_extractor():- from openviking.parse.parsers.code.ast.languages.csharp import CSharpExtractor-- return CSharpExtractor()---def _php_extractor():- from openviking.parse.parsers.code.ast.languages.php import PhpExtractor-- return PhpExtractor()---# ----------------------------------------------------------------------------# Python-# ------------------------------------------------------------------------------class TestPythonExtractor:- SAMPLE = '''"""Module for parsing things.--This module provides utilities for parsing text content.-"""--import os-import sys-from typing import List---class MyParser:- """A generic parser for text content.-- Handles both sync and async parsing flows.- """-- def parse(self, source: str) -> List[str]:- """Parse the source text.-- Args:- source: The text to parse.-- Returns:- List of parsed lines.- """- pass-- async def parse_async(- self,- source: str,- encoding: str = "utf-8",- ) -> List[str]:- """Parse the source asynchronously.-- Args:- source: The text to parse.- encoding: The text encoding.-- Returns:- List of parsed lines.- """- pass-- def _helper(self, text: str) -> str:- """Internal helper method."""- pass---def standalone(text: str) -> str:- """A standalone utility function."""- pass-'''-- def setup_method(self):- self.e = _python_extractor()-- def test_module_doc(self):- sk = self.e.extract("test.py\n\n", self.SAMPLE)- assert "Module for parsing things" in sk.module_doc-- def test_imports(self):- sk = self.e.extract("test.py", self.SAMPLE)- assert "os" in sk.imports- assert "sys" in sk.imports- assert any("List" in i for i in sk.imports)-- def test_class_extracted(self):- sk = self.e.extract("test.py", self.SAMPLE)- assert len(sk.classes) == 1- cls = sk.classes[0]- assert cls.name == "MyParser"- assert "generic parser" in cls.docstring-- def test_methods_extracted(self):- sk = self.e.extract("test.py", self.SAMPLE)- methods = {m.name: m for m in sk.classes[0].methods}- assert "parse" in methods- assert methods["parse"].return_type == "List[str]"- assert "parse_async" in methods- assert "_helper" in methods-- def test_multiline_params(self):- sk = self.e.extract("test.py", self.SAMPLE)- methods = {m.name: m for m in sk.classes[0].methods}- # raw params may contain newlines, but to_text() must compact them- assert "encoding" in methods["parse_async"].params- text = sk.to_text()- assert (- "\n +" not in text.split("parse_async")[1].split("\n")[0]- ) # no newline inside the signature line-- def test_top_level_function(self):- sk = self.e.extract("test.py", self.SAMPLE)- fns = {f.name for f in sk.functions}- assert "standalone" in fns-- def test_to_text_compact(self):- sk = self.e.extract("test.py", self.SAMPLE)- text = sk.to_text(verbose=False)- assert "# test.py [Python]" in text- assert "class MyParser" in text- assert "+ parse(" in text- assert "def standalone" in text- # only first line of docstring- assert "Handles both sync" not in text- assert "Args:" not in text-- def test_to_text_verbose(self):- sk = self.e.extract("test.py", self.SAMPLE)- text = sk.to_text(verbose=True)- # full class docstring preserved- assert "Handles both sync and async parsing flows." in text- # full method docstring preserved- assert "Args:" in text- assert "Returns:" in text- assert "List of parsed lines." in text- # module doc still single-line with label- assert 'module: "Module for parsing things.' in text---# ----------------------------------------------------------------------------# JavaScript-# ------------------------------------------------------------------------------class TestJavaScriptExtractor:- SAMPLE = """-import React from "react";-import { useState, useEffect } from "react";--/**- * Counter component.- *- * Maintains an internal count and exposes increment/decrement.- */-class Counter extends React.Component {- /**- * Render the counter UI.- *- * @returns JSX element- */- render() {- return null;- }-}--/**- * Add two numbers together.- *- * @param {number} a - First operand- * @param {number} b - Second operand- * @returns {number} Sum- */-function add(a, b) {- return a + b;-}-"""-- def setup_method(self):- self.e = _js_extractor()-- def test_imports(self):- sk = self.e.extract("app.js", self.SAMPLE)- assert "react" in sk.imports- # both import statements point to "react" — should be deduplicated- assert sk.imports.count("react") == 1-- def test_class_extracted(self):- sk = self.e.extract("app.js", self.SAMPLE)- names = {c.name for c in sk.classes}- assert "Counter" in names-- def test_class_docstring(self):- sk = self.e.extract("app.js", self.SAMPLE)- cls = next(c for c in sk.classes if c.name == "Counter")- assert "Counter component" in cls.docstring-- def test_method_docstring(self):- sk = self.e.extract("app.js", self.SAMPLE)- cls = next(c for c in sk.classes if c.name == "Counter")- methods = {m.name: m for m in cls.methods}- assert "render" in methods- assert "Render the counter UI" in methods["render"].docstring-- def test_function_extracted(self):- sk = self.e.extract("app.js", self.SAMPLE)- names = {f.name for f in sk.functions}- assert "add" in names-- def test_function_docstring(self):- sk = self.e.extract("app.js", self.SAMPLE)- fns = {f.name: f for f in sk.functions}- assert "Add two numbers together" in fns["add"].docstring-- def test_to_text_compact(self):- sk = self.e.extract("app.js", self.SAMPLE)- text = sk.to_text(verbose=False)- assert "# app.js [JavaScript]" in text- assert "class Counter" in text- # only first docstring line in compact mode- assert "Maintains an internal count" not in text-- def test_to_text_verbose(self):- sk = self.e.extract("app.js", self.SAMPLE)- text = sk.to_text(verbose=True)- assert "# app.js [JavaScript]" in text- assert "class Counter" in text- # full docstring in verbose mode- assert "Maintains an internal count and exposes increment/decrement" in text-- def test_export_class(self):- code = """-/** Base utility class.- *- * Provides shared helper methods.- */-export class Utils {- /** Log a message to the console. */- log(msg) { console.log(msg); }-}-"""- sk = self.e.extract("utils.js", code)- names = {c.name for c in sk.classes}- assert "Utils" in names- cls = next(c for c in sk.classes if c.name == "Utils")- assert "Base utility class" in cls.docstring- assert any(m.name == "log" for m in cls.methods)-- def test_arrow_function(self):- code = """-/** Double a number. */-const double = (n) => n * 2;--/** Negate a boolean. */-const negate = (b) => !b;-"""- sk = self.e.extract("math.js", code)- names = {f.name for f in sk.functions}- assert "double" in names- assert "negate" in names- fns = {f.name: f for f in sk.functions}- assert "Double a number" in fns["double"].docstring---# ----------------------------------------------------------------------------# Go-# ------------------------------------------------------------------------------class TestGoExtractor:- SAMPLE = """-package main--import (- "fmt"- "os"+from openviking.parse.parsers.code.ast import extract_skeleton_result+from openviking.parse.parsers.code.ast.providers import is_skeleton_useful+from openviking.parse.parsers.code.ast.aider_repomap import (+ _clean_repromap_rendered,+ _definition_lines,+ _query_captures,+)+from openviking.parse.parsers.code.ast.process_engine import (+ extract_process_skeleton,+ supports_process_skeleton,)-// Server handles incoming HTTP connections.-type Server struct {- host string- port int-}--// NewServer creates a Server with the given host and port.-// Returns a pointer to the initialized Server.-func NewServer(host string, port int) *Server {- return &Server{host: host, port: port}-}--//Start begins listening for connections.-func (s *Server) Start() error {- fmt.Println("starting")- return nil-}-"""-- def setup_method(self):- self.e = _go_extractor()-- def test_imports(self):- sk = self.e.extract("main.go", self.SAMPLE)- assert "fmt" in sk.imports- assert "os" in sk.imports-- def test_struct_extracted(self):- sk = self.e.extract("main.go", self.SAMPLE)- names = {c.name for c in sk.classes}- assert "Server" in names-- def test_functions_extracted(self):- sk = self.e.extract("main.go", self.SAMPLE)- names = {f.name for f in sk.functions}- assert "NewServer" in names- assert "Start" in names # method_declaration is included alongside function_declaration-- def test_method_receiver_not_params(self):- sk = self.e.extract("main.go", self.SAMPLE)- fns = {f.name: f for f in sk.functions}- # (s *Server) is the receiver, not a parameter — must not appear in params- assert "s *Server" not in fns["Start"].params- assert fns["Start"].return_type == "error"-- def test_docstring_extracted(self):- sk = self.e.extract("main.go", self.SAMPLE)- fns = {f.name: f for f in sk.functions}- assert (- "NewServer creates a Server with the given host and port." in fns["NewServer"].docstring- )- assert "Returns a pointer to the initialized Server." in fns["NewServer"].docstring- structs = {c.name: c for c in sk.classes}- assert "Server" in structs- assert "Server handles incoming HTTP connections" in structs["Server"].docstring-- def test_to_text_compact(self):- sk = self.e.extract("main.go", self.SAMPLE)- text = sk.to_text(verbose=False)- assert "# main.go [Go]" in text- assert "NewServer" in text- # only first line- assert "Returns a pointer" not in text-- def test_to_text_verbose(self):- sk = self.e.extract("main.go", self.SAMPLE)- text = sk.to_text(verbose=True)- assert "# main.go [Go]" in text- assert "NewServer" in text- assert "Returns a pointer to the initialized Server." in text---# ----------------------------------------------------------------------------# Java-# ------------------------------------------------------------------------------def _java_extractor():- from openviking.parse.parsers.code.ast.languages.java import JavaExtractor-- return JavaExtractor()---class TestJavaExtractor:- SAMPLE = """-import java.util.List;-import java.util.Optional;--/**- * A simple calculator service.- *- * Supports basic arithmetic operations on integers.- */-public class Calculator {-- /**- * Add two integers.- *- * @param a first operand- * @param b second operand- * @return sum of a and b- */- public int add(int a, int b) {- return a + b;- }-- /**- * Subtract b from a.- *- * @param a minuend- * @param b subtrahend- * @return difference- */- public int subtract(int a, int b) {- return a - b;- }-}-"""-- def setup_method(self):- self.e = _java_extractor()-- def test_imports(self):- sk = self.e.extract("Calculator.java\n", self.SAMPLE)- assert any("List" in i for i in sk.imports)-- def test_class_extracted(self):- sk = self.e.extract("Calculator.java", self.SAMPLE)- assert len(sk.classes) == 1- assert sk.classes[0].name == "Calculator"-- def test_class_docstring(self):- sk = self.e.extract("Calculator.java", self.SAMPLE)- doc = sk.classes[0].docstring- assert "simple calculator service" in doc- assert "Supports basic arithmetic" in doc-- def test_methods_extracted(self):- sk = self.e.extract("Calculator.java", self.SAMPLE)- methods = {m.name: m for m in sk.classes[0].methods}- assert "add" in methods- assert "subtract" in methods-- def test_method_docstring(self):- sk = self.e.extract("Calculator.java", self.SAMPLE)- methods = {m.name: m for m in sk.classes[0].methods}- assert "Add two integers." in methods["add"].docstring- assert "@param a first operand" in methods["add"].docstring- assert "Subtract b from a." in methods["subtract"].docstring-- def test_to_text_compact(self):- sk = self.e.extract("Calculator.java", self.SAMPLE)- text = sk.to_text(verbose=False)- assert "# Calculator.java [Java]" in text- assert "class Calculator" in text- assert "+ add(" in text- assert "@param" not in text-- def test_to_text_verbose(self):- sk = self.e.extract("Calculator.java", self.SAMPLE)- text = sk.to_text(verbose=True)- assert "simple calculator service" in text- assert "@param a first operand" in text- assert "@return sum of a and b" in text---class TestPhpExtractor:- SAMPLE = """-<?php-/** Module for math utilities.- *- * Provides simple arithmetic operations.- */-namespace App\\Services;--use Foo\\Bar;-use Foo\\Baz as BazAlias;-use Foo\\Group\\{A, B as Bee};--/** A simple calculator service.- *- * Supports basic arithmetic operations.- */-class Calculator extends BaseCalc implements ICalc {- /** Add two integers.- *- * @param int $a First operand- * @param int $b Second operand- * @return int Sum- */- public function add(int $a, int $b): int {- return $a + $b;- }-- // Subtract b from a.- public function subtract(int $a, int $b): int {- return $a - $b;- }-}--/** Multiply two integers. */-function mul(int $a, int $b): int {- return $a * $b;-}-"""-- def setup_method(self):- self.e = _php_extractor()-- def test_module_doc(self):- sk = self.e.extract("math.php", self.SAMPLE)- print(sk.to_text(verbose=True))- assert "Module for math utilities" in sk.module_doc-- def test_imports(self):- sk = self.e.extract("math.php", self.SAMPLE)- assert "Foo\\Bar" in sk.imports- assert "Foo\\Baz" in sk.imports- assert "Foo\\Group\\A" in sk.imports- assert "Foo\\Group\\B" in sk.imports-- def test_class_extracted(self):- sk = self.e.extract("math.php", self.SAMPLE)- names = {c.name for c in sk.classes}- assert "Calculator" in names-- def test_methods_extracted(self):- sk = self.e.extract("math.php", self.SAMPLE)- cls = next(c for c in sk.classes if c.name == "Calculator")- methods = {m.name: m for m in cls.methods}- assert "add" in methods- assert "subtract" in methods- assert "$a" in methods["add"].params- assert methods["add"].return_type == "int"-- def test_method_docstring(self):- sk = self.e.extract("math.php", self.SAMPLE)- cls = next(c for c in sk.classes if c.name == "Calculator")- methods = {m.name: m for m in cls.methods}- assert "Add two integers." in methods["add"].docstring- assert "@param int $a" in methods["add"].docstring- assert "Subtract b from a." in methods["subtract"].docstring-- def test_function_extracted(self):- sk = self.e.extract("math.php", self.SAMPLE)- names = {f.name for f in sk.functions}- assert "mul" in names-- def test_to_text_compact(self):- sk = self.e.extract("math.php", self.SAMPLE)- text = sk.to_text(verbose=False)- assert "# math.php [PHP]" in text- assert "class Calculator" in text- assert "@param" not in text-- def test_to_text_verbose(self):- sk = self.e.extract("math.php", self.SAMPLE)- text = sk.to_text(verbose=True)- assert "Supports basic arithmetic operations." in text- assert "@param int $a First operand" in text-- def test_trait_use_added_to_bases(self):- code = """-<?php-trait T1 {}-trait T2 {}-class C {- use T1, T2;- public function m() {}-}-"""- sk = self.e.extract("traits.php", code)- cls = next(c for c in sk.classes if c.name == "C")- assert "T1" in cls.bases- assert "T2" in cls.bases-- def test_trait_and_interface_declarations_included(self):- code = """-<?php-interface ICalc {}-/** T doc */-trait T { public function t() {} }-"""- sk = self.e.extract("defs.php", code)- names = {c.name for c in sk.classes}- assert "interface ICalc" in names- assert "trait T" in names-- def test_assignment_closure_extracted_as_function(self):- code = """-<?php-/** Handler doc. */-$handler = function(int $x): int { return $x; };-$fn = fn($x): int => $x + 1;-"""- sk = self.e.extract("closures.php", code)- fns = {f.name: f for f in sk.functions}- assert "$handler" in fns- assert fns["$handler"].return_type == "int"- assert "Handler doc." in fns["$handler"].docstring- assert "$fn" in fns- assert fns["$fn"].return_type == "int"-- def test_preceding_doc_prefers_phpdoc(self):- code = """-<?php-// Noise comment.--/** Real doc. */-function f() {}-"""- sk = self.e.extract("doc.php", code)- f = next(fn for fn in sk.functions if fn.name == "f")- assert f.docstring == "Real doc."-- def test_preceding_doc_falls_back_to_line_comments(self):- code = """-<?php-// Line 1.-// Line 2.-function g() {}-"""- sk = self.e.extract("doc2.php", code)- g = next(fn for fn in sk.functions if fn.name == "g")- assert "Line 1." in g.docstring- assert "Line 2." in g.docstring---# ----------------------------------------------------------------------------# C#-# ------------------------------------------------------------------------------class TestCSharpExtractor:- SAMPLE = """-using System;-using System.Collections.Generic;--namespace MyApp.Services-{- /// <summary>- /// A simple calculator service.- ///- /// Supports basic arithmetic operations.- /// </summary>- public class Calculator- {- /// <summary>- /// Add two integers.- ///- /// <param name=\"a\">First operand</param>- /// <param name=\"b\">Second operand</param>- /// <returns>Sum of a and b</returns>- /// </summary>- public int Add(int a, int b)- {- return a + b;- }-- /// <summary>- /// Subtract b from a.- /// </summary>- public int Subtract(int a, int b)- {- return a - b;- }- }-}-"""-- def setup_method(self):- self.e = _csharp_extractor()-- def test_imports(self):- sk = self.e.extract("Calculator.cs", self.SAMPLE)- assert "System" in sk.imports- assert "System.Collections.Generic" in sk.imports-- def test_class_extracted(self):- sk = self.e.extract("Calculator.cs", self.SAMPLE)- names = {c.name for c in sk.classes}- assert "Calculator" in names-- def test_class_docstring(self):- sk = self.e.extract("Calculator.cs", self.SAMPLE)- cls = next(c for c in sk.classes if c.name == "Calculator")- assert "simple calculator service" in cls.docstring- assert "Supports basic arithmetic" in cls.docstring-- def test_methods_extracted(self):- sk = self.e.extract("Calculator.cs", self.SAMPLE)- cls = next(c for c in sk.classes if c.name == "Calculator")- methods = {m.name: m for m in cls.methods}- assert "Add" in methods- assert "Subtract" in methods-- def test_method_docstring(self):- sk = self.e.extract("Calculator.cs", self.SAMPLE)- cls = next(c for c in sk.classes if c.name == "Calculator")- methods = {m.name: m for m in cls.methods}- assert "Add two integers." in methods["Add"].docstring- assert "First operand" in methods["Add"].docstring-- def test_to_text_compact(self):- sk = self.e.extract("Calculator.cs", self.SAMPLE)- text = sk.to_text(verbose=False)- assert "# Calculator.cs [C#]" in text- assert "class Calculator" in text- assert "+ Add(" in text- assert "First operand" not in text-- def test_to_text_verbose(self):- sk = self.e.extract("Calculator.cs", self.SAMPLE)- text = sk.to_text(verbose=True)- assert "simple calculator service" in text- assert "First operand" in text-- def test_file_scoped_namespace(self):- code = """-using System;--namespace MyApp.Services;--public class Calculator-{- public int Add(int a, int b)- {- return a + b;- }-}-"""- sk = self.e.extract("Calculator.cs", code)- names = {c.name for c in sk.classes}- assert "Calculator" in names- def test_property_accessor_signature(self):- code = """-public class Calculator-{- /// <summary>- /// Current result.- /// </summary>- public int Result { get; set; }-}-"""- sk = self.e.extract("Calculator.cs", code)- cls = next(c for c in sk.classes if c.name == "Calculator")- methods = {m.name: m for m in cls.methods}- assert "Result" in methods- assert "get" in methods["Result"].params- assert "set" in methods["Result"].params+def test_tags_query_wins_without_calling_process(monkeypatch):+ process = Mock()+ monkeypatch.setattr(+ "openviking.parse.parsers.code.ast.providers.has_tag_query",+ lambda _name: True,+ )+ monkeypatch.setattr(+ "openviking.parse.parsers.code.ast.providers._extract_with_grep_ast",+ lambda *_args, **_kwargs: "# sample.cpp\n\nclass Widget",+ )+ monkeypatch.setattr(+ "openviking.parse.parsers.code.ast.providers.extract_process_skeleton",+ process,+ )++ result = extract_skeleton_result("sample.cpp", "class Widget {};")++ assert result.provider == "aider_repomap"+ assert not result.should_fallback_to_llm+ process.assert_not_called()+++def test_low_quality_tags_request_llm_fallback_without_calling_process(monkeypatch):+ process = Mock()+ process.return_value = "# sample.cpp [C/C++]\n\nclass Widget"+ monkeypatch.setattr(+ "openviking.parse.parsers.code.ast.providers.has_tag_query",+ lambda _name: True,+ )+ monkeypatch.setattr(+ "openviking.parse.parsers.code.ast.providers._extract_with_grep_ast",+ lambda *_args, **_kwargs: "# sample.cpp",+ )+ monkeypatch.setattr(+ "openviking.parse.parsers.code.ast.providers.extract_process_skeleton",+ process,+ )++ result = extract_skeleton_result("sample.cpp", "class Widget {};")++ assert result.text is None+ assert result.provider == "llm"+ assert result.should_fallback_to_llm+ assert result.reason == "tags query produced no useful skeleton"+ process.assert_not_called()+++def test_no_tags_uses_process(monkeypatch):+ process = Mock()+ process.return_value = "# sample.py [Python]\n\ndef run()"+ monkeypatch.setattr(+ "openviking.parse.parsers.code.ast.providers.has_tag_query",+ lambda _name: False,+ )+ monkeypatch.setattr(+ "openviking.parse.parsers.code.ast.providers.extract_process_skeleton",+ process,+ )++ result = extract_skeleton_result("sample.py", "def run():\n pass\n")++ assert result.provider == "process"+ assert result.text+++def test_both_extractors_unavailable_requests_llm_fallback(monkeypatch):+ process = Mock()+ process.return_value = None+ monkeypatch.setattr(+ "openviking.parse.parsers.code.ast.providers.has_tag_query",+ lambda _name: False,+ )+ monkeypatch.setattr(+ "openviking.parse.parsers.code.ast.providers.extract_process_skeleton",+ process,+ )++ result = extract_skeleton_result("component.vue", "<template />")++ assert result.text is None+ assert result.provider == "llm"+ assert result.should_fallback_to_llm+++ "text",+ [+ "",+ "# sample.py [Python]",+ "# sample.py [Python]\nimports: os, sys\nmodule: sample\nlanguage: Python",+ ],+)+def test_skeleton_usefulness_rejects_empty_or_metadata_only_output(text):+ assert not is_skeleton_useful(text)-# ----------------------------------------------------------------------------# C/C++-# ---------------------------------------------------------------------------+ "text",+ [+ "# sample.lisp [aider-repomap-lite, compact]\n\n(defun add (a b)\n (+ a b))",+ "# sample.ml [aider-repomap-lite, compact]\n\nlet add a b = a + b",+ "# sample.rkt [aider-repomap-lite, compact]\n\n(define (add a b)\n (+ a b))",+ ],+)+def test_skeleton_usefulness_accepts_language_neutral_structure(text):+ assert is_skeleton_useful(text)-def _cpp_extractor():- from openviking.parse.parsers.code.ast.languages.cpp import CppExtractor+def test_clean_repromap_rendered_removes_tree_context_gutter():+ rendered = "⋮\n│struct Widget { int x; };\n│\n│int add(int a, int b) {\n│ return a + b;\n⋮"- return CppExtractor()+ text = _clean_repromap_rendered(rendered)+ assert text == "struct Widget { int x; };\n\nint add(int a, int b) {\n return a + b;"-class TestCppExtractor:- SAMPLE = """-#include <string>-#include <vector>-/**- * A simple stack data structure.- *- * Supports push, pop, and peek operations.- */-class Stack {-public:- /**- * Push a value onto the stack.- *- * @param value The value to push- */- void push(int value);+def test_tags_query_rendered_skeleton_is_useful_after_cleaning(monkeypatch):+ process = Mock()+ monkeypatch.setattr(+ "openviking.parse.parsers.code.ast.providers.extract_process_skeleton",+ process,+ )+ content = """#include <stdio.h>- /**- * Pop the top value from the stack.- *- * @return The popped value- */- int pop();-};+struct Widget { int x; };-/**- * Compute the sum of two integers.- *- * @param a First operand- * @param b Second operand- * @return Sum of a and b- */int add(int a, int b) {return a + b;}-"""-- def setup_method(self):- self.e = _cpp_extractor()-- def test_imports(self):- sk = self.e.extract("stack.cpp", self.SAMPLE)- assert "string" in sk.imports- assert "vector" in sk.imports-- def test_class_extracted(self):- sk = self.e.extract("stack.cpp", self.SAMPLE)- names = {c.name for c in sk.classes}- assert "Stack" in names-- def test_class_docstring(self):- sk = self.e.extract("stack.cpp", self.SAMPLE)- cls = next(c for c in sk.classes if c.name == "Stack")- assert "simple stack data structure" in cls.docstring- assert "Supports push, pop" in cls.docstring-- def test_method_docstring(self):- sk = self.e.extract("stack.cpp", self.SAMPLE)- cls = next(c for c in sk.classes if c.name == "Stack")- methods = {m.name: m for m in cls.methods}- assert "push" in methods- assert "Push a value onto the stack." in methods["push"].docstring- assert "@param value" in methods["push"].docstring-- def test_function_extracted(self):- sk = self.e.extract("stack.cpp", self.SAMPLE)- names = {f.name for f in sk.functions}- assert "add" in names-- def test_function_docstring(self):- sk = self.e.extract("stack.cpp", self.SAMPLE)- fns = {f.name: f for f in sk.functions}- assert "Compute the sum of two integers." in fns["add"].docstring- assert "@param a First operand" in fns["add"].docstring-- def test_method_return_type(self):- sk = self.e.extract("stack.cpp", self.SAMPLE)- cls = next(c for c in sk.classes if c.name == "Stack")- methods = {m.name: m for m in cls.methods}- assert methods["push"].return_type == "void"- assert methods["pop"].return_type == "int"-- def test_to_text_compact(self):- sk = self.e.extract("stack.cpp", self.SAMPLE)- text = sk.to_text(verbose=False)- assert "# stack.cpp [C/C++]" in text- assert "class Stack" in text- assert "@param" not in text-- def test_to_text_verbose(self):- sk = self.e.extract("stack.cpp", self.SAMPLE)- text = sk.to_text(verbose=True)- assert "simple stack data structure" in text- assert "@param a First operand" in text- assert "@return Sum of a and b" in text-- def test_typedef_struct_anonymous(self):- code = """-/* A 2D point. */-typedef struct {- float x;- float y;-} Point;--/* An RGB color value. */-typedef struct {- int r;- int g;- int b;-} Color;-"""- sk = self.e.extract("types.h", code)- names = {c.name for c in sk.classes}- assert "Point" in names- assert "Color" in names-- def test_typedef_struct_named_tag(self):- # typedef struct Node { ... } Node; — tag and alias are the same- code = """-typedef struct Node {- int value;- struct Node *next;-} Node;-"""- sk = self.e.extract("list.h", code)- names = {c.name for c in sk.classes}- assert "Node" in names-- def test_typedef_struct_docstring(self):- code = """-/** Represents a rectangle with width and height. */-typedef struct {- int width;- int height;-} Rect;-"""- sk = self.e.extract("rect.h", code)- rect = next((c for c in sk.classes if c.name == "Rect"), None)- assert rect is not None- assert "Represents a rectangle" in rect.docstring-- def test_function_prototype_top_level(self):- # .h header with only function declarations (no bodies)- code = """-#include <stddef.h>--/* Allocate n bytes of memory. */-void *my_malloc(size_t n);--/* Free previously allocated memory. */-void my_free(void *ptr);-"""- sk = self.e.extract("mem.h", code)- names = {f.name for f in sk.functions}- assert "my_malloc" in names- assert "my_free" in names-- def test_function_prototype_return_type(self):- code = """-int compute(int a, int b);-void reset(void);-"""- sk = self.e.extract("utils.h", code)- print(sk.to_text())- fns = {f.name: f for f in sk.functions}- assert fns["compute"].return_type == "int"- assert fns["reset"].return_type == "void"-- def test_function_prototype_docstring(self):- code = """-/** Add two integers and return the result. */-int add(int a, int b);-"""- sk = self.e.extract("math.h", code)- fns = {f.name: f for f in sk.functions}- assert "Add two integers" in fns["add"].docstring-- def test_namespace_typedef_and_proto(self):- code = """-namespace utils {--typedef struct {- int id;-} Handle;--int create(int flags);+static void run(void) {+ printf("%d", add(1, 2));}"""- sk = self.e.extract("utils.cpp", code)- names = {c.name for c in sk.classes}- assert "Handle" in names- fns = {f.name for f in sk.functions}- assert "create" in fns-- def test_declaration_and_definition_both_extracted(self):- # Forward declaration + definition in the same file — both appear in skeleton- code = """-/* Forward declaration */-int add(int a, int b);-/* Definition */-int add(int a, int b) {- return a + b;-}-"""- sk = self.e.extract("math.cpp", code)- names = [f.name for f in sk.functions]- assert names.count("add") == 2+ result = extract_skeleton_result("sample.c", content)+ assert result.provider == "aider_repomap"+ assert not result.should_fallback_to_llm+ assert result.text+ assert "struct Widget" in result.text+ assert "int add(int a, int b)" in result.text+ assert "│" not in result.text+ assert "⋮" not in result.text+ process.assert_not_called()-# ----------------------------------------------------------------------------# Rust-# ---------------------------------------------------------------------------[email protected]("file_name", ["sample.cpp", "kernel.cu"])+def test_cpp_tags_capture_top_level_function_template_declarations_only(file_name):+ content = """#include <vector>-def _rust_extractor():- from openviking.parse.parsers.code.ast.languages.rust import RustExtractor+template <class T>+void reduce(int size, T *input, T *output);- return RustExtractor()+int block_size;--class TestRustExtractor:- SAMPLE = """-use std::collections::HashMap;-use std::io::{self, Read};--/// A key-value store backed by a HashMap.-///-/// Supports get, set, and delete operations.-pub struct Store {- data: HashMap<String, String>,-}--impl Store {- /// Create a new empty Store.- ///- /// # Examples- /// ```- /// let store = Store::new();- /// ```- pub fn new() -> Self {- Store { data: HashMap::new() }- }-- /// Get a value by key.- ///- /// Returns None if the key does not exist.- pub fn get(&self, key: &str) -> Option<&String> {- self.data.get(key)- }-}--/// Compute the factorial of n.-///-/// # Panics-/// Panics if n is negative.-pub fn factorial(n: u64) -> u64 {- if n == 0 { 1 } else { n * factorial(n - 1) }+void configure() {+ std::vector<int> buffer(block_size);}"""- def setup_method(self):- self.e = _rust_extractor()-- def test_imports(self):- sk = self.e.extract("store.rs", self.SAMPLE)- assert any("HashMap" in i for i in sk.imports)+ _, captures = _query_captures(file_name, content)+ lines = _definition_lines(captures)+ one_based_lines = {line + 1 for line in lines}- def test_struct_extracted(self):- sk = self.e.extract("store.rs", self.SAMPLE)- names = {c.name for c in sk.classes}- assert "Store" in names+ assert 4 in one_based_lines+ assert 6 not in one_based_lines+ assert 9 not in one_based_lines- def test_struct_docstring(self):- sk = self.e.extract("store.rs", self.SAMPLE)- store = next(c for c in sk.classes if c.name == "Store")- assert "key-value store" in store.docstring- assert "Supports get, set, and delete" in store.docstring- def test_impl_methods_docstring(self):- sk = self.e.extract("store.rs", self.SAMPLE)- impl = next(c for c in sk.classes if c.name == "impl Store")- methods = {m.name: m for m in impl.methods}- assert "new" in methods- assert "Create a new empty Store." in methods["new"].docstring- assert "Examples" in methods["new"].docstring- assert "get" in methods- assert "Returns None if the key does not exist." in methods["get"].docstring-- def test_function_extracted(self):- sk = self.e.extract("store.rs", self.SAMPLE)- names = {f.name for f in sk.functions}- assert "factorial" in names-- def test_function_docstring(self):- sk = self.e.extract("store.rs", self.SAMPLE)- fns = {f.name: f for f in sk.functions}- assert "Compute the factorial of n." in fns["factorial"].docstring- assert "Panics" in fns["factorial"].docstring-- def test_to_text_compact(self):- sk = self.e.extract("store.rs", self.SAMPLE)- text = sk.to_text(verbose=False)- assert "# store.rs [Rust]" in text- assert "Store" in text- assert "Supports get, set" not in text-- def test_to_text_verbose(self):- sk = self.e.extract("store.rs", self.SAMPLE)- text = sk.to_text(verbose=True)- assert "key-value store" in text- assert "Supports get, set, and delete operations." in text- assert "Panics if n is negative." in text---# ----------------------------------------------------------------------------# Lua-# ------------------------------------------------------------------------------def _lua_extractor():- from openviking.parse.parsers.code.ast.languages.lua import LuaExtractor-- return LuaExtractor()---class TestLuaExtractor:- SAMPLE = """local mathx = require("mathx")-local util = require("util")--local Calculator = {}+def test_ocaml_interface_tags_capture_interface_structures(monkeypatch):+ process = Mock()+ monkeypatch.setattr(+ "openviking.parse.parsers.code.ast.providers.extract_process_skeleton",+ process,+ )+ content = """type user = {+ id : string;+ name : string;+}--- Add two numbers.--- Returns their sum.-function Calculator.add(a, b)- return a + b+module type STORE = sig+ val find : string -> user optionend--- Subtract b from a.--- Returns their difference.-function Calculator:sub(a, b)- return a - b+module Cache : sig+ val get : string -> user optionend--- Add two numbers at module scope.-local function add(a, b)- return a + b+class type printable = object+ method render : stringend-"""-- def setup_method(self):- self.e = _lua_extractor()-- def test_imports(self):- sk = self.e.extract("calculator.lua", self.SAMPLE)- assert "mathx" in sk.imports- assert "util" in sk.imports- # deduplicated imports should remain unique- assert sk.imports.count("mathx") == 1-- def test_class_extracted(self):- sk = self.e.extract("calculator.lua", self.SAMPLE)- names = {c.name for c in sk.classes}- assert "Calculator" in names-- def test_methods_extracted(self):- sk = self.e.extract("calculator.lua", self.SAMPLE)- cls = next(c for c in sk.classes if c.name == "Calculator")- method_names = {m.name for m in cls.methods}- assert "add" in method_names- assert "sub" in method_names-- def test_method_docstring(self):- sk = self.e.extract("calculator.lua", self.SAMPLE)- cls = next(c for c in sk.classes if c.name == "Calculator")- methods = {m.name: m for m in cls.methods}- assert "Add two numbers." in methods["add"].docstring- assert "Returns their sum." in methods["add"].docstring- assert "Subtract b from a." in methods["sub"].docstring-- def test_function_extracted(self):- sk = self.e.extract("calculator.lua", self.SAMPLE)- names = {f.name for f in sk.functions}- assert "add" in names-- def test_function_docstring(self):- sk = self.e.extract("calculator.lua", self.SAMPLE)- fns = {f.name: f for f in sk.functions}- assert "Add two numbers at module scope." in fns["add"].docstring-- def test_to_text_compact(self):- sk = self.e.extract("calculator.lua", self.SAMPLE)- text = sk.to_text(verbose=False)- assert "# calculator.lua [Lua]" in text- assert "Calculator" in text- assert "add" in text- # only first line of multi-line docstring in compact mode- assert "Returns their difference." not in text-- def test_to_text_verbose(self):- sk = self.e.extract("calculator.lua", self.SAMPLE)- text = sk.to_text(verbose=True)- assert "# calculator.lua [Lua]" in text- assert "Returns their sum." in text- assert "Returns their difference." in text-- def test_dot_method_params(self):- code = "function M.compute(x, y, z)\n return x + y + z\nend\n"- sk = self.e.extract("m.lua", code)- cls = next(c for c in sk.classes if c.name == "M")- methods = {m.name: m for m in cls.methods}- assert "compute" in methods- assert "x, y, z" in methods["compute"].params-- def test_colon_method_not_in_functions(self):- code = "function M:init()\nend\nfunction standalone()\nend\n"- sk = self.e.extract("m.lua", code)- fn_names = {f.name for f in sk.functions}- assert "standalone" in fn_names- assert "init" not in fn_names-- def test_bare_require(self):- code = "require 'inspect'\nfunction foo()\nend\n"- sk = self.e.extract("m.lua", code)- assert "inspect" in sk.imports---# ----------------------------------------------------------------------------# Skeleton.to_text() — verbose vs compact-# ------------------------------------------------------------------------------class TestSkeletonToText:- MULTILINE_DOC = "First line summary.\n\nMore details here.\nArgs:\n x: an integer."-- def _make_skeleton(self):- return CodeSkeleton(- file_name="foo.py",- language="Python",- module_doc="A foo module.",- imports=["os", "sys"],- classes=[- ClassSkeleton(- name="Foo",- bases=["Base"],- docstring=self.MULTILINE_DOC,- methods=[FunctionSig("run", "self", "None", self.MULTILINE_DOC)],- )- ],- functions=[FunctionSig("helper", "x: int", "bool", self.MULTILINE_DOC)],- )-- def test_empty_skeleton(self):- sk = CodeSkeleton(- file_name="empty.py",- language="Python",- module_doc="",- imports=[],- classes=[],- functions=[],- )- assert "# empty.py [Python]" in sk.to_text()-- def test_compact_only_first_line(self):- text = self._make_skeleton().to_text(verbose=False)- assert 'module: "A foo module."' in text- assert "imports: os, sys" in text- assert "class Foo(Base)" in text- assert '"""First line summary."""' in text- assert "+ run(self) -> None" in text- assert "def helper(x: int) -> bool" in text- # multi-line parts must NOT appear- assert "More details here." not in text- assert "Args:" not in text-- def test_verbose_full_docstring(self):- text = self._make_skeleton().to_text(verbose=True)- assert 'module: "A foo module."' in text- assert "More details here." in text- assert "Args:" in text- assert "x: an integer." in text- def test_verbose_single_line_doc_no_extra_quotes(self):- sk = CodeSkeleton(- file_name="bar.py",- language="Python",- module_doc="Single line.",- imports=[],- classes=[ClassSkeleton("Bar", [], "One liner.", [])],- functions=[],- )- text = sk.to_text(verbose=True)- # single-line docstring should still be inline: """One liner."""- assert '"""One liner."""' in text- # should NOT have a dangling """ on its own line- lines = text.split("\n")- assert not any(line.strip() == '"""' for line in lines)+external hash_user : user -> int = "hash_user"--# ----------------------------------------------------------------------------# TypeScript-# ------------------------------------------------------------------------------class TestTypeScriptExtractor:- SAMPLE = """-import { Observable } from "rxjs";-import { HttpClient } from "@angular/common/http";--/**- * Service for managing todos.- *- * Persists data to a remote API.- */-class TodoService {- /**- * Get all todos.- *- * @returns array of todo strings- */- getAll(): string[] {- return [];- }-- /**- * Add a new todo item.- *- * @param title the todo title- */- add(title: string): void {}-}--/**- * Validate a todo title.- *- * Returns false if title is empty or too long.- */-function validate(title: string): boolean {- return title.length > 0 && title.length < 100;-}+val create : id:string -> name:string -> user"""- def setup_method(self):- self.e = _ts_extractor()-- def test_imports(self):- sk = self.e.extract("todo.ts", self.SAMPLE)- assert "rxjs" in sk.imports- assert "@angular/common/http" in sk.imports- # no duplicates- assert sk.imports.count("rxjs") == 1-- def test_class_extracted(self):- sk = self.e.extract("todo.ts", self.SAMPLE)- names = {c.name for c in sk.classes}- assert "TodoService" in names-- def test_class_docstring(self):- sk = self.e.extract("todo.ts", self.SAMPLE)- cls = next(c for c in sk.classes if c.name == "TodoService")- assert "Service for managing todos" in cls.docstring- assert "Persists data to a remote API" in cls.docstring-- def test_methods_extracted(self):- sk = self.e.extract("todo.ts", self.SAMPLE)- cls = next(c for c in sk.classes if c.name == "TodoService")- methods = {m.name: m for m in cls.methods}- assert "getAll" in methods- assert "add" in methods-- def test_method_docstring(self):- sk = self.e.extract("todo.ts", self.SAMPLE)- cls = next(c for c in sk.classes if c.name == "TodoService")- methods = {m.name: m for m in cls.methods}- assert "Get all todos" in methods["getAll"].docstring- assert "Add a new todo item" in methods["add"].docstring-- def test_function_extracted(self):- sk = self.e.extract("todo.ts", self.SAMPLE)- names = {f.name for f in sk.functions}- assert "validate" in names-- def test_function_docstring(self):- sk = self.e.extract("todo.ts", self.SAMPLE)- fns = {f.name: f for f in sk.functions}- assert "Validate a todo title" in fns["validate"].docstring- assert "Returns false if title is empty" in fns["validate"].docstring-- def test_to_text_compact(self):- sk = self.e.extract("todo.ts", self.SAMPLE)- text = sk.to_text(verbose=False)- assert "# todo.ts [TypeScript]" in text- assert "TodoService" in text- assert "Persists data to a remote API" not in text-- def test_to_text_verbose(self):- sk = self.e.extract("todo.ts", self.SAMPLE)- text = sk.to_text(verbose=True)- assert "# todo.ts [TypeScript]" in text- assert "Persists data to a remote API." in text- assert "Returns false if title is empty or too long." in text---# ----------------------------------------------------------------------------# ASTExtractor dispatch-# ------------------------------------------------------------------------------class TestASTExtractorDispatch:- def setup_method(self):- from openviking.parse.parsers.code.ast.extractor import ASTExtractor-- self.extractor = ASTExtractor()-- def test_python_dispatch(self):- code = 'def foo(x: int) -> str:\n """Convert x to string."""\n return str(x)\n'- text = self.extractor.extract_skeleton("util.py", code)- assert "# util.py [Python]" in text- assert "def foo" in text-- def test_go_dispatch(self):- code = "package main\n\n// Run starts the app.\nfunc Run() error {\n return nil\n}\n"- text = self.extractor.extract_skeleton("main.go", code)- assert "# main.go [Go]" in text- assert "Run" in text-- def test_csharp_dispatch(self):- code = "namespace Demo;\n\npublic class Util { public int Add(int a, int b) { return a + b; } }\n"- text = self.extractor.extract_skeleton("util.cs", code)- assert "# util.cs [C#]" in text- assert "class Util" in text-- def test_lua_dispatch(self):- code = "-- Say hello.\nfunction greet(name)\n return 'Hi ' .. name\nend\n"- text = self.extractor.extract_skeleton("hello.lua", code)- assert text is not None- assert "# hello.lua [Lua]" in text- assert "greet" in text-- def test_unknown_extension_returns_none(self):- code = "def foo(x): pass\nclass Bar: pass\n"- result = self.extractor.extract_skeleton("script.xyz123", code)- assert result is None-- def test_never_raises(self):- # empty content for supported language- result = self.extractor.extract_skeleton("empty.py", "")- assert result is None or isinstance(result, str)- # unsupported extension → None, no exception- result = self.extractor.extract_skeleton("file.xyz123", "\x00\x01\x02binary")- assert result is None-- def test_verbose_propagated(self):- code = 'def foo():\n """Summary line.\n\n Detail here.\n """\n pass\n'- compact = self.extractor.extract_skeleton("m.py", code, verbose=False)- verbose = self.extractor.extract_skeleton("m.py", code, verbose=True)- assert "Detail here." not in compact- assert "Detail here." in verbose-- def test_viking_resource_md_uses_parent_extension(self):- # Viking add-resource stores `foo.py` as directory `foo.py/` with body- # `foo.py/foo.md`. Language detection must fall back to the parent- # directory's suffix so code tools recognise the original language.- code = "def foo(x):\n return x\n"- viking_uri = "viking://resources/test-code.py/test-code.md"- assert self.extractor.supports(viking_uri)- assert self.extractor._detect_language(viking_uri) == "python"- text = self.extractor.extract_skeleton(viking_uri, code)- assert text is not None- assert "def foo" in text-- def test_plain_markdown_still_unsupported(self):- # A genuine markdown file (no language-bearing parent) must not be- # treated as code.- assert not self.extractor.supports("notes.md")- assert not self.extractor.supports("viking://resources/notes.md")+ result = extract_skeleton_result("sample.mli", content)++ assert result.provider == "aider_repomap"+ assert result.text+ assert "type user" in result.text+ assert "module type STORE" in result.text+ assert "module Cache" in result.text+ assert "class type printable" in result.text+ assert "external hash_user" in result.text+ assert "val create" in result.text+ process.assert_not_called()+++ ("file_name", "content", "symbol"),+ [+ ("sample.py", "def build_order():\n return 1\n", "build_order"),+ ("sample.rb", "def build_order\n 1\nend\n", "build_order"),+ ("sample.swift", "func buildOrder() -> Int { return 1 }\n", "buildOrder"),+ ("sample.ts", "export function buildOrder(): number { return 1; }\n", "buildOrder"),+ ],+)+def test_process_smoke(file_name, content, symbol):+ text = extract_process_skeleton(file_name, content)+ assert text is not None+ assert symbol in text++[email protected]("file_name", ["README.md", "config.yaml", "data.json"])+def test_process_denylist(file_name):+ assert not supports_process_skeleton(file_name)+++ "file_name",+ [+ "sample.py",+ "sample.ts",+ "sample.cpp",+ "sample.rs",+ "sample.go",+ "component.svelte",+ "schema.graphql",+ "schema.prisma",+ "main.tf",+ "query.sql",+ "service.proto",+ ],+)+def test_process_supported_code_languages(file_name):+ assert supports_process_skeleton(file_name)+++ "file_name",+ [+ "README.md",+ "config.yaml",+ "data.json",+ "page.html",+ "style.css",+ "paper.tex",+ "chart.mmd",+ "diagram.dot",+ "request.http",+ "request.hurl",+ ],+)+def test_process_rejects_non_code_structured_formats(file_name):+ assert not supports_process_skeleton(file_name)diff --git a/tests/parse/test_code_tools.py b/tests/parse/test_code_tools.pydeleted file mode 100644index 83ea06790..000000000--- a/tests/parse/test_code_tools.py+++ /dev/null@@ -1,440 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""Tests for the code-navigation pure functions backing the-code_outline / code_search / code_expand MCP tools."""--from openviking.parse.parsers.code.ast.code_tools import (- expand_symbol,- outline_file,- search_symbols,-)-from openviking.parse.parsers.code.ast.extractor import get_extractor--PY_SAMPLE = '''"""Module top doc."""--import os-from typing import List---class Greeter:- """Greets people."""-- def __init__(self, name: str):- self.name = name-- def greet(self, who: str) -> str:- """Return a greeting."""- return f"Hello {who} from {self.name}"---def make_greeter(name: str) -> Greeter:- return Greeter(name)-'''---# ----------------------------------------------------------------------------# Line numbers populated by extractors-# ------------------------------------------------------------------------------class TestLineNumbers:- def test_python_class_and_method_lines(self):- skel = get_extractor().extract("greeter.py", PY_SAMPLE)- assert skel is not None- assert len(skel.classes) == 1- cls = skel.classes[0]- assert cls.name == "Greeter"- # Class spans from `class Greeter:` to end of greet body- assert cls.line_start == 7- assert cls.line_end >= 15-- method_names = [m.name for m in cls.methods]- assert "__init__" in method_names- assert "greet" in method_names-- greet = next(m for m in cls.methods if m.name == "greet")- assert greet.line_start == 13- assert greet.line_end == 15-- def test_python_top_level_function_lines(self):- skel = get_extractor().extract("greeter.py", PY_SAMPLE)- assert len(skel.functions) == 1- fn = skel.functions[0]- assert fn.name == "make_greeter"- assert fn.line_start == 18- assert fn.line_end == 19-- def test_unsupported_language_returns_none(self):- assert get_extractor().extract("readme.md", "# hello") is None---GO_SAMPLE = """\-package main--type Greeter struct {-\tName string-}--func (g *Greeter) Greet(who string) string {-\treturn "Hello " + who-}--func MakeGreeter(name string) *Greeter {-\treturn &Greeter{Name: name}-}-"""--TS_SAMPLE = """\-class Greeter {- name: string;- constructor(name: string) {- this.name = name;- }- greet(who: string): string {- return `Hello ${who}`;- }-}--function makeGreeter(name: string): Greeter {- return new Greeter(name);-}-"""--RS_SAMPLE = """\-pub struct Greeter {- pub name: String,-}--impl Greeter {- pub fn greet(&self, who: &str) -> String {- format!("Hello {}", who)- }-}--pub fn make_greeter(name: String) -> Greeter {- Greeter { name }-}-"""--JAVA_SAMPLE = """\-public class Greeter {- private String name;-- public Greeter(String name) {- this.name = name;- }-- public String greet(String who) {- return "Hello " + who;- }-}-"""--CPP_SAMPLE = """\-#include <string>--class Greeter {-public:- std::string greet(const std::string& who) {- return "Hello " + who;- }-};-"""--CS_SAMPLE = """\-public class Greeter {- public string Name { get; set; }- public string Greet(string who) {- return "Hello " + who;- }-}-"""--PHP_SAMPLE = """\-<?php--class Greeter {- public $name;- public function greet($who) {- return "Hello $who";- }-}--function makeGreeter($name) {- return new Greeter();-}-"""--LUA_SAMPLE = """\-function Greeter:greet(who)- return "Hello " .. who-end--function makeGreeter(name)- return name-end-"""--_LANG_SAMPLES = [- ("greeter.go", GO_SAMPLE, "Go"),- ("greeter.ts", TS_SAMPLE, "TypeScript"),- ("greeter.rs", RS_SAMPLE, "Rust"),- ("Greeter.java", JAVA_SAMPLE, "Java"),- ("greeter.cpp", CPP_SAMPLE, "C++"),- ("Greeter.cs", CS_SAMPLE, "C#"),- ("greeter.php", PHP_SAMPLE, "PHP"),- ("greeter.lua", LUA_SAMPLE, "Lua"),-]---class TestLineNumbersAllLanguages:- """Regression: every language extractor must populate non-zero line numbers.-- Prior to this commit all extractors left line_start/line_end at the default- of 0. These tests ensure the node.start_point / end_point wiring is correct- for each supported language by asserting that every class and function in the- sample snippet carries a positive, ordered span.- """-- def _check_non_zero(self, file_name: str, src: str, lang_name: str):- import pytest-- ext = get_extractor()- if not ext.supports(file_name):- pytest.skip(f"tree-sitter grammar for {lang_name} not installed")- skel = ext.extract(file_name, src)- assert skel is not None, f"{lang_name}: parse returned None"-- symbols = []- for cls in skel.classes:- symbols.append((f"class {cls.name}", cls.line_start, cls.line_end))- for m in cls.methods:- symbols.append((f"{cls.name}.{m.name}", m.line_start, m.line_end))- for fn in skel.functions:- symbols.append((f"fn {fn.name}", fn.line_start, fn.line_end))-- assert symbols, f"{lang_name}: no symbols extracted"- for sym, start, end in symbols:- assert start > 0, f"{lang_name} {sym}: line_start is 0 (not populated)"- assert end >= start, f"{lang_name} {sym}: line_end {end} < line_start {start}"-- def test_go_line_numbers(self):- self._check_non_zero("greeter.go", GO_SAMPLE, "Go")-- def test_typescript_line_numbers(self):- self._check_non_zero("greeter.ts", TS_SAMPLE, "TypeScript")-- def test_rust_line_numbers(self):- self._check_non_zero("greeter.rs", RS_SAMPLE, "Rust")-- def test_java_line_numbers(self):- self._check_non_zero("Greeter.java", JAVA_SAMPLE, "Java")-- def test_cpp_line_numbers(self):- self._check_non_zero("greeter.cpp", CPP_SAMPLE, "C++")-- def test_csharp_line_numbers(self):- self._check_non_zero("Greeter.cs", CS_SAMPLE, "C#")-- def test_php_line_numbers(self):- self._check_non_zero("greeter.php", PHP_SAMPLE, "PHP")-- def test_lua_line_numbers(self):- self._check_non_zero("greeter.lua", LUA_SAMPLE, "Lua")---# ----------------------------------------------------------------------------# outline_file-# ------------------------------------------------------------------------------class TestOutlineFile:- def test_outline_python(self):- out = outline_file(PY_SAMPLE, "greeter.py")- assert out.startswith("greeter.py [Python,")- assert "20 lines" in out # 19 newlines + 1- assert "imports: os, typing.List" in out- assert 'module: "Module top doc."' in out- assert "class Greeter L7-" in out- assert "+ __init__(self, name: str) L10-11" in out- assert "+ greet(self, who: str) -> str L13-15" in out- assert "def make_greeter(name: str) -> Greeter L18-19" in out- # outline must not leak docstrings (it's a navigation view)- assert '"""' not in out- assert "Return a greeting" not in out-- def test_outline_empty_file(self):- # Empty content: no symbols, but the header should still appear- out = outline_file("", "empty.py")- assert out.startswith("empty.py [Python,")- # 0 newlines + 1 = 1 line in our convention; tolerated either way- assert "lines]" in out-- def test_outline_unsupported_language(self):- out = outline_file("# nothing", "notes.md")- assert out == "Error: unsupported language for notes.md"---# ----------------------------------------------------------------------------# search_symbols-# ------------------------------------------------------------------------------SECOND_FILE = """def greet():- pass---class Other:- def helper(self):- pass-"""---class TestSearchSymbols:- def test_substring_case_insensitive(self):- result = search_symbols(- "greet",- [(PY_SAMPLE, "greeter.py"), (SECOND_FILE, "other.py")],- )- # Four substring hits on leaf name "greet":- # greeter.py : Greeter (class), Greeter.greet (method), make_greeter (fn)- # other.py : greet (top-level fn)- assert result.startswith('4 matches for "greet"')- assert "scanned 2 files" in result- assert "greeter.py" in result- assert "other.py" in result- assert "Greeter.greet" in result- assert "make_greeter" in result-- def test_qualified_name_search(self):- # Searching the full qualified name must also match.- result = search_symbols("Greeter.greet", [(PY_SAMPLE, "greeter.py")])- assert "1 matches" in result- assert "Greeter.greet" in result-- def test_query_only_matches_leaf_name(self):- result = search_symbols("helper", [(SECOND_FILE, "other.py")])- assert "1 matches" in result- assert "Other.helper" in result-- def test_no_match(self):- result = search_symbols("nonexistent_xyz", [(PY_SAMPLE, "greeter.py")])- assert result.startswith("No matches")- assert "scanned 1 files" in result-- def test_empty_query(self):- assert search_symbols("", [(PY_SAMPLE, "greeter.py")]) == "Error: empty query"-- def test_skips_unsupported_silently(self):- # Markdown file is silently skipped (still counts toward scanned total)- result = search_symbols(- "greet",- [(PY_SAMPLE, "greeter.py"), ("# heading", "notes.md")],- )- assert "scanned 2 files" in result- assert "notes.md" not in result---# ----------------------------------------------------------------------------# expand_symbol-# ------------------------------------------------------------------------------class TestExpandSymbol:- def test_expand_top_level_function(self):- out = expand_symbol(PY_SAMPLE, "greeter.py", "make_greeter")- assert out.startswith("# greeter.py L18-19 (make_greeter)")- assert "def make_greeter(name: str) -> Greeter:" in out- assert "return Greeter(name)" in out-- def test_expand_class(self):- out = expand_symbol(PY_SAMPLE, "greeter.py", "Greeter")- assert "(Greeter)" in out- assert "class Greeter:" in out- assert "def greet" in out # body included-- def test_expand_qualified_method(self):- out = expand_symbol(PY_SAMPLE, "greeter.py", "Greeter.greet")- assert "(Greeter.greet)" in out- assert "def greet(self, who: str) -> str:" in out- # Should NOT include __init__ or class header- assert "class Greeter" not in out- assert "__init__" not in out-- def test_expand_bare_method_resolves_to_first_match(self):- # bare 'greet' should find the method via class walk (first match)- out = expand_symbol(PY_SAMPLE, "greeter.py", "greet")- assert "(Greeter.greet)" in out- assert "def greet" in out-- def test_expand_missing_symbol(self):- out = expand_symbol(PY_SAMPLE, "greeter.py", "does_not_exist")- assert out == "Error: symbol 'does_not_exist' not found in greeter.py"-- def test_expand_unsupported_language(self):- out = expand_symbol("# hello", "readme.md", "anything")- assert out == "Error: unsupported language for readme.md"-- def test_expand_qualified_missing_class(self):- out = expand_symbol(PY_SAMPLE, "greeter.py", "NoSuchClass.greet")- assert "symbol 'NoSuchClass.greet' not found" in out---# ----------------------------------------------------------------------------# filter_code_uris-# -----------------------------------------------------------------------------from types import SimpleNamespace # noqa: E402--from openviking.parse.parsers.code.ast.code_tools import ( # noqa: E402- CODE_SEARCH_FILE_CAP,- filter_code_uris,-)---class TestFilterCodeUris:- def test_keeps_supported_extensions(self):- entries = [- {"uri": "viking://r/a.py", "isDir": False},- {"uri": "viking://r/b.md", "isDir": False},- {"uri": "viking://r/c.ts", "isDir": False},- {"uri": "viking://r/d.txt", "isDir": False},- ]- uris, capped = filter_code_uris(entries)- assert uris == ["viking://r/a.py", "viking://r/c.ts"]- assert capped is False-- def test_skips_directories(self):- entries = [- {"uri": "viking://r/sub", "isDir": True},- {"uri": "viking://r/a.py", "isDir": False},- ]- uris, capped = filter_code_uris(entries)- assert uris == ["viking://r/a.py"]- assert capped is False-- def test_object_entries_snake_case(self):- entries = [- SimpleNamespace(uri="viking://r/a.py", is_dir=False),- SimpleNamespace(uri="viking://r/sub", is_dir=True),- ]- uris, capped = filter_code_uris(entries)- assert uris == ["viking://r/a.py"]- assert capped is False-- def test_exactly_200_not_capped(self):- entries = [{"uri": f"viking://r/f{i}.py", "isDir": False} for i in range(200)]- uris, capped = filter_code_uris(entries)- assert len(uris) == 200- assert capped is False-- def test_201_files_triggers_cap(self):- entries = [{"uri": f"viking://r/f{i}.py", "isDir": False} for i in range(201)]- uris, capped = filter_code_uris(entries)- assert len(uris) == CODE_SEARCH_FILE_CAP- assert capped is True-- def test_empty_entries(self):- uris, capped = filter_code_uris([])- assert uris == []- assert capped is Falsediff --git a/tests/parse/test_directory_scan.py b/tests/parse/test_directory_scan.pyindex 2e4e28954..09f7ca8e8 100644--- a/tests/parse/test_directory_scan.py+++ b/tests/parse/test_directory_scan.py@@ -153,6 +153,26 @@ class TestScanDirectoryClassification:assert "config.yaml" in processable_relassert "src/app.py" in processable_rel+ def test_processable_includes_skeleton_supported_code_extensions(+ self, tmp_path: Path, registry: ParserRegistry+ ) -> None:+ (tmp_path / "infra.tf").write_text('resource "local_file" "demo" {}\n', encoding="utf-8")+ (tmp_path / "module.rkt").write_text(+ "#lang racket\n(define (run x) (+ x 1))\n",+ encoding="utf-8",+ )+ (tmp_path / "request.http").write_text("GET https://example.com\n", encoding="utf-8")+ (tmp_path / "diagram.mmd").write_text("graph TD\n A-->B\n", encoding="utf-8")++ result: DirectoryScanResult = scan_directory(tmp_path, registry=registry, strict=False)++ processable_rel = {f.rel_path for f in result.processable}+ unsupported_rel = {f.rel_path for f in result.unsupported}+ assert "infra.tf" in processable_rel+ assert "module.rkt" in processable_rel+ assert "request.http" in unsupported_rel+ assert "diagram.mmd" in unsupported_rel+def test_unsupported_unknown_ext(self, tmp_tree: Path, registry: ParserRegistry) -> None:result: DirectoryScanResult = scan_directory(tmp_tree, registry=registry, strict=False)unsup_rel = [f.rel_path for f in result.unsupported]diff --git a/tests/parse/test_url_filename_preservation.py b/tests/parse/test_url_filename_preservation.pyindex 4088636c4..20a8693f6 100644--- a/tests/parse/test_url_filename_preservation.py+++ b/tests/parse/test_url_filename_preservation.py@@ -71,6 +71,20 @@ class TestURLTypeDetectorCodeExtensions:url_type, meta = await self.detector.detect(url)assert url_type == URLType.DOWNLOAD_TXT+ @pytest.mark.asyncio+ async def test_ts_extension_defaults_to_video_when_headers_unavailable(self, monkeypatch):+ _patch_httpx_client(+ monkeypatch,+ headers={"content-type": "text/plain"},+ content=b"export const value = 1;\n",+ )++ url_type, meta = await self.detector.detect("https://example.com/path/index.ts")++ assert url_type == URLType.DOWNLOAD_VIDEO+ assert meta["detected_by"] == "extension"+ assert meta["extension"] == ".ts"+@pytest.mark.asyncioasync def test_yaml_extension_detected(self):url = "https://example.com/config.yaml"diff --git a/tests/server/test_api_code.py b/tests/server/test_api_code.pydeleted file mode 100644index 9dabebabb..000000000--- a/tests/server/test_api_code.py+++ /dev/null@@ -1,293 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0-"""Tests for /api/v1/code/* endpoints."""--from openviking_cli.exceptions import PermissionDeniedError--PY_SAMPLE = '''"""Module top doc."""---class Greeter:- def greet(self, who: str) -> str:- return f"Hello {who}"---def make_greeter() -> Greeter:- return Greeter()-'''---# ----------------------------------------------------------------------------# /api/v1/code/outline-# ------------------------------------------------------------------------------class TestCodeOutlineEndpoint:- async def test_success(self, client, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- return PY_SAMPLE-- monkeypatch.setattr(service.fs, "read", fake_read)-- resp = await client.post(- "/api/v1/code/outline", json={"uri": "viking://resources/greeter.py"}- )- assert resp.status_code == 200- body = resp.json()- assert body["status"] == "ok"- assert "class Greeter" in body["result"]- assert "def make_greeter" in body["result"]-- async def test_invalid_uri(self, client):- resp = await client.post("/api/v1/code/outline", json={"uri": "/tmp/foo.py"})- assert resp.status_code == 200- body = resp.json()- assert body["status"] == "ok"- assert body["result"].startswith("Error:")- assert "viking://" in body["result"]-- async def test_read_permission_denied_uses_error_response(self, client, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- raise PermissionDeniedError("denied")-- monkeypatch.setattr(service.fs, "read", fake_read)-- resp = await client.post("/api/v1/code/outline", json={"uri": "viking://resources/x.py"})- assert resp.status_code == 403- body = resp.json()- assert body["status"] == "error"- assert body["error"]["code"] == "PERMISSION_DENIED"-- async def test_unsupported_language(self, client, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- return "# just a markdown heading"-- monkeypatch.setattr(service.fs, "read", fake_read)-- resp = await client.post(- "/api/v1/code/outline", json={"uri": "viking://resources/notes.md"}- )- assert resp.status_code == 200- assert resp.json()["result"].startswith("Error: unsupported language")-- async def test_non_text_content(self, client, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- return b"\x00\x01binary"-- monkeypatch.setattr(service.fs, "read", fake_read)-- resp = await client.post("/api/v1/code/outline", json={"uri": "viking://resources/x.py"})- assert resp.status_code == 200- assert "is not text" in resp.json()["result"]---# ----------------------------------------------------------------------------# /api/v1/code/search-# ------------------------------------------------------------------------------class TestCodeSearchEndpoint:- async def test_success(self, client, service, monkeypatch):- async def fake_ls(uri, ctx=None, recursive=False, output=None, **_):- return [- {"uri": "viking://r/a.py", "isDir": False},- {"uri": "viking://r/sub", "isDir": True},- ]-- async def fake_read(uri, ctx=None, **_):- return PY_SAMPLE-- monkeypatch.setattr(service.fs, "ls", fake_ls)- monkeypatch.setattr(service.fs, "read", fake_read)-- resp = await client.post(- "/api/v1/code/search", json={"uri": "viking://r", "query": "greet"}- )- assert resp.status_code == 200- body = resp.json()- assert body["status"] == "ok"- assert "Greeter" in body["result"]- assert "viking://r/a.py" in body["result"]-- async def test_invalid_uri(self, client):- resp = await client.post("/api/v1/code/search", json={"uri": "/tmp/dir", "query": "foo"})- assert resp.status_code == 200- body = resp.json()- assert body["result"].startswith("Error:")- assert "viking://" in body["result"]-- async def test_empty_query(self, client):- resp = await client.post("/api/v1/code/search", json={"uri": "viking://r", "query": ""})- assert resp.status_code == 200- assert resp.json()["result"] == "Error: empty query"-- async def test_no_code_files(self, client, service, monkeypatch):- async def fake_ls(uri, ctx=None, recursive=False, output=None, **_):- return [{"uri": "viking://r/notes.md", "isDir": False}]-- monkeypatch.setattr(service.fs, "ls", fake_ls)-- resp = await client.post("/api/v1/code/search", json={"uri": "viking://r", "query": "foo"})- assert resp.status_code == 200- assert "No supported source files" in resp.json()["result"]-- async def test_ls_permission_denied_uses_error_response(self, client, service, monkeypatch):- async def fake_ls(uri, ctx=None, recursive=False, output=None, **_):- raise PermissionDeniedError("denied")-- monkeypatch.setattr(service.fs, "ls", fake_ls)-- resp = await client.post("/api/v1/code/search", json={"uri": "viking://r", "query": "foo"})- assert resp.status_code == 403- body = resp.json()- assert body["status"] == "error"- assert body["error"]["code"] == "PERMISSION_DENIED"-- async def test_file_cap_warning(self, client, service, monkeypatch):- async def fake_ls(uri, ctx=None, recursive=False, output=None, **_):- return [{"uri": f"viking://r/f{i}.py", "isDir": False} for i in range(250)]-- async def fake_read(uri, ctx=None, **_):- return PY_SAMPLE-- monkeypatch.setattr(service.fs, "ls", fake_ls)- monkeypatch.setattr(service.fs, "read", fake_read)-- resp = await client.post(- "/api/v1/code/search", json={"uri": "viking://r", "query": "greet"}- )- assert resp.status_code == 200- assert "200-file cap" in resp.json()["result"]-- async def test_partial_read_failure_skipped(self, client, service, monkeypatch):- async def fake_ls(uri, ctx=None, recursive=False, output=None, **_):- return [- {"uri": "viking://r/a.py", "isDir": False},- {"uri": "viking://r/b.py", "isDir": False},- ]-- async def fake_read(uri, ctx=None, **_):- if uri.endswith("b.py"):- raise RuntimeError("denied")- return PY_SAMPLE-- monkeypatch.setattr(service.fs, "ls", fake_ls)- monkeypatch.setattr(service.fs, "read", fake_read)-- resp = await client.post(- "/api/v1/code/search", json={"uri": "viking://r", "query": "greet"}- )- assert resp.status_code == 200- assert "viking://r/a.py" in resp.json()["result"]-- async def test_all_read_failures_reported(self, client, service, monkeypatch):- async def fake_ls(uri, ctx=None, recursive=False, output=None, **_):- return [- {"uri": "viking://r/a.py", "isDir": False},- {"uri": "viking://r/b.py", "isDir": False},- ]-- async def fake_read(uri, ctx=None, **_):- raise RuntimeError("denied")-- monkeypatch.setattr(service.fs, "ls", fake_ls)- monkeypatch.setattr(service.fs, "read", fake_read)-- resp = await client.post(- "/api/v1/code/search", json={"uri": "viking://r", "query": "greet"}- )- assert resp.status_code == 200- assert resp.json()["result"] == (- "Error: failed to read all 2 source files under viking://r"- )---# ----------------------------------------------------------------------------# /api/v1/code/expand-# ------------------------------------------------------------------------------class TestCodeExpandEndpoint:- async def test_success(self, client, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- return PY_SAMPLE-- monkeypatch.setattr(service.fs, "read", fake_read)-- resp = await client.post(- "/api/v1/code/expand",- json={"uri": "viking://r/a.py", "symbol": "make_greeter"},- )- assert resp.status_code == 200- body = resp.json()- assert body["status"] == "ok"- assert "def make_greeter" in body["result"]- assert "(make_greeter)" in body["result"]-- async def test_qualified_symbol(self, client, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- return PY_SAMPLE-- monkeypatch.setattr(service.fs, "read", fake_read)-- resp = await client.post(- "/api/v1/code/expand",- json={"uri": "viking://r/a.py", "symbol": "Greeter.greet"},- )- assert resp.status_code == 200- assert "def greet" in resp.json()["result"]-- async def test_invalid_uri(self, client):- resp = await client.post("/api/v1/code/expand", json={"uri": "/tmp/x.py", "symbol": "foo"})- assert resp.status_code == 200- body = resp.json()- assert body["result"].startswith("Error:")- assert "viking://" in body["result"]-- async def test_empty_symbol(self, client):- resp = await client.post(- "/api/v1/code/expand", json={"uri": "viking://r/x.py", "symbol": ""}- )- assert resp.status_code == 200- assert resp.json()["result"] == "Error: empty symbol"-- async def test_missing_symbol(self, client, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- return PY_SAMPLE-- monkeypatch.setattr(service.fs, "read", fake_read)-- resp = await client.post(- "/api/v1/code/expand",- json={"uri": "viking://r/a.py", "symbol": "nonexistent"},- )- assert resp.status_code == 200- assert "not found" in resp.json()["result"]-- async def test_read_permission_denied_uses_error_response(self, client, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- raise PermissionDeniedError("denied")-- monkeypatch.setattr(service.fs, "read", fake_read)-- resp = await client.post(- "/api/v1/code/expand",- json={"uri": "viking://r/a.py", "symbol": "Greeter"},- )- assert resp.status_code == 403- body = resp.json()- assert body["status"] == "error"- assert body["error"]["code"] == "PERMISSION_DENIED"-- async def test_non_text_content(self, client, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- return b"\x00binary"-- monkeypatch.setattr(service.fs, "read", fake_read)-- resp = await client.post(- "/api/v1/code/expand",- json={"uri": "viking://r/a.py", "symbol": "Greeter"},- )- assert resp.status_code == 200- assert "is not text" in resp.json()["result"]diff --git a/tests/server/test_mcp_endpoint_code.py b/tests/server/test_mcp_endpoint_code.pydeleted file mode 100644index fa5df16f2..000000000--- a/tests/server/test_mcp_endpoint_code.py+++ /dev/null@@ -1,375 +0,0 @@-# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.-# SPDX-License-Identifier: AGPL-3.0--"""Tests for the code-navigation MCP tools (code_outline / code_search /-code_expand) in openviking/server/mcp_endpoint.py.--The pure formatters in openviking.parse.parsers.code.ast.code_tools are-covered by tests/parse/test_code_tools.py. These tests cover the MCP wiring:-URI validation, service.fs.read / service.fs.ls plumbing, extension filtering,-the 200-file cap, and error mapping.-"""--from types import SimpleNamespace--import pytest--from openviking.server.dependencies import set_service-from openviking.server.identity import RequestContext, Role-from openviking.server.mcp_endpoint import (- _filter_code_uris,- _mcp_ctx,- _require_viking_uri,- code_expand,- code_outline,- code_search,-)-from openviking_cli.session.user_id import UserIdentifier--DEFAULT_CTX = RequestContext(- user=UserIdentifier.the_default_user("test_user"),- role=Role.ROOT,-)---PY_SAMPLE = '''"""Module top doc."""---class Greeter:- def greet(self, who: str) -> str:- return f"Hello {who}"---def make_greeter() -> Greeter:- return Greeter()-'''--[email protected](autouse=True)-def _set_mcp_identity(service):- """Set identity contextvar and wire service for all tests."""- set_service(service)- token = _mcp_ctx.set(DEFAULT_CTX)- yield- _mcp_ctx.reset(token)---def _patch_fs(monkeypatch, service, *, read=None, ls=None):- """Replace service.fs.read / .ls with async fakes."""- if read is not None:- monkeypatch.setattr(service.fs, "read", read)- if ls is not None:- monkeypatch.setattr(service.fs, "ls", ls)---# ----------------------------------------------------------------------------# _require_viking_uri (internal helper, but small contract worth pinning)-# ------------------------------------------------------------------------------class TestRequireVikingUri:- def test_accepts_viking_uri(self):- assert _require_viking_uri("viking://resources/foo.py") is None-- def test_rejects_local_path(self):- msg = _require_viking_uri("/tmp/foo.py")- assert msg is not None- assert "viking://" in msg-- def test_rejects_http_url(self):- msg = _require_viking_uri("https://example.com/foo.py")- assert msg is not None-- def test_rejects_non_string(self):- assert _require_viking_uri(None) is not None # type: ignore[arg-type]---# ----------------------------------------------------------------------------# _filter_code_uris-# ------------------------------------------------------------------------------class TestFilterCodeUris:- def test_keeps_supported_extensions(self):- entries = [- {"uri": "viking://r/a.py", "isDir": False},- {"uri": "viking://r/b.md", "isDir": False},- {"uri": "viking://r/c.ts", "isDir": False},- {"uri": "viking://r/d.txt", "isDir": False},- ]- uris, capped = _filter_code_uris(entries)- assert uris == ["viking://r/a.py", "viking://r/c.ts"]- assert capped is False-- def test_skips_directories(self):- entries = [- {"uri": "viking://r/sub", "isDir": True},- {"uri": "viking://r/a.py", "isDir": False},- ]- uris, capped = _filter_code_uris(entries)- assert uris == ["viking://r/a.py"]- assert capped is False-- def test_supports_object_entries(self):- entries = [- SimpleNamespace(uri="viking://r/a.py", is_dir=False),- SimpleNamespace(uri="viking://r/sub", is_dir=True),- ]- uris, capped = _filter_code_uris(entries)- assert uris == ["viking://r/a.py"]- assert capped is False-- def test_caps_at_200(self):- entries = [{"uri": f"viking://r/f{i}.py", "isDir": False} for i in range(250)]- uris, capped = _filter_code_uris(entries)- assert len(uris) == 200- assert capped is True-- def test_exactly_200_not_capped(self):- entries = [{"uri": f"viking://r/f{i}.py", "isDir": False} for i in range(200)]- uris, capped = _filter_code_uris(entries)- assert len(uris) == 200- assert capped is False---# ----------------------------------------------------------------------------# code_outline-# ------------------------------------------------------------------------------class TestCodeOutline:- async def test_rejects_non_viking_uri(self, service):- out = await code_outline("/tmp/foo.py")- assert "viking://" in out-- async def test_outline_via_fs_read(self, service, monkeypatch):- captured = {}-- async def fake_read(uri, ctx=None, **_):- captured["uri"] = uri- captured["ctx"] = ctx- return PY_SAMPLE-- _patch_fs(monkeypatch, service, read=fake_read)-- out = await code_outline("viking://resources/greeter.py")- assert captured["uri"] == "viking://resources/greeter.py"- assert captured["ctx"] == DEFAULT_CTX- assert "class Greeter" in out- assert "def make_greeter" in out- assert " L" in out # line spans rendered-- async def test_unsupported_language_returns_sentinel(self, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- return "# heading"-- _patch_fs(monkeypatch, service, read=fake_read)- out = await code_outline("viking://resources/notes.md")- assert out.startswith("Error: unsupported language")-- async def test_read_failure(self, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- raise RuntimeError("boom")-- _patch_fs(monkeypatch, service, read=fake_read)- out = await code_outline("viking://resources/x.py")- assert out.startswith("Error: failed to read")- assert "boom" in out-- async def test_non_text_content(self, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- return b"\x00\x01binary"-- _patch_fs(monkeypatch, service, read=fake_read)- out = await code_outline("viking://resources/x.py")- assert out.endswith("is not text")---# ----------------------------------------------------------------------------# code_search-# ------------------------------------------------------------------------------class TestCodeSearch:- async def test_rejects_non_viking_uri(self, service):- out = await code_search("foo", "/tmp/dir")- assert "viking://" in out-- async def test_empty_query(self, service):- out = await code_search("", "viking://resources")- assert out == "Error: empty query"-- async def test_lists_and_searches(self, service, monkeypatch):- ls_calls = {}- read_uris: list[str] = []-- async def fake_ls(uri, ctx=None, recursive=False, output=None, **_):- ls_calls["uri"] = uri- ls_calls["ctx"] = ctx- ls_calls["recursive"] = recursive- ls_calls["output"] = output- return [- {"uri": "viking://r/a.py", "isDir": False},- {"uri": "viking://r/sub", "isDir": True},- {"uri": "viking://r/b.md", "isDir": False},- {"uri": "viking://r/c.py", "isDir": False},- ]-- async def fake_read(uri, ctx=None, **_):- read_uris.append(uri)- if uri.endswith("a.py"):- return PY_SAMPLE- if uri.endswith("c.py"):- return "def other():\n pass\n"- return ""-- _patch_fs(monkeypatch, service, ls=fake_ls, read=fake_read)-- out = await code_search("greet", "viking://r")- assert ls_calls["recursive"] is True- assert ls_calls["output"] == "original"- assert ls_calls["ctx"] == DEFAULT_CTX- # b.md must be filtered out before any read happens- assert "viking://r/b.md" not in read_uris- assert set(read_uris) == {"viking://r/a.py", "viking://r/c.py"}- # search hits Greeter + Greeter.greet in a.py- assert "viking://r/a.py" in out- assert "Greeter" in out-- async def test_empty_directory(self, service, monkeypatch):- async def fake_ls(uri, ctx=None, recursive=False, output=None, **_):- return []-- _patch_fs(monkeypatch, service, ls=fake_ls)- out = await code_search("greet", "viking://empty")- assert "No supported source files" in out-- async def test_no_code_files(self, service, monkeypatch):- async def fake_ls(uri, ctx=None, recursive=False, output=None, **_):- return [{"uri": "viking://r/notes.md", "isDir": False}]-- _patch_fs(monkeypatch, service, ls=fake_ls)- out = await code_search("greet", "viking://r")- assert "No supported source files" in out-- async def test_ls_failure(self, service, monkeypatch):- async def fake_ls(uri, ctx=None, recursive=False, output=None, **_):- raise RuntimeError("ls denied")-- _patch_fs(monkeypatch, service, ls=fake_ls)- out = await code_search("greet", "viking://r")- assert out.startswith("Error: failed to list")- assert "ls denied" in out-- async def test_read_failures_are_skipped(self, service, monkeypatch):- async def fake_ls(uri, ctx=None, recursive=False, output=None, **_):- return [- {"uri": "viking://r/a.py", "isDir": False},- {"uri": "viking://r/b.py", "isDir": False},- ]-- async def fake_read(uri, ctx=None, **_):- if uri.endswith("b.py"):- raise RuntimeError("denied")- return PY_SAMPLE-- _patch_fs(monkeypatch, service, ls=fake_ls, read=fake_read)- out = await code_search("greet", "viking://r")- # Search should still report the matches from a.py despite b.py failing.- assert "viking://r/a.py" in out- assert "Greeter" in out-- async def test_file_cap_warning(self, service, monkeypatch):- async def fake_ls(uri, ctx=None, recursive=False, output=None, **_):- return [{"uri": f"viking://r/f{i}.py", "isDir": False} for i in range(250)]-- async def fake_read(uri, ctx=None, **_):- return PY_SAMPLE-- _patch_fs(monkeypatch, service, ls=fake_ls, read=fake_read)- out = await code_search("greet", "viking://r")- assert "200-file cap" in out-- async def test_no_cap_warning_below_threshold(self, service, monkeypatch):- async def fake_ls(uri, ctx=None, recursive=False, output=None, **_):- return [{"uri": "viking://r/a.py", "isDir": False}]-- async def fake_read(uri, ctx=None, **_):- return PY_SAMPLE-- _patch_fs(monkeypatch, service, ls=fake_ls, read=fake_read)- out = await code_search("greet", "viking://r")- assert "200-file cap" not in out---# ----------------------------------------------------------------------------# code_expand-# ------------------------------------------------------------------------------class TestCodeExpand:- async def test_rejects_non_viking_uri(self, service):- out = await code_expand("/tmp/foo.py", "Greeter")- assert "viking://" in out-- async def test_empty_symbol(self, service):- out = await code_expand("viking://r/a.py", "")- assert out == "Error: empty symbol"-- async def test_expand_bare_symbol(self, service, monkeypatch):- captured = {}-- async def fake_read(uri, ctx=None, **_):- captured["uri"] = uri- captured["ctx"] = ctx- return PY_SAMPLE-- _patch_fs(monkeypatch, service, read=fake_read)- out = await code_expand("viking://r/a.py", "make_greeter")- assert captured["uri"] == "viking://r/a.py"- assert captured["ctx"] == DEFAULT_CTX- assert "(make_greeter)" in out- assert "def make_greeter" in out-- async def test_expand_qualified_symbol(self, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- return PY_SAMPLE-- _patch_fs(monkeypatch, service, read=fake_read)- out = await code_expand("viking://r/a.py", "Greeter.greet")- assert "(Greeter.greet)" in out- assert "def greet" in out-- async def test_missing_symbol(self, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- return PY_SAMPLE-- _patch_fs(monkeypatch, service, read=fake_read)- out = await code_expand("viking://r/a.py", "does_not_exist")- assert "not found" in out- assert "does_not_exist" in out-- async def test_read_failure(self, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- raise RuntimeError("boom")-- _patch_fs(monkeypatch, service, read=fake_read)- out = await code_expand("viking://r/a.py", "Greeter")- assert out.startswith("Error: failed to read")- assert "boom" in out-- async def test_non_text_content(self, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- return b"\x00binary"-- _patch_fs(monkeypatch, service, read=fake_read)- out = await code_expand("viking://r/a.py", "Greeter")- assert out.endswith("is not text")-- async def test_unsupported_language(self, service, monkeypatch):- async def fake_read(uri, ctx=None, **_):- return "# heading"-- _patch_fs(monkeypatch, service, read=fake_read)- out = await code_expand("viking://r/notes.md", "anything")- assert out.startswith("Error: unsupported language")diff --git a/tests/session/test_memory_batching.py b/tests/session/test_memory_batching.pyindex 211a6912e..7cbaa7bb6 100644--- a/tests/session/test_memory_batching.py+++ b/tests/session/test_memory_batching.py@@ -81,7 +81,6 @@ async def test_manual_memory_batching_100_files(monkeypatch):mock_config.semantic.abstract_max_chars = 256mock_config.semantic.overview_max_chars = 4000mock_config.semantic.max_concurrent_llm = 10- mock_config.code.code_summary_mode = "llm"# 2. 模拟 AGFS/VikingFS 中的 100 个文件class MockVikingFS:diff --git a/tests/storage/test_semantic_processor_code_routing.py b/tests/storage/test_semantic_processor_code_routing.pynew file mode 100644index 000000000..8ae77de0f--- /dev/null+++ b/tests/storage/test_semantic_processor_code_routing.py@@ -0,0 +1,142 @@+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.+# SPDX-License-Identifier: Apache-2.0++import asyncio+from unittest.mock import AsyncMock, MagicMock, patch++import pytest++from openviking.parse.parsers.constants import (+ FILE_TYPE_CODE,+ FILE_TYPE_DOCUMENTATION,+ FILE_TYPE_OTHER,+)+from openviking.parse.parsers.code.ast import SkeletonExtractionResult+from openviking.parse.parsers.media.utils import get_media_type+from openviking.storage.queuefs.semantic_processor import SemanticProcessor+++def _config(vlm_available: bool = True):+ config = MagicMock()+ config.output_language_override = ""+ config.semantic.max_file_content_chars = 10000+ config.semantic.max_skeleton_chars = 10000+ config.vlm.is_available.return_value = vlm_available+ config.vlm.get_completion_async = AsyncMock(return_value="LLM summary")+ return config+++async def _generate(extraction=None, vlm_available=True):+ config = _config(vlm_available)+ fs = MagicMock()+ fs.read_file = AsyncMock(return_value="def run():\n return 1\n")+ patches = [+ patch(+ "openviking.storage.queuefs.semantic_processor.get_openviking_config",+ return_value=config,+ ),+ patch(+ "openviking.storage.queuefs.semantic_processor.get_viking_fs",+ return_value=fs,+ ),+ ]+ if extraction is not None:+ patches.append(+ patch(+ "openviking.parse.parsers.code.ast.extract_skeleton_result",+ return_value=extraction,+ )+ )++ with patches[0], patches[1]:+ if extraction is None:+ result = await SemanticProcessor()._generate_text_summary(+ "viking://resources/sample.py",+ "sample.py",+ asyncio.Semaphore(1),+ )+ else:+ with patches[2]:+ result = await SemanticProcessor()._generate_text_summary(+ "viking://resources/sample.py",+ "sample.py",+ asyncio.Semaphore(1),+ )+ return result, config+++async def test_useful_skeleton_skips_llm_even_when_vlm_unavailable():+ extraction = SkeletonExtractionResult(+ text="# sample.py [Python]\n\ndef run()",+ provider="process",+ should_fallback_to_llm=False,+ reason="process extraction succeeded",+ )+ result, config = await _generate(extraction, vlm_available=False)+ assert result["summary"] == extraction.text+ config.vlm.get_completion_async.assert_not_awaited()+++async def test_missing_skeleton_calls_llm_fallback():+ extraction = SkeletonExtractionResult(+ text=None,+ provider="llm",+ should_fallback_to_llm=True,+ reason="unsupported",+ )+ result, config = await _generate(extraction)+ assert result["summary"] == "LLM summary"+ config.vlm.get_completion_async.assert_awaited_once()+++async def test_missing_skeleton_without_vlm_returns_empty_summary():+ extraction = SkeletonExtractionResult(+ text=None,+ provider="llm",+ should_fallback_to_llm=True,+ reason="unsupported",+ )+ result, config = await _generate(extraction, vlm_available=False)+ assert result["summary"] == ""+ config.vlm.get_completion_async.assert_not_awaited()+++def test_cuda_extensions_are_dispatched_as_code():+ processor = SemanticProcessor()+ assert processor._detect_file_type("kernel.cu") == FILE_TYPE_CODE+ assert processor._detect_file_type("common.cuh") == FILE_TYPE_CODE+++def test_documentation_extensions_are_dispatched_before_code_skeleton_support():+ processor = SemanticProcessor()+ with patch(+ "openviking.parse.parsers.code.ast.providers.supports_code_skeleton",+ return_value=True,+ ):+ assert processor._detect_file_type("README.md") == FILE_TYPE_DOCUMENTATION+++def test_process_supported_extensions_are_dispatched_as_code():+ processor = SemanticProcessor()+ assert processor._detect_file_type("main.tf") == FILE_TYPE_CODE+++def test_process_denied_non_code_formats_are_not_dispatched_as_code():+ processor = SemanticProcessor()+ assert processor._detect_file_type("request.http") == FILE_TYPE_OTHER+++def test_legacy_code_extensions_remain_fallback_when_skeleton_is_unsupported():+ processor = SemanticProcessor()+ with patch(+ "openviking.parse.parsers.code.ast.providers.supports_code_skeleton",+ return_value=False,+ ):+ assert processor._detect_file_type("sample.py") == FILE_TYPE_CODE+++def test_plain_ts_extension_is_not_dispatched_as_video():+ assert get_media_type("viking://resources/sample.ts", None) is Nonediff --git a/tests/storage/test_semantic_processor_language.py b/tests/storage/test_semantic_processor_language.pyindex 0ec37af99..f87ed5adc 100644--- a/tests/storage/test_semantic_processor_language.py+++ b/tests/storage/test_semantic_processor_language.py@@ -350,19 +350,15 @@ class TestGenerateTextSummaryOutputLanguage:def _create_mock_config(self, mock_vlm: LanguageAwareMockVLM) -> MagicMock:mock_config = MagicMock()mock_config.vlm = mock_vlm+ mock_config.output_language_override = ""mock_config.language_fallback = "en"mock_config.semantic.max_file_content_chars = 10000- mock_config.code.code_summary_mode = "llm"return mock_config@pytest.mark.asyncio@pytest.mark.parametrize("file_key,file_name,expected_lang",[- ("chinese_py", "chinese_code.py", "zh-CN"),- ("english_py", "english_code.py", "en"),- ("japanese_py", "japanese_code.py", "ja"),- ("korean_py", "korean_code.py", "ko"),("chinese_md", "chinese_doc.md", "zh-CN"),("english_md", "english_doc.md", "en"),],@@ -515,7 +511,13 @@ class TestOutputLanguageOverride:def test_timezone_hint_used_when_locale_hint_absent(self):config = self._make_config(override="")- with patch.dict(os.environ, {"TZ": "Asia/Tokyo"}, clear=True):+ with (+ patch.dict(os.environ, {"TZ": "Asia/Tokyo"}, clear=True),+ patch(+ "openviking.session.memory.utils.language.locale.getlocale",+ return_value=("C", "UTF-8"),+ ),+ ):result = resolve_output_language("12345 ---", config=config)assert result == "ja"@@ -562,13 +564,25 @@ class TestOutputLanguageOverride:def test_english_timezone_hint_used_when_locale_hint_absent(self):config = self._make_config(override="")- with patch.dict(os.environ, {"TZ": "America/New_York"}, clear=True):+ with (+ patch.dict(os.environ, {"TZ": "America/New_York"}, clear=True),+ patch(+ "openviking.session.memory.utils.language.locale.getlocale",+ return_value=("C", "UTF-8"),+ ),+ ):result = resolve_output_language("12345 ---", config=config)assert result == "en"def test_arabic_timezone_hint_used_when_locale_hint_absent(self):config = self._make_config(override="")- with patch.dict(os.environ, {"TZ": "Asia/Riyadh"}, clear=True):+ with (+ patch.dict(os.environ, {"TZ": "Asia/Riyadh"}, clear=True),+ patch(+ "openviking.session.memory.utils.language.locale.getlocale",+ return_value=("C", "UTF-8"),+ ),+ ):result = resolve_output_language("12345 ---", config=config)assert result == "ar"diff --git a/tests/test_config_loader.py b/tests/test_config_loader.pyindex d14c1ebdd..71393826c 100644--- a/tests/test_config_loader.py+++ b/tests/test_config_loader.py@@ -269,6 +269,30 @@ def test_openviking_config_ignores_deprecated_agent_memory_enabled(monkeypatch):OpenVikingConfigSingleton.reset_instance()+def test_openviking_config_ignores_deprecated_code_summary_mode(monkeypatch):+ monkeypatch.setenv(OPENVIKING_CONFIG_ENV, "/tmp/codex-no-config.json")++ from openviking_cli.utils.config import parser_config+ from openviking_cli.utils.config.open_viking_config import (+ OpenVikingConfig,+ OpenVikingConfigSingleton,+ )++ warnings: list[str] = []+ monkeypatch.setattr(+ parser_config.logger,+ "warning",+ lambda message, *args, **kwargs: warnings.append(message % args if args else message),+ )++ config = OpenVikingConfig.from_dict({"code": {"code_summary_mode": "llm"}})++ assert not hasattr(config.code, "code_summary_mode")+ assert any("code.code_summary_mode is deprecated and ignored" in item for item in warnings)++ OpenVikingConfigSingleton.reset_instance()++def test_openviking_config_retrieval_hotness_alpha_defaults_to_zero(monkeypatch):monkeypatch.setenv(OPENVIKING_CONFIG_ENV, "/tmp/codex-no-config.json")diff --git a/tests/unit/test_vectorize_file_strategy.py b/tests/unit/test_vectorize_file_strategy.pyindex 8367db427..d1717a88f 100644--- a/tests/unit/test_vectorize_file_strategy.py+++ b/tests/unit/test_vectorize_file_strategy.py@@ -98,6 +98,11 @@ def test_get_resource_content_type_media_extensions_are_case_insensitive():assert embedding_utils.get_resource_content_type("RECORDING.WEBM") == ResourceContentType.VIDEO[email protected]("extension", [".cu", ".cuh"])+def test_get_resource_content_type_recognizes_cuda_extensions_as_text(extension):+ assert embedding_utils.get_resource_content_type(f"kernel{extension}") == ResourceContentType.TEXT++def test_get_resource_content_type_keeps_ts_as_text():assert embedding_utils.get_resource_content_type("source.ts") == ResourceContentType.TEXTdiff --git a/uv.lock b/uv.lockindex 32eb239eb..17d7c4f73 100644--- a/uv.lock+++ b/uv.lock@@ -1669,6 +1669,19 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/29/4b/45d90626aef8e65336bed690106d1382f7a43665e2249017e9527df8823b/greenlet-3.3.2-cp314-cp314t-win_amd64.whl", hash = "sha256:c04c5e06ec3e022cbfe2cd4a846e1d4e50087444f875ff6d2c2ad8445495cf1a", size = 237086, upload-time = "2026-02-20T20:20:45.786Z" },]+[[package]]+name = "grep-ast"+version = "0.9.0"+source = { registry = "https://pypi.org/simple" }+dependencies = [+ { name = "pathspec" },+ { name = "tree-sitter-language-pack" },+]+sdist = { url = "https://files.pythonhosted.org/packages/67/82/a87079945a7c15d242cb586ae22e17952132439eaa9c878ec5fbdc61c54d/grep_ast-0.9.0.tar.gz", hash = "sha256:620a242a4493e6721338d1c9a6c234ae651f8774f4924a6dcf90f6865d4b2ee3", size = 14125, upload-time = "2025-05-08T01:08:28.371Z" }+wheels = [+ { url = "https://files.pythonhosted.org/packages/40/79/29f1373b2ce1eec37c03aefbc17194c2470d8b61ede288e5043231825999/grep_ast-0.9.0-py3-none-any.whl", hash = "sha256:a3973dca99f1abc026a01bbbc70e00a63860c8ff94a56182ff18b089836826d7", size = 13918, upload-time = "2025-05-08T01:08:27.481Z" },+]+[[package]]name = "groovy"version = "0.1.2"@@ -3618,6 +3631,7 @@ dependencies = [{ name = "ebooklib" },{ name = "fastapi" },{ name = "feedparser" },+ { name = "grep-ast" },{ name = "httpx" },{ name = "jinja2" },{ name = "json-repair" },@@ -3653,6 +3667,7 @@ dependencies = [{ name = "tree-sitter-go" },{ name = "tree-sitter-java" },{ name = "tree-sitter-javascript" },+ { name = "tree-sitter-language-pack" },{ name = "tree-sitter-lua" },{ name = "tree-sitter-php" },{ name = "tree-sitter-python" },@@ -3808,6 +3823,7 @@ requires-dist = [{ name = "google-genai", marker = "extra == 'gemini'", specifier = ">=1.0.0" },{ name = "google-genai", marker = "extra == 'gemini-async'", specifier = ">=1.0.0" },{ name = "gradio", marker = "extra == 'bot'", specifier = ">=6.6.0" },+ { name = "grep-ast", specifier = ">=0.9.0" },{ name = "html2text", marker = "extra == 'bot'", specifier = ">=2020.1.16" },{ name = "httpx", specifier = ">=0.25.0" },{ name = "httpx", extras = ["socks"], marker = "extra == 'bot'", specifier = ">=0.25.0" },@@ -3895,6 +3911,7 @@ requires-dist = [{ name = "tree-sitter-go", specifier = ">=0.23.0" },{ name = "tree-sitter-java", specifier = ">=0.23.0" },{ name = "tree-sitter-javascript", specifier = ">=0.23.0" },+ { name = "tree-sitter-language-pack", specifier = ">=1.12,<2.0" },{ name = "tree-sitter-lua", specifier = ">=0.1.0" },{ name = "tree-sitter-php", specifier = ">=0.23.0" },{ name = "tree-sitter-python", specifier = ">=0.23.0" },@@ -6552,6 +6569,23 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/2e/1f/f9eba1038b7d4394410f3c0a6ec2122b590cd7acb03f196e52fa57ebbe72/tree_sitter_javascript-0.25.0-cp310-abi3-win_arm64.whl", hash = "sha256:622a69d677aa7f6ee2931d8c77c981a33f0ebb6d275aa9d43d3397c879a9bb0b", size = 61668, upload-time = "2025-09-01T07:13:43.803Z" },]+[[package]]+name = "tree-sitter-language-pack"+version = "1.13.3"+source = { registry = "https://pypi.org/simple" }+dependencies = [+ { name = "tree-sitter" },+]+sdist = { url = "https://files.pythonhosted.org/packages/cb/9e/01be7a94fc69204350dc99707730aa4f32906cdb8b0b5856ff43fd0c60d5/tree_sitter_language_pack-1.13.3.tar.gz", hash = "sha256:e0e0287bf5a2f3d8a382136b1565206988417ece502b796f4b6f7fefb832963c", size = 82100, upload-time = "2026-07-21T14:10:20.469Z" }+wheels = [+ { url = "https://files.pythonhosted.org/packages/75/a0/69ac382a8e610a2e521fd1c661a59127b5387fad8789355c9fa60b27765a/tree_sitter_language_pack-1.13.3-cp310-abi3-macosx_10_12_x86_64.whl", hash = "sha256:9229a14185583a0acfd9946154d491908078cc7a54150bf03268aed5a67cf3c3", size = 2141847, upload-time = "2026-07-21T14:10:11.626Z" },+ { url = "https://files.pythonhosted.org/packages/bb/57/24ea7493d5704fcce545707732c652d7fd1cbe82c6f824cdc26554124069/tree_sitter_language_pack-1.13.3-cp310-abi3-macosx_11_0_arm64.whl", hash = "sha256:8435aabc1e5537e97e0a5893b6bf8d501ee7e55f93ee813e98711c5787fdbf78", size = 2033141, upload-time = "2026-07-21T14:10:13.131Z" },+ { url = "https://files.pythonhosted.org/packages/4e/02/b476c812681922ac2763100aeb98040b880e6fae9bf5960068fb5652356d/tree_sitter_language_pack-1.13.3-cp310-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:3096595f83c3ad1c8cdace1db737e074f4ef3c798534deb2fe758acda0d7e211", size = 2190490, upload-time = "2026-07-21T14:10:14.66Z" },+ { url = "https://files.pythonhosted.org/packages/6e/f8/bfb863ffd53eb888308ffebeb9f73ed24bda0eac10393b9ec1b6774abe06/tree_sitter_language_pack-1.13.3-cp310-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:ebcd8fa9435ff956bd82eeea21f492fb2ccfefd9be909fe5cdebabb892c4b034", size = 2301379, upload-time = "2026-07-21T14:10:16.147Z" },+ { url = "https://files.pythonhosted.org/packages/5b/32/5a395972eee620b763493f6abf527dd76dea0cef91010ab348137cb51a2d/tree_sitter_language_pack-1.13.3-cp310-abi3-win_amd64.whl", hash = "sha256:c67c322370c30fa802e01532933709d0c29de8337d911eb693692a996993e55d", size = 2076066, upload-time = "2026-07-21T14:10:17.614Z" },+ { url = "https://files.pythonhosted.org/packages/ff/56/b2cbaaaadbcadc90355f3bc7ecf9bb9f842ffd328ee9fb6b33518c93c360/tree_sitter_language_pack-1.13.3-cp310-abi3-win_arm64.whl", hash = "sha256:49eb4d6f532556076a885b36aab51919ae6ab396401144e4f73e4a0c9ead0219", size = 1987435, upload-time = "2026-07-21T14:10:19.367Z" },+]+[[package]]name = "tree-sitter-lua"version = "0.5.0"