@codua/codeoutline-win32-x64 0.1.9 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -6
- package/README.zh-CN.md +36 -6
- package/THIRD_PARTY.md +3 -3
- package/bin/xnet.exe +0 -0
- package/build-info.json +1 -1
- package/package.json +1 -1
- package/scripts/codeoutline/cli.lua +2 -2
- package/scripts/codeoutline/command.lua +9 -1
- package/scripts/codeoutline/common.lua +45 -5
- package/scripts/codeoutline/completion.lua +936 -0
- package/scripts/codeoutline/control.lua +5 -1
- package/scripts/codeoutline/documents.lua +154 -0
- package/scripts/codeoutline/explore.lua +35 -8
- package/scripts/codeoutline/graph.lua +321 -102
- package/scripts/codeoutline/index.lua +170 -50
- package/scripts/codeoutline/index_worker.lua +108 -17
- package/scripts/codeoutline/indirect.lua +201 -0
- package/scripts/codeoutline/js_evidence.lua +175 -0
- package/scripts/codeoutline/js_resolution.lua +201 -0
- package/scripts/codeoutline/lang/c.lua +22 -12
- package/scripts/codeoutline/lang/cpp.lua +13 -12
- package/scripts/codeoutline/lang/csharp.lua +21 -21
- package/scripts/codeoutline/lang/go.lua +10 -10
- package/scripts/codeoutline/lang/java.lua +9 -9
- package/scripts/codeoutline/lang/js.lua +15 -14
- package/scripts/codeoutline/lang/kotlin.lua +384 -0
- package/scripts/codeoutline/lang/lua.lua +11 -6
- package/scripts/codeoutline/lang/python.lua +6 -6
- package/scripts/codeoutline/lang/rust.lua +23 -15
- package/scripts/codeoutline/lsp.lua +574 -0
- package/scripts/codeoutline/lua_bindings.lua +222 -0
- package/scripts/codeoutline/main.lua +28 -5
- package/scripts/codeoutline/navigation.lua +1046 -0
- package/scripts/codeoutline/parse.lua +9 -2
- package/scripts/codeoutline/parse_pool.lua +189 -0
- package/scripts/codeoutline/parse_worker.lua +24 -0
- package/scripts/codeoutline/service.lua +82 -31
- package/scripts/codeoutline/update_sequence.lua +1 -1
- package/scripts/codeoutline/version.lua +1 -1
- package/licenses/rpmalloc.txt +0 -12
package/README.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
English | [简体中文](README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
Lightweight code indexing and exploration for coding agents, as an MCP server. Powered by Lua.
|
|
5
|
+
Lightweight code indexing and exploration for coding agents, as an MCP server, and for editors, as a language server. Powered by Lua.
|
|
6
6
|
|
|
7
|
-
CodeOutline answers symbol queries with line-numbered source, call paths, and callers/callees, refreshes incrementally, and caches the index on disk. The MCP protocol
|
|
7
|
+
CodeOutline answers symbol queries with line-numbered source, call paths, and callers/callees, refreshes incrementally, and caches the index on disk. Editors get symbols, definitions, references, call hierarchy, and completion from the same index through LSP. The MCP protocol with both transports (stdio and Streamable HTTP) and the language server are implemented in Lua, so neither depends on Node; in the npm package, Node only locates and starts the runtime for your platform.
|
|
8
8
|
|
|
9
9
|
## Installation and setup
|
|
10
10
|
|
|
@@ -61,6 +61,28 @@ Three tools are provided:
|
|
|
61
61
|
|
|
62
62
|
Without Node, download the native archive for your platform from [GitHub Releases](https://github.com/1dao/codeoutline/releases), extract it, and run `codeoutline` (`codeoutline.cmd` on Windows).
|
|
63
63
|
|
|
64
|
+
## Editor integration (LSP)
|
|
65
|
+
|
|
66
|
+
`codeoutline lsp --stdio` is a language server over the same indexer. Each editor window starts its own server process with its own index; it does not connect to the shared MCP service, and the MCP URL is not an LSP endpoint.
|
|
67
|
+
|
|
68
|
+
| Feature | Scope |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| Document and workspace symbols | Workspace symbols match substrings, case-insensitively |
|
|
71
|
+
| Definition, hover, signature help | Definition also goes from import lines (`require`, `#include`, module imports) to the files they load |
|
|
72
|
+
| References, call hierarchy | Functions, methods, constructors, and macros; incoming and outgoing calls |
|
|
73
|
+
| Completion | Locals, the file's definitions and imports, declarations from included C/C++ headers, and members after `.`, `->`, `::`, `?.`, or Lua `:` |
|
|
74
|
+
|
|
75
|
+
Resolution is name-based, the same as `codeoutline_explore`; it is not a type checker. Rename, diagnostics, and formatting are not provided, so CodeOutline works best beside a language's own server or where none is available. Unsaved edits are included in every request. A `.codeoutline.json` file in the workspace root can map Lua call arguments to registration sites for Go to Definition. Behavior, limits, and options are described in [LSP.md](docs/LSP.md).
|
|
76
|
+
|
|
77
|
+
Thin clients are in this repository: one VSIX for [VS Code and Cursor](adapters/vscode/README.md), and a [Zed](adapters/zed/README.md) extension. They are not published to an extension marketplace yet; install them as described in their READMEs. Other editors can start the same command through their generic LSP support; only VS Code, Cursor, and Zed have been tested.
|
|
78
|
+
|
|
79
|
+
Clients start the server directly, without a shell:
|
|
80
|
+
|
|
81
|
+
- **Linux and macOS**: the npm installation puts an executable `codeoutline` on PATH, so the client defaults (`codeoutline` with `lsp --stdio`) work. An editor started from the desktop may not inherit PATH entries added by your shell profile (nvm, for example); then configure the absolute path printed by `command -v codeoutline`.
|
|
82
|
+
- **Windows**: npm installs `codeoutline.cmd`, a batch file. The VS Code/Cursor client finds the npm installation itself, and Zed starts `codeoutline.cmd` from PATH through cmd.exe, so neither needs settings. For clients that cannot start a batch file, configure `node` as the command, with the arguments `<global npm folder>/codeoutline/launcher/codeoutline.cjs`, `lsp`, `--stdio`; `npm root -g` prints the global folder, usually `C:\Users\<you>\AppData\Roaming\npm\node_modules`. For the native archive, run its `bin/xnet.exe` with `<archive>/scripts/codeoutline/command.lua`, `LOG_STDERR=1`, `LOG_FILE=0`, `lsp`, `--stdio`.
|
|
83
|
+
|
|
84
|
+
The server uses the newest installed version when it starts and does not install updates itself; an update installed by the background service takes effect the next time the editor starts the server. Started directly from the native archive, the server always runs that archive's version.
|
|
85
|
+
|
|
64
86
|
## System requirements
|
|
65
87
|
|
|
66
88
|
| Platform | Requirements |
|
|
@@ -73,20 +95,26 @@ On Linux, decoding GBK sources needs the GBK module of the system iconv. Minimal
|
|
|
73
95
|
|
|
74
96
|
## Supported languages
|
|
75
97
|
|
|
76
|
-
C, C++, C#, Go, Java, JavaScript / TypeScript (including JSX/TSX), Lua, Python, and Rust.
|
|
98
|
+
C, C++, C#, Go, Java, JavaScript / TypeScript (including JSX/TSX), Kotlin (`.kt` / `.kts`), Lua, Python, and Rust.
|
|
99
|
+
|
|
100
|
+
Kotlin includes declarations, constructor properties, extension functions, expression bodies,
|
|
101
|
+
package imports (including aliases), and ordinary, generic and trailing-lambda calls.
|
|
102
|
+
Resolution is heuristic: compiler-generated members, implicit lambda receivers, string-template
|
|
103
|
+
expressions, Java interop and coroutine/framework dispatch are not modeled.
|
|
77
104
|
|
|
78
105
|
## Command line
|
|
79
106
|
|
|
80
107
|
```sh
|
|
81
108
|
codeoutline serve --stdio [--project PATH] [--allow-root PATH ...]
|
|
82
109
|
codeoutline serve --http [--host HOST] [--port PORT] [--project PATH] [--allow-root PATH ...]
|
|
110
|
+
codeoutline lsp --stdio [--project PATH]
|
|
83
111
|
codeoutline explore --project PATH --query QUERY [--budget BYTES]
|
|
84
112
|
codeoutline status [--project PATH]
|
|
85
113
|
codeoutline rebuild [--project PATH]
|
|
86
114
|
codeoutline doctor [--project PATH]
|
|
87
115
|
```
|
|
88
116
|
|
|
89
|
-
`status`, `rebuild`, and `doctor` print JSON; a failed diagnostic exits nonzero. One-shot commands default to the current directory as the project.
|
|
117
|
+
`status`, `rebuild`, and `doctor` print JSON; a failed diagnostic exits nonzero. One-shot commands default to the current directory as the project. `lsp --stdio` is started by an editor and speaks LSP on stdin and stdout; it is not an interactive command. Its workspace comes from the editor, and `--project` is used only when the editor sends none.
|
|
90
118
|
|
|
91
119
|
The runtime logs only warnings and errors, to stderr, and writes no log files, so starting it in a project leaves nothing behind. For troubleshooting, set `CODEOUTLINE_LOG_LEVEL` (`DEBUG`, `INFO`, `WARN`, `ERROR`, ...) and `CODEOUTLINE_LOG_DIR` to write log files to that directory.
|
|
92
120
|
|
|
@@ -96,13 +124,15 @@ The protocol baseline is [MCP 2025-06-18](https://modelcontextprotocol.io/specif
|
|
|
96
124
|
|
|
97
125
|
In stdio mode, stdout carries only MCP messages and logs go to stderr. HTTP listens on the local machine by default; clients connect to `http://127.0.0.1:19876/mcp`. Remote listening requires a `CODEOUTLINE_TOKEN` of at least 16 bytes and hosts allowed explicitly with `--allow-host`; clients send `Authorization: Bearer ...`. Unlike local HTTP, a remote service without `--allow-root` is limited to `--project` or its start directory. Repeat `--allow-origin` to allow full browser origins; unlisted origins are rejected. Protect the token with a TLS reverse proxy for remote deployments.
|
|
98
126
|
|
|
99
|
-
The main thread handles the protocol while a resident index thread serves queries one at a time. Requests with a progress token receive progress every second (over SSE for HTTP); there is no standalone GET/SSE endpoint (it returns 405). Limits: 64 sessions, 64 queued or running jobs, a 120-second job deadline, and sessions expire after 15 idle minutes. Cancellation takes effect at
|
|
127
|
+
The main thread handles the protocol while a resident index thread serves queries one at a time. Requests with a progress token receive progress every second (over SSE for HTTP); there is no standalone GET/SSE endpoint (it returns 405). Limits: 64 sessions, 64 queued or running jobs, a 120-second job deadline, and sessions expire after 15 idle minutes. Cancellation takes effect at explicit checkpoints, so a single file's native parse cannot be interrupted (files are capped at 1.5 MB). Cancelled updates roll back to the last complete in-memory index; cancelling a read-only query does not discard it.
|
|
100
128
|
|
|
101
129
|
## Indexing behavior and limits
|
|
102
130
|
|
|
131
|
+
The service starts parse workers on demand for full scans with at least 32 files that need reading, while the index thread commits their results. It uses 8 parse threads on Windows and 6 elsewhere; set `CODEOUTLINE_INDEX_THREADS` to override the count, or `0` to disable them. Workers are reused and shut down after 60 seconds idle, once all outstanding batches have returned, then recreated when needed.
|
|
132
|
+
|
|
103
133
|
The cache lives at `.codeoutline/cache/<SHA-256 of path>.idx` in the user's home directory. It is integrity-checked and rebuilt automatically if corrupt; every write goes to a separate temporary file that atomically replaces the old one, which survives a failed write. Up to 8 projects stay resident by default, and idle ones are evicted after 15 minutes. Directory aliases and links resolve to real absolute paths; on Windows, ASCII case is ignored.
|
|
104
134
|
|
|
105
|
-
Source encodings are confirmed on demand: the first index pass does not check each file, only the files a query touches. UTF-8 (with or without BOM) is tried first, then strict GBK conversion; a GBK file is reparsed and
|
|
135
|
+
Source encodings are confirmed on demand: the first index pass does not check each file, only the files a query touches. UTF-8 (with or without BOM) is tried first, then strict GBK conversion; a GBK file is reparsed and its symbols updated before the query runs, without modifying the file. Encoding results are cached and invalidated when a file changes, and a matched file that cannot be decoded is reported as an error. When both encodings are valid, UTF-8 wins. GBK files that no query has touched yet may still be misparsed, so Chinese identifiers can be missed; querying the file name triggers its repair.
|
|
106
136
|
|
|
107
137
|
Files are listed with ripgrep (`rg`) when available, honoring every `.gitignore`. Without `rg`, a directory walk supports only the common rules of the root `.gitignore` (no negation, no nested ignore files) and skips hidden directories, `node_modules`, `__pycache__`, and symbolic links. Project root paths must not contain `"`, `%`, `!`, `$`, backticks, backslashes, or line breaks.
|
|
108
138
|
|
|
@@ -135,6 +165,8 @@ Tests:
|
|
|
135
165
|
```powershell
|
|
136
166
|
.\bin\xnet.exe tests/lua/codeoutline_spec.lua
|
|
137
167
|
.\bin\xnet.exe tests/lua/stability_spec.lua
|
|
168
|
+
.\bin\xnet.exe tests/lua/parse_pool_spec.lua
|
|
169
|
+
.\bin\xnet.exe tests/lua/lsp_spec.lua
|
|
138
170
|
npm ci
|
|
139
171
|
npm test
|
|
140
172
|
npm run test:package
|
package/README.zh-CN.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | 简体中文
|
|
4
4
|
|
|
5
|
-
Lightweight code indexing and exploration for coding agents, as an MCP server. Powered by Lua.
|
|
5
|
+
Lightweight code indexing and exploration for coding agents, as an MCP server, and for editors, as a language server. Powered by Lua.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
面向编程智能体的轻量代码索引与查询服务:按符号查询带行号的源码、调用路径和上下游关系,自动增量刷新并缓存到磁盘。编辑器通过 LSP 使用同一套索引,获得符号、定义跳转、引用、调用层级和补全。MCP 协议(含 stdio 与 Streamable HTTP 传输)和语言服务器均由 Lua 实现,运行不依赖 Node;npm 包中的 Node 只负责找到对应平台的程序并启动。
|
|
8
8
|
|
|
9
9
|
## 安装与配置
|
|
10
10
|
|
|
@@ -61,6 +61,28 @@ Windows 上 Claude Code 无法直接启动 `codeoutline.cmd`,请改用 `-- cmd
|
|
|
61
61
|
|
|
62
62
|
不使用 Node 时,可从 [GitHub Releases](https://github.com/1dao/codeoutline/releases) 下载对应平台的原生压缩包,解压后直接运行 `codeoutline`(Windows 为 `codeoutline.cmd`)。
|
|
63
63
|
|
|
64
|
+
## 编辑器集成(LSP)
|
|
65
|
+
|
|
66
|
+
`codeoutline lsp --stdio` 是基于同一索引器的语言服务器。每个编辑器窗口各自启动一个服务进程、各建一份索引,不连接共享的 MCP 服务;MCP 地址也不能当作 LSP 地址使用。
|
|
67
|
+
|
|
68
|
+
| 功能 | 范围 |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| 文档符号、工作区符号 | 工作区符号按子串匹配,不区分大小写 |
|
|
71
|
+
| 定义跳转、悬停、签名帮助 | 在导入行(`require`、`#include`、模块导入)上跳转定义会打开被加载的文件 |
|
|
72
|
+
| 引用、调用层级 | 函数、方法、构造函数和宏;支持调入与调出 |
|
|
73
|
+
| 补全 | 局部变量、本文件的定义与导入、C/C++ 所包含头文件中的声明,以及 `.`、`->`、`::`、`?.`、Lua `:` 之后的成员 |
|
|
74
|
+
|
|
75
|
+
解析基于名称,与 `codeoutline_explore` 相同,不做类型检查;不提供重命名、诊断和格式化,适合与语言自身的服务器并用,或用于没有语言服务器的场景。每次请求都会带上未保存的修改。工作区根目录的 `.codeoutline.json` 可以把 Lua 调用参数映射到注册位置,用于跳转定义。具体行为、限制和选项见 [LSP.md](docs/LSP.md)。
|
|
76
|
+
|
|
77
|
+
仓库内提供轻量客户端:[VS Code 与 Cursor](adapters/vscode/README.md) 共用的 VSIX,以及 [Zed](adapters/zed/README.md) 扩展。它们尚未发布到扩展市场,请按各自 README 安装。其他编辑器可通过通用 LSP 支持启动同一命令;目前只在 VS Code、Cursor 和 Zed 上验证过。
|
|
78
|
+
|
|
79
|
+
客户端不经过 shell 直接启动服务器:
|
|
80
|
+
|
|
81
|
+
- **Linux 与 macOS**:npm 安装会在 PATH 中放一个可执行的 `codeoutline`,客户端默认配置(`codeoutline` 加 `lsp --stdio`)即可使用。从桌面启动的编辑器可能拿不到 shell 配置文件里追加的 PATH(例如 nvm),此时请配置 `command -v codeoutline` 输出的绝对路径。
|
|
82
|
+
- **Windows**:npm 安装的是批处理文件 `codeoutline.cmd`。VS Code/Cursor 客户端会自行找到 npm 安装;Zed 会从 PATH 找到 `codeoutline.cmd` 并通过 cmd.exe 启动,两者都无需设置。无法启动批处理文件的客户端,请把命令配置为 `node`,参数为 `<npm 全局目录>/codeoutline/launcher/codeoutline.cjs`、`lsp`、`--stdio`;`npm root -g` 可输出全局目录,通常为 `C:\Users\<用户名>\AppData\Roaming\npm\node_modules`。使用原生压缩包时,运行其中的 `bin/xnet.exe`,参数为 `<解压目录>/scripts/codeoutline/command.lua`、`LOG_STDERR=1`、`LOG_FILE=0`、`lsp`、`--stdio`。
|
|
83
|
+
|
|
84
|
+
服务器启动时使用已安装的最新版本,自身不安装更新;后台服务安装的更新在编辑器下次启动服务器时生效。直接从原生压缩包启动时,始终运行该压缩包的版本。
|
|
85
|
+
|
|
64
86
|
## 系统要求
|
|
65
87
|
|
|
66
88
|
| 平台 | 要求 |
|
|
@@ -73,20 +95,24 @@ Linux 上解码 GBK 源码需要系统 iconv 的 GBK 模块;EL8/EL9 最小安
|
|
|
73
95
|
|
|
74
96
|
## 支持的语言
|
|
75
97
|
|
|
76
|
-
C、C++、C#、Go、Java、JavaScript / TypeScript(含 JSX/TSX)、Lua、Python、Rust。
|
|
98
|
+
C、C++、C#、Go、Java、JavaScript / TypeScript(含 JSX/TSX)、Kotlin(`.kt` / `.kts`)、Lua、Python、Rust。
|
|
99
|
+
|
|
100
|
+
Kotlin 支持声明、主构造器属性、扩展函数、表达式函数体、包导入与别名,以及普通、泛型和尾随 lambda 调用。
|
|
101
|
+
关系解析仍是启发式的;不建模编译器生成成员、lambda 隐式接收者、字符串模板内的表达式、Java 互操作或协程/框架分派。
|
|
77
102
|
|
|
78
103
|
## 命令行
|
|
79
104
|
|
|
80
105
|
```sh
|
|
81
106
|
codeoutline serve --stdio [--project PATH] [--allow-root PATH ...]
|
|
82
107
|
codeoutline serve --http [--host HOST] [--port PORT] [--project PATH] [--allow-root PATH ...]
|
|
108
|
+
codeoutline lsp --stdio [--project PATH]
|
|
83
109
|
codeoutline explore --project PATH --query QUERY [--budget BYTES]
|
|
84
110
|
codeoutline status [--project PATH]
|
|
85
111
|
codeoutline rebuild [--project PATH]
|
|
86
112
|
codeoutline doctor [--project PATH]
|
|
87
113
|
```
|
|
88
114
|
|
|
89
|
-
`status`、`rebuild`、`doctor` 输出 JSON
|
|
115
|
+
`status`、`rebuild`、`doctor` 输出 JSON;诊断失败返回非零退出码。一次性命令的项目默认为当前目录。`lsp --stdio` 由编辑器启动,通过 stdin/stdout 收发 LSP 消息,不是交互式命令;工作区由编辑器提供,编辑器未提供时才使用 `--project`。
|
|
90
116
|
|
|
91
117
|
运行时只把警告和错误输出到 stderr,不写日志文件,在项目中启动不会留下任何文件。排查问题时可设置 `CODEOUTLINE_LOG_LEVEL`(`DEBUG`、`INFO`、`WARN`、`ERROR` 等)调整级别,设置 `CODEOUTLINE_LOG_DIR` 将日志文件写到该目录。
|
|
92
118
|
|
|
@@ -96,13 +122,15 @@ codeoutline doctor [--project PATH]
|
|
|
96
122
|
|
|
97
123
|
stdio 模式下 stdout 只输出 MCP 消息,日志写入 stderr。HTTP 默认只监听本机,客户端地址为 `http://127.0.0.1:19876/mcp`。远程监听需设置至少 16 字节的 `CODEOUTLINE_TOKEN` 并用 `--allow-host` 显式允许主机,客户端使用 `Authorization: Bearer ...`;与本机 HTTP 不同,远程服务未传 `--allow-root` 时只允许访问 `--project` 或启动目录;`--allow-origin` 可重复指定允许的完整 Origin,未配置的浏览器 Origin 被拒绝。远程部署应由 TLS 反向代理保护令牌。
|
|
98
124
|
|
|
99
|
-
主线程处理协议,常驻索引线程串行处理查询。请求含进度 token 时每秒报告进度,HTTP 使用 SSE;没有独立的 GET/SSE 订阅端点(返回 405)。最多 64 个会话、64 个排队或执行中的任务;任务期限 120 秒,会话空闲 15
|
|
125
|
+
主线程处理协议,常驻索引线程串行处理查询。请求含进度 token 时每秒报告进度,HTTP 使用 SSE;没有独立的 GET/SSE 订阅端点(返回 405)。最多 64 个会话、64 个排队或执行中的任务;任务期限 120 秒,会话空闲 15 分钟过期。取消在显式检查点生效,单个文件的原生解析期间无法中断(单文件上限 1.5 MB)。更新被取消时回滚至上一份完整的内存索引;取消只读查询不会丢弃索引。
|
|
100
126
|
|
|
101
127
|
## 索引行为与限制
|
|
102
128
|
|
|
129
|
+
全量扫描有至少 32 个文件需要读取时,服务按需启动解析线程,由索引线程统一提交结果。Windows 默认使用 8 个解析线程,其他平台使用 6 个;可通过 `CODEOUTLINE_INDEX_THREADS` 覆盖,设为 `0` 禁用。线程复用至所有在途批次返回,空闲 60 秒后关闭,下次需要时重新创建。
|
|
130
|
+
|
|
103
131
|
缓存位于用户目录 `.codeoutline/cache/<路径 SHA-256>.idx`,带完整性校验,损坏后自动重建;每次写入独立临时文件再原子替换,失败时保留旧文件。默认最多驻留 8 个项目,空闲 15 分钟淘汰。服务使用真实绝对路径统一目录别名与链接,Windows 上忽略 ASCII 大小写。
|
|
104
132
|
|
|
105
|
-
源码编码按需确认:首次索引不逐个检查编码,查询涉及文件时才确认,UTF-8(含 BOM)优先,失败后严格转码 GBK
|
|
133
|
+
源码编码按需确认:首次索引不逐个检查编码,查询涉及文件时才确认,UTF-8(含 BOM)优先,失败后严格转码 GBK,重新解析并更新该文件的符号后再执行本次查询,不修改原文件。编码结果随缓存保存,文件改变后失效;无法解码的命中文件会明确报错。两种编码都合法时默认 UTF-8。未被查询过的 GBK 文件仍可能有误解析,中文标识符可能漏匹配;用文件名查询可触发该文件的修正。
|
|
106
134
|
|
|
107
135
|
优先用 ripgrep(`rg`)枚举文件并遵守各级 `.gitignore`;未安装 `rg` 时改用目录遍历,只支持根目录 `.gitignore` 的常见规则(不支持否定规则与嵌套忽略文件),并跳过隐藏目录、`node_modules`、`__pycache__` 与符号链接。项目根路径不能包含 `"`、`%`、`!`、`$`、反引号、反斜杠或换行。
|
|
108
136
|
|
|
@@ -135,6 +163,8 @@ sh tools/build-runtime.sh
|
|
|
135
163
|
```powershell
|
|
136
164
|
.\bin\xnet.exe tests/lua/codeoutline_spec.lua
|
|
137
165
|
.\bin\xnet.exe tests/lua/stability_spec.lua
|
|
166
|
+
.\bin\xnet.exe tests/lua/parse_pool_spec.lua
|
|
167
|
+
.\bin\xnet.exe tests/lua/lsp_spec.lua
|
|
138
168
|
npm ci
|
|
139
169
|
npm test
|
|
140
170
|
npm run test:package
|
package/THIRD_PARTY.md
CHANGED
|
@@ -13,7 +13,6 @@ the runtime links, recorded as `lua` in `build-info.json`:
|
|
|
13
13
|
| LuaJIT (release; includes Lua 5.1 notice) | `3rd/luajit/` | `licenses/luajit.txt` (MIT) |
|
|
14
14
|
| Lua / minilua (embedded-Lua builds only) | `3rd/minilua.h` | `licenses/lua-minilua.txt` (MIT) |
|
|
15
15
|
| lua-cmsgpack | `xlua/lua_cmsgpack.c` | `licenses/lua-cmsgpack.txt` (MIT) |
|
|
16
|
-
| rpmalloc | `3rd/rpmalloc/` | `licenses/rpmalloc.txt` (source public-domain dedication) |
|
|
17
16
|
| Mbed TLS 3.6.5 | `3rd/mbedtls3/` | `licenses/mbedtls.txt` (Apache-2.0 option) |
|
|
18
17
|
| CodeOutline | `scripts/codeoutline/` | `LICENSE` (BSD-2-Clause) |
|
|
19
18
|
|
|
@@ -21,8 +20,9 @@ No ripgrep executable is bundled. An installed `rg` is used when available;
|
|
|
21
20
|
otherwise the Lua directory walker is used with the limitations in README.md.
|
|
22
21
|
The MCP SDK is a development test dependency and is not in either runtime package.
|
|
23
22
|
|
|
24
|
-
Lua, minilua,
|
|
25
|
-
sources.
|
|
23
|
+
Lua, minilua, and cmsgpack notices were extracted from the pinned runtime
|
|
24
|
+
sources. The runtime is built without rpmalloc (`WITH_RPMALLOC=0`), so its code
|
|
25
|
+
is not linked and no notice ships for it. Mbed TLS's complete dual-license text is preserved from its
|
|
26
26
|
[v3.6.5 upstream LICENSE](https://github.com/Mbed-TLS/mbedtls/blob/v3.6.5/LICENSE);
|
|
27
27
|
this distribution selects its Apache-2.0 option. The LuaJIT notice is copied from
|
|
28
28
|
`3rd/luajit/COPYRIGHT`. Recheck this inventory when the runtime commit or build
|
package/bin/xnet.exe
CHANGED
|
Binary file
|
package/build-info.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"target":"win32-x64","note":"Release build from a clean checkout","updateSequence":11,"releaseReady":true,"sha256":{"codeoutline":"3d3970e488e077e8acd67d174b506a361d43578b3360c7b29f2ec3f0103ba899","scripts/codeoutline/lang/lua.lua":"784df7e7895cc7d9f56598d6485664f8ce55abc6374ae0bcc22ba7738439726e","scripts/codeoutline/graph.lua":"361091b354be3fc890d5e8b1a334fbf4daa3ee463fbb5ea5053c75ed66271163","scripts/codeoutline/path.lua":"407bd960c1ad04e5006b321ce33263393bb40eee5dee5c123be9b36d3ad10937","keys/update-ca.crt":"d9b5ec3d4628de9c5559871f39841a5f84d47c53ded4d58d6e3bba2b4c669a02","THIRD_PARTY.md":"a0d596a8600c5244b27c1426a81b4ec7046d213d733ec6b4287a4b1e8db501b5","README.md":"f858e6acadfb3f7d07e166c5b3c76dc3a3a2140edee6853e95aabe6d39026fc2","scripts/codeoutline/lang/python.lua":"1ae8f1658e25220ec4d952c17ed817bfc92d0c45d4585d3dd4716d5585b60cc6","scripts/codeoutline/http.lua":"3d957628ecc9592d57cc68a61e5d4229a71da501eb8fb3aa0bbb5e1cd772adf0","scripts/codeoutline/service.lua":"537b7ef657fc122a85ddf7275e242d225efc65d5316bf863cd3f3132657d3b3e","README.zh-CN.md":"fea0ffb9835e1b78925b1aa0a6a3019591e376d23e94da5b4f58773601e2d7da","DISTRIBUTION.md":"da4a1048fc9b44670fd6fcef97e7d92ac3f50d3523da1773930c49f7e2c38dc3","licenses/mbedtls.txt":"9b405ef4c89342f5eae1dd828882f931747f71001cfba7d114801039b52ad09b","scripts/codeoutline/lang/rust.lua":"294cee85786caaa5f29dedd5058877c7a4786349431faf33b36357ef69406a9e","scripts/codeoutline/index.lua":"dbe88bc5f60b8230e2b69f31c5ffc86e02caea3fb4022ea49ee6210ae2b6a440","scripts/codeoutline/text.lua":"75f9af87ff5ce62def74f69d8972a6b11ff660723fc5cf515369ee3012ff0675","scripts/codeoutline/cli.lua":"f7ac4addd32ced58069954cb81edd4836c6043bb5d143683b80bd7b11554c733","licenses/lua-cmsgpack.txt":"8edfdc5282278a1268d8a6ee52f9245f1a5fe3d1c8065be00330196b1de49873","scripts/xupgate/common.lua":"86267648c0dbbd3a05f90de4d6e1dbee53ba57bf4801783c2ae636224b1f228c","scripts/codeoutline/lsp.lua":"b9c9df2a790344bb8bdc48bd024e912b012750e3bfdbe37750de5add989385da","scripts/codeoutline/index_worker.lua":"8d34748ce1d74384f8f4cf89bfd7a27dcfb6c4d51b6b4936aa9d232814194a8a","scripts/codeoutline/updater.lua":"267c4b6e9704fce710f44d1bfceac69c1857e34e064d8444d7890f0e10d921c7","scripts/codeoutline/lang/c.lua":"9cd8abbdfda6cae5d6c04a9ae68bbd9f7589b217e88b7682917106e80df9b0c5","LICENSE":"1b63179362acd482b4a9a07ca526b3fce6d9103dcded361de2159ade174568b6","scripts/codeoutline/command.lua":"7a0a623b5e965449638938549be8587f9c9490b2a7653877e089a0cc1bb1071c","scripts/codeoutline/lua_bindings.lua":"3f781dfa3d88b0ff4446eb956a861098411873805f5b54536814900a8febad5f","scripts/codeoutline/indirect.lua":"c715b87261d5ad30a84af78ab8dcc468390ab0ea896dce88f8651f7f850be091","scripts/codeoutline/update_sequence.lua":"b73b8749b7b726c05d6931405c2a86f88b908f24cdb40390c2f0e744fbaad162","licenses/libdeflate.txt":"41b60f2caab6bffdd5ba360687bd23ca653c0a1235c00380ecffc939b4cd8d75","scripts/codeoutline/lang/cpp.lua":"47e3dc18cbc8b9a93567897e9ff69a026434a1971fe1dcc3e07d3af03c54a4f2","scripts/codeoutline/common.lua":"dda47a9143ee61086781befc046df24a7317faf9c3fe9a8fd9fbf7b28dd8ed0e","scripts/codeoutline/main.lua":"fff7b1577ab85625714c841773eee07b028fccd86aa9743f15a7ad5fd7a7353b","scripts/codeoutline/js_evidence.lua":"ddb9f8a4f22b1f7fd397a75c6c5660d434133b5148dbf396586bb5b443161776","scripts/codeoutline/update_worker.lua":"7e2ec28e4b911d7b90fd97d0a4c0e2f5b295d1a9200c5c7250e47a99139ca550","scripts/xupgate/proxy.lua":"5bf532e7005f44555d6a5277336e5ad395af060585c13a1cdc2441de50e0dcff","scripts/codeoutline/lang/csharp.lua":"4bfa8555955c7de98ea12d36ee6f7d817c40cb87e77350fe2af4783517190a3d","scripts/codeoutline/completion.lua":"dde4a55ccbc4824f68d7f4c48efd57bddca9c1b371bff2398d85f2930bd53d92","scripts/codeoutline/mcp.lua":"f14a2d0b9625544ad32309358121a5ff304839780f52d5c1c8ec548d56c5e901","scripts/codeoutline/js_resolution.lua":"76be5143d2d5ff5b381c1cde0c1039fa26cb035f309a0aba7c3683efdcdd4b58","scripts/codeoutline/version.lua":"3a5f21a9e5dfaf64c4bb7bc7fc581297a5e0f0b3c07742edc758f884740b2c98","lib/xhttp_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","bin/xnet.exe":"8785c409c74e33a2f464ee8589193c0e2a1e708b9f2cc2099e74d5f80c53cd23","scripts/codeoutline/control.lua":"b67a2e382e021f0793ef313aa4e71faab76f6cb77ca127f499d01ae96f36a8db","scripts/codeoutline/navigation.lua":"5e51ca4a0020607fc45e30209eba4d3cd6089fbc21304e49bd308c60e1cd4899","codeoutline.cmd":"607b60c6d107becdb6793df8f41aaf2cff944baf69f5ece59dba990d0f24c13b","scripts/codeoutline/xscan.lua":"bd95a1b0b7022d029a41aab615897502478b5834612505e8d299343cb5ca8ef9","keys/update-public.pem":"7ff853339e19631b20ed3fa2cf221daa31c581e2e84d161b344b8f06de6562a8","scripts/codeoutline/lang/java.lua":"0ea34298770cb3431f4bc3521c4d2ecf363d55e768d6cd30b3f11ad05d7e8f0d","scripts/codeoutline/daemon.lua":"06863991135cc9a85f07bca8310296f0df9e415b3e2de97ae006393e777b009b","scripts/codeoutline/parse.lua":"cf325eb88e4ac89bdd6a0cbe33fa97f9df9c657f5685febbb7004c77cdd2749c","scripts/xupgate/signature.lua":"f07de8a4093d08cc69d3c1d8296d23318c5d81344ece788d4453a9b3b700f000","licenses/xnet2lua.txt":"1aa8af3df70f60f1ebf2d23e14c27af1606057ad9c32a9a0d15fd76cff257532","scripts/xupgate/http_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/lang/js.lua":"62570ddc38c974991763e11770059880b87ec87f14578891df9d935af6cb4786","scripts/codeoutline/documents.lua":"320a7d40fd5c0fef03a18df586848059a65c0f4e7ab4b218e9e84561eb5a7007","scripts/codeoutline/parse_pool.lua":"acaafe74a568ec450e428f4a1a2ff704834588bba0f8b808e4c7a1d552861941","scripts/xupgate/http_client.lua":"a189506c3d0fcc454f5e001fdeecdd6349a1019ea0970d11ce2fbfdf035166d6","licenses/luajit.txt":"1b10a02c9474cb908da2d87bc908edd8798f9ad28d9a8c53fbd05c13227f7394","scripts/xupgate/client.lua":"967c29c1eeebd8596458025ab3237816a91591cca64236ea0e7ba1762814e6ba","scripts/codeoutline/lang/kotlin.lua":"cefaad1c412cb42ea6b2027ad9f81ad38d8d821f05c1cfde7f89c600d745a708","scripts/codeoutline/explore.lua":"83cf6f5be4d97a929444b58d6ce741cd31a27342438b64cb06daf3d6e1362942","scripts/codeoutline/parse_worker.lua":"c5f1745d15332c5040b1e97f6da08f2f456d9afe7c2491275cc97d7113b75e45","scripts/codeoutline/lang/go.lua":"3a62d4dc451b0d2f7f2aefd5e77d11449a5d725f59379728eba8dda0aacc13f3"},"runtimeCommit":"d33491598d199b1a2f5fd3d9840c5b17d49b1e13","runtimeBuild":"b9b847244c68283df56e7858fe3daaafd35b756f0ff67cfa379f998133ddf29d","lua":"LuaJIT 2.1.1774896198","version":"0.2.1","sourceCommit":"c5aa041e8a886ac11b3e695f86cb9ec94b4e1760","sourceDirty":false}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"cpu":["x64","arm64"],"license":"BSD-2-Clause","repository":{"url":"git+https://github.com/1dao/codeoutline.git","type":"git"},"
|
|
1
|
+
{"publishConfig":{"access":"public"},"description":"CodeOutline native runtime and Lua implementation for win32-x64","cpu":["x64","arm64"],"license":"BSD-2-Clause","os":["win32"],"repository":{"url":"git+https://github.com/1dao/codeoutline.git","type":"git"},"name":"@codua/codeoutline-win32-x64","version":"0.2.1","files":["bin/","lib/","keys/","scripts/","licenses/","LICENSE","codeoutline","codeoutline.cmd","build-info.json","*.md"]}
|
|
@@ -18,8 +18,8 @@ end
|
|
|
18
18
|
local root = argv.ROOT or '.'
|
|
19
19
|
local t0 = os.clock()
|
|
20
20
|
local idx, G, stats = svc.get(root)
|
|
21
|
-
print(string.format('[index] %d files, %d nodes
|
|
22
|
-
|
|
21
|
+
print(string.format('[index] %d files, %d nodes | refresh: parsed=%d unchanged=%d removed=%d skipped=%d | %.2fs%s',
|
|
22
|
+
G.file_count, G.node_count, stats.parsed, stats.unchanged, stats.removed, stats.skipped,
|
|
23
23
|
os.clock() - t0, (xscan and os.getenv('XSCAN_PURE_LUA') ~= '1') and ' (native xscan)' or ''))
|
|
24
24
|
|
|
25
25
|
if argv.Q and argv.STATS ~= '1' then
|
|
@@ -4,7 +4,7 @@ local scripts = assert(source:match('^(.*)/codeoutline/[^/]+$'))
|
|
|
4
4
|
local install = assert(scripts:match('^(.*)/scripts$'))
|
|
5
5
|
package.path = scripts .. '/?.lua;' .. package.path
|
|
6
6
|
local version = require('codeoutline.version')
|
|
7
|
-
local help = [[CodeOutline - Lua code indexing and
|
|
7
|
+
local help = [[CodeOutline - Lua code indexing for MCP and LSP
|
|
8
8
|
|
|
9
9
|
One shared background service serves every MCP client. A global npm install
|
|
10
10
|
starts it and registers it to start at login (codeoutline install does the same
|
|
@@ -16,6 +16,7 @@ Usage:
|
|
|
16
16
|
codeoutline uninstall [--port PORT]
|
|
17
17
|
codeoutline daemon [--port PORT]
|
|
18
18
|
codeoutline serve --stdio [--project PATH] [--allow-root PATH ...]
|
|
19
|
+
codeoutline lsp --stdio [--project PATH]
|
|
19
20
|
codeoutline serve --http [--host HOST] [--port PORT] [--project PATH] [--allow-root PATH ...]
|
|
20
21
|
codeoutline explore --project PATH --query QUERY [--budget BYTES]
|
|
21
22
|
codeoutline status [--project PATH]
|
|
@@ -54,6 +55,7 @@ local function parse(args)
|
|
|
54
55
|
return command, {}
|
|
55
56
|
end
|
|
56
57
|
local allowed = {
|
|
58
|
+
lsp = { stdio = true, project = true },
|
|
57
59
|
serve = { stdio = true, http = true, project = true, host = true, port = true,
|
|
58
60
|
['allow-root'] = true, ['allow-host'] = true, ['allow-origin'] = true },
|
|
59
61
|
daemon = { port = true }, install = { port = true, npm = true }, uninstall = { port = true },
|
|
@@ -213,6 +215,12 @@ local function run()
|
|
|
213
215
|
__thread_handle = function() end,
|
|
214
216
|
}
|
|
215
217
|
end
|
|
218
|
+
if command == 'lsp' then
|
|
219
|
+
assert(options.stdio, 'lsp requires --stdio')
|
|
220
|
+
arg = { 'STDIO=1', 'LSP=1' }
|
|
221
|
+
if options.project then arg[#arg + 1] = 'PROJECT=' .. options.project end
|
|
222
|
+
return dofile(scripts .. '/codeoutline/main.lua')
|
|
223
|
+
end
|
|
216
224
|
if command == 'serve' then
|
|
217
225
|
assert(not not options.stdio ~= not not options.http, 'serve requires exactly one of --stdio or --http')
|
|
218
226
|
arg = { options.stdio and 'STDIO=1' or 'HTTP=1' }
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
-- refs = { name = {...}, from = {...}, kind = {...}, line = {...}, recv = {...} },
|
|
8
8
|
-- imports = { {path, line, names?} },
|
|
9
9
|
-- }
|
|
10
|
+
-- Unless ranges=false, nodes store start_byte/end_byte and name_start/name_end as zero-based,
|
|
11
|
+
-- half-open byte ranges in the parser input (after BOM removal), and refs gain
|
|
12
|
+
-- start/stop columns for each name token (false when the token is not the name).
|
|
10
13
|
-- Refs are attributed after parsing: a parser only records where each call
|
|
11
14
|
-- sits (token index) and assign_refs() hands it to the innermost node whose
|
|
12
15
|
-- token range contains it. That keeps nested functions/classes correct
|
|
@@ -19,8 +22,9 @@
|
|
|
19
22
|
local M = {}
|
|
20
23
|
local text = require('codeoutline.text')
|
|
21
24
|
|
|
22
|
-
function M.new(path, language)
|
|
23
|
-
return { path = path, language = language, nodes = {}, refs = {}, imports = {}
|
|
25
|
+
function M.new(path, language, opts)
|
|
26
|
+
return { path = path, language = language, nodes = {}, refs = {}, imports = {},
|
|
27
|
+
ranges = not opts or opts.ranges ~= false, collect_dispatch = opts and opts.dispatch }
|
|
24
28
|
end
|
|
25
29
|
|
|
26
30
|
-- Collapse a token span into a one-line signature.
|
|
@@ -33,12 +37,21 @@ function M.sig(T, a, b, max)
|
|
|
33
37
|
end
|
|
34
38
|
|
|
35
39
|
-- ti/tj: token range the node covers (used for ref attribution, then dropped).
|
|
40
|
+
-- ni/nj: declaration name tokens; range_end overrides a synthetic block end.
|
|
36
41
|
function M.add_node(r, T, f)
|
|
37
42
|
local parent = f.parent and r.nodes[f.parent]
|
|
38
43
|
local sep = f.sep or '.'
|
|
39
44
|
f.qualified = parent and (parent.qualified .. sep .. f.name) or ((r.prefix and (r.prefix .. sep) or '') .. f.name)
|
|
40
45
|
f.line = f.line or T:line(f.ti)
|
|
41
46
|
f.end_line = f.end_line or T:eline(f.tj)
|
|
47
|
+
if r.ranges then
|
|
48
|
+
local ni, nj = f.ni or f.ti, f.nj or f.ni or f.ti
|
|
49
|
+
f.name_start = f.name_start or T.s[ni] - 1
|
|
50
|
+
f.name_end = f.name_end or T.e[nj]
|
|
51
|
+
f.start_byte = math.min(T.s[f.ti] - 1, f.name_start)
|
|
52
|
+
f.end_byte = math.max(T.e[f.range_end or f.tj], f.name_end)
|
|
53
|
+
end
|
|
54
|
+
f.ni, f.nj, f.range_end = nil, nil, nil
|
|
42
55
|
f.sep = nil
|
|
43
56
|
r.nodes[#r.nodes + 1] = f
|
|
44
57
|
return #r.nodes
|
|
@@ -117,14 +130,41 @@ function M.assign_refs(r)
|
|
|
117
130
|
end
|
|
118
131
|
|
|
119
132
|
-- Drop parser-internal fields so the result is plain data.
|
|
120
|
-
function M.finish(r)
|
|
133
|
+
function M.finish(r, T)
|
|
121
134
|
M.assign_refs(r)
|
|
135
|
+
if T then require('codeoutline.js_evidence').collect(r, T) end
|
|
136
|
+
if T then require('codeoutline.indirect').collect(r, T) end
|
|
137
|
+
r.collect_dispatch = nil
|
|
122
138
|
local name, from, kind, line, recv = {}, {}, {}, {}, {}
|
|
139
|
+
local js_receiver = r.js_imports and {}
|
|
140
|
+
local lua_binding = r.lua_imports and {}
|
|
141
|
+
local start, stop = r.ranges and T and {}, r.ranges and T and {}
|
|
123
142
|
for i, ref in ipairs(r.refs) do
|
|
124
143
|
name[i], from[i], kind[i], line[i], recv[i] = ref.name, ref.from, ref.kind, ref.line, ref.recv or false
|
|
144
|
+
if js_receiver then js_receiver[i] = ref.js_receiver or '' end
|
|
145
|
+
if lua_binding then lua_binding[i] = ref.lua_binding or '' end
|
|
146
|
+
if start then
|
|
147
|
+
local named = T:text(ref.tok) == ref.name
|
|
148
|
+
start[i], stop[i] = named and T.s[ref.tok] - 1 or false, named and T.e[ref.tok] or false
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
r.refs = { name = name, from = from, kind = kind, line = line, recv = recv, start = start or nil, stop = stop or nil }
|
|
152
|
+
r.refs.js_receiver = js_receiver
|
|
153
|
+
r.refs.lua_binding = lua_binding
|
|
154
|
+
for i, n in ipairs(r.nodes) do
|
|
155
|
+
n.ti, n.tj = nil, nil
|
|
156
|
+
if not r.ranges then
|
|
157
|
+
-- Rebuild: deleting keys does not shrink Lua table allocations.
|
|
158
|
+
local compact = {}
|
|
159
|
+
for key, value in pairs(n) do
|
|
160
|
+
if key ~= 'start_byte' and key ~= 'end_byte' and key ~= 'name_start' and key ~= 'name_end' then
|
|
161
|
+
compact[key] = value
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
r.nodes[i] = compact
|
|
165
|
+
end
|
|
125
166
|
end
|
|
126
|
-
r.
|
|
127
|
-
for _, n in ipairs(r.nodes) do n.ti, n.tj = nil, nil end
|
|
167
|
+
r.ranges = nil
|
|
128
168
|
r.prefix, r.skip_calls = nil, nil
|
|
129
169
|
return r
|
|
130
170
|
end
|