@buffcore/cli 0.8.47 → 0.8.49

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 (175) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/commands/build/server-text.en.d.ts +5 -0
  3. package/dist/commands/build/server-text.en.js +5 -0
  4. package/dist/commands/build/server-text.js +5 -0
  5. package/dist/commands/build/server.d.ts +4 -0
  6. package/dist/commands/build/server.js +10 -1
  7. package/dist/commands/change-merge-serial.d.ts +6 -2
  8. package/dist/commands/change-merge-serial.js +5 -1
  9. package/dist/commands/change-merge.d.ts +2 -2
  10. package/dist/commands/change.js +3 -0
  11. package/dist/commands/check-skills.d.ts +16 -0
  12. package/dist/commands/check-skills.en.d.ts +14 -0
  13. package/dist/commands/check-skills.en.js +14 -0
  14. package/dist/commands/check-skills.es.d.ts +2 -0
  15. package/dist/commands/check-skills.es.js +14 -0
  16. package/dist/commands/check-skills.js +146 -0
  17. package/dist/commands/check.js +5 -0
  18. package/dist/commands/dev.d.ts +9 -2
  19. package/dist/commands/dev.js +24 -5
  20. package/dist/commands/extension/config-text.d.ts +2 -0
  21. package/dist/commands/extension/config-text.js +2 -0
  22. package/dist/commands/extension/index.js +14 -2
  23. package/dist/commands/extension/new.d.ts +16 -0
  24. package/dist/commands/extension/new.js +52 -0
  25. package/dist/commands/extension/pack-files.d.ts +23 -0
  26. package/dist/commands/extension/pack-files.js +78 -0
  27. package/dist/commands/extension/pack-scan.d.ts +24 -0
  28. package/dist/commands/extension/pack-scan.js +131 -0
  29. package/dist/commands/extension/pack.d.ts +48 -0
  30. package/dist/commands/extension/pack.js +142 -0
  31. package/dist/commands/extension/share-text.d.ts +3 -0
  32. package/dist/commands/extension/share-text.js +6 -0
  33. package/dist/commands/extension/share.en.d.ts +32 -0
  34. package/dist/commands/extension/share.en.js +32 -0
  35. package/dist/commands/extension/share.es.d.ts +2 -0
  36. package/dist/commands/extension/share.es.js +32 -0
  37. package/dist/commands/hardening.d.ts +3 -0
  38. package/dist/commands/hardening.en.d.ts +3 -0
  39. package/dist/commands/hardening.en.js +3 -0
  40. package/dist/commands/hardening.es.d.ts +2 -0
  41. package/dist/commands/hardening.es.js +3 -0
  42. package/dist/commands/hardening.js +19 -0
  43. package/dist/commands/prototype/comp-record.d.ts +5 -0
  44. package/dist/commands/prototype/comp-record.js +22 -0
  45. package/dist/commands/server/build.d.ts +2 -1
  46. package/dist/commands/server/build.js +10 -2
  47. package/dist/commands/server/deploy-local.d.ts +3 -0
  48. package/dist/commands/server/deploy-local.js +9 -0
  49. package/dist/commands/server/deploy-plan.d.ts +5 -0
  50. package/dist/commands/server/deploy-plan.js +56 -0
  51. package/dist/commands/server/deploy-result.d.ts +7 -0
  52. package/dist/commands/server/deploy-result.js +1 -0
  53. package/dist/commands/server/deploy-script.d.ts +2 -0
  54. package/dist/commands/server/deploy-script.js +3 -2
  55. package/dist/commands/server/deploy.d.ts +9 -6
  56. package/dist/commands/server/deploy.js +39 -61
  57. package/dist/commands/server/files.d.ts +9 -1
  58. package/dist/commands/server/files.js +25 -5
  59. package/dist/commands/server/image.d.ts +4 -2
  60. package/dist/commands/server/image.js +6 -5
  61. package/dist/commands/server/setup.d.ts +1 -0
  62. package/dist/commands/server/setup.js +4 -0
  63. package/dist/commands/server/system-packages.d.ts +29 -0
  64. package/dist/commands/server/system-packages.js +103 -0
  65. package/dist/commands/services/compose.d.ts +1 -1
  66. package/dist/commands/services/compose.js +5 -3
  67. package/dist/commands/ui/agents-route.js +2 -0
  68. package/dist/commands/ui/approval-authority.en.d.ts +1 -0
  69. package/dist/commands/ui/approval-authority.en.js +1 -0
  70. package/dist/commands/ui/approval-authority.es.d.ts +1 -0
  71. package/dist/commands/ui/approval-authority.es.js +1 -0
  72. package/dist/commands/ui/approval-authority.js +7 -2
  73. package/dist/commands/ui/approve.js +2 -4
  74. package/dist/commands/ui/autopilot-records.d.ts +2 -0
  75. package/dist/commands/ui/autopilot-records.js +5 -0
  76. package/dist/commands/ui/brand-approval.js +5 -1
  77. package/dist/commands/ui/chat/permissions.js +1 -1
  78. package/dist/commands/ui/chat/routes.js +4 -0
  79. package/dist/commands/ui/comp-approval.d.ts +14 -2
  80. package/dist/commands/ui/comp-approval.js +45 -8
  81. package/dist/commands/ui/index.d.ts +1 -0
  82. package/dist/commands/ui/level-route.js +3 -0
  83. package/dist/commands/ui/merge-authority.d.ts +4 -1
  84. package/dist/commands/ui/merge-authority.en.d.ts +4 -0
  85. package/dist/commands/ui/merge-authority.en.js +5 -1
  86. package/dist/commands/ui/merge-authority.es.d.ts +4 -0
  87. package/dist/commands/ui/merge-authority.es.js +5 -1
  88. package/dist/commands/ui/merge-authority.js +6 -3
  89. package/dist/commands/ui/merge-claims.d.ts +7 -0
  90. package/dist/commands/ui/merge-claims.js +21 -0
  91. package/dist/commands/ui/merge-delegation.js +8 -3
  92. package/dist/commands/ui/merge-hold-name.d.ts +5 -0
  93. package/dist/commands/ui/merge-hold-name.js +5 -0
  94. package/dist/commands/ui/merge-hold.d.ts +6 -1
  95. package/dist/commands/ui/merge-hold.js +23 -5
  96. package/dist/commands/ui/merge-publish-host.d.ts +1 -0
  97. package/dist/commands/ui/merge-publish-host.js +2 -2
  98. package/dist/commands/ui/merge-record.d.ts +2 -0
  99. package/dist/commands/ui/merge-record.js +1 -1
  100. package/dist/commands/ui/merge-route.js +17 -1
  101. package/dist/commands/ui/merge-settle.d.ts +32 -0
  102. package/dist/commands/ui/merge-settle.js +133 -0
  103. package/dist/commands/ui/merge-state.d.ts +5 -0
  104. package/dist/commands/ui/merge-state.js +7 -1
  105. package/dist/commands/ui/merge-withdraw.d.ts +9 -0
  106. package/dist/commands/ui/merge-withdraw.js +29 -0
  107. package/dist/commands/ui/outside-merge.d.ts +13 -0
  108. package/dist/commands/ui/outside-merge.js +84 -0
  109. package/dist/commands/ui/outside.d.ts +7 -4
  110. package/dist/commands/ui/outside.js +3 -0
  111. package/dist/commands/ui/plan-extensions.d.ts +34 -0
  112. package/dist/commands/ui/plan-extensions.en.d.ts +4 -0
  113. package/dist/commands/ui/plan-extensions.en.js +4 -0
  114. package/dist/commands/ui/plan-extensions.es.d.ts +2 -0
  115. package/dist/commands/ui/plan-extensions.es.js +4 -0
  116. package/dist/commands/ui/plan-extensions.js +86 -0
  117. package/dist/commands/ui/plan-files.js +9 -3
  118. package/dist/commands/ui/plan-structure.js +5 -7
  119. package/dist/commands/ui/prototype-comp-route.d.ts +12 -3
  120. package/dist/commands/ui/prototype-comp-route.js +35 -17
  121. package/dist/commands/ui/prototype-main.d.ts +6 -0
  122. package/dist/commands/ui/real-file.d.ts +11 -0
  123. package/dist/commands/ui/real-file.js +84 -0
  124. package/dist/commands/ui/save-route.js +4 -1
  125. package/dist/commands/ui/server.d.ts +1 -0
  126. package/dist/commands/ui/server.js +1 -0
  127. package/dist/commands/ui/studio-routes.js +2 -0
  128. package/dist/commands/ui/studio-state.d.ts +8 -0
  129. package/dist/commands/ui/studio-versions.js +19 -3
  130. package/dist/commands/ui/studio.en.d.ts +2 -0
  131. package/dist/commands/ui/studio.en.js +2 -0
  132. package/dist/commands/ui/studio.es.d.ts +2 -0
  133. package/dist/commands/ui/studio.es.js +2 -0
  134. package/dist/commands/upgrade.js +1 -1
  135. package/dist/ui/page.js +91 -91
  136. package/docs/EXTENSIONS.md +6 -0
  137. package/docs/PROTOTYPE.md +13 -0
  138. package/docs/WORKBENCH.md +55 -2
  139. package/package.json +11 -11
  140. package/skills/ape-add-ai-purpose/SKILL.md +1 -1
  141. package/skills/ape-add-event/SKILL.md +1 -1
  142. package/skills/ape-add-extension/SKILL.md +5 -1
  143. package/skills/ape-add-feature/SKILL.md +1 -1
  144. package/skills/ape-add-generator/SKILL.md +1 -1
  145. package/skills/ape-add-module/SKILL.md +1 -1
  146. package/skills/ape-add-route/SKILL.md +3 -1
  147. package/skills/ape-add-service/SKILL.md +1 -1
  148. package/skills/ape-add-translations/SKILL.md +2 -2
  149. package/skills/ape-admin-screen/SKILL.md +1 -1
  150. package/skills/ape-app-screen/SKILL.md +1 -1
  151. package/skills/ape-critique/SKILL.md +11 -32
  152. package/skills/ape-critique/references/after.md +15 -0
  153. package/skills/ape-critique/references/spacing-pass.md +20 -0
  154. package/skills/ape-deploy/SKILL.md +8 -3
  155. package/skills/ape-design-system/SKILL.md +15 -15
  156. package/skills/ape-design-system/references/by-hand.md +7 -0
  157. package/skills/ape-design-system/references/reference-study.md +11 -0
  158. package/skills/ape-diagnose/SKILL.md +24 -0
  159. package/skills/ape-migration/SKILL.md +1 -1
  160. package/skills/ape-plan-change/SKILL.md +37 -31
  161. package/skills/ape-plan-change/references/change-file-fields.md +5 -0
  162. package/skills/ape-plan-change/references/extensions.md +25 -0
  163. package/skills/ape-plan-change/references/finishing.md +3 -0
  164. package/skills/ape-plan-change/references/fix-from-error.md +3 -0
  165. package/skills/ape-plan-change/references/refactor.md +9 -0
  166. package/skills/ape-plan-change/references/structure.md +19 -0
  167. package/skills/ape-prototype/SKILL.md +13 -23
  168. package/skills/ape-prototype/references/comp.md +3 -0
  169. package/skills/ape-prototype/references/scope-and-export.md +5 -0
  170. package/skills/ape-prototype/references/snapshot.md +3 -0
  171. package/skills/ape-prototype/references/structure.md +11 -0
  172. package/skills/ape-prototype/references/working-app.md +7 -0
  173. package/skills/ape-request/SKILL.md +1 -1
  174. package/skills/ape-upgrade/SKILL.md +4 -1
  175. package/templates/product/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,58 @@ One section per release (a git tag). **Upgrade notes** list anything that breaks
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## v0.8.49 (2026-12-06)
8
+
9
+ - A `sensitive-read` route that a screen refreshes can be audited once per person and state: bind it with `handle(route, handler, { auditOnce: { key, seconds } })`, where `key(result, request, ctx)` names the state read from IDs and versions only (it is stored hashed, not secret) and `seconds` is the window (300 unless set). A successful call whose person, route, object, account and key already have a row younger than the window writes none; a changed key, another person or object, or a passed window writes one. The audit log checks and writes under one database lock, so several API processes and a restart share the window, and at worst write an extra row; the window reads each process's clock, so drift between them (seconds with NTP) moves its edge by that much. A read of the same state from a second screen within the window writes none. Denials, errors, machines' reads (through a door or a credential, or an added kind not read as people), and the rows a handler writes itself are recorded every time, and the route stays a `sensitive-read` everywhere else. Start refuses `auditOnce` on a route that isn't a `sensitive-read` or is an action. Routes without it are unchanged.
10
+
11
+ **Upgrade:** nothing to do.
12
+ - BuffCore's `ape-*` skills are cheaper to load and easier to follow. Each description now says what the skill is, then "Use when …", in under 200 characters. `ape-upgrade` and `ape-deploy` carry `disable-model-invocation: true`, so only a person starts them; an agent still reads them by path for the work it does alone (phone builds, the settings file, the notes after an upgrade). The four longest skills (`ape-prototype`, `ape-plan-change`, `ape-critique`, `ape-design-system`) keep what every path needs and point into a `references/` folder beside them for the rest, and their steps end with something to check. A new `ape-diagnose` skill runs a bug down in six gates (a failing command first, a cut-down case, hypotheses that can be proven wrong, debug logging with one prefix, a regression test, secrets redacted), starting from `ape mcp`'s `recent_errors` and `change_from_error`. Skills that ask the owner ask in numbered rounds, each question with a recommendation. `ape check skills` checks all of this.
13
+
14
+ **Upgrade notes** (every product): `ape upgrade` refreshes the skills, their `references/` folders included, and the skills list in AGENTS.md. Add `ape check skills` to the `lint` script in `package.json` (after `ape check secrets`), as new products have it. A product's own skill that changes versions or ships can take `disable-model-invocation: true` in its front matter too.
15
+ - Payments bills usage by the unit (BuffApe's request, BR50). A plan in `settings.payments.plans` may name metered prices, `metered: { '<lookup key>': { unit, lineType? } }`: Stripe prices whose `recurring.usage_type` is `metered`, on a Billing Meter. Checkout and `change_items` put them on the subscription with no quantity, and refuse, in English or Spanish, a named key whose price isn't metered, a meter that isn't active or doesn't sum, a price with `transform_quantity`, and two metered prices on one meter; while a plan has metered prices, the portal offers no plan switch. Server code reports usage with `reportUsage(ctx, accountId, { price, quantity, at, key })`: one row per `key`, written with its send job in one transaction (the same report again answers `counted: false` and re-queues an unsent one; the same key for other usage is refused), refused for a price the account's plan doesn't name; the job `payments.send_usage` sends it to Stripe's meter events and retries a failed send, never resending one reported over 23 hours ago once a send was started (`too_late`), and the row says whether Stripe took it. No route or tool reports usage. `get_billing` and the console's `get_overview` show each metered price's quantity this period and amount so far (a new `usage` list), to those who already see them. On the invoice, usage is a paid line of its own type (`usage` unless set), so affiliates' commission treats it like a plan. Migration `payments/0004-metered-usage` only adds (the `payments_usage` table and the subscription's period start).
16
+
17
+ **Upgrade notes** (every product): with `@buffcore/payments`, a test or screen that builds a `Billing` value by hand adds `usage: []`; nothing else changes for a product that names no metered price. To bill usage, follow the payments README's "Metered prices".
18
+
19
+ - A hosted studio can merge an outside change through its host: register `outside.changes.act({ viewer, change, signal })` and `POST /api/outside/merge` (a person with the `build` right, from the page) calls it once, in the studio's one merge queue (refused as busy while a studio merge runs, and the reverse; like a person's inside merge, it is not stopped by the Autopilot merge hold), within `outside.timeoutMs`. The answer (`merged` with an optional receipt, `refused` with a code, `pending`, or a timeout or error) comes back in the page's words, English and Spanish, and the outside source is read again; Autopilot never calls it. Studio state carries `outside.merges: true`; the studio's page has the Merge action ready for the Work board's outside rows, which are not drawn yet (they wait for a drawn prototype). A host without `act` sees no change.
20
+
21
+ **Upgrade notes** (hosts with `outside.changes`): `act` was reserved and typed `Promise<unknown>`; it now must answer `{ status: 'merged', receipt? }`, `{ status: 'refused', code }` or `{ status: 'pending' }` (`OutsideActAnswer` from `@buffcore/contracts/workbench`), merge only ids the host listed for a viewer it lets merge, stop when its `signal` aborts, and be safe to call again for the same id (after a timeout the studio keeps the merge queue taken until `act` settles, at most four time limits, but a person may press Merge again later); it is refused at start when it is not a function. Hosts with no `act` do nothing.
22
+ - **The host's agent can read and propose a product setting (HS1).** A product that runs on a machine its host manages may set `hostSettings: { service, fields }` in `buffcore.config.ts` (with `automation` on): the host's agent, signed in with the host's key (`x-host-key`; the product's settings hold only its SHA-256 in `APE_HOST_KEY_SHA256`), reads those fields of that one service at `GET /v1/host/settings` (a secret only as set or not) and proposes a change at `POST /v1/host/settings` (a secret only as the host's `{ ref }`). Each proposal waits for an Owner in Automation › Approvals, showing the values and the reference, and is set only when an active Owner approves it. The key reaches nothing else, every step is audited without values, and a product that doesn't set `hostSettings` is unchanged. The approval shows each plain value as it was and becomes, and says when a saved secret will be sent to a new server. A route may now say `actorsOnly: true` to refuse every kind not in its `actors`, the kernel's too. The host: make a random key of 32 bytes or more, keep it in your vault, give the product its SHA-256, and answer only this product's references.
23
+ - The words the server sends the admin console follow the request's language: action titles, status lines and kill-switch descriptions arrive in Spanish when the console asks for Spanish, and pseudo-localized when it is in `en-XA` or `ar-XB` (outside production a pseudo-locale asked for first now wins over the person's saved language for the words served back; the request's `ctx.locale`, which rows, jobs and emails get, stays the real language), so a pseudo-locale audit sees them too. An approval's subject in the inbox is now its action's title in the reader's language, read when it is shown, and a status line whose name is a catalog key no catalog has shows its check's key instead of the raw message key (a plain name, such as `Queue`, still shows as given). A kill switch's description now reads from its declaring module's catalog, `<module>.switches.<switch key>`; BuffCore's own switches (Apps and its AI purposes) ship in English and Spanish. A product switch or purpose without that key shows its description as declared, as before; data such as a status item's name is never translated.
24
+
25
+ **Upgrade:** nothing to do. To translate a product's own switch or purpose description, add `<module>.switches.<switch key>` to the module's catalogs.
26
+
27
+ - A product's plan says what it will do for each capability it needs. `plan/extensions.md` holds one line each, `- <kind>: <name> - <why>`: `use` what exists, `improve` a catalog extension, `build to share`, `request` from BuffCore, or `product only`, with `(extra: <cost>)` on a line built to share. `ape change` names a line with an unknown kind, and the studio's Plan page shows the lines in groups with the extra cost of sharing. `ape extension new <key>` starts a shared piece in the product's `packages/` from the extension template, and `ape extension pack <key>` writes a submission bundle for the catalog the product names (the package, its check report, the scan, what it can touch, its licence, its screens), refusing a secret, real-looking personal data or the product's own name. It never publishes or calls the network. The `ape-plan-change` and `ape-add-extension` skills say how.
28
+
29
+ **Upgrade notes** (every product): `ape upgrade` refreshes the two skills. A product with a `plan/extensions.md` written another way gets its lines named by `ape change`: rewrite each as `- <kind>: <name> - <why>`.
30
+
31
+ - Members can sign up and in without a password, and use passkeys, each where the product turns it on. `signIn: { methods: ['email-code'] }` alone is now allowed: `POST /v1/sign-up` then takes a name and an email, answers `next: 'sign-in-code'` after the same work for every address, and a queued job makes the member with no password and emails a sign-in code; signing in with it confirms the address; a known address gets a code to its own account. Without `password` listed, a member's password signs nobody in and their reset sets none; operators keep theirs. With `methods: ['password', 'email-code']` the password may be left out the same way. `signIn: { members: { passkeys: 'offer' } }` lets a signed-in member add a passkey in the app and sign in with it, on operators' rules (confirmed on the device, its last use kept), listed and removed through the new `GET /v1/me/sign-in` and `DELETE /v1/me/passkeys/:passkeyId`, with an audit row as the member; the API warns at start when the app's host can't use them. `signIn: { newDevice: 'confirm' }` has a member confirm once each device they sign in on with a password: from a device the server didn't make and record as theirs (an httpOnly cookie on the web, `x-ape-sign-in-device` from a phone through the SDK's `signInDevice`), a right password answers 403 `confirm_device` with no session and the member is emailed a code; `POST /v1/auth/sign-in/confirm-device { token, code }` (the SDK's `auth.confirmDevice`, read the answer with `confirmDeviceOf`) or a passkey sign-in gives the session. Code, passkey, Apple and Google sign-ins confirm their own device; an ID is kept only when it is already the member's own (a `__Host-` cookie in production), and an address gets at most 5 of these code emails an hour. A wrong password answers as always. Wrong, expired and used confirmation codes and wrong sign-in codes count toward the address's pause with wrong passwords, which holds the confirmation too. `GET /v1/me/sign-in` lists the member's devices and `DELETE /v1/me/sign-in-devices/:deviceId` removes one, signing it out; devices are in privacy export and deletion (and an account's deletion now removes its members' passkeys too). All three are off by default, and operators are unchanged. The template's and the console's sign-in screens follow in a later release.
32
+
33
+ **Upgrade:** nothing to do. A product that turns members' passkeys on keeps the app on the console's host or one under it (the passkeys' relying party). Sign-up by code runs on the worker, so a product that offers it runs one; a code sign-up whose job runs more than an hour late is dropped, with a warning in the log. A tool that reads `POST /v1/sign-up` should accept `next: 'sign-in-code'`. Identity's migration `0009-sign-in-devices` only adds (a table, and a column on `auth_sessions`). A product that turns on `newDevice` and has a phone app passes `signInDevice` (secure storage) to `createClient` there, and shows a confirmation step on `confirm_device`.
34
+
35
+ - Sign in with GitHub, the first outside provider: a person signs up or in with GitHub (state and PKCE), links it to their account from a fresh sign-in, and disconnects it; the Owner lists and unlinks a person's linked identities. The token is sealed at rest and never reaches a client, a log, an audit row or an export; the product's server code gets it for the signed-in person with `outsideToken(ctx, 'github')` from `@buffcore/modules/identity`, audited and renewed when GitHub allows. Extensions add other providers with `outsideProviders`. An outside sign-in is never joined to an existing person by email: they link it themselves. Staff never get a session from Apple, Google or GitHub, nor a link to one, so two-step sign-in is never skipped (this also closes that gap for Apple and Google, which could join an operator by a verified email). Details in IDENTITY_ACCESS.md.
36
+
37
+ **Upgrade notes** (every product): an active operator can no longer reach the product's app by Apple, Google or GitHub (the app already refuses their password and emailed code): staff who used one there need a separate member address. Adding an operator, or turning one back on, now ends that person's sessions, so they sign in again with password and authenticator. The app still shows its general sign-in failure for `?error=USE_PASSWORD` (no message for it yet).
38
+
39
+ To turn it on, add `'github'` to `signIn.methods` in `buffcore.config.ts`, register `<API>/v1/auth/callback/github` as the callback of a GitHub OAuth app (or GitHub App), and set its client ID and secret (and any more scopes, e.g. `repo`) in Admin › Services › Sign in with GitHub. The sign-in library's `/v1/auth/get-access-token`, `/refresh-token`, `/account-info` and `/unlink-account` now answer 404, and `/v1/auth/link-social` takes only outside providers.
40
+
41
+ ## v0.8.48 (2026-12-05)
42
+
43
+ - A product may set `hardening` in `buffcore.config.ts`. With `refuseDebugOptions: true` (off by default), the API and each declared Node process refuse to start when Node's debugging or dump options (`--inspect*`, `--debug-port`, the heap snapshot options, `--diagnostic-dir`, `--report-*`) reach them on the command line or in `NODE_OPTIONS`: on a server a small module imported before the entry exits 1 naming the option, with `--disable-sigusr1`, and `ape dev` and `ape server setup` refuse every one of them in the `NODE_OPTIONS` they pass on (the shell's, `.env`'s, the settings file's) before starting anything, since `--inspect-brk` and `--inspect-wait` pause Node before any code runs. A `NODE_OPTIONS` word with a quote or a backslash is refused too. The compose file `ape server setup` writes now runs the API, each declared process and container, and the `ape` tools service with `ulimits: { core: 0 }`, so a crash writes no core dump; `coreDumps: true` keeps Docker's default. The compose file records the `hardening` it was written for, and `ape deploy` refuses a server whose file differs or predates it. Development is unchanged.
44
+
45
+ **Upgrade notes** (every product): run `ape server setup` again before the next deploy: `ape deploy` refuses a server whose compose file predates `hardening`, since it lacks the core-file limit; a product that needs core files sets `hardening: { coreDumps: true }` first.
46
+
47
+ - A product can add Debian system packages to its server image: `server: { systemPackages: ['openssh-client'] }` in `buffcore.config.ts`, for programs its API starts itself. `ape deploy` and `ape build server` install them in the image's last stage before it drops to the API's user, and record the installed versions in their `--json` (`systemPackages`). A name that isn't a Debian package name is refused with a plain sentence before anything is built, and a package that can't be installed fails the build. With no list the image is the same as before.
48
+
49
+ **Upgrade:** nothing to do. A tool that compares the whole `ape deploy --json` or `ape build server --json` line should expect the new `systemPackages` key.
50
+
51
+ - A hosted studio with an approval authority can approve the look. **Approve the look** now asks the host's authority once (`kind: 'comp'`, as for brand, prototype, release and places) and records its grant in `prototype/versions/comp.json` by the studio's own approval commit; it was refused with `approval_authority_invalid` before the host was asked. An agent or an AI approver is still refused. On a hosted studio the comp read shows the look approved only when the host confirms that record (`action: 'check'`), and shows the reason when it does not. The comp's pictures, and the plan, structure, design and version files the studio reads, are read only from a regular file with one link whose real path stays inside the product's folder: a link, junction or hard link leading out, or a folder, is not read. On Linux the check is made on the opened file itself. On Windows and macOS it resolves the path again, so a process that keeps swapping a folder on the path for a link while the studio reads can still slip one file past it; keep the product folder writable only by the people and agents who work on it.
52
+
53
+ **Upgrade notes** (every product): a host whose `approval` hook decides approvals now receives `{ kind: 'comp', version: null, commit, fingerprint }` with `action: 'approve'` and `'check'`. Answer as for the other kinds, with a person's signature only (no `agent`, no `ai`); the studio writes the record itself. The `check` names the commit the record's signature holds (the one checked out when the person approved), not today's HEAD, so key grants by commit and fingerprint. A `comp` rule in `plan/approvals.md` is still refused: the look is one person's approval. A host that refuses `comp` keeps the look unapproved, as before. A comp picture, plan file, `plan/structure.md`, `design/DESIGN.md` or `prototype/versions/*.json` that is a link (or a hard link) to a place outside the product's folder is no longer read: copy the file into the folder.
54
+
55
+ - A host whose `merge` hook answers `pending` for an Autopilot change can now settle it later from its own process: `settleHostMerge(root, { change, head, claim, outcome, code? })` from `@buffcore/cli/workbench`, where `claim` is the new `HostMergeInput.claim`, a secret the host was given with that ask (the studio keeps only its hash). It is accepted only for that exact waiting Autopilot claim (change, head and claim) while the saved level is Autopilot, runs under the same hold and publication lock as `publish`, and for `merged` only when main holds that exact head; the studio's next read records the merge and runs its Snapshot as for a published claim. BuffCore chose this over settling on main alone: since 0.8.27 an Autopilot success must pass the hold, and on a hosted studio the host itself writes main, so main holding the head shows a write happened, not that it respected a person's hold. A waiting merge now shows how long it has waited. A waiting Autopilot claim (not a person's own) ends when a person withdraws it from the merge preview (`POST /api/merge/withdraw`), turns the hold on, leaves Autopilot or presses Stop on the change, unless main already holds it; so a host that never answers cannot hold Autopilot, and Autopilot asks again after its next turn. A settle of any outcome that finds `plan/agents.md` or the hold edited since the ask withdraws the claim the same way, and the merge preview offers Withdraw only on an Autopilot wait (`automatic: true` in `work.merges`). Local studios, a person's own merge and a hook that answers `merged` are unchanged.
56
+
57
+ **Upgrade notes** (hosts with a `merge` hook): a queue that merges an Autopilot change after answering `pending` keeps `HostMergeInput.claim` with the queued request and calls `settleHostMerge` once the merge lands on main (or with `outcome: 'not_merged'` and a code when it gives up). Call it with `outcome: 'check'` (writes nothing, answers `ready`) just before the final write. When a settle answers `merge_settle_unknown` (the claim was withdrawn, held, stopped, or `plan/agents.md` or the hold changed since the ask), drop the queue entry and do not write main for it; the studio asks again when the change is merged next. A change the queue merged anyway shows in Work as a merge Git holds, like one made at a terminal, with no host line, record or Snapshot. On `merge_record_failed`, call again. On `merge_publication_lock` (the studio's publication lock stayed busy), call again later. `merge_settle_invalid` and `merge_settle_unknown` are now reserved codes.
58
+
7
59
  ## v0.8.47 (2026-12-04)
8
60
 
9
61
  - On Linux and macOS, `ape prototype snapshot` reuses unchanged console scenes again: files Vite serves from outside the console's folder (`/@fs/…`) were read as paths under the working folder, so every console scene was drawn again. A worktree's snapshot also records its dev servers every few seconds while they start, so the next run stops the servers of a run killed during their cold start.
@@ -4,6 +4,11 @@ export declare const en: {
4
4
  'build.server.name': string;
5
5
  'build.server.inspect': string;
6
6
  'build.server.made': string;
7
+ 'build.server.packages': string;
8
+ 'build.server.packagesFailed': string;
9
+ 'build.server.versionsRun': string;
10
+ 'build.server.label': string;
11
+ 'build.server.versionsMissing': string;
7
12
  'build.server.flags': string;
8
13
  'build.server.platformOnly': string;
9
14
  'build.server.platform': string;
@@ -5,6 +5,11 @@ export const en = {
5
5
  'build.server.name': '{name} is not a name setup took.',
6
6
  'build.server.inspect': 'Could not read the image ID for {image}.',
7
7
  'build.server.made': 'Built {image}: {id}',
8
+ 'build.server.packages': 'buffcore.config.ts: {problems}. Nothing was built: fix server.systemPackages, then run it again.',
9
+ 'build.server.packagesFailed': 'The image did not build. It installs system packages ({names}): when the output above shows apt-get or "ape: the system package" failing, check those names in Debian. No image is made without them.',
10
+ 'build.server.versionsRun': "Could not read the system packages' versions in {image}: Docker said {cause}. Is Docker running, and is the image on this machine?",
11
+ 'build.server.label': "The image {image}'s ape.system-packages label names {name}, which is not a Debian package name: its system packages' versions were not read.",
12
+ 'build.server.versionsMissing': '{name} is not installed in {image} by that name: list each system package by its own Debian name, not one another package provides.',
8
13
  'build.server.flags': '--local, --builder and --simulator are for ape build ios only.',
9
14
  'build.server.platformOnly': '--platform is for ape build server only.',
10
15
  'build.server.platform': 'server only: the image platform (default: linux/amd64)',
@@ -6,6 +6,11 @@ const es = {
6
6
  'build.server.name': '{name} no es un nombre aceptado por setup.',
7
7
  'build.server.inspect': 'No se pudo leer el ID de la imagen {image}.',
8
8
  'build.server.made': 'Imagen creada {image}: {id}',
9
+ 'build.server.packages': 'buffcore.config.ts: {problems}. No se creó nada: corrige server.systemPackages y ejecútalo otra vez.',
10
+ 'build.server.packagesFailed': 'La imagen no se creó. Instala paquetes del sistema ({names}): si la salida de arriba muestra un fallo de apt-get o de "ape: the system package", revisa esos nombres en Debian. No se crea ninguna imagen sin ellos.',
11
+ 'build.server.versionsRun': 'No se pudieron leer las versiones de los paquetes del sistema en {image}: Docker dijo {cause}. ¿Está Docker en marcha y la imagen en esta máquina?',
12
+ 'build.server.label': 'La etiqueta ape.system-packages de la imagen {image} nombra {name}, que no es un nombre de paquete de Debian: no se leyeron las versiones de sus paquetes del sistema.',
13
+ 'build.server.versionsMissing': '{name} no está instalado en {image} con ese nombre: nombra cada paquete del sistema por su propio nombre en Debian, no por uno que otro paquete provee.',
9
14
  'build.server.flags': '--local, --builder y --simulator son solo para ape build ios.',
10
15
  'build.server.platformOnly': '--platform es solo para ape build server.',
11
16
  'build.server.platform': 'solo server: la plataforma de la imagen (predeterminada: linux/amd64)',
@@ -1,5 +1,6 @@
1
1
  import { type Local } from '../server/build.ts';
2
2
  import { type ImageReader } from '../server/image-id.ts';
3
+ import { type PackageReader } from '../server/system-packages.ts';
3
4
  import { type Runner } from './runner.ts';
4
5
  export interface ServerBuildOptions {
5
6
  platform?: string;
@@ -17,6 +18,8 @@ export interface ServerBuildResult {
17
18
  image: string;
18
19
  id: string;
19
20
  }[];
21
+ /** The system packages' installed versions in the image (`server.systemPackages`); `{}` for none. */
22
+ systemPackages: Record<string, string>;
20
23
  }
21
24
  export interface ServerBuildDeps {
22
25
  root?: string;
@@ -24,6 +27,7 @@ export interface ServerBuildDeps {
24
27
  run?: Runner;
25
28
  log?: (line: string) => void;
26
29
  readImage?: ImageReader;
30
+ readPackages?: PackageReader;
27
31
  }
28
32
  /** Only a failure after the build starts is exit 1; preparation failures are refusals (2). */
29
33
  export declare class ServerBuildFailed extends Error {
@@ -4,6 +4,7 @@ import { buildImages, local } from '../server/build.js';
4
4
  import { imagePlan, workspaceOf } from '../server/deploy.js';
5
5
  import { dockerfile } from '../server/image.js';
6
6
  import { imageIdOf } from '../server/image-id.js';
7
+ import { packageVersions, systemPackagesOf, } from '../server/system-packages.js';
7
8
  import { shell } from './runner.js';
8
9
  import { t } from './server-text.js';
9
10
  /** Only a failure after the build starts is exit 1; preparation failures are refusals (2). */
@@ -29,7 +30,13 @@ export async function buildServer(options, deps = {}) {
29
30
  const commit = here.commit(workspace);
30
31
  if (commit.changed)
31
32
  throw new Error(t('build.server.changed'));
32
- const docker = dockerfile(imagePlan(root, workspace, { name: product.name, commit: commit.sha }));
33
+ const systemPackages = systemPackagesOf(product);
34
+ const plan = imagePlan(root, workspace, {
35
+ name: product.name,
36
+ commit: commit.sha,
37
+ systemPackages,
38
+ });
39
+ const docker = dockerfile(plan);
33
40
  const info = run('docker info --format "{{.ServerVersion}}"', {
34
41
  cwd: workspace,
35
42
  capture: true,
@@ -44,6 +51,7 @@ export async function buildServer(options, deps = {}) {
44
51
  json: Boolean(options.json),
45
52
  log,
46
53
  tag: commit.sha,
54
+ packages: systemPackages,
47
55
  });
48
56
  const images = [];
49
57
  for (const image of tags)
@@ -52,6 +60,7 @@ export async function buildServer(options, deps = {}) {
52
60
  ...images[0],
53
61
  commit: commit.sha,
54
62
  containers: images.slice(1).map((image, i) => ({ name: built.names[i], ...image })),
63
+ systemPackages: await packageVersions(tags[0], systemPackages, where.platform, deps.readPackages),
55
64
  };
56
65
  }
57
66
  catch (error) {
@@ -2,6 +2,10 @@ import { type MergeResult, type MergeTools } from './change-merge.ts';
2
2
  export declare function lockPath(root: string, git?: import("./change-merge.ts").MergeGit): Promise<string>;
3
3
  /** Shared across checkouts and studios; a stopped merge's lock waits for the person to remove it. */
4
4
  export declare function mergingChange(root: string): Promise<string | null>;
5
- export declare function locked<T>(root: string, change: string, tools: MergeTools, action: () => Promise<T>): Promise<T | (MergeResult & {
5
+ type Busy = MergeResult & {
6
6
  ok: false;
7
- })>;
7
+ };
8
+ export declare function locked<T>(root: string, change: string, tools: MergeTools, action: () => Promise<T>): Promise<T | Busy>;
9
+ /** The one merge queue: whoever holds the lock (a studio change, an outside merge, a release). */
10
+ export declare function serialized<T>(root: string, holder: string, tools: MergeTools, action: () => Promise<T>): Promise<T | Busy>;
11
+ export {};
@@ -23,9 +23,13 @@ export async function mergingChange(root) {
23
23
  export async function locked(root, change, tools, action) {
24
24
  if (!/^C-\d{3,}$/.test(change))
25
25
  return refuse('held', 'change.merge.missing');
26
+ return serialized(root, change, tools, action);
27
+ }
28
+ /** The one merge queue: whoever holds the lock (a studio change, an outside merge, a release). */
29
+ export async function serialized(root, holder, tools, action) {
26
30
  const path = await lockPath(root, tools.git);
27
31
  try {
28
- const text = lockText(change);
32
+ const text = lockText(holder);
29
33
  await writeFile(path, text, { flag: 'wx' }).catch(async (error) => {
30
34
  if (error?.code !== 'EEXIST')
31
35
  throw error;
@@ -103,11 +103,11 @@ export declare const hasMerge: (path: string, git: MergeGit) => Promise<boolean>
103
103
  * may rewrite it). Any read failure holds it.
104
104
  */
105
105
  export declare function hostLevelRefusal(root: string, refs: string[], tools: MergeTools): Promise<{
106
- reason: 'held';
107
- detail: string;
108
106
  ok: false;
109
107
  code: string;
110
108
  error: string;
109
+ reason: 'held';
110
+ detail: string;
111
111
  } | undefined>;
112
112
  /** Person-only action shared by CLI and studio. Nothing pushes or forces a branch. */
113
113
  export declare function mergeOne(root: string, change: string, tools?: MergeTools, approval?: MergeAuthority, level?: HostLevel): Promise<MergeResult>;
@@ -17,6 +17,7 @@ import { MilestoneVersionsPending, requireLegacyChange } from './prototype/miles
17
17
  import { serviceEnvWithExample, unavailableService } from './services/reachability.js';
18
18
  import { checkNotice, t as checkT } from './ui/command-environment.en.js';
19
19
  import { commandEnvironment } from './ui/command-environment.js';
20
+ import { planExtensionProblems } from './ui/plan-extensions.js';
20
21
  export { runChecks } from './change-checks.js';
21
22
  /** Resolve what a change touches against the manifest: what exists (and where), what is new. */
22
23
  export function resolveTouches(touches, manifest) {
@@ -77,6 +78,8 @@ export async function changeResult(id, options, load, root = findRoot()) {
77
78
  file,
78
79
  branch,
79
80
  }));
81
+ // The plan's extension list is checked with the change files: an unknown kind is a problem.
82
+ problems.push(...(await planExtensionProblems(root)));
80
83
  return { ok: problems.length === 0, changes: listed, problems };
81
84
  }
82
85
  const own = problems.filter((p) => p.file.startsWith(`plan/changes/${id}-`));
@@ -0,0 +1,16 @@
1
+ import { en } from './check-skills.en.ts';
2
+ export declare const t: (key: keyof typeof en, values?: Record<string, unknown>) => string;
3
+ export declare const DESCRIPTION_LIMIT = 200;
4
+ /** Skills a person starts: the model never starts them by itself. */
5
+ export declare const PERSON_STARTED: string[];
6
+ /** The four longest skills, kept under the limit by moving branch-only detail to `references/`. */
7
+ export declare const LONG_SKILLS: string[];
8
+ export declare const SKILL_LIMIT = 13500;
9
+ /** ape-diagnose's six gates, each by the words that name it. */
10
+ export declare const DIAGNOSE_GATES: string[];
11
+ /** The words that make a question round, in ape-plan-change. */
12
+ export declare const ROUND_WORDING: string[];
13
+ /** Every problem with the `ape-*` skills in a skills folder (a product's `.claude/skills`). */
14
+ export declare function skillsProblems(skillsDir: string): string[];
15
+ /** Run from a product's root (or BuffCore's): exit 1 with each problem on its own line. */
16
+ export declare function checkSkills(root?: string): void;
@@ -0,0 +1,14 @@
1
+ export declare const en: {
2
+ readonly 'skills.command': "Fail on a BuffCore skill out of shape: its description's trigger form and length, the person-started flag, the long skills' size and references, ape-diagnose's gates, questions in rounds";
3
+ readonly 'skills.form': '{skill}: the description is not in trigger form ("<what it is>. Use when <case>, <case>.")';
4
+ readonly 'skills.length': '{skill}: the description is {length} characters, over {limit}';
5
+ readonly 'skills.flag': '{skill}: a person starts it, so its front matter needs disable-model-invocation: true';
6
+ readonly 'skills.size': '{skill}: SKILL.md is {size} bytes, over {limit}: move branch-only detail to references/';
7
+ readonly 'skills.noReferences': '{skill}: a long skill with no pointer into references/';
8
+ readonly 'skills.pointer': '{skill}: {file} points at {target}, which does not exist';
9
+ readonly 'skills.orphan': '{skill}: {file} is in references/ but SKILL.md never points at it';
10
+ readonly 'skills.missing': '{skill} is missing';
11
+ readonly 'skills.gate': '{skill}: the gate "{gate}" is missing';
12
+ readonly 'skills.rounds': '{skill}: it has the agent ask the owner, but never says to ask in rounds';
13
+ readonly 'skills.roundWording': '{skill}: the question-round wording "{words}" is missing';
14
+ };
@@ -0,0 +1,14 @@
1
+ export const en = {
2
+ 'skills.command': "Fail on a BuffCore skill out of shape: its description's trigger form and length, the person-started flag, the long skills' size and references, ape-diagnose's gates, questions in rounds",
3
+ 'skills.form': '{skill}: the description is not in trigger form ("<what it is>. Use when <case>, <case>.")',
4
+ 'skills.length': '{skill}: the description is {length} characters, over {limit}',
5
+ 'skills.flag': '{skill}: a person starts it, so its front matter needs disable-model-invocation: true',
6
+ 'skills.size': '{skill}: SKILL.md is {size} bytes, over {limit}: move branch-only detail to references/',
7
+ 'skills.noReferences': '{skill}: a long skill with no pointer into references/',
8
+ 'skills.pointer': '{skill}: {file} points at {target}, which does not exist',
9
+ 'skills.orphan': '{skill}: {file} is in references/ but SKILL.md never points at it',
10
+ 'skills.missing': '{skill} is missing',
11
+ 'skills.gate': '{skill}: the gate "{gate}" is missing',
12
+ 'skills.rounds': '{skill}: it has the agent ask the owner, but never says to ask in rounds',
13
+ 'skills.roundWording': '{skill}: the question-round wording "{words}" is missing',
14
+ };
@@ -0,0 +1,2 @@
1
+ import type { en } from './check-skills.en.ts';
2
+ export declare const es: Record<keyof typeof en, string>;
@@ -0,0 +1,14 @@
1
+ export const es = {
2
+ 'skills.command': 'Falla si una habilidad de BuffCore no tiene la forma debida: la forma de activación y la longitud de su descripción, la marca de inicio por una persona, el tamaño y las referencias de las habilidades largas, las compuertas de ape-diagnose, las preguntas por rondas',
3
+ 'skills.form': '{skill}: la descripción no tiene forma de activación ("<qué es>. Use when <caso>, <caso>.")',
4
+ 'skills.length': '{skill}: la descripción tiene {length} caracteres, más de {limit}',
5
+ 'skills.flag': '{skill}: la inicia una persona, así que su cabecera necesita disable-model-invocation: true',
6
+ 'skills.size': '{skill}: SKILL.md tiene {size} bytes, más de {limit}: pasa el detalle de un solo camino a references/',
7
+ 'skills.noReferences': '{skill}: una habilidad larga sin ningún enlace a references/',
8
+ 'skills.pointer': '{skill}: {file} apunta a {target}, que no existe',
9
+ 'skills.orphan': '{skill}: {file} está en references/ pero SKILL.md nunca apunta a él',
10
+ 'skills.missing': 'falta {skill}',
11
+ 'skills.gate': '{skill}: falta la compuerta "{gate}"',
12
+ 'skills.rounds': '{skill}: hace que el agente pregunte al dueño, pero nunca dice que pregunte por rondas',
13
+ 'skills.roundWording': '{skill}: falta el texto de las preguntas por rondas "{words}"',
14
+ };
@@ -0,0 +1,146 @@
1
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
+ import { join, relative, sep } from 'node:path';
3
+ import { createI18n } from '@buffcore/i18n';
4
+ import { en } from './check-skills.en.js';
5
+ import { es } from './check-skills.es.js';
6
+ import { descriptionOf } from './skills-list.js';
7
+ /**
8
+ * `ape check skills`: BuffCore's `ape-*` skills keep the shape agents rely on. Every session loads
9
+ * each description, so it says what the skill is and when to use it, short. A skill a person starts
10
+ * (it ships, deploys or changes a running product's versions) is never started by the model. The
11
+ * long skills keep what every path needs and point into `references/` for the rest, and those
12
+ * pointers resolve. `ape-diagnose` keeps its six gates, and a skill that has the agent ask the
13
+ * owner asks in rounds.
14
+ */
15
+ const messages = createI18n({ catalogs: [{ en, es }] });
16
+ export const t = (key, values) => messages.t(/^es(?:[-_.]|$)/i.test(process.env.LC_ALL || process.env.LANG || '') ? 'es' : 'en', key, values);
17
+ export const DESCRIPTION_LIMIT = 200;
18
+ /** "<what it is>. Use when <case>, <case>.": one sentence of what, then the cases. */
19
+ const TRIGGER_FORM = /^\S[^\n]*?\. Use when [^\n]+\.$/;
20
+ /** Skills a person starts: the model never starts them by itself. */
21
+ export const PERSON_STARTED = ['ape-upgrade', 'ape-deploy', 'ape-release'];
22
+ /** The four longest skills, kept under the limit by moving branch-only detail to `references/`. */
23
+ export const LONG_SKILLS = [
24
+ 'ape-prototype',
25
+ 'ape-plan-change',
26
+ 'ape-critique',
27
+ 'ape-design-system',
28
+ ];
29
+ export const SKILL_LIMIT = 13_500;
30
+ /** ape-diagnose's six gates, each by the words that name it. */
31
+ export const DIAGNOSE_GATES = [
32
+ 'A command that fails because of the bug',
33
+ 'Cut the case down',
34
+ 'Three to five hypotheses that can be proven wrong',
35
+ 'Debug logging with one prefix',
36
+ 'A regression test that fails before the fix and passes after',
37
+ 'Secrets redacted in anything quoted',
38
+ '`recent_errors`',
39
+ '`change_from_error`',
40
+ ];
41
+ /** The words that make a question round, in ape-plan-change. */
42
+ export const ROUND_WORDING = [
43
+ 'ask every question that is ready to decide in one numbered round',
44
+ 'worded so that "yes" accepts it',
45
+ 'Look facts up',
46
+ ];
47
+ /** A skill that has the agent ask the owner or the person something. */
48
+ const ASKS = /\b(?:ask|check with|confirm with)\s+(?:the\s+)?(?:person|owner|founder|user)s?\b|\bask them\b|\bwith the (?:person|owner)\b/i;
49
+ const frontMatter = (text) => text.replace(/\r\n/g, '\n').match(/^---\n([\s\S]*?)\n---/)?.[1] ?? '';
50
+ /** The files under a folder, as paths relative to it with `/`. */
51
+ function filesUnder(dir) {
52
+ if (!existsSync(dir))
53
+ return [];
54
+ return readdirSync(dir, { recursive: true, withFileTypes: true })
55
+ .filter((e) => e.isFile())
56
+ .map((e) => relative(dir, join(e.parentPath, e.name)).split(sep).join('/'))
57
+ .sort();
58
+ }
59
+ /**
60
+ * The `references/…` paths a Markdown file points at, relative to the skill's folder: in
61
+ * backticks, or as a Markdown link (`[the comp](references/comp.md#heading)`).
62
+ */
63
+ function pointersIn(text) {
64
+ const ticked = [...text.matchAll(/`(references\/[^`\s]+)`/g)].map((m) => m[1]);
65
+ const linked = [...text.matchAll(/\]\((?:\.\/)?(references\/[^)\s#]+)(?:#[^)\s]*)?\)/g)].map((m) => m[1]);
66
+ return [...ticked, ...linked].map((p) => p.replace(/\/$/, ''));
67
+ }
68
+ /** Problems with the `references/` pointers of one skill: dangling ones, and orphan files. */
69
+ function referenceProblems(skill, dir) {
70
+ const problems = [];
71
+ const skillText = readFileSync(join(dir, 'SKILL.md'), 'utf8');
72
+ const markdown = [
73
+ 'SKILL.md',
74
+ ...filesUnder(join(dir, 'references')).map((f) => `references/${f}`),
75
+ ];
76
+ for (const file of markdown.filter((f) => f.endsWith('.md'))) {
77
+ for (const target of pointersIn(readFileSync(join(dir, file), 'utf8')))
78
+ if (!existsSync(join(dir, target)))
79
+ problems.push(t('skills.pointer', { skill, file, target }));
80
+ }
81
+ const named = pointersIn(skillText);
82
+ for (const file of filesUnder(join(dir, 'references'))) {
83
+ const path = `references/${file}`;
84
+ const reached = named.some((n) => path === n || path.startsWith(`${n}/`));
85
+ if (!reached)
86
+ problems.push(t('skills.orphan', { skill, file: path }));
87
+ }
88
+ return problems;
89
+ }
90
+ /** Every problem with the `ape-*` skills in a skills folder (a product's `.claude/skills`). */
91
+ export function skillsProblems(skillsDir) {
92
+ const problems = [];
93
+ const names = existsSync(skillsDir)
94
+ ? readdirSync(skillsDir)
95
+ .filter((n) => n.startsWith('ape-') && existsSync(join(skillsDir, n, 'SKILL.md')))
96
+ .sort()
97
+ : [];
98
+ for (const skill of names) {
99
+ const dir = join(skillsDir, skill);
100
+ const text = readFileSync(join(dir, 'SKILL.md'), 'utf8');
101
+ const description = descriptionOf(text);
102
+ if (!TRIGGER_FORM.test(description))
103
+ problems.push(t('skills.form', { skill }));
104
+ if (description.length > DESCRIPTION_LIMIT)
105
+ problems.push(t('skills.length', { skill, length: description.length, limit: DESCRIPTION_LIMIT }));
106
+ const flagged = /^disable-model-invocation:\s*true\s*$/m.test(frontMatter(text));
107
+ if (PERSON_STARTED.includes(skill) && !flagged)
108
+ problems.push(t('skills.flag', { skill }));
109
+ problems.push(...referenceProblems(skill, dir));
110
+ if (LONG_SKILLS.includes(skill)) {
111
+ // Bytes with `\n` line ends, so a checkout with CRLF measures the same.
112
+ const size = Buffer.byteLength(text.replace(/\r\n/g, '\n'));
113
+ if (size > SKILL_LIMIT)
114
+ problems.push(t('skills.size', { skill, size, limit: SKILL_LIMIT }));
115
+ if (!pointersIn(text).length)
116
+ problems.push(t('skills.noReferences', { skill }));
117
+ }
118
+ if (ASKS.test(text) && !/\bin rounds\b/i.test(text))
119
+ problems.push(t('skills.rounds', { skill }));
120
+ }
121
+ if (!names.length)
122
+ return problems;
123
+ const diagnose = join(skillsDir, 'ape-diagnose', 'SKILL.md');
124
+ if (!existsSync(diagnose))
125
+ problems.push(t('skills.missing', { skill: 'ape-diagnose' }));
126
+ else {
127
+ const text = readFileSync(diagnose, 'utf8');
128
+ for (const gate of DIAGNOSE_GATES.filter((g) => !text.includes(g)))
129
+ problems.push(t('skills.gate', { skill: 'ape-diagnose', gate }));
130
+ }
131
+ const plan = join(skillsDir, 'ape-plan-change', 'SKILL.md');
132
+ if (existsSync(plan)) {
133
+ const text = readFileSync(plan, 'utf8');
134
+ for (const words of ROUND_WORDING.filter((w) => !text.includes(w)))
135
+ problems.push(t('skills.roundWording', { skill: 'ape-plan-change', words }));
136
+ }
137
+ return problems;
138
+ }
139
+ /** Run from a product's root (or BuffCore's): exit 1 with each problem on its own line. */
140
+ export function checkSkills(root = process.cwd()) {
141
+ const problems = skillsProblems(join(root, '.claude', 'skills'));
142
+ if (!problems.length)
143
+ return;
144
+ console.error(problems.join('\n'));
145
+ process.exitCode = 1;
146
+ }
@@ -2,6 +2,7 @@ import { checkBoundaries } from './check-boundaries.js';
2
2
  import { checkPlaces } from './check-places.js';
3
3
  import { checkPublic } from './check-public.js';
4
4
  import { checkSecrets } from './check-secrets.js';
5
+ import { checkSkills, t as skillsT } from './check-skills.js';
5
6
  import { checkCompatible, t } from './compatible.js';
6
7
  import { t as placesT } from './extension/places-messages.js';
7
8
  /** `ape check …`: checks on the repository, each part of `pnpm lint`. */
@@ -28,4 +29,8 @@ export function addCheckCommand(program) {
28
29
  .command('boundaries')
29
30
  .description("Fail on a module reaching past another's public entry: its files, entities or tables")
30
31
  .action(() => checkBoundaries());
32
+ check
33
+ .command('skills')
34
+ .description(skillsT('skills.command'))
35
+ .action(() => checkSkills());
31
36
  }
@@ -1,4 +1,4 @@
1
- import { type CoreEnv, type ProductConfig, type ProductProcess } from '@buffcore/config';
1
+ import { type CoreEnv, type Hardening, type ProductConfig, type ProductProcess } from '@buffcore/config';
2
2
  export { buffcorePackages, clearExpoCache } from './dev-expo-cache.ts';
3
3
  /** The Docker services file: the product's, or BuffCore's own when in the BuffCore repository. */
4
4
  export declare function composeFile(root: string): string;
@@ -40,13 +40,20 @@ export type DevEnv = Pick<CoreEnv, 'APE_API_PORT' | 'APE_API_URL' | 'APE_ADMIN_U
40
40
  */
41
41
  export declare function devProcesses(root: string, declared: readonly ProductProcess[], env: DevEnv & Pick<CoreEnv, 'APE_ENV'>,
42
42
  /** Start Expo with its cache cleared (`clearExpoCache`). */
43
- clearApp?: boolean): DevProcess[];
43
+ clearApp?: boolean,
44
+ /** The product's `hardening`: its debug options refused before anything starts. */
45
+ hardening?: Hardening): DevProcess[];
44
46
  /**
45
47
  * The admin and app are told the API's address as `APE_API_URL`. On this computer that address
46
48
  * must be the API's own port, or they would call another checkout's API (a copied `.env` where
47
49
  * only `APE_API_PORT` changed). A tunnel or network address is the developer's to name.
48
50
  */
49
51
  export declare function checkApiAddress(env: DevEnv): void;
52
+ /**
53
+ * `.env`'s settings. Node reads its NODE_OPTIONS through --env-file before any code runs, as the
54
+ * shell's, so `ape dev` refuses debugging options in either before starting anything.
55
+ */
56
+ export declare const devSettings: (root: string) => Record<string, string | undefined>;
50
57
  /**
51
58
  * `ape dev`: Docker services and the product's containers (none with `APE_DEV_SERVICES=external`),
52
59
  * then the API with hot reload, the product's other declared processes, and the admin and web app
@@ -7,6 +7,7 @@ import { devAddresses, devPorts, findRoot, loadEnv, loadProduct, uiFolder } from
7
7
  import { clearExpoCache } from './dev-expo-cache.js';
8
8
  import { watchDevOutput } from './dev-output.js';
9
9
  import { watchDevReady } from './dev-ready.js';
10
+ import { refuseDebugStart } from './hardening.js';
10
11
  import { claimBlock } from './port-claims.js';
11
12
  import { containersOf, devCompose } from './services/compose.js';
12
13
  import { runComposeUp } from './services/compose-up.js';
@@ -106,7 +107,13 @@ export function apiFolder(root) {
106
107
  */
107
108
  export function devProcesses(root, declared, env,
108
109
  /** Start Expo with its cache cleared (`clearExpoCache`). */
109
- clearApp = false) {
110
+ clearApp = false,
111
+ /** The product's `hardening`: its debug options refused before anything starts. */
112
+ hardening) {
113
+ refuseDebugStart(hardening, {
114
+ shell: process.env.NODE_OPTIONS,
115
+ '.env': devSettings(root).NODE_OPTIONS,
116
+ });
110
117
  const api = apiFolder(root);
111
118
  return [
112
119
  {
@@ -168,6 +175,14 @@ export function checkApiAddress(env) {
168
175
  throw new Error(`APE_API_URL (${env.APE_API_URL}) is not on APE_API_PORT (${env.APE_API_PORT}). Set both, or the admin and app call another API.`);
169
176
  }
170
177
  }
178
+ /**
179
+ * `.env`'s settings. Node reads its NODE_OPTIONS through --env-file before any code runs, as the
180
+ * shell's, so `ape dev` refuses debugging options in either before starting anything.
181
+ */
182
+ export const devSettings = (root) => {
183
+ const file = join(root, '.env');
184
+ return existsSync(file) ? parseEnv(readFileSync(file, 'utf8')) : {};
185
+ };
171
186
  /**
172
187
  * `ape dev`: Docker services and the product's containers (none with `APE_DEV_SERVICES=external`),
173
188
  * then the API with hot reload, the product's other declared processes, and the admin and web app
@@ -181,15 +196,19 @@ export async function dev() {
181
196
  // This product's block stays claimed, so `ape create` picks another one even while it is stopped.
182
197
  await claimBlock(root, String(Math.floor(env.APE_API_PORT / 100)));
183
198
  const product = await loadProduct(root);
184
- await startDevServices(root, product);
185
199
  const app = uiFolder(root, 'app');
186
200
  const clear = app !== undefined && clearExpoCache(root, app);
201
+ // Before the services: the product's debugging options are refused before anything starts.
202
+ refuseDebugStart(product.hardening, {
203
+ shell: process.env.NODE_OPTIONS,
204
+ '.env': devSettings(root).NODE_OPTIONS,
205
+ });
206
+ await startDevServices(root, product);
207
+ const entries = devProcesses(root, product.processes ?? [], env, clear, product.hardening);
187
208
  if (clear)
188
209
  console.log("BuffCore's packages changed: the app starts with Expo's cache cleared.");
189
- const entries = devProcesses(root, product.processes ?? [], env, clear);
210
+ const values = devSettings(root);
190
211
  console.log(`API ${env.APE_API_URL} · admin ${env.APE_ADMIN_URL} · app ${env.APE_APP_URL}`);
191
- const envFile = join(root, '.env');
192
- const values = existsSync(envFile) ? parseEnv(readFileSync(envFile, 'utf8')) : {};
193
212
  const containerNames = new Set(containersOf(product.processes).map(({ name }) => name));
194
213
  // Keep using the process record for this checkout; readers see each complete update.
195
214
  const record = { pid: process.pid, children: [] };
@@ -15,6 +15,8 @@ export declare function configObject(text: string): {
15
15
  export declare function literalGrants(config: Map<string, Field>): Grants;
16
16
  export declare function readEditConfig(root: string): Promise<{
17
17
  grants: Grants;
18
+ /** The product's own name, as its config writes it. */
19
+ name: () => string;
18
20
  catalog: () => Pick<ProductConfig, 'buffcore' | 'catalog'>;
19
21
  }>;
20
22
  export {};
@@ -108,6 +108,8 @@ export async function readEditConfig(root) {
108
108
  const { fields: config } = configObject(file);
109
109
  return {
110
110
  grants: literalGrants(config),
111
+ /** The product's own name, as its config writes it. */
112
+ name: () => string(config.get('name'), 'name'),
111
113
  catalog: () => {
112
114
  const buffcore = string(config.get('buffcore'), 'buffcore');
113
115
  const node = config.get('catalog');