@wirecat/cli-base 0.96.0 → 0.98.0
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/CHANGELOG.md +81 -0
- package/dist/commands/document.js +1 -1
- package/dist/commands/registry.d.ts +2 -1
- package/dist/dev/adopt.d.ts +6 -0
- package/dist/dev/adopt.js +43 -0
- package/dist/dev/audit.js +2 -2
- package/dist/dev/conformance.d.ts +5 -0
- package/dist/dev/conformance.js +24 -4
- package/dist/dev/family.d.ts +10 -0
- package/dist/dev/family.js +41 -0
- package/dist/dev/lint.d.ts +8 -0
- package/dist/dev/lint.js +34 -7
- package/dist/dev/main.js +173 -23
- package/dist/dev/network.js +10 -2
- package/dist/dev/result-shape.d.ts +19 -0
- package/dist/dev/result-shape.js +263 -0
- package/dist/http/index.d.ts +23 -2
- package/dist/http/index.js +61 -0
- package/dist/release/fragments.d.ts +17 -0
- package/dist/release/fragments.js +108 -0
- package/dist/release/index.d.ts +2 -0
- package/dist/release/index.js +2 -0
- package/dist/release/level.d.ts +2 -0
- package/dist/release/level.js +52 -0
- package/dist/standards/audit.d.ts +2 -0
- package/dist/standards/audit.js +2 -0
- package/dist/standards/flags-account.d.ts +3 -0
- package/dist/standards/flags-account.js +36 -0
- package/dist/standards/index.d.ts +1 -1
- package/dist/standards/lint.d.ts +18 -2
- package/dist/standards/lint.js +29 -6
- package/dist/standards/output.d.ts +12 -0
- package/dist/standards/tables.d.ts +1 -1
- package/dist/standards/tables.js +1 -1
- package/dist/standards/vocabulary.js +3 -0
- package/docs/standards/README.md +1 -1
- package/docs/standards/accounts.md +3 -3
- package/docs/standards/layout.md +1 -1
- package/docs/standards/lifecycle.md +4 -6
- package/docs/standards/output.md +42 -2
- package/docs/standards/releases.md +6 -4
- package/docs/standards/testing.md +1 -1
- package/docs/standards/toolchain.md +7 -3
- package/package.json +1 -1
package/docs/standards/output.md
CHANGED
|
@@ -137,7 +137,7 @@ JSON Schema 2020-12.
|
|
|
137
137
|
|
|
138
138
|
- **Why:** an agent that reads one CLI's answer can read the other's.
|
|
139
139
|
- **Enforced by:** `same-path-contract` (weekly audit; it does not block a pull request yet) · `same-entity-schema`
|
|
140
|
-
(
|
|
140
|
+
(the family audit, which reads every CLI's schemas).
|
|
141
141
|
- **Example:** what only one messenger knows goes under `provider_metadata`, never as a top-level field one CLI has and
|
|
142
142
|
the other lacks.
|
|
143
143
|
- **Exceptions:** none.
|
|
@@ -190,7 +190,7 @@ whole or partial.
|
|
|
190
190
|
### WC-OUT-15 · Branch on `code` and `reason`, never on `message`
|
|
191
191
|
|
|
192
192
|
- **Why:** the message is for a person and may change. The code and reason are the contract.
|
|
193
|
-
- **Enforced by:** `same-error-reason` (
|
|
193
|
+
- **Enforced by:** `same-error-reason` (the family audit, which reads every CLI's reasons).
|
|
194
194
|
- **Example:** `reason` is a registered dotted id, such as `query.too-large`, defined with `defineReasons` where it is
|
|
195
195
|
raised. `details` keeps only registered keys, and never a `cause`.
|
|
196
196
|
- **Exceptions:** none.
|
|
@@ -309,6 +309,46 @@ Three things follow from it:
|
|
|
309
309
|
- **Exceptions:** MCP tools answer JSON.
|
|
310
310
|
- **Applies to:** CLIs that run on cli-core's `run()`. **Since:** cli-base 0.74.0. **Rulings:** NEED-2131.
|
|
311
311
|
|
|
312
|
+
## TypeScript API
|
|
313
|
+
|
|
314
|
+
### WC-OUT-25 · Return a list or a search from a TypeScript API as a `ListResult`
|
|
315
|
+
|
|
316
|
+
- **Why:** a caller that pages one service pages all of them the same way, and a command prints any of them as the
|
|
317
|
+
list envelope with no renaming of its own.
|
|
318
|
+
- **Enforced by:** `result-shape`.
|
|
319
|
+
- **Example:** `ListResult<T>` from `@wirecat/cli-base/standards` is `{ items, hasMore, nextOffset?, nextCursor?,
|
|
320
|
+
total? }`. A search takes `offset` and `limit`:
|
|
321
|
+
|
|
322
|
+
```ts
|
|
323
|
+
const page = await notes.search("invoice", { offset: 40, limit: 20 })
|
|
324
|
+
// { items: [ … ], hasMore: true, nextOffset: 60, total: { value: 312, relation: "eq" } }
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
`nextOffset` is absent on the last page. A source with its own position, such as a message history or a provider's
|
|
328
|
+
page token, gives `nextCursor` instead. `total` is the `Total` of
|
|
329
|
+
[WC-OUT-5](#wc-out-5--say-in-page-how-the-source-pages). Other facts about the run sit beside these keys, in
|
|
330
|
+
camelCase: `meaningSkipped`, `accounts`. In `--json` the same result is the list envelope of
|
|
331
|
+
[WC-OUT-4](#wc-out-4--answer-every-json-request-with-one-envelope-a-list-or-one-thing), in snake_case: `hasMore` is
|
|
332
|
+
`page.has_more`, a command paged by `--page` reads `offset = (page - 1) × limit` and answers `next_page`, and
|
|
333
|
+
`nextCursor` is `page.next_cursor`. A failure throws a `CliError`, which prints as the error object of
|
|
334
|
+
[WC-OUT-14](#wc-out-14--print-a-failure-in-machine-mode-as-one-json-object-on-stderr-with-stdout-empty); a result
|
|
335
|
+
never carries an `error` key. A paged list is never a bare array, never takes a page number, and its keys are never
|
|
336
|
+
`hits`, `has_more`, `limit_reached` or `next_offset`.
|
|
337
|
+
- **Exceptions:** a list that takes no limit and returns everything it has, such as the folders of an account, may
|
|
338
|
+
return an array. A type that describes the `--json` answer itself keeps the envelope's snake_case keys. A page as a
|
|
339
|
+
provider hands it to a source adapter, such as a CRM's `nextPage` token, keeps the provider's paging: an entry in
|
|
340
|
+
`lint/overrides.json` says so.
|
|
341
|
+
- **Applies to:** packages whose TypeScript API other packages import: cli-core today. **Since:** cli-base 0.97.0.
|
|
342
|
+
**Rulings:** NEED-2561.
|
|
343
|
+
|
|
344
|
+
`result-shape` reads the `.d.ts` files a package publishes: every `types` entry in `package.json`, and what they
|
|
345
|
+
import. It checks a declaration or member named like a page (`list…`, `search…`, `history…`, or a name ending in
|
|
346
|
+
`Found`, `Page`, `Result`, `Results`, `List` or `Hits`) that holds an array and a paging key. It also checks a
|
|
347
|
+
function or method named like a list or a search (`list…`, `search…`, `find…`, `…List`, `…Search`) that takes a
|
|
348
|
+
`limit`, an `offset`, a page, or a type that declares a `limit` or an `offset`: it must not return an array or take a
|
|
349
|
+
page number. A list named otherwise, such as `memories()`, is not seen. A package that publishes no types, or has not
|
|
350
|
+
built them, is skipped, and the lint says so. A declared file that is missing while others are built is a violation.
|
|
351
|
+
|
|
312
352
|
## Sources
|
|
313
353
|
|
|
314
354
|
These documents explain the rules on this page in more detail. Where one of them disagrees with this page, this page
|
|
@@ -220,10 +220,12 @@ and fails a first release (the base version is `0.0.0`) whose `package.json` ins
|
|
|
220
220
|
After the live check of the real service passes
|
|
221
221
|
([WC-TEST-18](testing.md#wc-test-18--check-the-real-service-by-hand-never-in-the-test-suite)),
|
|
222
222
|
`cli-dev live record --script <its script>` appends `<version> <commit> <date> <script> <tree>` to
|
|
223
|
-
`docs/dev/live-checks.txt`, committed in the release pull request; `<tree>` is a SHA-256 of
|
|
224
|
-
package.json pnpm-lock.yaml
|
|
225
|
-
|
|
226
|
-
|
|
223
|
+
`docs/dev/live-checks.txt`, committed in the release pull request; `<tree>` is `v2:` and a SHA-256 of
|
|
224
|
+
`git ls-tree -r HEAD -- src package.json pnpm-lock.yaml` without the files that never ship: `*.test.*`, `src/testing/`,
|
|
225
|
+
`__snapshots__/` and `__fixtures__/`. A merge that changes only those needs no new live check. `bin/release` runs
|
|
226
|
+
`cli-dev live check` first: it refuses a version with no line, and one whose shipped files differ from the files the
|
|
227
|
+
record hashed. The commit is information only. A `<tree>` without `v2:` was written before cli-base 0.98.0 and is
|
|
228
|
+
still compared with every file; a line from before cli-base 0.80.8 has no `<tree>` and is compared with its commit.
|
|
227
229
|
|
|
228
230
|
- **Why:** every automated check passed on bitrix24-cli while it ignored `deny` on reads; a release that says what
|
|
229
231
|
was checked, and a live check bound to the code released, are what a reviewer reads instead of the whole diff.
|
|
@@ -209,7 +209,7 @@ and which run after merge is in [CI](ci.md).
|
|
|
209
209
|
update check, MCP logins and lock files that only cli-core writes do not count. Tests still keep them in the
|
|
210
210
|
sandboxed home, like every other path
|
|
211
211
|
([WC-TEST-1](#wc-test-1--point-every-path-a-test-could-write-at-a-temporary-directory)).
|
|
212
|
-
- **Applies to:** all CLIs with local state.
|
|
212
|
+
- **Applies to:** all CLIs with local state. **Since:** cli-base 0.41.0. **Rulings:** none.
|
|
213
213
|
|
|
214
214
|
### WC-TEST-15 · A refactor keeps `commands --json` and the MCP tool list as they were
|
|
215
215
|
|
|
@@ -209,10 +209,14 @@ no-unbounded-spread ([WC-TOOL-12](#wc-tool-12--do-not-spread-a-list-of-user-data
|
|
|
209
209
|
comes out when the shared package catches up. A word the CLI needs that the vocabulary does not have yet goes in
|
|
210
210
|
`lint/overrides.json`, never in the baseline: its `reason` links the cli-base pull request or issue that adds the
|
|
211
211
|
word, and it comes out in the change that takes the cli-base release with the word. The shared package's words
|
|
212
|
-
go in the baseline, as above; the CLI's own go in the overrides, where the count and the date keep them few.
|
|
212
|
+
go in the baseline, as above; the CLI's own go in the overrides, where the count and the date keep them few. Once cli-core marks the commands it mounts
|
|
213
|
+
(`origin: "cli-core"` in `commands --json`), the lint fails a word rule's baseline entry on the CLI's own command and
|
|
214
|
+
an override on cli-core's; with `--allow-stale` it only warns. A permanent exception also goes in `lint/overrides.json`, with `rule`, `target`, `reason`, `owner`
|
|
213
215
|
and `review_after`. More than 10
|
|
214
|
-
overrides fail the run
|
|
215
|
-
|
|
216
|
+
overrides fail the run. An override warns from 14 days before its `review_after`, and fails the run once it is more
|
|
217
|
+
than 14 days past it, so a date shared by several CLIs gives two weeks to land the fix. A rule of `low` severity
|
|
218
|
+
(`command-help-too-long`, `command-example-count`) is advice: its violations and stale baseline entries are printed
|
|
219
|
+
as warnings and fail nothing. The rules themselves are on the [Commands page](commands.md).
|
|
216
220
|
- **Exceptions:** zoom runs `lint:commands` in full validation only. cli-core runs its own command lint test in
|
|
217
221
|
`ci:quick`. cli-base, cli-testing, cli-docs and community have no command tree.
|
|
218
222
|
- **Applies to:** the CLIs. **Since:** cli-base 0.41.0. **Rulings:** none.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.98.0",
|
|
4
4
|
"description": "The parts every command line tool needs: output modes, terminal rendering, error model, exit codes, credentials, clocks",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Viacheslav Ptsarev",
|