meegle-cli 0.1.0 → 0.1.2

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-en.md ADDED
@@ -0,0 +1,193 @@
1
+ # meegle-cli
2
+
3
+ CLI for Feishu Project (Meegle).
4
+ Current mode is `plugin-only`: it supports `plugin_access_token / virtual_plugin_token`, but not `user_access_token`.
5
+
6
+ ## Install
7
+
8
+ ```bash
9
+ npm install -g meegle-cli
10
+ meegle --help
11
+ ```
12
+
13
+ ## What You Need
14
+
15
+ - `pluginId`
16
+ - `pluginSecret`
17
+ - `userKey`
18
+ - `projectKey`
19
+
20
+ Optional:
21
+
22
+ - `baseURL`
23
+ - default: `https://project.feishu.cn`
24
+
25
+ ## Quick Start
26
+
27
+ ### 1. Initialize a profile
28
+
29
+ ```bash
30
+ meegle auth init \
31
+ --target-profile default \
32
+ --plugin-id <PLUGIN_ID> \
33
+ --plugin-secret <PLUGIN_SECRET> \
34
+ --default-user-key <USER_KEY>
35
+ ```
36
+
37
+ Or use environment variables:
38
+
39
+ ```bash
40
+ export MEEGLE_PLUGIN_ID=<PLUGIN_ID>
41
+ export MEEGLE_PLUGIN_SECRET=<PLUGIN_SECRET>
42
+ export MEEGLE_USER_KEY=<USER_KEY>
43
+
44
+ meegle auth init --target-profile default
45
+ ```
46
+
47
+ ### 2. Verify credentials
48
+
49
+ ```bash
50
+ meegle --profile default auth status --json
51
+ ```
52
+
53
+ ### 3. List spaces
54
+
55
+ ```bash
56
+ meegle --profile default space list --json
57
+ ```
58
+
59
+ ### 4. Query yourself
60
+
61
+ ```bash
62
+ meegle --profile default user query --self --json
63
+ ```
64
+
65
+ ## Common Tasks
66
+
67
+ ### Get a work item
68
+
69
+ ```bash
70
+ meegle --profile default workitem get \
71
+ --project-key <PROJECT_KEY> \
72
+ --type story \
73
+ --id 6300034462 \
74
+ --json
75
+ ```
76
+
77
+ ### Create a work item
78
+
79
+ ```bash
80
+ meegle --profile default workitem create \
81
+ --project-key <PROJECT_KEY> \
82
+ --type story \
83
+ --name "Login improvement" \
84
+ --desc "Improve error messages" \
85
+ --owner <USER_KEY> \
86
+ --priority P2 \
87
+ --json
88
+ ```
89
+
90
+ ### Add a comment
91
+
92
+ ```bash
93
+ meegle --profile default comment add \
94
+ --project-key <PROJECT_KEY> \
95
+ --type story \
96
+ --id 6300034462 \
97
+ --content "Received, starting now" \
98
+ --json
99
+ ```
100
+
101
+ ## View Usage
102
+
103
+ Do not infer view type from the page URL.
104
+ Always call `view list` first, then choose the correct API.
105
+
106
+ ### Resolve a view
107
+
108
+ ```bash
109
+ meegle --profile default view list \
110
+ --project-key 69zyer \
111
+ --body-file ./examples/view-list.json \
112
+ --json
113
+ ```
114
+
115
+ Check:
116
+
117
+ - `view_id`
118
+ - `name`
119
+ - `view_type`
120
+ - `1` = condition view
121
+ - `2` = fixed view
122
+
123
+ ### Fixed view items
124
+
125
+ ```bash
126
+ meegle --profile default view fix-items \
127
+ --project-key 69zyer \
128
+ --view-id sypbi-z60 \
129
+ --query-file ./examples/view-fix-items.json \
130
+ --json
131
+ ```
132
+
133
+ ## Related Field Filtering
134
+
135
+ For related fields such as `planning_version`, do not use:
136
+
137
+ - `workitem search filter` with `field_value_pairs`
138
+
139
+ Use this flow instead:
140
+
141
+ 1. find the related work item ID
142
+ 2. run `workitem search by-params`
143
+ 3. pass the related work item **ID list**, not the display name
144
+
145
+ ### Example: find stories by planning version
146
+
147
+ Step 1: search the `version` work item:
148
+
149
+ ```bash
150
+ meegle --profile default workitem search filter \
151
+ --project-key 69zyer \
152
+ --body-file ./examples/version-search-filter.json \
153
+ --json
154
+ ```
155
+
156
+ Step 2: use the returned version `id` in `planning_version`:
157
+
158
+ ```bash
159
+ meegle --profile default workitem search by-params \
160
+ --project-key 69zyer \
161
+ --type story \
162
+ --body-file ./examples/story-by-planning-version.json \
163
+ --json
164
+ ```
165
+
166
+ Replace `1234567890` in the example file with the real version work item ID.
167
+
168
+ ## Agent Notes
169
+
170
+ If you use this CLI from an AI agent or automation:
171
+
172
+ 1. run `meegle --help` or subcommand `--help` first
173
+ 2. do not guess request shapes from web URLs
174
+ 3. use `workitem search by-params` for custom fields and related fields
175
+ 4. `field_value_pairs` is for create/update, not for search
176
+
177
+ ## Examples
178
+
179
+ - `examples/view-list.json`
180
+ - `examples/view-fix-items.json`
181
+ - `examples/version-search-filter.json`
182
+ - `examples/story-by-planning-version.json`
183
+
184
+ ## Limits
185
+
186
+ This CLI currently rejects user-token-only commands such as:
187
+
188
+ - `user search`
189
+ - `user group create`
190
+ - `user group update-members`
191
+ - `user group query-members`
192
+
193
+ That is expected behavior in `plugin-only` mode.
package/README.md CHANGED
@@ -1,215 +1,546 @@
1
- # meegle-cli (plugin-only)
1
+ # meegle-cli
2
2
 
