@bluestep-systems/b6p-cli 0.8.2 → 1.0.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 +164 -0
  2. package/README.md +304 -27
  3. package/dist/cli.js +472 -583
  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,170 @@ 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.0.0] — 2026-11-17
9
+
10
+ ### Fixed
11
+
12
+ - **A first pull or publish no longer stops at "HTTP 403"** (b6p-core 1.0.0 with bsjs-git 0.3.1, ClickUp 1k5g91bq9ef).
13
+ The first platform request of a run sent a CSRF token that the sign-in had just dropped, and nothing retried it,
14
+ so 0.9.0 could not pull or publish against 26.11.09.00. That request is now retried once with a fresh token.
15
+
16
+ ### Changed (breaking)
17
+
18
+ - **The platform builds every push; the CLI bundles no compiler** (b6p-core 1.0.0,
19
+ [ADR 0003](docs/adr/0003-server-side-compile.md)). `b6p script push` commits and pushes the draft over git, the
20
+ platform builds that commit, and the draft folder is moved to its build commit; `--snapshot` publishes the build.
21
+ Against a server that predates the git build a plain push is the git push alone (exit `0`), and `--snapshot`
22
+ pushes the draft, takes no snapshot, prints `cannot snapshot, only push saves` and exits `1`.
23
+ - **New exit-`1` cases** (push and each deploy target): the server cannot take the snapshot; the build was not asked
24
+ for (the platform's draft moved), was refused (`BUILD_REFUSED`: the draft moved, is over the build's size limit, or
25
+ its repository or draft branch is missing), its request failed, its outcome is unknown, or it ended in a status
26
+ that does not publish (busy, gate tripped, output withheld, ...); local files block taking in the build commit.
27
+ 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
28
+ snapshot of it is refused until it builds cleanly.
29
+ - **`--json`**: core 1.0's push result (new `route`, `snapshotRefused`, `build`, `buildCommitSha`, `buildVouched`,
30
+ `buildError`, `buildErrorKind`, `buildErrorReason`, `buildIncomplete`, `buildFastForward`) plus `declinedOverwrites` and a new
31
+ `error` (`null`, or `{ kind, message, howTo }`, the same verdict as the exit code). `typeCheckDiagnostics` is now
32
+ the platform's whole ERROR + WARNING count; `typeCheckErrors` lists the ones in the script's own sources, with
33
+ `severity`.
34
+ - **`--fail-on-type-errors` / `failOnTypeErrors`** fail on any diagnostic the platform's build reports in the
35
+ script's own sources (`typeCheckErrors`).
36
+ - **`--externally-built` is removed** (an unknown option): the platform reads each script's own `externallyBuilt`
37
+ flag. A deploy config's `externallyBuilt` key, like any other unknown key at the top level or in a target, is
38
+ refused by name before anything is pushed.
39
+ - **The standalone binaries are a normal release** again: `release.yml` no longer marks any line pre-release.
40
+ - **Node.js 24 or newer is required** (`engines.node` is `>=24`); Node 18 to 22 are no longer supported.
41
+ CI tests Node 24 and 26, the publish and release builds run on Node 24, and `@types/node` is `^24`.
42
+ The standalone binaries bundle their own Node and are unaffected. `engines` is only advisory to npm,
43
+ so `b6p` also checks the Node major at startup and exits `1` with a clear message below 24.
44
+ - **Failing commands now exit `1`** where they used to exit `0` (for example `b6p script deploy
45
+ missing.json`). A pipeline that relied on `b6p` never failing will go red. See Fixed below.
46
+
47
+ ### Added
48
+
49
+ - `b6p kb list` shows a STATUS column and, after the table, one note per non-ok status present; `--json` carries `id`,
50
+ `status` and `rawStatus`. `b6p kb pull` of a `row-only` knowledge base says it has no repository yet.
51
+ - `b6p auth token rotate`: when the rotation's outcome is unknown, the message now says b6p already sent the request a
52
+ second time (core retries an unanswered rotation once with the same idempotency key).
53
+ - **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`.
54
+ - **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`.
55
+ - **`b6p kb list|pull|push`** - browse, clone and push the knowledge bases (global and tenant) the stored
56
+ `b6pt_` token may reach, through the BlueStep gateway. Pulls fast-forward an existing clone and never
57
+ overwrite local changes; pushes are fast-forward only, to the live branch.
58
+ - **`b6p marketplace list|pull`** - list marketplace repositories and clone one (optionally at a tag or
59
+ branch with `--ref`) into a folder.
60
+ - **`b6p auth token list|create|revoke|rotate`** - manage your own gateway tokens. `create` and `rotate`
61
+ print the secret once on stdout; `--expires` takes `90d` (default), another day count, an ISO date or
62
+ `never` (asks first). Needs the `tokens:self` scope.
63
+ - A token the gateway minted but answered malformedly (`off-contract`) still has its secret printed once, with what to do next.
64
+ - `auth token create --expires` takes a day count, a date (start of that day, UTC) or a full ISO date-time
65
+ with `Z` or an offset; anything else is refused before a request is sent. `marketplace pull --ref` also
66
+ accepts full ref names (`refs/tags/v1.0.0`).
67
+ - `auth token revoke` of the token b6p itself is using asks first (Cancel by default; `--yes` alone declines).
68
+ Under `--json` every secret-bearing body carries the secret in a top-level `secret` field. `kb push` works
69
+ from a subfolder of a clone. The spinner is cleared before any stdout write.
70
+ - Gateway errors come with the fix: the scope to mint, `b6p auth set`, the dirty paths, "pull first",
71
+ "choose another folder", "switch to the live branch".
72
+
73
+ - **`b6p script <verb>`** - script-tree operations now live under a `script` namespace:
74
+ `b6p script push`, `pull`, `audit`, `deploy`, `setup`. The top level of `b6p` is becoming a namespace of
75
+ platform subsystems (nouns), so later commands such as `b6p kb ...` can be added without colliding with
76
+ a verb. It mirrors `B6PCore`, where each subsystem hangs off the composition root as its own service.
77
+ The 0.9.0 flags (`--author`, `--enable-git`, `--fail-on-type-errors`) and the 0.9.0
78
+ `--json` fields live on `b6p script push` / `pull` / `deploy`, and so on their deprecated aliases too.
79
+ - **`b6p auth status`** - reports whether an access token is stored (`{"authenticated": bool}` under
80
+ `--json`). It never prompts, so unattended scripts can check for credentials without risking a hang.
81
+ - **Machine-readable failures.** Under `--json`, a failed command writes `{"error": "...", "errors": [...]}`
82
+ to stdout instead of leaving stdout empty. This covers errors that are thrown (such as no input
83
+ available for a prompt) as well as failures core reports, and never writes two documents.
84
+ - `130` is the exit code when a prompt is interrupted with Ctrl-C.
85
+
86
+ ### Removed
87
+
88
+ - `copy-ts-libs`, the SEA `ts-libs` asset, `typescriptLibDirs` and the TypeScript lib invariant test:
89
+ nothing compiles in the CLI any more.
90
+ - `--externally-built` (see above).
91
+
92
+ ### Build
93
+
94
+ - `typescript` is an exact `7.0.2` devDependency, for `check-types` only; `test/noCompiler.test.ts` checks that
95
+ `dist/cli.js` contains no compiler.
96
+
97
+ ### Changed
98
+
99
+ - The old top-level `push`, `pull`, `audit`, `deploy` and `setup` still work as hidden aliases. They are
100
+ registered from the same definition as the `script` commands, so their flags and behaviour cannot
101
+ drift; they print a deprecation warning to stderr, carry the notice in their own `--help` text, and
102
+ will be removed in a future release (no date yet).
103
+
104
+ ```diff
105
+ - b6p push --file ./src/app.ts --snapshot
106
+ + b6p script push --file ./src/app.ts --snapshot
107
+ ```
108
+
109
+ - `b6p auth set` is scriptable: `echo "$B6P_TOKEN" | b6p auth set`. A fresh install used to prompt twice
110
+ and fail on the second prompt at end of input.
111
+ - Reorganised `src/` around the command tree: `src/commands/` holds one module per noun, `src/context.ts`
112
+ the SDK construction and the `withCore` wrapper every action runs inside, `src/program.ts` the root
113
+ command. `src/index.ts` is only version injection and `parseAsync`.
114
+
115
+ ### Fixed
116
+
117
+ - **Failing commands exit non-zero.** Core reports most failures through `Prompt.error` and returns
118
+ normally, so commands such as `b6p script deploy missing.json` printed an error and exited `0`.
119
+ `CliPrompt` now counts what crosses its error channel and sets `process.exitCode`. `Logger.error` is
120
+ deliberately not counted (core logs recoverable conditions there). Reporting a value is still success:
121
+ `b6p auth status` with no token stored exits `0`.
122
+ - **`b6p script audit` outside a script tree fails** instead of printing `null` at exit `0`.
123
+ - **`b6p check-updates` works.** The CLI never passed `updateServiceConfig` to core, so the command could
124
+ only report "Update service is not configured". It now checks this repository's own releases.
125
+ - The CLI now calls `B6PCore.dispose()`, so core's session-cleanup timer no longer outlives the command.
126
+ - Fatal errors set `process.exitCode` instead of calling `process.exit()`, which could truncate a `--json`
127
+ write. A closed stdout pipe (`b6p --json report | head -1`) is a clean exit rather than an `EPIPE`, and keeps
128
+ a failure exit code the command had already set.
129
+ - The standalone-binary build smoke test looks for `script` in `--help` rather than `push`.
130
+ - 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).
131
+ - The test build shares the real build's `external` list (`NODE_EXTERNALS` in `esbuild.js`).
132
+
133
+ ## [0.9.0] — 2026-11-16
134
+
135
+ Depends on b6p-core 0.9.0, which moves scripts to git: a script's draft and snapshot are a git repository,
136
+ and its history is its git history. **Platform floor:** the platform's git publishing. Today's server works
137
+ through its `enableGitPublishing` switch (the first push, or `pull --enable-git`, turns a script over); the
138
+ release that moves script history to git makes it the only mode, and refuses WebDAV writes to a script's draft
139
+ and snapshot. 0.8.x clients stop working against a script once it is on git: update them to this version.
140
+
141
+ ### Changed (breaking, user-visible)
142
+
143
+ - **`push --json` lost `historyRecorded` and gained `commitSha`, `publishedSha`, `publishError` and
144
+ `switchedToGit`.** Every other field is unchanged. `commitSha` is the draft commit after the push,
145
+ `publishedSha` the commit a snapshot published, `publishError` why a publish failed, `switchedToGit` that this
146
+ push moved the script from WebDAV to git. Anything that reads `historyRecorded` must read `publishedSha`
147
+ (snapshot) or `commitSha` instead; the new shape is in the README.
148
+ - **New exit-code rules.** `1` when `pushed` is false. On a snapshot, also `1` when `publishedSha` is `null`,
149
+ `publishError` is set, or `liveVerified` is `false` . Otherwise
150
+ `0`. A plain push is judged by `pushed` alone.
151
+ - A push that stops after switching a script to git (a declined overwrite, for instance) reports `switchedToGit: true`; the switch stands.
152
+ - **A push is a git commit and needs an author.** `--author "Name <email>"`, or `b6p config set author "Name
153
+ <email>"`, or (as before for git users) `git config user.name/user.email` or `GIT_AUTHOR_*` in the
154
+ environment. With none, the push exits `1` and says how to fix it.
155
+ - **Pulls and pushes work on the script's git draft.** `pull` clones it (or fast-forwards an existing clone);
156
+ there is no WebDAV draft or snapshot transfer any more. `audit` needs a pulled git working copy.
157
+ - **Switching a script from WebDAV to git is one-way,** and the CLI says so: a push prints it (`switchedToGit` in
158
+ `--json`), and `pull` asks first (`[Cancel]` first, so `--yes` declines).
159
+
160
+ ### Added
161
+
162
+ - `--fail-on-type-errors` on `push` and `deploy` (and `failOnTypeErrors` in deploy configs). Type errors in a script's own sources are now warnings that exit `0` by default (0.8 failed a snapshot on them); errors in `.d.ts` files never count; syntax and emit errors still exit `1`.
163
+
164
+ - Build manifest: a push that builds writes `<outDir>/.b6p-build.json` with the build output (a draft with no TypeScript source needs none), and the platform refuses to publish a draft whose sources changed since the build. The refusal (`BUILD_STALE`, `BUILD_MANIFEST_MISSING`, `BUILD_MANIFEST_INVALID`) exits `1`, lists the files, says to rebuild and push, and appears in `--json` as `publishRefusal`. `--externally-built` (push) and `externallyBuilt` (deploy config) mark a script a bundler builds.
165
+
166
+ - `--enable-git` on `pull` (with a URL, `--file` or the current folder) and `push`: switch a script still on WebDAV to git without asking. Without it the switch is asked about and `--yes` declines.
167
+ - Clear messages, each exiting `1` with nothing changed, for a declined switch, a wrong branch checked out, staged-only changes and symlinks that escape the draft folder.
168
+ - `b6p push --author` and `b6p deploy --author`; `author` and `message` in deploy config files.
169
+ - A push prints the draft and published commit SHAs.
170
+ - `deploy` exits `1` when no author resolves (checked before anything is pushed) or when any target failed, was not pushed, or had its publish refused, and prints a line per target with its commit and published SHAs (and a switch to git). Before, it printed "Deploy complete!" and exited `0` whatever happened.
171
+
8
172
  ## [0.8.2] — 2026-10-20
