@bluestep-systems/b6p-cli 0.9.0 → 1.1.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 (104) hide show
  1. package/CHANGELOG.md +134 -0
  2. package/README.md +255 -62
  3. package/dist/cli.js +447 -701
  4. package/package.json +6 -5
  5. package/dist/lib/lib.d.ts +0 -22
  6. package/dist/lib/lib.decorators.d.ts +0 -384
  7. package/dist/lib/lib.decorators.legacy.d.ts +0 -22
  8. package/dist/lib/lib.dom.asynciterable.d.ts +0 -41
  9. package/dist/lib/lib.dom.d.ts +0 -39429
  10. package/dist/lib/lib.dom.iterable.d.ts +0 -571
  11. package/dist/lib/lib.es2015.collection.d.ts +0 -147
  12. package/dist/lib/lib.es2015.core.d.ts +0 -597
  13. package/dist/lib/lib.es2015.d.ts +0 -28
  14. package/dist/lib/lib.es2015.generator.d.ts +0 -77
  15. package/dist/lib/lib.es2015.iterable.d.ts +0 -605
  16. package/dist/lib/lib.es2015.promise.d.ts +0 -81
  17. package/dist/lib/lib.es2015.proxy.d.ts +0 -128
  18. package/dist/lib/lib.es2015.reflect.d.ts +0 -144
  19. package/dist/lib/lib.es2015.symbol.d.ts +0 -46
  20. package/dist/lib/lib.es2015.symbol.wellknown.d.ts +0 -326
  21. package/dist/lib/lib.es2016.array.include.d.ts +0 -116
  22. package/dist/lib/lib.es2016.d.ts +0 -21
  23. package/dist/lib/lib.es2016.full.d.ts +0 -23
  24. package/dist/lib/lib.es2016.intl.d.ts +0 -31
  25. package/dist/lib/lib.es2017.arraybuffer.d.ts +0 -21
  26. package/dist/lib/lib.es2017.d.ts +0 -26
  27. package/dist/lib/lib.es2017.date.d.ts +0 -31
  28. package/dist/lib/lib.es2017.full.d.ts +0 -23
  29. package/dist/lib/lib.es2017.intl.d.ts +0 -44
  30. package/dist/lib/lib.es2017.object.d.ts +0 -49
  31. package/dist/lib/lib.es2017.sharedmemory.d.ts +0 -135
  32. package/dist/lib/lib.es2017.string.d.ts +0 -45
  33. package/dist/lib/lib.es2017.typedarrays.d.ts +0 -53
  34. package/dist/lib/lib.es2018.asyncgenerator.d.ts +0 -77
  35. package/dist/lib/lib.es2018.asynciterable.d.ts +0 -53
  36. package/dist/lib/lib.es2018.d.ts +0 -24
  37. package/dist/lib/lib.es2018.full.d.ts +0 -24
  38. package/dist/lib/lib.es2018.intl.d.ts +0 -83
  39. package/dist/lib/lib.es2018.promise.d.ts +0 -30
  40. package/dist/lib/lib.es2018.regexp.d.ts +0 -37
  41. package/dist/lib/lib.es2019.array.d.ts +0 -79
  42. package/dist/lib/lib.es2019.d.ts +0 -24
  43. package/dist/lib/lib.es2019.full.d.ts +0 -24
  44. package/dist/lib/lib.es2019.intl.d.ts +0 -23
  45. package/dist/lib/lib.es2019.object.d.ts +0 -33
  46. package/dist/lib/lib.es2019.string.d.ts +0 -37
  47. package/dist/lib/lib.es2019.symbol.d.ts +0 -24
  48. package/dist/lib/lib.es2020.bigint.d.ts +0 -765
  49. package/dist/lib/lib.es2020.d.ts +0 -27
  50. package/dist/lib/lib.es2020.date.d.ts +0 -42
  51. package/dist/lib/lib.es2020.full.d.ts +0 -24
  52. package/dist/lib/lib.es2020.intl.d.ts +0 -474
  53. package/dist/lib/lib.es2020.number.d.ts +0 -28
  54. package/dist/lib/lib.es2020.promise.d.ts +0 -47
  55. package/dist/lib/lib.es2020.sharedmemory.d.ts +0 -99
  56. package/dist/lib/lib.es2020.string.d.ts +0 -44
  57. package/dist/lib/lib.es2020.symbol.wellknown.d.ts +0 -41
  58. package/dist/lib/lib.es2021.d.ts +0 -23
  59. package/dist/lib/lib.es2021.full.d.ts +0 -24
  60. package/dist/lib/lib.es2021.intl.d.ts +0 -166
  61. package/dist/lib/lib.es2021.promise.d.ts +0 -48
  62. package/dist/lib/lib.es2021.string.d.ts +0 -33
  63. package/dist/lib/lib.es2021.weakref.d.ts +0 -78
  64. package/dist/lib/lib.es2022.array.d.ts +0 -121
  65. package/dist/lib/lib.es2022.d.ts +0 -25
  66. package/dist/lib/lib.es2022.error.d.ts +0 -75
  67. package/dist/lib/lib.es2022.full.d.ts +0 -24
  68. package/dist/lib/lib.es2022.intl.d.ts +0 -145
  69. package/dist/lib/lib.es2022.object.d.ts +0 -26
  70. package/dist/lib/lib.es2022.regexp.d.ts +0 -39
  71. package/dist/lib/lib.es2022.string.d.ts +0 -25
  72. package/dist/lib/lib.es2023.array.d.ts +0 -924
  73. package/dist/lib/lib.es2023.collection.d.ts +0 -21
  74. package/dist/lib/lib.es2023.d.ts +0 -22
  75. package/dist/lib/lib.es2023.full.d.ts +0 -24
  76. package/dist/lib/lib.es2023.intl.d.ts +0 -56
  77. package/dist/lib/lib.es2024.arraybuffer.d.ts +0 -65
  78. package/dist/lib/lib.es2024.collection.d.ts +0 -29
  79. package/dist/lib/lib.es2024.d.ts +0 -26
  80. package/dist/lib/lib.es2024.full.d.ts +0 -24
  81. package/dist/lib/lib.es2024.object.d.ts +0 -29
  82. package/dist/lib/lib.es2024.promise.d.ts +0 -35
  83. package/dist/lib/lib.es2024.regexp.d.ts +0 -25
  84. package/dist/lib/lib.es2024.sharedmemory.d.ts +0 -68
  85. package/dist/lib/lib.es2024.string.d.ts +0 -29
  86. package/dist/lib/lib.es5.d.ts +0 -4601
  87. package/dist/lib/lib.es6.d.ts +0 -23
  88. package/dist/lib/lib.esnext.array.d.ts +0 -35
  89. package/dist/lib/lib.esnext.collection.d.ts +0 -96
  90. package/dist/lib/lib.esnext.d.ts +0 -29
  91. package/dist/lib/lib.esnext.decorators.d.ts +0 -28
  92. package/dist/lib/lib.esnext.disposable.d.ts +0 -193
  93. package/dist/lib/lib.esnext.error.d.ts +0 -24
  94. package/dist/lib/lib.esnext.float16.d.ts +0 -443
  95. package/dist/lib/lib.esnext.full.d.ts +0 -24
  96. package/dist/lib/lib.esnext.intl.d.ts +0 -21
  97. package/dist/lib/lib.esnext.iterator.d.ts +0 -148
  98. package/dist/lib/lib.esnext.promise.d.ts +0 -34
  99. package/dist/lib/lib.esnext.sharedmemory.d.ts +0 -25
  100. package/dist/lib/lib.scripthost.d.ts +0 -322
  101. package/dist/lib/lib.webworker.asynciterable.d.ts +0 -41
  102. package/dist/lib/lib.webworker.d.ts +0 -13150
  103. package/dist/lib/lib.webworker.importscripts.d.ts +0 -23
  104. package/dist/lib/lib.webworker.iterable.d.ts +0 -340