3
- 基于 `project-oapi-sdk-typescript` 的命令行工具。
4
- 当前模式:仅支持 `plugin_access_token / virtual_plugin_token`,不支持 `user_access_token`。
3
+ 面向飞书项目(Meegle)的命令行工具。
4
+ 当前版本运行在 `plugin-only` 模式:只支持 `plugin_access_token / virtual_plugin_token`,不支持 `user_access_token`。
5
5
 
6
- ## 安装
6
+ ## 适用对象
7
+
8
+ - 想在终端里查询空间、工作项、视图、评论、子任务
9
+ - 想把 Meegle 调用接到脚本、Agent、CI 里
10
+ - 已经有插件凭证:`pluginId / pluginSecret`
7
11
 
8
- 对外用户安装:
12
+ 不适用场景:
13
+
14
+ - 需要 `user_access_token` 的接口
15
+ - 需要在 CLI 内做浏览器登录换 user token
16
+
17
+ ## 安装
9
18
 
10
19
  ```bash
11
20
  npm install -g meegle-cli
12
21
  meegle --help
13
22
  ```
14
23
 
15
- 仓库内开发安装:
24
+ 如果安装后提示 `meegle: command not found`,先确认 npm 全局 bin 在 PATH 里:
16
25
 
17
26
  ```bash
18
- cd /Users/linmi/conductor/repos/meego-client/meegle-cli
19
- npm install
27
+ npm bin -g
20
28
  ```
21
29
 
22
- ## 构建
30
+ ## 你需要准备什么
23
31
 
24
- ```bash
25
- npm run build
26
- ```
32
+ 最少准备这几项:
33
+
34
+ - `pluginId`
35
+ - `pluginSecret`
36
+ - `userKey`
37
+ - `projectKey`
38
+
39
+ 可选:
27
40
 
28
- ## 发布
41
+ - `baseURL`
42
+ - 默认就是 `https://project.feishu.cn`
29
43
 
30
- 发布说明见 [RELEASE.md](/Users/linmi/conductor/repos/meego-client/meegle-cli/RELEASE.md)。
44
+ ## 3 分钟上手
31
45
 
32
- ## 初始化
46
+ ### 1. 初始化一个 profile
33
47
 
