@wirecat/cli-base 0.43.4 → 0.44.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.
Files changed (51) hide show
  1. package/dist/commands/document.d.ts.map +1 -1
  2. package/dist/commands/document.js +2 -0
  3. package/dist/commands/document.js.map +1 -1
  4. package/dist/commands/index.d.ts +9 -0
  5. package/dist/commands/index.d.ts.map +1 -1
  6. package/dist/commands/index.js +10 -6
  7. package/dist/commands/index.js.map +1 -1
  8. package/dist/config.d.ts +1 -1
  9. package/dist/config.d.ts.map +1 -1
  10. package/dist/config.js.map +1 -1
  11. package/dist/dev/audit.d.ts.map +1 -1
  12. package/dist/dev/audit.js +6 -2
  13. package/dist/dev/audit.js.map +1 -1
  14. package/dist/dev/lint.d.ts.map +1 -1
  15. package/dist/dev/lint.js +3 -0
  16. package/dist/dev/lint.js.map +1 -1
  17. package/dist/query/parser.d.ts.map +1 -1
  18. package/dist/query/parser.js +6 -1
  19. package/dist/query/parser.js.map +1 -1
  20. package/dist/result-fields.d.ts.map +1 -1
  21. package/dist/result-fields.js +2 -1
  22. package/dist/result-fields.js.map +1 -1
  23. package/dist/standards/flags-how.d.ts.map +1 -1
  24. package/dist/standards/flags-how.js +7 -0
  25. package/dist/standards/flags-how.js.map +1 -1
  26. package/dist/standards/lint.d.ts.map +1 -1
  27. package/dist/standards/lint.js +6 -0
  28. package/dist/standards/lint.js.map +1 -1
  29. package/dist/standards/vocabulary.d.ts.map +1 -1
  30. package/dist/standards/vocabulary.js +1 -0
  31. package/dist/standards/vocabulary.js.map +1 -1
  32. package/dist/testing/sandbox.d.ts +2 -0
  33. package/dist/testing/sandbox.d.ts.map +1 -1
  34. package/dist/testing/sandbox.js +17 -3
  35. package/dist/testing/sandbox.js.map +1 -1
  36. package/docs/standards/README.md +1 -1
  37. package/docs/standards/architecture.md +4 -2
  38. package/docs/standards/ci.md +5 -3
  39. package/docs/standards/commands.md +1 -1
  40. package/docs/standards/docs.md +2 -2
  41. package/docs/standards/layout.md +1 -0
  42. package/docs/standards/lifecycle.md +4 -1
  43. package/docs/standards/new-cli.md +8 -4
  44. package/docs/standards/output.md +8 -4
  45. package/docs/standards/permissions.md +8 -5
  46. package/docs/standards/releases.md +3 -1
  47. package/docs/standards/security.md +9 -3
  48. package/docs/standards/style.md +3 -1
  49. package/docs/standards/testing.md +9 -4
  50. package/docs/standards/toolchain.md +17 -2
  51. package/package.json +1 -1
@@ -81,9 +81,11 @@ Commands that look after the tool and its files, and never show a message, have
81
81
  - **Why:** a profile that denies everything must still be able to fix its own config and log in.
82
82
  - **Enforced by:** review only.
83
83
  - **Example:** `config`, `session`, `doctor`, `commands`, `complete`, `upgrade`, `skill`, `models`, `server`,
84
- `schedule`, `runs`, `sends`, `recipients`, `flood`, `mcp`, `replies`, and `store info|check|migrate|backup|restore|
85
- repair|copies`. Under `bot`: `auth`, `list`, `sends`, `recipients`, `mcp`.
86
- - **Exceptions:** what a schedule or a reply rule does is checked by its own key when it runs (`replies.send`).
84
+ `schedule`, `runs`, `sends`, `recipients`, `flood`, `mcp`, `replies` where the messenger has replies, and
85
+ `store info|check|migrate|backup|restore|repair|copies`. Under `bot`: `auth`, `list`, `sends`, `recipients`, `mcp`.
86
+ wa has no `replies` group: its owner rules out automatic replies.
87
+ - **Exceptions:** what a schedule does, or a reply rule where the messenger has replies, is checked by its own key
88
+ when it runs (`replies.send`).
87
89
  - **Applies to:** messenger CLIs. **Since:** cli-base 0.41.0. **Rulings:** none.