package/CHANGELOG.md CHANGED
@@ -5,6 +5,140 @@ All notable changes to `@bluestep-systems/b6p-cli` will be documented in this fi
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.1.0] — 2026-11-19
9
+
10
+ ### Added
11
+
12
+ - **`b6p kb create <name>` and `b6p kb set <name>`** register a global knowledge base and change its title, live
13
+ branch or access (`public` or `private`), in one request each. Needs `kb:manage` to write (`kb set` reads with `kb:read`) and b6p-core 1.2.0. Making a knowledge
14
+ base public asks first, naming it and warning that every commit reachable from the live branch, files since
15
+ deleted included, becomes publicly readable (Cancel is the default); `--confirm-public` goes ahead, and the global `--yes` alone never makes it public. ClickUp 1k5g91bqhx6.
16
+
17
+ ## [1.0.0] — 2026-11-17
18
+
19
+ ### Fixed
20
+
21
+ - **A first pull or publish no longer stops at "HTTP 403"** (b6p-core 1.0.0 with bsjs-git 0.3.1, ClickUp 1k5g91bq9ef).
22
+ The first platform request of a run sent a CSRF token that the sign-in had just dropped, and nothing retried it,
23
+ so 0.9.0 could not pull or publish against 26.11.09.00. That request is now retried once with a fresh token.
24
+
25
+ ### Changed (breaking)
26
+
27
+ - **The platform builds every push; the CLI bundles no compiler** (b6p-core 1.0.0,
28
+ [ADR 0003](docs/adr/0003-server-side-compile.md)). `b6p script push` commits and pushes the draft over git, the
29
+ platform builds that commit, and the draft folder is moved to its build commit; `--snapshot` publishes the build.
30
+ Against a server that predates the git build a plain push is the git push alone (exit `0`), and `--snapshot`
31
+ pushes the draft, takes no snapshot, prints `cannot snapshot, only push saves` and exits `1`.
32
+ - **New exit-`1` cases** (push and each deploy target): the server cannot take the snapshot; the build was not asked
33
+ for (the platform's draft moved), was refused (`BUILD_REFUSED`: the draft moved, is over the build's size limit, or
34
+ its repository or draft branch is missing), its request failed, its outcome is unknown, or it ended in a status
35
+ that does not publish (busy, gate tripped, output withheld, ...); local files block taking in the build commit.
36
+ Each prints a "To go on:" line naming the command to run. An unclean build on a plain push still exits `0` with a warning: a
37
+ snapshot of it is refused until it builds cleanly.
38
+ - **`--json`**: core 1.0's push result (new `route`, `snapshotRefused`, `build`, `buildCommitSha`, `buildVouched`,
39
+ `buildError`, `buildErrorKind`, `buildErrorReason`, `buildIncomplete`, `buildFastForward`) plus `declinedOverwrites` and a new
40
+ `error` (`null`, or `{ kind, message, howTo }`, the same verdict as the exit code). `typeCheckDiagnostics` is now
41
+ the platform's whole ERROR + WARNING count; `typeCheckErrors` lists the ones in the script's own sources, with
42
+ `severity`.
43
+ - **`--fail-on-type-errors` / `failOnTypeErrors`** fail on any diagnostic the platform's build reports in the
44
+ script's own sources (`typeCheckErrors`).
45
+ - **`--externally-built` is removed** (an unknown option): the platform reads each script's own `externallyBuilt`
46
+ flag. A deploy config's `externallyBuilt` key, like any other unknown key at the top level or in a target, is
47
+ refused by name before anything is pushed.
48
+ - **The standalone binaries are a normal release** again: `release.yml` no longer marks any line pre-release.
49
+ - **Node.js 24 or newer is required** (`engines.node` is `>=24`); Node 18 to 22 are no longer supported.
50
+ CI tests Node 24 and 26, the publish and release builds run on Node 24, and `@types/node` is `^24`.
51
+ The standalone binaries bundle their own Node and are unaffected. `engines` is only advisory to npm,
52
+ so `b6p` also checks the Node major at startup and exits `1` with a clear message below 24.
53
+ - **Failing commands now exit `1`** where they used to exit `0` (for example `b6p script deploy
54
+ missing.json`). A pipeline that relied on `b6p` never failing will go red. See Fixed below.
55
+
56
+ ### Added
57
+
58
+ - `b6p kb list` shows a STATUS column and, after the table, one note per non-ok status present; `--json` carries `id`,
59
+ `status` and `rawStatus`. `b6p kb pull` of a `row-only` knowledge base says it has no repository yet.
60
+ - `b6p auth token rotate`: when the rotation's outcome is unknown, the message now says b6p already sent the request a
61
+ second time (core retries an unanswered rotation once with the same idempotency key).
62
+ - **Gateway: `409 live-branch-unprotected`** on `b6p kb push` says nothing was pushed, that the knowledge base's live branch is not protected on the forge, and to ask a Bluestep administrator to restore the protection before pushing again; under `--json` the failure document carries `code`.
63
+ - **Gateway contract delta (2026-11-10)**: `auth token create` without `--expires` mints for the sooner of 90 days and the stored token's own expiry and prints a note with the date when it cut it; a `--expires` (or `never`) past the stored token's expiry is explained, and so are the 400 (`invalid-request`), 409 `token-limit` (revoke an unused token) and 503 `registry-unavailable` answers. a 403 `restricted-mints-disabled` says token creation for that scope set is not enabled yet (only `mcp`-scoped tokens can be minted for now). `auth token list` shows expired tokens, `CREATED` (`unknown` when the gateway has no creation time) and an approximate `LAST USED`. A 403 `rewrite-not-permitted` (a `kb:rewrite` mint or rotate the account may not hold) says to ask an administrator or create the token without that scope, and under `--json` the failure document carries `reason` and `scope`.
64
+ - **`b6p kb list|pull|push`** - browse, clone and push the knowledge bases (global and tenant) the stored
65
+ `b6pt_` token may reach, through the BlueStep gateway. Pulls fast-forward an existing clone and never
66
+ overwrite local changes; pushes are fast-forward only, to the live branch.
67
+ - **`b6p marketplace list|pull`** - list marketplace repositories and clone one (optionally at a tag or
68
+ branch with `--ref`) into a folder.
69
+ - **`b6p auth token list|create|revoke|rotate`** - manage your own gateway tokens. `create` and `rotate`
70
+ print the secret once on stdout; `--expires` takes `90d` (default), another day count, an ISO date or
71
+ `never` (asks first). Needs the `tokens:self` scope.
72
+ - A token the gateway minted but answered malformedly (`off-contract`) still has its secret printed once, with what to do next.
73
+ - `auth token create --expires` takes a day count, a date (start of that day, UTC) or a full ISO date-time
74
+ with `Z` or an offset; anything else is refused before a request is sent. `marketplace pull --ref` also
75
+ accepts full ref names (`refs/tags/v1.0.0`).
76
+ - `auth token revoke` of the token b6p itself is using asks first (Cancel by default; `--yes` alone declines).
77
+ Under `--json` every secret-bearing body carries the secret in a top-level `secret` field. `kb push` works
78
+ from a subfolder of a clone. The spinner is cleared before any stdout write.
79
+ - Gateway errors come with the fix: the scope to mint, `b6p auth set`, the dirty paths, "pull first",
80
+ "choose another folder", "switch to the live branch".
81
+
82
+ - **`b6p script <verb>`** - script-tree operations now live under a `script` namespace:
83
+ `b6p script push`, `pull`, `audit`, `deploy`, `setup`. The top level of `b6p` is becoming a namespace of
84
+ platform subsystems (nouns), so later commands such as `b6p kb ...` can be added without colliding with
85
+ a verb. It mirrors `B6PCore`, where each subsystem hangs off the composition root as its own service.
86
+ The 0.9.0 flags (`--author`, `--enable-git`, `--fail-on-type-errors`) and the 0.9.0
87
+ `--json` fields live on `b6p script push` / `pull` / `deploy`, and so on their deprecated aliases too.
88
+ - **`b6p auth status`** - reports whether an access token is stored (`{"authenticated": bool}` under
89
+ `--json`). It never prompts, so unattended scripts can check for credentials without risking a hang.
90
+ - **Machine-readable failures.** Under `--json`, a failed command writes `{"error": "...", "errors": [...]}`
91
+ to stdout instead of leaving stdout empty. This covers errors that are thrown (such as no input
92
+ available for a prompt) as well as failures core reports, and never writes two documents.
93
+ - `130` is the exit code when a prompt is interrupted with Ctrl-C.
94
+
95
+ ### Removed
96
+
97
+ - `copy-ts-libs`, the SEA `ts-libs` asset, `typescriptLibDirs` and the TypeScript lib invariant test:
98
+ nothing compiles in the CLI any more.
99
+ - `--externally-built` (see above).
100
+
101
+ ### Build
102
+
103
+ - `typescript` is an exact `7.0.2` devDependency, for `check-types` only; `test/noCompiler.test.ts` checks that
104
+ `dist/cli.js` contains no compiler.
105
+
106
+ ### Changed
107
+
108
+ - The old top-level `push`, `pull`, `audit`, `deploy` and `setup` still work as hidden aliases. They are
109
+ registered from the same definition as the `script` commands, so their flags and behaviour cannot
110
+ drift; they print a deprecation warning to stderr, carry the notice in their own `--help` text, and
111
+ will be removed in a future release (no date yet).
112
+
113
+ ```diff
114
+ - b6p push --file ./src/app.ts --snapshot
115
+ + b6p script push --file ./src/app.ts --snapshot
116
+ ```
117
+
118
+ - `b6p auth set` is scriptable: `echo "$B6P_TOKEN" | b6p auth set`. A fresh install used to prompt twice
119
+ and fail on the second prompt at end of input.
120
+ - Reorganised `src/` around the command tree: `src/commands/` holds one module per noun, `src/context.ts`
121
+ the SDK construction and the `withCore` wrapper every action runs inside, `src/program.ts` the root
122
+ command. `src/index.ts` is only version injection and `parseAsync`.
123
+
124
+ ### Fixed
125
+
126
+ - **Failing commands exit non-zero.** Core reports most failures through `Prompt.error` and returns
127
+ normally, so commands such as `b6p script deploy missing.json` printed an error and exited `0`.
128
+ `CliPrompt` now counts what crosses its error channel and sets `process.exitCode`. `Logger.error` is
129
+ deliberately not counted (core logs recoverable conditions there). Reporting a value is still success:
130
+ `b6p auth status` with no token stored exits `0`.
131
+ - **`b6p script audit` outside a script tree fails** instead of printing `null` at exit `0`.
132
+ - **`b6p check-updates` works.** The CLI never passed `updateServiceConfig` to core, so the command could
133
+ only report "Update service is not configured". It now checks this repository's own releases.
134
+ - The CLI now calls `B6PCore.dispose()`, so core's session-cleanup timer no longer outlives the command.
135
+ - Fatal errors set `process.exitCode` instead of calling `process.exit()`, which could truncate a `--json`
136
+ write. A closed stdout pipe (`b6p --json report | head -1`) is a clean exit rather than an `EPIPE`, and keeps
137
+ a failure exit code the command had already set.
138
+ - The standalone-binary build smoke test looks for `script` in `--help` rather than `push`.
139
+ - CI: `npm ci` retry loops now fail the step when all three attempts fail (they used to fall through to a misleading type error), and the Intel macOS binary builds on `macos-15-intel` (the retired `macos-13` runner never ran).
140
+ - The test build shares the real build's `external` list (`NODE_EXTERNALS` in `esbuild.js`).
141
+
8
142
  ## [0.9.0] — 2026-11-16
