@dreamor/atlas-cli 0.7.24 → 0.7.26

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.
Files changed (3) hide show
  1. package/atlas.cjs +24 -24
  2. package/package.json +1 -1
  3. package/README.github.md +0 -230
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamor/atlas-cli",
3
- "version": "0.7.24",
3
+ "version": "0.7.26",
4
4
  "description": "Atlas CLI",
5
5
  "type": "module",
6
6
  "bin": {
package/README.github.md DELETED
@@ -1,230 +0,0 @@
1
- # Atlas CLI
2
-
3
- 斑马云图(Banma Yuntu)人力基线管理 CLI 工具。
4
-
5
- ```bash
6
- npm i -g @dreamor/atlas-cli
7
- ```
8
-
9
- > 需要 Node.js 20+
10
-
11
- ---
12
-
13
- ## 目录
14
-
15
- - [快速开始](#快速开始)
16
- - [命令结构](#命令结构)
17
- - [源码开发](#源码开发)
18
- - [发布流程](#发布流程)
19
- - [测试](#测试)
20
- - [架构](#架构)
21
- - [文档](#文档)
22
-
23
- ---
24
-
25
- ## 快速开始
26
-
27
- ```bash
28
- # SSO 登录
29
- atlas auth login
30
-
31
- # 搜索项目
32
- atlas find project 斑马
33
-
34
- # 绑定默认项目
35
- atlas link <project-name>
36
-
37
- # 查询基线
38
- atlas baseline month --project-id 2496
39
-
40
- # 查询实际工时
41
- atlas actual month --project-id 2496
42
-
43
- # 基线 vs 实际对比
44
- atlas compare --project-id 2496 --from 2026-01 --to 2026-06
45
- ```
46
-
47
- ### 沙盒环境(无 GUI 容器)
48
-
49
- Claude Code、悟空、AntCode WebIDE 等沙盒环境无法直接 `atlas auth login`,推荐:
50
-
51
- ```bash
52
- # 先诊断环境
53
- atlas auth doctor
54
-
55
- # 方案 A:从宿主机导入登录态
56
- export ATLAS_COOKIES_B64='<宿主机 atlas auth export --base64 输出>'
57
- atlas auth refresh # 补发 access_token
58
-
59
- # 方案 B:通过 daemon 代理
60
- export ATLAS_DAEMON_URL=http://host.docker.internal:8765
61
- export ATLAS_DAEMON_TOKEN=$(cat ~/.atlas/daemon.token)
62
- ```
63
-
64
- 详见 [docs/sandbox-login.md](docs/sandbox-login.md)。
65
-
66
- ## 命令结构
67
-
68
- ```
69
- atlas
70
- ├── auth {login,status,refresh,export,import,doctor}
71
- ├── find <kind> <query> # project/department/manpower-type/role/area
72
- ├── projects
73
- ├── link / unlink
74
- ├── baseline {month,summary,export}
75
- ├── actual {show,month,summary,export}
76
- ├── compare
77
- ├── schema {commands,export}
78
- ├── daemon
79
- ├── exec --plan-file <path>
80
- ├── update
81
- └── suggest <query>
82
- ```
83
-
84
- ### 全局选项
85
-
86
- - `--json` — JSON 信封输出(stdout);日志走 stderr,不污染管道
87
- - `--quiet` — 静默模式
88
- - `--describe` — 输出参数 schema,不执行
89
-
90
- ### 退出码
91
-
92
- | 码 | 含义 | agent 应对 |
93
- |----|------|-----------|
94
- | 0 | 成功 | 继续 |
95
- | 2 | 会话过期 | 先试 `atlas auth refresh` |
96
- | 3 | API 错误 | 不重试 |
97
- | 4 | 项目匹配歧义 | 用 `atlas find project` 让用户挑 |
98
- | 5 | 项目未找到 | 改关键词重试 1 次后报告 |
99
- | 6 | 限流 | 退避 10s 重试 ≤1 次 |
100
- | 7 | 网络错误 | 退避 5s 重试 ≤1 次 |
101
- | 8 | 升级异常 | 忽略 |
102
- | 64 | 配置/未实现 | 不重试 |
103
- | 65 | 输出超限 | 改用 `--out <file>` |
104
-
105
- ### 数据单位
106
-
107
- - **基线**:`manpower` = 人月
108
- - **实际工时**:`mp` / `weeklyActuals[].manpower` = 人月
109
- - **compare**:`diff = 实际 - 基线`(人月,已自动统一单位,**不要二次换算**)
110
- - 月份格式 `YYYY-MM`,已修正 CST(UTC+8) 偏移
111
-
112
- ## 源码开发
113
-
114
- ### 技术栈
115
-
116
- TypeScript + Commander (CLI 框架) + Zod (输入验证) + undici (HTTP 客户端) + Playwright (SSO 登录)
117
-
118
- ### 本地开发
119
-
120
- ```bash
121
- git clone <repo>
122
- cd atlas-cli
123
- pnpm install
124
-
125
- # 构建
126
- npm run build
127
-
128
- # 类型检查
129
- npm run lint
130
-
131
- # 测试
132
- npm test
133
-
134
- # 验证 CLI
135
- npm run verify
136
-
137
- # 本地运行
138
- node atlas.js --help
139
- ```
140
-
141
- ## 测试
142
-
143
- | 类型 | 位置 | 测试数 | 说明 |
144
- |------|------|--------|------|
145
- | 单元测试 | `adapters/atlas/tests/` | 354(27 文件) | Vitest,覆盖率 80%+ |
146
- | E2E 真实 API | `scripts/run-e2e-real.mjs` | 41 | 需登录态(~/.atlas/cookies.json) |
147
- | E2E 沙盒登录 | `scripts/run-e2e-sandbox-login.mjs` | 12 | 验证 export/import/COOKIES_B64/daemon |
148
-
149
- ### CI 流程
150
-
151
- - **CI**(`.github/workflows/ci.yml`):push/PR 自动 lint → test → build → 源码泄漏检查
152
- - **Publish**(`.github/workflows/publish-npm.yml`):tag `v*` 触发 OIDC Trusted Publisher → npmjs
153
-
154
- ## 发布流程
155
-
156
- ```bash
157
- # 更新版本号
158
- # package.json + adapters/atlas/util/version.ts
159
-
160
- # 本地验证
161
- npm run build
162
- npm test
163
- npm run lint
164
- npm run verify
165
-
166
- # 提交并打 tag
167
- git add -A && git commit -m "chore: bump X.Y.Z → X.Y.Z"
168
- git tag vX.Y.Z
169
- git push dist main && git push dist vX.Y.Z
170
- ```
171
-
172
- > npm 包名 `@dreamor/atlas-cli`,仅 `dist/` 编译产物(零源码、零 sourcemap、零测试文件)。发布由 GitHub CI 自动完成,无需本地 `npm publish`。
173
-
174
- ## 架构
175
-
176
- ```
177
- adapters/atlas/
178
- ├── cli.ts # Commander 入口
179
- ├── commands/ # 命令处理
180
- │ ├── auth.ts # auth login/status/refresh/export/import/doctor
181
- │ ├── project/ # find, projects, link, unlink
182
- │ ├── baseline/ # month, summary, export
183
- │ ├── actual/ # show, month, summary, export
184
- │ ├── compare/ # 基线 vs 实际对比
185
- │ ├── schema.ts # 命令树自省
186
- │ ├── exec.ts # 批量命令执行
187
- │ ├── suggest.ts # 自然语言→命令翻译
188
- │ └── update.ts # 自动升级
189
- ├── auth/ # 鉴权
190
- │ ├── login.ts # Playwright SSO + daemon 自动登录
191
- │ ├── session.ts # cookies 读写 + ATLAS_COOKIES_B64 + daemon 客户端
192
- │ ├── portable.ts # export/import/doctor 便携登录态打包
193
- │ └── refresh.ts # 无头 token 刷新
194
- ├── daemon/ # 本地守护进程
195
- │ ├── index.ts # HTTP server + token 鉴权 + IP 白名单
196
- │ └── ipmask.ts # CIDR 位运算匹配
197
- ├── http/ # Banma API HTTP 客户端
198
- ├── util/ # 工具函数
199
- │ ├── environment.ts # 沙盒环境识别(agent_code/容器/GUI/daemon)
200
- │ ├── output.ts # JSON 信封、日志
201
- │ ├── errors.ts # 错误类型 + 退出码
202
- │ └── ...
203
- └── tests/ # 单元测试(27 文件)
204
- ```
205
-
206
- ## 环境变量
207
-
208
- | 变量 | 必需 | 说明 | 默认值 |
209
- |------|------|------|--------|
210
- | `BANMA_PROJECT_ID` | 是(或 `--project-id` / `atlas link`) | 默认项目 ID | — |
211
- | `ATLAS_HOME` | 否 | 数据目录根路径 | `~/.atlas` |
212
- | `ATLAS_COOKIES_B64` | 否 | 沙盒免命令登录:base64 bundle 内存导入 | — |
213
- | `ATLAS_DAEMON_URL` | 否 | 沙盒连宿主机 daemon URL | — |
214
- | `ATLAS_DAEMON_TOKEN` | 否 | daemon Bearer token | — |
215
- | `ATLAS_DAEMON_PORT` | 否 | 守护进程端口 | `8765` |
216
- | `ATLAS_AGENT_CODE` | 否 | 显式声明 agent 类型 | 自动识别 |
217
- | `ATLAS_SANDBOX` | 否 | 强制沙盒模式(禁用浏览器拉起) | — |
218
- | `ATLAS_OUTPUT` | 否 | 设为 `json` 启用 JSON 信封输出 | — |
219
- | `ATLAS_QUIET` | 否 | 抑制 stderr 日志 | — |
220
- | `ATLAS_DISABLE_UPDATE` | 否 | 禁用升级检查 | — |
221
- | `ATLAS_MAX_OUTPUT_BYTES` | 否 | 导出字节上限 | 无限制 |
222
- | `DEBUG` | 否 | 显示详细错误堆栈 | — |
223
-
224
- ## 文档
225
-
226
- - [贡献指南](docs/CONTRIBUTING.md) — 开发环境、测试、PR 流程
227
- - [运维手册](docs/RUNBOOK.md) — 安装、发布、故障排查
228
- - [项目状态](docs/STATUS.md) — 当前版本、测试状态、已知问题
229
- - [沙盒登录](docs/sandbox-login.md) — 沙盒环境登录全攻略
230
- - [CLI 完整契约](.claude/skills/atlas/SKILL.md) — AI agent 调用契约