@davidvornholt/standards 0.25.0 → 0.26.1
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/README.md +247 -41
- package/package.json +5 -4
- package/src/creds-cloudflare.ts +2 -0
- package/src/creds-github-apps.ts +2 -0
- package/src/creds-plan.ts +2 -0
- package/src/creds-sops-editor.ts +0 -1
- package/src/creds-store-lock-lease.ts +1 -1
- package/src/creds-store.ts +3 -0
- package/src/dev-env-brokered-resolve.ts +2 -0
- package/src/github-graphql.ts +2 -0
- package/src/poller-codex.ts +3 -0
- package/src/structure-bun-version.ts +12 -0
- package/src/structure-check.ts +2 -0
- package/src/structure-profile.ts +5 -4
package/README.md
CHANGED
|
@@ -1,59 +1,265 @@
|
|
|
1
1
|
# @davidvornholt/standards
|
|
2
2
|
|
|
3
|
-
CLI for
|
|
3
|
+
CLI for initializing, synchronizing, and validating repositories that consume [`davidvornholt/standards`](../../README.md).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
Start a new repository without a prior installation:
|
|
4
8
|
|
|
5
9
|
```sh
|
|
6
10
|
bunx @davidvornholt/standards init
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
standards
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
bun install
|
|
12
|
+
bun run check
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Adopt an existing repository by installing the exact package first:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
bun add --dev --exact @davidvornholt/standards
|
|
19
|
+
bun standards init
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Read the [adoption guide](../../docs/adoption.md) before running `init` in a repository that already has agent instructions, Just recipes, Dependabot configuration, or Claude skills.
|
|
23
|
+
|
|
24
|
+
## Commands
|
|
25
|
+
|
|
26
|
+
| Command | Purpose |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| `init` | Seed project-owned files, mirror canonical paths, generate owned output, and create the lock. |
|
|
29
|
+
| `sync` | Mirror the selected upstream revision and update the lock. |
|
|
30
|
+
| `check` | Verify drift, extension points, structure, generated output, and GitHub settings. |
|
|
31
|
+
| `doctor` | Validate integration points without checking lock-backed drift. |
|
|
32
|
+
| `structure` | Validate the monorepo contract. |
|
|
33
|
+
| `dependabot` | Verify or regenerate `.github/dependabot.yml`. |
|
|
34
|
+
| `dev-env` | Generate workspace `.env.local` files. |
|
|
35
|
+
| `github` | Compare or converge live repository settings. |
|
|
36
|
+
| `creds` | Mint and reconcile brokered credentials. |
|
|
37
|
+
| `screenshots` | Publish pull-request screenshots through the configured bucket. |
|
|
38
|
+
| `poller` | Run one approved fix or review automation tick. |
|
|
39
|
+
| `help` | Print command and option help. |
|
|
40
|
+
|
|
41
|
+
Use `bun standards help`, `bun standards creds help`, or `bun standards screenshots help` for the complete invocation syntax.
|
|
42
|
+
|
|
43
|
+
## init
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
bun standards init [--dir <repo>] [--from <source>] [--ref <ref>]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`init` is a one-time ownership cutover. It:
|
|
50
|
+
|
|
51
|
+
1. seeds missing project-owned files from `template/`;
|
|
52
|
+
2. mirrors every canonical path in `sync-standards.json`;
|
|
53
|
+
3. regenerates engine-owned output;
|
|
54
|
+
4. writes `sync-standards.lock`.
|
|
55
|
+
|
|
56
|
+
Existing project-owned files are kept. Synced files are replaced. `init` refuses after a lock exists and refuses before writing when a managed destination is a directory containing unowned work.
|
|
57
|
+
|
|
58
|
+
## sync
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
bun standards sync --dry-run
|
|
62
|
+
bun standards sync
|
|
63
|
+
bun standards sync --ref v0.26.1
|
|
64
|
+
bun standards sync --from ../standards
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`sync` mirrors canonical files and symlinks, removes canonical paths deleted upstream, regenerates `.github/dependabot.yml`, and rewrites the lock.
|
|
68
|
+
|
|
69
|
+
`--dry-run` prints the full plan without writing. `--ref` selects a tag, branch, or full commit SHA for a remote source. `--from` accepts another GitHub source or a local checkout.
|
|
70
|
+
|
|
71
|
+
A local source is useful for testing unpublished canonical changes, but its lock may describe content that does not exist upstream. Discard that test state afterward. See [Sync and ownership](../../docs/sync-and-ownership.md#test-an-unpublished-canonical-change).
|
|
72
|
+
|
|
73
|
+
## check
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
bun standards check
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The command fails when:
|
|
80
|
+
|
|
81
|
+
- a lock-backed canonical path changed, disappeared, or has the wrong path type;
|
|
82
|
+
- a required extension point is missing or invalid;
|
|
83
|
+
- generated Dependabot output differs from its inputs;
|
|
84
|
+
- the monorepo structure contract fails;
|
|
85
|
+
- the CI secret files have an invalid encrypted or example shape;
|
|
86
|
+
- declared GitHub settings differ from live state or cannot be verified.
|
|
87
|
+
|
|
88
|
+
The canonical workflow performs the live GitHub comparison in its restricted aggregator job. Local checks use the available `gh`, `GH_TOKEN`, or `GITHUB_TOKEN` authentication.
|
|
89
|
+
|
|
90
|
+
## doctor and structure
|
|
91
|
+
|
|
92
|
+
```sh
|
|
93
|
+
bun standards doctor
|
|
94
|
+
bun standards structure
|
|
95
|
+
bun standards structure --profile source
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`doctor` checks project-owned integration points such as `biome.jsonc`, `AGENTS.local.md`, package scripts, sync policy, settings overlays, and Dependabot inputs.
|
|
99
|
+
|
|
100
|
+
`structure` checks the exact Bun declaration, workspace scripts, internal dependency versions, package exports, TypeScript inheritance, accessibility wiring, workspace READMEs, and CI secret structure. The `source` profile records the few intentional differences in this repository itself.
|
|
101
|
+
|
|
102
|
+
## dependabot
|
|
103
|
+
|
|
104
|
+
```sh
|
|
105
|
+
bun standards dependabot --check
|
|
106
|
+
bun standards dependabot --write
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The generated `.github/dependabot.yml` combines:
|
|
110
|
+
|
|
111
|
+
- canonical `.github/dependabot.base.yml`;
|
|
112
|
+
- project-owned `.github/dependabot.local.yml`.
|
|
113
|
+
|
|
114
|
+
The local overlay may add update blocks, private registries, and `ignore` or `registries` entries on matching canonical targets. It cannot replace canonical policy.
|
|
115
|
+
|
|
116
|
+
## dev-env
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
bun standards dev-env
|
|
120
|
+
just dev-env-generate
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Each workspace environment is composed in this order:
|
|
124
|
+
|
|
125
|
+
1. `config/dev.yaml`, tracked configuration;
|
|
126
|
+
2. `secrets/dev.yaml`, SOPS-encrypted shared secrets and reference policy;
|
|
127
|
+
3. `config/dev.local.yaml`, gitignored machine-specific overrides.
|
|
128
|
+
|
|
129
|
+
Later layers win, but one key cannot exist in both tracked layers. The command validates every destination before writing and commits all generated-file changes as one transaction.
|
|
130
|
+
|
|
131
|
+
A plain layer may reference one part of a broker-owned S3 pair:
|
|
132
|
+
|
|
133
|
+
```yaml
|
|
134
|
+
apps:
|
|
135
|
+
web:
|
|
136
|
+
R2_ACCESS_KEY_ID:
|
|
137
|
+
brokeredS3: assets
|
|
138
|
+
key: assets.web
|
|
139
|
+
part: access_key_id
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Authorize the complete pair in encrypted `secrets/dev.yaml`:
|
|
143
|
+
|
|
144
|
+
```yaml
|
|
145
|
+
brokeredReferences:
|
|
146
|
+
- assets:assets.web
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The referenced target must contain both `access_key_id` and `secret_access_key`. Every generated `.env.local`, transaction artifact, and `config/dev.local.yaml` must be ignored by Git.
|
|
150
|
+
|
|
151
|
+
## github
|
|
152
|
+
|
|
153
|
+
```sh
|
|
154
|
+
bun standards github --check
|
|
155
|
+
bun standards github --apply
|
|
29
156
|
```
|
|
30
157
|
|
|
31
|
-
|
|
158
|
+
The command merges `.github/settings.json` with `.github/settings.local.json`, then compares or converges repository settings, declared rulesets, and canonical labels. Undeclared live labels are left alone. Undeclared repository-owned rulesets are removed by `--apply`.
|
|
159
|
+
|
|
160
|
+
`--apply` needs admin authentication and rechecks the API response instead of treating an accepted request as success. A repository whose plan cannot enforce rulesets may declare `"rulesetEnforcement": "unavailable-on-plan"` in the local settings file.
|
|
161
|
+
|
|
162
|
+
## creds
|
|
163
|
+
|
|
164
|
+
The broker writes secret values directly into SOPS targets. It does not print them or pass them through command arguments.
|
|
32
165
|
|
|
33
|
-
|
|
166
|
+
### Bootstrap providers
|
|
34
167
|
|
|
35
|
-
|
|
168
|
+
```sh
|
|
169
|
+
bun standards creds login github
|
|
170
|
+
bun standards creds login github --org <org>
|
|
171
|
+
bun standards creds login cloudflare
|
|
172
|
+
bun standards creds status
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The machine-global broker store lives at `$XDG_CONFIG_HOME/standards/broker.yaml`, or `~/.config/standards/broker.yaml` by default, with owner-only permissions. It holds one private GitHub App per repository owner and one Cloudflare bootstrap token per account.
|
|
36
176
|
|
|
37
|
-
|
|
177
|
+
### Mint credentials
|
|
178
|
+
|
|
179
|
+
```sh
|
|
180
|
+
bun standards creds add github --dest ci:ci.broker_app
|
|
181
|
+
bun standards creds add cloudflare \
|
|
182
|
+
--dest ci:ci.cloudflare_workers_token \
|
|
183
|
+
--permissions "Workers Scripts Write"
|
|
184
|
+
bun standards creds add cloudflare \
|
|
185
|
+
--dest assets:assets.screenshots_rw \
|
|
186
|
+
--bucket screenshots \
|
|
187
|
+
--s3 \
|
|
188
|
+
--permissions "Workers R2 Storage Bucket Item Write"
|
|
189
|
+
```
|
|
38
190
|
|
|
39
|
-
|
|
191
|
+
Use `--zone <id>` for zone-scoped Cloudflare permissions and `--jurisdiction eu` for an EU R2 bucket. Run `bun standards creds permissions` to list accepted permission-group names.
|
|
40
192
|
|
|
41
|
-
|
|
193
|
+
### Reconcile Cloudflare tokens
|
|
42
194
|
|
|
43
|
-
`creds` is the credential broker: it mints scoped Cloudflare tokens, rotates and revokes those tokens, and places GitHub App credentials into SOPS-encrypted targets — secret values never touch stdout, argv, or an agent's context; commands print only metadata (token name, scopes, expiry, destination). Cloudflare reconciliation has exactly two sources of truth: the plaintext key structure of the SOPS files and the provider token list under the deterministic naming scheme `standards/<owner>/<repo>/<sops-target>/<dotted.key>`; there is no separate credential manifest. `plan` and `apply` reconcile Cloudflare only: each run uses the stored bootstrap credential to verify its current provider token ID, excludes that ID from reconciliation regardless of its current name, and aborts if the identity cannot be correlated with the complete account token list; a brokered token whose SOPS key was deleted is revoked, while one nearing expiry (30 days) is renewed by creating a fresh-expiry replacement with the live token's policies, durably writing and verifying the new value, and only then revoking the old token; secrets the broker did not mint are never touched. Both also report what reconciliation will never touch, in two separately labelled and separately counted blocks that never block: unmanaged tokens, meaning every unexpired token in the account whose name falls outside the reserved `standards/` namespace — with one exception, this machine's own bootstrap credential, which every run removes by verified ID before anything is classified — and tokens brokered to another repository, each printed with the repository whose `apply` owns it. An expired token is omitted from the unmanaged listing because it grants nothing. Neither block is idle information: nothing here renews or revokes those tokens, and a forgotten one — the original half of a hand-made credential that was replaced rather than retired, or a brokered token whose repository was renamed away — stays valid indefinitely, so a listed token is normally printed with the exact command that retires it, carrying `--account` and, for a token brokered elsewhere, `--force` and the one condition that justifies it. Two rows are exceptions. A token named `standards-broker` holds the reserved name for a machine's bootstrap credential, so it is either another machine's or a superseded one on this machine; `revoke` refuses it by name, so the row names the Cloudflare dashboard rather than a command that would always fail. The other exception looks like an ordinary brokered-elsewhere row, and its command fails. `plan` classifies by exact token name, so a token whose brokered repository differs from this checkout's origin only in capitalisation lands in the brokered-elsewhere block with a `--force` command; `revoke` compares repository names case-insensitively, reads the same token as this checkout's own, and refuses. Row and block header both read that token as foreign — the header labels the block tokens brokered to another repository, and the row explains the `--force` by the owning repository having been renamed, transferred, or deleted. Neither holds there: GitHub names are case-insensitive, so the owning repository is this one and it is still alive. Re-point the origin remote at the capitalisation the token carries, or retire the token in the Cloudflare dashboard. A name that claims this repository's brokered namespace without being one the broker mints is a finding instead, and findings abort reconciliation before any mutation, because reconciliation cannot own that token; plain `revoke --token-id` takes it once you decide it should go. `revoke --token-id <id>` deletes exactly one Cloudflare token, named by its 32-character hexadecimal ID, with `--account <id>` required whenever more than one account is configured; it records no ownership, so the power is momentary rather than standing and a human names the target every time. It refuses an ID the account does not hold, the bootstrap credential this machine has stored (matched by verified ID, so a rename cannot disguise it), and any other token named `standards-broker`, the reserved name for a machine's bootstrap (matched by name, because that one is another machine's bootstrap or a superseded one, retired in the Cloudflare dashboard where you can confirm whose it is — the broker cannot re-mint its own root credential). A token brokered to this repository is refused with the remedy that works here: delete its SOPS key in this repository and run `apply`, which revokes the token and keeps the secret in step. A token whose brokered name differs from this checkout's origin only in capitalisation is refused too, and without the `apply` remedy: reconciliation matches the name exactly, so from here it would neither renew nor revoke the token. Its remedies are re-pointing the origin remote at the capitalisation the token carries, which brings it back under reconciliation, or retiring it in the Cloudflare dashboard. A token brokered to a repository that is genuinely a different one is refused with that repository named, because the same `apply` remedy runs there. `--force` widens exactly that last refusal, and nothing else: it lets `revoke` delete a token whose brokered repository is not this checkout's. It verifies nothing about the state of that repository, so it is justified only when nothing reconciles the token any more — the owning repository was renamed, transferred, or deleted, and no checkout resolves to its name. `revoke` decides ownership from the origin remote and compares it case-insensitively, as GitHub names are; `plan` classifies by exact name instead, which is why the two disagree about a case-only difference. When the origin remote resolves to no GitHub repository, every brokered token is refused, `--force` included, because the check it widens is the one that could not be run. `--force` never bypasses either bootstrap guard, the case-only refusal, or that unresolvable-origin refusal. Without a manifest there is no desired-policy record, so live policy drift is not detected, and a repository rename or transfer changes the deterministic namespace and requires the visible old token to be re-minted under the new name and revoked. `add cloudflare` mints an account-owned API token (default TTL 90 days) scoped to the named permission groups (`permissions` lists the valid names) and writes it to `--dest <target>:<dotted.key>`, where `<target>` resolves like the canonical `just secrets` targets (`ci` → `secrets/ci.yaml`, `prod-1` → `infra/hosts/prod-1/secrets.yaml`). `--zone <zone-id>[,<zone-id>...]` adds a zone resource so zone-scoped groups such as DNS Write can be minted. Zones are named by their 32-character hexadecimal ID, shown on the zone's dashboard overview and not a secret; resolving a domain name instead would need Zone Read on the bootstrap token, which holds Account API Tokens / Edit and nothing else. With zones named, the selection is split by what each group can target: every group Cloudflare reports as zone-scoped forms one policy holding all named zones, and groups that can only target an account keep their own account policy on the same token, so one credential can hold DNS access next to account-wide access. A group Cloudflare reports as both takes the zone policy, which is the narrower reading of `--zone`. A group matching neither resource is named and rejected, `--zone` requires at least one zone-scoped group, and `--zone` cannot be combined with `--bucket`, which is a separate credential. The mint summary prints the resources the token reaches, so an account policy alongside the zones is visible rather than implied. `--bucket <name>` switches the policy resource to a single R2 bucket; `--jurisdiction default|eu` selects the provider jurisdiction and defaults to `default`, producing `com.cloudflare.edge.r2.bucket.<account_id>_default_<bucket>` or `com.cloudflare.edge.r2.bucket.<account_id>_eu_<bucket>`. FedRAMP jurisdictions are not supported. Bucket destinations accept only bucket-scoped groups such as Workers R2 Storage Bucket Item Read/Write, and account-scoped groups are rejected. `--s3` requires `--bucket` and stores the S3-compatible credential pair Cloudflare derives from an API token — access key ID is the token ID, secret access key is the SHA-256 hex digest of the token value — as `<dotted.key>.access_key_id` and `<dotted.key>.secret_access_key` under the destination instead of the raw token value; the default endpoint is `https://<account_id>.r2.cloudflarestorage.com`, while EU uses `https://<account_id>.eu.r2.cloudflarestorage.com`. Reconciliation infers each destination's concrete write footprint from the plaintext SOPS key structure — a bearer owns the leaf at its key, while an S3 token owns both pair leaves — and aborts before mutation when managed footprints intersect. `plan` and `apply` renew and revoke S3 destinations like any other brokered token, but renewal first proves the stored access key ID matches the current provider token; an incomplete pair, unreadable value, or identity mismatch is surfaced as a finding and never mutated automatically. `add github` selects the private broker App whose owner matches the destination repository's origin owner, checks both local SOPS leaves before authenticating, proves that the exact selected App is installed on that repository, and writes only while that full App identity still holds the synchronized broker-store entry; missing, duplicate, replaced, or mismatched owners fail before SOPS changes. Durable GitHub tokens cannot be created via API (PAT and OAuth-app creation are UI-only), so workflows mint short-lived installation tokens from the App at runtime (`actions/create-github-app-token`), scoped per repository and permission. The canonical weekly sync expects `bun standards creds add github --dest ci:ci.broker_app`, then mints a current-repository branch writer with Contents write and Workflows write plus a separate PR opener with Contents read and Pull requests write; both mint before sync but enter only their post-sync operations, and missing credentials, unapproved App permissions, or minting failures stop the workflow without a fallback. Existing broker Apps must add Workflows write on the App settings page and have every installation owner approve that permission before consumers adopt the workflow. Bootstrap is once per machine and per GitHub owner: `login github` creates a private personal App, while `login github --org <org>` creates or replaces only that organization's entry; each manifest conversion records GitHub's authoritative owner, and the command opens the installation page, where the App must be bound to selected repositories rather than all repositories. GitHub App names are globally unique and limited to 34 characters, so organization defaults include owners up to 17 characters; a longer owner or a colliding replacement name requires an explicit shorter unused `--name`. The first GitHub-specific command against an existing singleton broker store authenticates as that App, resolves its registration owner, and atomically migrates the old mapping to that one owner; a failed lookup leaves the persisted bytes untouched. If the singleton was a public App installed on repositories owned by other users or organizations, those repositories stop matching after migration because owner selection no longer treats that App as shared. For each affected owner, run `login github` while signed in as that personal owner or `login github --org <owner>`, install the new private App only on the selected repositories, run `bun standards creds add github --dest <target>:<key>` in every consumer, and verify its workflows can mint tokens. Retire the old public App only after every repository owner has its own entry, every intended SOPS destination has been reprovisioned, and token minting has been verified; until then, keep its key and installation available for any destinations not yet migrated. `login cloudflare` guides the one dashboard paste Cloudflare requires for the first account token (named `standards-broker` to match the App, created from the "Create additional tokens" token template because its "Account API Tokens: Edit" permission is unavailable in the custom token builder, and holding that permission only), verifies that it is active, correlates its verified ID with the complete account token list and an active list record, and stores it; a bootstrap token named inside the minted `standards/` namespace is rejected before storage to keep its role unambiguous, while any other divergence from the recommended name only warns. `plan` and `apply` do not rotate GitHub App keys; create a replacement key on the App's settings page, atomically replace that owner's `private_key` in the protected machine-global broker store while preserving its `0600` mode, then update every intended SOPS destination, verify workflows can mint installation tokens, and revoke the old key manually. Root credentials live in the machine-global broker store (see Configuration); SOPS writes go through `sops edit` with a non-interactive editor, preserving comments and reusing the file's data key.
|
|
195
|
+
```sh
|
|
196
|
+
bun standards creds plan
|
|
197
|
+
bun standards creds apply
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
The desired destinations are inferred from SOPS key structure. `plan` reports renewals, revocations, unmanaged tokens, and tokens owned by another repository. `apply` renews expiring brokered tokens and revokes brokered tokens whose SOPS destination was removed. It never changes credentials it did not mint.
|
|
201
|
+
|
|
202
|
+
To delete one Cloudflare token outside normal reconciliation:
|
|
203
|
+
|
|
204
|
+
```sh
|
|
205
|
+
bun standards creds revoke --account <account-id> --token-id <token-id>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Bootstrap credentials and tokens still owned by an active repository are refused.
|
|
209
|
+
|
|
210
|
+
## screenshots
|
|
211
|
+
|
|
212
|
+
```sh
|
|
213
|
+
bun standards screenshots publish docs/pr/settings-page.png docs/pr/settings-empty-state.png
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
The command reads `config/screenshots.yaml`, resolves its S3 pair from SOPS, uploads each supported image to a content-addressed key, and prints Markdown image lines in input order.
|
|
217
|
+
|
|
218
|
+
```yaml
|
|
219
|
+
pair: assets:assets.screenshots_rw
|
|
220
|
+
bucket: screenshots
|
|
221
|
+
endpoint: https://<account-id>.r2.cloudflarestorage.com
|
|
222
|
+
publicBaseUrl: https://screenshots.example.com
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Published URLs are public and permanent. Use demo data and exclude secrets and personal data.
|
|
226
|
+
|
|
227
|
+
## poller
|
|
228
|
+
|
|
229
|
+
```sh
|
|
230
|
+
bun standards poller --config <path>
|
|
231
|
+
bun standards poller --acknowledge-only --config <path>
|
|
232
|
+
bun standards poller --print-units --config <path>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
The host-level JSON configuration requires:
|
|
236
|
+
|
|
237
|
+
```json
|
|
238
|
+
{
|
|
239
|
+
"repos": ["owner/repo"],
|
|
240
|
+
"model": "<codex model>",
|
|
241
|
+
"reasoningEffort": "<effort>"
|
|
242
|
+
}
|
|
243
|
+
```
|
|
44
244
|
|
|
45
|
-
|
|
245
|
+
Optional keys are `maxJobsPerTick`, `staleClaimHours`, `runTimeoutMinutes`, `cacheDir`, and `extraCodexArgs`. One poller supports at most 12 repositories.
|
|
46
246
|
|
|
47
|
-
|
|
247
|
+
The worker accepts only exact issue or draft-PR revisions approved by a user with `admin` or `maintain` role. It runs Codex in a disposable worktree, revalidates approval before publication, and leaves merge to a human. The polling host owns authenticated `codex` and `gh`, the service token, writable home, configuration, and systemd deployment.
|
|
48
248
|
|
|
49
|
-
## Configuration
|
|
249
|
+
## Configuration index
|
|
50
250
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
251
|
+
| File or variable | Purpose |
|
|
252
|
+
| --- | --- |
|
|
253
|
+
| `sync-standards.json` | Canonical source, seed directory, and managed paths. |
|
|
254
|
+
| `sync-standards.local.json` | Optional `ref` pin and `autoSync` policy. |
|
|
255
|
+
| `sync-standards.lock` | Exact synchronized commit and managed digests. |
|
|
256
|
+
| `.github/dependabot.local.yml` | Project-owned Dependabot additions. |
|
|
257
|
+
| `.github/settings.local.json` | Project-owned GitHub settings additions. |
|
|
258
|
+
| `config/dev.yaml` | Shared non-secret development configuration. |
|
|
259
|
+
| `secrets/dev.yaml` | Shared development secrets and broker-reference policy. |
|
|
260
|
+
| `config/dev.local.yaml` | Machine-specific overrides. |
|
|
261
|
+
| `config/screenshots.yaml` | Public screenshot bucket and SOPS pair reference. |
|
|
262
|
+
| `STANDARDS_BROKER_FILE` | Optional broker-store path override. |
|
|
263
|
+
| `GH_TOKEN` or `GITHUB_TOKEN` | GitHub API authentication where required. |
|
|
58
264
|
|
|
59
|
-
|
|
265
|
+
The [root README](../../README.md) gives the short overview. The [adoption guide](../../docs/adoption.md) and [sync guide](../../docs/sync-and-ownership.md) explain repository ownership and first use.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@davidvornholt/standards",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.1",
|
|
4
4
|
"description": "Bootstrap, synchronize, and validate davidvornholt/standards consumers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -164,6 +164,7 @@
|
|
|
164
164
|
"src/screenshots-upload.ts",
|
|
165
165
|
"src/sops-exec.ts",
|
|
166
166
|
"src/structure-check.ts",
|
|
167
|
+
"src/structure-bun-version.ts",
|
|
167
168
|
"src/structure-profile.ts",
|
|
168
169
|
"src/structure-readme.ts",
|
|
169
170
|
"src/structure-secret-document.ts",
|
|
@@ -183,17 +184,17 @@
|
|
|
183
184
|
},
|
|
184
185
|
"devDependencies": {
|
|
185
186
|
"@davidvornholt/typescript-config": "0.0.0",
|
|
186
|
-
"@types/bun": "^1.
|
|
187
|
+
"@types/bun": "^1.4.2",
|
|
187
188
|
"sigstore": "5.0.0",
|
|
188
189
|
"typescript": "7.0.2"
|
|
189
190
|
},
|
|
190
191
|
"engines": {
|
|
191
|
-
"bun": ">=1.
|
|
192
|
+
"bun": ">=1.4.2"
|
|
192
193
|
},
|
|
193
194
|
"publishConfig": {
|
|
194
195
|
"access": "public"
|
|
195
196
|
},
|
|
196
197
|
"dependencies": {
|
|
197
|
-
"yaml": "^2.9.
|
|
198
|
+
"yaml": "^2.9.1"
|
|
198
199
|
}
|
|
199
200
|
}
|
package/src/creds-cloudflare.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// itself, lists and mints scoped tokens, and revokes them. Token values
|
|
4
4
|
// returned by create flow only into SOPS writers,
|
|
5
5
|
// never stdout.
|
|
6
|
+
// User-owned tokens are intentionally outside this API and the bootstrap
|
|
7
|
+
// credential's authority; they must be managed separately in Cloudflare.
|
|
6
8
|
|
|
7
9
|
import {
|
|
8
10
|
type CfResult,
|
package/src/creds-github-apps.ts
CHANGED
|
@@ -57,6 +57,8 @@ export const loadOwnedGithubStore = async (
|
|
|
57
57
|
return { ok: true, value: migrated };
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
+
// Private Apps belong to one owner. Selecting by repository owner keeps each
|
|
61
|
+
// owner's credentials separate; installation access is verified before export.
|
|
60
62
|
export const selectGithubAppForRepo = (
|
|
61
63
|
apps: ReadonlyArray<GithubBrokerApp>,
|
|
62
64
|
repo: string,
|
package/src/creds-plan.ts
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
// tokens it minted for another repository, are reported
|
|
8
8
|
// (creds-plan-unmanaged.ts) but never mutated. Execution lives in
|
|
9
9
|
// creds-plan-run.ts.
|
|
10
|
+
// Live policy is preserved, not compared with a separate desired-policy manifest.
|
|
11
|
+
// Adding policy-drift enforcement would require a new source of truth.
|
|
10
12
|
|
|
11
13
|
import { cloudflareExpiresOn } from './creds-cloudflare-expiry';
|
|
12
14
|
import { groupByIntersectingFootprint } from './creds-plan-groups';
|
package/src/creds-sops-editor.ts
CHANGED
|
@@ -143,7 +143,6 @@ export const applySopsEditorChanges = (
|
|
|
143
143
|
}
|
|
144
144
|
document.setIn(path, change.value);
|
|
145
145
|
}
|
|
146
|
-
// biome-ignore lint/nursery/noBaseToString: YAML Document implements toString as its comment-preserving serializer.
|
|
147
146
|
return document.toString();
|
|
148
147
|
};
|
|
149
148
|
const runEditor = (): void => {
|
|
@@ -24,7 +24,7 @@ export const startBrokerLockLease = (
|
|
|
24
24
|
holderPath: string,
|
|
25
25
|
intervalMs: number,
|
|
26
26
|
): Worker => {
|
|
27
|
-
const lease = new Worker(import.meta.url, {
|
|
27
|
+
const lease = new Worker(new URL(import.meta.url), {
|
|
28
28
|
workerData: { holderPath, intervalMs } satisfies LeaseWorkerData,
|
|
29
29
|
});
|
|
30
30
|
lease.unref();
|
package/src/creds-store.ts
CHANGED
|
@@ -24,6 +24,9 @@ export type BrokerStore = {
|
|
|
24
24
|
readonly cloudflare: ReadonlyArray<CloudflareBrokerAccount>;
|
|
25
25
|
};
|
|
26
26
|
export const EMPTY_BROKER_STORE: BrokerStore = { github: [], cloudflare: [] };
|
|
27
|
+
// This machine-global store trusts the local account, like its age private key.
|
|
28
|
+
// Encrypting it with a colocated key would not protect against that account.
|
|
29
|
+
// Repository secrets still belong in SOPS; this store stays outside repositories.
|
|
27
30
|
const OWNER_ONLY_FILE_MODE = 0o600;
|
|
28
31
|
const OWNER_ONLY_DIR_MODE = 0o700;
|
|
29
32
|
const FILE_MODE_MODULUS = 0o1000;
|
|
@@ -22,6 +22,8 @@ export type ResolvedDevEnv = {
|
|
|
22
22
|
readonly problems: ReadonlyArray<string>;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
+
// Each variable independently selects a complete pair and then one part.
|
|
26
|
+
// Variable names and neighboring references do not imply a shared credential.
|
|
25
27
|
const lookupReference = (
|
|
26
28
|
document: unknown,
|
|
27
29
|
reference: BrokeredS3Reference,
|
package/src/github-graphql.ts
CHANGED
|
@@ -120,6 +120,8 @@ const BYPASS_ACTOR_PROBE = 1;
|
|
|
120
120
|
// `totalCount` means the connection is being filtered rather than merely
|
|
121
121
|
// redacted, so it supplies no count; a null *element* is the documented
|
|
122
122
|
// identity-withholding shape, so only the length is checked.
|
|
123
|
+
// Probes with restricted tokens confirmed that hidden actors still count:
|
|
124
|
+
// https://github.com/davidvornholt/standards/pull/176
|
|
123
125
|
const countedRuleset = (node: unknown): readonly [number, number] | null => {
|
|
124
126
|
if (!isRecord(node) || typeof node.databaseId !== 'number') {
|
|
125
127
|
return null;
|
package/src/poller-codex.ts
CHANGED
|
@@ -163,6 +163,9 @@ export const runCodex = async (
|
|
|
163
163
|
{
|
|
164
164
|
detached: true,
|
|
165
165
|
stdio: ['ignore', 'ignore', 'pipe'],
|
|
166
|
+
// Approved runs share the host service identity and its GitHub token.
|
|
167
|
+
// Approval and write revalidation constrain the workflow; they do not
|
|
168
|
+
// isolate credentials. This assumes trusted, maintainer-approved work.
|
|
166
169
|
env: { ...process.env },
|
|
167
170
|
},
|
|
168
171
|
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const BUN_PACKAGE_MANAGER =
|
|
2
|
+
/^bun@(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/u;
|
|
3
|
+
const PACKAGE_MANAGER_PROBLEM =
|
|
4
|
+
'package.json: "packageManager" must pin an exact bun@x.y.z version';
|
|
5
|
+
|
|
6
|
+
export const collectBunVersionProblems = (
|
|
7
|
+
manifest: Record<string, unknown>,
|
|
8
|
+
): ReadonlyArray<string> =>
|
|
9
|
+
typeof manifest.packageManager === 'string' &&
|
|
10
|
+
BUN_PACKAGE_MANAGER.test(manifest.packageManager)
|
|
11
|
+
? []
|
|
12
|
+
: [PACKAGE_MANAGER_PROBLEM];
|
package/src/structure-check.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { readdir } from 'node:fs/promises';
|
|
|
3
3
|
import { isAbsolute, join } from 'node:path';
|
|
4
4
|
import { isRecord } from './github-settings-parse';
|
|
5
5
|
import { readJsonFile } from './json-file';
|
|
6
|
+
import { collectBunVersionProblems } from './structure-bun-version';
|
|
6
7
|
import {
|
|
7
8
|
missingPublishedCliProblems,
|
|
8
9
|
rootScriptExpectations,
|
|
@@ -189,6 +190,7 @@ export const collectStructureProblems = async (
|
|
|
189
190
|
...resolved.flatMap((r) => (r.problem === null ? [] : [r.problem])),
|
|
190
191
|
...loaded.flatMap((l) => (l.problem === null ? [] : [l.problem])),
|
|
191
192
|
...missingPublishedCliProblems(profile, workspaces),
|
|
193
|
+
...collectBunVersionProblems(root),
|
|
192
194
|
...inspectRootScripts(root, profile, requireA11y),
|
|
193
195
|
...inspections.flatMap((i) => [...i.problems]),
|
|
194
196
|
...readmeProblems,
|
package/src/structure-profile.ts
CHANGED
|
@@ -8,9 +8,10 @@ import { isRecord } from './github-settings-parse';
|
|
|
8
8
|
// drifting silently while the normal quality gate stays green.
|
|
9
9
|
export type StructureProfile = 'consumer' | 'source';
|
|
10
10
|
|
|
11
|
-
const CONSUMER_CHECK =
|
|
11
|
+
const CONSUMER_CHECK =
|
|
12
|
+
'turbo run lint check-types test build test:a11y --output-logs=errors-only';
|
|
12
13
|
const CONSUMER_CHECK_FIX =
|
|
13
|
-
'turbo run lint:fix check-types test build test:a11y';
|
|
14
|
+
'turbo run lint:fix check-types test build test:a11y --output-logs=errors-only';
|
|
14
15
|
const ROOT_A11Y = 'turbo run test:a11y';
|
|
15
16
|
|
|
16
17
|
export const PUBLISHED_CLI_WORKSPACE = 'packages/standards-cli';
|
|
@@ -32,7 +33,7 @@ const SOURCE_ROOT_EXPECTATIONS: ReadonlyArray<RootScriptExpectation> = [
|
|
|
32
33
|
`${SOURCE_CLI} structure --profile source`,
|
|
33
34
|
`${SOURCE_CLI} dependabot --check`,
|
|
34
35
|
`${SOURCE_CLI} github --check`,
|
|
35
|
-
'turbo run lint check-types test',
|
|
36
|
+
'turbo run lint check-types test --output-logs=errors-only',
|
|
36
37
|
],
|
|
37
38
|
exact: true,
|
|
38
39
|
},
|
|
@@ -42,7 +43,7 @@ const SOURCE_ROOT_EXPECTATIONS: ReadonlyArray<RootScriptExpectation> = [
|
|
|
42
43
|
`${SOURCE_CLI} structure --profile source`,
|
|
43
44
|
`${SOURCE_CLI} dependabot --write`,
|
|
44
45
|
`${SOURCE_CLI} github --check`,
|
|
45
|
-
'turbo run lint:fix check-types test',
|
|
46
|
+
'turbo run lint:fix check-types test --output-logs=errors-only',
|
|
46
47
|
],
|
|
47
48
|
exact: true,
|
|
48
49
|
},
|