34
48
  ```bash
35
- node dist/index.js auth init \
49
+ meegle auth init \
36
50
  --target-profile default \
37
- --plugin-id MII_xxx \
38
- --plugin-secret xxx \
39
- --base-url https://project.feishu.cn \
40
- --token-type 0 \
41
- --default-user-key 123456
51
+ --plugin-id <PLUGIN_ID> \
52
+ --plugin-secret <PLUGIN_SECRET> \
53
+ --default-user-key <USER_KEY>
42
54
  ```
43
55
 
44
- 也可以先放环境变量,再直接初始化:
56
+ 也可以先放环境变量,再执行初始化:
45
57
 
46
58
  ```bash
47
- export MEEGLE_PLUGIN_ID=MII_xxx
48
- export MEEGLE_PLUGIN_SECRET=xxx
49
- export MEEGLE_USER_KEY=123456
59
+ export MEEGLE_PLUGIN_ID=<PLUGIN_ID>
60
+ export MEEGLE_PLUGIN_SECRET=<PLUGIN_SECRET>
61
+ export MEEGLE_USER_KEY=<USER_KEY>
50
62
 
51
- node dist/index.js auth init --target-profile default
63
+ meegle auth init --target-profile default
52
64
  ```
53
65
 
54
- ## 入参约定
66
+ ### 2. 校验凭证
55
67
 
56
- - 常用查询优先走直接参数,不再强制写 JSON 文件
57
- - 常用写操作也优先走直接参数,例如 `--name`、`--desc`、`--content`
58
- - 复杂请求体仍可使用 `--body <json>` 或 `--body-file <path>`
59
- - 复杂查询参数仍可使用 `--query-file <path>`
60
- - 大多数命令要求 `userKey`:`--user-key` 或 `auth init --default-user-key`
61
- - 如果 profile 里没存 `defaultUserKey`,运行时也会读取 `MEEGLE_USER_KEY`
62
- - 自定义字段统一使用 `--field field_key=value`;对象/数组值直接传 JSON
63
- - 排期参数统一支持 `--start/--end`,可传毫秒时间戳或可解析日期,如 `2025-01-01`
68
+ ```bash
69
+ meegle --profile default auth status --json
70
+ ```
64
71
 
65
- ## 命令总览
72
+ 成功时会返回:
66
73
 
67
- - `auth`: `init`, `status`
68
- - `space`: `list`, `get`, `types`, `team-members`
69
- - `workitem`: `get`, `meta`, `create`, `update`, `remove`, `freeze`, `unfreeze`, `abort`, `restore`, `op-records`, `update-compound`
70
- - `workitem search`: `filter`, `filter-across`, `by-params`, `by-relation`, `compositive`, `universal`
71
- - `workflow`: `query`, `state-change`, `node-operate`, `node-update`, `required-info`, `wbs`
72
- - `comment`: `list`, `add`, `update`, `remove`
73
- - `subtask`: `list`, `search`, `create`, `update`, `remove`, `operate`
74
- - `attachment`: `upload-file`, `upload`, `download`, `delete`
75
- - `workhour`: `list`, `create`, `update`, `delete`
76
- - `view`: `list`, `fix-items`, `panoramic-items`, `create-fix`, `update-fix`, `delete`, `create-condition`, `update-condition`
77
- - `measure`: `charts`, `chart-data`
78
- - `tenant`: `info`, `entitlement`, `spaces`
79
- - `user`: `query`, `search`(会被拒绝)
80
- - `user group`: `create`, `update-members`, `query-members`(会被拒绝)
74
+ - `profile`
75
+ - `baseURL`
76
+ - `tokenType`
77
+ - `tokenPreview`
78
+ - `ok: true`
79
+
80
+ ### 3. 列出你能看到的空间
81
81
 
82
- ## 真实环境 Smoke(可选)
82
+ ```bash
83
+ meegle --profile default space list --json
84
+ ```
83
85
 
84
- 执行:
86
+ ### 4. 查询自己
85
87
 
86
88
  ```bash
87
- npm run test:smoke:real
89
+ meegle --profile default user query --self --json
88
90
  ```
89
91
 
90
- 必填环境变量:
92
+ ## 核心概念
93
+
94
+ ### profile
91
95
 
