@codua/codeoutline-win32-x64 0.1.1 → 0.1.2
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 +30 -7
- package/README.zh-CN.md +30 -7
- package/bin/xnet.exe +0 -0
- package/build-info.json +1 -1
- package/package.json +1 -1
- package/scripts/codeoutline/command.lua +3 -1
- package/scripts/codeoutline/index_worker.lua +1 -5
- package/scripts/codeoutline/main.lua +21 -2
- package/scripts/codeoutline/mcp.lua +1 -3
- package/scripts/codeoutline/path.lua +10 -0
- package/scripts/codeoutline/version.lua +1 -1
package/README.md
CHANGED
|
@@ -8,25 +8,48 @@ CodeOutline answers symbol queries with line-numbered source, call paths, and ca
|
|
|
8
8
|
|
|
9
9
|
## Installation and setup
|
|
10
10
|
|
|
11
|
-
Requires Node.js 20 or newer. npm downloads the runtime for your platform automatically; no compiler or Lua installation is needed.
|
|
11
|
+
Requires Node.js 20 or newer. npm downloads the runtime for your platform automatically; no compiler or Lua installation is needed. Install it globally rather than configuring clients with `npx -y`: npx keeps a full npm process running beside every server it starts.
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
|
-
|
|
14
|
+
npm install -g codeoutline
|
|
15
|
+
codeoutline --version
|
|
15
16
|
```
|
|
16
17
|
|
|
18
|
+
### Recommended: one shared HTTP service
|
|
19
|
+
|
|
20
|
+
A stdio server is a child process of its client, so every agent session (each Claude Code session, each Cursor window) starts its own copy and builds its own in-memory index. One HTTP service serves all sessions from a single process and a single index.
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
codeoutline serve --http
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The service listens on `127.0.0.1:19876` and, without `--allow-root`, serves projects anywhere on the machine, so switching between projects on different drives needs no configuration. Only local processes can reach it, and they already have your file access. To restrict it anyway, repeat `--allow-root` for each directory tree to allow; a tree that is unavailable at startup, such as an unmounted drive, is reported and becomes usable once it appears.
|
|
27
|
+
|
|
17
28
|
**Claude Code** (added globally, available in every project):
|
|
18
29
|
|
|
19
30
|
```sh
|
|
20
|
-
claude mcp add codeoutline --scope user
|
|
31
|
+
claude mcp add --transport http codeoutline --scope user http://127.0.0.1:19876/mcp
|
|
21
32
|
```
|
|
22
33
|
|
|
23
34
|
**Cursor** (`~/.cursor/mcp.json`):
|
|
24
35
|
|
|
25
36
|
```json
|
|
26
|
-
{ "mcpServers": { "codeoutline": { "
|
|
37
|
+
{ "mcpServers": { "codeoutline": { "url": "http://127.0.0.1:19876/mcp" } } }
|
|
27
38
|
```
|
|
28
39
|
|
|
29
|
-
|
|
40
|
+
A shared service has no project of its own: it uses the client's roots when the client provides them, and otherwise the agent passes `projectPath`, which the tools ask for when it is missing. Clients do not start an HTTP service, so start it at login (Task Scheduler on Windows, launchd on macOS, a systemd user unit on Linux). On Windows, supervise the native launcher rather than the npm one; see [DISTRIBUTION.md](docs/DISTRIBUTION.md).
|
|
41
|
+
|
|
42
|
+
### Alternative: stdio, one process per session
|
|
43
|
+
|
|
44
|
+
Use stdio when you do not want a resident service. Each session then starts and stops its own server.
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
claude mcp add codeoutline --scope user -- codeoutline serve --stdio
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
On Windows, Claude Code cannot start the `codeoutline.cmd` shim directly; use `-- cmd /c codeoutline serve --stdio`. For Cursor, set `"command": "codeoutline", "args": ["serve", "--stdio"]`.
|
|
51
|
+
|
|
52
|
+
When no project is specified, the service uses, in order: the `projectPath` argument of the call, the `--project` option, the client's roots (the first directory returned by `roots/list`), and the directory the service was started in. Clients usually start a stdio service in the project directory, so a global configuration needs no project path. Access defaults to `--project` or the start directory; repeat `--allow-root` to allow more.
|
|
30
53
|
|
|
31
54
|
Three tools are provided:
|
|
32
55
|
|
|
@@ -56,7 +79,7 @@ C, C++, C#, Go, Java, JavaScript / TypeScript (including JSX/TSX), Lua, Python,
|
|
|
56
79
|
|
|
57
80
|
```sh
|
|
58
81
|
codeoutline serve --stdio [--project PATH] [--allow-root PATH ...]
|
|
59
|
-
codeoutline serve --http [--host HOST] [--port PORT] [--project PATH]
|
|
82
|
+
codeoutline serve --http [--host HOST] [--port PORT] [--project PATH] [--allow-root PATH ...]
|
|
60
83
|
codeoutline explore --project PATH --query QUERY [--budget BYTES]
|
|
61
84
|
codeoutline status [--project PATH]
|
|
62
85
|
codeoutline rebuild [--project PATH]
|
|
@@ -71,7 +94,7 @@ The runtime logs only warnings and errors, to stderr, and writes no log files, s
|
|
|
71
94
|
|
|
72
95
|
The protocol baseline is [MCP 2025-06-18](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports). Query budgets range from 256 to 262144 bytes (default 16000); truncated output stays valid UTF-8 and ends with a truncation notice. Paths always refer to the machine running the service.
|
|
73
96
|
|
|
74
|
-
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 ...`. Repeat `--allow-origin` to allow full browser origins; unlisted origins are rejected. Protect the token with a TLS reverse proxy for remote deployments.
|
|
97
|
+
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.
|
|
75
98
|
|
|
76
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 per-file checkpoints, so a single file's parse cannot be interrupted (files are capped at 1.5 MB); after a cancellation the possibly incomplete in-memory index is discarded and the next query recovers from the cache.
|
|
77
100
|
|
package/README.zh-CN.md
CHANGED
|
@@ -8,25 +8,48 @@ Lightweight code indexing and exploration for coding agents, as an MCP server. P
|
|
|
8
8
|
|
|
9
9
|
## 安装与配置
|
|
10
10
|
|
|
11
|
-
需要 Node.js 20 或更新版本。npm 会按系统自动下载对应平台的运行时,无需编译器或 Lua
|
|
11
|
+
需要 Node.js 20 或更新版本。npm 会按系统自动下载对应平台的运行时,无需编译器或 Lua。请全局安装,不要在客户端配置里写 `npx -y`:npx 会在它启动的每个服务旁边常驻一个完整的 npm 进程。
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
|
-
|
|
14
|
+
npm install -g codeoutline
|
|
15
|
+
codeoutline --version
|
|
15
16
|
```
|
|
16
17
|
|
|
18
|
+
### 推荐:共享一个 HTTP 服务
|
|
19
|
+
|
|
20
|
+
stdio 服务是客户端的子进程,每个智能体会话(每个 Claude Code 会话、每个 Cursor 窗口)都会各自启动一份,并各自建一份内存索引。HTTP 服务只用一个进程、一份索引,供所有会话共用。
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
codeoutline serve --http
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
服务监听 `127.0.0.1:19876`。不传 `--allow-root` 时可访问本机任意位置的项目,在不同盘的项目之间切换无需额外配置;只有本机进程能连到它,而本机进程本来就有你的文件访问权限。仍想限制时,为每个允许的目录树重复一次 `--allow-root`;启动时不可用的目录(如未挂载的盘)只会给出提示,出现后即可使用。
|
|
27
|
+
|
|
17
28
|
**Claude Code**(全局添加,在任意项目中可用):
|
|
18
29
|
|
|
19
30
|
```sh
|
|
20
|
-
claude mcp add codeoutline --scope user
|
|
31
|
+
claude mcp add --transport http codeoutline --scope user http://127.0.0.1:19876/mcp
|
|
21
32
|
```
|
|
22
33
|
|
|
23
34
|
**Cursor**(`~/.cursor/mcp.json`):
|
|
24
35
|
|
|
25
36
|
```json
|
|
26
|
-
{ "mcpServers": { "codeoutline": { "
|
|
37
|
+
{ "mcpServers": { "codeoutline": { "url": "http://127.0.0.1:19876/mcp" } } }
|
|
27
38
|
```
|
|
28
39
|
|
|
29
|
-
|
|
40
|
+
共享服务没有自己的项目:客户端提供 roots 时使用 roots,否则由智能体传入 `projectPath`,缺少时工具会提示需要它。客户端不会启动 HTTP 服务,请让它随登录启动(Windows 用任务计划程序,macOS 用 launchd,Linux 用 systemd 用户单元)。Windows 上请托管原生启动器而不是 npm 启动器,原因见 [DISTRIBUTION.md](docs/DISTRIBUTION.md)。
|
|
41
|
+
|
|
42
|
+
### 备选:stdio,每个会话一个进程
|
|
43
|
+
|
|
44
|
+
不想常驻服务时使用 stdio,每个会话自行启动和关闭自己的服务进程。
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
claude mcp add codeoutline --scope user -- codeoutline serve --stdio
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Windows 上 Claude Code 无法直接启动 `codeoutline.cmd`,请改用 `-- cmd /c codeoutline serve --stdio`。Cursor 配置为 `"command": "codeoutline", "args": ["serve", "--stdio"]`。
|
|
51
|
+
|
|
52
|
+
未指定项目时,服务依次使用:调用参数 `projectPath`、启动参数 `--project`、客户端 roots(`roots/list` 返回的第一个目录)、服务启动目录。客户端通常在项目目录中启动 stdio 服务,因此全局配置无需写项目路径。访问范围默认为 `--project` 或启动目录,可用可重复的 `--allow-root` 扩大。
|
|
30
53
|
|
|
31
54
|
提供三个工具:
|
|
32
55
|
|
|
@@ -56,7 +79,7 @@ C、C++、C#、Go、Java、JavaScript / TypeScript(含 JSX/TSX)、Lua、Pyth
|
|
|
56
79
|
|
|
57
80
|
```sh
|
|
58
81
|
codeoutline serve --stdio [--project PATH] [--allow-root PATH ...]
|
|
59
|
-
codeoutline serve --http [--host HOST] [--port PORT] [--project PATH]
|
|
82
|
+
codeoutline serve --http [--host HOST] [--port PORT] [--project PATH] [--allow-root PATH ...]
|
|
60
83
|
codeoutline explore --project PATH --query QUERY [--budget BYTES]
|
|
61
84
|
codeoutline status [--project PATH]
|
|
62
85
|
codeoutline rebuild [--project PATH]
|
|
@@ -71,7 +94,7 @@ codeoutline doctor [--project PATH]
|
|
|
71
94
|
|
|
72
95
|
协议基线为 [MCP 2025-06-18](https://modelcontextprotocol.io/specification/2025-06-18/basic/transports)。查询预算为 256–262144 字节,默认 16000;超限输出保持 UTF-8 有效并附截断提示。路径均指服务所在机器。
|
|
73
96
|
|
|
74
|
-
stdio 模式下 stdout 只输出 MCP 消息,日志写入 stderr。HTTP 默认只监听本机,客户端地址为 `http://127.0.0.1:19876/mcp`。远程监听需设置至少 16 字节的 `CODEOUTLINE_TOKEN` 并用 `--allow-host` 显式允许主机,客户端使用 `Authorization: Bearer
|
|
97
|
+
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 反向代理保护令牌。
|
|
75
98
|
|
|
76
99
|
主线程处理协议,常驻索引线程串行处理查询。请求含进度 token 时每秒报告进度,HTTP 使用 SSE;没有独立的 GET/SSE 订阅端点(返回 405)。最多 64 个会话、64 个排队或执行中的任务;任务期限 120 秒,会话空闲 15 分钟过期。取消在每个文件的检查点生效,单个文件解析期间无法中断(单文件上限 1.5 MB);取消后丢弃可能不完整的内存索引,下次查询从缓存恢复。
|
|
77
100
|
|
package/bin/xnet.exe
CHANGED
|
Binary file
|
package/build-info.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"runtimeCommit":"f2c3ddfcbd3f04d7dd71543d0878d06e033519a0","lua":"LuaJIT 2.1.1774896198","sourceCommit":"130ebb1f85ca78c52119407f04a45fcb51a51ba6","sourceDirty":false,"releaseReady":true,"note":"Release build from a clean checkout","version":"0.1.2","target":"win32-x64","sha256":{"README.zh-CN.md":"4c2ff0fe0b73b3052f067926e45f9f9792571d9d529c731567b2c0d3b1d2c844","scripts/codeoutline/lang/python.lua":"f7219c04914673ee6bae387c222b09acd433596c746237bdd6650a4f4087b17c","DISTRIBUTION.md":"0de1a4699845a93c811a60bbb1dd3f7c1c4f39916c26e912fed5e621bcaf8b91","scripts/codeoutline/index_worker.lua":"47f80807a458d5c706b1a54f60fb2200ae51f022b21d9039df44611035e9ac40","licenses/mbedtls.txt":"9b405ef4c89342f5eae1dd828882f931747f71001cfba7d114801039b52ad09b","scripts/codeoutline/lang/rust.lua":"f7c21751b1ab08512a406f45bd53546dddfa98ff680b1374d29a4152ae110023","scripts/codeoutline/text.lua":"75f9af87ff5ce62def74f69d8972a6b11ff660723fc5cf515369ee3012ff0675","scripts/codeoutline/main.lua":"287c48d3006bf94fcf84e5e14b9a0a7379857c450f05bd850e3cb29119615d90","scripts/codeoutline/cli.lua":"ba996c3c3def65aab08ba60141a7a98a19dfcc1bbe004ab5d8ea14a7f9f9a08b","scripts/codeoutline/version.lua":"76d6123c414a5d03314de604c292f44e63e51ea3246f2702fca7ab93083b8dae","scripts/codeoutline/lang/c.lua":"1251352bcfac6b6d3704460e00b06cf4f41232144748b41b89db04a5ab594073","scripts/codeoutline/mcp.lua":"f14a2d0b9625544ad32309358121a5ff304839780f52d5c1c8ec548d56c5e901","scripts/codeoutline/command.lua":"e0fabf964487972eee3440f9b4b5e4b85bc713dd0266d7a429a53a96249150a6","scripts/codeoutline/xscan.lua":"508d1fdccee4e856e0f198992bec45d7c8a9a3c191e0a5f71717741db9e00325","scripts/codeoutline/parse.lua":"ccda7a087dc90109fce7a1e64ebe1de0d7c7036990b81b3423ff14b4299bf38f","scripts/codeoutline/common.lua":"ee775ed5b2f7ada7a02851f44b51bd4008bceacbf9700576a474e6732e3c03c2","scripts/codeoutline/lang/csharp.lua":"36ac648b8691c85b8c75d5bcb146fcdfc87992a278e4798f3eb194124e3df2bb","scripts/codeoutline/control.lua":"1dfbea9f1397d9fb3c321c48a8d8ee7fc7928e864588226e55247bd548255bb4","lib/xhttp_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","licenses/xnet2lua.txt":"1aa8af3df70f60f1ebf2d23e14c27af1606057ad9c32a9a0d15fd76cff257532","licenses/libdeflate.txt":"41b60f2caab6bffdd5ba360687bd23ca653c0a1235c00380ecffc939b4cd8d75","scripts/codeoutline/explore.lua":"d9e4e0d0179d00205df96ad0e7442e7bbc87e27481e6d27eb772ca302b5f35d3","LICENSE":"1b63179362acd482b4a9a07ca526b3fce6d9103dcded361de2159ade174568b6","licenses/luajit.txt":"1b10a02c9474cb908da2d87bc908edd8798f9ad28d9a8c53fbd05c13227f7394","THIRD_PARTY.md":"a70238f26ec05b7be4b813fa49c337cfb4d3cd64c36fcd27401d121e0e6e38df","README.md":"a1757e831f9d60d14cf318bd47cf8d9481a3e65b7bf99922064445d5d4913c89","scripts/codeoutline/graph.lua":"1ef35f2e92e9db3bbe9b612bb0cb336a9b57b440c9a066e7ba3ef81574326834","licenses/rpmalloc.txt":"f6c10eb9ec349900767c3dcb8bc71fe4fba2aefea329f05e2608827188016c0f","licenses/lua-cmsgpack.txt":"8edfdc5282278a1268d8a6ee52f9245f1a5fe3d1c8065be00330196b1de49873","scripts/codeoutline/lang/js.lua":"7a25a195356deeef7da3fdaf6e8a483b2a3a230cae3064e5dde2a3556fdcbda9","scripts/codeoutline/lang/go.lua":"f5717cbeabe6d30dad72c473fa445480d7fb6b5546bb262e5f4c46185f0959da","scripts/codeoutline/lang/cpp.lua":"96aebcd8972d5272c11446257f37fe90c10f4130c3c1b5bb71c793d7c25456f4","scripts/codeoutline/http.lua":"33802130445b348ce607e9891d4a9789d34b18338bf5d296f56e0b3c7b0c5493","bin/xnet.exe":"8c04f418e6784ff77405ba6ae50301cea0022af585269a4b57564854723cc442","scripts/codeoutline/path.lua":"407bd960c1ad04e5006b321ce33263393bb40eee5dee5c123be9b36d3ad10937","scripts/codeoutline/lang/lua.lua":"33b038192425e4db29251674e30c73b7a1af849789c49ff6430ee409c062f812","scripts/codeoutline/service.lua":"597c435309abc0d8149b5e88095896c3bba6516146fd587d53b4b6fbf23a553c","scripts/codeoutline/lang/java.lua":"435b6ddcd231679db9e705a604344a3fb6c00b84cc20b2ecd210423ee0b376a6","scripts/codeoutline/index.lua":"08c585a7cb264962ac04beb3bf5bc8a9dd22b4f85644b6fdd6a4e527843fbee9"}}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"repository":{"url":"git+https://github.com/1dao/codeoutline.git","type":"git"},"cpu":["x64","arm64"],"license":"BSD-2-Clause","name":"@codua/codeoutline-win32-x64","description":"CodeOutline native runtime and Lua implementation for win32-x64","os":["win32"],"version":"0.1.2","files":["bin/","lib/","scripts/","licenses/","LICENSE","codeoutline","codeoutline.cmd","build-info.json","*.md"],"publishConfig":{"access":"public"}}
|
|
@@ -7,7 +7,7 @@ local help = [[CodeOutline - Lua code indexing and MCP
|
|
|
7
7
|
|
|
8
8
|
Usage:
|
|
9
9
|
codeoutline serve --stdio [--project PATH] [--allow-root PATH ...]
|
|
10
|
-
codeoutline serve --http [--host HOST] [--port PORT] [--project PATH]
|
|
10
|
+
codeoutline serve --http [--host HOST] [--port PORT] [--project PATH] [--allow-root PATH ...]
|
|
11
11
|
codeoutline explore --project PATH --query QUERY [--budget BYTES]
|
|
12
12
|
codeoutline status [--project PATH]
|
|
13
13
|
codeoutline rebuild [--project PATH]
|
|
@@ -16,6 +16,8 @@ Usage:
|
|
|
16
16
|
|
|
17
17
|
HTTP options: --allow-host HOST, --allow-origin ORIGIN (repeatable).
|
|
18
18
|
Remote HTTP requires CODEOUTLINE_TOKEN (at least 16 bytes).
|
|
19
|
+
Local HTTP without --allow-root serves any project; stdio and remote HTTP
|
|
20
|
+
default to --project or the working directory.
|
|
19
21
|
Project defaults to the working directory for one-shot commands.
|
|
20
22
|
doctor reports JSON diagnostics and exits nonzero on a failed check.
|
|
21
23
|
]]
|
|
@@ -8,11 +8,7 @@ local shared = assert(xshared.dict('codeoutline_control'))
|
|
|
8
8
|
|
|
9
9
|
local function execute(req)
|
|
10
10
|
local root = assert(paths.canonical(req.projectPath))
|
|
11
|
-
|
|
12
|
-
for _, configured in ipairs(req.allowedRoots) do
|
|
13
|
-
if paths.contains(configured, root) then allowed = true; break end
|
|
14
|
-
end
|
|
15
|
-
assert(allowed, 'project path is outside allowed roots')
|
|
11
|
+
assert(paths.allowed(req.allowedRoots, root), 'project path is outside allowed roots')
|
|
16
12
|
if req.method == 'explore' then
|
|
17
13
|
local text, info = service.explore(root, req.query, { budget = req.budget })
|
|
18
14
|
return { text = text, truncated = info.truncated or false, refresh = info.refresh }
|
|
@@ -19,8 +19,27 @@ local config = { roots = {}, project = options.PROJECT and assert(paths.canonica
|
|
|
19
19
|
token = os.getenv('CODEOUTLINE_TOKEN'), hosts = options.ALLOW_HOST, origins = options.ALLOW_ORIGIN }
|
|
20
20
|
assert(config.port and config.port % 1 == 0 and config.port >= 1 and config.port <= 65535, 'Invalid PORT')
|
|
21
21
|
if config.token == '' then config.token = nil end
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
-- Stdio mode owns stdout for protocol messages, so its notices go to stderr.
|
|
23
|
+
local function notice(text)
|
|
24
|
+
local stream = options.STDIO == '1' and io.stderr or io.stdout
|
|
25
|
+
stream:write('[codeoutline] ', text, '\n'); stream:flush()
|
|
26
|
+
end
|
|
27
|
+
-- A missing root (an unmounted drive, say) is kept as written and matches once
|
|
28
|
+
-- it exists: failing startup would take down a service started at login.
|
|
29
|
+
for _, root in ipairs(options.ALLOW_ROOT) do
|
|
30
|
+
local canonical, err = paths.canonical(root)
|
|
31
|
+
if not canonical then notice('warning: allowed root ' .. root .. ' is unavailable (' .. err .. ')') end
|
|
32
|
+
config.roots[#config.roots + 1] = canonical or paths.normalize(root)
|
|
33
|
+
end
|
|
34
|
+
if #config.roots == 0 then
|
|
35
|
+
if options.HTTP == '1' and (config.host == '127.0.0.1' or config.host == 'localhost' or config.host == '::1') then
|
|
36
|
+
-- One loopback service serves every project of every session. Only local
|
|
37
|
+
-- processes reach it, and they already hold the user's file access.
|
|
38
|
+
config.roots = false
|
|
39
|
+
else
|
|
40
|
+
config.roots[1] = config.project or assert(paths.canonical('.'))
|
|
41
|
+
end
|
|
42
|
+
end
|
|
24
43
|
local shared = assert(xshared.create('codeoutline_control', 65536, 256))
|
|
25
44
|
local jobs, next_id, job_count, worker_ready = {}, 0, 0, false
|
|
26
45
|
local endpoint, stdio, input = nil, nil, ''
|
|
@@ -161,9 +161,7 @@ function M.new(config, submit, cancel)
|
|
|
161
161
|
local root, err
|
|
162
162
|
if project_path then root, err = paths.canonical(project_path)
|
|
163
163
|
else err = 'projectPath is required: no PROJECT, client root or working directory is available' end
|
|
164
|
-
|
|
165
|
-
if root then for _, r in ipairs(config.roots) do if paths.contains(r, root) then allowed = true; break end end end
|
|
166
|
-
if not root or not allowed then
|
|
164
|
+
if not root or not paths.allowed(config.roots, root) then
|
|
167
165
|
self.pending[id] = nil
|
|
168
166
|
result({ content = array({ { type = 'text', text = err or 'projectPath is outside allowed roots' } }), isError = true }); return
|
|
169
167
|
end
|
|
@@ -33,4 +33,14 @@ function M.contains(root, candidate)
|
|
|
33
33
|
return candidate == root or candidate:sub(1, #prefix) == prefix
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
-- `roots == false` is the unrestricted access of a loopback HTTP service
|
|
37
|
+
-- started without ALLOW_ROOT; otherwise the candidate must sit under a root.
|
|
38
|
+
function M.allowed(roots, candidate)
|
|
39
|
+
if roots == false then return true end
|
|
40
|
+
for _, root in ipairs(roots) do
|
|
41
|
+
if M.contains(root, candidate) then return true end
|
|
42
|
+
end
|
|
43
|
+
return false
|
|
44
|
+
end
|
|
45
|
+
|
|
36
46
|
return M
|
|
@@ -1 +1 @@
|
|
|
1
|
-
return '0.1.
|
|
1
|
+
return '0.1.2'
|