Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ coverage/

# npm pack output
*.tgz
.zcode/plans/
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Examples:

## Reporting Bugs

Open a [GitHub Issue](https://github.com/zcode-org/zcode-acp-server/issues) with:
Open a [GitHub Issue](https://github.com/william0wang/zcode-acp/issues) with:
- ZCode CLI version (`zcode --version`)
- Editor + version (Zed, JetBrains, ...)
- Node.js version (`node --version`)
Expand Down
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# zcode-acp-server

[![CI](https://github.com/zcode-org/zcode-acp-server/actions/workflows/ci.yml/badge.svg)](https://github.com/zcode-org/zcode-acp-server/actions/workflows/ci.yml)
[![CI](https://github.com/william0wang/zcode-acp/actions/workflows/ci.yml/badge.svg)](https://github.com/william0wang/zcode-acp/actions/workflows/ci.yml)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)

English | **[简体中文](README.zh-CN.md)**
Expand Down Expand Up @@ -87,6 +87,34 @@ automatically. Point `ZCODE_BIN` at the bundled `zcode.cjs`:
| `ZCODE_BASE_URL` | _(from config)_ | Override the provider base URL |
| `ZCODE_ACP_DEBUG` | _(unset)_ | Set to `1` to enable verbose diagnostic logs (event flow, probe loops, status updates). Default is quiet — only warnings (backend pipe errors, command/permission failures, lock timeouts) are emitted. Enable this when diagnosing bridge issues; the logs appear in `Zed.log` prefixed with `[zcode-acp]`. |

## Standalone Quota CLI

Besides the ACP server, the package ships a `zcode-quota` bin that queries
your GLM Coding Plan usage **from the terminal** — no editor or running server
needed. It reads the same `~/.zcode/v2/config.json` for credentials.

```bash
# One-shot: print the card and exit
zcode-quota

# Live monitor: clear the screen and refresh every 30s (default)
zcode-quota -w

# Refresh at a custom interval (seconds; minimum 10)
zcode-quota --watch --interval 60
```

The watch mode clears and redraws the card in place, like `top`/`htop`. Press
`Ctrl-C` to exit. The 10s minimum exists because the quota API is cached for
10s internally — a shorter interval would just keep returning the stale cached
value.

When the package isn't globally installed, run the built file directly:

```bash
node dist/bin/quota.js -w
```

## ACP Registry

This server is compatible with the [ACP Registry](https://agentclientprotocol.com/get-started/registry). It advertises a single `agent`-type auth method at `initialize` time — the GLM API key is read from `~/.zcode/v2/config.json` by the ZCode backend, so **no editor-side credentials are required**.
Expand Down Expand Up @@ -157,6 +185,23 @@ recorded in [CHANGELOG.md](CHANGELOG.md).
- [ZCode](https://zcode.z.ai) / [Zhipu Z.AI](https://z.ai) — the GLM model and ZCode CLI
- [zcode-open-bridge](https://github.com/tizerluo/zcode-open-bridge) — reference implementation that informed this server's design

## Privacy

**No telemetry or tracking** — the server reports nothing to anyone. The only
runtime dependency beyond the ACP SDK is `zod`.

Your prompts, code, and file contents are relayed between the editor and the
ZCode backend over **local pipes**; that data reaches the GLM cloud API only
because the ZCode backend itself sends it there for inference — this server
adds no extra destinations.

| Concern | What & why |
| ------- | ---------- |
| Network | Only one outbound request in the whole codebase: the quota GET (`open.bigmodel.cn` / `api.z.ai`), carrying just your API key — needed to fetch your usage numbers, sends no user content |
| Credentials | API key read from `~/.zcode/v2/config.json` to authenticate the ZCode subprocess and quota request. Never logged, never written elsewhere. OAuth handled entirely by the ZCode subprocess |
| Disk | No new files created. Writes only to the existing `~/.zcode/v2/tasks-index.sqlite` — this **syncs sessions to the ZCode app** so they appear in its history list and full-text search (stores the session title and first prompt) |
| Logging | Diagnostics to stderr for troubleshooting bridge issues. Even with `ZCODE_ACP_DEBUG=1`, no prompts/code/keys are ever logged |

## License

Apache-2.0. This project follows the same license as the upstream ACP specification.
Expand Down
44 changes: 43 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# zcode-acp-server

[![CI](https://github.com/zcode-org/zcode-acp-server/actions/workflows/ci.yml/badge.svg)](https://github.com/zcode-org/zcode-acp-server/actions/workflows/ci.yml)
[![CI](https://github.com/william0wang/zcode-acp/actions/workflows/ci.yml/badge.svg)](https://github.com/william0wang/zcode-acp/actions/workflows/ci.yml)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)

**[English](README.md)** | 简体中文
Expand Down Expand Up @@ -86,6 +86,33 @@ ZCode CLI 内置于桌面应用中,默认不会加到 `PATH`。用 `ZCODE_BIN`
| `ZCODE_BASE_URL` | _(来自 config) | 覆盖 provider 的 base URL |
| `ZCODE_ACP_DEBUG` | _(未设置) | 设为 `1` 可开启详细诊断日志(事件流、探测循环、状态更新)。默认安静——只输出警告类日志(后端管道错误、命令/权限失败、锁等待超时)。诊断桥接问题时开启;日志出现在 `Zed.log` 中,前缀为 `[zcode-acp]`。 |

## 独立配额查询 CLI(zcode-quota)

除了 ACP server,本包还附带一个 `zcode-quota` 命令,可在**终端**里直接查询
GLM Coding Plan 用量——无需编辑器,也无需 server 运行。它读取同一个
`~/.zcode/v2/config.json` 获取凭证。

```bash
# 一次性:打印卡片后退出
zcode-quota

# 常驻监控:清屏并每 30s 刷新(默认)
zcode-quota -w

# 自定义刷新间隔(秒,最小 10)
zcode-quota --watch --interval 60
```

watch 模式会原地清屏重绘卡片,效果类似 `top`/`htop`。按 `Ctrl-C` 退出。
之所以设最小间隔 10s,是因为配额 API 内部有 10s 缓存——更短的间隔只会一直
返回过期的缓存值,没有意义。

未全局安装时,可直接运行构建产物:

```bash
node dist/bin/quota.js -w
```

## ACP Registry

本服务端兼容 [ACP Registry](https://agentclientprotocol.com/get-started/registry)。它在 `initialize` 时声明一个 `agent` 类型的认证方法——GLM API key 由 ZCode 后端从 `~/.zcode/v2/config.json` 读取,**编辑器侧无需配置任何凭据**。
Expand Down Expand Up @@ -154,6 +181,21 @@ commit 约定和 PR 检查清单。重要变更记录在 [CHANGELOG.md](CHANGELO
- [ZCode](https://zcode.z.ai) / [智谱 Z.AI](https://z.ai) —— GLM 模型与 ZCode CLI
- [zcode-open-bridge](https://github.com/tizerluo/zcode-open-bridge) —— 参考实现,本项目的设计借鉴了它的桥接架构

## 隐私

**无遥测、无追踪** —— 本服务端不向任何方上报任何信息。除 ACP SDK 外唯一运行时依赖是
`zod`。

你的提示词、代码、文件内容通过**本地管道**在编辑器与 ZCode 后端之间中转;这些数据会到达
GLM 云端 API,仅因 ZCode 后端本身为推理而发送——本服务端不增加任何额外去向。

| 方面 | 做什么 & 为什么 |
| ---- | --------------- |
| 网络 | 全代码库仅一处对外请求:配额 GET(`open.bigmodel.cn` / `api.z.ai`),只带 API key —— 为查询用量数字,不发送用户内容 |
| 凭据 | API key 从 `~/.zcode/v2/config.json` 读取,用于认证 ZCode 子进程和配额请求。从不记录日志、从不写入别处。OAuth 完全由 ZCode 子进程处理 |
| 磁盘 | 不创建任何新文件。只写入已存在的 `~/.zcode/v2/tasks-index.sqlite` —— 这是**将会话同步到 ZCode App**,使其出现在历史列表和全文搜索中(存会话标题和首条提示词) |
| 日志 | 诊断信息输出到 stderr,用于排查桥接问题。即使开启 `ZCODE_ACP_DEBUG=1`,也绝不记录提示词/代码/密钥 |

## 许可证

Apache-2.0。本项目沿用上游 ACP 规范的同一许可证。
Expand Down
14 changes: 14 additions & 0 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ This ensures the snapshot diff does not re-emit tools already handled by the
event path, preventing Bash terminal output from being overwritten by a
content-less ToolCallNew.

## Data & Privacy

**No telemetry, no analytics, no third-party network calls.** The server is a
local relay: prompts, code, and tool outputs pass through process memory on
their way between the editor and the ZCode subprocess, but reach the GLM cloud
API only because the ZCode backend itself sends them for inference.

| Concern | Detail |
| ------- | ------ |
| Network | One outbound request in the whole codebase — `src/quota/client.ts` GET to the quota API, Bearer token only, no body |
| Credentials | API key from `~/.zcode/v2/config.json` (authenticates the subprocess + quota request), never logged. OAuth handled by the ZCode subprocess, not this server |
| Disk | No new files. Writes only to the existing `~/.zcode/v2/tasks-index.sqlite` — syncs sessions into the ZCode app's history & search (session title + first prompt) |
| Logging | `log()`/`warn()` → stderr only for troubleshooting; even with `ZCODE_ACP_DEBUG=1`, no prompts/code/keys are logged |

## Module Responsibilities

### `backend/` — ZCode process communication
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"author": "ZCode ACP Server Contributors",
"repository": {
"type": "git",
"url": "https://github.com/zcode-org/zcode-acp-server.git"
"url": "https://github.com/william0wang/zcode-acp.git"
},
"homepage": "https://github.com/zcode-org/zcode-acp-server#readme",
"homepage": "https://github.com/william0wang/zcode-acp#readme",
"bugs": {
"url": "https://github.com/zcode-org/zcode-acp-server/issues"
"url": "https://github.com/william0wang/zcode-acp/issues"
},
"keywords": [
"acp",
Expand All @@ -23,7 +23,8 @@
"zcode"
],
"bin": {
"zcode-acp-server": "dist/index.js"
"zcode-acp-server": "dist/index.js",
"zcode-quota": "dist/bin/quota.js"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Loading
Loading