@metaphorli/pingcode-cli 0.3.2 → 0.3.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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: pingcode
3
- description: 当用户提到 PingCode、工作项、任务、缺陷、故事、需求、项目、迭代、用户令牌、OAuth 登录、认证、查看我的任务、创建或更新工作项时使用此 skill。即使未明确点名,只要请求涉及 PingCode 数据操作,就优先触发此 skill。
3
+ description: 当用户提到 PingCode、工作项、任务、缺陷、故事、需求/idea、项目、迭代、用户令牌、OAuth 登录、认证、查看我的任务、创建或更新工作项时使用此 skill。即使未明确点名,只要请求涉及 PingCode 数据操作,就优先触发此 skill。
4
4
  ---
5
5
 
6
6
  # PingCode
@@ -11,18 +11,21 @@ description: 当用户提到 PingCode、工作项、任务、缺陷、故事、
11
11
 
12
12
  只要用户请求涉及 PingCode 数据,就优先触发:
13
13
 
14
- - 查看/查询工作项、任务、缺陷、故事、需求
15
- - 创建/更新/完成工作项,或修改状态、负责人、迭代
14
+ - 查看/查询工作项、任务、缺陷、故事、需求/idea、产品
15
+ - 创建/更新/完成工作项或需求,或修改状态、负责人、迭代
16
16
  - 初始化或切换项目、迭代、用户上下文
17
17
  - 登录 PingCode、切换令牌类型、处理认证问题
18
- - 任何提到「PingCode」「我的任务」「未解决缺陷」等的请求
18
+ - 任何提到「PingCode」「我的任务」「未解决缺陷」「产品」等的请求
19
19
 
20
20
  ## 快速开始
21
21
 
22
22
  ```bash
23
- # 1. 认证(用户令牌)
23
+ # 1. 认证(用户令牌,默认打开浏览器)
24
24
  pingcode auth login --client-id ID --client-secret SECRET
25
25
 
26
+ # 1.1 无浏览器环境(远程服务器/容器)使用 URL+授权码方式
27
+ pingcode auth login --client-id ID --client-secret SECRET --no-browser
28
+
26
29
  # 2. 初始化工作区上下文
27
30
  pingcode context init
28
31
 
@@ -61,9 +64,12 @@ export PINGCODE_WORKSPACE_CACHE=".pingcode/cache.json"
61
64
 
62
65
  按用户请求场景选择要阅读的参考文件:
63
66
 
64
- - 登录、切换令牌、询问认证方式或 grant_type → 阅读 `references/auth.md`
67
+ - 登录、切换令牌、询问认证方式或 grant_type、查看当前认证状态 → 阅读 `references/auth.md`
65
68
  - 选择项目/迭代/用户、初始化上下文、Agent 前台问答 → 阅读 `references/ctx.md`
66
69
  - 查询/创建/更新工作项、改状态、指派负责人 → 阅读 `references/workitem.md`
70
+ - 查询/创建/更新需求 → 阅读 `references/idea.md`
71
+ - 查询产品列表/产品详情 → 阅读 `references/product.md`
72
+ - 查看/创建/删除工作项评论 → 阅读 `references/comment.md`
67
73
 
68
74
  ## 自然语言速查表
69
75
 
@@ -75,16 +81,25 @@ export PINGCODE_WORKSPACE_CACHE=".pingcode/cache.json"
75
81
  | 查看我的未解决缺陷 | `pingcode workitem list --type bug --assignee @me --state 未解决 --compact` |
76
82
  | 在故事下新增任务 | `pingcode workitem create --title "标题" --type task --parent STORY-123 --dry-run` |
77
83
  | 把工作项改成已完成 | `pingcode workitem update SCR-123 --state 已完成 --dry-run` |
84
+ | 查看某产品下的需求 | `pingcode idea list --product PRODUCT_ID --compact` |
85
+ | 查看 PingCode 产品列表 | `pingcode product list --compact` |
86
+ | 查看 PingCode 产品详情 | `pingcode product get PRODUCT_ID` |
87
+ | 创建需求并预览 | `pingcode idea create --product PRODUCT_ID --title "新增登录" --dry-run` |
78
88
  | 初始化当前项目/迭代/用户 | `pingcode context init` |
79
- | 登录 PingCode 获取用户令牌 | `pingcode auth login --client-id ID --client-secret SECRET` |
89
+ | 登录 PingCode 获取用户令牌(默认打开浏览器) | `pingcode auth login --client-id ID --client-secret SECRET` |
90
+ | 登录 PingCode 获取用户令牌(无浏览器环境) | `pingcode auth login --client-id ID --client-secret SECRET --no-browser` |
91
+ | 查看 PingCode 认证状态 | `pingcode auth status` |
92
+ | 查看工作项评论 | `pingcode comment list SCR-123 --compact` |
93
+ | 添加工作项评论 | `pingcode comment create SCR-123 --content "..." --dry-run` |
80
94
 
81
95
  ## 安全规则
82
96
 
83
97
  - 禁止回显令牌值。
84
98
  - 禁止猜测 `state_id`、`type_id`、`priority_id`、`project_id`、`product_id`。先通过 list 命令或上下文字典将名称解析为 ID。
99
+ - 需求字典(`states`、`properties`、`suites`、`plans`、`priorities`)必须使用 raw ID;不要猜测 `suite_id`、`plan_id`、`state_id`、`priority_id`。`product_id` 同样必须是 raw ID。
85
100
  - HTTP 429 表示触发频率限制,等待 `x-pc-retry-after` 秒后重试。
86
101
  - 写操作先使用 `--dry-run` 预览请求,确认后再执行真实写入。
87
- - 默认使用 `--compact` 展示 list/show 输出,除非用户要求完整详情。
102
+ - 默认使用 `--compact` 展示 list/get 输出,除非用户要求完整详情。
88
103
  - 未缓存工作区上下文时,不要直接执行写操作;先引导用户完成上下文初始化。
89
104
 
90
105
  ## 常见错误处理
@@ -11,12 +11,18 @@ PingCode 支持两种令牌类型:
11
11
 
12
12
  ## 用户令牌登录
13
13
 
14
- 首次使用用户令牌前必须先运行 `auth login`,会在浏览器中完成授权:
14
+ 首次使用用户令牌前必须先运行 `auth login`。默认行为会自动打开浏览器完成授权:
15
15
 
16
16
  ```bash