92
- - `MEEGLE_SMOKE_PLUGIN_ID`
93
- - `MEEGLE_SMOKE_PLUGIN_SECRET`
94
- - `MEEGLE_SMOKE_USER_KEY`
95
- - `MEEGLE_SMOKE_PROJECT_KEY`
96
+ 一套 CLI 配置,通常对应一套环境或一组凭证。
96
97
 
97
- 可选环境变量:
98
+ 例如:
98
99
 
99
- - `MEEGLE_SMOKE_BASE_URL`(默认 `https://project.feishu.cn`)
100
- - `MEEGLE_SMOKE_WORK_ITEM_TYPE_KEY`(不填时自动取 `space types` 第一项)
101
- - `MEEGLE_SMOKE_WORK_ITEM_ID`(填了会额外做 `workitem get`)
100
+ - `default`
101
+ - `test`
102
+ - `prod`
102
103
 
103
- 测试链路:
104
+ 切换方式:
104
105
 
105
- - `auth init -> auth status -> space list -> space get -> user query --self -> space types -> workitem meta`
106
- - 若提供 `MEEGLE_SMOKE_WORK_ITEM_ID`,再执行 `workitem get`
107
- - 最后验证 user-only 接口在 plugin-only 下被拒绝
106
+ ```bash
107
+ meegle --profile prod space list
108
+ ```
108
109
 
109
- `MEEGLE_SMOKE_USER_KEY` 获取建议:
110
+ ### userKey
110
111
 
111
- - 文档建议可在飞书项目空间双击头像获取 `user_key`
112
- - 如果你在插件前端里调试,JS SDK 文档里有 `window.JSSDK.utils.getAuthCode()`;虽然该方法用于 user token 流程,但同一套文档章节也包含用户身份相关取值指引
112
+ `plugin-only` 模式下,大多数命令都需要 `userKey`。
113
113
 
114
- ## plugin-only 拒绝列表(denylist)
114
+ 来源优先级:
115
115
 
116
- - `POST /open_api/user/search`
117
- - `POST /open_api/:project_key/user_group`
118
- - `PATCH /open_api/:project_key/user_group/members`
119
- - `POST /open_api/:project_key/user_groups/members/page`
116
+ 1. 命令行 `--user-key`
117
+ 2. profile 里的 `defaultUserKey`
118
+ 3. 环境变量 `MEEGLE_USER_KEY`
120
119
 
121
- ## 示例
120
+ ### projectKey
122
121
 
123
- ```bash
124
- # 1) 校验凭证
125
- node dist/index.js --profile default auth status --json
122
+ 空间 ID,通常就是接口里的 `project_key`。
123
+ 很多命令也支持空间域名 `simple_name`,例如 `69zyer`。
126
124
 
127
- # 2) 列出空间
128
- node dist/index.js --profile default space list --json
125
+ ## 常见任务
129
126
 
130
- # 3) 获取空间详情
131
- node dist/index.js --profile default space get \
132
- --project-key your_project \
127
+ ### 查空间详情
128
+
129
+ ```bash
130
+ meegle --profile default space get \
131
+ --project-key <PROJECT_KEY> \
133
132
  --json
133
+ ```
134
134
 
135
- # 4) 查询当前 userKey 对应的用户
136
- node dist/index.js --profile default user query \
137
- --self \
135
+ ### 查工作项
136
+
137
+ 查单个工作项:
138
+
139
+ ```bash
140
+ meegle --profile default workitem get \
141
+ --project-key <PROJECT_KEY> \
142
+ --type story \
143
+ --id 6300034462 \
138
144
  --json
145
+ ```
139
146
 
140
- # 5) 查询工作项,常见场景直接传 ID
141
- node dist/index.js --profile default workitem get \
142
- --project-key your_project \
147
+ 只取部分字段:
148
+
149
+ ```bash
150
+ meegle --profile default workitem get \
151
+ --project-key <PROJECT_KEY> \
143
152
  --type story \
144
153
  --id 6300034462 \
154
+ --fields name,priority,owner,description \
145
155
  --json
156
+ ```
146
157
 
147
- # 6) 创建工作项,常见字段直接写
148
- node dist/index.js --profile default workitem create \
149
- --project-key your_project \
158
+ ### 创建工作项
159
+
160
+ ```bash
161
+ meegle --profile default workitem create \
162
+ --project-key <PROJECT_KEY> \
150
163
  --type story \
