@briefingprotocol/brief 0.0.0-stage → 0.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.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,160 @@
1
- # Temporary Holding Version
1
+ # brief
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `brief` is the command-line client of the [Briefing Protocol](https://github.com/briefingprotocol/brief). A coding agent that needs a decision from a person writes a **brief** (a title, a short body and one **point** per decision, each with options and the agent's recommendation), posts it with `brief post`, and waits. The person answers every point on their phone in the Briefing Room app, and the agent gets the decisions and notes back as text.
4
+
5
+ Its commands, flags, config and output follow the [spec](../spec/clients.md#an-agent-side-client); how it fits a coding harness (`when`, `delay`, the delay setting, `install`, the hooks, the log, `--version`), which the spec leaves to each client, is in [docs/harness.md](docs/harness.md).
6
+
7
+ Briefs are end-to-end encrypted: the CLI seals each brief and its images on this computer with the environment's credential, and the server only stores records it cannot open.
8
+
9
+ ## Install
10
+
11
+ Needs Node.js 22 or later.
12
+
13
+ ```sh
14
+ npm install -g @briefingprotocol/brief
15
+ brief --help
16
+ ```
17
+
18
+ To update it, `npm update -g @briefingprotocol/brief`. A brief from a newer version of the format, or a server that speaks a newer spec version, makes `brief` say it is out of date and leave the update to you: it never runs an installer itself.
19
+
20
+ ## Set up
21
+
22
+ `brief` talks to the Briefing Room server at `https://briefingroom.dev`. It needs a credential for an **environment** (a place agents run that can post to your inbox), which the Briefing Room app makes.
23
+
24
+ - **This computer:** run `brief pair` in a terminal and scan the QR code it shows with the app. If you'd rather not scan it, tap "Prefer to paste instead?" in the app and paste the credential it makes (`bpk1_...`) into that same terminal; what you paste stays hidden. `brief pair --token` reads a credential from a pipe or a hidden prompt instead. Either way the credential is saved to `~/.config/briefingroom/config.json` (mode 600), and `brief pair` sends a short welcome brief to try answering.
25
+ - **A cloud environment:** add one in the app under Settings, Environments, and set `BRIEFING_TOKEN` to the credential it shows, as a secret. It is 1,797 characters on one line; a value cut short or wrapped is refused. With `BRIEFING_TOKEN` set, no config file is read. Its home directory is fresh every session, so add `npm install -g @briefingprotocol/brief && brief install --user` to its setup script.
26
+
27
+ Then teach your agents when to use it:
28
+
29
+ - `brief install` sets up every agent your user runs on this computer, in any directory: it writes the `brief` skill, `SKILL.md` and `BRIEFING.md`, for Claude Code (`~/.claude/skills/brief/`, or `$CLAUDE_CONFIG_DIR/skills/brief/` when that is set) and Codex (`~/.agents/skills/brief/`), and adds Claude Code's hooks to your settings (`~/.claude/settings.json`, or `$CLAUDE_CONFIG_DIR/settings.json`). The hooks do nothing where Briefing Room is not set up. `brief pair` does the same, wherever you run it. `--no-hooks` writes the skill files, and the delay, but no hooks.
30
+ - `brief install --repo` writes the same files into the git repository you are in instead, at its root (`.claude/skills/brief/`, `.agents/skills/brief/`, `.claude/settings.json`), for a team to commit, so every session that starts from the repository has them. It refuses a repository whose root is your home directory. Each level writes only its own copies; when the other level's copy of the skill differs, it says so in one line and leaves it, and `brief when` tells the agent to tell you.
31
+ - A `BRIEFING.md` at a repository's root is yours: the skill follows it wherever it differs from the skill's own, and `brief install` never touches it. A line in it that says only `brief: off`, outside a code block, turns Briefing Room off in that repository.
32
+ - Or install the skill alone with `npx skills add briefingprotocol/brief`. See [the skill](https://github.com/briefingprotocol/brief/blob/main/skills/brief/SKILL.md), and [the prompt](https://github.com/briefingprotocol/brief/blob/main/skills/prompt.md) for harnesses without skills.
33
+
34
+ The **delay** is how long you have to reply in the session before an agent waiting on you sends a brief instead. `brief install` and `brief pair` set it in the config file when it has none: 5 minutes when you run them at a terminal, 3 otherwise (an agent or a script). Edit the file's `"delay"` (`90`, `90s`, `5m`, up to 60 minutes, or `0` for briefs at once) or set `BRIEFING_DELAY` to change it.
35
+
36
+ Never paste the credential into a conversation with an agent, and never pass it as an argument: `brief` refuses any argument that looks like a credential or a token.
37
+
38
+ ## Use
39
+
40
+ ```
41
+ brief when Whether Briefing Room can be used here, the delay, and how to wait. Once per session.
42
+ brief delay [seconds] Wait for the delay (or the seconds given), sending nothing, then say what to do.
43
+ brief post <file | -> [--wait] [--json] [--agent <name>]
44
+ Send a brief. Prints its id, or with --wait, the answers.
45
+ brief wait <id> [--json] [--timeout <seconds>]
46
+ Block until a brief is answered, then print the answers.
47
+ brief show <id> [--json] Print a brief's status, or its answers once it has them.
48
+ brief list [--json] List this environment's recent briefs, newest first.
49
+ brief done <id> <outcome> Optionally tell the person what you did about the answers.
50
+ brief cancel <id> [reason] Withdraw a brief that is no longer needed.
51
+ brief pair [--name <name>] [--print-link]
52
+ brief pair --token Set this computer up (once; the person runs it).
53
+ brief install [--user | --repo] [--no-hooks | --remove-hooks]
54
+ Add the skill and Claude Code's hooks, for your user or (--repo) to this repository.
55
+ brief hook stop|prompt Claude Code's hooks, added by brief install.
56
+ ```
57
+
58
+ `brief post --help` has the brief format and its limits, and `brief <command> --help` the details of each command. The skill says when an agent should send a brief and how to write one.
59
+
60
+ `brief --version` prints the version and the commit it was built from, such as `0.1.0 (1f3c9a2)`.
61
+
62
+ Exit codes: 0 success, 1 error (the message says why; for `brief when`, Briefing Room can't be used here), 2 still waiting after `--timeout`, 3 the brief was cancelled while waiting, 4 `brief delay` was stopped before it finished.
63
+
64
+ | Environment variable | What it does |
65
+ |---|---|
66
+ | `BRIEFING_TOKEN` | The credential, for a cloud environment. With it set no config file is read. |
67
+ | `BRIEFING_API_URL` | The server's origin, for development. Default `https://briefingroom.dev`. `https://` except for `localhost` and `127.0.0.1`, with no path. `brief pair` saves it to the config file; every other command uses the saved address, and this variable over it when set. Empty counts as unset. |
68
+ | `BRIEFING_AGENT` | Who is asking, shown on each brief. |
69
+ | `BRIEFING_DELAY` | How long the user has to reply in the session before a brief goes: whole seconds (`90`), `90s` or `5m`, up to 60 minutes; `0` sends briefs at once. Over the config file's `"delay"`; without either, 3 minutes. |
70
+
71
+ The server is sent only the credential's server token (`bpa_...`) as the bearer token, and sealed records. Nothing prints or logs the credential or any part of it, and no message prints the API URL's value: messages say where it came from. API requests never follow redirects.
72
+
73
+ `wait` keeps polling through anything that can pass: no network, a request past its time limit or cut off, a 5xx, 408 or 429, or a reply that is not what it should be. Only a 401, 403, 404 or a redirect end it, each as an error with exit 1, and only a status of `answered`, `done` or `cancelled` whose record opens ends it with a result. `--timeout` bounds how long it waits for an answer, not how long fetching one takes, so an answer found at the last moment is still printed. A brief written under a newer spec version than this CLI knows ends the wait with exit 1 and a sentence saying the CLI is too old to read it.
74
+
75
+ ### Reading the log
76
+
77
+ `$XDG_STATE_HOME/briefingroom/brief.log` (default `~/.local/state/briefingroom/brief.log`, with one older `brief.log.1`) records what the hooks decided and what each command did, to find out why a brief did not reach the phone. Each line is `<time> <session> <pid> <event> key=value ...`, the session cut to 8 characters. It logs ids, counts, statuses, codes and reasons, never a credential, a token, a key id, an environment's name, the server's error text or what the agent or the person wrote. The events:
78
+
79
+ - `install scope=repo|user|pair hooks=installed|updated|already|skipped-broken-settings|removed|absent|none [delay=5m|3m|kept|corrupt|unreadable|variable|failed]` (`none`: `--no-hooks`; `absent`: `--remove-hooks` found none; pair also logs `failed`, when writing the skill failed; `delay`: what it set in the config file, `kept` one already there, `corrupt` a file that isn't JSON, `unreadable` one that is there but can't be read, both left alone, `variable` none written since `BRIEFING_TOKEN` is set, `failed` the write failed, a warning).
80
+ - Stop hook, one line per run: `stop skip reason=bad-input|not-set-up|opted-out|duplicate|stop-hook-active|no-delay|brief-running|no-message|no-question|already-woke|delay-running` (`opted-out`: the session's repository has `brief: off` in its root `BRIEFING.md`; `duplicate`: another Stop hook, from the other level's settings, took this stop; `no-delay`: `BRIEFING_DELAY` is 0) (`brief-running`: a `brief post` or `brief wait` in Claude Code's background tasks, or one the session record holds, and `ended=wait` when that ended a wait an earlier stop left pending; `no-question` adds `chars=` the prose's length after code, URLs and quoted text are dropped and `mark=` how far from its end the last `?` is, or `none`, and leaves a pending wait alone; the last two add `asked=`), or `stop wait seconds= asked=yes|delay [chars= mark=] [replaced=yes] [deadline=kept] [capped=yes limit=]` (`seconds`: how long it will sleep; `deadline=kept`: it took over a live wait, so it wakes when that one would have; `capped=yes`: the delay runs past the hook's time limit, `limit` seconds, less 20, so it sleeps only that long: `limit=210` is an entry from an earlier install, and `brief install --user` gives it the whole delay if it is in the user's settings, `brief install --repo` if it is in a repository's), either adding `delay=invalid-variable` or `delay=invalid-config` when `BRIEFING_DELAY` or the config file's `delay` was a value it doesn't take and the default was used, then `stop stopped signal=`, `stop superseded`, `stop quiet reason=brief-sent|brief-running` (it woke to find the session had sent a brief since the wait began, or was waiting on one, so it said nothing) or `stop wake`; `stop error`.
81
+ - Prompt hook: `prompt skip reason=not-set-up|opted-out`, `prompt user stopped=wait|delay|wait,delay|none`, `prompt task-notification`, `prompt agent-message` (a background subagent's report or another session's message, which isn't the user), `prompt error`.
82
+ - `when usable delay= hooks=yes|no [invalid=variable|config]` (`invalid`: the delay set there isn't one it takes, so it used the default and asked the agent to tell the user), `when not-set-up`, `when opted-out`, `when unreachable status=<http status>|unreachable [code=]` (the server can't be reached or failed in a way that can pass), `when refused status= [code=]` (it refused the credential or the request), or `when broken message=` (the config, the credential or the API URL can't be used). A delay it doesn't take is no error: see `invalid` above.
83
+ - `delay hooks-own-wait`, or `delay start seconds=` (either with `delay=invalid-variable|invalid-config` as the Stop hook logs it) then `delay done` or `delay stopped signal=`. Its session column is `-` when the agent's command carried no session id, so it ran as a plain timer the hooks can't see.
84
+ - `post ok id= points= images= wait=yes|no`; `wait start id=`, `wait retrying id= status=<http status>|unreachable` at the first failed poll, `wait recovered id= failures=`, then `wait answered id= seconds=`, `wait cancelled id=`, `wait timeout id= [reachable=no]` or `wait stopped id= signal=`; `done id=`, `cancel id=`. `pair`'s wait for its welcome brief's answer logs the same, and `wait error id= kind=api|cli|unexpected [status= code=]` when it ends on an error, or `done error` with the same fields when the outcome can't be attached, both a warning that `main` doesn't log.
85
+ - `pair drawn`, `pair read` or `pair pasted` (a credential pasted while the code showed), `pair retrying step=read|register status=<http status>|unreachable` (the first failure of a run of them; for registering, the first attempt whose outcome was unknown), `pair recovered step=read failures=`, `pair registered status=200|201 [after=unknown]`, `pair saved welcome=sent|failed|refused [image=yes|no]` (`image`: whether the welcome brief carries its demo image), `pair stopped signal= [saved=yes]` (`saved=yes`: a SIGQUIT while the welcome brief was being sent). Never the link, the pairing id, a key, the name or the credential: a refusal is the `error` line, whose message names only what failed, such as `The sealed credential did not open (authentication).` or `The registration could not be confirmed.`
86
+ - `error command= exit= [status= code=] [message=]`, once per failure (not for a `wait timeout`, which is its own line); `status` and `code` when the server answered (`code` is one the spec defines, or `unknown`), `status=unreachable` when it couldn't be reached. The message is our own, never the server's text, so an error from the server may have none. A record that did not open logs `message="The <brief|answer|outcome|cancellation> record did not open (<refusal>)."`, the refusal being `CryptoError.refusal`.
87
+
88
+ What it tells you:
89
+
90
+ - No `stop` lines for a session: the Stop hook never ran. The hooks aren't installed, or `brief` isn't on the PATH Claude Code runs hooks with; look for an `install` line. A `stop skip reason=duplicate` beside each stop means the hooks are installed twice, for the user and in the repository, which is harmless.
91
+ - `stop skip` gives the reason it didn't wait.
92
+ - `stop wake` should be followed by `prompt task-notification` (the wake reached the session); with no later `post ok`, the agent ignored it.
93
+ - A `stop` line is one per turn end, not per message: a question followed by a tool call and a closing line is judged by the closing line, and `asked=delay` means `brief delay` marked the turn.
94
+ - `post ok` means the server accepted the brief, not that the phone showed it. Without a later `wait answered`, the answer was never picked up.
95
+ - `did not open` means the server served a record that is not what this environment wrote or the phone sealed for it: changed on the way, written for another brief, or written with another credential.
96
+ - `wait retrying` without `wait recovered`: the server stayed unreachable until the wait ended, or, before a `wait answered`, the poll that delivered the answer could not fetch its outcome or look at the metadata again.
97
+ - `pair drawn` with neither `pair read` nor `pair pasted`: no credential came in the ten minutes (not scanned, its write failed, or nothing pasted). `pair read` with no `pair registered`: the registration was refused or could not be confirmed; the `error` line says which.
98
+ - `stop wait` or `wait start` with no later line from that pid: the process was killed outright (SIGKILL), not stopped.
99
+
100
+ ## Develop
101
+
102
+ TypeScript, which esbuild bundles into one executable file, `dist/brief.mjs`, for the package; the bundle runs on Node 22.0 and later. The tests and scripts run the sources directly with Node's type stripping, and act as the phone with ML-DSA-87 keys, so they need a Node built with OpenSSL 3.5 or later: among the official builds, 22.20.0 or later on 22.x, 24.5.0 or later on 24.x, and every 26.x. The skill, `../skills/brief/SKILL.md` and `BRIEFING.md`, is inlined into the bundle as text, so `brief install` writes the copy the package was built with: rebuild after editing it. So are `package.json`'s version and the short commit hash (`git rev-parse`, else `unknown`), which `brief --version` prints. So is the WebAssembly build of the Rust core in `../rust/dist/`, which does the X-Wing sealing and opening (see [`../rust`](../rust)): the build reads the committed module and never compiles Rust.
103
+
104
+ ```sh
105
+ npm ci
106
+ npm run build # type-checks, bundles dist/brief.mjs and writes dist/THIRD_PARTY_NOTICES.md
107
+ npm test # builds, then runs test/*.test.ts with node --test
108
+ ```
109
+
110
+ The run-time dependencies are bundled and pinned to exact versions: `zod` for the brief's rules, `image-size` for an image's type and dimensions, and `qr` for the matrix of `brief pair`'s QR code. The build writes `dist/THIRD_PARTY_NOTICES.md` with the licence files of every package esbuild put in the bundle and the Rust core's notices (`../rust/THIRD-PARTY-NOTICES.txt`), and the package ships it; the bundle also carries the Rust core's notices as a comment at its end.
111
+
112
+ ### Layout
113
+
114
+ - `src/main.ts`: argument parsing, dispatch and error printing. `src/help.ts`: all help text.
115
+ - `src/api.ts`: the server, as the commands see it. Images go up in two requests, both to the server: `POST /uploads` with the record's size, then `PUT /uploads/:id` with the record. Every reply is checked against a schema before it is used, every record is opened before anything of it is printed, every request has a time limit and a cap on what it reads, and nothing an error reply holds is printed: the sentences come from `src/refusal.ts`.
116
+ - `src/crypto.ts`: end-to-end encryption for an environment: the credential, key derivation, sealing and opening records, and pairing by QR code. Pure functions. `src/xwing.ts` loads the Rust core's wasm on first use: the bytes inlined in the bundle, or `../rust/dist/` when run from source. `src/crypto-device.ts` is the device's side, for the tests and the vector scripts only: nothing under `src/main.ts` imports it, and a test checks that the bundle carries none of it.
117
+ - `src/plaintext.ts`, `src/strict-json.ts`, `src/text.ts`: what a decrypted content, response, outcome or cancellation must hold, the strict JSON rules, and the rules for text (length in scalars, white space, line breaks). `src/validate.ts` builds the brief file's checks from the same rules.
118
+ - `src/post.ts`, `src/image.ts`: reading a brief file and its images, checking them, sealing, uploading and storing. `src/wait.ts`: polling.
119
+ - `src/pair.ts`, `src/pair-code.ts`, `src/pair-name.ts`, `src/qr.ts`: pairing, by pasting a credential or by QR code. `src/welcome.ts`: the welcome brief `pair` sends once it has saved the credential, and the wait for its answer.
120
+ - `src/when.ts`: `brief when`, what an agent runs once per session before its first brief: whether Briefing Room can be used here, the delay, and how to wait in this harness.
121
+ - `src/install.ts`, `src/hook.ts`, `src/delay.ts`, `src/state.ts`: the skill and Claude Code's hooks, for the user or a repository, the delay (`BRIEFING_DELAY`, then the config file's `delay`, then 3 minutes) and the wait for it, and the per-session records they share. Installed for the user, the hooks run in every session, so both first check that Briefing Room is set up and that the session's repository doesn't opt out. `src/repo.ts`: a directory's repository root, found without starting git, and the opt-out line `brief: off` in its `BRIEFING.md`.
122
+ - `src/config.ts`: the credential, the API URL, the delay and the config file. `src/log.ts`: the local log. `src/child.ts`: the one way the CLI runs `git` and `ps`, without `BRIEFING_TOKEN` in their environment.
123
+
124
+ ### Tests
125
+
126
+ - `test/cli.test.ts` runs the built CLI as a subprocess against `test/stub-server.ts`, an in-memory stand-in for the API, uploads included, that can also misbehave on purpose (drop, stall, redirect, lie). `test/phone.ts` plays the phone: it adds environments, and opens and answers what the CLI posts. `test/swipe-right.png` is a copy of the welcome brief's demo image, which the stub serves as the real server does. Every run gets a temporary `HOME`, so tests never touch your real config, `~/.claude` or `~/.agents`, and every process a test starts gets an environment without the runner's `BRIEFING_` or Claude Code variables. `BRIEFING_ROOM_POLL_INTERVAL_MS` shortens the 3-second poll for tests; the hook tests set `BRIEFING_DELAY` to a second or a few.
127
+ - `pair`'s QR code is read back by an independent decoder (jsQR) from what a terminal of a given size would show (`test/pty-run.py`, `test/scan.ts`, `test/qr.test.ts`), and its hidden prompt is tested through a pseudo-terminal (`test/pty-pair.py`) where `python3` has the `pty` module, and skipped otherwise.
128
+ - `test/crypto.test.ts`, `test/crypto-swift.test.ts` and `test/plaintext.test.ts` test the encryption and the readers against the shared vectors in `../vectors`, which other implementations are tested against too: a change that makes them fail has changed a byte format. They also check that the committed vectors are what the scripts in `scripts/` write. `test/plaintext.test.ts` also fails when a file under `src`, `test` or `scripts` holds a raw invisible or look-alike character, since a tool that normalises a file could change one unseen; write those as escapes.
129
+
130
+ The last test runs the whole loop against a real server of the protocol and is skipped unless you name one, by its origin. It adds an inbox and an environment there on each run, so point it only at a server meant for testing:
131
+
132
+ ```sh
133
+ BRIEFING_TEST_API_URL=<the server's origin> npm test
134
+ ```
135
+
136
+ ### Vectors
137
+
138
+ The scripts in `scripts/` write the shared vectors:
139
+
140
+ ```sh
141
+ npm run vectors # vectors/crypto: keys.json, records.json, tampered.json (runs cargo in ../rust)
142
+ npm run vectors:pairing # vectors/crypto/pairing.json
143
+ npm run vectors:linking # vectors/crypto/linking.json
144
+ npm run cases:validation # vectors/validation/cases.json
145
+ ```
146
+
147
+ Read `vectors/crypto/README.md` before regenerating: `records.json` and `tampered.json` are sealed afresh on every run, so regenerate them only when a format changes.
148
+
149
+ ### Running it by hand
150
+
151
+ Point `HOME` at a scratch directory unless you mean to pair this computer for real:
152
+
153
+ ```sh
154
+ HOME=$(mktemp -d) node dist/brief.mjs --help
155
+ npm link # puts `brief` on PATH, pointing at dist/brief.mjs
156
+ ```
157
+
158
+ ## License
159
+
160
+ Copyright 2026 Fresko Digital LLC. Apache-2.0; see [LICENSE](LICENSE). The bundled packages' licences are in `dist/THIRD_PARTY_NOTICES.md` in the published package.