@zabaca/zbc 0.12.0 → 0.14.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/CHANGELOG.md +174 -0
- package/package.json +6 -2
- package/src/commands/add.ts +13 -0
- package/src/commands/init.ts +1 -0
- package/src/engine/apply.ts +60 -21
- package/src/engine/destroy.ts +183 -14
- package/src/engine/discover.ts +1 -1
- package/src/engine/resolve.ts +56 -11
- package/src/utils/copy-template.ts +10 -0
- package/templates/apps/inbox/package.json +4 -2
- package/templates/apps/inbox/tsconfig.json +3 -1
- package/templates/apps/inbox/worker/api.ts +197 -0
- package/templates/apps/inbox/worker/commands.ts +299 -0
- package/templates/apps/inbox/worker/inbox-do.ts +53 -10
- package/templates/apps/inbox/worker/index.ts +15 -202
- package/templates/apps/inbox/worker/mcp.ts +49 -100
- package/templates/apps/walgit/CONTEXT.md +135 -0
- package/templates/apps/walgit/Dockerfile +40 -18
- package/templates/apps/walgit/README.md +518 -55
- package/templates/apps/walgit/e2e/README.md +100 -6
- package/templates/apps/walgit/e2e/harness.ts +262 -1
- package/templates/apps/walgit/e2e/live.ts +588 -0
- package/templates/apps/walgit/e2e/scenarios.ts +367 -5
- package/templates/apps/walgit/e2e/suite.ts +5 -5
- package/templates/apps/walgit/examples/watch.ts +209 -0
- package/templates/apps/walgit/package.json +12 -3
- package/templates/apps/walgit/registry.json +6 -11
- package/templates/apps/walgit/shared/capabilities.ts +189 -0
- package/templates/apps/walgit/shared/container-env.ts +114 -0
- package/templates/apps/walgit/shared/credentials.ts +81 -0
- package/templates/apps/walgit/shared/events.ts +277 -0
- package/templates/apps/walgit/shared/landing.ts +1241 -0
- package/templates/apps/walgit/shared/llms.ts +463 -0
- package/templates/apps/walgit/shared/outbox.ts +266 -0
- package/templates/apps/walgit/shared/policy.ts +59 -0
- package/templates/apps/walgit/shared/protocol.ts +197 -0
- package/templates/apps/walgit/shared/provenance.ts +154 -0
- package/templates/apps/walgit/shared/ref-cache.ts +181 -0
- package/templates/apps/walgit/shared/telemetry.ts +219 -0
- package/templates/apps/walgit/src/announce-main.ts +37 -0
- package/templates/apps/walgit/src/announce.ts +98 -0
- package/templates/apps/walgit/src/append-only.ts +112 -0
- package/templates/apps/walgit/src/cache.ts +172 -0
- package/templates/apps/walgit/src/cli.ts +493 -0
- package/templates/apps/walgit/src/compact.ts +25 -23
- package/templates/apps/walgit/src/delete-repo.ts +237 -0
- package/templates/apps/walgit/src/expire.ts +248 -0
- package/templates/apps/walgit/src/gc.ts +8 -16
- package/templates/apps/walgit/src/git-backend.ts +29 -0
- package/templates/apps/walgit/src/git.ts +78 -0
- package/templates/apps/walgit/src/hook-main.ts +259 -17
- package/templates/apps/walgit/src/hooks.ts +4 -3
- package/templates/apps/walgit/src/http.ts +237 -45
- package/templates/apps/walgit/src/instructions.ts +240 -0
- package/templates/apps/walgit/src/keys.ts +126 -0
- package/templates/apps/walgit/src/limits.ts +158 -0
- package/templates/apps/walgit/src/materialize.bench.ts +10 -10
- package/templates/apps/walgit/src/materialize.ts +48 -40
- package/templates/apps/walgit/src/mkdir-lock.ts +66 -0
- package/templates/apps/walgit/src/orphans.ts +2 -5
- package/templates/apps/walgit/src/pending.ts +201 -0
- package/templates/apps/walgit/src/push-cert.ts +254 -0
- package/templates/apps/walgit/src/push.ts +233 -46
- package/templates/apps/walgit/src/reconcile.ts +5 -8
- package/templates/apps/walgit/src/repo.ts +22 -77
- package/templates/apps/walgit/src/server.ts +148 -26
- package/templates/apps/walgit/src/signers.ts +577 -0
- package/templates/apps/walgit/src/store-env.ts +5 -4
- package/templates/apps/walgit/src/store.ts +47 -24
- package/templates/apps/walgit/src/usage.ts +404 -0
- package/templates/apps/walgit/src/verify.ts +171 -0
- package/templates/apps/walgit/src/wal-index.ts +189 -11
- package/templates/apps/walgit/tsconfig.json +8 -2
- package/templates/apps/walgit/tsconfig.worker.json +24 -0
- package/templates/apps/walgit/worker/events-do.ts +259 -0
- package/templates/apps/walgit/worker/index.ts +572 -0
- package/templates/apps/walgit/wrangler.jsonc +95 -0
- package/templates/apps/warehouse/package.json +1 -1
- package/templates/infra/modules/cloudflare/index.ts +93 -67
- package/templates/infra/modules/cloudflare-access/index.ts +3 -3
- package/templates/infra/modules/cloudflare-api/index.ts +144 -32
- package/templates/infra/modules/cloudflare-api/registry.json +1 -1
- package/templates/infra/modules/cloudflare-email/index.ts +103 -144
- package/templates/infra/modules/cloudflare-email/registry.json +1 -1
- package/templates/infra/modules/cloudflare-token/index.ts +10 -30
- package/templates/infra/modules/cloudflare-token/registry.json +1 -1
- package/templates/infra/modules/cloudflare-tunnel/index.ts +3 -3
- package/templates/infra/modules/cloudflare-zone/index.ts +2 -2
- package/templates/infra/modules/fly/index.ts +158 -35
- package/templates/infra/modules/host-file/index.ts +6 -7
- package/templates/infra/modules/provision-core/index.ts +21 -15
- package/templates/infra/modules/r2/index.ts +38 -55
- package/templates/infra/modules/r2/registry.json +1 -1
- package/templates/infra/modules/remote-provision/index.ts +1 -3
- package/templates/infra/modules/turso/index.ts +45 -7
- package/templates/infra/modules/vm-provision/index.ts +10 -3
- package/templates/infra/package.json +1 -1
- package/templates/infra/src/context.ts +115 -0
- package/templates/infra/src/define-module.ts +8 -2
- package/templates/infra/src/index.ts +11 -1
- package/templates/infra/src/types.ts +72 -3
- package/src/commands/add-registry.test.ts +0 -92
- package/src/commands/secret.test.ts +0 -717
- package/src/commands/vendor-mode.test.ts +0 -183
- package/src/infra-types.ts +0 -38
- package/src/utils/subtree.test.ts +0 -127
- package/templates/apps/inbox/worker/send-op.ts +0 -174
- package/templates/apps/walgit/entrypoint.sh +0 -59
- package/templates/apps/walgit/fly.toml +0 -52
- package/templates/apps/walgit/src/ssh-shell.ts +0 -36
- package/templates/apps/walgit/sshd_config +0 -38
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/llms.txt` — the long version, for an agent that came looking.
|
|
3
|
+
*
|
|
4
|
+
* There are now two documents for the same audience, and the difference
|
|
5
|
+
* between them is when they are read rather than who reads them.
|
|
6
|
+
*
|
|
7
|
+
* GET / is read IN BAND. An agent hits it because a push failed or
|
|
8
|
+
* because it is orienting mid-task, and every line costs it
|
|
9
|
+
* context it wanted to spend on the task. It stays terse.
|
|
10
|
+
* GET /llms.txt is read DELIBERATELY, by an agent or a harness that went
|
|
11
|
+
* looking for the manual. Length is close to free here, so
|
|
12
|
+
* this is where worked examples and the reasoning live.
|
|
13
|
+
*
|
|
14
|
+
* The rule that keeps them from becoming two versions of the truth: every
|
|
15
|
+
* enforced limit in both is rendered from one `Capabilities`
|
|
16
|
+
* (`shared/capabilities.ts`), derived from the environment the push path reads
|
|
17
|
+
* and never written as prose. A cap this deployment does not enforce cannot
|
|
18
|
+
* appear in either document, because neither has a constant to state it with.
|
|
19
|
+
*
|
|
20
|
+
* Markdown rather than plain text, following the llms.txt convention: the
|
|
21
|
+
* headings are the index, and a model can skim them without parsing anything.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import type { Capabilities } from './capabilities'
|
|
25
|
+
import { MAX_REFS_PER_ENTRY, MAX_WATCH_ENTRIES } from './events'
|
|
26
|
+
import { describeBytes } from './policy'
|
|
27
|
+
import { EVENTS_PATH, PROVENANCE_PATH, SIGNERS_REF } from './protocol'
|
|
28
|
+
|
|
29
|
+
/** Only GET or HEAD on the one path. Nothing else is this document. */
|
|
30
|
+
export function wantsLlms(method: string, pathname: string): boolean {
|
|
31
|
+
if (method !== 'GET' && method !== 'HEAD') return false
|
|
32
|
+
return pathname === '/llms.txt'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const hours = (n: number) => (n === 1 ? '1 hour' : `${n} hours`)
|
|
36
|
+
|
|
37
|
+
export function renderLlms(host: string, caps: Capabilities): string {
|
|
38
|
+
const ws = `wss://${host}${EVENTS_PATH}`
|
|
39
|
+
|
|
40
|
+
const limits: string[] = []
|
|
41
|
+
if (caps.publicAccess) {
|
|
42
|
+
/**
|
|
43
|
+
* The first thing an agent reads about write access, so it is the first
|
|
44
|
+
* thing the gate makes false. It is read from `namesCanRefuse` — the gate
|
|
45
|
+
* alone — unlike `## Hold a name` below, which asks for
|
|
46
|
+
* `namesCanBeClaimed`: the section teaches an agent to claim a name and
|
|
47
|
+
* must not do so where nothing can sign, whereas this sentence only says
|
|
48
|
+
* what `pre-receive` refuses, and `pre-receive` refuses on the flag by
|
|
49
|
+
* itself. On a deployment that sets it without a seed, a claimed name
|
|
50
|
+
* refuses every push, which makes unconditional writability more wrong
|
|
51
|
+
* rather than less.
|
|
52
|
+
*/
|
|
53
|
+
limits.push(
|
|
54
|
+
caps.namesCanRefuse
|
|
55
|
+
? '- **No credential.** Reads and writes take no token, no key and no account. Everything here is world-readable, and a name that has not written a **Signer List** takes a push from anyone — which is every name until someone writes one. Do not push a secret.'
|
|
56
|
+
: '- **No credential.** Reads and writes take no token, no key and no account. Everything here is world-readable and world-writable. Do not push a secret.',
|
|
57
|
+
)
|
|
58
|
+
} else {
|
|
59
|
+
limits.push(
|
|
60
|
+
'- **A credential is required.** Send it as the Basic-auth password: `git clone https://walgit:$TOKEN@' +
|
|
61
|
+
host +
|
|
62
|
+
'/my-thing.git`.',
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
limits.push(
|
|
66
|
+
'- **A repository is created by its first push.** Names are one segment, claimed first-come, never reassigned. Put a random suffix on the name: many agents run near-identical prompts at the same time, and a taken name means a refused push.',
|
|
67
|
+
)
|
|
68
|
+
if (caps.appendOnly) {
|
|
69
|
+
// The second half is gated for the same reason the bullet above it is:
|
|
70
|
+
// "safe to hand a repository to a stranger: they can build on it" is the
|
|
71
|
+
// same promise of unconditional writability one bullet later, and a list
|
|
72
|
+
// that corrects one entry and leaves the next one contradicting it has not
|
|
73
|
+
// been corrected. What append-only guarantees does not change — who may
|
|
74
|
+
// push at all is what the gate narrows.
|
|
75
|
+
limits.push(
|
|
76
|
+
`- **Refs only move forward.** A push that would rewrite history or delete a ref is refused. Adding a commit or a branch is always allowed. ${
|
|
77
|
+
caps.namesCanRefuse
|
|
78
|
+
? 'This is what makes it safe to hand an unclaimed name to a stranger: they can build on it and cannot take anything away.'
|
|
79
|
+
: 'This is what makes it safe to hand a repository to a stranger: they can build on it and cannot take anything away.'
|
|
80
|
+
}`,
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
if (caps.retentionHours !== null) {
|
|
84
|
+
limits.push(
|
|
85
|
+
`- **A repository is deleted ${hours(caps.retentionHours)} after its LAST push.** Cloning does not extend it; pushing does. This is scratch space. Copy anything that must outlive that window.`,
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
if (caps.maxPushBytes !== null) {
|
|
89
|
+
limits.push(
|
|
90
|
+
`- **A single push may not exceed ${describeBytes(caps.maxPushBytes)}.** Refused in \`pre-receive\`, before anything is uploaded.`,
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
if (caps.maxRepoBytes !== null) {
|
|
94
|
+
limits.push(`- **One repository may not exceed ${describeBytes(caps.maxRepoBytes)}** in total.`)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Signing, argued rather than merely offered.
|
|
99
|
+
*
|
|
100
|
+
* The terse document gives an agent the flag and the endpoint; this is where
|
|
101
|
+
* the two questions it will actually have get answered — what the host takes
|
|
102
|
+
* a fingerprint to MEAN, and whether not signing costs anything. Both
|
|
103
|
+
* answers are deliberately small, and saying so is the point: walgit
|
|
104
|
+
* verifies a signature and records the key, and does nothing else with it
|
|
105
|
+
* (docs/adr/0011). A manual that implied more would be describing an
|
|
106
|
+
* ownership model this host does not have.
|
|
107
|
+
*
|
|
108
|
+
* Unless it does. Where Signer Lists are on, both of those answers change —
|
|
109
|
+
* a fingerprint can be what a name is defended by, and there IS a list of
|
|
110
|
+
* allowed signers, written by whoever holds the name. The two sentences are
|
|
111
|
+
* conditioned rather than rewritten because saying "the gate exists" is what
|
|
112
|
+
* stops this document from lying; how to write one is `## Hold a name`, and
|
|
113
|
+
* this section points at it rather than repeating it.
|
|
114
|
+
*/
|
|
115
|
+
const signing = caps.signedPushes
|
|
116
|
+
? `
|
|
117
|
+
## Say who pushed
|
|
118
|
+
|
|
119
|
+
A push here can carry a **push certificate**: a small signed document naming
|
|
120
|
+
the refs it moves and a nonce this host issued. walgit verifies the signature
|
|
121
|
+
itself and records the fingerprint of the key that made it.${
|
|
122
|
+
caps.namesCanRefuse
|
|
123
|
+
? ` A name that has
|
|
124
|
+
written a **Signer List** takes pushes from the keys that list names and refuses
|
|
125
|
+
everything else; a name nobody has written one for refuses nothing, which is
|
|
126
|
+
every name until someone does. *Hold a name*, below, is how one is written.`
|
|
127
|
+
: ' Nothing is refused on the strength of it.'
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
\`\`\`sh
|
|
131
|
+
git -c gpg.format=ssh -c user.signingkey=~/.ssh/id_ed25519.pub \\
|
|
132
|
+
push --signed=if-asked https://${host}/$NAME.git HEAD:refs/heads/main
|
|
133
|
+
\`\`\`
|
|
134
|
+
|
|
135
|
+
Use \`--signed=if-asked\`, not \`--signed=yes\`. It signs where the host takes a
|
|
136
|
+
certificate and pushes normally where it does not, so one command is correct
|
|
137
|
+
everywhere and an agent never has to branch on which host it is talking to.
|
|
138
|
+
\`--signed=yes\` against a host without the capability is refused by your own git
|
|
139
|
+
before anything reaches the network.
|
|
140
|
+
|
|
141
|
+
The key costs nothing to provision: if you already push to GitHub over SSH, the
|
|
142
|
+
key you push with is the key that signs. There is nothing to register here${
|
|
143
|
+
caps.namesCanRefuse
|
|
144
|
+
? `: a
|
|
145
|
+
key walgit has never seen is accepted anywhere a Signer List does not say
|
|
146
|
+
otherwise, and the list is a file in a repository rather than an account here.`
|
|
147
|
+
: ` —
|
|
148
|
+
walgit keeps no list of allowed signers, which is exactly why it can accept a
|
|
149
|
+
key it has never seen.`
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
### Read it back
|
|
153
|
+
|
|
154
|
+
\`\`\`sh
|
|
155
|
+
curl https://${host}${PROVENANCE_PATH}?repo=$NAME
|
|
156
|
+
{"repo":"$NAME","provenance":{"refs/heads/main":{"signer":"SHA256:BMBE…","ts":"2026-08-30T19:00:00.000Z"}}}
|
|
157
|
+
\`\`\`
|
|
158
|
+
|
|
159
|
+
One entry per ref that a signed push last moved, behind the same credential a
|
|
160
|
+
clone of that repository needs. A repository nobody has signed a push to
|
|
161
|
+
answers with an empty object — that is the ordinary case, not an error.
|
|
162
|
+
|
|
163
|
+
### What a fingerprint means here, and what it does not
|
|
164
|
+
|
|
165
|
+
The identity is the **key**, not a person and not an account: neither exists on
|
|
166
|
+
this host. What walgit claims when it records a Signer is exactly one thing —
|
|
167
|
+
*this key signed this push, over this nonce, for these refs* — and the nonce is
|
|
168
|
+
what stops the certificate being replayed onto another push.
|
|
169
|
+
|
|
170
|
+
It claims nothing about who holds the key. Two pushes with the same fingerprint
|
|
171
|
+
came from the same key; whether that is the same agent is between you and
|
|
172
|
+
whoever published the key. Matching a fingerprint against one you already trust
|
|
173
|
+
— from a GitHub profile, a prior message, your own \`~/.ssh\` — is the reader's
|
|
174
|
+
job, and it is the only thing that turns a fingerprint into a person.
|
|
175
|
+
|
|
176
|
+
${
|
|
177
|
+
caps.namesCanRefuse
|
|
178
|
+
? `**Unsigned pushes are ordinary, until a name says otherwise.** Signing is not
|
|
179
|
+
authentication and buys no access by itself: an unsigned push lands exactly as a
|
|
180
|
+
signed one does, to the same names, with the same rules, on every name nobody
|
|
181
|
+
has claimed — which is every name until someone writes a Signer List for one. A
|
|
182
|
+
name that has written one takes pushes from the keys that list names and refuses
|
|
183
|
+
everything else, saying so in the refusal. Reads are never gated, a claimed
|
|
184
|
+
repository stays world-readable, and no name is owned by the key that merely
|
|
185
|
+
pushed to it first — only by the list it wrote.`
|
|
186
|
+
: `**Unsigned pushes are ordinary.** Signing is not authentication and buys no
|
|
187
|
+
access: an unsigned push lands exactly as a signed one does, to the same names,
|
|
188
|
+
with the same rules. Nothing here is refused for being anonymous, no name is
|
|
189
|
+
owned by the key that first pushed it, and a repository with a recorded Signer
|
|
190
|
+
is still world-writable by anyone. If provenance ever starts refusing things,
|
|
191
|
+
it will say so on this page first.`
|
|
192
|
+
}
|
|
193
|
+
`
|
|
194
|
+
: ''
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The one sentence in the section below that is rendered rather than written:
|
|
198
|
+
* on a deployment that collects idle repositories, idle expiry IS the way
|
|
199
|
+
* back from a lost key, and on one that does not there is none. Claiming
|
|
200
|
+
* either on the wrong deployment is the drift every limit here is rendered
|
|
201
|
+
* to avoid.
|
|
202
|
+
*/
|
|
203
|
+
const lostKey =
|
|
204
|
+
caps.retentionHours === null
|
|
205
|
+
? 'A lost key ends the name: nobody can push to it again.'
|
|
206
|
+
: `Where a key is lost, ${hours(caps.retentionHours)} without a push collects the repository
|
|
207
|
+
and frees the name with it — the only way back.`
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Ownership, taught where an agent went looking for it.
|
|
211
|
+
*
|
|
212
|
+
* This is the discovery ADR-0012 chose: `GET /` gains nothing, because it is
|
|
213
|
+
* read mid-task and has a byte budget, and because ownership's failure lands
|
|
214
|
+
* on our server in our words at the moment it is relevant. The refusal
|
|
215
|
+
* teaches whoever hit it; this teaches whoever came looking first.
|
|
216
|
+
*
|
|
217
|
+
* Every spelling here is the one `src/signers.ts` refuses with — the ref, the
|
|
218
|
+
* file name, `ssh-keygen -lf`, "a grant governs the NEXT push", the two ways
|
|
219
|
+
* a list is refused — so an agent that reads this and an agent that reads a
|
|
220
|
+
* refusal are not being told about two different files.
|
|
221
|
+
*
|
|
222
|
+
* "List two keys" is a subsection rather than a footnote on purpose. The
|
|
223
|
+
* single-key list is the shape an agent writes by default and the one with no
|
|
224
|
+
* way back: there is no escrow and no support address here, and the ADR
|
|
225
|
+
* bounded a lost key with multi-key lists, revocation, and idle expiry where
|
|
226
|
+
* a deployment has it.
|
|
227
|
+
*
|
|
228
|
+
* `namesCanBeClaimed`, never the gate alone: with no nonce seed nothing can
|
|
229
|
+
* sign, so every push to a claimed name is refused as unsigned and no client
|
|
230
|
+
* can sign its way out. Teaching an agent to claim a name there would hand it
|
|
231
|
+
* a command that cannot work — the same defect as a cap nothing enforces.
|
|
232
|
+
*/
|
|
233
|
+
const ownership = caps.namesCanBeClaimed
|
|
234
|
+
? `
|
|
235
|
+
## Hold a name
|
|
236
|
+
|
|
237
|
+
Every name here is free until somebody claims it, and claiming one is a push. A
|
|
238
|
+
repository that has written a **Signer List** to \`${SIGNERS_REF}\` takes
|
|
239
|
+
pushes signed by the keys that list names and refuses everything else, saying
|
|
240
|
+
so. A name nobody has written one for refuses nothing.
|
|
241
|
+
|
|
242
|
+
The list is a commit whose tree holds a file called \`signers\`: one SSH key
|
|
243
|
+
fingerprint per line, blank lines and \`#\` comments ignored. A fingerprint is
|
|
244
|
+
what \`ssh-keygen -lf <key>\` prints.
|
|
245
|
+
|
|
246
|
+
\`\`\`
|
|
247
|
+
# laptop
|
|
248
|
+
SHA256:BMBEMXbMBsnjXwgNs+86IiJrPgYlZEsWxaKZW/2/1dw
|
|
249
|
+
# the key that is not on the laptop
|
|
250
|
+
SHA256:oGJ8Ai9nQ5wnTfEEqcnybGDBTBYRhLKlbBLXSpOfZ0Y
|
|
251
|
+
\`\`\`
|
|
252
|
+
|
|
253
|
+
### Claim one
|
|
254
|
+
|
|
255
|
+
\`\`\`sh
|
|
256
|
+
set -e -o pipefail
|
|
257
|
+
git init -q claim && cd claim
|
|
258
|
+
ssh-keygen -lf ~/.ssh/id_ed25519.pub | awk '{print $2}' > signers
|
|
259
|
+
ssh-keygen -lf ~/.ssh/id_backup.pub | awk '{print $2}' >> signers
|
|
260
|
+
git add signers
|
|
261
|
+
git -c user.email=agent@localhost -c user.name=agent commit -qm claim
|
|
262
|
+
git -c gpg.format=ssh -c user.signingkey=~/.ssh/id_ed25519.pub \\
|
|
263
|
+
push --signed=if-asked https://${host}/$NAME.git HEAD:${SIGNERS_REF}
|
|
264
|
+
\`\`\`
|
|
265
|
+
|
|
266
|
+
The first line is load-bearing. A key file that is not there must stop this,
|
|
267
|
+
because the alternative is a half-written list claiming the name with one key —
|
|
268
|
+
or with the wrong one, if the key that signs is the one that was missing.
|
|
269
|
+
|
|
270
|
+
The list has its own history and nothing in your working repository changes to
|
|
271
|
+
write one. What changes is every push after it: from here on, a push to this
|
|
272
|
+
name — yours included, and to any ref — must carry a signature from a key the
|
|
273
|
+
list names. Only the founding push is free, because **a grant governs the next
|
|
274
|
+
push**: the list that judges a push is the one that stood before it, and before
|
|
275
|
+
the founding push there was none.
|
|
276
|
+
|
|
277
|
+
### List two keys
|
|
278
|
+
|
|
279
|
+
There is no recovery for a lost key: no escrow, no proof of identity, no support
|
|
280
|
+
address. A second key — another machine, or one kept where the first is not — is
|
|
281
|
+
the whole of the recovery story, and the one-key list is the shape most agents
|
|
282
|
+
write.
|
|
283
|
+
${lostKey}
|
|
284
|
+
|
|
285
|
+
### Grant and revoke
|
|
286
|
+
|
|
287
|
+
Both are a commit on the same ref, pushed by a key the list already names:
|
|
288
|
+
adding a line grants, removing one revokes. A grant governs the NEXT push, so an
|
|
289
|
+
agent that was just added should retry once the granting push has landed. A
|
|
290
|
+
revoked key is refused from its next push onward, and revoking it undoes nothing
|
|
291
|
+
that key already pushed. Nothing here is retroactive.${
|
|
292
|
+
caps.appendOnly
|
|
293
|
+
? ` Refs only move
|
|
294
|
+
forward here, so nothing it pushed can be taken away afterwards either.`
|
|
295
|
+
: ''
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
### Read a list
|
|
299
|
+
|
|
300
|
+
\`\`\`sh
|
|
301
|
+
# is this name claimed at all? the ref exists, or it does not.
|
|
302
|
+
git ls-remote https://${host}/$NAME.git ${SIGNERS_REF}
|
|
303
|
+
|
|
304
|
+
# the keys themselves. a clone does not fetch refs/walgit/*, so ask for it.
|
|
305
|
+
git fetch -q https://${host}/$NAME.git ${SIGNERS_REF} && git cat-file -p FETCH_HEAD:signers
|
|
306
|
+
|
|
307
|
+
# or read the copy the refusal reads, without a repository to fetch into.
|
|
308
|
+
curl https://${host}${PROVENANCE_PATH}?repo=$NAME
|
|
309
|
+
{"repo":"$NAME","provenance":{…},"claim":{"signers":["SHA256:BMBE…"],"ts":"2026-08-30T19:00:00.000Z"}}
|
|
310
|
+
\`\`\`
|
|
311
|
+
|
|
312
|
+
The ref is the authority and \`claim\` is a copy of it, kept so that the refusal
|
|
313
|
+
in \`pre-receive\` never has to read a git object. \`claim\` is **omitted** for a
|
|
314
|
+
name nobody has claimed, which is most of them.
|
|
315
|
+
|
|
316
|
+
Reads are gated by none of this. A claimed repository, its list and its
|
|
317
|
+
provenance stay as readable as they were, to anyone who can read the rest.
|
|
318
|
+
|
|
319
|
+
### Two lists that are refused
|
|
320
|
+
|
|
321
|
+
An **empty** list, and one walgit **cannot read**, are refused on claimed and
|
|
322
|
+
unclaimed names alike — deleting the ref is the empty case spelled differently.
|
|
323
|
+
An empty list would hand the name to the next stranger, which is a way to lose
|
|
324
|
+
it rather than a way to release it; an unreadable one would leave you believing
|
|
325
|
+
you hold a name the host still thinks is free. To hand a name on, push a list
|
|
326
|
+
naming the other key. To stop using it, stop pushing.
|
|
327
|
+
`
|
|
328
|
+
: ''
|
|
329
|
+
|
|
330
|
+
const events = caps.events
|
|
331
|
+
? `
|
|
332
|
+
## Know when a ref moves, without asking
|
|
333
|
+
|
|
334
|
+
There is no webhook to configure and no endpoint to run. Open a WebSocket to \`${ws}\`, say what you care about, and the host talks down it. The connection is outbound, so a sandbox with no ingress is not a problem.
|
|
335
|
+
|
|
336
|
+
\`\`\`
|
|
337
|
+
-> {"watch":[{"repo":"my-thing","refs":["refs/heads/main"]}]}
|
|
338
|
+
<- {"ok":true,"refs":[{"repo":"my-thing","ref":"refs/heads/main","sha":"a1b2c3…"}]}
|
|
339
|
+
<- {"repo":"my-thing","ref":"refs/heads/main","sha":"d4e5f6…"}
|
|
340
|
+
\`\`\`
|
|
341
|
+
|
|
342
|
+
The first reply is current state for everything you named, so connecting and catching up are one operation. After that you get one message per ref that moves, and nothing in between.
|
|
343
|
+
|
|
344
|
+
Events are **latest state, not a log**. There is no cursor, no replay and no timer: if the socket drops, reconnect and the reply to your next \`watch\` is current state. Nothing is owed to you in between, which is why there is nothing to resume.
|
|
345
|
+
|
|
346
|
+
Omit \`refs\` to watch every ref in a repository. A \`sha\` of \`null\` means the ref is gone.
|
|
347
|
+
|
|
348
|
+
### The published client
|
|
349
|
+
|
|
350
|
+
\`\`\`sh
|
|
351
|
+
bunx @zabaca/agentgit watch # npx works too; no dependencies
|
|
352
|
+
\`\`\`
|
|
353
|
+
|
|
354
|
+
Run it inside a clone and there is nothing left to decide: it reads the host and the repository from the remote, and the ref from the branch you are on. On each event it fetches — and only fetches. Your branch, your working tree and any work in progress are left alone, because a watcher that moved branches under a working agent would be a menace.
|
|
355
|
+
|
|
356
|
+
| flag | what it is for |
|
|
357
|
+
| --- | --- |
|
|
358
|
+
| \`--once\` | exit 0 after the first ref moves. **This is the handoff primitive**: block until the other agent pushes, then carry on. |
|
|
359
|
+
| \`--on '<cmd>'\` | run a shell command in the clone after a fetch. \`$AGENTGIT_REPO\`, \`$AGENTGIT_REF\` and \`$AGENTGIT_SHA\` are set. |
|
|
360
|
+
| \`--json\` | one JSON object per line instead of prose — parse this rather than the prose. |
|
|
361
|
+
| \`--ref <ref>\` | a full ref name, repeatable. Defaults to the branch you are on; \`--all-refs\` for every ref. |
|
|
362
|
+
| \`<repo>=<dir>\` | watch several checkouts on one socket. |
|
|
363
|
+
| \`--host\`, \`--token\` | for a deployment the remote does not name, or one that needs a credential. |
|
|
364
|
+
|
|
365
|
+
\`\`\`
|
|
366
|
+
{"event":"watching","host":"${host}","repos":["my-thing"]}
|
|
367
|
+
{"event":"fetched","ref":"refs/heads/main","sha":"d4e5f6…","current":true}
|
|
368
|
+
{"event":"collides","ref":"refs/heads/main","paths":["src/index.ts"]}
|
|
369
|
+
\`\`\`
|
|
370
|
+
|
|
371
|
+
### The whole client, without installing anything
|
|
372
|
+
|
|
373
|
+
The client above is a convenience, not a dependency. The protocol is one socket and one JSON message, so if you would rather not install anything:
|
|
374
|
+
|
|
375
|
+
\`\`\`sh
|
|
376
|
+
bun -e 'const w=new WebSocket("${ws}")
|
|
377
|
+
w.onopen=()=>w.send(JSON.stringify({watch:[{repo:"my-thing"}]}))
|
|
378
|
+
w.onmessage=e=>JSON.parse(e.data).ok||Bun.spawnSync(["git","fetch"])
|
|
379
|
+
w.onclose=()=>process.exit(75)' &
|
|
380
|
+
\`\`\`
|
|
381
|
+
|
|
382
|
+
It exits when the socket closes so a supervisor restarts it, and the new handshake catches up whatever moved meanwhile. No cursor, no state file, no keepalive. A longer version that watches several repositories on one socket ships with walgit at \`examples/watch.ts\`.
|
|
383
|
+
|
|
384
|
+
### Did it land on top of me
|
|
385
|
+
|
|
386
|
+
The question worth asking after a fetch, and what \`collides\` above is reporting. git answers it without touching your working tree:
|
|
387
|
+
|
|
388
|
+
\`\`\`sh
|
|
389
|
+
WIP=$(git stash create)
|
|
390
|
+
git merge-tree --write-tree --name-only \${WIP:-HEAD} origin/main
|
|
391
|
+
\`\`\`
|
|
392
|
+
|
|
393
|
+
\`stash create\` is the part that matters: \`merge-tree\` compares commits, so uncommitted edits — the normal state of an agent mid-task — are invisible to it otherwise.
|
|
394
|
+
|
|
395
|
+
| exit | meaning |
|
|
396
|
+
| --- | --- |
|
|
397
|
+
| 0 | no collision, including when you are simply behind — the merge is a fast-forward |
|
|
398
|
+
| 1 | collision; the tree oid is line one, then one path per line |
|
|
399
|
+
| other | git could not answer (unrelated histories, and similar). Not the same as "no collision" — say nothing rather than send somebody to reconcile a conflict that does not exist. |
|
|
400
|
+
|
|
401
|
+
Report it when it CHANGES, not on every event. A collision that is still there is still true, but an agent told the same thing on every unrelated push learns to ignore the channel.
|
|
402
|
+
|
|
403
|
+
### The rest of the wire
|
|
404
|
+
|
|
405
|
+
One message can name several repositories, and a deleted ref arrives as a null sha:
|
|
406
|
+
|
|
407
|
+
\`\`\`
|
|
408
|
+
-> {"watch":[{"repo":"my-thing","refs":["refs/heads/main"]},{"repo":"other"}]}
|
|
409
|
+
<- {"repo":"my-thing","ref":"refs/heads/gone","sha":null}
|
|
410
|
+
\`\`\`
|
|
411
|
+
|
|
412
|
+
There is no \`seq\` field and no cursor anywhere in this protocol. The omission is deliberate: no client should be written against a resume point the host will not honour.
|
|
413
|
+
|
|
414
|
+
Limits: at most **${MAX_WATCH_ENTRIES} repositories** per connection and **${MAX_REFS_PER_ENTRY} refs** per repository, and there is no wildcard. Over either, the subscription is refused with a message naming the cap and what you asked for. A socket that stops draining is closed rather than buffered; reconnect and the handshake makes you current.
|
|
415
|
+
|
|
416
|
+
Use the same credential a clone needs. A public deployment has a public stream.
|
|
417
|
+
`
|
|
418
|
+
: ''
|
|
419
|
+
|
|
420
|
+
return `# ${host}
|
|
421
|
+
|
|
422
|
+
A git host for agents. Push to a name and the repository exists. There is no account to create, no repository to create first, and no API besides git itself.
|
|
423
|
+
|
|
424
|
+
Smart-HTTP is the only transport.
|
|
425
|
+
|
|
426
|
+
## Before you push
|
|
427
|
+
|
|
428
|
+
${limits.join('\n')}
|
|
429
|
+
|
|
430
|
+
## Push something you already have
|
|
431
|
+
|
|
432
|
+
\`\`\`sh
|
|
433
|
+
NAME=my-project-$(openssl rand -hex 4)
|
|
434
|
+
git remote add walgit https://${host}/$NAME.git
|
|
435
|
+
git push walgit HEAD:refs/heads/main
|
|
436
|
+
\`\`\`
|
|
437
|
+
|
|
438
|
+
## Start from nothing
|
|
439
|
+
|
|
440
|
+
\`\`\`sh
|
|
441
|
+
NAME=scratch-$(openssl rand -hex 4)
|
|
442
|
+
git init . && git add -A
|
|
443
|
+
git -c user.email=agent@localhost -c user.name=agent commit -m first
|
|
444
|
+
git push https://${host}/$NAME.git HEAD:refs/heads/main
|
|
445
|
+
\`\`\`
|
|
446
|
+
|
|
447
|
+
## Read somebody else's work
|
|
448
|
+
|
|
449
|
+
\`\`\`sh
|
|
450
|
+
git clone https://${host}/$NAME.git
|
|
451
|
+
\`\`\`
|
|
452
|
+
|
|
453
|
+
Handing work to another agent is the URL and nothing else. There is no owner to ask, no invitation to send and no review to pass.
|
|
454
|
+
${signing}${ownership}${events}
|
|
455
|
+
## If a push is refused
|
|
456
|
+
|
|
457
|
+
Read the message. A refusal names what it refused and what to do instead — it is not a transport failure, and retrying the same push unchanged will not help. The usual cause is a name already held by an unrelated history: push to a new one.
|
|
458
|
+
|
|
459
|
+
## What this is not
|
|
460
|
+
|
|
461
|
+
Not a forge: no pull requests, no code review, no CI, no issues.${caps.publicAccess ? ' Not private: everything here is readable by everyone.' : ''}${caps.retentionHours !== null ? ` Not permanent: ${hours(caps.retentionHours)} from the last push, a repository is collected.` : ' Not an archive: nothing here is a promise to keep your history.'} Not a place for anything you cannot lose.
|
|
462
|
+
`
|
|
463
|
+
}
|