151
164
  --name "登录优化" \
152
165
  --desc "补齐错误提示" \
153
- --owner your_user_key \
166
+ --owner <USER_KEY> \
154
167
  --priority P2 \
155
168
  --json
169
+ ```
156
170
 
157
- # 7) 更新工作项,改单个字段不需要写 update_fields
158
- node dist/index.js --profile default workitem update \
159
- --project-key your_project \
171
+ ### 更新工作项
172
+
173
+ ```bash
174
+ meegle --profile default workitem update \
175
+ --project-key <PROJECT_KEY> \
160
176
  --type story \
161
177
  --id 6300034462 \
162
178
  --name "登录优化(已排期)" \
163
179
  --json
180
+ ```
164
181
 
165
- # 8) 添加评论,支持直接写文本或从文件读
166
- node dist/index.js --profile default comment add \
167
- --project-key your_project \
182
+ ### 添加评论
183
+
184
+ ```bash
185
+ meegle --profile default comment add \
186
+ --project-key <PROJECT_KEY> \
168
187
  --type story \
169
188
  --id 6300034462 \
170
189
  --content "收到,开始处理" \
171
190
  --json
191
+ ```
192
+
193
+ 如果评论内容很长,改用文件:
194
+
195
+ ```bash
196
+ meegle --profile default comment add \
197
+ --project-key <PROJECT_KEY> \
198
+ --type story \
199
+ --id 6300034462 \
200
+ --content-file ./comment.txt \
201
+ --json
202
+ ```
203
+
204
+ ### 创建子任务
172
205
 
173
- # 9) 创建子任务
174
- node dist/index.js --profile default subtask create \
175
- --project-key your_project \
206
+ ```bash
207
+ meegle --profile default subtask create \
208
+ --project-key <PROJECT_KEY> \
176
209
  --type story \
177
210
  --id 6300034462 \
178
211
  --node-id doing \
179
212
  --name "需求分析" \
180
213
  --note "补齐边界条件" \
181
- --assignee your_user_key \
214
+ --assignee <USER_KEY> \
182
215
  --points 3 \
183
216
  --start 2025-01-01 \
184
217
  --end 2025-01-02 \
185
218
  --json
219
+ ```
220
+
221
+ ### 状态流转
186
222
 
187
- # 10) 状态流转
188
- node dist/index.js --profile default workflow state-change \
189
- --project-key your_project \
223
+ ```bash
224
+ meegle --profile default workflow state-change \
225
+ --project-key <PROJECT_KEY> \
190
226
  --type story \
191
227
  --id 6300034462 \
192
228
  --transition-id 12345 \
193
229
  --field description="流转补充说明" \
194
230
  --json
231
+ ```
232
+
233
+ ### 节点完成 / 回滚
195
234
 
196
- # 11) 节点完成/回滚
197
- node dist/index.js --profile default workflow node-operate \
198
- --project-key your_project \
235
+ ```bash
236
+ meegle --profile default workflow node-operate \
237
+ --project-key <PROJECT_KEY> \
199
238
  --type story \
200
239
  --id 6300034462 \
201
240
  --node-id dev \
202
241
  --action rollback \
203
242
  --rollback-reason "需要返工" \
204
243
  --json
