@dtinsight/dt-cli 0.0.0-stage → 0.1.0
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.
Potentially problematic release.
This version of @dtinsight/dt-cli might be problematic. Click here for more details.
- package/README.md +207 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4425 -0
- package/package.json +45 -4
package/README.md
CHANGED
|
@@ -1,3 +1,208 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dt-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
面向开发者和 AI Agent 的 DTStack 统一研发 CLI,覆盖禅道 Bug、GitLab MR、Git 分支和 OMP 部署工作流。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @dtstack/dt-cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
升级到最新版:`npm install -g @dtstack/dt-cli@latest`。
|
|
12
|
+
|
|
13
|
+
## 开发
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm install
|
|
17
|
+
pnpm check
|
|
18
|
+
pnpm dev -- bug --help
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Node.js 版本要求:18.17 或更高。
|
|
22
|
+
|
|
23
|
+
## 配置
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
export DTSTACK_ZENTAO_BASE_URL='http://172.16.85.194:6789'
|
|
27
|
+
export DTSTACK_USER='your-zentao-account'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
禅道 Bug 接口无需登录,配置 API 地址后即可直接查询。
|
|
31
|
+
|
|
32
|
+
## Bug 命令
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# ID、URL 和批量查询
|
|
36
|
+
dt bug view 148878
|
|
37
|
+
dt bug view 'http://zenpms.dtstack.cn/zentao/bug-view-148878.html'
|
|
38
|
+
dt bug view 148878 148879
|
|
39
|
+
dt bug view 148878,148879 -json
|
|
40
|
+
|
|
41
|
+
# 模糊搜索
|
|
42
|
+
dt bug search '资产目录' -limit 20
|
|
43
|
+
|
|
44
|
+
# 精确筛选
|
|
45
|
+
dt bug list -assigned-to zhangsan -status active,resolved
|
|
46
|
+
dt bug list -product 数据资产 -assigned-from 2026-09-01 -assigned-to-date 2026-09-10
|
|
47
|
+
|
|
48
|
+
# 查询分配给自己或指定用户的 Bug
|
|
49
|
+
dt bug assigned
|
|
50
|
+
dt bug assigned lisi -status active
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
终端交互时默认输出可读表格;stdout 不是 TTY 时自动输出 JSON,也可使用 `-json` 强制开启:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"ok": true,
|
|
58
|
+
"schemaVersion": "1",
|
|
59
|
+
"data": [],
|
|
60
|
+
"meta": {
|
|
61
|
+
"command": "bug.search",
|
|
62
|
+
"durationMs": 42,
|
|
63
|
+
"requestId": "..."
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
诊断信息写入 stderr,结构化结果写入 stdout,失败时进程退出码为 `1`。
|
|
69
|
+
|
|
70
|
+
### API 映射
|
|
71
|
+
|
|
72
|
+
| 命令 | 接口 | 请求方法 |
|
|
73
|
+
| --- | --- | --- |
|
|
74
|
+
| `bug view` | `/bugs/details` | POST |
|
|
75
|
+
| `bug search` | `/bugs/search` | POST |
|
|
76
|
+
| `bug list` | `/bugs/precise` | POST |
|
|
77
|
+
| `bug assigned` | `/bugs/precise` | POST |
|
|
78
|
+
|
|
79
|
+
`bug view` 会先把单个 ID、逗号/空格分隔的 ID 列表以及
|
|
80
|
+
`bug-view-{bugId}.html` 链接解析为数字,并以
|
|
81
|
+
`{"bugIds":[148878]}` 的格式请求 `/bugs/details`;不会向该接口发送字符串 ID。
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
## Git 分支命令
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# 先预览:不会 fetch、checkout 或 push
|
|
88
|
+
dt branch create fix 158741 \
|
|
89
|
+
-app dataAssets \
|
|
90
|
+
-branch-version 6.3.x \
|
|
91
|
+
-dry-run \
|
|
92
|
+
-json
|
|
93
|
+
|
|
94
|
+
# 来源分支唯一时,正式创建并推送
|
|
95
|
+
dt branch create hotfix 158742 \
|
|
96
|
+
-app batch \
|
|
97
|
+
-branch-version 7.0.x
|
|
98
|
+
|
|
99
|
+
# 多个 test/release 来源分支时显式选择
|
|
100
|
+
dt branch create feat 10988 \
|
|
101
|
+
-app batch \
|
|
102
|
+
-branch-version 6.4.x \
|
|
103
|
+
-base batch/test_6.4.x_v651
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`branch create` 支持 `feat`、`fix`、`hotfix`、`conflict`。它先通过 `git ls-remote` 匹配来源分支;正式执行时依次 fetch 来源、创建本地分支并默认 push。使用 `-no-push` 可只创建本地分支。标准 test 分支的 `v{迭代号}` 不会进入目标名称,定制化来源分支的标识会原样保留。
|
|
107
|
+
|
|
108
|
+
## GitLab Merge Request
|
|
109
|
+
|
|
110
|
+
GitLab 能力复用本机 `glab` 的认证和仓库识别:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
dt auth login gitlab
|
|
114
|
+
dt auth status gitlab
|
|
115
|
+
dt auth logout gitlab
|
|
116
|
+
|
|
117
|
+
# 使用显式目标分支,根据当前分支和提交记录生成并创建 MR
|
|
118
|
+
dt mr create -target dataAssets/test_6.3.x -repo customltem/dt-insight-studio
|
|
119
|
+
|
|
120
|
+
# 只预览源分支、目标分支、标题和描述,不推送、不创建
|
|
121
|
+
dt mr create -target dataAssets/test_6.3.x -dry-run -json
|
|
122
|
+
|
|
123
|
+
# 显式指定目标、处理人,且合并后保留源分支
|
|
124
|
+
dt mr create -target batch/test_6.2.x -assignee shuangxu -keep-source-branch
|
|
125
|
+
|
|
126
|
+
# test 分支对应的 release -> test MR
|
|
127
|
+
dt mr create -release-to-test -target batch/test_6.2.x
|
|
128
|
+
|
|
129
|
+
# 在目标 Git 仓库中可省略 -repo
|
|
130
|
+
dt mr view 2711
|
|
131
|
+
dt mr list -mine
|
|
132
|
+
dt mr diff 2711
|
|
133
|
+
dt mr pipeline 2711
|
|
134
|
+
|
|
135
|
+
# 在其他目录显式指定仓库
|
|
136
|
+
dt mr view 2711 -repo customltem/dt-insight-studio -json
|
|
137
|
+
dt mr list -repo customltem/dt-insight-studio -state opened -page-size 20
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
可通过 `DTSTACK_GITLAB_HOST` 修改默认 GitLab Host。
|
|
141
|
+
|
|
142
|
+
`mr create` 要求显式传入 `-target`,不会根据分支名猜测目标分支。命令会从 `git log <target>..<source>` 生成标题、变更类型和禅道链接。普通 MR 默认推送源分支,并显式设置合并后删除源分支;使用 `-no-push` 或 `-keep-source-branch` 可覆盖。只有显式传入 `-commit-message` 时才会暂存全部改动并提交。
|
|
143
|
+
|
|
144
|
+
## OMP 部署
|
|
145
|
+
|
|
146
|
+
首次使用先交互登录,密码输入不会回显。登录成功后只缓存 OMP 返回的 access token,不保存账号密码:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
dt auth login omp
|
|
150
|
+
dt auth status omp
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
也兼容 `OMP_MCP_USERNAME` / `OMP_MCP_PASSWORD` 环境变量,且环境变量优先于 access token 缓存。使用 `dt auth logout omp` 可删除当前 access token;环境变量不会被修改。token 过期或接口返回 401/403 且没有环境变量密码时,需要重新执行 `dt auth login omp`。
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# 查询环境,部署前用这里返回的真实 envId
|
|
157
|
+
dt omp list-env
|
|
158
|
+
|
|
159
|
+
# 提交当前 Git 分支;-service 可重复传入
|
|
160
|
+
dt omp deploy -env-id 137 -service AssetsFront
|
|
161
|
+
|
|
162
|
+
# 显式指定分支,并让 OMP 合并到新分支后部署
|
|
163
|
+
dt omp deploy -env-id 137 \
|
|
164
|
+
-branch dataAssets/feat_6.3.x_ltqc_15127 \
|
|
165
|
+
-service AssetsFront \
|
|
166
|
+
-merge \
|
|
167
|
+
-new-branch dataAssets/test_6.3.x
|
|
168
|
+
|
|
169
|
+
# 查询部署记录;status 对应 OMP 的 build_status
|
|
170
|
+
dt omp list-log -limit 20
|
|
171
|
+
dt omp list-log -environmentlog '环境全名' -services AssetsFront
|
|
172
|
+
dt omp list-log -user alice # 按提交人筛选(本地匹配 user 字段,会翻页扫描历史)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`--user` 过滤只能本地做:命令会从 `--page` 开始按 1000 条/页向后扫描,直到取完服务端 `count`。为避免历史记录过多时请求失控,最多扫描 50 页;触顶时 JSON 结果带 `truncated: true`,human 模式会在 stderr 提示结果可能不完整。此时建议加 `--environmentlog` / `--services` 缩小范围。
|
|
176
|
+
|
|
177
|
+
`deploy` 会在提交前重新查询环境并使用完整环境信息组装请求;返回的 `status=success` 只表示任务已提交,不代表部署完成。需用 `list-log` 核对对应部署 ID、环境、分支和服务的最终状态。可通过 `DTSTACK_OMP_BASE_URL` 或全局参数 `-omp-base-url` 覆盖默认地址。
|
|
178
|
+
|
|
179
|
+
## 蓝湖(lanhu)
|
|
180
|
+
|
|
181
|
+
蓝湖登录复用统一的 `dt auth` 认证入口,PRD 下载挂载在 `dt lanhu` 下。登录状态保存在 `~/.dt-cli/lanhu`(与 dt-cli 其他状态放在同一个 `~/.dt-cli` 目录下的 `lanhu` 子目录)。
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# 登录(默认复用已登录浏览器的蓝湖 Cookie;无效时打开临时隔离的 Chrome 窗口)
|
|
185
|
+
dt auth login lanhu
|
|
186
|
+
dt auth login lanhu --method password # 账号 + 隐藏输入密码
|
|
187
|
+
dt auth status lanhu
|
|
188
|
+
dt auth refresh lanhu
|
|
189
|
+
dt auth logout lanhu
|
|
190
|
+
|
|
191
|
+
# 复用登录态下载蓝湖 PRD / Axure 原型到 --output-dir(默认 ./tmp)
|
|
192
|
+
dt lanhu prd download 'https://lanhuapp.com/...'
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
`dt auth login lanhu` 还支持 `--browser <chrome|edge|brave|arc|chromium>`、`--profile`、`--force-login` 和 `--timeout`。所有 lanhu 命令与其他 dt-cli 命令使用同一套结果协议:TTY 下输出可读文本,非 TTY 或 `-json` 时输出 `{ ok, schemaVersion, data, meta }` 结构化结果。
|
|
196
|
+
|
|
197
|
+
安全边界:密码经 AES-256-GCM 加密后写入 `~/.dt-cli/lanhu/auth/password.enc`(属于混淆而非强加密);`prd download` 会以完整会话 Cookie 调用受信的 `LanhuExtractor` 脚本(默认 `~/.claude/skills/lanhu-prd-extractor/scripts/lanhu_extractor.js`,可用 `--extractor-path` 指定)。完整说明见 `docs/lanhu/README.md`。
|
|
198
|
+
|
|
199
|
+
## Agent Skill
|
|
200
|
+
|
|
201
|
+
仓库内置 `.agents/skills/dtstack-cli/SKILL.md`。Codex 在此仓库中可以根据 Bug 查询请求自动加载,也可以显式调用:
|
|
202
|
+
|
|
203
|
+
```text
|
|
204
|
+
$dtstack-cli 查询 Bug 148878
|
|
205
|
+
$dtstack-cli 查一下指派给 shuangxu 的 active Bug
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
在其他仓库使用前,需要将这个 Skill 安装或链接到目标仓库的 `.agents/skills/dtstack-cli`,或用户级 `~/.agents/skills/dtstack-cli`。
|
package/dist/index.d.ts
ADDED