9
173
 
10
174
  ### Fixed
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, snapshot 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,19 +79,101 @@ 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
+
141
+ `<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
142
+ overwrite local changes (the dirty paths are listed) and pushes are fast-forward only: if the knowledge
143
+ base moved on, pull first. Pushing needs push rights on that knowledge base as well as the `kb:push` scope.
144
+
145
+ ### `b6p marketplace` — marketplace repositories
146
+
147
+ | Command | Purpose |
148
+ |---|---|
149
+ | `b6p marketplace list` | List repositories with their default branch and tags |
150
+ | `b6p marketplace pull <name> [dir] [--ref <tag\|branch>]` | Clone a repository into a folder (default `./<name>`), or fast-forward an existing clone |
151
+
152
+ A plain working clone, unrelated to any script. There is no push.
153
+
154
+ ### Gateway token scopes
155
+
156
+ `kb` and `marketplace` talk to the BlueStep gateway (`gatewayUrl`, default `https://gateway.bluestep.net`;
157
+ change it with `b6p config set gatewayUrl <url>`) using the same stored `b6pt_` token. Mint a token with
158
+ the scopes you need:
159
+
160
+ | Scope | For |
161
+ |---|---|
162
+ | `kb:read` | `kb list`, `kb pull` |
163
+ | `kb:push` | `kb push` |
164
+ | `registry:read` | `marketplace list`, `marketplace pull` |
165
+ | `tokens:self` | `auth token …` |
166
+ | `kb:rewrite` | rewriting a knowledge base's history (not a `b6p` command); mintable and rotatable here only if the token b6p uses holds it |
167
+
168
+ ### Everything else
169
+
80
170
  | Command | Purpose |
