xuanzhu 0.1.3 → 0.1.5
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/LICENSE +1 -0
- package/README.md +84 -28
- package/dist/cli.js +173 -139
- package/package.json +13 -4
package/LICENSE
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2026 Oyinlola Olasunkanmi Raymond
|
|
4
|
+
Copyright (c) 2026 amble311 (玄猪 XuanZhu 的改造与衍生部分)
|
|
4
5
|
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -2,8 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
> 专为终端打造的 AI 编码 Agent —— 一条 `xzh` 命令,把 AI 编程助手带进你的终端。
|
|
4
4
|
|
|
5
|
+
## 快速上手
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i -g xuanzhu # 安装(需要 Node.js ≥ 18)
|
|
9
|
+
xzh model # 配置模型:选服务商、填 API Key
|
|
10
|
+
xzh # 启动
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 简介
|
|
14
|
+
|
|
5
15
|
玄猪是一个运行在终端里的全屏 AI Agent:它能读懂你的代码库、直接读写文件、执行命令、运行测试,
|
|
6
|
-
并用流式输出向你展示它的每一步思考与工具调用。内核采用了codebuddy的开源代码。
|
|
16
|
+
并用流式输出向你展示它的每一步思考与工具调用。内核采用了 codebuddy 的开源代码。
|
|
7
17
|
|
|
8
18
|
```
|
|
9
19
|
╭──────────────────────────────────────────────╮
|
|
@@ -17,7 +27,7 @@
|
|
|
17
27
|
- **多模型支持**:DeepSeek、Anthropic Claude、OpenAI、Google Gemini、智谱 GLM、通义千问、Groq、Ollama,以及任意 OpenAI 兼容端点。
|
|
18
28
|
- **内置工具**:读取 / 写入 / 编辑文件、列目录、glob 查找、grep 搜索、执行 shell 命令。
|
|
19
29
|
- **流式响应**:实时渲染 Markdown,支持代码块,中文对齐正确。
|
|
20
|
-
-
|
|
30
|
+
- **默认全自动**:`autoApprove` 默认为 `true`,所有工具——包括写文件、执行命令、读取工作区之外的文件——都直接执行,无需逐项确认,开箱即用;`/auto off` 可切换为写文件与执行命令逐项确认。唯一的例外是读取**凭据类文件**(`~/.ssh`、`.env`、`~/.xzh/config.json`、`*.pem` 等)时会确认一次 —— 防止凭据被读进上下文并转交给模型服务商。这与是否在工作区内无关。
|
|
21
31
|
- **多轮自主执行**:自动串联工具调用完成任务,可随时 `Ctrl+C` 中断。
|
|
22
32
|
|
|
23
33
|
## 环境要求
|
|
@@ -27,33 +37,35 @@
|
|
|
27
37
|
|
|
28
38
|
## 安装
|
|
29
39
|
|
|
30
|
-
###
|
|
40
|
+
### 方式一:npm(推荐)
|
|
31
41
|
|
|
32
|
-
|
|
42
|
+
```bash
|
|
43
|
+
npm i -g xuanzhu # 全局安装
|
|
44
|
+
xzh # 启动
|
|
45
|
+
```
|
|
33
46
|
|
|
34
|
-
|
|
35
|
-
因此**不要求包已发布到 npm**:
|
|
47
|
+
不想全局安装,也可以免安装试用:
|
|
36
48
|
|
|
37
49
|
```bash
|
|
38
|
-
|
|
39
|
-
./install.sh
|
|
50
|
+
npx xuanzhu
|
|
40
51
|
```
|
|
41
52
|
|
|
42
|
-
|
|
53
|
+
> 若安装后提示 `xzh: command not found`,说明 npm 的全局 `bin` 目录不在 `PATH` 中,
|
|
54
|
+
> 见下方「PATH 配置」。
|
|
43
55
|
|
|
44
|
-
|
|
56
|
+
### 方式二:一键脚本
|
|
45
57
|
|
|
46
|
-
|
|
47
|
-
# Linux / macOS
|
|
48
|
-
curl -fsSL https://raw.githubusercontent.com/<owner>/<repo>/main/install.sh | sh
|
|
58
|
+
**Linux / macOS**
|
|
49
59
|
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
```bash
|
|
61
|
+
curl -fsSL https://raw.githubusercontent.com/amble311/xuanzhu/main/install.sh | sh
|
|
52
62
|
```
|
|
53
63
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
**Windows(PowerShell)**
|
|
65
|
+
|
|
66
|
+
```powershell
|
|
67
|
+
iex (irm https://raw.githubusercontent.com/amble311/xuanzhu/main/install.ps1)
|
|
68
|
+
```
|
|
57
69
|
|
|
58
70
|
脚本会检查 Node.js 版本、全局安装 `xzh`,并在需要时提示补充 PATH。
|
|
59
71
|
|
|
@@ -64,7 +76,7 @@ iex (irm https://raw.githubusercontent.com/<owner>/<repo>/main/install.ps1)
|
|
|
64
76
|
npm config set prefix ~/.npm-global # 然后确保 ~/.npm-global/bin 在 PATH 中
|
|
65
77
|
```
|
|
66
78
|
|
|
67
|
-
|
|
79
|
+
**脚本支持的环境变量**
|
|
68
80
|
|
|
69
81
|
| 变量 | 作用 |
|
|
70
82
|
| --- | --- |
|
|
@@ -73,23 +85,29 @@ npm config set prefix ~/.npm-global # 然后确保 ~/.npm-global/bin 在 PATH
|
|
|
73
85
|
| `XZH_NPM_ARGS` | 追加给 npm 的参数,如国内镜像 `--registry=https://registry.npmmirror.com` |
|
|
74
86
|
| `XZH_DRY_RUN=1` | 只打印将要执行的命令,不真正安装 |
|
|
75
87
|
|
|
76
|
-
###
|
|
88
|
+
### 方式三:从源码安装(开发用)
|
|
77
89
|
|
|
78
90
|
```bash
|
|
79
|
-
|
|
91
|
+
git clone https://github.com/amble311/xuanzhu.git
|
|
92
|
+
cd xuanzhu
|
|
80
93
|
npm install
|
|
81
94
|
npm run build
|
|
82
|
-
|
|
83
|
-
# 全局链接,使 xzh 命令可用
|
|
84
|
-
npm link
|
|
95
|
+
npm link # 使 xzh 命令指向本地源码
|
|
85
96
|
```
|
|
86
97
|
|
|
87
|
-
|
|
98
|
+
改动源码后执行 `npm run build` 即生效(`npm link` 建立的是软链)。
|
|
99
|
+
想切回正式发布的版本:
|
|
88
100
|
|
|
89
101
|
```bash
|
|
90
|
-
|
|
102
|
+
npm unlink -g xuanzhu && npm i -g xuanzhu
|
|
91
103
|
```
|
|
92
104
|
|
|
105
|
+
### 环境要求
|
|
106
|
+
|
|
107
|
+
- **Node.js ≥ 18**
|
|
108
|
+
- **真实终端**:TUI 需要交互式终端,在管道、CI 或部分编辑器内置终端中无法运行
|
|
109
|
+
- 首次运行会在**当前工作目录**创建 `.xuanzhu/`(项目记忆与规则),建议写入 `.gitignore`
|
|
110
|
+
|
|
93
111
|
## 快速开始
|
|
94
112
|
|
|
95
113
|
```bash
|
|
@@ -150,7 +168,7 @@ XZH_HOME=/path/to/dir xzh # 改用 /path/to/dir/config.json
|
|
|
150
168
|
{ "id": "openai/gpt-4o", "provider": "openai", "model": "gpt-4o", "weight": 6 }
|
|
151
169
|
],
|
|
152
170
|
"temperature": 0.2,
|
|
153
|
-
"maxToolRounds":
|
|
171
|
+
"maxToolRounds": 200,
|
|
154
172
|
"autoApprove": true,
|
|
155
173
|
"intent": { "enabled": false },
|
|
156
174
|
"providers": {
|
|
@@ -291,7 +309,7 @@ API Key 也可以来自环境变量,优先级低于配置文件:
|
|
|
291
309
|
| --- | --- |
|
|
292
310
|
| `.xuanzhu/memory/MEMORY.md` | 长期记忆:稳定的项目结论与约定,启动时会注入系统提示词(节选) |
|
|
293
311
|
| `.xuanzhu/memory/YYYY-MM-DD.md` | 每日日志:按天追加的过程记录 |
|
|
294
|
-
| `.xuanzhu/rules.md` |
|
|
312
|
+
| `.xuanzhu/rules.md` | 项目规则,内容作为「项目级指令」注入系统提示词。**首次初始化时若项目根已有 `AGENTS.md`**,会以它的内容作为初始规则 |
|
|
295
313
|
|
|
296
314
|
记忆由玄猪自行维护:
|
|
297
315
|
|
|
@@ -467,6 +485,44 @@ npm run typecheck # 类型检查
|
|
|
467
485
|
node bin/xzh.js # 本地运行
|
|
468
486
|
```
|
|
469
487
|
|
|
488
|
+
### 发布新版本
|
|
489
|
+
|
|
490
|
+
```bash
|
|
491
|
+
./release.sh # 版本尾号 +1(0.1.4 → 0.1.5)
|
|
492
|
+
./release.sh minor # 0.1.4 → 0.2.0
|
|
493
|
+
./release.sh 1.0.0 # 指定版本
|
|
494
|
+
XZH_RELEASE_DRY_RUN=1 ./release.sh # 先演练一遍,不做任何写入
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
脚本会依次完成:**版本号 +1 → `npm publish` → 等待 registry 同步 → 提交并推送 GitHub
|
|
498
|
+
→ 更新本机全局安装**。
|
|
499
|
+
|
|
500
|
+
之所以需要脚本,是因为这条链路有几个反直觉的地方:`npm publish` 返回成功**不等于**
|
|
501
|
+
registry 已可见(npm 有 staging 阶段,期间 `npm view` / `npm install` 会报 `notarget`),
|
|
502
|
+
而版本号、GitHub 提交、npm 包三者又必须保持一致。脚本把它们串起来并自动等待与重试。
|
|
503
|
+
|
|
504
|
+
| 环境变量 | 作用 |
|
|
505
|
+
| --- | --- |
|
|
506
|
+
| `XZH_RELEASE_DRY_RUN=1` | 只演练,不改版本、不发布、不推送 |
|
|
507
|
+
| `XZH_RELEASE_YES=1` | 跳过发布前的确认提示 |
|
|
508
|
+
| `XZH_RELEASE_SKIP_GIT=1` | 不推送 GitHub |
|
|
509
|
+
| `XZH_RELEASE_SKIP_LOCAL=1` | 不更新本机全局安装 |
|
|
510
|
+
| `XZH_RELEASE_WAIT=<秒>` | 等待 registry 同步的上限(默认 300) |
|
|
511
|
+
|
|
512
|
+
## 致谢
|
|
513
|
+
|
|
514
|
+
本项目站在前人的开源工作上,特别感谢:
|
|
515
|
+
|
|
516
|
+
- **[CodeBuddy](https://github.com/olasunkanmi-SE/codebuddy)** —— 作者
|
|
517
|
+
[Oyinlola Olasunkanmi Raymond](https://github.com/olasunkanmi-SE)。
|
|
518
|
+
玄猪由该项目改造而来(移除编辑器依赖、改为纯粹的终端形态),
|
|
519
|
+
并依 MIT 许可**保留其原始版权声明**。
|
|
520
|
+
- **[Playwright](https://github.com/microsoft/playwright)** —— 由 Microsoft 开源。
|
|
521
|
+
内置的 `playwright` 技能基于它实现浏览器自动化与端到端测试。
|
|
522
|
+
|
|
523
|
+
同时也感谢所有直接与间接依赖的开源项目,以及 npm 生态中的众多工具
|
|
524
|
+
(完整清单见 `package.json`)。
|
|
525
|
+
|
|
470
526
|
## License
|
|
471
527
|
|
|
472
528
|
MIT
|