use-pingcode-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUse PingCode CLI (pc
, REST API v2.0)
pcUse PingCode CLI (pc
, REST API v2.0)
pc把用户的自然语言目标翻译成对已安装 命令的调用,并验证结果。
本 skill 可在任意目录运行:直接调用 PATH 上的 ,不要假设 CLI 源码在本地、不要用 。
pcpccargo run当前 CLI 的业务命令全部调用 PingCode REST API v2.0,默认地址是 ,路径形如 。不要沿用 v1 的 、 环境变量或 配置方式。
https://open.pingcode.com/v2/pjm/workitemsapi.pingcode.comPC_*.env详细凭据、v2 数据结构、编号解析、搜索语法与错误对照见 ,动手前读一遍。
reference.mdTranslate the user's natural-language goal into calls to the installed command and validate the results.
This skill can run in any directory: directly invoke from PATH; do not assume the CLI source code is local and do not use .
pcpccargo runAll business commands in the current CLI call the PingCode REST API v2.0, with the default base URL being and paths shaped like . Do not use the v1 , environment variables, or configuration methods.
https://open.pingcode.com/v2/pjm/workitemsapi.pingcode.comPC_*.envDetailed credentials, v2 data structures, identifier parsing, search syntax, and error mappings are documented in ; read it before starting.
reference.md步骤
Steps
-
预检 CLI 与鉴权。
- 确认已安装;没有就按
command -v pc的安装方式提示用户(npm 包reference.md、Homebrew、Release 二进制或 cargo install),不要继续。@pingcode/cli - 跑 验证配置与连通。它在 stdout 输出结构化 JSON:
pc doctor为是否全部通过,ok每项有稳定checks[]、id(pass/fail/warn/info/skipped),失败项的status是可直接照做的修复步骤;退出码 0=通过、1=有检查失败、2=命令自身异常。remediation.steps - 退出码非 0 时,读 里
checks[]的项(如status=fail/credentials_present缺凭据、credential_pair/base_url_format地址或网络问题、base_url_reachable/token_exchange凭据无效),把对应api_auth转述给用户并停下让其处理;鉴权类问题不要反复重试。remediation.steps - 未登录时让用户自己执行 (自动化场景用
pc login从 stdin 读令牌);企业凭据用pc login --with-token。不要让用户在聊天里粘贴密钥。pc login --method client-credentials --client-id ... --client-secret ... - 私有部署先 ;
pc config set base-url <URL>可查看当前生效地址。pc config get base-url - 完成标准:退出码 0(
pc doctor),且ok: true指向预期环境。config.base_url
-
理解意图并发现命令(不臆造参数)。
- 把目标映射到 module/resource/operation(模块见 )。
reference.md - 逐级看帮助确定真实子命令与参数:→
pc <module> --help→pc <module> <resource> --help。以 help 里列出的 flags 和pc <module> <resource> <operation> --help链接为准;Doc:现在指向 v2 文档Doc:。https://developer.pingcode.com/restapi/pingcode/... - 需要更完整的 CLI 语义时,可读 CLI 自带参考:、
pc skills read pjm、pc skills read query、pc skills read fields、pc skills read authentication。pc skills read rate-limits - 密钥护栏:help 输出可能回显凭据默认值。读取帮助时忽略 auth/token/secret 相关行,绝不在回复里复述任何密钥。
- 完成标准:已确定要执行的确切命令行。
- 把目标映射到 module/resource/operation(模块见
-
把"名字/编号"解析成 ID。
- 已知工作项编号时,直接用 ,不要先 list。 v2 的
get支持GET /v2/pjm/workitems/{workitem_id}、id、short_id三种写法:whole_identifier- 完整编号:
pc pjm workitem get ABC-42 - 纯数字短号:
pc pjm workitem get 42 - 对象 id:优先用完整编号(项目前缀 + 数字),歧义最小。返回结果里同时有
pc pjm workitem get 5e05d8448f8461dada9ba29c、id、short_id(数字)、identifier(如whole_identifier)。ABC-42
- 完整编号:
- 项目名:,取
pc pjm project list --keywords "<名字>"。类型名:values[].id,取真实pc pjm workitem-type list-for-project --project-id <pid>。人名:type_id。pc organization user list --keywords "<名字>" - 列表响应是分页结构 ;
{page_index, page_size, total, values[]}从 0 开始,每页默认 30、最大 100,必要时翻页或加大page_index。--page-size - 名字匹配到 0 个或多个时,列出候选项让用户确认,不要猜。
- 完成标准:命令所需的每个 id 都有明确来源。
- 已知工作项编号时,直接用
-
执行。
- 读操作直接运行。写/删操作也直接运行——除非用户在本次调用里明确要求先预览(才加 )。
--dry-run - 写操作用 传 JSON:内联字符串、
--data、或@文件路径(stdin)。在其它仓库需要文件体时,写到临时目录再用@-。v2 请求体字段以该操作@/tmp/xxx.json里的--help页面为准。Doc: - 创建/更新工作项时 必须是项目里真实的类型 id,不能把
type_id/story这类标签当作bug;先type_id。workitem-type list-for-project - PATCH 只发送本次要改的字段;省略、、空字符串和空数组含义不同,不要整对象回写。
null - 所有业务结果都是 stdout 上的 pretty-print JSON;的请求预览在 stderr。
--dry-run - 完成标准:命令返回(成功或报错)。
- 读操作直接运行。写/删操作也直接运行——除非用户在本次调用里明确要求先预览(才加
-
验证输出。 解析 JSON,确认拿到了预期:新建对象的/
id/url、按编号查询到的html_url/identifier、更新后的字段值等。修改状态或属性后重新whole_identifier一次对比。结果不符预期就当作问题处理,不要报喜。get -
报错就给可操作的修正。 非 2xx 时 CLI 会打印 HTTP status 与 v2 错误体。按
{"code":"...","message":"..."}的错误对照表归类(鉴权/权限 scope、id 或编号非法、请求体缺字段、分页/参数、限流),指出具体怎么改(缺哪个字段、该用哪个 id/编号、需要哪个 scope),修正后重试。鉴权类错误不要反复重试,交回用户。reference.md -
汇报。 用中文简要给出结果:按编号查到了哪个工作项(标题/状态/负责人)、创建了什么(带/
id)、改了什么、或报错与修正建议。不复述密钥。url
不要把运行时学到的内容写回本 skill 目录下的任何文件( / 等):skill 目录随版本分发与更新,回写内容会在更新时被覆盖,也会污染受版本管理的安装目录。
SKILL.mdreference.md-
Precheck the CLI and authentication.
- Use to confirm that it is installed. If it is not, prompt the user to follow the installation instructions in
command -v pc(npm packagereference.md, Homebrew, Release binary, or cargo install), and do not continue.@pingcode/cli - Run to validate the configuration and connectivity. It outputs structured JSON to stdout:
pc doctorindicates whether all checks passed; each item inokhas a stablechecks[]andid(pass/fail/warn/info/skipped); andstatusfor failed items provides remediation steps that can be followed directly. Exit codes: 0=passed, 1=one or more checks failed, 2=the command itself encountered an error.remediation.steps - When the exit code is nonzero, read the items in whose
checks[](such asstatus=fail/credentials_presentfor missing credentials,credential_pair/base_url_formatfor address or network issues, orbase_url_reachable/token_exchangefor invalid credentials), relay the correspondingapi_authto the user, and stop so the user can resolve them. Do not repeatedly retry authentication issues.remediation.steps - When the user is not logged in, ask them to run themselves (in automation scenarios, use
pc loginto read the token from stdin). For enterprise credentials, usepc login --with-token. Do not ask the user to paste secrets into the chat.pc login --method client-credentials --client-id ... --client-secret ... - For private deployments, first run ;
pc config set base-url <URL>displays the currently effective URL.pc config get base-url - Completion criteria: exits with code 0 (
pc doctor), andok: truepoints to the expected environment.config.base_url
- Use
-
Understand the intent and discover the command (do not invent parameters).
- Map the goal to a module/resource/operation (see the modules in ).
reference.md - Inspect the help at each level to determine the actual subcommand and parameters: →
pc <module> --help→pc <module> <resource> --help. Use the flags listed in the help and itspc <module> <resource> <operation> --helplinks as the source of truth;Doc:now points to the v2 documentation atDoc:.https://developer.pingcode.com/restapi/pingcode/... - When more complete CLI semantics are needed, read the CLI's bundled reference: ,
pc skills read pjm,pc skills read query,pc skills read fields, andpc skills read authentication.pc skills read rate-limits - Credential guardrails: Help output may echo credential default values. Ignore auth/token/secret-related lines when reading the help, and never repeat any secrets in your response.
- Completion criteria: the exact command to execute has been determined.
- Map the goal to a module/resource/operation (see the modules in
-
Resolve "names/identifiers" to IDs.
- When the work item identifier is known, use directly; do not call list first. The v2
getendpoint supports three forms:GET /v2/pjm/workitems/{workitem_id},id, andshort_id:whole_identifier- Full identifier:
pc pjm workitem get ABC-42 - Numeric short ID:
pc pjm workitem get 42 - Object ID: Prefer the full identifier (project prefix + number) because it is the least ambiguous. The response includes
pc pjm workitem get 5e05d8448f8461dada9ba29c,id,short_id(numeric), andidentifier(such aswhole_identifier).ABC-42
- Full identifier:
- Project name: , and take
pc pjm project list --keywords "<name>". Type name:values[].id, and obtain the actualpc pjm workitem-type list-for-project --project-id <pid>. Person name:type_id.pc organization user list --keywords "<name>" - List responses use the paginated structure .
{page_index, page_size, total, values[]}starts at 0, and the default page size is 30 with a maximum of 100. Paginate or increasepage_indexwhen necessary.--page-size - When a name matches zero or multiple results, list the candidates and ask the user to confirm; do not guess.
- Completion criteria: every ID required by the command has a clear source.
- When the work item identifier is known, use
-
Execute.
- Run read operations directly. Write/delete operations also run directly, unless the user explicitly requests a preview in this invocation (only then add ).
--dry-run - Pass JSON to write operations using : an inline string,
--data, or@/path/to/file(stdin). When a file body is needed in another repository, write it to a temporary directory and then use@-. For v2 request body fields, follow the operation's@/tmp/xxx.json--helppage.Doc: - When creating or updating a work item, must be the actual type ID in the project. Do not treat labels such as
type_idorstoryasbug; first runtype_id.workitem-type list-for-project - For PATCH requests, send only the fields being changed. Omission, , an empty string, and an empty array have different meanings; do not write the entire object back.
null - All business results are pretty-printed JSON on stdout; request previews are written to stderr.
--dry-run - Completion criteria: the command returns either success or an error.
- Run read operations directly. Write/delete operations also run directly, unless the user explicitly requests a preview in this invocation (only then add
-
Verify the output. Parse the JSON and confirm that the expected data was received: the/
id/urlof a newly created object, thehtml_url/identifierof a work item queried by identifier, the updated field values, and so on. After changing a status or property, runwhole_identifieragain and compare the results. If the result does not match expectations, treat it as an issue and do not report success.get -
For errors, provide actionable corrections. For non-2xx responses, the CLI prints the HTTP status and the v2 error body. Categorize the error according to the error mapping table in
{"code":"...","message":"..."}(authentication/permission scope, invalid ID or identifier, missing request body fields, pagination/parameters, or rate limiting), and specify the exact correction needed (which field is missing, which ID/identifier to use, or which scope is required). Retry after making the correction. Do not repeatedly retry authentication errors; hand them back to the user.reference.md -
Report the results. Briefly report the outcome in Chinese: which work item was found by identifier (title/status/assignee), what was created (with/
id), what was changed, or the error and suggested correction. Do not repeat any secrets.url
Do not write anything learned at runtime back to any file in this skill directory ( / , etc.): the skill directory is distributed and updated with versions, so writing back will overwrite content during updates and pollute the version-controlled installation directory.
SKILL.mdreference.md