meegle-cli 0.1.1 → 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
@@ -331,6 +331,91 @@ meegle --profile default view panoramic-items \
331
331
 
332
332
  不要直接拿整个空间总池代替“这个视图”的口径。
333
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
385
+
386
+ ```bash
387
+ meegle --profile default workitem search by-params \
388
+ --project-key 69zyer \
389
+ --type story \
390
+ --body-file ./examples/story-by-planning-version.json \
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 丢参,而是请求体结构不符合接口契约。
418
+
334
419
  ## 参数约定
335
420
 
336
421
  - 常用查询优先走直接参数,不强制写 JSON 文件
@@ -400,6 +485,18 @@ meegle auth init \
400
485
  先回到 `view list` 看 `view_type`。
401
486
  不要只凭页面 URL 去猜视图类型。
402
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
+
403
500
  ## 命令总览
404
501
 
405
502
  - `auth`: `init`, `status`
@@ -428,3 +525,22 @@ npm test
428
525
  ```
429
526
 
430
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,6 +1,6 @@
1
1
  {
2
2
  "name": "meegle-cli",
3
- "version": "0.1.1",
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": {
@@ -9,7 +9,9 @@
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",