17
17
  pingcode auth login --client-id ID --client-secret SECRET
18
18
  ```
19
19
 
20
+ 如果当前环境无法打开浏览器(例如远程服务器、容器),可加上 `--no-browser`,改为打印授权 URL 并提示粘贴授权码:
21
+
22
+ ```bash
23
+ pingcode auth login --client-id ID --client-secret SECRET --no-browser
24
+ ```
25
+
20
26
  `auth login` 默认 grant_type 为 `authorization_code`,无需显式传入。
21
27
 
22
28
  登录成功后用户令牌缓存在默认 token cache 中。后续命令自动识别缓存的 grant_type:
@@ -26,6 +32,54 @@ pingcode auth login --client-id ID --client-secret SECRET
26
32
 
27
33
  显式传 `--grant-type` 可覆盖自动识别。未缓存用户令牌时 fallback 为 `client_credentials`。
28
34
 
35
+ ## 查看认证状态
36
+
37
+ 使用 `auth status` 查看当前认证状态,包括凭证是否配置、token cache 是否存在、令牌是否有效、剩余有效期等:
38
+
39
+ ```bash
40
+ # 查看默认 token cache 的认证状态
41
+ pingcode auth status
42
+
43
+ # 指定 token cache 和凭证
44
+ pingcode auth status --token-cache /path/to/token.json --client-id ID --client-secret SECRET
45
+
46
+ # 查看是否会使用显式传入的访问令牌(不会写入 cache)
47
+ pingcode auth status --token TOKEN
48
+
49
+ # 紧凑输出
50
+ pingcode auth status --compact
51
+
52
+ # 试运行,不发起网络请求
53
+ pingcode auth status --dry-run
54
+ ```
55
+
56
+ 输出示例(已登录):
57
+
58
+ ```json
59
+ {
60
+ "authenticated": true,
61
+ "grant_type": "authorization_code",
62
+ "base_url": "https://open.pingcode.com",
63
+ "token_cache": "/Users/.../.cache/pingcode/token.json",
64
+ "token_cache_exists": true,
65
+ "token_valid": true,
66
+ "token_expires_at": 1739956800,
67
+ "token_expires_in": 7185,
68
+ "credentials": {
69
+ "client_id_configured": true,
70
+ "client_secret_configured": true
71
+ },
72
+ "workspace_cache": ".pingcode/cache.json",
73
+ "workspace_cache_exists": true
74
+ }
75
+ ```
76
+
77
+ 安全规则:
78
+
79
+ - `auth status` 不会回显 `access_token` 或 `refresh_token` 的值。
80
+ - `--token` 仅用于本次检查,不会保存到 token cache。
81
+ - 当令牌过期或 token cache 不存在时,`authenticated` 和 `token_valid` 为 `false`。
82
+
29
83
  ## 用户令牌下的行为
30
84
 
31
85
  使用用户令牌时,`pingcode workitem list` 不再默认按当前用户过滤(等价于加 `--all-users`),因此不需要配置 `PINGCODE_USER_ID` 或工作区用户。如需只看自己的工作项,显式加 `--assignee @me` 或 `--user-id`。`client_credentials` 模式下保持原有的默认过滤行为。
@@ -0,0 +1,52 @@
1
+ # 评论
2
+
3
+ 通过 `pingcode comment` 子命令创建、查看、获取和删除工作项评论。
4
+
5
+ `principal_type` 固定为 `work_item`,只支持工作项评论。
6
+
7
+ ## 前置条件
8
+
9
+ 调用 API 前必须配置 PingCode 凭证:
10
+
11
+ ```bash
12
+ export PINGCODE_CLIENT_ID="..."
13
+ export PINGCODE_CLIENT_SECRET="..."
14
+ ```
15
+
16
+ 如果缺少凭证,CLI 会输出配置指引,按指引配置后重试。不要要求用户在对话中粘贴凭证或令牌。
17
+
18
+ ## 命令
19
+
20
+ ```bash
21
+ # 创建评论
22
+ pingcode comment create SCR-123 --content "这个工作项需要考虑性能优化"
23
+
24
+ # 创建回复评论
25
+ pingcode comment create SCR-123 --content "已确认,稍后处理" --reply-to cmt-456
26
+
27
+ # 查看评论列表
28
+ pingcode comment list SCR-123 --compact
29
+
30
+ # 获取单个评论
31
+ pingcode comment get cmt-456 SCR-123
32
+
33
+ # 删除评论
34
+ pingcode comment delete cmt-456 SCR-123
35
+ ```
36
+
37
+ 写操作加 `--dry-run` 可预览请求而不实际发送。列表/获取输出默认使用 `--compact`。
38
+
39
+ ## 操作流程
40
+
41
+ 1. 获取目标工作项的 id 或 identifier(如 `SCR-123`)。
42
+ 2. 创建评论时提供 `--content`(必填),可选 `--reply-to` 回复已有评论。
43
+ 3. 查看、获取或删除评论时同时提供评论 id 和工作项 id/identifier。
44
+ 4. 写操作优先使用 `--dry-run` 预览。
45
+
46
+ ## 安全规则
47
+
48
+ - 禁止猜测 `principal_id`。identifier 会通过 `/v1/project/work_items?identifier=...` 自动解析为 id。
49
+ - `principal_type` 固定为 `work_item`,不支持其他主体类型。
50
+ - 写操作优先 `--dry-run` 预览。
51
+ - HTTP 429 表示触发频率限制,等待 `x-pc-retry-after` 秒后重试。
52
+ - 不要在最终回答中回显令牌值。
@@ -1,6 +1,6 @@
1
1
  # 工作区上下文
2
2
 
3
- 配置 `.pingcode/cache.json`,让工作项命令可以使用默认的项目、迭代和用户值。
3
+ 配置 `.pingcode/cache.json`,让工作项命令可以使用默认的项目、迭代和用户值。`pingcode context list` 以 JSON 输出当前偏好和字典条目数量。
4
4
 
5
5
  ## Agent 前台问答流程
6
6
 
@@ -18,7 +18,7 @@
18
18
  ## 命令
19
19
 
20
20
  ```bash
