balladeer 0.0.4 → 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 (60) hide show
  1. package/LICENSE +200 -5
  2. package/README.md +154 -68
  3. package/dist/agent.d.ts +126 -0
  4. package/dist/agent.js +209 -0
  5. package/dist/cli.d.ts +34 -0
  6. package/dist/cli.js +392 -0
  7. package/dist/client.d.ts +44 -0
  8. package/dist/client.js +114 -0
  9. package/dist/commands/affected.d.ts +22 -0
  10. package/dist/commands/affected.js +122 -0
  11. package/dist/commands/check-seals.d.ts +37 -0
  12. package/dist/commands/check-seals.js +289 -0
  13. package/dist/commands/discover.d.ts +68 -0
  14. package/dist/commands/discover.js +395 -0
  15. package/dist/commands/explain.d.ts +35 -0
  16. package/dist/commands/explain.js +90 -0
  17. package/dist/commands/invite.d.ts +24 -0
  18. package/dist/commands/invite.js +197 -0
  19. package/dist/commands/mcp.d.ts +65 -0
  20. package/dist/commands/mcp.js +202 -0
  21. package/dist/commands/propose.d.ts +59 -0
  22. package/dist/commands/propose.js +262 -0
  23. package/dist/commands/repositories.d.ts +18 -0
  24. package/dist/commands/repositories.js +185 -0
  25. package/dist/commands/setup.d.ts +75 -0
  26. package/dist/commands/setup.js +1471 -0
  27. package/dist/commands/status.d.ts +35 -0
  28. package/dist/commands/status.js +482 -0
  29. package/dist/commands/touch-map.d.ts +42 -0
  30. package/dist/commands/touch-map.js +251 -0
  31. package/dist/commands/whoami.d.ts +8 -0
  32. package/dist/commands/whoami.js +79 -0
  33. package/dist/conventions.d.ts +69 -0
  34. package/dist/conventions.js +175 -0
  35. package/dist/copy.d.ts +148 -0
  36. package/dist/copy.js +459 -0
  37. package/dist/currency.d.ts +31 -0
  38. package/dist/currency.js +72 -0
  39. package/dist/gh.d.ts +80 -0
  40. package/dist/gh.js +188 -0
  41. package/dist/git.d.ts +76 -0
  42. package/dist/git.js +203 -0
  43. package/dist/markers.d.ts +76 -0
  44. package/dist/markers.js +125 -0
  45. package/dist/mcp-config.d.ts +99 -0
  46. package/dist/mcp-config.js +230 -0
  47. package/dist/release.d.ts +55 -0
  48. package/dist/release.js +67 -0
  49. package/dist/repository.d.ts +8 -0
  50. package/dist/repository.js +32 -0
  51. package/dist/seals.d.ts +48 -0
  52. package/dist/seals.js +112 -0
  53. package/dist/store.d.ts +98 -0
  54. package/dist/store.js +225 -0
  55. package/dist/touch-map.d.ts +241 -0
  56. package/dist/touch-map.js +487 -0
  57. package/dist/wire.d.ts +588 -0
  58. package/dist/wire.js +20 -0
  59. package/package.json +19 -10
  60. package/bin/balladeer.js +0 -136
