@shulex/cxclawctl 0.0.0-stage → 0.1.3
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 +231 -2
- package/bin/cxclawctl.mjs +11 -0
- package/dist/cli.js +2438 -0
- package/dist/cli.js.map +1 -0
- package/package.json +46 -4
package/README.md
CHANGED
|
@@ -1,3 +1,232 @@
|
|
|
1
|
-
#
|
|
1
|
+
# CXClaw
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
CXClaw 是 Solvea 内部使用的 Codex 插件。它把原 CXClaw 的业务能力带到本地 Codex:Codex 负责理解任务和编排步骤,`cxclaw` CLI 负责登录、选择租户、调用业务接口、执行本地工作流和直查 SLS。所有业务代码统一使用 TypeScript,Skills 只描述流程并调用 CLI。
|
|
4
|
+
|
|
5
|
+
插件不启动本地 MCP,也不依赖 `solvea-kit`。`shulex-cloud` 只提供钉钉授权、租户授权、服务配置和短期凭据;具体业务操作由本机 CLI 执行。
|
|
6
|
+
|
|
7
|
+
## 能力
|
|
8
|
+
|
|
9
|
+
- Agent 分析、配置、测试和交付
|
|
10
|
+
- 知识库构建、迁移和导入
|
|
11
|
+
- POC 交付与报告生成
|
|
12
|
+
- Solvea Desk 工单查询和报告
|
|
13
|
+
- badcase 排查与 SLS 客户端直查
|
|
14
|
+
- 测试、生产环境和跨租户切换
|
|
15
|
+
- 写操作的预览、确认、提交和结果核验
|
|
16
|
+
|
|
17
|
+
完整能力映射见 [`capabilities.lock.json`](./capabilities.lock.json)。`runtime-inspector` 只在 `dev` 和 `canary` 通道使用。
|
|
18
|
+
|
|
19
|
+
## 运行要求
|
|
20
|
+
|
|
21
|
+
- Codex CLI
|
|
22
|
+
- Node.js 22 或更高版本,包含 `npm` 和 `npx`
|
|
23
|
+
- 可用的系统安全凭据库:macOS Keychain、Windows Credential Manager 或 Linux Secret Service
|
|
24
|
+
|
|
25
|
+
Linux 没有 Secret Service 时会拒绝保存登录信息,不会把凭据写入明文文件。
|
|
26
|
+
|
|
27
|
+
## 安装
|
|
28
|
+
|
|
29
|
+
推荐使用稳定通道:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
codex plugin marketplace add SolveaCX/cx_claw_codex --ref marketplace/stable
|
|
33
|
+
codex plugin add cxclaw@cxclaw
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
然后登录公司提供的授权服务:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx --yes @shulex/cxclawctl@latest auth login --server <shulex-cloud 授权地址>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
CLI 会打开钉钉授权页。授权完成后,检查登录状态和本地版本:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx --yes @shulex/cxclawctl@latest auth status
|
|
46
|
+
npx --yes @shulex/cxclawctl@latest doctor
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
也可以用一条命令完成插件安装、登录和自动更新任务注册:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npx --yes @shulex/cxclawctl@latest setup \
|
|
53
|
+
--server <shulex-cloud 授权地址> \
|
|
54
|
+
--channel stable
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
可用通道为 `stable`、`canary` 和 `dev`。内部日常使用请选择 `stable`。
|
|
58
|
+
|
|
59
|
+
安装后的 Skills 不直接调用 npm `latest`。插件内的 `plugin-cli.mjs` 会读取插件清单版本,并调用完全相同版本的 `@shulex/cxclawctl`,避免新 CLI 与旧 Skills 混用。README 中的 `@latest` 命令只用于首次安装、人工诊断和更新入口。
|
|
60
|
+
|
|
61
|
+
## 选择环境和租户
|
|
62
|
+
|
|
63
|
+
测试环境使用 `--env test`,生产环境使用 `--env prod`。环境由每次租户选择明确指定,不从租户名称推断。
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# 搜索测试环境租户
|
|
67
|
+
npx --yes @shulex/cxclawctl@latest tenant search "租户名称" --env test
|
|
68
|
+
|
|
69
|
+
# 选择测试环境租户
|
|
70
|
+
npx --yes @shulex/cxclawctl@latest tenant use <accountId> \
|
|
71
|
+
--env test \
|
|
72
|
+
--purpose "badcase 排查"
|
|
73
|
+
|
|
74
|
+
# 查看或清除当前租户
|
|
75
|
+
npx --yes @shulex/cxclawctl@latest tenant current
|
|
76
|
+
npx --yes @shulex/cxclawctl@latest tenant clear
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
切换到生产环境时,重新执行 `tenant search` 和 `tenant use`,并把 `--env` 改为 `prod`。
|
|
80
|
+
|
|
81
|
+
## 常用命令
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# 查看版本和能力清单
|
|
85
|
+
npx --yes @shulex/cxclawctl@latest version
|
|
86
|
+
npx --yes @shulex/cxclawctl@latest version --json
|
|
87
|
+
npx --yes @shulex/cxclawctl@latest capabilities
|
|
88
|
+
|
|
89
|
+
# 调用只读业务命令;业务命令统一使用“资源 + 动作”两层结构
|
|
90
|
+
npx --yes @shulex/cxclawctl@latest agent get --id 456 --pretty
|
|
91
|
+
npx --yes @shulex/cxclawctl@latest intent list --pretty
|
|
92
|
+
|
|
93
|
+
# 使用 TypeScript CLI 执行本地工作流
|
|
94
|
+
npx --yes @shulex/cxclawctl@latest poc plan --init
|
|
95
|
+
npx --yes @shulex/cxclawctl@latest kb-builder crawl --url https://docs.example.com
|
|
96
|
+
npx --yes @shulex/cxclawctl@latest solvea-desk fetch-tickets --task-id demo
|
|
97
|
+
|
|
98
|
+
# 直接从本机查询 SLS;from/to 使用 Unix 秒级时间戳
|
|
99
|
+
npx --yes @shulex/cxclawctl@latest sls query \
|
|
100
|
+
--from <开始时间> \
|
|
101
|
+
--to <结束时间> \
|
|
102
|
+
--query '<查询语句>' \
|
|
103
|
+
--line 50
|
|
104
|
+
|
|
105
|
+
# 刷新登录或退出
|
|
106
|
+
npx --yes @shulex/cxclawctl@latest auth refresh
|
|
107
|
+
npx --yes @shulex/cxclawctl@latest auth logout
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 写操作
|
|
111
|
+
|
|
112
|
+
写操作必须先预览,再由用户明确确认。确认凭证通过 stdin 传入,不能写进命令参数、文件或日志。
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
npx --yes @shulex/cxclawctl@latest agent update \
|
|
116
|
+
--data-file update.json \
|
|
117
|
+
--phase preview \
|
|
118
|
+
--pretty
|
|
119
|
+
|
|
120
|
+
printf '%s' "$CONFIRMATION_TOKEN" | npx --yes @shulex/cxclawctl@latest agent update \
|
|
121
|
+
--data-file update.json \
|
|
122
|
+
--phase commit \
|
|
123
|
+
--confirmation-token-stdin \
|
|
124
|
+
--idempotency-key "$IDEMPOTENCY_KEY" \
|
|
125
|
+
--pretty
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## 更新
|
|
129
|
+
|
|
130
|
+
自动更新以 Git Marketplace 中的插件版本为准。更新任务先刷新当前配置的 `stable`、`canary` 或 `dev` Marketplace,再重新安装已启用的 CXClaw 插件;新版插件中的 `plugin-cli.mjs` 随后调用同版本 npm CLI:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
npx --yes @shulex/cxclawctl@latest update
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
注册每 6 小时执行一次的系统更新任务:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
npx --yes @shulex/cxclawctl@latest update --install-scheduler
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
更新任务使用安装时解析出的 Node.js 和 npm 绝对路径,避免 macOS LaunchAgent 等后台环境找不到 `npx`。更新后还会确认对应 npm CLI 版本已经公开可下载;检查失败时命令报错,不把不完整更新报告为成功。
|
|
143
|
+
|
|
144
|
+
更新完成后,新建 Codex 会话或重启 Codex,让新版 Skills 生效。已经运行中的会话继续使用启动时加载的旧版 Skills。
|
|
145
|
+
|
|
146
|
+
## 安全边界
|
|
147
|
+
|
|
148
|
+
- 登录信息只保存在操作系统安全凭据库。
|
|
149
|
+
- SLS 长期 AK/SK 不下发到客户端;CLI 每次查询只申请短期只读 STS,并直接连接阿里云 SLS。
|
|
150
|
+
- 客户端提供的 `tenantId`、`accountId` 和环境值不能直接作为授权依据,服务端签发的租户上下文才是最终权限边界。
|
|
151
|
+
- 业务 token 不输出到终端或日志,只在请求对象的生命周期内传给 CLI 的 HTTP client。
|
|
152
|
+
- `main` 分支只用于开发;员工使用由发布流程推进的 `marketplace/stable`、`marketplace/canary` 或 `marketplace/dev`。
|
|
153
|
+
|
|
154
|
+
## 本地开发
|
|
155
|
+
|
|
156
|
+
开发工具使用 Bun,运行时仍是 Node.js 22:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
bun install --frozen-lockfile
|
|
160
|
+
bun run typecheck
|
|
161
|
+
bun test
|
|
162
|
+
bun run build
|
|
163
|
+
bun run check:capabilities
|
|
164
|
+
bun run check:release
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
本地执行 CLI:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
bun run dev -- version
|
|
171
|
+
node bin/cxclawctl.mjs version
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
修改 Skills 或业务 command 后,重新生成并校验能力清单:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
bun run check:capabilities -- --write
|
|
178
|
+
bun run check:capabilities
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## 发布
|
|
182
|
+
|
|
183
|
+
使用版本准备脚本同步修改 npm、插件清单和能力清单中的版本:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
bun run release:prepare <版本号>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
版本规则:
|
|
190
|
+
|
|
191
|
+
- `vX.Y.Z` 发布到 `stable`
|
|
192
|
+
- `vX.Y.Z-canary.N` 发布到 `canary`
|
|
193
|
+
- `vX.Y.Z-dev.N` 发布到 `dev`
|
|
194
|
+
|
|
195
|
+
稳定版必须在 `release/vX.Y.Z` 分支准备版本并创建 PR。PR 经过评审并合入 `main` 后,GitHub Actions 才会创建 tag 和发布。不要直接推送稳定版 tag。
|
|
196
|
+
|
|
197
|
+
`canary` 和 `dev` 预发布版在通过 CI 的提交上推送对应 tag 后发布:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
git push origin vX.Y.Z-canary.N
|
|
201
|
+
git push origin vX.Y.Z-dev.N
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
发布流水线会固定到触发发布的 Git commit,并依次执行测试、构建、能力校验、npm 发布、GitHub Release 和 Marketplace 通道推进。只有前一步成功才会执行下一步;npm 包未发布时不会推进 `marketplace/<channel>`。
|
|
205
|
+
|
|
206
|
+
npm 发布需要在 GitHub 的 `npm-publish` Environment 或仓库中配置 Secret `NPM_TOKEN`。缺少凭据会让发布失败,不会跳过。
|
|
207
|
+
|
|
208
|
+
发布产物包括:
|
|
209
|
+
|
|
210
|
+
```text
|
|
211
|
+
cxclaw-agent-plugin.zip
|
|
212
|
+
cxclaw-agent-plugin.json
|
|
213
|
+
cxclaw-agent-plugin.sha256
|
|
214
|
+
cxclaw-codex-plugin.zip
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
插件 ZIP 只从已提交的 Git 快照生成,不会包含本地未提交文件。
|
|
218
|
+
|
|
219
|
+
## 仓库结构
|
|
220
|
+
|
|
221
|
+
```text
|
|
222
|
+
.agents/plugins/marketplace.json Git Marketplace 清单
|
|
223
|
+
.codex-plugin/plugin.json Codex 插件清单
|
|
224
|
+
plugin-cli.mjs 将插件固定到同版本 npm CLI
|
|
225
|
+
bin/cxclawctl.mjs npm CLI 入口
|
|
226
|
+
src/ TypeScript CLI 和业务工作流实现
|
|
227
|
+
skills/ Marketplace Skills、reference 和静态资源
|
|
228
|
+
capabilities.lock.json Skills 与业务 command 能力映射
|
|
229
|
+
scripts/ 能力校验和发布打包脚本
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
npm 包只包含 CLI 运行时代码;`SKILL.md`、reference 文档和静态资源只通过 Git Marketplace 分发,不在 npm 中重复打包。
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import module from "node:module";
|
|
3
|
+
|
|
4
|
+
const major = Number(process.versions.node.split(".")[0]);
|
|
5
|
+
if (major < 22) {
|
|
6
|
+
console.error(`CXClaw requires Node.js >= 22; current version is ${process.versions.node}`);
|
|
7
|
+
process.exitCode = 1;
|
|
8
|
+
} else {
|
|
9
|
+
module.enableCompileCache?.();
|
|
10
|
+
await import("../dist/cli.js");
|
|
11
|
+
}
|