88
90
 
89
91
  ### WC-PERM-6 · The built-in defaults ask only before what cannot be undone
@@ -103,8 +105,9 @@ A default is never made stricter without the owner's word.
103
105
  - **Why:** the tool should work without questions; only a deletion, a logout or an automatic reply needs one.
104
106
  - **Enforced by:** `cli-core: src/sends/permissions.test.ts`.
105
107
  - **Example:** a new profile sends at once, and asks before `messages delete`.
106
- - **Exceptions:** `replies.send` is `deny`: a reply rule writes to people with nobody typing a command, so it waits for
107
- the owner's own `allow`.
108
+ - **Exceptions:** where the messenger has replies, `replies.send` is `deny`: a reply rule writes to people with nobody
109
+ typing a command, so it waits for the owner's own `allow`. A messenger with no `replies` group, such as wa, has no
110
+ use for the key.
108
111
  - **Applies to:** messenger CLIs. **Since:** cli-base 0.41.0. **Rulings:** NEED-568.
109
112
 
110
113
  ### WC-PERM-7 · A built-in default only ever tightens
@@ -136,7 +136,9 @@ on the [CI](ci.md) page.
136
136
  - **Enforced by:** `release.yml` · `release-checks.yml`.
137
137
  - **Example:** `release.yml` runs full validation and `release-checks.yml` (dependency audit, workflow analysis with
138
138
  zizmor, CodeQL). Validation packs the package once, and the `build` job checks that file's SHA-256 before it is
139
- handed to `publish`.
139
+ handed to `publish`. A CLI that publishes several packages packs every one of them once, records each file's
140
+ SHA-256, and checks each before it is published: wa publishes its main package and six platform packages of its
141
+ Go engine.
140
142
  - **Exceptions:** none.
141
143
  - **Applies to:** all CLIs and shared libraries. **Since:** cli-base 0.41.0. **Rulings:** none.
142
144
 
@@ -53,7 +53,10 @@ name is scoped to that directory (`isolated: true`).
53
53
  owner's real keyring entry.
54
54
  - **Enforced by:** `src/credentials.test.ts`.
55
55
  - **Example:** a bot token is read from `MAX_BOT_TOKEN`, then the keyring entry `bot:<profile>`, then the file.