package/dist/copy.js ADDED
@@ -0,0 +1,459 @@
1
+ /**
2
+ * The boundary copy, byte for byte. It is the same text in `docs/setup-boundary.md`
3
+ * and in the control plane's `/agent` instructions, and a packaging test compares
4
+ * all three, so what the command tells a person Balladeer can see cannot drift
5
+ * from what the documentation says.
6
+ *
7
+ * It describes the product's boundary, not one release's behaviour. What this
8
+ * release actually performs is stamped separately, outside this constant.
9
+ */
10
+ export const BOUNDARY_COPY = `Balladeer never receives your code. It cannot read your repository: it holds no GitHub token,
11
+ installs no GitHub App, and has no access to your files, tests, fixtures, logs, prompts, or
12
+ transcripts.
13
+
14
+ What it does receive is small and bounded. From you: the text of each promise a named person on your
15
+ team approves, the numeric ids of your repository and its GitHub owner, and the name of its default
16
+ branch. From CI: GitHub's signed statement of which repository, workflow, and run is reporting, and
17
+ for each promise the run checked, the pass or fail outcome, the exact commit it checked, and content
18
+ hashes of the verifier package and its output. Hashes cannot be turned back into your code or your
19
+ test output.
20
+
21
+ The verify job in your CI runs your tests with your checkout and has no Balladeer credential. A
22
+ separate publish job, with no checkout, sends only those outcomes and hashes.
23
+
24
+ This setup creates two credentials, both of which you control. Approving in the browser lets this
25
+ session act as you to add repositories, connect your coding agent, connect CI, and propose promises;
26
+ it cannot approve, activate, or remove anything. That session lasts a day, each use buys it another
27
+ day, and it is gone seven days after you approved it however much you used it. The coding agent's
28
+ own connection has no expiry: it lets the agent read the promises your team has approved, propose
29
+ new ones, and propose replacing, retiring, excepting, or reassigning one you already have; every one
30
+ of those waits for a named person to decide it. It can also carry out one of those acts for you, and
31
+ only this way: you open a Balladeer page in your own browser, read what the act is, sign it off
32
+ there, and read back the one-time code that page gives you. That code covers that one act on that
33
+ one thing, once, and Balladeer records you as the person who took it and the connection as the
34
+ messenger. Without a code you signed, the connection cannot approve, activate, grant, transfer,
35
+ retire, or delete anything. You can revoke either one at any time in Balladeer, and the setup
36
+ session also ends on its own.
37
+
38
+ Adding the workflow puts a check on pull requests into your default branch. That check is advisory
39
+ on Balladeer's side; whether it blocks a merge is your own branch protection.
40
+ `;
41
+ /**
42
+ * How a person gets a workspace to approve into, for an agent reading the
43
+ * setup instructions.
44
+ *
45
+ * The pairing page is one page doing two jobs, and only one of them was ever
46
+ * described: an agent whose person had no workspace read instructions that
47
+ * assumed there was one to join. The name can be carried to that page so the
48
+ * person does not retype it, and carrying it is all an agent may do. Creating a
49
+ * workspace is a person's act, so the copy says the flag pre-fills a form and
50
+ * says who presses the button, rather than leaving an agent to read a flag name
51
+ * and conclude it creates something.
52
+ *
53
+ * Byte for byte the same text as `AGENT_INSTRUCTIONS_JOIN_OR_CREATE` in the
54
+ * control plane, and a packaging test compares them: the page an agent fetches
55
+ * and the terminal it is reading cannot come to describe this differently.
56
+ */
57
+ export const JOIN_OR_CREATE = `The pairing page joins an existing workspace or makes a new one. Somebody whose team already has
58
+ a Balladeer workspace signs in and approves the code from the terminal. Somebody who is the first
59
+ person from their team signs in, names a workspace, and clicks Create, and only then is there
60
+ anything to approve into.
61
+
62
+ You can save them the typing, and nothing else. Ask what the workspace should be called, then run
63
+ \`balladeer setup --create-workspace "<name>"\` with the name they gave you. The pairing link this
64
+ command prints then carries \`?create=<name>\`, which pre-fills that name in the create form on the
65
+ pairing page. It fills the box and no more than that: the person signs in and clicks Create, and
66
+ until they do there is no workspace. An agent never creates one, and Balladeer refuses the attempt
67
+ whatever it was told in conversation. Never invent the name either. A workspace is named once and
68
+ the whole team reads it.`;
69
+ /**
70
+ * When a coding agent reads this repository's promises, and when it does not.
71
+ *
72
+ * The instruction it replaces said "retrieve by identity, never in bulk" and
73
+ * then left the choice of read to the agent, which in a repository holding a
74
+ * thousand promises means a session that opens by paging a catalog it has no
75
+ * question about. This says which read answers which situation, and names the
76
+ * one read that must never happen at session start.
77
+ *
78
+ * Byte for byte the same text in three carriers: the conventions block written
79
+ * into the customer's own instructions file, the instructions this server sends
80
+ * a host on initialize, and the `/agent` page. A packaging test compares them,
81
+ * because an agent that met one of the three and not the others would read the
82
+ * catalog on the strength of the carrier that was quiet about it.
83
+ */
84
+ export const RETRIEVAL_SCOPE = `### Reading what is already agreed
85
+
86
+ Retrieve by promise, and only when this session has a reason to. One repository here can hold a
87
+ thousand agreed promises, and a plan built from whatever survived a truncated catalog read is worse
88
+ than a plan built from none of it, because nothing tells you which half went missing.
89
+
90
+ When a person gives you a promise id, expand exactly that one with get_promise and stop there. Every
91
+ promise page carries a control that copies its id, so an id is what a person hands you when they
92
+ mean a particular promise. Ask for one rather than searching for what they meant.
93
+
94
+ Consult list_promises in two situations and no others. The person asks what this repository has
95
+ promised, in which case page the index they asked for. Or the change you are about to make touches
96
+ paths that carry promises, in which case give those paths to list_promises: it answers with the
97
+ promises whose scope overlaps them, closest first, and with the few that name no path and so cover
98
+ the whole repository. That answer is a selection rather than a page and does not continue with a
99
+ cursor, so when the total beside it is larger than what you were handed, narrow the paths rather
100
+ than asking for more.
101
+
102
+ When you do not yet know which paths you are about to touch, do not call the index at all. Work from
103
+ ids until you do, because a page you did not ask a question of is not about your change, and reading
104
+ one as though it were is how a plan quietly misses the promise it breaks.
105
+
106
+ To learn which paths those are, read \`paths\` on a list_promises answer you asked for
107
+ without paths of your own. It is the set of
108
+ repository paths this repository's promises are scoped to, deduplicated and bounded, with
109
+ \`pathsTruncated\` saying whether there were more than the answer carries. Compare the files you are
110
+ about to change against it. Nothing matching means there is nothing here to read, and saying so is a
111
+ better answer than a page of promises about somewhere else.
112
+
113
+ Never call get_promise_context at the start of a session. It answers the markers you give it, and
114
+ before you know what you are changing there are no markers to give: what comes back is a slice of
115
+ the catalog chosen by nothing. Call it once the work is in front of you, with that work's markers.
116
+
117
+ Every one of these reads is bounded and none of them returns the whole catalog. Read the total
118
+ beside the rows and the sentence in \`scope\` that says what the total is a total of, and when the
119
+ total is larger than what you were handed, page or narrow rather than planning as though you had
120
+ seen everything.`;
121
+ /**
122
+ * The two things an agent offers in a connected repository without being asked
123
+ * for them, and starts neither of on its own.
124
+ *
125
+ * Both exist because the person cannot see what the agent can. A promise nobody
126
+ * is checking looks exactly like a promise that is protected until somebody
127
+ * opens the catalog, and a proposal sitting in a browser tab is a proposal
128
+ * nobody reads. Neither of these is a licence to act: the first is a sentence
129
+ * and a question, the second is a rendering of work already done. The capture
130
+ * style stays what it was, and nothing here proposes a promise nobody asked
131
+ * for.
132
+ *
133
+ * It sits inside `CONVENTIONS_BLOCK` rather than beside it, because the block
134
+ * is what reaches a session in the customer's own repository. The control
135
+ * plane's `/agent` page carries the same bytes under its own constant, and a
136
+ * packaging test compares them.
137
+ */
138
+ export const SESSION_BEHAVIORS = `### Two things to offer without being asked
139
+
140
+ At the start of any session in this repository, before you plan anything, ask list_promises for the
141
+ promises nothing is checking yet that belong to the person you are working with: \`unverified\` true
142
+ and \`mine\` true, which is one bounded read rather than the catalog. If it returns any, say so in one
143
+ line and offer to build their verifiers now. Name each one by its one-sentence claim rather than by
144
+ an id, so the person can see which behavior is unguarded. Ask the same tool for
145
+ \`brokenSinceLastSeen\` true as well, and where that returns any, say in one line that those promises
146
+ broke since they last looked, name each by its claim, and offer to fix them. Then wait for their
147
+ answer. The offer is the whole of it, and never start building or repairing one because nobody said
148
+ no.
149
+
150
+ Theirs, and nobody else's. \`mine\` keeps the promises this person owns or agreed to, and a teammate's
151
+ unguarded promise is that teammate's to hear about: a session that opens by reading out other
152
+ people's unfinished work reads as an audit of them. \`brokenSinceLastSeen\` is that person's own by
153
+ construction and needs no \`mine\` beside it. Drop \`mine\` when this person asks what the rest of the
154
+ team has promised, and say whose promises you are showing them when you do.
155
+
156
+ When you have proposed promises, show them here as well as there. Put each proposal in the
157
+ conversation in full: its one-sentence claim, who it is for, when it applies and what must then be
158
+ true, the numbered cases that must keep working and the ones that must be caught, and every question
159
+ you left open. Then offer to finish the agreement from here, by asking for a sign-off, giving them
160
+ the page it returns and taking the one-time code that page shows them, so the browser is needed only
161
+ for signing. Give them the review link in the same message too, because some people would rather
162
+ read it there and edit it before they agree.`;
163
+ /**
164
+ * What a session may spend on reading, in three sentences.
165
+ *
166
+ * The bounded index says what one read may carry. This says how many reads
167
+ * there should be, which is the half no ceiling can enforce: an agent that
168
+ * pages the whole index and expands every row has obeyed every limit in the
169
+ * protocol and has still put the entire catalog in front of a model. So the
170
+ * budget is written where the agent reads it, beside the rule that makes it
171
+ * affordable: a row carries what it takes to rule its promise out, and an
172
+ * expansion is what you spend once a row could not.
173
+ *
174
+ * Three carriers say it, byte for byte: the block setup writes into the
175
+ * customer's own instructions file, the instructions the MCP server sends on
176
+ * initialize, and the page `/agent` serves. A packaging test holds them
177
+ * together.
178
+ */
179
+ export const FETCH_BUDGET = `Fetch by id, and only for an id the person gave you or an index row whose paths match the change in
180
+ front of you. Never enumerate the catalog. Never chain one fetch into the next to see the whole of
181
+ something: when the rows do not settle it, narrow the filter rather than expanding another promise.`;
182
+ /**
183
+ * What a coder must know before their editor opens a file inside a promise's
184
+ * own directory.
185
+ *
186
+ * A seal is broken by an ordinary edit, and the person who breaks one rarely
187
+ * meant to: a rename swept a directory, a formatter reached everything, a
188
+ * dependency upgrade rewrote an import. The cost lands on somebody else, who
189
+ * has to qualify the promise again before it protects anything. So this says
190
+ * three things in the order a coder needs them: those files are sealed, here is
191
+ * how to see which ones before you edit and before you push, and here is the
192
+ * single case where editing one is the right move.
193
+ *
194
+ * It sits inside `CONVENTIONS_BLOCK` rather than beside it, because the block
195
+ * is what reaches a session in the customer's own repository. The MCP server's
196
+ * tool guidance and the control plane's `/agent` page carry the same bytes
197
+ * under their own constants, and a packaging test compares all three.
198
+ */
199
+ export const SEALED_FILES = `### Files that are sealed, and the one reason to edit one
200
+
201
+ Every file under .continuity/promises/ is sealed. The promise that owns that directory records the
202
+ exact bytes of each file in it, so editing one, adding one there, renaming one or deleting one
203
+ breaks the seal. A promise whose seal is broken stops being checked, and it stays that way until a
204
+ named person qualifies it again, which is their afternoon rather than your commit. Nothing in there
205
+ is ordinary source: keep it out of refactors, formatting runs and dependency upgrades.
206
+
207
+ Find out which directories are sealed before you plan an edit, not after. balladeer status lists
208
+ them, and list_promises names a promise's sealed directory on its row once a verifier is bound to
209
+ it. Then, before you push, run balladeer check-seals. It prints nothing and exits zero when your
210
+ change touches no seal, and names the promise, its owner and its page when your change would break
211
+ one.
212
+
213
+ The one reason to edit a sealed file is to repair a verifier that can no longer run: something it
214
+ imports moved, or the language it is written in changed under it. Never edit one to make a failing
215
+ check pass. A check going red is the promise doing its job, and the repair for that belongs in the
216
+ behavior it protects. A repair is not finished until the promise is sealed again with the runner
217
+ this repository is pinned to. get_promise_setup carries that exact seal command, and balladeer
218
+ check-seals prints it beside any promise it names.`;
219
+ /**
220
+ * Which promises a change touches, measured rather than guessed.
221
+ *
222
+ * A promise's scope paths are what somebody typed when they agreed it, and they
223
+ * age the moment a module moves. The touch map is the measurement instead: the
224
+ * files each verifier actually executed, recorded on the customer's machine and
225
+ * sent nowhere. An agent that does not know the command exists goes on matching
226
+ * markers and never asks for the better answer sitting in the repository.
227
+ *
228
+ * The last paragraph is the whole reason the signal is named here. Whether the
229
+ * map is worth keeping is answerable only if the receipt says which fetches it
230
+ * caused, and no surface can infer that after the fact.
231
+ *
232
+ * Three carriers say it, byte for byte, and a packaging test holds them
233
+ * together.
234
+ */
235
+ export const TOUCH_MAP_GUIDANCE = `Prefer the measurement over the markers. Where this repository has a touch map, \`balladeer affected
236
+ <paths...>\` answers which promises ran the files in front of you, out of what each verifier actually
237
+ executed the last time \`balladeer touch-map\` measured it. Both commands run on this machine and
238
+ send Balladeer nothing, so you may name any path in the change.
239
+
240
+ An answer marked stale was measured against a verifier that has changed since, so read it as the
241
+ last thing anybody measured rather than as fact, and offer to run \`balladeer touch-map\` again.
242
+ Where there is no map, where it does not name your paths, or where it reports a promise it could not
243
+ measure, fall back to the paths on the index rows. The map narrows which promises are worth
244
+ fetching. It never widens what you may read: the catalog is still never enumerated, and the fetch
245
+ budget is unchanged.
246
+
247
+ When a retrieval receipt asks why you read a row, the answer for one the map named is \`touch\`.`;
248
+ /**
249
+ * The conventions block written between markers into this repository's agent
250
+ * instructions file. Fixed text, compared byte for byte by a test, because a
251
+ * block that drifts per run would rewrite a customer's committed file on every
252
+ * setup and the diff would say nothing.
253
+ */
254
+ export const CONVENTIONS_BLOCK = `## Balladeer promises
255
+
256
+ Before planning work in this repository, read the promises this team has already approved through
257
+ the Balladeer MCP server. They are the behaviors a named person has agreed the software keeps, so
258
+ your plan has to hold them, not just read them.
259
+
260
+ ${RETRIEVAL_SCOPE}
261
+
262
+ Each index row carries what it takes to rule that promise out without fetching it: the repository,
263
+ the paths it covers, its one-sentence claim, what protects it and why, and when anything last
264
+ checked it.
265
+
266
+ ${TOUCH_MAP_GUIDANCE}
267
+
268
+ ${FETCH_BUDGET}
269
+
270
+ ### When somebody asks you to protect a behavior
271
+
272
+ Somebody has asked you to protect a behavior when they say what the software must do, or must never
273
+ do again, and mean it as a rule rather than as this one bug. That is one promise, for the behavior
274
+ they named, and nothing else: if you notice others worth protecting, say so in a sentence and let
275
+ them choose, and file none of them. Never propose from a conversation that did not ask you to. A
276
+ question about how something works and a plan you were asked to sketch are not requests to record
277
+ anything, nor is a fix nobody asked you to write a rule about.
278
+
279
+ Ask before you extrapolate. Ask only what you cannot work out for yourself, ask it all in one
280
+ message, and stop at four. Four is a ceiling, not a target: two good ones are better. Then write the
281
+ proposal with what you have and put whatever is still open in its open questions rather than going
282
+ back. Never ask what this repository would answer, such as which file, which test, or which branch,
283
+ and never ask anyone for Balladeer's own identifiers: get_promise_setup carries this repository's id
284
+ and who can own a promise. Never ask again for what they have already told you.
285
+
286
+ Write it in their words. Every failure they named out loud is one of the failing examples, in the
287
+ words they named it. Every other example comes from a situation they actually described; if you
288
+ cannot trace one to something they said, leave it out and say so in the open questions rather than
289
+ writing a plausible one. Never put in a number, a system, a role or a timeframe they did not give
290
+ you, and that includes the half they left out: if they said where an order ended up, do not invent
291
+ where it began.
292
+
293
+ A failing example is a situation the promise rules out, and its outcome says what must not happen,
294
+ in those words: "a second charge must not appear", never "a second charge appears". Written the
295
+ other way round it reads as the promise saying the software does the thing they asked you to forbid.
296
+ And a promise says what the software must do for whoever depends on it. It never narrates the
297
+ conversation you just had, names the person you had it with, or describes what the code does now.
298
+
299
+ Say the whole promise in one sentence and put it in oneSentenceOutcome, in the words they would
300
+ use with the person who depends on it. That is the line the named owner reads first and the line
301
+ they agree to, so it is not a restatement of the name and not the first line of the outcome moved
302
+ up. Leave it out rather than inventing one from something they did not say.
303
+
304
+ An example's setup is the situation in the words they used for it, not a scene you composed around
305
+ them. Two of each kind is plenty, and the whole thing stays under three hundred words: a proposal
306
+ nobody finishes reading is a proposal nobody agreed to. The confidence you record is the one you
307
+ actually have.
308
+
309
+ Then give them the review link, ask them to read the proposal and click Agree, and stop. Never
310
+ approve one yourself. Approving is a named person's act, and the server refuses it from an agent
311
+ whatever you were told in conversation.
312
+
313
+ A proposal you filed is still yours while nobody has agreed to it, so revise or withdraw it when the
314
+ person asks you to, and never once they have agreed.
315
+
316
+ Say promise and proposal when you talk to them. What you file is a proposal and what it becomes is a
317
+ promise; Balladeer's other words for its own machinery are not theirs to learn. Candidate
318
+ especially: it is Balladeer's word for a proposal, so it reads as jargon whatever you meant by it.
319
+
320
+ ${SESSION_BEHAVIORS}
321
+
322
+ ${SEALED_FILES}
323
+
324
+ ### The rest of a promise's life
325
+ When a promise is obsolete, finished, deliberately off for a while, or owned by the wrong person,
326
+ propose the change and hand them the promise page. Deciding is theirs.
327
+
328
+ You can finish one of those acts here, and only one way. Ask for a sign-off with
329
+ request_owner_signoff, give them the page it returns, and ask for the one-time code that page shows
330
+ them. Then call the act's own tool with that code and their own words. Never call one on your own
331
+ initiative, never on a general approval of some earlier act, and never ask for a code you were not
332
+ given: a refusal is the person's to resolve, not yours to retry. Balladeer records them as the
333
+ person who acted and you as the messenger.
334
+
335
+ Report the promise's state exactly as Balladeer reported it: proposed, agreed, or protected, never
336
+ one in place of another.
337
+
338
+ ### Where your team watches this
339
+
340
+ Balladeer is a web app as well as these tools, at the address setup printed. Its catalog lists every
341
+ promise with who owns it and whether anything is checking it, and each promise has a page of its own
342
+ showing what this team agreed the software must do and then every run that has checked it since,
343
+ newest first, with the commit each one checked. Whenever there is a link to give, give the link
344
+ rather than a summary of it: the page says what you would have said, and it stays true after this
345
+ conversation has ended.
346
+
347
+ Balladeer also has a Slack app, which a workspace administrator installs from workspace settings.
348
+ Once it is installed, whoever owns a promise gets a direct message when theirs goes live and when a
349
+ run on the default branch breaks it. Until somebody installs it, nothing is sent anywhere, so say it
350
+ is available rather than saying they will be told.
351
+
352
+ ### Questions people ask
353
+
354
+ Answer these when they come up. Where you do not know, say so and point at the address setup
355
+ printed: a confident wrong answer about what a vendor can see is worse than no answer.
356
+
357
+ What it does: it holds the behaviors this team has agreed the software must keep, and reports
358
+ whether each one is still being kept, from this repository's own tests running in its own CI.
359
+
360
+ What it sees: the text of each promise somebody approves, this repository's numeric ids and the name
361
+ of its default branch, and from CI the pass or fail outcome, the commit checked, and content hashes.
362
+ Never the code, the tests, the fixtures, the logs, the prompts, or the transcripts.
363
+
364
+ What stopping costs: nothing that matters to their tests. The verifier package, its fixtures and the
365
+ workflow file are theirs, in their repository, running in their CI, and disconnecting changes none
366
+ of them. An administrator can download everything Balladeer holds at any time from workspace
367
+ settings, and disconnecting hands them that same download in the response that ends access.
368
+
369
+ Who can approve one: the named person who owns it, in their own browser. Not an administrator on
370
+ their behalf, and never you.
371
+
372
+ Whether it blocks a merge: no. The check is advisory on Balladeer's side, and their own branch
373
+ protection is what decides whether a failing check stops anything.
374
+
375
+ Who can invite people and change setup: a workspace administrator. A contributor can read the
376
+ workspace and propose promises, and a viewer can read it. If somebody asks you to add a teammate,
377
+ invite_teammate returns the page an administrator sends the invitation from, with the address filled
378
+ in for them to read. The tool sends nothing itself: an administrator presses Send.`;
379
+ /**
380
+ * How an agent turns a repository that has just been connected into a catalog a
381
+ * person can read. Setup's last step prints it, and the control plane's `/agent`
382
+ * page serves it byte for byte, so the instruction a connected agent reads on
383
+ * the page cannot drift from the one the command prints in the terminal.
384
+ *
385
+ * The runnable invocation is deliberately not in here. Only the server knows
386
+ * whether the package is published, and a playbook carrying a literal command
387
+ * would either name a registry version npm does not have or name somebody
388
+ * else's package. Each carrier prints that one line underneath this text.
389
+ *
390
+ * The capture rules this leans on are `CONVENTIONS_BLOCK`'s, not a second set:
391
+ * one promise per behavior, the person's own words, and never an agent
392
+ * approving anything. This says how to find the behaviors in a repository
393
+ * nobody has interviewed yet; that says how to write one down.
394
+ *
395
+ * The seam that is not shipped: a fifth source, the person's own local agent
396
+ * transcripts, would be the richest of all, because a behavior somebody argued
397
+ * about in a session is a behavior they care about. It is dark on purpose here.
398
+ * Reading it means walking files Balladeer promises never to receive, so
399
+ * shipping it needs three things this release does not have: the person's
400
+ * explicit spoken yes each time, a bounded extraction that never carries a line
401
+ * of a transcript off the machine, and the privacy test extended to plant a
402
+ * sentinel in every host's transcript directory. Until then the text below tells
403
+ * the agent not to read them, which is the visible half of the same seam:
404
+ * nothing quietly starts doing it.
405
+ */
406
+ export const DISCOVERY_PLAYBOOK = `## Discover this repository's promises
407
+
408
+ This repository is connected and holds no promises yet. Work the four sources below in order and
409
+ hand back between five and ten promises this repository already keeps. Stop at ten however much you
410
+ find: a person has to read every one of them, and eleven is where reading turns into skimming.
411
+
412
+ 1. The repository's own tests. A test that has been green for months is a behavior somebody already
413
+ decided matters. Read the test names and the assertions rather than the implementation.
414
+ 2. Merged pull requests of the last 90 days. Read the ones whose title or body says what had to keep
415
+ working, and the review comments that argued for it.
416
+ 3. Guarantee sentences in the documentation. The README, the docs directory, and the comments that
417
+ say always, never, must, or is guaranteed to. Those sentences are promises somebody already wrote
418
+ down in prose.
419
+ 4. Incidents and reverts. A revert commit, a hotfix, a postmortem note. A behavior that broke once
420
+ and was repaired on purpose is the behavior most worth protecting.
421
+
422
+ Do not read the person's local agent transcripts, and do not offer to. They are not a source in this
423
+ release, and Balladeer never receives them.
424
+
425
+ For each promise you propose:
426
+
427
+ - One promise per behavior. Two behaviors found in one source are two proposals, not one proposal
428
+ with two outcomes.
429
+ - One passing example and one failing example, both drawn from the source you found it in. The
430
+ passing example is the case the source shows working; the failing example is the case the source
431
+ shows being caught, or the regression the revert repaired. Write both in the source's own words
432
+ rather than in words of your own.
433
+ - One provenance sentence, precise enough for a person to check it without asking you: the test file
434
+ and the test's name, the pull request number, the document and its heading, or the commit that
435
+ reverted it. Put that sentence first in explicitIntent.
436
+ - Never propose a promise this repository does not keep. A source saying a behavior should exist,
437
+ where nothing in the repository does it, is a wish rather than a promise. Leave it out, and tell
438
+ the person you left it out.
439
+ - Anything you could not settle from the source goes in unresolvedQuestions. Never fill an unknown
440
+ in plausibly: an invented answer is the one thing a person cannot catch by reading.
441
+ - One confidence number from 0 to 1, saying how sure you are that this is a behavior the repository
442
+ actually keeps and that you have described it as its source describes it. Nine promises from nine
443
+ sources are not nine equally certain readings, and the person reading them is entitled to know
444
+ which one you were least sure of. Never write 1 to get past the check.
445
+
446
+ Write them all into one file, an object with a promises array, each entry shaped exactly as one
447
+ proposal file:
448
+
449
+ {"promises": [{"explicitIntent": "...", "teachBack": {"confidence": 0.9, "meaning": {"title": "..."}}}]}
450
+
451
+ An entry carries explicitIntent and teachBack, and inside teachBack only meaning, confidence,
452
+ unresolvedQuestions, and proposedOwnerId. Anything else is refused on this machine before the file
453
+ leaves it, and one bad entry means not one of them is sent.
454
+
455
+ Every promise in the file is proposed as owned by whoever ran setup, and waits for that person. The
456
+ command prints one link that opens all of them at once. Give the person that link and ask them to
457
+ read each promise and click Agree. Nothing you can run agrees to one.
458
+
459
+ File the whole catalog in one go with the discover subcommand, naming that file:`;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Whether this copy is the newest one, answered by the server on every call.
3
+ *
4
+ * Legacy customers ran a months-old command because nothing ever told them
5
+ * otherwise: the invocation in their config named a version, the version kept
6
+ * working, and a working thing announces nothing. So the server stamps what the
7
+ * newest published version is on every answer it gives a program, and this
8
+ * module is where the command notices.
9
+ *
10
+ * It is a nag, never a refusal. Refusing is the floor's job, and the floor is
11
+ * the server's to enforce; a copy that is merely behind still works, and a
12
+ * command that stopped working the day after a publish would be worse than the
13
+ * problem it fixes.
14
+ */
15
+ export declare const CLI_NEWEST_HEADER = "x-balladeer-cli-newest";
16
+ export declare const CLI_FLOOR_HEADER = "x-balladeer-cli-minimum";
17
+ export declare const CLI_ADVICE_HEADER = "x-balladeer-cli-advice";
18
+ /**
19
+ * Reads the version signals off one response.
20
+ *
21
+ * The comparison is this command's own, against the number the server named.
22
+ * The server's sentence is used for the wording when it sent one, because only
23
+ * the server knows whether the registry form or the checkout form is the line a
24
+ * person can actually run, but the decision to say anything at all is made here
25
+ * against a version this program knows for certain: its own.
26
+ */
27
+ export declare function noteServerVersion(headers: Headers): void;
28
+ /** The one line this run prints about itself, or nothing when it is current. */
29
+ export declare function updateNotice(): string | undefined;
30
+ /** For tests, and for a process that runs more than one command. */
31
+ export declare function resetUpdateNotice(): void;
@@ -0,0 +1,72 @@
1
+ import { CLI_VERSION } from "./wire.js";
2
+ /**
3
+ * Whether this copy is the newest one, answered by the server on every call.
4
+ *
5
+ * Legacy customers ran a months-old command because nothing ever told them
6
+ * otherwise: the invocation in their config named a version, the version kept
7
+ * working, and a working thing announces nothing. So the server stamps what the
8
+ * newest published version is on every answer it gives a program, and this
9
+ * module is where the command notices.
10
+ *
11
+ * It is a nag, never a refusal. Refusing is the floor's job, and the floor is
12
+ * the server's to enforce; a copy that is merely behind still works, and a
13
+ * command that stopped working the day after a publish would be worse than the
14
+ * problem it fixes.
15
+ */
16
+ export const CLI_NEWEST_HEADER = "x-balladeer-cli-newest";
17
+ export const CLI_FLOOR_HEADER = "x-balladeer-cli-minimum";
18
+ export const CLI_ADVICE_HEADER = "x-balladeer-cli-advice";
19
+ /**
20
+ * How much of the server's sentence may be printed. It is one line from the
21
+ * control plane this machine paired with, and a ceiling means a server that
22
+ * answers with pages of text cannot turn a terminal into its own output.
23
+ */
24
+ const ADVICE_LIMIT = 300;
25
+ const VERSION = /^\d{1,4}\.\d{1,4}\.\d{1,4}$/;
26
+ let notice;
27
+ function older(left, right) {
28
+ const [a, b] = [left.split(".").map(Number), right.split(".").map(Number)];
29
+ for (let index = 0; index < 3; index += 1) {
30
+ const difference = a[index] - b[index];
31
+ if (difference !== 0)
32
+ return difference < 0;
33
+ }
34
+ return false;
35
+ }
36
+ /** Control characters stripped, length bounded: a server writes words, not terminal control. */
37
+ function bounded(value) {
38
+ return value
39
+ .replace(/[\u0000-\u001f\u007f]/g, " ")
40
+ .trim()
41
+ .slice(0, ADVICE_LIMIT);
42
+ }
43
+ /**
44
+ * Reads the version signals off one response.
45
+ *
46
+ * The comparison is this command's own, against the number the server named.
47
+ * The server's sentence is used for the wording when it sent one, because only
48
+ * the server knows whether the registry form or the checkout form is the line a
49
+ * person can actually run, but the decision to say anything at all is made here
50
+ * against a version this program knows for certain: its own.
51
+ */
52
+ export function noteServerVersion(headers) {
53
+ const newest = headers.get(CLI_NEWEST_HEADER)?.trim();
54
+ if (newest === undefined || !VERSION.test(newest))
55
+ return;
56
+ if (!older(CLI_VERSION, newest))
57
+ return;
58
+ const advice = headers.get(CLI_ADVICE_HEADER);
59
+ const line = advice === null ? "" : bounded(advice);
60
+ notice =
61
+ line === ""
62
+ ? `A newer Balladeer is available (${newest}; this is ${CLI_VERSION}). Run setup --refresh, or restart this session, before continuing.`
63
+ : line;
64
+ }
65
+ /** The one line this run prints about itself, or nothing when it is current. */
66
+ export function updateNotice() {
67
+ return notice;
68
+ }
69
+ /** For tests, and for a process that runs more than one command. */
70
+ export function resetUpdateNotice() {
71
+ notice = undefined;
72
+ }
package/dist/gh.d.ts ADDED
@@ -0,0 +1,80 @@
1
+ export type CommandResult = Readonly<{
2
+ ok: boolean;
3
+ code: number | null;
4
+ stdout: string;
5
+ stderr: string;
6
+ }>;
7
+ export declare function runCommand(file: string, args: readonly string[], options?: Readonly<{
8
+ cwd?: string;
9
+ timeoutMs?: number;
10
+ /**
11
+ * The whole environment the child gets, when the caller needs to name one.
12
+ * Left out, the child inherits this process's, which is what every other
13
+ * call here wants.
14
+ */
15
+ env?: NodeJS.ProcessEnv;
16
+ }>): Promise<CommandResult>;
17
+ export type RepositoryFacts = Readonly<{
18
+ githubRepositoryId: string;
19
+ githubOwnerId: string;
20
+ defaultBranch: string;
21
+ /** Whether the person can push to, or administer, this repository. */
22
+ canWrite: boolean;
23
+ /** True when the facts came from an authenticated read. */
24
+ authenticated: boolean;
25
+ }>;
26
+ export type RepositoryLookup = Readonly<{
27
+ kind: "found";
28
+ facts: RepositoryFacts;
29
+ }>
30
+ /**
31
+ * Why the read did not happen, and what the person does about it. The two
32
+ * travel together because they came apart once: a developer with no `gh`
33
+ * installed at all was told to run `gh auth login`, which is a command they do
34
+ * not have.
35
+ */
36
+ | Readonly<{
37
+ kind: "unavailable";
38
+ reason: string;
39
+ next: string;
40
+ }>;
41
+ export declare function ghAvailable(): Promise<boolean>;
42
+ export declare function ghSignedIn(): Promise<boolean>;
43
+ /**
44
+ * Reads a repository's immutable ids, its default branch, and what the person
45
+ * may do with it.
46
+ *
47
+ * The unauthenticated read is deliberately NOT a fallback for enrolling. It
48
+ * proves nothing about who is asking, so a workspace could otherwise end up
49
+ * holding an enrollment, a CI identity, and eventually a protection claim about
50
+ * a repository nobody in it controls. It exists only so the command can render
51
+ * the do-it-by-hand block with real values.
52
+ */
53
+ export declare function readRepositoryFacts(repository: string): Promise<RepositoryLookup>;
54
+ /** The public read, for rendering the fallback block only. */
55
+ export declare function readPublicRepositoryFacts(repository: string): Promise<RepositoryLookup>;
56
+ /**
57
+ * What this machine's own GitHub access can see, so an agent has a list to
58
+ * offer instead of asking a person to type repository names from memory.
59
+ *
60
+ * Read through the person's own `gh`, exactly as every other GitHub read here
61
+ * is: Balladeer holds no GitHub token and this list never leaves the machine
62
+ * unless a person picks something off it. Archived repositories are dropped,
63
+ * because enrolling one records a claim about a repository nobody is going to
64
+ * push to again.
65
+ */
66
+ export type VisibleRepository = Readonly<{
67
+ repository: string;
68
+ canWrite: boolean;
69
+ }>;
70
+ /**
71
+ * The repositories one GitHub account or organization holds, newest first.
72
+ *
73
+ * `owner` empty means the signed-in account's own. A refusal is an empty list
74
+ * rather than an error: this is a convenience for offering a choice, and a
75
+ * person who cannot list an organization can still name a repository by hand.
76
+ */
77
+ export declare function listVisibleRepositories(owner: string | undefined, limit?: number): Promise<readonly VisibleRepository[]>;
78
+ /** The signed-in GitHub account's login, or nothing. */
79
+ export declare function ghLogin(): Promise<string | undefined>;
80
+ export declare function setRepositoryVariable(repository: string, name: string, value: string): Promise<CommandResult>;