pingcode-cli-unofficial 2.2.0 → 2.3.1
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.md +63 -17
- package/dist/bin/pingcode.js +479 -164
- package/dist/bin/pingcode.js.map +1 -1
- package/package.json +3 -1
- package/skills/pingcode/SKILL.md +19 -0
- package/skills/pingcode/modules/api.md +11 -8
package/README.md
CHANGED
|
@@ -26,20 +26,27 @@ Requires **Node.js >= 20**. The package is published to **npm** as [`pingcode-cl
|
|
|
26
26
|
npm install -g pingcode-cli-unofficial
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
That puts `pingcode` on your `PATH`, and it is the only install path.
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
That puts `pingcode` on your `PATH`, and it is the only install path. npm owns the
|
|
30
|
+
installation lifecycle: version selection, extraction, replacement, executable links,
|
|
31
|
+
and rollback. The CLI only consumes that installation and reads its version from the
|
|
32
|
+
running package. Self-update invokes `npm i -g`, so the box needs an `npm` alongside
|
|
33
|
+
the `node` running the CLI.
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
A retired standalone copy under `~/.local/share/pingcode-cli` is never used for
|
|
36
|
+
version, package, or skill resolution. `pingcode self-update` prints a one-line
|
|
37
|
+
notice when that directory exists; it can be deleted.
|
|
34
38
|
|
|
35
|
-
|
|
39
|
+
### Development from source
|
|
40
|
+
|
|
41
|
+
Build from a checkout when you want the latest code between releases, or want to edit/extend the CLI.
|
|
42
|
+
This is a development workflow, not a second installation mechanism:
|
|
36
43
|
|
|
37
44
|
```bash
|
|
38
45
|
git clone https://github.com/anine09/pingcode-cli-unofficial.git
|
|
39
46
|
cd pingcode-cli-unofficial
|
|
40
47
|
npm install
|
|
41
48
|
npm run build # → dist/bin/pingcode.js
|
|
42
|
-
|
|
49
|
+
node dist/bin/pingcode.js --help
|
|
43
50
|
```
|
|
44
51
|
|
|
45
52
|
Development commands:
|
|
@@ -51,6 +58,8 @@ npm run dev # tsup --watch
|
|
|
51
58
|
npm run skill:install # build, then copy skills/pingcode into the agent skill dirs
|
|
52
59
|
npm run scan:secrets # credential / tenant-identifier scan
|
|
53
60
|
npm run check:commits # commit-message gate
|
|
61
|
+
npm run check:npm-ownership # reject CLI-owned install paths/version literals
|
|
62
|
+
npm run smoke:npm-package # after build: verify built and packed tarball execution
|
|
54
63
|
```
|
|
55
64
|
|
|
56
65
|
---
|
|
@@ -126,31 +135,67 @@ The CLI authenticates as an **application**, not as a user, using the OAuth
|
|
|
126
135
|
|
|
127
136
|
## Log in
|
|
128
137
|
|
|
138
|
+
Two kinds of credential are supported, and they are independent slots in the same config file:
|
|
139
|
+
|
|
140
|
+
- **app credentials** (`client_id` + `client_secret`) — the enterprise app
|
|
141
|
+
(`client_credentials`, `--mode enterprise`) or a user-bound OAuth app (`--mode user`,
|
|
142
|
+
authorization code). Without `--mode`, `auth login` defaults to `user`;
|
|
143
|
+
- **a personal access token** — created in PingCode 个人设置, pasted in with `--mode pat`, or supplied
|
|
144
|
+
as `PINGCODE_TOKEN`. No app registration, no browser, no refresh.
|
|
145
|
+
|
|
129
146
|
```bash
|
|
130
147
|
# public cloud (default host: https://open.pingcode.com)
|
|
131
|
-
pingcode auth login --client-id <id> --client-secret <secret> --save
|
|
148
|
+
pingcode auth login --mode enterprise --client-id <id> --client-secret <secret> --save
|
|
132
149
|
|
|
133
150
|
# self-hosted: pass your instance host, the API is served from <host>/open
|
|
134
|
-
pingcode auth login --host https://pingcode.example.com \
|
|
151
|
+
pingcode auth login --mode enterprise --host https://pingcode.example.com \
|
|
135
152
|
--client-id <id> --client-secret <secret> --save
|
|
136
153
|
|
|
137
154
|
pingcode auth status --check # adds one live call: GET /v1/pjm/projects?page_size=1
|
|
138
|
-
pingcode auth logout # drops the token
|
|
155
|
+
pingcode auth logout # drops the active token slot and the metadata cache
|
|
156
|
+
pingcode auth logout --all # additionally drops both app credential pairs and the other slots
|
|
139
157
|
```
|
|
140
158
|
|
|
141
159
|
Credentials resolve in this precedence order: **CLI flags → environment
|
|
142
|
-
(`PINGCODE_CLIENT_ID`, `PINGCODE_CLIENT_SECRET`, `PINGCODE_HOST`) →
|
|
143
|
-
With a TTY attached, `auth login` prompts for anything missing.
|
|
160
|
+
(`PINGCODE_CLIENT_ID`, `PINGCODE_CLIENT_SECRET`, `PINGCODE_TOKEN`, `PINGCODE_HOST`) →
|
|
161
|
+
`~/.pingcode/config.json`**. With a TTY attached, `auth login` prompts for anything missing.
|
|
144
162
|
|
|
145
163
|
- `--save` is what persists the client id/secret. Without it only the token is stored, so you must
|
|
146
164
|
log in again when it expires.
|
|
147
165
|
- Storage is `~/.pingcode/config.json`, mode `0600` inside a `0700` directory (a no-op on Windows).
|
|
148
166
|
`PINGCODE_CONFIG_DIR` relocates it.
|
|
149
|
-
-
|
|
150
|
-
and reactively once on a `401`, replaying the original request. You never have to
|
|
151
|
-
while the credentials are stored.
|
|
167
|
+
- App-credential tokens are valid ~30 days and are re-acquired **transparently**: proactively 120 s
|
|
168
|
+
before expiry, and reactively once on a `401`, replaying the original request. You never have to
|
|
169
|
+
re-run `login` while the credentials are stored. A personal access token is the exception — it
|
|
170
|
+
cannot be renewed, see below.
|
|
152
171
|
- Repeated logins do **not** invalidate previously issued tokens, so parallel invocations are safe.
|
|
153
172
|
|
|
173
|
+
### Personal access token (脚本 / CI/CD)
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# token created in PingCode 个人设置 (validity + scopes chosen there, shown only once)
|
|
177
|
+
pingcode auth login --mode pat --token <token> # store it (mode 0600, in its own slot)
|
|
178
|
+
PINGCODE_TOKEN=<token> pingcode project list # or use it for one process, no login at all
|
|
179
|
+
pingcode auth status --check # verifies with GET /v1/myself
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Use it when the OAuth dance is impractical — a cron job, a CI runner, a shared machine, or when you
|
|
183
|
+
simply do not want to register an app. Things worth knowing:
|
|
184
|
+
|
|
185
|
+
- it is **not refreshable**. There is no token endpoint to call and no `refresh_token` to exchange:
|
|
186
|
+
an expired or revoked token fails with exit code `3` (`auth:`) and points you at `auth login --mode
|
|
187
|
+
pat`, which is also what `--check` proves. The CLI never silently retries a rejected PAT.
|
|
188
|
+
- its reach is whatever `scopes` you granted. Because it acts as you it can call the seven
|
|
189
|
+
user-token-only endpoints (`/v1/myself`, `/v1/permission/my/*`, `/v1/permission/check/*`), and
|
|
190
|
+
`auth login --mode pat` verifies tolerantly: `/v1/myself`, then one capability probe, then "stored
|
|
191
|
+
but unverified" when the token has no probeable scope. A `401` always fails hard — a dead token is
|
|
192
|
+
never written over a working one.
|
|
193
|
+
- `PINGCODE_TOKEN` wins over the config file, so a CI job can override a developer's local login
|
|
194
|
+
without touching it. `auth status` reports which slot is active (`auth_mode`), where it came from
|
|
195
|
+
(`token_source`) and whether the CLI can renew it (`token_refreshable`).
|
|
196
|
+
- `auth logout` clears only the active slot; `--all` clears the enterprise, user and pat slots plus
|
|
197
|
+
both app credential pairs, keeping `host`.
|
|
198
|
+
|
|
154
199
|
---
|
|
155
200
|
|
|
156
201
|
## Coverage: reach vs ergonomics
|
|
@@ -165,8 +210,9 @@ layers whose costs are completely different, and it is worth knowing which one y
|
|
|
165
210
|
|
|
166
211
|
"Complete" (完全体) refers to **Reach**, and Reach is finished: every documented endpoint is
|
|
167
212
|
invocable today. Seven of the 459 need a user token (`/v1/myself`, `/v1/permission/my/*`,
|
|
168
|
-
`/v1/permission/check/*`) — run `pingcode auth login --mode user`
|
|
169
|
-
|
|
213
|
+
`/v1/permission/check/*`) — run `pingcode auth login --mode user` (it prints an authorize URL; paste
|
|
214
|
+
the redirect URL back, or pass `--code`), or use a personal access token whose scopes cover them,
|
|
215
|
+
and all 459 become callable. On the
|
|
170
216
|
default 企业令牌 alone they are refused *before any request*, which leaves 452 actually callable.
|
|
171
217
|
Ergonomics is a
|
|
172
218
|
**curation backlog, not a finish line**: an endpoint earns a named command by being run against a
|
|
@@ -883,7 +929,7 @@ in `scripts/` for one reason: `prepare` runs during `npm ci`, including on the N
|
|
|
883
929
|
**`.github/workflows/release.yml`** — on tags matching `v*`. To cut a release:
|
|
884
930
|
|
|
885
931
|
```bash
|
|
886
|
-
# 1. bump the version in package.json (
|
|
932
|
+
# 1. bump the version in package.json (the CLI reads this running-package value at runtime)
|
|
887
933
|
# 2. commit it, and make sure main is green
|
|
888
934
|
git tag -a v0.2.0 -m 'v0.2.0'
|
|
889
935
|
git push origin v0.2.0
|