81
171
  |---|---|
82
- | `b6p pull <webdav-url>` | Pull a script by URL |
83
- | `b6p pull --file <path>` | Pull using metadata stored with a local file |
84
- | `b6p push --file <path>` | Push local files to the platform |
85
- | `b6p push --file <path> --snapshot --message "…"` | Push and record a versioned snapshot |
86
- | `b6p push --file <path> --overwrite <file>` | Push, overwriting a file that changed on the platform |
87
- | `b6p audit --file <path>` | Diff local vs. server |
88
- | `b6p audit --file <path> --pull` | Audit and pull if differences found |
89
- | `b6p deploy <config.json>` | Multi-target deploy from a config file |
90
- | `b6p setup --file <path>` | Print the web-UI setup URL for a script |
172
+ | `b6p sessions clear` | Clear all active sessions |
173
+ | `b6p config set <key> <value>` | Set a configuration value |
174
+ | `b6p config reset` | Reset all settings to defaults |
91
175
  | `b6p report` | Report cached state |
92
- | `b6p auth set` | Store or replace your platform access token (`b6pt_…`, see [Signing in](#signing-in)) |
176
+ | `b6p check-updates` | Check for CLI updates |
93
177
 
94
178
  Most commands accept `--json` for machine-readable output and `--yes` to answer every question with
95
179
  its default (and print what it answered). Run `b6p <command> --help` for full options.
@@ -107,27 +191,219 @@ take, so `--yes` never overwrites or deletes anything on the platform:
107
191
  No keeps them (exit `0`).
108
192
 
109
193
  When question 1 is declined, the CLI prints the command that confirms it. After checking the
110
- platform versions (`b6p audit`), confirm specific files up front with `--overwrite`, once per file,
194
+ platform versions (`b6p script audit`), confirm specific files up front with `--overwrite`, once per file,
111
195
  using the path the question listed:
112
196
 
113
197
  ```bash
114
- b6p --yes push --file <path> --snapshot --overwrite scripts/app.ts --overwrite README.md
198
+ b6p --yes script push --file <path> --snapshot --overwrite scripts/app.ts --overwrite README.md
115
199
  ```
116
200
 
117
201
  Question 2 has no flag: run without `--yes` and answer `Yes`. Answers can be piped, one line per
118
- question, in order (`printf 'Overwrite all\nYes\n' | b6p push --file <path>`, or `< answers.txt`;
119
- in PowerShell, `'Overwrite all', 'Yes' | b6p push --file <path>`). The commands the CLI prints are
202
+ question, in order (`printf 'Overwrite all\nYes\n' | b6p script push --file <path>`, or `< answers.txt`;
203
+ in PowerShell, `'Overwrite all', 'Yes' | b6p script push --file <path>`). The commands the CLI prints are
120
204
  written for your shell: POSIX, or PowerShell on Windows outside Git Bash.
121
205
 
122
- **Exit codes:** `0` when the push went through (keeping platform-only files is still `0`); `1` when
123
- nothing was uploaded, an overwrite was not confirmed, an upload was refused, or, on a snapshot, a
124
- live copy is still wrong after one re-send, the history entry wasn't recorded, or type-check
125
- diagnostics were reported.
206
+ ### Git, authors and switching
207
+
208
+ A script's draft and its published snapshot are a git repository on the platform; a push commits your
209
+ `draft/` folder to it, and `--snapshot` (or `--message`, which implies it) also publishes that
210
+ commit. Its history is its git history. Requires a platform with git publishing for scripts (today's
211
+ server: its `enableGitPublishing` switch); a script still on WebDAV is switched
212
+ to git by its first push or by `b6p script pull --enable-git`. **The switch is one-way**: afterwards the
213
+ script's draft and snapshot refuse WebDAV writes. The CLI says so when it happens
214
+ (`switchedToGit`).
215
+
216
+ Every commit needs an author. In order, the first complete one is used: `--author "Name <email>"`;
217
+ for `deploy`, the config file's `author`; the stored default (`b6p config set author "Name <email>"`);
218
+ `git config user.name` and `user.email` for the script folder; then `GIT_AUTHOR_NAME` and
219
+ `GIT_AUTHOR_EMAIL` (or the `GIT_COMMITTER_*` pair) in the environment. With none of them the push
220
+ stops with exit `1` and prints those fixes; nothing is ever committed as nobody.
221
+
222
+ `b6p script pull` and `b6p script push` without `--enable-git` ask before switching a WebDAV script (`[Cancel]` first),
223
+ and `--yes` declines, so an unattended run never switches anything and exits `1` (push) with nothing changed.
224
+ `--enable-git` works with a URL or with `--file`/the current folder.
126
225
 
127
- **`--json`** prints one object on stdout: `pushed`, `historyRecorded`, `typeCheckDiagnostics`,
128
- `liveVerified`, `liveMismatches`, `keptPlatformOnly`, `declinedOverwrites`. A declined overwrite
129
- prints `pushed: false` with the files in `declinedOverwrites`. Questions, warnings and next steps
130
- go to stderr.
226
+ Refusals that change nothing and exit `1`: a declined switch, a draft folder with a branch other than
227
+ `draft` checked out (push), staged-only changes that a pull would discard, and symbolic links that
228
+ would let a pull write outside the draft folder. Each message says how to fix it.
229
+
230
+ ### What the platform does with a push
231
+
232
+ A push commits the draft and pushes it over git; then the **platform** builds that commit (b6p bundles no
233
+ compiler) and commits its output, plus a build manifest when the build is clean, as one build commit. The
234
+ draft folder is moved to that build commit, and `--snapshot` publishes it. `b6p` asks the server for its
235
+ version first (`--verbose` prints the route; `--json` carries it as `route`):
236
+
237
+ | Server | `b6p script push` | `b6p script push --snapshot` |
238
+ |---|---|---|
239
+ | Builds git drafts (at or above core's minimum, or a `dev` build) | pushed, then built | pushed, built, and the build published |
240
+ | Older, unreadable version, or no minimum known | pushed; nothing built (exit `0`) | pushed, **no snapshot**: prints `cannot snapshot, only push saves` and exits `1` |
241
+
242
+ The platform's diagnostics are printed on stderr. An unclean build (an `ERROR` diagnostic: syntax, emit
243
+ or configuration) commits its output without a manifest: the push still exits `0` with a warning, and a
244
+ snapshot of that draft is refused until it builds cleanly. There is no `b6p script check` (a dry-run
245
+ build is waiting on a platform endpoint).
246
+
247
+ ### Exit codes
248
+
249
+ | Result | Exit |
250
+ |---|---|
251
+ | 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` |
252
+ | The user cancelled at the target-URL prompt | `0` |
253
+ | Nothing was pushed (`pushed: false`): bad `--root`, empty draft, an overwrite not confirmed, no commit author, an upload refused | `1` |
254
+ | Snapshot, and the server cannot take one (`snapshotRefused`) | `1` |
255
+ | 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` |
256
+ | The build ended in a status that does not publish, or its outcome is unknown (`buildIncomplete`) | `1` |
257
+ | Local files block moving the draft folder to the build commit, or the move failed (`buildFastForward.state` `blocked` / `failed`) | `1` |
258
+ | Snapshot, and the publish was refused or failed (`publishError`), published nothing (`publishedSha: null`), or reads back at another commit (`liveVerified: false`) | `1` |
259
+ | `--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` |
260
+
261
+ Every failure prints a `To go on:` line saying what to run: for example `b6p script pull`, then push again,
262
+ after the platform's draft moved or when the build's outcome is unknown; push again after a busy or
263
+ incomplete build; move or delete the listed files when they block the build commit; update b6p for a build
264
+ status it does not know. Diagnostics are **warnings by default** (the platform runs the emitted JavaScript);
265
+ those in a `.d.ts` never count. Add `--fail-on-type-errors` to push, snapshot or deploy to make them fail.
266
+
267
+ ### `--json`
268
+
269
+ `--json` prints one object on stdout, the same shape for every outcome (agents parse it): core's push result
270
+ plus `declinedOverwrites` and `error`.
271
+
272
+ ```json
273
+ {
274
+ "pushed": true,
275
+ "commitSha": "3f2a…",
276
+ "publishedSha": "9c1b…",
277
+ "publishError": null,
278
+ "publishRefusal": null,
279
+ "switchedToGit": false,
280
+ "route": { "mode": "server-build", "reason": "at-or-above-floor", "serverVersion": "…", "required": "…" },
281
+ "snapshotRefused": null,
282
+ "build": { "status": "COMPILED", "rawStatus": "COMPILED", "errors": 0, "warnings": 0, "…": "…" },
283
+ "buildCommitSha": "7d4e…",
284
+ "buildVouched": true,
285
+ "buildError": null,
286
+ "buildErrorKind": null,
287
+ "buildErrorReason": null,
288
+ "buildIncomplete": null,
289
+ "buildFastForward": { "state": "fast-forwarded", "blockedPaths": [], "error": null },
290
+ "typeCheckDiagnostics": 0,
291
+ "typeCheckErrors": [],
292
+ "liveVerified": true,
293
+ "liveMismatches": [],
294
+ "keptPlatformOnly": [],
295
+ "declinedOverwrites": [],
296
+ "error": null
297
+ }
298
+ ```
299
+
300
+ - `commitSha`: the draft commit this push made (or the one already there); `buildCommitSha`: the platform's
301
+ build commit after it, `null` when it made none. `publishedSha`: the commit published (snapshot only).
302
+ - `route` / `snapshotRefused`: which route the push took, and why a snapshot was refused (`too-old`,
303
+ `unknown`, `floor-unset`, with the versions).
304
+ - `build`, `buildVouched`, `buildError` / `buildErrorKind` / `buildErrorReason` (`DRAFT_MOVED`, `DRAFT_TOO_LARGE`,
305
+ `REPO_MISSING`, `DRAFT_BRANCH_MISSING` when the platform refused the build), `buildIncomplete` (`{ status, rawStatus, description }`)
306
+ and `buildFastForward` (`{ state, blockedPaths, error }`): what the platform's build came to.
307
+ - `publishRefusal`: `{ "reason", "withheld" }`, straight from the platform, when it refused the publish
308
+ (`BUILD_STALE`, `BUILD_MANIFEST_MISSING`, `BUILD_MANIFEST_INVALID`, `DRAFT_MOVED`, ...).
309
+ - `typeCheckDiagnostics`: the platform's whole `ERROR` + `WARNING` count. `typeCheckErrors`: those in the
310
+ script's own sources (`{ file, line, column, code, message, severity }`, at most 20); `.d.ts` diagnostics are
311
+ never included.
312
+ - `error`: `null` when the push succeeded, else `{ "kind", "message", "howTo" }`, the same verdict as the exit
313
+ code. `kind` is one of `NOTHING_PUSHED`, `SNAPSHOT_REFUSED`, `BUILD_NOT_REQUESTED`, `BUILD_REFUSED`, `BUILD_REQUEST_FAILED`,
314
+ `BUILD_OUTCOME_UNKNOWN`, `BUILD_INCOMPLETE`, `BUILD_BLOCKED`, `BUILD_TAKE_IN_FAILED`, `PUBLISH_REFUSED`,
315
+ `PUBLISH_FAILED`, `NOT_PUBLISHED`, `LIVE_MISMATCH`, `TYPE_ERRORS`, `OVERWRITE_DECLINED`, `NO_AUTHOR`,
316
+ `AUTHOR_INVALID`, `GIT_REFUSED`.
317
+ - A declined overwrite prints `pushed: false` with the files in `declinedOverwrites`; a cancelled target-URL
318
+ prompt prints `{ "cancelled": true }`. Questions, warnings and next steps go to stderr.
319
+
320
+ ### Deploy
321
+
322
+ `b6p script deploy <config.json>` pushes the source draft to each target, and each target's platform builds it:
323
+
324
+ ```json
325
+ {
326
+ "sourceRootPath": "./my-script",
327
+ "targets": [{ "url": "https://…/files/123/draft/", "snapshot": true }],
328
+ "author": { "name": "Jane Doe", "email": "jane@example.com" },
329
+ "message": "Deploy from CI",
330
+ "enableGit": false,
331
+ "failOnTypeErrors": false
332
+ }
333
+ ```
334
+
335
+ Those are the only keys (and `url` / `snapshot` in a target): any other key is refused by name before anything is
336
+ pushed. `externallyBuilt` was removed in 1.0.0, since the platform reads each script's own flag. `author` (an object,
337
+ or `"Jane Doe <jane@example.com>"`) and `message` are optional and apply to every target; `b6p script deploy
338
+ --author "…"` overrides the file's author. `deploy` exits `1` if no author resolves (nothing is pushed then) or if
339
+ any target fails by the push rules above.
340
+
341
+ ## Exit codes
342
+
343
+ | Code | Meaning |
344
+ |---|---|
345
+ | `0` | The command completed without reporting an error |
346
+ | `1` | The command failed, or its arguments were rejected |
347
+ | `130` | A prompt was interrupted with Ctrl-C |
348
+
349
+ `--quiet` and `--json` change what is printed, never the exit code, so it is safe to gate a
350
+ pipeline on:
351
+
352
+ ```bash
353
+ set -e
354
+ b6p script push --file ./src/app.ts --snapshot --message "release $VERSION"
355
+ ```
356
+
357
+ Under `--json`, a failure also writes a machine-readable payload to stdout:
358
+
359
+ ```console
360
+ $ b6p --json script deploy missing.json
361
+ {
362
+ "error": "Config file not found: missing.json",
363
+ "errors": ["Config file not found: missing.json"]
364
+ }
365
+ ```
366
+
367
+ Note that a command reporting a *value* has still succeeded — `b6p auth status` exits `0` whether
368
+ or not a token is stored. Branch on its output, not its exit code:
369
+
370
+ ```bash
371
+ b6p --json auth status | jq -e .authenticated >/dev/null
372
+ ```
373
+
374
+ > **Changed after 0.9.0.** Failing commands previously exited `0`. If a pipeline was relying on
375
+ > `b6p` never failing, it will now correctly go red.
376
+
377
+ ## Unattended use
378
+
379
+ Every command is usable from a script, but two flags matter:
380
+
381
+ - `--yes` skips confirmation prompts. If a command needs a value it cannot guess, it now **fails
382
+ immediately** rather than blocking on a prompt no one will answer.
383
+ - `--json` writes machine-readable output to stdout and keeps all human text on stderr.
384
+
385
+ A closed stdin is also an error rather than a hang, so `b6p … < /dev/null` in CI fails fast
386
+ instead of stalling until the job times out.
387
+
388
+ ## Authentication
389
+
390
+ The token from [Signing in](#signing-in) is stored in encrypted secret storage under `~/.b6p/`.
391
+ Any command that needs credentials prompts for a token if none is stored, so `b6p auth set` is
392
+ optional — but it is the only way to *replace* a token without clearing it first.
393
+
394
+ For unattended use, check for credentials before running anything that might prompt:
395
+
396
+ ```bash
397
+ if [ "$(b6p --json auth status | jq -r .authenticated)" != "true" ]; then
398
+ echo "no b6p token configured" >&2; exit 1
399
+ fi
400
+ ```
401
+
402
+ Set a token non-interactively by piping it in:
403
+
404
+ ```bash
405
+ echo "$B6P_TOKEN" | b6p auth set
406
+ ```
131
407
 
132
408
  ## WebDAV URL format
133
409
 
@@ -145,8 +421,9 @@ npm install
145
421
  npm run check-types # tsc --noEmit
146
422
  npm run compile # esbuild → dist/cli.js (self-contained bundle)
147
423
  npm run watch # esbuild --watch
424
+ npm run test # bundle test/ → dist-test/ and run node --test
148
425
  npm run format # prettier --write
149
- npm run clean # rm -rf dist
426
+ npm run clean # rm -rf dist dist-test
150
427
  ```
151
428
 
152
429
  `npm run compile` bundles the CLI and `@bluestep-systems/b6p-core` into a single self-contained