244
+ ```
245
+
246
+ ## 视图使用
247
+
248
+ ### 先查视图配置,再决定调哪个接口
249
+
250
+ 固定视图和全景视图不是一个接口。
251
+ 先查 `view_type`,再调后续命令,别从 URL 结构直接猜。
252
+
253
+ 查指定视图:
254
+
255
+ ```bash
256
+ cat > /tmp/view-list.json <<'JSON'
257
+ {
258
+ "work_item_type_key": "story",
259
+ "view_ids": ["sypbi-z60"],
260
+ "is_query_quick_filter": true,
261
+ "page_size": 10,
262
+ "page_num": 1
263
+ }
264
+ JSON
265
+
266
+ meegle --profile default view list \
267
+ --project-key 69zyer \
268
+ --body-file /tmp/view-list.json \
269
+ --json
270
+ ```
271
+
272
+ 返回中重点看:
273
+
274
+ - `view_id`
275
+ - `name`
276
+ - `view_type`
277
+ - `1` = 条件视图
278
+ - `2` = 固定视图
279
+
280
+ ### 固定视图
281
+
282
+ 固定视图用:
283
+
284
+ ```bash
285
+ cat > /tmp/fix.json <<'JSON'
286
+ {
287
+ "page_size": 50,
288
+ "page_num": 1
289
+ }
290
+ JSON
291
+
292
+ meegle --profile default view fix-items \
293
+ --project-key 69zyer \
294
+ --view-id sypbi-z60 \
295
+ --query-file /tmp/fix.json \
296
+ --json
297
+ ```
298
+
299
+ ### 全景视图
300
+
301
+ 全景视图用:
302
+
303
+ ```bash
304
+ cat > /tmp/panoramic.json <<'JSON'
305
+ {
306
+ "page_size": 50,
307
+ "page_num": 1
308
+ }
309
+ JSON
310
+
311
+ meegle --profile default view panoramic-items \
312
+ --project-key 69zyer \
313
+ --view-id <VIEW_ID> \
314
+ --body-file /tmp/panoramic.json \
315
+ --json
316
+ ```
317
+
318
+ ### PMO 视角的正确用法
319
+
320
+ 如果你要做 PMO 基线分析,推荐链路是:
321
+
322
+ 1. `view list` 确认视图类型
323
+ 2. `view fix-items` 或 `view panoramic-items` 拉视图内工作项 ID
324
+ 3. `workitem get --ids ... --fields ...` 拉详情字段
325
+ 4. 再在脚本里统计:
326
+ - 状态分布
327
+ - 负责人分布
328
+ - 优先级分布
329
+ - 到期时间完整度
330
+ - 超期 / 逾期 / 老化
331
+
332
+ 不要直接拿整个空间总池代替“这个视图”的口径。
333
+
334
+ ## 关联字段筛选
335
+
336
+ ### 结论先说
337
+
338
+ 像 `planning_version` 这类字段,不要用:
339
+
340
+ - `workitem search filter` + `field_value_pairs`
341
+
342
+ 正确做法是:
343
+
344
+ 1. 先找到被关联工作项的实例 ID
345
+ 2. 再用 `workitem search by-params`
346
+ 3. 对关联字段传 **ID 列表**,不要传名称
347
+
348
+ ### 为什么
349
+
350
+ `planning_version` 的字段类型是:
351
+
352
+ - `work_item_related_multi_select`
353
+
354
+ 这类字段的筛选值格式是:
355
+
356
+ - `list<int64>`,也就是关联工作项 ID 列表
357
+
358
+ 不是:
359
+
360
+ - 版本名称字符串
361
+ - `field_value_pairs`
362
+
363
+ ### 典型例子:按“规划版本”筛需求
364
+
365
+ 目标:找出 `planning_version` 关联到某个版本实例的全部 story。
366
+
367
+ #### 第一步:先找版本实例
368
+
369
+ 先在 `version` 类型里按名称查候选:
370
+
371
+ ```bash
372
+ meegle --profile default workitem search filter \
373
+ --project-key 69zyer \
374
+ --body-file ./examples/version-search-filter.json \
375
+ --json
376
+ ```
377
+
378
+ 示例文件:
379
+
380
+ - [examples/version-search-filter.json](/Users/linmi/conductor/repos/meego-client/meegle-cli/examples/version-search-filter.json)
381
+
382
+ 你要从返回结果里拿到真正的版本实例 `id`。
383
+
384
+ #### 第二步:再按 `planning_version` 查 story
205
385
 
206
- # 12) 复杂场景再回退到原始请求体
207
- node dist/index.js --profile default workitem get \
208
- --project-key your_project \
386
+ ```bash
387
+ meegle --profile default workitem search by-params \
388
+ --project-key 69zyer \
209
389
  --type story \
210
- --body '{"work_item_ids":[6300034462],"fields":["name","priority"]}' \
390
+ --body-file ./examples/story-by-planning-version.json \
211
391
  --json
