Skip to content

Commit 93d7fb4

Browse files
luanvdwclaude
andcommitted
docs(version): spec --version flag and version subcommand
Doc-driven prep for PRO-174. - command-spec.md: add `prisma-cli version` subcommand section and `prisma-cli --version` flag section; document `--help` and `--version` as universal utility flags distinct from per-command shared global flags; add `version` to the scope listing as the one top-level utility command. - output-conventions.md: map `version` to the `show` pattern. - error-conventions.md: register `VERSION_UNAVAILABLE` as a defensive code used only when the bundled CLI metadata cannot be read. No code change in this commit. The implementation follows. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent aef197d commit 93d7fb4

3 files changed

Lines changed: 85 additions & 0 deletions

File tree

docs/product/command-spec.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ The preview package includes these command groups:
1414
- `branch`
1515
- `app`
1616

17+
The preview package also includes one top-level utility command:
18+
19+
- `version`
20+
21+
`version` is intentionally outside the workflow groups: it reports CLI build and environment state, requires no auth, no project context, and no network, and is the canonical answer to "is this CLI installed and on the build I expect?"
22+
1723
Out of scope for the current preview:
1824

1925
- `init`
@@ -25,6 +31,7 @@ Out of scope for the current preview:
2531
## Global Rules
2632

2733
- Canonical shape is `prisma <group> <action>`.
34+
- `version` is the one top-level command outside that shape (see Scope above).
2835
- Every command supports `--json`.
2936
- Shared global flags are:
3037
- `--json`
@@ -36,6 +43,9 @@ Out of scope for the current preview:
3643
- `-y`, `--yes`
3744
- `--color`
3845
- `--no-color`
46+
- Universal utility flags also work at the program level:
47+
- `--help` — prints help for the root program or the named command and exits 0.
48+
- `--version` — prints the CLI version and exits 0. Honors `--json` for the structured envelope. No short alias (`-v` is reserved for `--verbose`; `-V` is avoided as a near-collision).
3949
- Long flags use kebab-case.
4050
- Boolean negation uses `--no-<flag>`.
4151
- `--json` and non-interactive mode must not block on prompts.
@@ -124,6 +134,78 @@ Rules:
124134
- `workspace` is the active workspace or `null`
125135
- signed-out state is an empty auth state, not an error
126136

137+
## `prisma-cli version`
138+
139+
Purpose:
140+
141+
- report the installed CLI build and a small block of host environment metadata
142+
143+
Behavior:
144+
145+
- requires no auth, no project context, and no network
146+
- reads the package's own version from its bundled metadata
147+
- reports CLI name, CLI version, Node.js version, OS platform, OS architecture, and a best-effort `invocation` label (`bunx`, `npx`, `global`, `dev`, or `unknown`)
148+
- uses the `show` output pattern (see `output-conventions.md`)
149+
- fails only when the bundled CLI metadata cannot be read; this is treated as `VERSION_UNAVAILABLE` and is not expected in practice
150+
151+
In `--json`, `result` uses this shape:
152+
153+
```json
154+
{
155+
"cli": {
156+
"name": "prisma-cli",
157+
"version": "3.0.0-alpha.3"
158+
},
159+
"node": {
160+
"version": "v24.14.1"
161+
},
162+
"os": {
163+
"platform": "darwin",
164+
"arch": "arm64"
165+
},
166+
"invocation": "bunx"
167+
}
168+
```
169+
170+
Rules:
171+
172+
- `cli.name` is the published package's `bin` name (`prisma-cli` in the current preview).
173+
- `cli.version` is the published package version.
174+
- `node.version` mirrors `process.version` exactly, including the leading `v`.
175+
- `os.platform` and `os.arch` mirror `process.platform` and `process.arch`.
176+
- `invocation` is best-effort and may be `null` when no signal is conclusive.
177+
178+
Examples:
179+
180+
```bash
181+
prisma-cli version
182+
prisma-cli version --json
183+
```
184+
185+
## `prisma-cli --version`
186+
187+
Purpose:
188+
189+
- universal smoke-test flag at the root of the program
190+
191+
Behavior:
192+
193+
- prints the CLI version and exits 0
194+
- requires no auth, no project context, and no network
195+
- works before any subcommand parsing — bare `prisma-cli --version` is sufficient
196+
- in human mode, prints a single line to stdout: `prisma-cli <version>`
197+
- in `--json` mode, emits the standard success envelope (see Command Result Envelopes) with `command: "version"` and `result.version: "<version>"`
198+
- `--version` is documented as a universal utility flag in Global Rules, not as a shared global flag (it is an early-exit utility, not a per-command modifier)
199+
200+
Examples:
201+
202+
```bash
203+
prisma-cli --version
204+
prisma-cli --version --json
205+
```
206+
207+
`prisma-cli version` is the richer environment report; `prisma-cli --version` is the terse one-liner. Both report the same `cli.version`. Use the flag for quick checks, the subcommand for support tickets and bug reports.
208+
127209
## `prisma-cli auth login`
128210

129211
Purpose:

docs/product/error-conventions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ These codes are the minimum stable set for the MVP:
163163
- `BUILD_FAILED`
164164
- `RUN_FAILED`
165165
- `DEPLOY_FAILED`
166+
- `VERSION_UNAVAILABLE`
166167

167168
Recommended meanings:
168169

@@ -184,6 +185,7 @@ Recommended meanings:
184185
- `BUILD_FAILED`: build failed before a healthy deployment existed
185186
- `RUN_FAILED`: local framework run command could not be started or exited unsuccessfully
186187
- `DEPLOY_FAILED`: deployment or post-build health failed
188+
- `VERSION_UNAVAILABLE`: CLI could not read its own bundled package metadata to report a version (defensive; not expected in normal installs)
187189

188190
## Exit Codes
189191

docs/product/output-conventions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Current MVP commands map to patterns like this:
6262

6363
| Command | Pattern |
6464
| --- | --- |
65+
| `version` | `show` |
6566
| `auth login` | `mutate` |
6667
| `auth logout` | `mutate` |
6768
| `auth whoami` | `show` |

0 commit comments

Comments
 (0)