@buffcore/cli 0.8.41 → 0.8.42

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 (164) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/commands/agents-file.d.ts +5 -0
  3. package/dist/commands/agents-file.js +30 -7
  4. package/dist/commands/change.d.ts +4 -0
  5. package/dist/commands/change.js +12 -5
  6. package/dist/commands/create-block.d.ts +2 -1
  7. package/dist/commands/create-block.js +7 -5
  8. package/dist/commands/create.d.ts +3 -2
  9. package/dist/commands/create.en.js +1 -1
  10. package/dist/commands/create.es.js +1 -1
  11. package/dist/commands/create.js +8 -6
  12. package/dist/commands/design/check.d.ts +2 -0
  13. package/dist/commands/design/check.js +6 -0
  14. package/dist/commands/design/journey-roles.d.ts +6 -0
  15. package/dist/commands/design/journey-roles.js +60 -0
  16. package/dist/commands/design/references.d.ts +3 -0
  17. package/dist/commands/design/references.js +25 -0
  18. package/dist/commands/design/tells-text.js +2 -2
  19. package/dist/commands/design/tells.d.ts +3 -1
  20. package/dist/commands/design/tells.en.d.ts +2 -0
  21. package/dist/commands/design/tells.en.js +2 -0
  22. package/dist/commands/design/tells.es.js +2 -0
  23. package/dist/commands/design/tells.js +10 -7
  24. package/dist/commands/dev.js +3 -0
  25. package/dist/commands/port-claims.d.ts +23 -0
  26. package/dist/commands/port-claims.js +95 -0
  27. package/dist/commands/prototype/browser.d.ts +9 -4
  28. package/dist/commands/prototype/browser.js +26 -18
  29. package/dist/commands/prototype/export-base.d.ts +27 -0
  30. package/dist/commands/prototype/export-base.js +80 -0
  31. package/dist/commands/prototype/export.d.ts +3 -2
  32. package/dist/commands/prototype/export.js +13 -6
  33. package/dist/commands/prototype/index.js +1 -0
  34. package/dist/commands/prototype/media-ready.d.ts +8 -0
  35. package/dist/commands/prototype/media-ready.js +36 -0
  36. package/dist/commands/prototype/messages.en.d.ts +6 -0
  37. package/dist/commands/prototype/messages.en.js +6 -0
  38. package/dist/commands/prototype/messages.js +6 -0
  39. package/dist/commands/prototype/scene.d.ts +3 -1
  40. package/dist/commands/prototype/scene.js +22 -6
  41. package/dist/commands/prototype/snapshot-inputs.js +35 -7
  42. package/dist/commands/prototype/snapshot-setup.d.ts +1 -1
  43. package/dist/commands/prototype/snapshot-setup.js +2 -1
  44. package/dist/commands/prototype/snapshot.d.ts +2 -0
  45. package/dist/commands/prototype/snapshot.js +2 -1
  46. package/dist/commands/ui/chat/allow-folder.js +23 -77
  47. package/dist/commands/ui/chat/claude-permissions.d.ts +21 -0
  48. package/dist/commands/ui/chat/claude-permissions.js +69 -0
  49. package/dist/commands/ui/chat/codex-idle.d.ts +1 -0
  50. package/dist/commands/ui/chat/codex-overrides.js +2 -1
  51. package/dist/commands/ui/chat/codex-permissions.d.ts +12 -0
  52. package/dist/commands/ui/chat/codex-permissions.js +97 -0
  53. package/dist/commands/ui/chat/command-parts.d.ts +33 -0
  54. package/dist/commands/ui/chat/command-parts.js +219 -0
  55. package/dist/commands/ui/chat/command-wrappers.d.ts +21 -0
  56. package/dist/commands/ui/chat/command-wrappers.js +100 -0
  57. package/dist/commands/ui/chat/design-deletes.d.ts +1 -0
  58. package/dist/commands/ui/chat/design-deletes.js +39 -0
  59. package/dist/commands/ui/chat/launch-input.d.ts +4 -2
  60. package/dist/commands/ui/chat/launch-input.js +16 -3
  61. package/dist/commands/ui/chat/limit-mentions.d.ts +5 -0
  62. package/dist/commands/ui/chat/limit-mentions.js +74 -0
  63. package/dist/commands/ui/chat/limit-patterns.d.ts +15 -0
  64. package/dist/commands/ui/chat/limit-patterns.js +182 -0
  65. package/dist/commands/ui/chat/limits-hook.d.ts +1 -0
  66. package/dist/commands/ui/chat/limits-hook.js +30 -0
  67. package/dist/commands/ui/chat/limits.d.ts +37 -0
  68. package/dist/commands/ui/chat/limits.en.d.ts +18 -0
  69. package/dist/commands/ui/chat/limits.en.js +18 -0
  70. package/dist/commands/ui/chat/limits.es.d.ts +2 -0
  71. package/dist/commands/ui/chat/limits.es.js +17 -0
  72. package/dist/commands/ui/chat/limits.js +224 -0
  73. package/dist/commands/ui/chat/local-settings.d.ts +17 -0
  74. package/dist/commands/ui/chat/local-settings.js +73 -0
  75. package/dist/commands/ui/chat/opencode-config.d.ts +22 -0
  76. package/dist/commands/ui/chat/opencode-config.js +83 -0
  77. package/dist/commands/ui/chat/parse-claude.js +18 -2
  78. package/dist/commands/ui/chat/permission-ask.d.ts +44 -0
  79. package/dist/commands/ui/chat/permission-ask.js +142 -0
  80. package/dist/commands/ui/chat/permission-channel.d.ts +18 -0
  81. package/dist/commands/ui/chat/permission-channel.js +67 -0
  82. package/dist/commands/ui/chat/permission-route.d.ts +10 -0
  83. package/dist/commands/ui/chat/permission-route.js +47 -0
  84. package/dist/commands/ui/chat/permission-tool.d.ts +1 -0
  85. package/dist/commands/ui/chat/permission-tool.js +86 -0
  86. package/dist/commands/ui/chat/permissions.d.ts +11 -12
  87. package/dist/commands/ui/chat/permissions.js +20 -102
  88. package/dist/commands/ui/chat/planning-limits.d.ts +12 -0
  89. package/dist/commands/ui/chat/planning-limits.js +31 -0
  90. package/dist/commands/ui/chat/process.js +4 -1
  91. package/dist/commands/ui/chat/prompt.d.ts +8 -1
  92. package/dist/commands/ui/chat/prompt.en.d.ts +4 -0
  93. package/dist/commands/ui/chat/prompt.en.js +4 -0
  94. package/dist/commands/ui/chat/prompt.es.d.ts +4 -0
  95. package/dist/commands/ui/chat/prompt.es.js +4 -0
  96. package/dist/commands/ui/chat/prompt.js +18 -50
  97. package/dist/commands/ui/chat/recorded-turn.js +3 -0
  98. package/dist/commands/ui/chat/routes.js +2 -0
  99. package/dist/commands/ui/chat/secret-folders.d.ts +16 -0
  100. package/dist/commands/ui/chat/secret-folders.js +35 -0
  101. package/dist/commands/ui/chat/stdin-shells.d.ts +8 -0
  102. package/dist/commands/ui/chat/stdin-shells.js +102 -0
  103. package/dist/commands/ui/chat/step-rules.d.ts +13 -0
  104. package/dist/commands/ui/chat/step-rules.js +47 -0
  105. package/dist/commands/ui/chat/store.js +11 -2
  106. package/dist/commands/ui/chat/stream.en.d.ts +6 -0
  107. package/dist/commands/ui/chat/stream.en.js +6 -0
  108. package/dist/commands/ui/chat/stream.es.d.ts +6 -0
  109. package/dist/commands/ui/chat/stream.es.js +6 -0
  110. package/dist/commands/ui/chat/stream.js +4 -1
  111. package/dist/commands/ui/chat/turn-guard.d.ts +25 -0
  112. package/dist/commands/ui/chat/turn-guard.js +74 -0
  113. package/dist/commands/ui/chat/turn-input.d.ts +3 -2
  114. package/dist/commands/ui/chat/turn-input.js +3 -1
  115. package/dist/commands/ui/chat/turn-scenes.d.ts +19 -0
  116. package/dist/commands/ui/chat/turn-scenes.js +44 -0
  117. package/dist/commands/ui/chat/turn-state.d.ts +6 -0
  118. package/dist/commands/ui/chat/turn.js +8 -3
  119. package/dist/commands/ui/level-route.js +8 -3
  120. package/dist/commands/ui/page.d.ts +19 -1
  121. package/dist/commands/ui/page.js +9 -6
  122. package/dist/commands/ui/plan-structure.d.ts +9 -2
  123. package/dist/commands/ui/plan-structure.en.d.ts +1 -0
  124. package/dist/commands/ui/plan-structure.en.js +1 -0
  125. package/dist/commands/ui/plan-structure.es.d.ts +1 -0
  126. package/dist/commands/ui/plan-structure.es.js +1 -0
  127. package/dist/commands/ui/plan-structure.js +36 -10
  128. package/dist/commands/ui/prototype-main.d.ts +1 -0
  129. package/dist/commands/ui/prototype-scenes-child.js +3 -1
  130. package/dist/commands/ui/prototype-scenes-read.d.ts +1 -0
  131. package/dist/commands/ui/prototype-scenes-route.js +7 -1
  132. package/dist/commands/ui/save-commit.js +6 -2
  133. package/dist/commands/ui/server-options.js +2 -0
  134. package/dist/commands/ui/server.d.ts +5 -22
  135. package/dist/commands/ui/server.js +3 -45
  136. package/dist/commands/ui/snapshot-runners.d.ts +22 -0
  137. package/dist/commands/ui/snapshot-runners.js +45 -0
  138. package/dist/commands/ui/studio-routes.d.ts +1 -0
  139. package/dist/commands/ui/studio-routes.js +1 -0
  140. package/dist/commands/ui/studio-state.d.ts +3 -0
  141. package/dist/commands/ui/studio-state.js +1 -0
  142. package/dist/commands/ui/studio.en.d.ts +13 -0
  143. package/dist/commands/ui/studio.en.js +13 -0
  144. package/dist/commands/ui/studio.es.d.ts +13 -0
  145. package/dist/commands/ui/studio.es.js +13 -0
  146. package/dist/commands/ui/theme-option.d.ts +8 -0
  147. package/dist/commands/ui/theme-option.js +40 -0
  148. package/dist/commands/ui/theme-values.d.ts +5 -0
  149. package/dist/commands/ui/theme-values.js +113 -0
  150. package/dist/ui/page.js +93 -93
  151. package/docs/PROTOTYPE.md +4 -1
  152. package/docs/WORKBENCH.md +76 -22
  153. package/package.json +11 -11
  154. package/skills/ape-critique/SKILL.md +8 -4
  155. package/skills/ape-design-system/SKILL.md +3 -3
  156. package/skills/ape-plan-change/SKILL.md +7 -3
  157. package/skills/ape-prototype/SKILL.md +8 -1
  158. package/templates/example/apps/app/src/i18n/en.ts +2 -0
  159. package/templates/example/apps/app/src/i18n/es.json +2 -0
  160. package/templates/product/apps/admin/src/fonts.ts +2 -1
  161. package/templates/product/apps/app/src/fonts.ts +5 -1
  162. package/templates/product/apps/app/src/i18n/en.ts +2 -0
  163. package/templates/product/apps/app/src/i18n/es.json +2 -0
  164. package/templates/product/prototype/journeys.ts +3 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,31 @@ One section per release (a git tag). **Upgrade notes** list anything that breaks
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## v0.8.42 (2026-12-02)
8
+
9
+ - A host fills more of the studio (`createUiServer({ signIn, hostParts })`): modules at `side:prototype` (beside the prototype; a tab named with the host's label on a phone), `approve:release` and `card:server`, each mounted as `mount(element, viewer, subject)` with plain JSON (`HostSubjects`: the change and version, the release, and the server; the release's `approval` is absent until release approval records exist); `rail: [{ id, label, source, icon? }]` entries at the rail's end, drawn as rail rows, each opening its module on the `page` place; and `label`, the host's name over its rail entries and on its badges. A changed subject remounts only that place. The same trust rules apply: root-relative same-origin URLs, only with `signIn`. React `parts` at those three places get the same subject as a third argument of `draw` ([WORKBENCH.md](docs/WORKBENCH.md#modules-through-the-built-in-page)).
10
+ - `createUiServer({ theme })` draws the studio in a host's theme, the same `Theme` as `studioTheme`, made with `extendStudioTheme` from `@buffcore/admin-shell/workbench`. Every value is read by its kind (only the studio's modes; colors, lengths, numbers, shadows and font names, nothing that writes CSS of its own; set-aside checks only the studio's own two), then by `checkTheme`; any problem refuses to start and lists every problem. `toCss` leaves out a declaration or mode name that would leave its rule; the layout stays, and a font the studio does not ship must already be available. A host that passes neither gets the same page as before.
11
+
12
+ **Upgrade notes** (every product):
13
+ the `side:prototype` place moved from the Prototype journeys column to beside the prototype, so it is at version 2; a React part registered there now draws in that column (or its phone tab).
14
+ - `ape change <id> --check --no-service-probe` (or `APE_CHECK_SERVICE_PROBE=off`) skips only the question to the configured development services, so a sealed caller with no services reaches the checks; the isolated environment, migration checks, approved commands, JSON and exit codes stay the same. Off by default, and `ape dev` is unchanged.
15
+ - `ape prototype export --base <path>` builds the static export for another path (`/s/abc/`), or for any path with `./`; the default, `/`, is unchanged. Its files and the viewer's routes follow the base, the entry `index.html` stays at the root, and it plays inside a frame sandboxed with `allow-scripts` alone when its files are served with `Access-Control-Allow-Origin: *` ([PROTOTYPE.md](docs/PROTOTYPE.md#a-commit-as-static-files)). A base that is not a plain path is refused. Under a plain path each page uses the root it was built for, never one read from the address; the export's development builds carry source maps and any inlined `VITE_*` and `EXPO_PUBLIC_*` values, so keep secrets out of them.
16
+ - Saving a step takes one click. A planning step's own unsaved files, and the Prototype step's unsaved source, show their file list with the step's files ticked and one **Save** (in place of Save this step, I reviewed this file set and Save this reviewed set). The server still checks the files are the ones shown: unticking or ticking a file asks for the new list's fingerprint first, and when the files changed since, the list comes back with "This changed since you looked" and one more Save. Record version saves the list shown in the same click. Brand asks for its list when its page opens, so it is one Save too; a change in its own checkout lists its files on its first Save. On a hosted studio the list is asked for only for a viewer with the `build` right, which saving needs. Autopilot's automatic save is unchanged. No upgrade notes.
17
+ - The studio's Structure step holds planned sections: a row in `plan/structure.md` may name the change that adds its first screen, `/billing (planned, C-020)`, checked against that change's screens. It shows as planned until the route exists, then as an ordinary row. "Your app, in plain words" shows each question's answer from the file, or "Answer this in the chat" (English and Spanish). A structure row in the workbench plan contract may carry `planned`. No upgrade notes.
18
+ - Journeys say who they are for: the `ape-prototype` skill asks for a `role` (an i18n key, one of the people in `plan/journeys.md`) on every journey, and `ape design check` warns, never fails, when a row of `plan/journeys.md` has no Actor or a journey in `prototype/journeys.ts` has no `role`. `ape design check --json` lists them in a new `warnings` array. A new product's three sample journeys name theirs (`prototype.role.member` and `prototype.role.owner`, English and Spanish). No upgrade notes: an existing product's journeys without a role only warn.
19
+ - A Prototype turn that changed scenes ends with links that open those scenes in the preview (English and Spanish). The studio's scene read now carries each scene's view name for this, inside the studio only; `/api/prototype/scenes` answers as before. A chat turn's end record may carry `scenes`. No upgrade notes.
20
+ - `ape create` (and `npm create @buffcore`) skips a port block another product on this computer has claimed, even while it is stopped: a product folder beside the new one, or `ports.json` in your config folder, which create and `ape dev` keep up to date. A list that can't be read changes nothing. No upgrade notes.
21
+ - The design system keeps `design/references.md` (in place of `design/study.md`): the reference study and the paths of its pictures, which stay outside the repository. The `ape-design-system` skill writes it, `ape-prototype` reads it before drawing, and `ape-critique` looks there first for references, at the product's desktop frame. `ape design check` notes, without failing, a picture it names that is not on this computer. The prototype and critique skills say plainly that the agent that drew the scenes never runs the critique in its own turn. No upgrade notes: rename a `design/study.md` to `design/references.md` to keep it read.
22
+ - `ape prototype snapshot` waits for a scene's fonts and pictures before each picture: `document.fonts.ready` and every `<img>` loaded or failed (lazy ones loaded at once), in the page and its framed scenes, for at most 10 seconds. Past that it takes the picture anyway and adds a hint naming the scene (English and Spanish). No upgrade notes.
23
+ - The design system's own fonts load by themselves: put each family's files in `design/fonts/`, named from the family (`InterVariable.woff2`, `Fraunces-SemiBold.woff2`), and the console, its prototype viewer and its scenes give every family the theme names an `@font-face` from them; a family with no file stays the system's. A file belongs to a family when its name is the family without spaces, then nothing, a suffix after `-` or `_`, or `Variable` (`RobotoMono-Bold.woff2` is not "Roboto"). The console's Vite plugin serves and builds them under `/_fonts/`, and `ape prototype snapshot` counts them in an admin scene's fingerprint, so a changed font file shoots the console's scenes again and unchanged ones are reused. The app does not find them by itself: its `fonts` map takes one line per family by hand, with a TTF or OTF file (`require('../../../design/fonts/<file>.ttf')`), as phones load only those. `ape design check` counts a file there as loaded, and skips web addresses and network shares in `design/references.md`. New in `@buffcore/tokens`: `themeFontFiles`, `fontFaceCss`, `fontFileSuffix`, `themeFamilies`. The playground's console pictures change once; its JetBrains Mono file is given every weight (100 to 900) though it holds 100 to 800. No upgrade notes: a product without `design/fonts/` is unchanged.
24
+ - A product sets its desktop scene frame in `buffcore.config.ts`: `prototype: { frame: { width: 1280, height: 800 } }` (whole pixels, 320 to 3840 wide and 320 to 2400 high). The viewer and `ape prototype snapshot` show `desktop` scenes at it, so the compare and the critique see it too. `frameSizes(product)` in `@buffcore/config` gives every frame's size.
25
+
26
+ **Upgrade notes** (every product):
27
+ the default desktop frame moved from 1280 by 800 to 1440 by 900, so `desktop` scenes' pictures change once; set `prototype.frame` to `{ width: 1280, height: 800 }` to keep the old one. The next full snapshot shoots every scene again once, as its fingerprint changed; after that a new `prototype.frame` shoots only the `desktop` scenes again.
28
+ - The studio's agent permissions follow the development level. On You drive, Review and Lead, a command outside the step's list no longer ends the turn: the chat shows "Your agent wants to run this" with Allow once, Always allow in this step (kept in `.claude/settings.local.json`) and Refuse, and a refused agent hears which part and what to run alone. Autopilot runs Claude Code's `auto` mode with no step list, and the new "Never ask" setting under Autopilot (off by default, with its warning) runs with no permission checks. At every level, Never ask included, a hook the studio installs refuses reading folders of sign-ins or keys, deploys, production settings files and `git push`, and holds network downloads for a person's click. Design turns may run `pnpm format` and delete files in `design/` and `prototype/`. Planning and loop turns on Autopilot run `auto` (or no checks with Never ask) under the same limits, without their two-command list; below Autopilot they keep `dontAsk`, with deny rules for the limits. OpenCode on Autopilot runs with `--auto` and no command list, and carries the limits as its own deny rules at every level; Codex already never asks inside its sandbox, at every level. When a model can't run Auto mode, the chat says the agent will ask instead. No upgrade notes: `plan/agents.md` gains an optional `neverAsk`; the studio's state, chats and level body gain optional fields.
29
+ - The studio's limits no longer let a command they cannot vouch for run silently. After the command check refuses nothing, the studio reads the command's whole text: when it still mentions `git push`, `ape deploy`, a folder of sign-ins or keys, a production settings file or a download program, and also when a shell or interpreter reads its script from standard input (`echo … | sh`, `bash <<'EOF'`), a here-document never reaches its end line, `Invoke-Expression` (`iex`) runs text, or the command is too long or nested to read, the card asks the person, at every level including Never ask, with Allow once only and the reason ("This command mentions `git push`; the studio couldn't tell if it runs it."). A commit message that mentions one of these costs one click. The check always answers in well under a second, so the hook's timeout can't let a call through. `git --git-dir x push` and an end word written `E"OF"` are now refused outright, and a word after `-m` is skipped only for `git commit` and `git tag` (English and Spanish). The chat's `asking` card gains an optional `unsure` (`why`, `mention`); no upgrade notes: nothing changes for an existing product.
30
+ - The studio's permission card sits at the end of the chat, as drawn: Allow once first, Always allow in this step and Refuse below it, and "Paused until you answer". While it waits, the page's own primary button (such as the Prototype step's Approve) draws as secondary. An answer folds the card to one line while the turn goes on ("Allowed once", or "Always allowed in this step" with where it is kept), or to "Refused" with what the agent was told. "Never ask" is a switch inside the Autopilot card, shown only while Autopilot is chosen, with its warning once on; on a phone the settings sheet names the level with Never ask in words. A reply's scene links are buttons under "Changed, open in preview:" (English and Spanish). No upgrade notes.
31
+
7
32
  ## v0.8.41 (2026-12-01)
8
33
 
9
34
  - Three new starter themes, `themes.clear`, `themes.warm` and `themes.bold`, each with its own ground, main color, type, corners and one-line voice, in light, dark and high contrast. The Brand step offers these three first, so its cards look clearly different; a product's current starter still shows beside them. `themes.neutral` and `themes.soft` stay. No upgrade notes: nothing changes for an existing product.
@@ -17,6 +17,10 @@ export declare function committedLevel(root: string): AgentsFile['level'];
17
17
  export declare function mainAgentsRoot(root: string): string;
18
18
  /** A pending downgrade limits authority immediately; only committed main can grant more. */
19
19
  export declare function effectiveLevel(root: string): AgentsFile['level'];
20
+ /** "Never ask" holds only on Autopilot, on in main's commit and in the working copy alike. */
21
+ export declare const neverAsk: (committed?: AgentsFile, working?: AgentsFile) => boolean;
22
+ /** Whether "Never ask" is in effect for a launch now; anything unreadable leaves it off. */
23
+ export declare function effectiveNeverAsk(root: string): boolean;
20
24
  /** Model and effort come from main. A prior read lets who compare the same contents. */
21
25
  export declare function committedOverrides(root: string, settings: AgentsFile, committed?: AgentsFileBytes): Promise<AgentSettings>;
22
26
  /**
@@ -30,6 +34,7 @@ export declare function committedOverrides(root: string, settings: AgentsFile, c
30
34
  export declare function agentLevels(root: string, withCommit?: boolean, strict?: boolean): Promise<{
31
35
  committed: AgentsFile['level'];
32
36
  effective: AgentsFile['level'];
37
+ neverAsk: boolean;
33
38
  commit?: string;
34
39
  }>;
35
40
  /** Writes the front matter only; the file's body is kept. */
@@ -71,6 +71,9 @@ export async function readAgentsFile(root) {
71
71
  }
72
72
  /** Only main's committed settings grant authority; missing or damaged settings ask the person. */
73
73
  export function committedLevel(root) {
74
+ return committedAgents(root)?.level ?? 'guide';
75
+ }
76
+ function committedAgents(root) {
74
77
  try {
75
78
  const text = execFileSync('git', ['--no-optional-locks', 'show', `${MAIN_REF}:./plan/agents.md`], {
76
79
  cwd: root,
@@ -80,10 +83,10 @@ export function committedLevel(root) {
80
83
  timeout: 10_000,
81
84
  maxBuffer: AGENTS_FILE_LIMIT,
82
85
  });
83
- return parseCommittedAgents(text).level;
86
+ return parseCommittedAgents(text);
84
87
  }
85
88
  catch {
86
- return 'guide';
89
+ return undefined;
87
90
  }
88
91
  }
89
92
  /** The path of main's registered checkout in `git worktree list --porcelain -z`. */
@@ -117,6 +120,21 @@ export function effectiveLevel(root) {
117
120
  }
118
121
  return limitedLevel(committed, working);
119
122
  }
123
+ /** "Never ask" holds only on Autopilot, on in main's commit and in the working copy alike. */
124
+ export const neverAsk = (committed, working) => committed?.level === 'auto' &&
125
+ committed.neverAsk === true &&
126
+ working?.level === 'auto' &&
127
+ working.neverAsk === true;
128
+ /** Whether "Never ask" is in effect for a launch now; anything unreadable leaves it off. */
129
+ export function effectiveNeverAsk(root) {
130
+ try {
131
+ const working = parseAgentsFile(readFileSync(join(mainAgentsRoot(root), 'plan/agents.md'), 'utf8'));
132
+ return neverAsk(committedAgents(root), working);
133
+ }
134
+ catch {
135
+ return false;
136
+ }
137
+ }
120
138
  const gitAsync = promisify(execFile);
121
139
  const asyncGit = async (root, args, maxBuffer) => (await gitAsync('git', ['--no-optional-locks', ...args], {
122
140
  cwd: root,
@@ -173,10 +191,9 @@ export async function agentLevels(root, withCommit = false, strict = false) {
173
191
  .catch(() => undefined)
174
192
  : undefined;
175
193
  const committed = read(['show', `${commit ?? MAIN_REF}:./plan/agents.md`], AGENTS_FILE_LIMIT)
176
- .then((text) => parseCommittedAgents(text).level)
194
+ .then((text) => parseCommittedAgents(text))
177
195
  .catch(() => {
178
196
  commit = undefined;
179
- return 'guide';
180
197
  });
181
198
  const working = Promise.all([
182
199
  read(['worktree', 'list', '--porcelain', '-z']),
@@ -184,14 +201,20 @@ export async function agentLevels(root, withCommit = false, strict = false) {
184
201
  ])
185
202
  .then(async ([list, prefix]) => {
186
203
  const text = await readFile(join(mainCheckout(list), prefix.trim(), 'plan/agents.md'), 'utf8');
187
- return parseAgentsFile(text).level;
204
+ return parseAgentsFile(text);
188
205
  })
189
206
  // An unreadable draft grants no additional authority.
190
- .catch(() => 'guide');
207
+ .catch(() => undefined);
191
208
  const [saved, draft] = await Promise.all([committed, working]);
192
209
  if (strict && unread)
193
210
  throw new Error('levels_unread');
194
- return { committed: saved, effective: limitedLevel(saved, draft), ...(commit ? { commit } : {}) };
211
+ const level = saved?.level ?? 'guide';
212
+ return {
213
+ committed: level,
214
+ effective: limitedLevel(level, draft?.level ?? 'guide'),
215
+ neverAsk: neverAsk(saved, draft),
216
+ ...(commit ? { commit } : {}),
217
+ };
195
218
  }
196
219
  /** Writes the front matter only; the file's body is kept. */
197
220
  export async function writeAgentsFile(root, file) {
@@ -61,7 +61,11 @@ export interface ChangeOptions {
61
61
  fromError?: string;
62
62
  /** Internal: write this product's facts to the file (the refactor proof, on its base). */
63
63
  facts?: string;
64
+ /** False (`--no-service-probe`) skips only the configured services' reachability probe. */
65
+ serviceProbe?: boolean;
64
66
  }
67
+ /** A sealed caller turns the services probe off with the flag or `APE_CHECK_SERVICE_PROBE=off`. */
68
+ export declare function probesServices(options: ChangeOptions, env?: NodeJS.ProcessEnv): boolean;
65
69
  type Touches = ReturnType<typeof resolveTouches>;
66
70
  /** The result `--json` prints (and the words are made from): a list, or one change. */
67
71
  export interface ChangeResult {
@@ -47,6 +47,10 @@ export function resolveTouches(touches, manifest) {
47
47
  services: touches.services.map(service),
48
48
  };
49
49
  }
50
+ /** A sealed caller turns the services probe off with the flag or `APE_CHECK_SERVICE_PROBE=off`. */
51
+ export function probesServices(options, env = process.env) {
52
+ return options.serviceProbe !== false && env.APE_CHECK_SERVICE_PROBE?.toLowerCase() !== 'off';
53
+ }
50
54
  export async function changeResult(id, options, load, root = findRoot()) {
51
55
  if (!id && options.check) {
52
56
  id = branchChange(root);
@@ -87,10 +91,12 @@ export async function changeResult(id, options, load, root = findRoot()) {
87
91
  const message = await currentMigrationClash(root);
88
92
  if (message)
89
93
  return { ok: false, message };
90
- const env = scope.linked ? scope.environment : serviceEnvWithExample(root, scope.environment);
91
- const unavailable = await unavailableService(env, root);
92
- if (unavailable)
93
- return { ok: false, message: unavailable };
94
+ if (probesServices(options)) {
95
+ const env = scope.linked ? scope.environment : serviceEnvWithExample(root, scope.environment);
96
+ const unavailable = await unavailableService(env, root);
97
+ if (unavailable)
98
+ return { ok: false, message: unavailable };
99
+ }
94
100
  }
95
101
  const touches = resolveTouches(change.touches, await load());
96
102
  const refactor = options.check && change.type === 'refactor';
@@ -144,9 +150,10 @@ async function newFromError(options) {
144
150
  export function addChangeCommand(program) {
145
151
  const command = program
146
152
  .command('change [id]')
147
- .usage('[id] [--check] [--json] | new --from-error <group>')
153
+ .usage('[id] [--check [--no-service-probe]] [--json] | new --from-error <group>')
148
154
  .description("The plan's changes (plan/changes); with an id, the change, its branch and what it touches, resolved against the manifest")
149
155
  .option('--check', "run the change's done-when checks; a refactor's proof first")
156
+ .option('--no-service-probe', "with --check: don't ask the configured services for a reply first (or APE_CHECK_SERVICE_PROBE=off)")
150
157
  .option('--base <ref>', "a refactor's base: its merge base with HEAD (default main)")
151
158
  .option('--from-error <group>', 'with `new`: write a fix change from an error group (its id)')
152
159
  .addOption(new Option('--facts <file>').hideHelp())
@@ -16,4 +16,5 @@ export declare function productPorts(block: string): {
16
16
  };
17
17
  /** A block is usable only if this computer can bind each port on every IPv4 address. */
18
18
  export declare const portFree: PortCheck;
19
- export declare function selectBlock(given: string | undefined, check: PortCheck): Promise<string>;
19
+ /** A block the person names is checked by its ports only; a chosen one also skips claims. */
20
+ export declare function selectBlock(given: string | undefined, check: PortCheck, claimed?: ReadonlySet<string>): Promise<string>;
@@ -31,17 +31,19 @@ async function takenPorts(block, check) {
31
31
  const free = await Promise.all(ports.map((port) => check(port)));
32
32
  return ports.filter((_, i) => !free[i]);
33
33
  }
34
- async function firstFree(check, skip) {
34
+ /** The first block from 44 whose ports are free and that no other product claims. */
35
+ async function firstFree(check, claimed, skip) {
35
36
  for (let block = 44; block <= 64; block++) {
36
37
  const value = String(block);
37
- if (value !== skip && !(await takenPorts(value, check)).length)
38
+ if (value !== skip && !claimed.has(value) && !(await takenPorts(value, check)).length)
38
39
  return value;
39
40
  }
40
41
  return null;
41
42
  }
42
- export async function selectBlock(given, check) {
43
+ /** A block the person names is checked by its ports only; a chosen one also skips claims. */
44
+ export async function selectBlock(given, check, claimed = new Set()) {
43
45
  if (given === undefined) {
44
- const block = await firstFree(check);
46
+ const block = await firstFree(check, claimed);
45
47
  if (block)
46
48
  return block;
47
49
  throw new CreateRefused(t('create.noFreeBlock'));
@@ -49,7 +51,7 @@ export async function selectBlock(given, check) {
49
51
  const taken = await takenPorts(given, check);
50
52
  if (!taken.length)
51
53
  return given;
52
- const next = await firstFree(check, given);
54
+ const next = await firstFree(check, claimed, given);
53
55
  const locale = new Intl.NumberFormat().resolvedOptions().locale;
54
56
  const ports = new Intl.ListFormat(locale, { type: 'conjunction' }).format(taken.map((port) => portText(port, locale)));
55
57
  const hint = next
@@ -1,5 +1,6 @@
1
1
  import type { Command } from 'commander';
2
2
  import { type PortCheck } from './create-block.ts';
3
+ import { type PortClaims } from './port-claims.ts';
3
4
  export { nextSteps } from './create-steps.ts';
4
5
  interface CreateOptions {
5
6
  cwd?: string;
@@ -12,7 +13,7 @@ interface CreateOptions {
12
13
  /** A comma list that includes web; every platform when left out. */
13
14
  platforms?: string;
14
15
  }
15
- export declare function copyProject(name: string, options: CreateOptions, check: PortCheck): Promise<{
16
+ export declare function copyProject(name: string, options: CreateOptions, check: PortCheck, claims?: PortClaims): Promise<{
16
17
  block: string;
17
18
  target: string;
18
19
  copied: {
@@ -24,7 +25,7 @@ export declare function copyProject(name: string, options: CreateOptions, check:
24
25
  platforms: ("android" | "ios" | "web")[];
25
26
  }>;
26
27
  /** --json owns stdout: one line, exit 0 made, 1 refused, 2 could not run. */
27
- export declare function create(name: string, options: CreateOptions, command?: Pick<Command, 'getOptionValueSource'>, check?: PortCheck): Promise<void>;
28
+ export declare function create(name: string, options: CreateOptions, command?: Pick<Command, 'getOptionValueSource'>, check?: PortCheck, claims?: PortClaims): Promise<void>;
28
29
  /** pnpm 9 reads this setting from .npmrc; keep an existing product's other settings. */
29
30
  export declare function writeNpmrc(target: string, registry: string | null): Promise<boolean>;
30
31
  /** The product's .npmrc for a registry, or null for npm's public one (or none). */
@@ -2,6 +2,6 @@ export const en = {
2
2
  'create.noFreeBlock': 'No free port block from 44 to 64 on this computer. Free its ports and try again.',
3
3
  'create.portsTaken': 'Ports {ports} are in use on this computer. {hint}',
4
4
  'create.freeBlock': 'Pick another block: --block {block} is free.',
5
- 'create.skippedBlock': 'Block 44 is in use here; using {block}.',
5
+ 'create.skippedBlock': 'Block 44 is in use or claimed by another product on this computer; using {block}.',
6
6
  'create.firstCommit': 'First commit skipped: set git config user.name and git config user.email, then run git add -A and git commit -m "chore: a new BuffCore product".',
7
7
  };
@@ -2,6 +2,6 @@ export const es = {
2
2
  'create.noFreeBlock': 'No hay un bloque de puertos libre entre 44 y 64 en este equipo. Libera sus puertos e inténtalo de nuevo.',
3
3
  'create.portsTaken': 'Los puertos {ports} están en uso en este equipo. {hint}',
4
4
  'create.freeBlock': 'Elige otro bloque: --block {block} está libre.',
5
- 'create.skippedBlock': 'El bloque 44 está en uso aquí; se usará el {block}.',
5
+ 'create.skippedBlock': 'El bloque 44 está en uso o lo reservó otro producto en este equipo; se usará el {block}.',
6
6
  'create.firstCommit': 'Se omitió el primer commit: configura git config user.name y git config user.email, luego ejecuta git add -A y git commit -m "chore: a new BuffCore product".',
7
7
  };
@@ -10,6 +10,7 @@ import { CreateRefused, portFree, portText, productPorts, selectBlock, } from '.
10
10
  import { createAgents, nextCommands, nextSteps, t, wireExtension, wireStandalone, } from './create-steps.js';
11
11
  import { writeTemplates } from './create-template.js';
12
12
  import { listedPlatforms, parsePlatforms, setPlatformsText } from './platforms-list.js';
13
+ import { machineClaims } from './port-claims.js';
13
14
  import { writeSkillsList } from './skills-list.js';
14
15
  export { nextSteps } from './create-steps.js';
15
16
  const here = dirname(fileURLToPath(import.meta.url));
@@ -56,9 +57,9 @@ async function writeSecrets(target) {
56
57
  .replace(/^APE_ENCRYPTION_KEY=.*$/m, `APE_ENCRYPTION_KEY=${randomBytes(32).toString('base64')}`);
57
58
  await writeFile(env, text);
58
59
  }
59
- export async function copyProject(name, options, check) {
60
+ export async function copyProject(name, options, check, claims) {
60
61
  const { target, skills, platforms } = inputs(name, options);
61
- const block = await selectBlock(options.block, check);
62
+ const block = await selectBlock(options.block, check, claims?.claimed(target));
62
63
  const copied = await writeTemplates(target, {
63
64
  name,
64
65
  appId: name.replaceAll('-', ''),
@@ -88,9 +89,10 @@ export async function copyProject(name, options, check) {
88
89
  await writeSecrets(target);
89
90
  return { block, target, copied, listed, fromCheckout, platforms: listedNow };
90
91
  }
91
- async function scaffold(name, given, check) {
92
+ async function scaffold(name, given, check, claims) {
92
93
  const options = { ...given, extension: given.extension || given.standalone };
93
- const { block, target, copied, listed, fromCheckout, platforms } = await copyProject(name, options, check);
94
+ const { block, target, copied, listed, fromCheckout, platforms } = await copyProject(name, options, check, claims);
95
+ await claims.claim(target, block);
94
96
  const commands = existsSync(join(target, '.git')) ? [] : [['init', '-q', '-b', 'main']];
95
97
  for (const args of commands)
96
98
  runGit(target, args);
@@ -155,12 +157,12 @@ function printCreated(made) {
155
157
  console.log(nextSteps(folder, fromCheckout));
156
158
  }
157
159
  /** --json owns stdout: one line, exit 0 made, 1 refused, 2 could not run. */
158
- export async function create(name, options, command, check = portFree) {
160
+ export async function create(name, options, command, check = portFree, claims = machineClaims) {
159
161
  try {
160
162
  const given = command?.getOptionValueSource('block') === 'default'
161
163
  ? { ...options, block: undefined }
162
164
  : options;
163
- const made = await scaffold(name, given, check);
165
+ const made = await scaffold(name, given, check, claims);
164
166
  if (made.commitSkipped && !options.json) {
165
167
  console.error(t('create.firstCommit'));
166
168
  }
@@ -9,6 +9,8 @@ export interface DesignCheckResult {
9
9
  /** The product's own components, by name. */
10
10
  components: string[];
11
11
  problems: DesignProblem[];
12
+ /** Advice that never fails the check: journeys that name no role. */
13
+ warnings: string[];
12
14
  }
13
15
  export declare function designCheck(root: string, advise?: (lines: string[]) => void): Promise<DesignCheckResult>;
14
16
  /** `ape design check [--json]`: exit 0 ok, 1 a problem found, 2 couldn't run. */
@@ -7,6 +7,8 @@ import { readFile } from 'node:fs/promises';
7
7
  import { join } from 'node:path';
8
8
  import { findRoot } from '../../project.js';
9
9
  import { printJson } from '../json.js';
10
+ import { journeyRoleWarnings } from './journey-roles.js';
11
+ import { missingReferences } from './references.js';
10
12
  import { outsideComponents, rawValues } from './rules.js';
11
13
  import { componentFiles, componentName, fontFiles, fromRoot, isShowcaseFile, loadShowcase, screenFiles, } from './sources.js';
12
14
  import { designState } from './state.js';
@@ -162,6 +164,7 @@ async function designHints(root, sources) {
162
164
  const extra = await Promise.all(texts.map((file) => readFile(file, 'utf8')));
163
165
  tells.push(...unloadedFonts(fonts, [...sources.values(), ...extra], assets));
164
166
  }
167
+ tells.push(...(await missingReferences(root)));
165
168
  return hintLines(tells);
166
169
  }
167
170
  catch {
@@ -194,12 +197,15 @@ export async function designCheck(root, advise) {
194
197
  files: [...scanned.map((f) => fromRoot(root, f)), DESIGN, MANIFEST],
195
198
  components: components.map(componentName),
196
199
  problems,
200
+ warnings: await journeyRoleWarnings(root),
197
201
  };
198
202
  }
199
203
  function print(result) {
200
204
  console.log(`Read ${result.files.length} file(s): the screens, design/components/ and the design contract (${result.components.length} component(s)).`);
201
205
  for (const p of result.problems)
202
206
  console.log(` ${p.rule.padEnd(9)} ${p.file}${p.line ? `:${p.line}` : ''} ${p.detail}`);
207
+ for (const warning of result.warnings)
208
+ console.log(warning);
203
209
  console.log(result.ok
204
210
  ? 'The design system holds: no raw colors, fonts or sizes, every component from it, every component showcased, and its design contract in place.'
205
211
  : `\n${result.problems.length} problem(s).`);
@@ -0,0 +1,6 @@
1
+ /** Journey names in `plan/journeys.md` tables whose Actor column is missing or empty. */
2
+ export declare function planJourneysWithoutRole(text: string): string[];
3
+ /** Journey keys in `prototype/journeys.ts` whose entry has no `role`. */
4
+ export declare function prototypeJourneysWithoutRole(text: string): string[];
5
+ /** One warning line per journey with no role, in the person's language. */
6
+ export declare function journeyRoleWarnings(root: string): Promise<string[]>;
@@ -0,0 +1,60 @@
1
+ // Journeys say who they are for: each row of `plan/journeys.md` names its Actor, and each journey in
2
+ // `prototype/journeys.ts` its `role` (one of the people in plan/journeys.md). A static read; a
3
+ // journey with no role is a warning, never a failure.
4
+ import { readFile } from 'node:fs/promises';
5
+ import { join } from 'node:path';
6
+ import { createI18n } from '@buffcore/i18n';
7
+ import { en } from './tells.en.js';
8
+ import { es } from './tells.es.js';
9
+ const messages = createI18n({ catalogs: [{ en, es }] });
10
+ const cells = (line) => line
11
+ .trim()
12
+ .replace(/^\||\|$/g, '')
13
+ .split('|')
14
+ .map((cell) => cell.replace(/\*\*|`/g, '').trim());
15
+ /** Journey names in `plan/journeys.md` tables whose Actor column is missing or empty. */
16
+ export function planJourneysWithoutRole(text) {
17
+ const names = [];
18
+ let columns = [];
19
+ for (const line of text.split(/\r?\n/)) {
20
+ if (!line.trim().startsWith('|')) {
21
+ columns = [];
22
+ continue;
23
+ }
24
+ const row = cells(line);
25
+ if (row.includes('Journey')) {
26
+ columns = row;
27
+ continue;
28
+ }
29
+ const name = row[columns.indexOf('Journey')] ?? '';
30
+ if (!columns.length || !name || /^[-:\s]+$/.test(name))
31
+ continue;
32
+ const actor = columns.includes('Actor') ? (row[columns.indexOf('Actor')] ?? '') : '';
33
+ if (!actor)
34
+ names.push(name);
35
+ }
36
+ return names;
37
+ }
38
+ /** Journey keys in `prototype/journeys.ts` whose entry has no `role`. */
39
+ export function prototypeJourneysWithoutRole(text) {
40
+ return text
41
+ .split(/(?=\bkey:\s*['"])/)
42
+ .slice(1)
43
+ .filter((entry) => !/\brole:\s*['"`]/.test(entry))
44
+ .map((entry) => /^key:\s*['"]([^'"]+)/.exec(entry)?.[1] ?? '')
45
+ .filter(Boolean);
46
+ }
47
+ const readText = (path) => readFile(path, 'utf8').catch(() => '');
48
+ /** One warning line per journey with no role, in the person's language. */
49
+ export async function journeyRoleWarnings(root) {
50
+ const locale = /^es(?:[-_.]|$)/i.test(process.env.LC_ALL || process.env.LANG || '') ? 'es' : 'en';
51
+ const [plan, prototype] = await Promise.all([
52
+ readText(join(root, 'plan', 'journeys.md')),
53
+ readText(join(root, 'prototype', 'journeys.ts')),
54
+ ]);
55
+ const warn = (file) => (journey) => messages.t(locale, 'design.journeyRole', { file, journey });
56
+ return [
57
+ ...planJourneysWithoutRole(plan).map(warn('plan/journeys.md')),
58
+ ...prototypeJourneysWithoutRole(prototype).map(warn('prototype/journeys.ts')),
59
+ ];
60
+ }
@@ -0,0 +1,3 @@
1
+ import type { Tell } from './tells.ts';
2
+ /** Each picture `design/references.md` names (in backticks or as a link) that is not there. */
3
+ export declare function missingReferences(root: string): Promise<Tell[]>;
@@ -0,0 +1,25 @@
1
+ // `design/references.md` keeps the reference study and the paths of its pictures; the pictures stay
2
+ // outside the repository, so a path can stop existing (another computer, a cleared folder).
3
+ import { existsSync } from 'node:fs';
4
+ import { readFile } from 'node:fs/promises';
5
+ import { homedir } from 'node:os';
6
+ import { join, resolve } from 'node:path';
7
+ const PICTURE = /`([^`\r\n]+?\.(?:png|jpe?g|webp|gif|avif))`|\]\(([^)\s]+?\.(?:png|jpe?g|webp|gif|avif))\)/gi;
8
+ /** Each picture `design/references.md` names (in backticks or as a link) that is not there. */
9
+ export async function missingReferences(root) {
10
+ const file = join(root, 'design', 'references.md');
11
+ if (!existsSync(file))
12
+ return [];
13
+ const tells = [];
14
+ for (const [index, line] of (await readFile(file, 'utf8')).split(/\r?\n/).entries())
15
+ for (const [, quoted, linked] of line.matchAll(PICTURE)) {
16
+ const path = quoted ?? linked ?? '';
17
+ // A web address or a network share is never looked up: the check stays on this computer.
18
+ if (/^(?:https?:\/\/|\\\\|\/\/)/i.test(path))
19
+ continue;
20
+ const home = /^~[/]/.test(path);
21
+ if (!existsSync(home ? join(homedir(), path.slice(2)) : resolve(root, path)))
22
+ tells.push({ kind: 'reference', file: 'design/references.md', line: index + 1, path });
23
+ }
24
+ return tells;
25
+ }
@@ -12,9 +12,9 @@ export function hintLines(tells) {
12
12
  for (const [index, group] of groups.entries()) {
13
13
  // Leave one line for each kind still to come. Counts share the final line for their kind.
14
14
  const visible = Math.min(3, group.length, 15 - lines.length - (groups.length - index - 1));
15
- for (const [row, { kind, file, line, family }] of group.slice(0, visible).entries()) {
15
+ for (const [row, { kind, file, line, family, path }] of group.slice(0, visible).entries()) {
16
16
  const location = `${file}:${lineNumber.format(line)}`;
17
- const detail = t(`design.${kind}`, { family });
17
+ const detail = t(`design.${kind}`, { family, path });
18
18
  const remaining = group.length - visible;
19
19
  const more = remaining && row === visible - 1
20
20
  ? t('design.moreHints', { count: number.format(remaining) })
@@ -1,8 +1,10 @@
1
1
  export interface Tell {
2
- kind: 'titles' | 'mono' | 'chips' | 'cards' | 'tints' | 'width' | 'font';
2
+ kind: 'titles' | 'mono' | 'chips' | 'cards' | 'tints' | 'width' | 'font' | 'reference';
3
3
  file: string;
4
4
  line: number;
5
5
  family?: string;
6
+ /** A picture `design/references.md` names. */
7
+ path?: string;
6
8
  }
7
9
  /** For most patterns, one location per affected file is sufficient. */
8
10
  export declare function screenTells(file: string, source: string): Tell[];
@@ -8,4 +8,6 @@ export declare const en: {
8
8
  'design.tints': string;
9
9
  'design.width': string;
10
10
  'design.font': string;
11
+ 'design.journeyRole': string;
12
+ 'design.reference': string;
11
13
  };
@@ -8,4 +8,6 @@ export const en = {
8
8
  'design.tints': 'Rows use several tinted boxes. Give rows a shared background.',
9
9
  'design.width': 'The screen is capped at a narrow width. Give wide screens their own layout.',
10
10
  'design.font': 'No font loading or bundle found for {family}. Load that family with the app fonts.',
11
+ 'design.journeyRole': 'Warning {file} the journey {journey} names no role: say who it is for, one of the people in plan/journeys.md.',
12
+ 'design.reference': 'The reference picture {path} is not on this computer. Capture it again, or remove its line.',
11
13
  };
@@ -8,4 +8,6 @@ export const es = {
8
8
  'design.tints': 'Las filas usan fondos de varios colores. Dales un fondo común.',
9
9
  'design.width': 'La pantalla tiene un ancho máximo reducido. Diseña una disposición propia para pantallas anchas.',
10
10
  'design.font': 'No se encontró cómo se carga ni se incluye la fuente {family}. Cárgala junto con las fuentes de la aplicación.',
11
+ 'design.journeyRole': 'Aviso {file} el recorrido {journey} no nombra un rol: di para quién es, una de las personas de plan/journeys.md.',
12
+ 'design.reference': 'La imagen de referencia {path} no está en este equipo. Vuelve a capturarla o quita su línea.',
11
13
  };
@@ -1,4 +1,5 @@
1
1
  // Advisory patterns in common JSX and theme declarations. These reads don't resolve expressions.
2
+ import { fontFileSuffix } from '@buffcore/tokens';
2
3
  import { code } from './rules.js';
3
4
  // Quoted attributes and inline styles can contain angle brackets. Only pair matching JSX tags.
4
5
  const TAG = /<(\/?)([A-Za-z][\w.:-]*|(?=>))((?:[^<>{}'"`]|"[^"\n]*"|'[^'\n]*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/g;
@@ -209,11 +210,13 @@ export function unloadedFonts(fonts, sources, assets) {
209
210
  for (const [, quoted, bare] of text.matchAll(FONT_REQUIRE))
210
211
  names.add(normalize(quoted ?? bare ?? ''));
211
212
  }
212
- for (const asset of assets) {
213
- const face = (asset.split(/[/\\]/).at(-1) ?? '')
214
- .replace(FONT_ASSET, '')
215
- .replace(/[-_](?:regular|medium|semibold|bold|italic|variable|vf)(?:[-_].*)?$/i, '');
216
- names.add(normalize(face));
217
- }
218
- return fonts.filter(({ family }) => family && !names.has(normalize(family)));
213
+ // A font file is named from its family (`InterVariable.woff2`, `JetBrainsMono-Bold.ttf`), the
214
+ // rule the console loads `design/fonts/` by (`themeFontFiles`); `RobotoMono` is not "Roboto".
215
+ const stems = assets.map((asset) => (asset.split(/[/\\]/).at(-1) ?? '').replace(FONT_ASSET, ''));
216
+ return fonts.filter(({ family }) => {
217
+ const name = normalize(family ?? '');
218
+ if (!name || names.has(name))
219
+ return false;
220
+ return !stems.some((stem) => fontFileSuffix(stem, family ?? '') !== undefined);
221
+ });
219
222
  }
@@ -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 { claimBlock } from './port-claims.js';
10
11
  import { containersOf, devCompose } from './services/compose.js';
11
12
  import { runComposeUp } from './services/compose-up.js';
12
13
  import { serviceEnvWithExample, unavailableService } from './services/reachability.js';
@@ -177,6 +178,8 @@ export async function dev() {
177
178
  const root = findRoot();
178
179
  const env = loadEnv(root);
179
180
  checkApiAddress(env);
181
+ // This product's block stays claimed, so `ape create` picks another one even while it is stopped.
182
+ await claimBlock(root, String(Math.floor(env.APE_API_PORT / 100)));
180
183
  const product = await loadProduct(root);
181
184
  await startDevServices(root, product);
182
185
  const app = uiFolder(root, 'app');
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Port blocks other products on this computer have claimed, so `ape create` picks another one
3
+ * even while those products are stopped. Two sources: product folders beside the new one (a
4
+ * `buffcore.config.ts`, its block from `.env` or `.env.example`), and `ports.json` in the user's
5
+ * config folder, which create and `ape dev` keep. Anything unreadable counts as no claim: the
6
+ * choice is then today's, by free ports only.
7
+ */
8
+ export interface PortClaims {
9
+ claimed: (target: string) => ReadonlySet<string>;
10
+ claim: (folder: string, block: string) => Promise<void>;
11
+ }
12
+ /** The user's BuffCore config folder: `APE_CONFIG_HOME`, else the platform's own. */
13
+ export declare function configHome(env?: NodeJS.ProcessEnv): string;
14
+ /** Folder → block, as `ports.json` lists them; a missing or malformed file lists none. */
15
+ export declare function readClaims(home?: string): Record<string, number>;
16
+ /** A product folder's block, from the API port its `.env` or `.env.example` names (not a link). */
17
+ export declare function folderBlock(folder: string): string | undefined;
18
+ /** Every block claimed by a product other than the one at `target`. */
19
+ export declare function claimedBlocks(target: string, home?: string): ReadonlySet<string>;
20
+ /** Records a product's block; folders that are gone drop out. Never fails the command. */
21
+ export declare function claimBlock(folder: string, block: string, home?: string): Promise<void>;
22
+ /** This computer's claims, in the user's config folder. */
23
+ export declare const machineClaims: PortClaims;