392
+ ```
393
+
394
+ 示例文件:
395
+
396
+ - [examples/story-by-planning-version.json](/Users/linmi/conductor/repos/meego-client/meegle-cli/examples/story-by-planning-version.json)
397
+
398
+ 重点:
399
+
400
+ - 把 `1234567890` 替换成真实版本实例 ID
401
+ - 不要直接写版本名称
402
+
403
+ ### 常见误用
404
+
405
+ 错误方向:
406
+
407
+ 1. 用 `workitem search filter` 查自定义关联字段
408
+ 2. 在筛选请求体里传 `field_value_pairs`
409
+ 3. 直接把版本名称塞给 `planning_version`
410
+
411
+ 这些场景下,接口常见表现是:
412
+
413
+ - 条件被忽略
414
+ - 返回全部需求
415
+ - 让人误以为 CLI 不支持
416
+
417
+ 根因通常不是 CLI 丢参,而是请求体结构不符合接口契约。
212
418
 
213
- # 13) user-only 接口会被直接拒绝
214
- node dist/index.js user search --query test
419
+ ## 参数约定
420
+
421
+ - 常用查询优先走直接参数,不强制写 JSON 文件
422
+ - 常用写操作优先走直接参数,例如 `--name`、`--desc`、`--content`
423
+ - 复杂请求体可使用 `--body <json>` 或 `--body-file <path>`
424
+ - 复杂查询参数可使用 `--query-file <path>`
425
+ - 自定义字段统一使用 `--field field_key=value`
426
+ - 对象 / 数组值直接传 JSON
427
+ - 排期参数统一支持 `--start/--end`
428
+ - 可传毫秒时间戳
429
+ - 也可传可解析日期,例如 `2025-01-01`
430
+
431
+ ## 当前限制
432
+
433
+ ### plugin-only
434
+
435
+ 当前 CLI 不支持 `user_access_token`。
436
+ 所以这类命令会被直接拒绝:
437
+
438
+ - `user search`
439
+ - `user group create`
440
+ - `user group update-members`
441
+ - `user group query-members`
442
+
443
+ 这是设计行为,不是故障。
444
+
445
+ ## 排错
446
+
447
+ ### 1. `meegle: command not found`
448
+
449
+ 先看 npm 全局 bin:
450
+
451
+ ```bash
452
+ npm bin -g
215
453
  ```
454
+
455
+ ### 2. 缺少 `userKey`
456
+
457
+ 报错通常类似:
458
+
459
+ - `缺少 userKey`
460
+ - `命令 ... 需要 userKey`
461
+
462
+ 处理方式:
463
+
464
+ ```bash
465
+ meegle --profile default space list --user-key <USER_KEY>
466
+ ```
467
+
468
+ 或者重新初始化:
469
+
470
+ ```bash
471
+ meegle auth init \
472
+ --target-profile default \
473
+ --plugin-id <PLUGIN_ID> \
474
+ --plugin-secret <PLUGIN_SECRET> \
475
+ --default-user-key <USER_KEY>
476
+ ```
477
+
478
+ ### 3. `user search` 被拒绝
479
+
480
+ 这是正常行为。
481
+ 当前版本是 `plugin-only`,该命令依赖 `user_access_token`。
482
+
483
+ ### 4. 固定视图 / 全景视图调用报错
484
+
485
+ 先回到 `view list` 看 `view_type`。
486
+ 不要只凭页面 URL 去猜视图类型。
487
+
488
+ ### 5. 明明传了条件,结果返回全部数据
489
+
490
+ 优先检查三件事:
491
+
492
+ 1. 用的命令是不是对
493
+ - 内置字段简单筛选:`workitem search filter`
494
+ - 自定义字段 / 关联字段:`workitem search by-params`
495
+ 2. 值格式是不是对
496
+ - 关联工作项字段通常要传实例 ID,不是名称
497
+ 3. 请求体键是不是对
498
+ - `field_value_pairs` 用于创建 / 更新,不是搜索条件
499
+
500
+ ## 命令总览
501
+
502
+ - `auth`: `init`, `status`
503
+ - `space`: `list`, `get`, `types`, `team-members`
504
+ - `workitem`: `get`, `meta`, `create`, `update`, `remove`, `freeze`, `unfreeze`, `abort`, `restore`, `op-records`, `update-compound`
505
+ - `workitem search`: `filter`, `filter-across`, `by-params`, `by-relation`, `compositive`, `universal`
506
+ - `workflow`: `query`, `state-change`, `node-operate`, `node-update`, `required-info`, `wbs`
507
+ - `comment`: `list`, `add`, `update`, `remove`
508
+ - `subtask`: `list`, `search`, `create`, `update`, `remove`, `operate`
509
+ - `attachment`: `upload-file`, `upload`, `download`, `delete`
510
+ - `workhour`: `list`, `create`, `update`, `delete`
511
+ - `view`: `list`, `fix-items`, `panoramic-items`, `create-fix`, `update-fix`, `delete`, `create-condition`, `update-condition`
512
+ - `measure`: `charts`, `chart-data`
513
+ - `tenant`: `info`, `entitlement`, `spaces`
514
+ - `user`: `query`, `search`(会被拒绝)
515
+ - `user group`: `create`, `update-members`, `query-members`(会被拒绝)
516
+
517
+ ## 开发与发布
518
+
519
+ 仓库内开发:
520
+
521
+ ```bash
522
+ cd meegle-cli
523
+ npm install
524
+ npm test
525
+ ```
526
+
527
+ 发布说明见 [RELEASE.md](./RELEASE.md)。
528
+
529
+ ## Examples
530
+
531
+ 可直接复制修改的模板在:
532
+
533
+ - [examples/view-list.json](/Users/linmi/conductor/repos/meego-client/meegle-cli/examples/view-list.json)
534
+ - [examples/view-fix-items.json](/Users/linmi/conductor/repos/meego-client/meegle-cli/examples/view-fix-items.json)
535
+ - [examples/version-search-filter.json](/Users/linmi/conductor/repos/meego-client/meegle-cli/examples/version-search-filter.json)
536
+ - [examples/story-by-planning-version.json](/Users/linmi/conductor/repos/meego-client/meegle-cli/examples/story-by-planning-version.json)
537
+
538
+ ## AI / Agent 提示
539
+
540
+ 如果你在 Agent、Openclaw、脚本平台里调用 `meegle-cli`,建议遵守这几条:
541
+
542
+ 1. 先跑 `meegle --help` 或子命令 `--help`,不要凭印象猜参数名
543
+ 2. 不要从页面 URL 直接猜视图类型;先调用 `view list`
544
+ 3. 自定义字段和关联字段优先走 `workitem search by-params`
545
+ 4. `planning_version` 这类关联字段,先查出被关联工作项的 `id`,再筛主工作项
546
+ 5. `field_value_pairs` 是写操作格式,不是搜索格式
@@ -0,0 +1,23 @@
1
+ {
2
+ "search_group": {
3
+ "conjunction": "AND",
4
+ "search_params": [
5
+ {
6
+ "param_key": "planning_version",
7
+ "operator": "CONTAINS",
8
+ "value": [
9
+ 1234567890
10
+ ]
11
+ }
12
+ ]
13
+ },
14
+ "page_size": 200,
15
+ "page_num": 1,
16
+ "fields": [
17
+ "name",
18
+ "owner",
19
+ "priority",
20
+ "planning_version",
21
+ "work_item_status"
22
+ ]
23
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "work_item_type_keys": [
3
+ "version"
4
+ ],
5
+ "work_item_name": "260312",
6
+ "page_size": 50,
7
+ "page_num": 1
8
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "page_size": 50,
3
+ "page_num": 1
4
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "work_item_type_key": "story",
3
+ "view_ids": [
4
+ "sypbi-z60"
5
+ ],
6
+ "is_query_quick_filter": true,
7
+ "page_size": 10,
8
+ "page_num": 1
9
+ }
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "meegle-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Plugin-only CLI for Feishu Project (Meegle) based on meeglesdk",
5
5
  "type": "module",
6
6
  "bin": {
7
- "meegle": "./dist/index.js"
7
+ "meegle": "dist/index.js"
8
8
  },
9
9
  "files": [
10
10
  "dist",
11
11
  "README.md",
12
- "RELEASE.md"
12
+ "README-en.md",
13
+ "RELEASE.md",
14
+ "examples"
13
15
  ],
14
16
  "scripts": {
15
17
  "clean": "rm -rf dist",