21
- # 查看当前工作区偏好和缓存字典数量
21
+ # 以 JSON 输出当前工作区偏好和缓存字典数量
22
22
  pingcode context list
23
23
 
24
24
  # 设置当前项目
@@ -38,7 +38,7 @@ pingcode context init
38
38
 
39
39
  ## 完成确认
40
40
 
41
- 当三项偏好均已缓存后,通过 `pingcode context list` 报告已选择的当前项目、迭代和用户。工作项命令即可使用缓存默认值执行日常工作项查询和创建。
41
+ 当三项偏好均已缓存后,通过 `pingcode context list` 以 JSON 格式报告已选择的当前项目、迭代和用户。工作项命令即可使用缓存默认值执行日常工作项查询和创建。
42
42
 
43
43
  ## 终端回退
44
44
 
@@ -0,0 +1,70 @@
1
+ # 需求 (Idea)
2
+
3
+ 通过 `pingcode idea` 子命令列出、创建、查看、获取、搜索和更新 PingCode 需求。
4
+
5
+ ## 前置条件
6
+
7
+ 调用 API 前必须配置 PingCode 凭证:
8
+
9
+ ```bash
10
+ export PINGCODE_CLIENT_ID="..."
11
+ export PINGCODE_CLIENT_SECRET="..."
12
+ ```
13
+
14
+ 如果缺少凭证,CLI 会输出配置指引,按指引配置后重试。不要要求用户在对话中粘贴凭证或令牌。
15
+
16
+ ## 命令
17
+
18
+ ```bash
19
+ # 查询需求列表
20
+ pingcode idea list --product PRODUCT_ID --compact
21
+ pingcode idea list --product PRODUCT_ID --state STATE_ID --priority PRIORITY_ID --keywords "登录页面" --compact
22
+ pingcode idea list --product PRODUCT_ID --include-public-image-token --compact
23
+
24
+ # 通过 identifier 获取需求(get 接受 identifier 或 raw ID)
25
+ pingcode idea get SLC-1
26
+ pingcode idea get IDEA_ID
27
+
28
+ # 搜索需求
29
+ pingcode idea search --product PRODUCT_ID --filter '{"state": {"in": ["STATE_ID"]}}' --keywords "登录" --limit 20 --page-index 1
30
+ pingcode idea search --product PRODUCT_ID --include-public-image-token --limit 50 --page-index 1
31
+
32
+ # 创建需求(--product 必须是 raw ID;--assignee 支持从缓存解析名称)
33
+ pingcode idea create --product PRODUCT_ID --title "新增登录功能" --dry-run
34
+ pingcode idea create --product PRODUCT_ID --title "新增登录功能" --description "支持手机号登录" --assignee "张三" --suite SUITE_ID --priority PRIORITY_ID --properties '{"custom_field": "value"}'
35
+
36
+ # 更新需求(通过 identifier 或 id;支持 --title、--description、--state、--priority、--assignee、--progress、--plan-at、--real-at、--plan、--suite、--properties)
37
+ pingcode idea update SLC-1 --state STATE_ID --priority PRIORITY_ID --dry-run
38
+ pingcode idea update SLC-1 --title "修正后的标题" --progress 0.5 --plan-at '{"from": "2026-07-20", "to": "2026-07-30", "granularity": "day"}' --real-at '{"from": "2026-07-21", "to": "2026-07-31", "granularity": "day"}' --plan PLAN_ID --suite SUITE_ID --properties '{"custom_field": "value"}'
39
+
40
+ # 查询需求字典(均需 --product raw ID)
41
+ pingcode idea states --product PRODUCT_ID
42
+ pingcode idea properties --product PRODUCT_ID
43
+ pingcode idea suites --product PRODUCT_ID
44
+ pingcode idea plans --product PRODUCT_ID
45
+ pingcode idea priorities --product PRODUCT_ID
46
+
47
+ # 查询需求状态流转历史
48
+ pingcode idea transition-history TRANSITION_HISTORY_ID SLC-1
49
+ pingcode idea transition-histories SLC-1
50
+ pingcode idea transition-histories IDEA_ID
51
+ ```
52
+
53
+ 查询/列表输出默认使用 `--compact`。写操作加 `--dry-run` 可预览请求而不实际发送。
54
+
55
+ ## 操作流程
56
+
57
+ 1. 使用 `pingcode context init` 初始化工作区缓存,确保用户列表等字典可用。
58
+ 2. 从产品后台或字典接口获取 `product_id`、`state_id`、`priority_id`、`suite_id`、`plan_id` 等 raw ID。
59
+ 3. 使用 `pingcode idea list --product PRODUCT_ID --compact` 查看需求标识符(如 `SLC-1`)。
60
+ 4. 创建需求时先加 `--dry-run` 预览,确认无误后去掉 `--dry-run` 执行真实写入。
61
+ 5. 更新需求时通过 identifier(如 `SLC-1`)定位,涉及字典 ID 的字段均使用 raw ID。
62
+ 6. 获取单条需求用 `get`(identifier 或 raw ID 均可)。
63
+
64
+ ## 安全规则
65
+
66
+ - 禁止猜测 `product_id`、`state_id`、`priority_id`、`suite_id`、`plan_id`。这些字段必须使用 PingCode Web UI 或字典接口返回的 raw ID。
67
+ - 只有 `--assignee` 支持通过名称从工作区缓存解析;其他名称到 ID 的转换必须依赖缓存或字典接口。
68
+ - 创建/更新需求前优先使用 `--dry-run` 预览请求,确认字段正确后再执行真实写入。
69
+ - 不要在最终回答中回显令牌值。
70
+ - HTTP 429 表示触发频率限制,等待 `x-pc-retry-after` 秒后重试。
@@ -0,0 +1,48 @@
1
+ # 产品
2
+
3
+ 通过 `pingcode product` 子命令列出和获取 PingCode 产品。
4
+
5
+ ## 前置条件
6
+
7
+ 调用 API 前必须配置 PingCode 凭证:
8
+
9
+ ```bash
10
+ export PINGCODE_CLIENT_ID="..."
11
+ export PINGCODE_CLIENT_SECRET="..."
12
+ ```
13
+
14
+ 如果缺少凭证,CLI 会输出配置指引,按指引配置后重试。不要要求用户在对话中粘贴凭证或令牌。
15
+
16
+ ## 命令
17
+
18
+ ```bash
19
+ # 列出产品(默认 --compact)
20
+ pingcode product list --compact
21
+
22
+ # 按关键词搜索产品
23
+ pingcode product list --keywords "核心产品" --compact
24
+
25
+ # 限制返回数量
26
+ pingcode product list --limit 10 --compact
27
+
28
+ # 查看单个产品详情(需使用产品 raw id)
29
+ pingcode product get PRODUCT_ID
30
+
31
+ # 预览 API 请求而不实际发送
32
+ pingcode product list --dry-run
33
+ pingcode product get PRODUCT_ID --dry-run
34
+ ```
35
+
36
+ ## 操作流程
37
+
38
+ 1. 使用 `pingcode product list --compact` 查看产品列表,记录目标产品的 `id`。
39
+ 2. 使用 `pingcode product get PRODUCT_ID` 查看某个产品的完整详情。
40
+ 3. 拿到产品 `id` 后,可在需求(idea)命令中作为 `--product` 参数使用。
41
+
42
+ ## 安全规则
43
+
44
+ - 禁止猜测 `product_id`。应通过 `product list` 获取产品 ID 后再用于其他命令。
45
+ - 列表/详情查询输出默认使用 `--compact`。
46
+ - 写操作优先使用 `--dry-run` 预览(当前 product 模块仅支持查询)。
47
+ - HTTP 429 表示触发频率限制,等待 `x-pc-retry-after` 秒后重试。
48
+ - 不要在最终回答中回显令牌值。
@@ -25,13 +25,11 @@ pingcode workitem list --keywords "登录页面" --compact
25
25
  pingcode workitem create --title "New task" --type task --project PROJECT_ID --sprint SPRINT_ID
26
26
  pingcode workitem create --title "Bug fix" --type bug --assignee @me --priority high
27
27
 
28
- # 查看工作项
29
- pingcode workitem show SCR-123
30
- pingcode workitem show WI-AbCdEf
31
-
32
28
  # 获取工作项(单个工作项接口,通过 id 或 identifier)
33
29
  pingcode workitem get WORK_ITEM_ID
34
30
  pingcode workitem get WYT-852
31
+ pingcode workitem get SCR-123
32
+ pingcode workitem get WI-AbCdEf
35
33
 
36
34
  # 更新工作项(通过 identifier 或 id;支持 --title、--description、--type、--project、--sprint、--state、--priority、--assignee、--parent、--version、--board、--entry、--swimlane、--start-at、--end-at、--participants、--story-points、--estimated-workload、--remaining-workload、--properties)
37
35
  pingcode workitem update SCR-123 --state 已完成