9
143
 
10
144
  Depends on b6p-core 0.9.0, which moves scripts to git: a script's draft and snapshot are a git repository,
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # @bluestep-systems/b6p-cli
2
2
 
3
- Command-line interface for managing [BlueStep](https://www.bluestep.net/) B6P
4
- scripts: pull components from the platform, push changes back, audit local vs.
5
- server, git history, and deploy across targets.
3
+ Headless command-line interface for the [BlueStep](https://www.bluestep.net/) platform.
4
+
5
+ Script management is the subsystem it covers today — pull components from the platform,
6
+ push changes back, audit local vs. server, git history, and deploy across targets —
7
+ under `b6p script`. Further subsystems will appear alongside it as top-level names.
6
8
 
7
9
  The CLI shares its core implementation
8
10
  ([`@bluestep-systems/b6p-core`](https://github.com/Bluestep-Systems/b6p-core)) with the
@@ -12,7 +14,7 @@ terminals, CI pipelines, and scripts.
12
14
  ## Installation
13
15
 
14
16
  This package is published to the public [npm registry](https://www.npmjs.com/), so no authentication is
15
- required to install it.
17
+ required to install it. Requires **Node.js 24 or newer** (the standalone binaries below bundle their own).
16
18
 
17
19
  1. Install globally:
18
20
 
@@ -77,21 +79,111 @@ means the token expired or its account lost access, not that it is the wrong kin
77
79
 
78
80
  ## Commands
79
81
 
82
+ `b6p` is organised as `b6p <subsystem> <verb>`. Each top-level name is a part of the
83
+ platform; the verbs beneath it act on that part.
84
+
85
+ ### `b6p script` — script trees
86
+
87
+ | Command | Purpose |
88
+ |---|---|
89
+ | `b6p script pull <webdav-url>` | Pull a script by URL (clones its git draft) |
90
+ | `b6p script pull <webdav-url> --enable-git` | Same, and switch a script still on WebDAV to git without asking (one-way) |
91
+ | `b6p script pull --file <path>` | Pull using metadata stored with a local file |
92
+ | `b6p script push --file <path>` | Push local files to the platform |
93
+ | `b6p script push --file <path> --snapshot --message "…"` | Commit the draft with a message and publish it |
94
+ | `b6p script push --file <path> --author "Jane Doe <jane@example.com>"` | Push as a given commit author |
95
+ | `b6p script push --file <path> --overwrite <file>` | Push, overwriting a file that changed on the platform |
96
+ | `b6p script audit --file <path>` | Diff local vs. server |
97
+ | `b6p script audit --file <path> --pull` | Audit and pull if differences found |
98
+ | `b6p script deploy <config.json>` | Multi-target deploy from a config file |
99
+ | `b6p script setup --file <path>` | Print the web-UI setup URL for a script |
100
+
101
+ > **Moved.** These were previously top-level (`b6p push`, `b6p pull`, …). The old
102
+ > spellings still work but are deprecated, warn on use, and **will be removed in a future release** —
103
+ > the top level is being kept free for other platform subsystems.
104
+
105
+ ### `b6p auth` — credentials
106
+
107
+ | Command | Purpose |
108
+ |---|---|
109
+ | `b6p auth set` | Set or update the access token |
110
+ | `b6p auth status` | Report whether a token is stored (never prompts) |
111
+ | `b6p auth clear` | Clear the stored token |
112
+ | `b6p auth token list` | List your own tokens, expired ones included, marked `(expired)` (the secret is never shown) |
113
+ | `b6p auth token create --alias <a> --scopes <s,…> [--expires <90d\|date\|date-time\|never>]` | Mint a token; the secret is printed once |
114
+ | `b6p auth token revoke --tokenid <alias\|id>` | Revoke one of your tokens |
115
+ | `b6p auth token rotate --tokenid <alias\|id>` | Replace a token (same alias, scopes and end date); the old one dies at once |
116
+
117
+ `auth token` manages only your **own** tokens and needs the `tokens:self` scope. `create` and `rotate`
118
+ print the new secret **once**, alone on stdout (so `TOKEN=$(b6p auth token create …)` captures it), with
119
+ the details and a "store it now" note on stderr. Under `--json` the secret is the top-level `secret`
120
+ field of the body, on success (`create`, `rotate`) and on the failure bodies that still carry one (a token
121
+ that could not be stored, a malformed gateway answer), which also have `error`, `errors`, `operation`
122
+ and `stored`. A new token's
123
+ scopes can never exceed the token b6p is using. The default lifetime is 90 days, or until the token b6p is using expires if that comes first (the command says so and gives the date); `--expires 30d`, a date
124
+ (`2027-03-01`, the start of that day UTC) or a full date-time with `Z` or an offset
125
+ (`2027-03-01T12:00Z`, `2027-03-01T12:00:00+02:00`) picks another. `--expires never` warns and asks first (the safe answer, Cancel, is the
126
+ default); under `--yes` it goes ahead only because you typed `never` yourself. Rotating the token b6p is
127
+ using runs at once and stores the new secret for b6p. Revoking it asks first (Cancel is the default, so
128
+ `--yes` alone declines, and `--json` with no input fails) because it leaves b6p holding a dead token until
129
+ you run `b6p auth set`; revoking any other token runs at once.
130
+
131
+ A new token can never outlive the token that creates it: an explicit `--expires` (or `never`) past that date is refused (`403`), and the error says when the stored token expires. Until the gateway's rollout switch is flipped, only tokens with just the `mcp` scope can be minted (`not enabled yet`). You may hold at most 50 live tokens; past that, revoke one you no longer use. `list` shows a token whose creation time the gateway never recorded as `unknown`, and `LAST USED` is approximate (the gateway stamps it at most every 12 hours).
132
+
133
+ ### `b6p kb` — knowledge bases
134
+
135
+ | Command | Purpose |
136
+ |---|---|
137
+ | `b6p kb list [--scope global\|tenant] [--tenant U…]` | List the knowledge bases you may read, whether you may push, and each one's STATUS (`ok`, `branch-mismatch`, `repo-only`, `row-only`, `unconfirmed`, `undescribed`; a note under the table explains each one present) |
138
+ | `b6p kb pull <ref> [dir]` | Clone a knowledge base into a folder (default `./<name>`, or `./<tenant>-<name>` for a tenant's), or fast-forward an existing clone |
139
+ | `b6p kb push [dir]` | Push a clone (default: the current folder, or the clone that contains it) to the knowledge base's live branch |
140
+ | `b6p kb create <name> [--title <t>] [--live-branch <b>] [--access public\|private] [--confirm-public]` | Register a global knowledge base (and its repository). Defaults: title = name, branch `main`, private |
141
+ | `b6p kb set <name> [--title <t>] [--live-branch <b>] [--access public\|private] [--confirm-public]` | Change a global knowledge base's title, live branch or access, in one request; at least one option is required |
142
+
143
+ `<ref>` is `<name>` for a global knowledge base or `U<number>/<name>` for a tenant's; names and the tenant match in any letter case, and the local folder uses the canonical name. Pulls never
144
+ overwrite local changes (the dirty paths are listed) and pushes are fast-forward only: if the knowledge
145
+ base moved on, pull first. Pushing needs push rights on that knowledge base as well as the `kb:push` scope.
146
+
147
+ `kb create` and `kb set` are for super users and need the `kb:manage` scope to write (`kb set` reads the knowledge base first, which needs `kb:read`, to find
148
+ the knowledge base). `--access public` lets anyone on the internet read the knowledge base with no sign-in, and that covers every commit reachable from the live branch, files since deleted included, so b6p asks
149
+ first, naming the knowledge base (Cancel is the default). `--confirm-public` goes ahead without asking, and says so; the global `--yes`
150
+ alone never makes a knowledge base public (it refuses). A knowledge base that
151
+ is already public is left alone. `--json` prints `{ knowledgeBase, changed }` (`kb set`) or `{ knowledgeBase }`
152
+ (`kb create`). Only global knowledge bases can be created or changed; a tenant's cannot.
153
+
154
+ ### `b6p marketplace` — marketplace repositories
155
+
80
156
  | Command | Purpose |
81
157
  |---|---|
82
- | `b6p pull <webdav-url>` | Pull a script by URL (clones its git draft) |
83
- | `b6p pull <webdav-url> --enable-git` | Same, and switch a script still on WebDAV to git without asking (one-way) |
84
- | `b6p pull --file <path>` | Pull using metadata stored with a local file |
85
- | `b6p push --file <path>` | Push local files to the platform |
86
- | `b6p push --file <path> --snapshot --message "…"` | Commit the draft with a message and publish it |
87
- | `b6p push --file <path> --author "Jane Doe <jane@example.com>"` | Push as a given commit author |
88
- | `b6p push --file <path> --overwrite <file>` | Push, overwriting a file that changed on the platform |
89
- | `b6p audit --file <path>` | Diff local vs. server |
90
- | `b6p audit --file <path> --pull` | Audit and pull if differences found |
91
- | `b6p deploy <config.json>` | Multi-target deploy from a config file |
92
- | `b6p setup --file <path>` | Print the web-UI setup URL for a script |
158
+ | `b6p marketplace list` | List repositories with their default branch and tags |
159
+ | `b6p marketplace pull <name> [dir] [--ref <tag\|branch>]` | Clone a repository into a folder (default `./<name>`), or fast-forward an existing clone |
160
+
161
+ A plain working clone, unrelated to any script. There is no push.
162
+
163
+ ### Gateway token scopes
164
+
165
+ `kb` and `marketplace` talk to the BlueStep gateway (`gatewayUrl`, default `https://gateway.bluestep.net`;
166
+ change it with `b6p config set gatewayUrl <url>`) using the same stored `b6pt_` token. Mint a token with
167
+ the scopes you need:
168
+
169
+ | Scope | For |
170
+ |---|---|
171
+ | `kb:read` | `kb list`, `kb pull` |
172
+ | `kb:push` | `kb push` |
173
+ | `kb:manage` | `kb create`, and the change in `kb set` (super users) |
174
+ | `registry:read` | `marketplace list`, `marketplace pull` |
175
+ | `tokens:self` | `auth token …` |
176
+ | `kb:rewrite` | rewriting a knowledge base's history (not a `b6p` command); mintable and rotatable here only if the token b6p uses holds it |
177
+
178
+ ### Everything else
179
+
180
+ | Command | Purpose |
181
+ |---|---|
182
+ | `b6p sessions clear` | Clear all active sessions |
183
+ | `b6p config set <key> <value>` | Set a configuration value |
184
+ | `b6p config reset` | Reset all settings to defaults |
93
185
  | `b6p report` | Report cached state |
94
- | `b6p auth set` | Store or replace your platform access token (`b6pt_…`, see [Signing in](#signing-in)) |
186
+ | `b6p check-updates` | Check for CLI updates |
95
187
 
96
188
  Most commands accept `--json` for machine-readable output and `--yes` to answer every question with
97
189
  its default (and print what it answered). Run `b6p <command> --help` for full options.
@@ -109,16 +201,16 @@ take, so `--yes` never overwrites or deletes anything on the platform:
109
201
  No keeps them (exit `0`).
110
202
 
111
203
  When question 1 is declined, the CLI prints the command that confirms it. After checking the
112
- platform versions (`b6p audit`), confirm specific files up front with `--overwrite`, once per file,
204
+ platform versions (`b6p script audit`), confirm specific files up front with `--overwrite`, once per file,
113
205
  using the path the question listed:
114
206
 
115
207
  ```bash
116
- b6p --yes push --file <path> --snapshot --overwrite scripts/app.ts --overwrite README.md
208
+ b6p --yes script push --file <path> --snapshot --overwrite scripts/app.ts --overwrite README.md
117
209
  ```
118
210
 
119
211
  Question 2 has no flag: run without `--yes` and answer `Yes`. Answers can be piped, one line per
120
- question, in order (`printf 'Overwrite all\nYes\n' | b6p push --file <path>`, or `< answers.txt`;
121
- in PowerShell, `'Overwrite all', 'Yes' | b6p push --file <path>`). The commands the CLI prints are
212
+ question, in order (`printf 'Overwrite all\nYes\n' | b6p script push --file <path>`, or `< answers.txt`;
213
+ in PowerShell, `'Overwrite all', 'Yes' | b6p script push --file <path>`). The commands the CLI prints are
122
214
  written for your shell: POSIX, or PowerShell on Windows outside Git Bash.
123
215
 
124
216
  ### Git, authors and switching
@@ -127,7 +219,7 @@ A script's draft and its published snapshot are a git repository on the platform
127
219
  `draft/` folder to it, and `--snapshot` (or `--message`, which implies it) also publishes that
128
220
  commit. Its history is its git history. Requires a platform with git publishing for scripts (today's
129
221
  server: its `enableGitPublishing` switch); a script still on WebDAV is switched
130
- to git by its first push or by `b6p pull --enable-git`. **The switch is one-way**: afterwards the
222
+ to git by its first push or by `b6p script pull --enable-git`. **The switch is one-way**: afterwards the
131
223
  script's draft and snapshot refuse WebDAV writes. The CLI says so when it happens
132
224
  (`switchedToGit`).
133
225
 
@@ -137,7 +229,7 @@ for `deploy`, the config file's `author`; the stored default (`b6p config set au
137
229
  `GIT_AUTHOR_EMAIL` (or the `GIT_COMMITTER_*` pair) in the environment. With none of them the push
138
230
  stops with exit `1` and prints those fixes; nothing is ever committed as nobody.
139
231
 
140
- `b6p pull` and `b6p push` without `--enable-git` ask before switching a WebDAV script (`[Cancel]` first),
232
+ `b6p script pull` and `b6p script push` without `--enable-git` ask before switching a WebDAV script (`[Cancel]` first),
141
233
  and `--yes` declines, so an unattended run never switches anything and exits `1` (push) with nothing changed.
142
234
  `--enable-git` works with a URL or with `--file`/the current folder.
143
235
 
@@ -145,67 +237,99 @@ Refusals that change nothing and exit `1`: a declined switch, a draft folder wit
145
237
  `draft` checked out (push), staged-only changes that a pull would discard, and symbolic links that
146
238
  would let a pull write outside the draft folder. Each message says how to fix it.
147
239
 
240
+ ### What the platform does with a push
241
+
242
+ A push commits the draft and pushes it over git; then the **platform** builds that commit (b6p bundles no
243
+ compiler) and commits its output, plus a build manifest when the build is clean, as one build commit. The
244
+ draft folder is moved to that build commit, and `--snapshot` publishes it. `b6p` asks the server for its
245
+ version first (`--verbose` prints the route; `--json` carries it as `route`):
246
+
247
+ | Server | `b6p script push` | `b6p script push --snapshot` |
248
+ |---|---|---|
249
+ | Builds git drafts (at or above core's minimum, or a `dev` build) | pushed, then built | pushed, built, and the build published |
250
+ | Older, unreadable version, or no minimum known | pushed; nothing built (exit `0`) | pushed, **no snapshot**: prints `cannot snapshot, only push saves` and exits `1` |
251
+
252
+ The platform's diagnostics are printed on stderr. An unclean build (an `ERROR` diagnostic: syntax, emit
253
+ or configuration) commits its output without a manifest: the push still exits `0` with a warning, and a
254
+ snapshot of that draft is refused until it builds cleanly. There is no `b6p script check` (a dry-run
255
+ build is waiting on a platform endpoint).
256
+
148
257
  ### Exit codes
149
258
 
150
259
  | Result | Exit |
151
260
  |---|---|
152
- | Pushed; kept platform-only files, a switch to git, or a read-back that could not run (`liveVerified: null`) are still fine | `0` |
261
+ | Pushed and built; kept platform-only files, a switch to git, a plain push to an older server, an unclean plain push, or a read-back that could not run (`liveVerified: null`) are still fine | `0` |
153
262
  | The user cancelled at the target-URL prompt | `0` |
154
263
  | Nothing was pushed (`pushed: false`): bad `--root`, empty draft, an overwrite not confirmed, no commit author, an upload refused | `1` |
155
- | Snapshot, and `publishedSha` is `null` (nothing was published) | `1` |
156
- | Snapshot, and `publishError` is set (the platform refused or failed the publish; the draft is still pushed) | `1` |
157
- | Snapshot, and `liveVerified` is `false` (the published branch reads back at another commit) | `1` |
158
- | `--fail-on-type-errors` (or `failOnTypeErrors: true` in a deploy config), and the build reported type errors in the script's own sources (`typeCheckDiagnostics > 0`) | `1` |
159
-
160
- A plain push (no `--snapshot`) is judged by `pushed` alone. Type errors are **warnings by default**: they
161
- are printed, counted in `--json` (`typeCheckDiagnostics`) and the exit code stays `0`, because the platform
162
- runs the emitted JavaScript and valid JS often comes from imperfect TypeScript. Errors located in a `.d.ts`
163
- (the generated platform declarations) never count. Syntax and emit errors always stop the push with exit
164
- `1`. Add `--fail-on-type-errors` to push, snapshot or deploy to make type errors fail instead.
264
+ | Snapshot, and the server cannot take one (`snapshotRefused`) | `1` |
265
+ | The build was not asked for (`buildErrorKind: "not-requested"`: the platform's draft moved), was refused (`"refused"`, with `buildErrorReason`) or its request failed (`buildError`) | `1` |
266
+ | The build ended in a status that does not publish, or its outcome is unknown (`buildIncomplete`) | `1` |
267
+ | Local files block moving the draft folder to the build commit, or the move failed (`buildFastForward.state` `blocked` / `failed`) | `1` |
268
+ | Snapshot, and the publish was refused or failed (`publishError`), published nothing (`publishedSha: null`), or reads back at another commit (`liveVerified: false`) | `1` |
269
+ | `--fail-on-type-errors` (or `failOnTypeErrors: true` in a deploy config), and the build reported diagnostics in the script's own sources (`typeCheckErrors` not empty) | `1` |
270
+
271
+ Every failure prints a `To go on:` line saying what to run: for example `b6p script pull`, then push again,
272
+ after the platform's draft moved or when the build's outcome is unknown; push again after a busy or
273
+ incomplete build; move or delete the listed files when they block the build commit; update b6p for a build
274
+ status it does not know. Diagnostics are **warnings by default** (the platform runs the emitted JavaScript);
275
+ those in a `.d.ts` never count. Add `--fail-on-type-errors` to push, snapshot or deploy to make them fail.
165
276
 
166
277
  ### `--json`
167
278
 
168
- `--json` prints one object on stdout, the same shape for every outcome (agents parse it):
279
+ `--json` prints one object on stdout, the same shape for every outcome (agents parse it): core's push result
280
+ plus `declinedOverwrites` and `error`.
169
281
 
170
282
  ```json
171
283
  {
172
284
  "pushed": true,
173
- "commitSha": "3f2a…40 hex characters",
174
- "publishedSha": "9c1b…40 hex characters",
285
+ "commitSha": "3f2a…",
286
+ "publishedSha": "9c1b…",
175
287
  "publishError": null,
176
288
  "publishRefusal": null,
177
289
  "switchedToGit": false,
290
+ "route": { "mode": "server-build", "reason": "at-or-above-floor", "serverVersion": "…", "required": "…" },
291
+ "snapshotRefused": null,
292
+ "build": { "status": "COMPILED", "rawStatus": "COMPILED", "errors": 0, "warnings": 0, "…": "…" },
293
+ "buildCommitSha": "7d4e…",
294
+ "buildVouched": true,
295
+ "buildError": null,
296
+ "buildErrorKind": null,
297
+ "buildErrorReason": null,
298
+ "buildIncomplete": null,
299
+ "buildFastForward": { "state": "fast-forwarded", "blockedPaths": [], "error": null },
178
300
  "typeCheckDiagnostics": 0,
179
301
  "typeCheckErrors": [],
180
302
  "liveVerified": true,
181
303
  "liveMismatches": [],
182
304
  "keptPlatformOnly": [],
183
- "declinedOverwrites": []
305
+ "declinedOverwrites": [],
306
+ "error": null
184
307
  }
185
308
  ```
186
309
 
187
- - `commitSha`: the draft branch's head after the push (the commit this push made, or the one already
188
- there); `null` when `pushed` is false.
189
- - `publishedSha`: the commit the platform published; `null` on a plain push, an aborted push or a
190
- failed publish.
191
- - `publishError`: why the publish failed, else `null`.
192
- - `publishRefusal`: `{ "reason", "withheld" }`, straight from the platform, when it refused the publish. For
193
- a build that is missing, unreadable or older than its sources (`BUILD_MANIFEST_MISSING`,
194
- `BUILD_MANIFEST_INVALID`, `BUILD_STALE`) `withheld` lists the stale files or the manifest's path: rebuild
195
- and push. The draft is pushed, the published script unchanged, and the exit code is `1`. Else `null`.
196
- - `typeCheckDiagnostics` / `typeCheckErrors`: the count and the list (`{ file, line, column, code, message }`) of
197
- type errors in the script's own sources; `.d.ts` diagnostics are never included. Warnings unless
198
- `--fail-on-type-errors`.
199
- - `switchedToGit`: this push moved the script from WebDAV to git.
200
- - `historyRecorded` is gone (0.9.0): history is the git history, so `commitSha` and `publishedSha`
201
- replace it.
202
- - A declined overwrite prints `pushed: false` with the files in `declinedOverwrites`; a missing
203
- author prints `pushed: false` too (the reason is on stderr); a cancelled target-URL prompt prints
204
- `{ "cancelled": true }`. Questions, warnings and next steps go to stderr.
310
+ - `commitSha`: the draft commit this push made (or the one already there); `buildCommitSha`: the platform's
311
+ build commit after it, `null` when it made none. `publishedSha`: the commit published (snapshot only).
312
+ - `route` / `snapshotRefused`: which route the push took, and why a snapshot was refused (`too-old`,
313
+ `unknown`, `floor-unset`, with the versions).
314
+ - `build`, `buildVouched`, `buildError` / `buildErrorKind` / `buildErrorReason` (`DRAFT_MOVED`, `DRAFT_TOO_LARGE`,
315
+ `REPO_MISSING`, `DRAFT_BRANCH_MISSING` when the platform refused the build), `buildIncomplete` (`{ status, rawStatus, description }`)
316
+ and `buildFastForward` (`{ state, blockedPaths, error }`): what the platform's build came to.
317
+ - `publishRefusal`: `{ "reason", "withheld" }`, straight from the platform, when it refused the publish
318
+ (`BUILD_STALE`, `BUILD_MANIFEST_MISSING`, `BUILD_MANIFEST_INVALID`, `DRAFT_MOVED`, ...).
319
+ - `typeCheckDiagnostics`: the platform's whole `ERROR` + `WARNING` count. `typeCheckErrors`: those in the
320
+ script's own sources (`{ file, line, column, code, message, severity }`, at most 20); `.d.ts` diagnostics are
321
+ never included.
322
+ - `error`: `null` when the push succeeded, else `{ "kind", "message", "howTo" }`, the same verdict as the exit
323
+ code. `kind` is one of `NOTHING_PUSHED`, `SNAPSHOT_REFUSED`, `BUILD_NOT_REQUESTED`, `BUILD_REFUSED`, `BUILD_REQUEST_FAILED`,
324
+ `BUILD_OUTCOME_UNKNOWN`, `BUILD_INCOMPLETE`, `BUILD_BLOCKED`, `BUILD_TAKE_IN_FAILED`, `PUBLISH_REFUSED`,
325
+ `PUBLISH_FAILED`, `NOT_PUBLISHED`, `LIVE_MISMATCH`, `TYPE_ERRORS`, `OVERWRITE_DECLINED`, `NO_AUTHOR`,
326
+ `AUTHOR_INVALID`, `GIT_REFUSED`.
327
+ - A declined overwrite prints `pushed: false` with the files in `declinedOverwrites`; a cancelled target-URL
328
+ prompt prints `{ "cancelled": true }`. Questions, warnings and next steps go to stderr.
205
329
 
206
330
  ### Deploy
207
331
 
208
- `b6p deploy <config.json>` pushes the source draft to each target:
332
+ `b6p script deploy <config.json>` pushes the source draft to each target, and each target's platform builds it:
209
333
 
210
334
  ```json
211
335
  {
@@ -213,15 +337,83 @@ runs the emitted JavaScript and valid JS often comes from imperfect TypeScript.
213
337
  "targets": [{ "url": "https://…/files/123/draft/", "snapshot": true }],
214
338
  "author": { "name": "Jane Doe", "email": "jane@example.com" },
215
339
  "message": "Deploy from CI",
216
- "externallyBuilt": false,
340
+ "enableGit": false,
217
341
  "failOnTypeErrors": false
218
342
  }
219
343
  ```
220
344
 
221
- `externallyBuilt: true` is for scripts a bundler outside b6p builds (no build manifest is written and the
222
- platform skips its stale-build check); `b6p push --externally-built` is the same for a push. `author` (an object, or `"Jane Doe <jane@example.com>"`) and `message` are optional and apply to every
223
- target; `b6p deploy --author "…"` overrides the file's author. `deploy` exits `1` if no author resolves
224
- (nothing is pushed then) or if any target failed or its publish was refused.
345
+ Those are the only keys (and `url` / `snapshot` in a target): any other key is refused by name before anything is
346
+ pushed. `externallyBuilt` was removed in 1.0.0, since the platform reads each script's own flag. `author` (an object,
347
+ or `"Jane Doe <jane@example.com>"`) and `message` are optional and apply to every target; `b6p script deploy
348
+ --author "…"` overrides the file's author. `deploy` exits `1` if no author resolves (nothing is pushed then) or if
349
+ any target fails by the push rules above.
350
+
351
+ ## Exit codes
352
+
353
+ | Code | Meaning |
354
+ |---|---|
355
+ | `0` | The command completed without reporting an error |
356
+ | `1` | The command failed, or its arguments were rejected |
357
+ | `130` | A prompt was interrupted with Ctrl-C |
358
+
359
+ `--quiet` and `--json` change what is printed, never the exit code, so it is safe to gate a
360
+ pipeline on:
361
+
362
+ ```bash
363
+ set -e
364
+ b6p script push --file ./src/app.ts --snapshot --message "release $VERSION"
365
+ ```
366
+
367
+ Under `--json`, a failure also writes a machine-readable payload to stdout:
368
+
369
+ ```console
370
+ $ b6p --json script deploy missing.json
371
+ {
372
+ "error": "Config file not found: missing.json",
373
+ "errors": ["Config file not found: missing.json"]
374
+ }
375
+ ```
376
+
377
+ Note that a command reporting a *value* has still succeeded — `b6p auth status` exits `0` whether
378
+ or not a token is stored. Branch on its output, not its exit code:
379
+
380
+ ```bash
381
+ b6p --json auth status | jq -e .authenticated >/dev/null
382
+ ```
383
+
384
+ > **Changed after 0.9.0.** Failing commands previously exited `0`. If a pipeline was relying on
385
+ > `b6p` never failing, it will now correctly go red.
386
+
387
+ ## Unattended use
388
+
389
+ Every command is usable from a script, but two flags matter:
390
+
391
+ - `--yes` skips confirmation prompts. If a command needs a value it cannot guess, it now **fails
392
+ immediately** rather than blocking on a prompt no one will answer.
393
+ - `--json` writes machine-readable output to stdout and keeps all human text on stderr.
394
+
395
+ A closed stdin is also an error rather than a hang, so `b6p … < /dev/null` in CI fails fast
396
+ instead of stalling until the job times out.
397
+
398
+ ## Authentication
399
+
400
+ The token from [Signing in](#signing-in) is stored in encrypted secret storage under `~/.b6p/`.
401
+ Any command that needs credentials prompts for a token if none is stored, so `b6p auth set` is
402
+ optional — but it is the only way to *replace* a token without clearing it first.
403
+
404
+ For unattended use, check for credentials before running anything that might prompt:
405
+
406
+ ```bash
407
+ if [ "$(b6p --json auth status | jq -r .authenticated)" != "true" ]; then
408
+ echo "no b6p token configured" >&2; exit 1
409
+ fi
410
+ ```
411
+
412
+ Set a token non-interactively by piping it in:
413
+
414
+ ```bash
415
+ echo "$B6P_TOKEN" | b6p auth set
416
+ ```
225
417
 
226
418
  ## WebDAV URL format
227
419
 
@@ -239,8 +431,9 @@ npm install
239
431
  npm run check-types # tsc --noEmit
240
432
  npm run compile # esbuild → dist/cli.js (self-contained bundle)
241
433
  npm run watch # esbuild --watch
434
+ npm run test # bundle test/ → dist-test/ and run node --test
242
435
  npm run format # prettier --write
243
- npm run clean # rm -rf dist
436
+ npm run clean # rm -rf dist dist-test
244
437
  ```
245
438
 
246
439
  `npm run compile` bundles the CLI and `@bluestep-systems/b6p-core` into a single self-contained