56
- - **Exceptions:** `auto` storage tries the keyring and, when it fails, warns once on stderr and uses the file.
56
+ - **Exceptions:** `auto` storage tries the keyring and, when it fails, warns once on stderr and uses the file. A
57
+ messenger library's own device store, which the library opens as a file and which cannot live in the keyring
58
+ (WhatsApp's `private.db`), is an owner-only file under
59
+ [WC-SECR-10](#wc-secr-10--private-files-are-written-atomically-with-private-modes) instead.
57
60
  - **Applies to:** all CLIs. **Since:** cli-base 0.41.0. **Rulings:** NEED-295.
58
61
 
59
62
  ### WC-SECR-5 · A secret is never taken on the command line
@@ -102,7 +105,9 @@ Output shows the last four digits (`***1234`). `--show-phone` prints the whole n
102
105
  - **Why:** a phone number identifies a person and is the login of a messenger account.
103
106
  - **Enforced by:** review only.
104
107
  - **Example:** `max work account show --show-phone`.
105
- - **Exceptions:** none.
108
+ - **Exceptions:** an id that is itself the phone number is printed whole, because a masked id cannot be passed back
109
+ to the next command. WhatsApp names a person by a phone-form id while their hidden id (LID) is not known yet; wa
110
+ prints the LID whenever it has one.
106
111
  - **Applies to:** messenger CLIs. **Since:** cli-base 0.41.0. **Rulings:** NEED-209.
107
112
 
108
113
  ### WC-SECR-9 · A command does not send the CLI's own secret files unless the owner says so
@@ -119,7 +124,8 @@ the message store. The owner adds `--allow-any-file` to send one anyway.
119
124
  ### WC-SECR-10 · Private files are written atomically with private modes
120
125
 
121
126
  A file that holds a secret or private state is written with `writeSecurely`: atomically, mode `0600`, in a directory
122
- created with mode `0700`. A temporary credential file, such as a login QR image, is `0600` and removed in `finally`.
127
+ created with mode `0700`. `writeSecurely` takes text or bytes, so a login QR image is written the same way. A
128
+ temporary credential file, such as that image, is `0600` and removed in `finally`.
123
129
  tg's `doctor` reports a wrong mode and prints the `chmod` fix without applying it.
124
130
 
125
131
  - **Why:** another user on the same computer must not read the session.
@@ -35,7 +35,9 @@ formatting, so this page does not repeat it.
35
35
  - **Enforced by:** review only.
36
36
  - **Example:** `src/format-markdown.ts` and `src/format-markdown.test.ts`. A test that covers a behaviour across
37
37
  modules is named after that behaviour, such as `src/every-failure.test.ts`.
38
- - **Exceptions:** none.
38
+ - **Exceptions:** a language whose toolchain reads meaning from a file name keeps that language's form. Go files are
39
+ lower case with underscores, because `go test` finds `_test.go` and the build picks `_unix.go` or `_windows.go`
40
+ by name: wa's `engine/cmd/wa-engine/lock_unix.go` and `convert_test.go`.
39
41
  - **Applies to:** all repositories. **Since:** cli-base 0.41.0. **Rulings:** none.
40
42
 
41
43
  ### WC-STYLE-4 · Write functions in the small, and a class only where identity matters
@@ -47,14 +47,17 @@ and which run after merge is in [CI](ci.md).
47
47
  - **Applies to:** all CLIs and the shared packages. cli-base uses the shared setup; the CLIs keep their own sandboxes
48
48
  for now. drive has none yet, and zoom's moves only the temporary directory. **Since:** cli-base 0.41.0. **Rulings:** none.
49
49
 
50
- ### WC-TEST-2 · No test reaches the real keyring
50
+ ### WC-TEST-2 · No test opens a real credential store
51
51
 
52
- - **Why:** the owner's tokens live in the real keychain, and one test that forgets an option would write there.
53
- - **Enforced by:** `src/keyring.test.ts`.
52
+ - **Why:** the owner's tokens live in the real keychain, and a messenger's device keys in a file of their own; one
53
+ test that forgets an option would read or write the real one.
54
+ - **Enforced by:** `src/keyring.test.ts` · `whatsapp-cli: src/testing/sandbox.test.ts`.
54
55
  - **Example:** every test passes `memoryKeyring()` from `@wirecat/cli-base/testing`. The shared setup
55
56
  (`@wirecat/cli-base/testing/setup`, [WC-TEST-1](#wc-test-1--point-every-path-a-test-could-write-at-a-temporary-directory))
56
57
  also replaces `@napi-rs/keyring` with a module that throws, so a forgotten option fails the test instead of
57
58
  reaching the keychain, and `src/keyring.test.ts` asserts that `systemKeyring` throws under it.
59
+ A credential store that is a file, such as WhatsApp's linked-device keys in `private.db`, resolves under the
60
+ sandbox's state directory, and a sandbox test asserts that its path is inside the temporary root, as wa's does.
58
61
  - **Exceptions:** none. Until a CLI adopts the shared setup, its sandbox does not replace `@napi-rs/keyring`; tg and
59
62
  max only scope the keyring entry through environment variables.
60
63
  - **Applies to:** all CLIs and the shared packages. **Since:** cli-base 0.41.0. **Rulings:** none.
@@ -220,7 +223,9 @@ and which run after merge is in [CI](ci.md).
220
223
  - **Example:** live scenarios run by hand, by the owner or with the owner's yes, on test profiles and test chats
221
224
  only. The cast lives in an ignored file, no profile is assumed, and the record keeps the shape of each answer,
222
225
  never its content. When a scenario is run again, the sentence it supports is updated.
223
- - **Exceptions:** none.
226
+ - **Exceptions:** a messenger with no test accounts, such as WhatsApp, where a second account or a second linked
227
+ device would change the owner's real one, runs live scenarios on the owner's profile and only in the owner's own
228
+ chat (the chat with themselves). It never writes to another person, and still runs only with the owner's yes.
224
229
  - **Applies to:** all CLIs that talk to a real account. **Since:** cli-base 0.41.0. **Rulings:** none.
225
230
 
226
231
  ## Sources
@@ -1,10 +1,12 @@
1
1
  # Toolchain
2
2
 
3
+ <!-- cspell:ignore gofmt -->
4
+
3
5
  ## Scope
4
6
 
5
7
  How a repository is built and checked before review: the shared presets and `standards:check`, strict TypeScript,
6
8
  the shared Biome preset and its grit plugins, the file size cap, import cycles, layer boundaries as lint, the command
7
- lint, spelling and Markdown lint.
9
+ lint, spelling, Markdown lint, and the checks for a Go part.
8
10
 
9
11
  Rule ids on this page are `WC-TOOL-<n>`. How to read a rule, how ids work and which rule wins are in the
10
12
  [index](README.md). What runs on which trigger is on the [CI page](ci.md).
@@ -156,7 +158,8 @@ cli-testing, cli-docs, plus community itself.
156
158
  in [WC-LAY-7](layout.md#wc-lay-7--treat-300-and-500-lines-as-review-signals).
157
159
  - **Exceptions:** a file that is one cohesive unit may get its own override, listed by path in `biome.json` (tg
158
160
  `src/telegram/adapter.ts`; four files in cli-core). A smaller cap is allowed: zoom uses 500. cli-base, cli-testing,
159
- cli-docs and community have no cap yet.
161
+ cli-docs and community have no cap yet. Biome reads only JavaScript and TypeScript, so the cap does not cover
162
+ code in another language, such as wa's Go engine; the review signals of WC-LAY-7 still apply to it.
160
163
  - **Applies to:** the ten repositories. **Since:** cli-base 0.41.0. **Rulings:** none.
161
164
 
162
165
  ### WC-TOOL-14 · Turn on the import cycle rule
@@ -223,6 +226,18 @@ cli-testing, cli-docs, plus community itself.
223
226
  - **Exceptions:** memo, drive, cli-base and cli-core do not run `rumdl` yet.
224
227
  - **Applies to:** the CLIs and cli-testing. **Since:** cli-base 0.41.0. **Rulings:** none.
225
228
 
229
+ ### WC-TOOL-20 · Build a Go part with the version in `go.mod`, and check it with gofmt, vet and its tests
230
+
231
+ - **Why:** the TypeScript checks do not read Go, so a Go part with no checks of its own drifts without anyone seeing
232
+ it.
233
+ - **Enforced by:** `whatsapp-cli: engine-pr.yml:engine` · `whatsapp-cli: ci.yml:engine`.
234
+ - **Example:** every workflow that builds the Go part uses `actions/setup-go` with `go-version-file` pointing at its
235
+ `go.mod`, never a version written in the workflow. A path-scoped pull request job and full validation both run
236
+ `gofmt -l .` (any file listed fails), `go vet ./...` and `go test ./...` in the Go folder. wa's engine is the
237
+ example.
238
+ - **Exceptions:** none.
239
+ - **Applies to:** CLIs with a Go part (wa). **Since:** cli-base 0.44.0. **Rulings:** none.
240
+
226
241
  ## Sources
227
242
 
228
243
  These documents explain the rules on this page in more detail. Where one of them disagrees with this page, this page
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-base",
3
- "version": "0.43.4",
3
+ "version": "0.44.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",