Skip to content

AtomCode v5.0.9 新子系统深度分析 — CodeIntel 代码智能六件套与 LSP 集成 ​

基于 strings 工具契约 + 模块枚举 + LSP 协议串 + 类型元数据的还原分析 2026-09-09 前置报告:05-version-diff-v4.25.5-to-v5.0.9.md 姊妹报告:42_Review_Assembly_Scope_Confinement.md(code-graph 在 review 内的引导使用)


1. 源码模块(全新) ​

crates/atomcode-capabilities/src/codeintel/
  ├── index.rs                ← 符号索引(后台构建)
  ├── symbols.rs              ← 符号模型
  ├── list_symbols.rs         ← 列出源文件内符号
  ├── read_symbol.rs          ← 读取符号定义
  ├── find_references.rs      ← 全项目引用查找
  ├── trace_callers.rs        ← 反向调用图
  ├── trace_callees.rs        ← 正向调用图
  ├── trace_chain.rs          ← 两点最短调用链
  ├── blast_radius.rs         ← 爆炸半径(文件级影响面)
  ├── file_deps.rs            ← 文件依赖图
  ├── lsp_tool.rs             ← LSP 工具封装
  └── lsp/
      ├── client.rs           ← LSP 客户端
      ├── jsonrpc.rs          ← JSON-RPC 编解码
      └── manager.rs          ← LSP 服务器生命周期管理

→ 14 个模块的代码智能子系统(CodeIntel),与 DEEP_ANALYSIS_14 的旧 CodeGraph 同族升级。


2. 符号索引(index.rs / symbols.rs) ​

2.1 索引状态机 ​

indexed source file(s) > <N>          ← 已索引源文件数
<M> symbols indexed                   ← 已索引符号数
no symbol index for <file>            ← 该文件无索引(fallback 提示)
<symbol> not found in the code graph (no indexed symbols)
<symbol> found in code graph
[codeintel]                            ← 日志前缀

→ 后台惰性索引:源文件级 + 符号级两级计数;无索引时工具链给出明确 fallback。

2.2 查询语义 ​

File path relative to the workspace or absolute path.
Symbol name to read
Target symbol name

→ 工具统一路径解析(workspace 相对 | 绝对)。


3. 六件套工具契约(逐字还原) ​

工具语义参数
list_symbols列出源文件内函数/类/结构体/方法及行区间file_path
read_symbol读取符号定义体symbol (+file_path)
find_references全项目整词匹配引用查找symbol
trace_callers反向调用图(BFS 深度)symbol
trace_callees正向调用图(BFS 深度)symbol
trace_chain两符号最短调用链(BFS max 10 跳)from/to
blast_radius文件级爆炸半径(影响面)file
file_dependencies文件依赖图file

3.1 工具自描述 ​

List the functions, classes, structs, methods and other symbols defined in a
source file, each with its line range. Faster and more precise than read_file
for understanding a file.
Trace all callers of a symbol (reverse call graph), BFS up to a depth. Shows
the caller chain with ...
Trace all callees of a symbol (forward call graph), BFS up to a depth. Shows
the callee chain with ...
Find the shortest call chain between two symbols (BFS, max 10 hops). ...
Find all references to a symbol (function/class/variable) across the project
as whole-word textual match ...

→ list_symbols 明确优于 read_file(行区间 + 符号粒度); trace_chain 是图算法(BFS,max 10 跳);find_references 为整词文本匹配。

3.2 参数校验错误串 ​

list_symbols: invalid arguments:
read_symbol: invalid arguments:
find_references: invalid arguments:
trace_chain: invalid arguments:
blast_radius: invalid arguments:
file_dependencies: invalid arguments:

3.3 运行失败串 ​

list_symbols: task failed
read_symbol: task failed / read_symbol: cannot read <path>
find_references: task failed / find_references: path not found:
trace_callers: task failed / trace_callees: task failed / trace_chain: task failed
blast_radius: task failed / file_dependencies: task failed
read_symbol: failed to parse

4. 工具 UI 面映射(confine 联动) ​

case `list_symbols`: return `file`
case `read_symbol`: return `file`
case `file_dependencies`: return `file`
case `find_references`: return `search`
case `trace_chain`: return `search`
case `blast_radius`: return `search`

→ 工具被分类为 file / search 两组,供 UI 展示 + review 的 confine 白名单复用 (与 42 号报告 confine.rs 的允许面一致)。


5. LSP 集成(lsp/ 子模块) ​

5.1 服务器映射 ​

rust-analyzer --stdio          ← Rust
typescript-language-server     ← TypeScript/JS
pylsp (serve)                  ← Python
gopls                          ← Go
jdtls                          ← Java
clangd                         ← C/C++
(javascriptreact / typescriptreact / typescript)← 前端变体

5.2 协议面(LSP 客户端能力) ​

rootUri / general / positionEncodings / configuration
applyEdit / publishDiagnostics / relatedInformation
synchronization / didOpen / didChange
definition / dynamicRegistration / references / hover / diagnostic
atomcode-capabilities    ← LSP 客户端标识
textDocument/publishDiagnostics

→ 完整 LSP 客户端:文档同步、定义跳转、引用、hover、诊断订阅。

5.3 生命周期与错误 ​

initialized
language server stream closed / LSP stream closed
Content-Length: / LSP message: no Content-Length    ← JSON-RPC 帧解析
LSP document sync cancelled
language server startup cancelled
file has no supported extension
lsp: file must be inside the workspace:

→ Content-Length 帧协议(LSP 传输层);workspace 边界 + 扩展名白名单。

5.4 降级策略 ​

[LSP unavailable] fall back to read_symbol/find_references/search instead of retrying.

→ LSP 不可用自动降级到符号索引 / 引用 / 搜索,不阻塞工具链。


6. 与既有系统的关系 ​

系统关系
DEEP_ANALYSIS_14 CodeGraph旧版语义分析器(tree-sitter 表达式/语句)→ 本子系统为升级版符号+调用图
DEEP_ANALYSIS_39 file_index文件索引 → 本子系统为符号级索引(更细粒度)
DEEP_ANALYSIS_42 impact_plan直接消费 code-graph 工具做确定性影响面规划
DEEP_ANALYSIS_11 LspConfig配置面(服务器白名单/扩展名映射)

7. 逆向方法论备注 ​

  1. codeintel/lsp/client.rs 等 14 个模块路径 = 子系统边界的直接证据
  2. list_symbols 工具描述强调"faster than read_file" → 明确性能设计意图
  3. Content-Length: + no Content-Length 暴露 LSP JSON-RPC 帧协议
  4. rust-analyzer --stdio/pylsp serve 等二进制名 = 语言服务器映射表
  5. fall back to read_symbol/find_references/search 揭示多层降级链
  6. returnfile/`return`search 的 UI 分类映射与 confine 白名单复用

本报告由持续分析循环生成 — v5.0.9 CodeIntel 代码智能与 LSP 集成深度分析

基于 VitePress 构建 · AtomCode v5.2.3 逆向工程分析文档